Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <fcntl.h>
10 : : #include <stdio.h>
11 : : #include <stdint.h>
12 : : #include <stdlib.h>
13 : : #include <string.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : : #include <sys/queue.h>
17 : :
18 : : #include <rte_common.h>
19 : : #include <rte_byteorder.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_cycles.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_malloc.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_ring.h>
32 : : #include <rte_mempool.h>
33 : : #include <rte_interrupts.h>
34 : : #include <rte_ether.h>
35 : : #include <rte_ethdev.h>
36 : : #include <rte_string_fns.h>
37 : : #include <rte_devargs.h>
38 : : #include <rte_flow.h>
39 : : #ifdef RTE_LIB_GRO
40 : : #include <rte_gro.h>
41 : : #endif
42 : : #include <rte_mbuf_dyn.h>
43 : : #include <rte_trace.h>
44 : :
45 : : #include <cmdline_rdline.h>
46 : : #include <cmdline_parse.h>
47 : : #include <cmdline_parse_num.h>
48 : : #include <cmdline_parse_bool.h>
49 : : #include <cmdline_parse_string.h>
50 : : #include <cmdline_parse_ipaddr.h>
51 : : #include <cmdline_parse_etheraddr.h>
52 : : #include <cmdline_socket.h>
53 : : #include <cmdline.h>
54 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 : : #include <rte_pmd_dpaa.h>
56 : : #endif
57 : : #ifdef RTE_NET_IXGBE
58 : : #include <rte_pmd_ixgbe.h>
59 : : #endif
60 : : #ifdef RTE_NET_I40E
61 : : #include <rte_pmd_i40e.h>
62 : : #endif
63 : : #ifdef RTE_NET_BNXT
64 : : #include <rte_pmd_bnxt.h>
65 : : #endif
66 : : #include "testpmd.h"
67 : : #include "cmdline_cman.h"
68 : : #include "cmdline_mtr.h"
69 : : #include "cmdline_tm.h"
70 : : #include "bpf_cmd.h"
71 : :
72 : : static struct cmdline *testpmd_cl;
73 : : static cmdline_parse_ctx_t *main_ctx;
74 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
75 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
76 : :
77 : : /* *** Help command with introduction. *** */
78 : : struct cmd_help_brief_result {
79 : : cmdline_fixed_string_t help;
80 : : };
81 : :
82 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
83 : : struct cmdline *cl,
84 : : __rte_unused void *data)
85 : : {
86 : 0 : cmdline_printf(
87 : : cl,
88 : : "\n"
89 : : "Help is available for the following sections:\n\n"
90 : : " help control : Start and stop forwarding.\n"
91 : : " help display : Displaying port, stats and config "
92 : : "information.\n"
93 : : " help config : Configuration information.\n"
94 : : " help ports : Configuring ports.\n"
95 : : " help filters : Filters configuration help.\n"
96 : : " help traffic_management : Traffic Management commands.\n"
97 : : " help devices : Device related commands.\n"
98 : : " help drivers : Driver specific commands.\n"
99 : : " help all : All of the above sections.\n\n"
100 : : );
101 : :
102 : 0 : }
103 : :
104 : : static cmdline_parse_token_string_t cmd_help_brief_help =
105 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
106 : :
107 : : static cmdline_parse_inst_t cmd_help_brief = {
108 : : .f = cmd_help_brief_parsed,
109 : : .data = NULL,
110 : : .help_str = "help: Show help",
111 : : .tokens = {
112 : : (void *)&cmd_help_brief_help,
113 : : NULL,
114 : : },
115 : : };
116 : :
117 : : /* *** Help command with help sections. *** */
118 : : struct cmd_help_long_result {
119 : : cmdline_fixed_string_t help;
120 : : cmdline_fixed_string_t section;
121 : : };
122 : :
123 : 0 : static void cmd_help_long_parsed(void *parsed_result,
124 : : struct cmdline *cl,
125 : : __rte_unused void *data)
126 : : {
127 : : int show_all = 0;
128 : : struct cmd_help_long_result *res = parsed_result;
129 : :
130 : 0 : if (!strcmp(res->section, "all"))
131 : : show_all = 1;
132 : :
133 : 0 : if (show_all || !strcmp(res->section, "control")) {
134 : :
135 : 0 : cmdline_printf(
136 : : cl,
137 : : "\n"
138 : : "Control forwarding:\n"
139 : : "-------------------\n\n"
140 : :
141 : : "start\n"
142 : : " Start packet forwarding with current configuration.\n\n"
143 : :
144 : : "start tx_first\n"
145 : : " Start packet forwarding with current config"
146 : : " after sending one burst of packets.\n\n"
147 : :
148 : : "stop\n"
149 : : " Stop packet forwarding, and display accumulated"
150 : : " statistics.\n\n"
151 : :
152 : : "quit\n"
153 : : " Quit to prompt.\n\n"
154 : : );
155 : : }
156 : :
157 : 0 : if (show_all || !strcmp(res->section, "display")) {
158 : :
159 : 0 : cmdline_printf(
160 : : cl,
161 : : "\n"
162 : : "Display:\n"
163 : : "--------\n\n"
164 : :
165 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
166 : : " Display information for port_id, or all.\n\n"
167 : :
168 : : "show port info (port_id) representor\n"
169 : : " Show supported representors for a specific port\n\n"
170 : :
171 : : "show port port_id (module_eeprom|eeprom)\n"
172 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
173 : :
174 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
175 : : " value (value) offset (offset)\n"
176 : : " Set the device eeprom for certain port.\nNote:\n"
177 : : " This is a high-risk command and its misuse may"
178 : : " result in unexpected behaviour from the NIC.\n"
179 : : " By inserting \"accept_risk\" into the command, the"
180 : : " user is acknowledging and taking responsibility for"
181 : : " this risk.\n\n"
182 : :
183 : : "show port X rss reta (size) (mask0,mask1,...)\n"
184 : : " Display the rss redirection table entry indicated"
185 : : " by masks on port X. size is used to indicate the"
186 : : " hardware supported reta size\n\n"
187 : :
188 : : "show port (port_id) rss-hash [key | algorithm]\n"
189 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
190 : :
191 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
192 : : " Clear information for port_id, or all.\n\n"
193 : :
194 : : "show (rxq|txq) info (port_id) (queue_id)\n"
195 : : " Display information for configured RX/TX queue.\n\n"
196 : :
197 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
198 : : " Display the given configuration.\n\n"
199 : :
200 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
201 : : " Display an RX descriptor of a port RX queue.\n\n"
202 : :
203 : : "read txd (port_id) (queue_id) (txd_id)\n"
204 : : " Display a TX descriptor of a port TX queue.\n\n"
205 : :
206 : : "show vf stats (port_id) (vf_id)\n"
207 : : " Display a VF's statistics.\n\n"
208 : :
209 : : "clear vf stats (port_id) (vf_id)\n"
210 : : " Reset a VF's statistics.\n\n"
211 : :
212 : : "show port meter stats (port_id) (meter_id) (clear)\n"
213 : : " Get meter stats on a port\n\n"
214 : :
215 : : "show fwd stats all\n"
216 : : " Display statistics for all fwd engines.\n\n"
217 : :
218 : : "clear fwd stats all\n"
219 : : " Clear statistics for all fwd engines.\n\n"
220 : :
221 : : "show port (port_id) rx_offload capabilities\n"
222 : : " List all per queue and per port Rx offloading"
223 : : " capabilities of a port\n\n"
224 : :
225 : : "show port (port_id) rx_offload configuration\n"
226 : : " List port level and all queue level"
227 : : " Rx offloading configuration\n\n"
228 : :
229 : : "show port (port_id) tx_offload capabilities\n"
230 : : " List all per queue and per port"
231 : : " Tx offloading capabilities of a port\n\n"
232 : :
233 : : "show port (port_id) tx_offload configuration\n"
234 : : " List port level and all queue level"
235 : : " Tx offloading configuration\n\n"
236 : :
237 : : "show port (port_id) tx_metadata\n"
238 : : " Show Tx metadata value set"
239 : : " for a specific port\n\n"
240 : :
241 : : "show port (port_id) ptypes\n"
242 : : " Show port supported ptypes"
243 : : " for a specific port\n\n"
244 : :
245 : : "show device info (<identifier>|all)"
246 : : " Show general information about devices probed.\n\n"
247 : :
248 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
249 : : " Show status of rx|tx descriptor.\n\n"
250 : :
251 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
252 : : " Show current number of used descriptor count for rx|tx.\n\n"
253 : :
254 : : "show port (port_id) macs|mcast_macs"
255 : : " Display list of mac addresses added to port.\n\n"
256 : :
257 : : "show port (port_id) flow transfer proxy\n"
258 : : " Display proxy port to manage transfer flows\n\n"
259 : :
260 : : "show port (port_id) fec capabilities"
261 : : " Show fec capabilities of a port.\n\n"
262 : :
263 : : "show port (port_id) fec_mode"
264 : : " Show fec mode of a port.\n\n"
265 : :
266 : : "show port (port_id) flow_ctrl"
267 : : " Show flow control info of a port.\n\n"
268 : :
269 : : "dump_physmem\n"
270 : : " Dumps all physical memory segment layouts\n\n"
271 : :
272 : : "dump_socket_mem\n"
273 : : " Dumps the memory usage of all sockets\n\n"
274 : :
275 : : "dump_memzone\n"
276 : : " Dumps the layout of all memory zones\n\n"
277 : :
278 : : "dump_struct_sizes\n"
279 : : " Dumps the size of all memory structures\n\n"
280 : :
281 : : "dump_ring\n"
282 : : " Dumps the status of all or specific element in DPDK rings\n\n"
283 : :
284 : : "dump_mempool\n"
285 : : " Dumps the statistics of all or specific memory pool\n\n"
286 : :
287 : : "dump_devargs\n"
288 : : " Dumps the user device list\n\n"
289 : :
290 : : "dump_lcores\n"
291 : : " Dumps the logical cores list\n\n"
292 : :
293 : : "dump_trace\n"
294 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
295 : :
296 : : "dump_log_types\n"
297 : : " Dumps the log level for all the dpdk modules\n\n"
298 : :
299 : : "show port (port_id) speed_lanes capabilities"
300 : : " Show speed lanes capabilities of a port.\n\n"
301 : : );
302 : : }
303 : :
304 : 0 : if (show_all || !strcmp(res->section, "config")) {
305 : 0 : cmdline_printf(
306 : : cl,
307 : : "\n"
308 : : "Configuration:\n"
309 : : "--------------\n"
310 : : "Configuration changes only become active when"
311 : : " forwarding is started/restarted.\n\n"
312 : :
313 : : "set default\n"
314 : : " Reset forwarding to the default configuration.\n\n"
315 : :
316 : : "set verbose (level)\n"
317 : : " Set the debug verbosity level X.\n\n"
318 : :
319 : : "set log global|(type) (level)\n"
320 : : " Set the log level.\n\n"
321 : :
322 : : "set nbport (num)\n"
323 : : " Set number of ports.\n\n"
324 : :
325 : : "set nbcore (num)\n"
326 : : " Set number of cores.\n\n"
327 : :
328 : : "set coremask (mask)\n"
329 : : " Set the forwarding cores hexadecimal mask.\n\n"
330 : :
331 : : "set portmask (mask)\n"
332 : : " Set the forwarding ports hexadecimal mask.\n\n"
333 : :
334 : : "set burst (num)\n"
335 : : " Set number of packets per burst.\n\n"
336 : :
337 : : "set burst tx delay (microseconds) retry (num)\n"
338 : : " Set the transmit delay time and number of retries,"
339 : : " effective when retry is enabled.\n\n"
340 : :
341 : : "set rxoffs (x[,y]*)\n"
342 : : " Set the offset of each packet segment on"
343 : : " receiving if split feature is engaged."
344 : : " Affects only the queues configured with split"
345 : : " offloads.\n\n"
346 : :
347 : : "set rxpkts (x[,y]*)\n"
348 : : " Set the length of each segment to scatter"
349 : : " packets on receiving if split feature is engaged."
350 : : " Affects only the queues configured with split"
351 : : " offloads.\n\n"
352 : :
353 : : "set rxhdrs (eth[,ipv4])*\n"
354 : : " Set the protocol hdr of each segment to scatter"
355 : : " packets on receiving if split feature is engaged."
356 : : " Affects only the queues configured with split"
357 : : " offloads.\n"
358 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
359 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
360 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
361 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
362 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
363 : :
364 : : "set txpkts (x[,y]*)\n"
365 : : " Set the length of each segment of TXONLY"
366 : : " and optionally CSUM packets.\n\n"
367 : :
368 : : "set txsplit (off|on|rand)\n"
369 : : " Set the split policy for the TX packets."
370 : : " Right now only applicable for CSUM and TXONLY"
371 : : " modes\n\n"
372 : :
373 : : "set txtimes (x, y)\n"
374 : : " Set the scheduling on timestamps"
375 : : " timings for the TXONLY mode\n\n"
376 : :
377 : : "set corelist (x[,y]*)\n"
378 : : " Set the list of forwarding cores.\n\n"
379 : :
380 : : "set portlist (x[,y]*)\n"
381 : : " Set the list of forwarding ports.\n\n"
382 : :
383 : : "set port setup on (iterator|event)\n"
384 : : " Select how attached port is retrieved for setup.\n\n"
385 : :
386 : : "set tx loopback (port_id) (on|off)\n"
387 : : " Enable or disable tx loopback.\n\n"
388 : :
389 : : "set all queues drop (port_id) (on|off)\n"
390 : : " Set drop enable bit for all queues.\n\n"
391 : :
392 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
393 : : " Set MAC antispoof for a VF from the PF.\n\n"
394 : :
395 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
396 : : " Set the VLAN strip for a queue on a port.\n\n"
397 : :
398 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
399 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
400 : :
401 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
402 : : " Set VLAN insert for a VF from the PF.\n\n"
403 : :
404 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
405 : : " Set VLAN antispoof for a VF from the PF.\n\n"
406 : :
407 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
408 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
409 : :
410 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
411 : : " Set the VLAN TPID for Packet Filtering on"
412 : : " a port\n\n"
413 : :
414 : : "rx_vlan add (vlan_id|all) (port_id)\n"
415 : : " Add a vlan_id, or all identifiers, to the set"
416 : : " of VLAN identifiers filtered by port_id.\n\n"
417 : :
418 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
419 : : " Remove a vlan_id, or all identifiers, from the set"
420 : : " of VLAN identifiers filtered by port_id.\n\n"
421 : :
422 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
423 : : " Add a vlan_id, to the set of VLAN identifiers"
424 : : "filtered for VF(s) from port_id.\n\n"
425 : :
426 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
427 : : " Remove a vlan_id, to the set of VLAN identifiers"
428 : : "filtered for VF(s) from port_id.\n\n"
429 : :
430 : : "rx_vxlan_port add (udp_port) (port_id)\n"
431 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
432 : :
433 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
434 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
435 : :
436 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
437 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
438 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
439 : :
440 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
441 : : " Set port based TX VLAN insertion.\n\n"
442 : :
443 : : "tx_vlan reset (port_id)\n"
444 : : " Disable hardware insertion of a VLAN header in"
445 : : " packets sent on a port.\n\n"
446 : :
447 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
448 : : " Select hardware or software calculation of the"
449 : : " checksum when transmitting a packet using the"
450 : : " csum forward engine.\n"
451 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
452 : : " outer-ip concerns the outer IP layer in"
453 : : " outer-udp concerns the outer UDP layer in"
454 : : " case the packet is recognized as a tunnel packet by"
455 : : " the forward engine (vxlan, gre and ipip are supported)\n"
456 : : " Please check the NIC datasheet for HW limits.\n\n"
457 : :
458 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
459 : : " If disabled, treat tunnel packets as non-tunneled"
460 : : " packets (treat inner headers as payload). The port\n"
461 : : " argument is the port used for TX in csum forward"
462 : : " engine.\n\n"
463 : :
464 : : "csum show (port_id)\n"
465 : : " Display tx checksum offload configuration\n\n"
466 : :
467 : : "tso set (segsize) (portid)\n"
468 : : " Enable TCP Segmentation Offload in csum forward"
469 : : " engine.\n"
470 : : " Please check the NIC datasheet for HW limits.\n\n"
471 : :
472 : : "tso show (portid)"
473 : : " Display the status of TCP Segmentation Offload.\n\n"
474 : :
475 : : #ifdef RTE_LIB_GRO
476 : : "set port (port_id) gro on|off\n"
477 : : " Enable or disable Generic Receive Offload in"
478 : : " csum forwarding engine.\n\n"
479 : :
480 : : "show port (port_id) gro\n"
481 : : " Display GRO configuration.\n\n"
482 : :
483 : : "set gro flush (cycles)\n"
484 : : " Set the cycle to flush GROed packets from"
485 : : " reassembly tables.\n\n"
486 : : #endif
487 : :
488 : : #ifdef RTE_LIB_GSO
489 : : "set port (port_id) gso (on|off)"
490 : : " Enable or disable Generic Segmentation Offload in"
491 : : " csum forwarding engine.\n\n"
492 : :
493 : : "set gso segsz (length)\n"
494 : : " Set max packet length for output GSO segments,"
495 : : " including packet header and payload.\n\n"
496 : :
497 : : "show port (port_id) gso\n"
498 : : " Show GSO configuration.\n\n"
499 : : #endif
500 : :
501 : : "set fwd (%s)\n"
502 : : " Set packet forwarding mode.\n\n"
503 : :
504 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
505 : : " Add a MAC address on port_id.\n\n"
506 : :
507 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
508 : : " Remove a MAC address from port_id.\n\n"
509 : :
510 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
511 : : " Set the default MAC address for port_id.\n\n"
512 : :
513 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
514 : : " Add a MAC address for a VF on the port.\n\n"
515 : :
516 : : "mcast_addr add (port_id) (mcast_addr)\n"
517 : : " Add a multicast MAC addresses on port_id.\n\n"
518 : :
519 : : "mcast_addr remove (port_id) (mcast_addr)\n"
520 : : " Remove a multicast MAC address from port_id.\n\n"
521 : :
522 : : "mcast_addr flush (port_id)\n"
523 : : " Flush all multicast MAC addresses on port_id.\n\n"
524 : :
525 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
526 : : " Set the MAC address for a VF from the PF.\n\n"
527 : :
528 : : "set eth-peer (port_id) (peer_addr)\n"
529 : : " set the peer address for certain port.\n\n"
530 : :
531 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
532 : : " Add/Remove a or all unicast hash filter(s)"
533 : : "from port X.\n\n"
534 : :
535 : : "set promisc (port_id|all) (on|off)\n"
536 : : " Set the promiscuous mode on port_id, or all.\n\n"
537 : :
538 : : "set allmulti (port_id|all) (on|off)\n"
539 : : " Set the allmulti mode on port_id, or all.\n\n"
540 : :
541 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
542 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
543 : : " (on|off) autoneg (on|off) (port_id)\n"
544 : : "set flow_ctrl rx (on|off) (portid)\n"
545 : : "set flow_ctrl tx (on|off) (portid)\n"
546 : : "set flow_ctrl high_water (high_water) (portid)\n"
547 : : "set flow_ctrl low_water (low_water) (portid)\n"
548 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
549 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
550 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
551 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
552 : : " Set the link flow control parameter on a port.\n\n"
553 : :
554 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
555 : : " (low_water) (pause_time) (priority) (port_id)\n"
556 : : " Set the priority flow control parameter on a"
557 : : " port.\n\n"
558 : :
559 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
560 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
561 : : " Set the queue priority flow control parameter on a"
562 : : " given Rx and Tx queues of a port.\n\n"
563 : :
564 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
565 : : " set available descriptors threshold for Rx queue\n\n"
566 : :
567 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
568 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
569 : : " queue on port.\n"
570 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
571 : : " on port 0 to mapping 5.\n\n"
572 : :
573 : : "set xstats-hide-zero on|off\n"
574 : : " Set the option to hide the zero values"
575 : : " for xstats display.\n"
576 : :
577 : : "set record-core-cycles on|off\n"
578 : : " Set the option to enable measurement of CPU cycles.\n"
579 : :
580 : : "set record-burst-stats on|off\n"
581 : : " Set the option to enable display of RX and TX bursts.\n"
582 : :
583 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
584 : : " Enable/Disable a VF receive/transmit from a port\n\n"
585 : :
586 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
587 : : "|MPE) (on|off)\n"
588 : : " AUPE:accepts untagged VLAN;"
589 : : "ROPE:accept unicast hash\n\n"
590 : : " BAM:accepts broadcast packets;"
591 : : "MPE:accepts all multicast packets\n\n"
592 : : " Enable/Disable a VF receive mode of a port\n\n"
593 : :
594 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
595 : : " Set rate limit for a queue of a port\n\n"
596 : :
597 : : "set port (port_id) vf (vf_id) rate (rate_num) "
598 : : "queue_mask (queue_mask_value)\n"
599 : : " Set rate limit for queues in VF of a port\n\n"
600 : :
601 : : "set flush_rx (on|off)\n"
602 : : " Flush (default) or don't flush RX streams before"
603 : : " forwarding. Mainly used with PCAP drivers.\n\n"
604 : :
605 : : "set link-up port (port_id)\n"
606 : : " Set link up for a port.\n\n"
607 : :
608 : : "set link-down port (port_id)\n"
609 : : " Set link down for a port.\n\n"
610 : :
611 : : "set port (port_id) ptype_mask (ptype_mask)\n"
612 : : " set packet types classification for a specific port\n\n"
613 : :
614 : : "show port meter cap (port_id)\n"
615 : : " Show port meter capability information\n\n"
616 : :
617 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
618 : : " meter profile add - srtcm rfc 2697\n\n"
619 : :
620 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
621 : : " meter profile add - trtcm rfc 2698\n\n"
622 : :
623 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
624 : : " meter profile add - trtcm rfc 4115\n\n"
625 : :
626 : : "del port meter profile (port_id) (profile_id)\n"
627 : : " meter profile delete\n\n"
628 : :
629 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
630 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
631 : : "(dscp_tbl_entry63)]\n"
632 : : " meter create\n\n"
633 : :
634 : : "enable port meter (port_id) (mtr_id)\n"
635 : : " meter enable\n\n"
636 : :
637 : : "disable port meter (port_id) (mtr_id)\n"
638 : : " meter disable\n\n"
639 : :
640 : : "del port meter (port_id) (mtr_id)\n"
641 : : " meter delete\n\n"
642 : :
643 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
644 : : "y_actions (actions) r_actions (actions)\n"
645 : : " meter policy add\n\n"
646 : :
647 : : "del port meter policy (port_id) (policy_id)\n"
648 : : " meter policy delete\n\n"
649 : :
650 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
651 : : " meter update meter profile\n\n"
652 : :
653 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
654 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
655 : : " update meter dscp table entries\n\n"
656 : :
657 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
658 : : "(action0) [(action1) (action2)]\n"
659 : : " meter update policer action\n\n"
660 : :
661 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
662 : : " meter update stats\n\n"
663 : :
664 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
665 : : " set fec mode for a specific port\n\n"
666 : :
667 : : "show port cman capa (port_id)\n"
668 : : " Show congestion management capabilities\n\n"
669 : :
670 : : "show port cman config (port_id)\n"
671 : : " Show congestion management configuration\n\n"
672 : :
673 : : "set port cman config (port_id) (queue_id) default | "
674 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
675 : : "(max_thresh) (prob_inv)]\n"
676 : : " Set congestion management configuration\n\n"
677 : :
678 : : "set port (port_id) led (on|off)\n"
679 : : " Set a controllable LED associated with a certain"
680 : : " port on or off.\n\n"
681 : :
682 : : , list_pkt_forwarding_modes()
683 : : );
684 : : }
685 : :
686 : 0 : if (show_all || !strcmp(res->section, "ports")) {
687 : :
688 : 0 : cmdline_printf(
689 : : cl,
690 : : "\n"
691 : : "Port Operations:\n"
692 : : "----------------\n\n"
693 : :
694 : : "port start (port_id|all)\n"
695 : : " Start all ports or port_id.\n\n"
696 : :
697 : : "port stop (port_id|all)\n"
698 : : " Stop all ports or port_id.\n\n"
699 : :
700 : : "port close (port_id|all)\n"
701 : : " Close all ports or port_id.\n\n"
702 : :
703 : : "port reset (port_id|all)\n"
704 : : " Reset all ports or port_id.\n\n"
705 : :
706 : : "port attach (ident)\n"
707 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
708 : :
709 : : "port detach (port_id)\n"
710 : : " Detach physical or virtual dev by port_id\n\n"
711 : :
712 : : "port config (port_id|all)"
713 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
714 : : " duplex (half|full|auto)\n"
715 : : " Set speed and duplex for all ports or port_id\n\n"
716 : :
717 : : "port config (port_id|all) loopback (mode)\n"
718 : : " Set loopback mode for all ports or port_id\n\n"
719 : :
720 : : "port config all (rxq|txq|rxd|txd) (value)\n"
721 : : " Set number for rxq/txq/rxd/txd.\n\n"
722 : :
723 : : "port config all max-pkt-len (value)\n"
724 : : " Set the max packet length.\n\n"
725 : :
726 : : "port config all max-lro-pkt-size (value)\n"
727 : : " Set the max LRO aggregated packet size.\n\n"
728 : :
729 : : "port config all drop-en (on|off)\n"
730 : : " Enable or disable packet drop on all RX queues of all ports when no "
731 : : "receive buffers available.\n\n"
732 : :
733 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
734 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
735 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
736 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
737 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
738 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
739 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
740 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
741 : : " Set the RSS mode.\n\n"
742 : :
743 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
744 : : " Set the RSS redirection table.\n\n"
745 : :
746 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
747 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
748 : : " Set the RSS hash algorithm.\n\n"
749 : :
750 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
751 : : " pfc (on|off)\n"
752 : : " Set the DCB mode.\n\n"
753 : :
754 : : "port config all burst (value)\n"
755 : : " Set the number of packets per burst.\n\n"
756 : :
757 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
758 : : " (value)\n"
759 : : " Set the ring prefetch/host/writeback threshold"
760 : : " for tx/rx queue.\n\n"
761 : :
762 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
763 : : " Set free threshold for rx/tx, or set"
764 : : " tx rs bit threshold.\n\n"
765 : : "port config mtu X value\n"
766 : : " Set the MTU of port X to a given value\n\n"
767 : :
768 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
769 : : " Set a rx/tx queue's ring size configuration, the new"
770 : : " value will take effect after command that (re-)start the port"
771 : : " or command that setup the specific queue\n\n"
772 : :
773 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
774 : : " Start/stop a rx/tx queue of port X. Only take effect"
775 : : " when port X is started\n\n"
776 : :
777 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
778 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
779 : : " take effect when port X is stopped.\n\n"
780 : :
781 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
782 : : " Setup a rx/tx queue of port X.\n\n"
783 : :
784 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
785 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
786 : :
787 : : "port config (port_id|all) rx_offload all|vlan_strip|"
788 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
789 : : "outer_ipv4_cksum|macsec_strip|"
790 : : "vlan_filter|vlan_extend|scatter|"
791 : : "buffer_split|timestamp|security|keep_crc on|off\n"
792 : : " Enable or disable a per port Rx offloading"
793 : : " on all Rx queues of a port\n\n"
794 : :
795 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
796 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
797 : : "outer_ipv4_cksum|macsec_strip|"
798 : : "vlan_filter|vlan_extend|scatter|"
799 : : "buffer_split|timestamp|security|keep_crc on|off\n"
800 : : " Enable or disable a per queue Rx offloading"
801 : : " only on a specific Rx queue\n\n"
802 : :
803 : : "port config (port_id|all) tx_offload all|vlan_insert|"
804 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
805 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
806 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
807 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
808 : : "security on|off\n"
809 : : " Enable or disable a per port Tx offloading"
810 : : " on all Tx queues of a port\n\n"
811 : :
812 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
813 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
814 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
815 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
816 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
817 : : " on|off\n"
818 : : " Enable or disable a per queue Tx offloading"
819 : : " only on a specific Tx queue\n\n"
820 : :
821 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
822 : : " Load an eBPF program as a callback"
823 : : " for particular RX/TX queue\n\n"
824 : :
825 : : "bpf-unload rx|tx (port) (queue)\n"
826 : : " Unload previously loaded eBPF program"
827 : : " for particular RX/TX queue\n\n"
828 : :
829 : : "port config (port_id) tx_metadata (value)\n"
830 : : " Set Tx metadata value per port. Testpmd will add this value"
831 : : " to any Tx packet sent from this port\n\n"
832 : :
833 : : "port config (port_id) dynf (name) set|clear\n"
834 : : " Register a dynf and Set/clear this flag on Tx. "
835 : : "Testpmd will set this value to any Tx packet "
836 : : "sent from this port\n\n"
837 : :
838 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
839 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
840 : :
841 : : "port config (port_id) txq (queue_id) affinity (value)\n"
842 : : " Map a Tx queue with an aggregated port "
843 : : "of the DPDK port\n\n"
844 : :
845 : : "port config (port_id|all) speed_lanes (value)\n"
846 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
847 : : );
848 : : }
849 : :
850 : 0 : if (show_all || !strcmp(res->section, "filters")) {
851 : :
852 : 0 : cmdline_printf(
853 : : cl,
854 : : "\n"
855 : : "filters:\n"
856 : : "--------\n\n"
857 : :
858 : : "flow validate {port_id}"
859 : : " [group {group_id}] [priority {level}]"
860 : : " [ingress] [egress]"
861 : : " pattern {item} [/ {item} [...]] / end"
862 : : " actions {action} [/ {action} [...]] / end\n"
863 : : " Check whether a flow rule can be created.\n\n"
864 : :
865 : : "flow create {port_id}"
866 : : " [group {group_id}] [priority {level}]"
867 : : " [ingress] [egress]"
868 : : " pattern {item} [/ {item} [...]] / end"
869 : : " actions {action} [/ {action} [...]] / end\n"
870 : : " Create a flow rule.\n\n"
871 : :
872 : : "flow destroy {port_id} rule {rule_id} [...]\n"
873 : : " Destroy specific flow rules.\n\n"
874 : :
875 : : "flow update {port_id} {rule_id}"
876 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
877 : : " Update a flow rule with new actions.\n\n"
878 : :
879 : : "flow flush {port_id}\n"
880 : : " Destroy all flow rules.\n\n"
881 : :
882 : : "flow query {port_id} {rule_id} {action}\n"
883 : : " Query an existing flow rule.\n\n"
884 : :
885 : : "flow list {port_id} [group {group_id}] [...]\n"
886 : : " List existing flow rules sorted by priority,"
887 : : " filtered by group identifiers.\n\n"
888 : :
889 : : "flow isolate {port_id} {boolean}\n"
890 : : " Restrict ingress traffic to the defined"
891 : : " flow rules\n\n"
892 : :
893 : : "flow aged {port_id} [destroy]\n"
894 : : " List and destroy aged flows"
895 : : " flow rules\n\n"
896 : :
897 : : "flow indirect_action {port_id} create"
898 : : " [action_id {indirect_action_id}]"
899 : : " [ingress] [egress]"
900 : : " action {action} / end\n"
901 : : " Create indirect action.\n\n"
902 : :
903 : : "flow indirect_action {port_id} update"
904 : : " {indirect_action_id} action {action} / end\n"
905 : : " Update indirect action.\n\n"
906 : :
907 : : "flow indirect_action {port_id} destroy"
908 : : " action_id {indirect_action_id} [...]\n"
909 : : " Destroy specific indirect actions.\n\n"
910 : :
911 : : "flow indirect_action {port_id} query"
912 : : " {indirect_action_id}\n"
913 : : " Query an existing indirect action.\n\n"
914 : :
915 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
916 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
917 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
918 : : " Configure the VXLAN encapsulation for flows.\n\n"
919 : :
920 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
921 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
922 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
923 : : " eth-dst (eth-dst)\n"
924 : : " Configure the VXLAN encapsulation for flows.\n\n"
925 : :
926 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
927 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
928 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
929 : : " eth-dst (eth-dst)\n"
930 : : " Configure the VXLAN encapsulation for flows.\n\n"
931 : :
932 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
933 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
934 : : " (eth-dst)\n"
935 : : " Configure the NVGRE encapsulation for flows.\n\n"
936 : :
937 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
938 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
939 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
940 : : " Configure the NVGRE encapsulation for flows.\n\n"
941 : :
942 : : "set raw_encap {flow items}\n"
943 : : " Configure the encapsulation with raw data.\n\n"
944 : :
945 : : "set raw_decap {flow items}\n"
946 : : " Configure the decapsulation with raw data.\n\n"
947 : :
948 : : );
949 : : }
950 : :
951 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
952 : 0 : cmdline_printf(
953 : : cl,
954 : : "\n"
955 : : "Traffic Management:\n"
956 : : "--------------\n"
957 : : "show port tm cap (port_id)\n"
958 : : " Display the port TM capability.\n\n"
959 : :
960 : : "show port tm level cap (port_id) (level_id)\n"
961 : : " Display the port TM hierarchical level capability.\n\n"
962 : :
963 : : "show port tm node cap (port_id) (node_id)\n"
964 : : " Display the port TM node capability.\n\n"
965 : :
966 : : "show port tm node type (port_id) (node_id)\n"
967 : : " Display the port TM node type.\n\n"
968 : :
969 : : "show port tm node stats (port_id) (node_id) (clear)\n"
970 : : " Display the port TM node stats.\n\n"
971 : :
972 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
973 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
974 : : " (packet_length_adjust) (packet_mode)\n"
975 : : " Add port tm node private shaper profile.\n\n"
976 : :
977 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
978 : : " Delete port tm node private shaper profile.\n\n"
979 : :
980 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
981 : : " (shaper_profile_id)\n"
982 : : " Add/update port tm node shared shaper.\n\n"
983 : :
984 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
985 : : " Delete port tm node shared shaper.\n\n"
986 : :
987 : : "set port tm node shaper profile (port_id) (node_id)"
988 : : " (shaper_profile_id)\n"
989 : : " Set port tm node shaper profile.\n\n"
990 : :
991 : : "add port tm node wred profile (port_id) (wred_profile_id)"
992 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
993 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
994 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
995 : : " Add port tm node wred profile.\n\n"
996 : :
997 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
998 : : " Delete port tm node wred profile.\n\n"
999 : :
1000 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1001 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1002 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1003 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1004 : : " Add port tm nonleaf node.\n\n"
1005 : :
1006 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1007 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1008 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1009 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1010 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1011 : :
1012 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1013 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1014 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1015 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1016 : : " Add port tm leaf node.\n\n"
1017 : :
1018 : : "del port tm node (port_id) (node_id)\n"
1019 : : " Delete port tm node.\n\n"
1020 : :
1021 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1022 : : " (priority) (weight)\n"
1023 : : " Set port tm node parent.\n\n"
1024 : :
1025 : : "suspend port tm node (port_id) (node_id)"
1026 : : " Suspend tm node.\n\n"
1027 : :
1028 : : "resume port tm node (port_id) (node_id)"
1029 : : " Resume tm node.\n\n"
1030 : :
1031 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1032 : : " Commit tm hierarchy.\n\n"
1033 : :
1034 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1035 : : " (red)\n"
1036 : : " Enables/Disables the traffic management marking"
1037 : : " for IP ECN (Explicit Congestion Notification)"
1038 : : " packets on a given port\n\n"
1039 : :
1040 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1041 : : " (red)\n"
1042 : : " Enables/Disables the traffic management marking"
1043 : : " on the port for IP dscp packets\n\n"
1044 : :
1045 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1046 : : " (red)\n"
1047 : : " Enables/Disables the traffic management marking"
1048 : : " on the port for VLAN packets with DEI enabled\n\n"
1049 : : );
1050 : : }
1051 : :
1052 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1053 : 0 : cmdline_printf(
1054 : : cl,
1055 : : "\n"
1056 : : "Device Operations:\n"
1057 : : "--------------\n"
1058 : : "device detach (identifier)\n"
1059 : : " Detach device by identifier.\n\n"
1060 : : );
1061 : : }
1062 : :
1063 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1064 : : struct testpmd_driver_commands *c;
1065 : : unsigned int i;
1066 : :
1067 : 0 : cmdline_printf(
1068 : : cl,
1069 : : "\n"
1070 : : "Driver specific:\n"
1071 : : "----------------\n"
1072 : : );
1073 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1074 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1075 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1076 : : }
1077 : : }
1078 : 0 : }
1079 : :
1080 : : static cmdline_parse_token_string_t cmd_help_long_help =
1081 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1082 : :
1083 : : static cmdline_parse_token_string_t cmd_help_long_section =
1084 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1085 : : "all#control#display#config#ports#"
1086 : : "filters#traffic_management#devices#drivers");
1087 : :
1088 : : static cmdline_parse_inst_t cmd_help_long = {
1089 : : .f = cmd_help_long_parsed,
1090 : : .data = NULL,
1091 : : .help_str = "help all|control|display|config|ports|"
1092 : : "filters|traffic_management|devices|drivers: "
1093 : : "Show help",
1094 : : .tokens = {
1095 : : (void *)&cmd_help_long_help,
1096 : : (void *)&cmd_help_long_section,
1097 : : NULL,
1098 : : },
1099 : : };
1100 : :
1101 : :
1102 : : /* *** start/stop/close all ports *** */
1103 : : struct cmd_operate_port_result {
1104 : : cmdline_fixed_string_t keyword;
1105 : : cmdline_fixed_string_t name;
1106 : : cmdline_fixed_string_t value;
1107 : : };
1108 : :
1109 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1110 : : __rte_unused struct cmdline *cl,
1111 : : __rte_unused void *data)
1112 : : {
1113 : : struct cmd_operate_port_result *res = parsed_result;
1114 : :
1115 : 0 : if (!strcmp(res->name, "start"))
1116 : 0 : start_port(RTE_PORT_ALL);
1117 : 0 : else if (!strcmp(res->name, "stop"))
1118 : 0 : stop_port(RTE_PORT_ALL);
1119 : 0 : else if (!strcmp(res->name, "close"))
1120 : 0 : close_port(RTE_PORT_ALL);
1121 : 0 : else if (!strcmp(res->name, "reset"))
1122 : 0 : reset_port(RTE_PORT_ALL);
1123 : : else
1124 : 0 : fprintf(stderr, "Unknown parameter\n");
1125 : 0 : }
1126 : :
1127 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1128 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1129 : : "port");
1130 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1131 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1132 : : "start#stop#close#reset");
1133 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1134 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1135 : :
1136 : : static cmdline_parse_inst_t cmd_operate_port = {
1137 : : .f = cmd_operate_port_parsed,
1138 : : .data = NULL,
1139 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1140 : : .tokens = {
1141 : : (void *)&cmd_operate_port_all_cmd,
1142 : : (void *)&cmd_operate_port_all_port,
1143 : : (void *)&cmd_operate_port_all_all,
1144 : : NULL,
1145 : : },
1146 : : };
1147 : :
1148 : : /* *** start/stop/close specific port *** */
1149 : : struct cmd_operate_specific_port_result {
1150 : : cmdline_fixed_string_t keyword;
1151 : : cmdline_fixed_string_t name;
1152 : : uint8_t value;
1153 : : };
1154 : :
1155 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1156 : : __rte_unused struct cmdline *cl,
1157 : : __rte_unused void *data)
1158 : : {
1159 : : struct cmd_operate_specific_port_result *res = parsed_result;
1160 : :
1161 : 0 : if (!strcmp(res->name, "start"))
1162 : 0 : start_port(res->value);
1163 : 0 : else if (!strcmp(res->name, "stop"))
1164 : 0 : stop_port(res->value);
1165 : 0 : else if (!strcmp(res->name, "close"))
1166 : 0 : close_port(res->value);
1167 : 0 : else if (!strcmp(res->name, "reset"))
1168 : 0 : reset_port(res->value);
1169 : : else
1170 : 0 : fprintf(stderr, "Unknown parameter\n");
1171 : 0 : }
1172 : :
1173 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1174 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1175 : : keyword, "port");
1176 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1177 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1178 : : name, "start#stop#close#reset");
1179 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1180 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1181 : : value, RTE_UINT8);
1182 : :
1183 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1184 : : .f = cmd_operate_specific_port_parsed,
1185 : : .data = NULL,
1186 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1187 : : .tokens = {
1188 : : (void *)&cmd_operate_specific_port_cmd,
1189 : : (void *)&cmd_operate_specific_port_port,
1190 : : (void *)&cmd_operate_specific_port_id,
1191 : : NULL,
1192 : : },
1193 : : };
1194 : :
1195 : : /* *** enable port setup (after attach) via iterator or event *** */
1196 : : struct cmd_set_port_setup_on_result {
1197 : : cmdline_fixed_string_t set;
1198 : : cmdline_fixed_string_t port;
1199 : : cmdline_fixed_string_t setup;
1200 : : cmdline_fixed_string_t on;
1201 : : cmdline_fixed_string_t mode;
1202 : : };
1203 : :
1204 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1205 : : __rte_unused struct cmdline *cl,
1206 : : __rte_unused void *data)
1207 : : {
1208 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1209 : :
1210 : 0 : if (strcmp(res->mode, "event") == 0)
1211 : 0 : setup_on_probe_event = true;
1212 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1213 : 0 : setup_on_probe_event = false;
1214 : : else
1215 : 0 : fprintf(stderr, "Unknown mode\n");
1216 : 0 : }
1217 : :
1218 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1219 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1220 : : set, "set");
1221 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1222 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1223 : : port, "port");
1224 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1226 : : setup, "setup");
1227 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1228 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1229 : : on, "on");
1230 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1232 : : mode, "iterator#event");
1233 : :
1234 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1235 : : .f = cmd_set_port_setup_on_parsed,
1236 : : .data = NULL,
1237 : : .help_str = "set port setup on iterator|event",
1238 : : .tokens = {
1239 : : (void *)&cmd_set_port_setup_on_set,
1240 : : (void *)&cmd_set_port_setup_on_port,
1241 : : (void *)&cmd_set_port_setup_on_setup,
1242 : : (void *)&cmd_set_port_setup_on_on,
1243 : : (void *)&cmd_set_port_setup_on_mode,
1244 : : NULL,
1245 : : },
1246 : : };
1247 : :
1248 : : /* *** attach a specified port *** */
1249 : : struct cmd_operate_attach_port_result {
1250 : : cmdline_fixed_string_t port;
1251 : : cmdline_fixed_string_t keyword;
1252 : : cmdline_multi_string_t identifier;
1253 : : };
1254 : :
1255 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1256 : : __rte_unused struct cmdline *cl,
1257 : : __rte_unused void *data)
1258 : : {
1259 : : struct cmd_operate_attach_port_result *res = parsed_result;
1260 : :
1261 : 0 : if (!strcmp(res->keyword, "attach"))
1262 : 0 : attach_port(res->identifier);
1263 : : else
1264 : 0 : fprintf(stderr, "Unknown parameter\n");
1265 : 0 : }
1266 : :
1267 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1268 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1269 : : port, "port");
1270 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1271 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1272 : : keyword, "attach");
1273 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1274 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1275 : : identifier, TOKEN_STRING_MULTI);
1276 : :
1277 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1278 : : .f = cmd_operate_attach_port_parsed,
1279 : : .data = NULL,
1280 : : .help_str = "port attach <identifier>: "
1281 : : "(identifier: pci address or virtual dev name)",
1282 : : .tokens = {
1283 : : (void *)&cmd_operate_attach_port_port,
1284 : : (void *)&cmd_operate_attach_port_keyword,
1285 : : (void *)&cmd_operate_attach_port_identifier,
1286 : : NULL,
1287 : : },
1288 : : };
1289 : :
1290 : : /* *** detach a specified port *** */
1291 : : struct cmd_operate_detach_port_result {
1292 : : cmdline_fixed_string_t port;
1293 : : cmdline_fixed_string_t keyword;
1294 : : portid_t port_id;
1295 : : };
1296 : :
1297 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1298 : : __rte_unused struct cmdline *cl,
1299 : : __rte_unused void *data)
1300 : : {
1301 : : struct cmd_operate_detach_port_result *res = parsed_result;
1302 : :
1303 : 0 : if (!strcmp(res->keyword, "detach")) {
1304 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1305 : 0 : detach_port_device(res->port_id);
1306 : : } else {
1307 : 0 : fprintf(stderr, "Unknown parameter\n");
1308 : : }
1309 : : }
1310 : :
1311 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1312 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1313 : : port, "port");
1314 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1315 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1316 : : keyword, "detach");
1317 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1318 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1319 : : port_id, RTE_UINT16);
1320 : :
1321 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1322 : : .f = cmd_operate_detach_port_parsed,
1323 : : .data = NULL,
1324 : : .help_str = "port detach <port_id>",
1325 : : .tokens = {
1326 : : (void *)&cmd_operate_detach_port_port,
1327 : : (void *)&cmd_operate_detach_port_keyword,
1328 : : (void *)&cmd_operate_detach_port_port_id,
1329 : : NULL,
1330 : : },
1331 : : };
1332 : :
1333 : : /* *** detach device by identifier *** */
1334 : : struct cmd_operate_detach_device_result {
1335 : : cmdline_fixed_string_t device;
1336 : : cmdline_fixed_string_t keyword;
1337 : : cmdline_fixed_string_t identifier;
1338 : : };
1339 : :
1340 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1341 : : __rte_unused struct cmdline *cl,
1342 : : __rte_unused void *data)
1343 : : {
1344 : : struct cmd_operate_detach_device_result *res = parsed_result;
1345 : :
1346 : 0 : if (!strcmp(res->keyword, "detach"))
1347 : 0 : detach_devargs(res->identifier);
1348 : : else
1349 : 0 : fprintf(stderr, "Unknown parameter\n");
1350 : 0 : }
1351 : :
1352 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1353 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1354 : : device, "device");
1355 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1356 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1357 : : keyword, "detach");
1358 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1359 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1360 : : identifier, NULL);
1361 : :
1362 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1363 : : .f = cmd_operate_detach_device_parsed,
1364 : : .data = NULL,
1365 : : .help_str = "device detach <identifier>:"
1366 : : "(identifier: pci address or virtual dev name)",
1367 : : .tokens = {
1368 : : (void *)&cmd_operate_detach_device_device,
1369 : : (void *)&cmd_operate_detach_device_keyword,
1370 : : (void *)&cmd_operate_detach_device_identifier,
1371 : : NULL,
1372 : : },
1373 : : };
1374 : : /* *** configure speed for all ports *** */
1375 : : struct cmd_config_speed_all {
1376 : : cmdline_fixed_string_t port;
1377 : : cmdline_fixed_string_t keyword;
1378 : : cmdline_fixed_string_t all;
1379 : : cmdline_fixed_string_t item1;
1380 : : cmdline_fixed_string_t item2;
1381 : : cmdline_fixed_string_t value1;
1382 : : cmdline_fixed_string_t value2;
1383 : : };
1384 : :
1385 : : static int
1386 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1387 : : {
1388 : :
1389 : : int duplex;
1390 : :
1391 : 0 : if (!strcmp(duplexstr, "half")) {
1392 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1393 : 0 : } else if (!strcmp(duplexstr, "full")) {
1394 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1395 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1396 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1397 : : } else {
1398 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1399 : 0 : return -1;
1400 : : }
1401 : :
1402 : 0 : if (!strcmp(speedstr, "10")) {
1403 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1404 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1405 : 0 : } else if (!strcmp(speedstr, "100")) {
1406 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1407 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1408 : : } else {
1409 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1410 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1411 : 0 : return -1;
1412 : : }
1413 : 0 : if (!strcmp(speedstr, "1000")) {
1414 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1415 : 0 : } else if (!strcmp(speedstr, "2500")) {
1416 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1417 : 0 : } else if (!strcmp(speedstr, "5000")) {
1418 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1419 : 0 : } else if (!strcmp(speedstr, "10000")) {
1420 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1421 : 0 : } else if (!strcmp(speedstr, "25000")) {
1422 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1423 : 0 : } else if (!strcmp(speedstr, "40000")) {
1424 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1425 : 0 : } else if (!strcmp(speedstr, "50000")) {
1426 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1427 : 0 : } else if (!strcmp(speedstr, "100000")) {
1428 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1429 : 0 : } else if (!strcmp(speedstr, "200000")) {
1430 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1431 : 0 : } else if (!strcmp(speedstr, "400000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1433 : 0 : } else if (!strcmp(speedstr, "auto")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1435 : : } else {
1436 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1437 : 0 : return -1;
1438 : : }
1439 : : }
1440 : :
1441 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1442 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1443 : :
1444 : : return 0;
1445 : : }
1446 : :
1447 : : static void
1448 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1449 : : __rte_unused struct cmdline *cl,
1450 : : __rte_unused void *data)
1451 : : {
1452 : : struct cmd_config_speed_all *res = parsed_result;
1453 : : uint32_t link_speed;
1454 : : portid_t pid;
1455 : :
1456 : 0 : if (!all_ports_stopped()) {
1457 : 0 : fprintf(stderr, "Please stop all ports first\n");
1458 : 0 : return;
1459 : : }
1460 : :
1461 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1462 : : &link_speed) < 0)
1463 : : return;
1464 : :
1465 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1466 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1467 : : }
1468 : :
1469 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1470 : : }
1471 : :
1472 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1473 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1474 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1475 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1476 : : "config");
1477 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1478 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1479 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1480 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1481 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1482 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1483 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1484 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1485 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1486 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1487 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1488 : : "half#full#auto");
1489 : :
1490 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1491 : : .f = cmd_config_speed_all_parsed,
1492 : : .data = NULL,
1493 : : .help_str = "port config all speed "
1494 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1495 : : "half|full|auto",
1496 : : .tokens = {
1497 : : (void *)&cmd_config_speed_all_port,
1498 : : (void *)&cmd_config_speed_all_keyword,
1499 : : (void *)&cmd_config_speed_all_all,
1500 : : (void *)&cmd_config_speed_all_item1,
1501 : : (void *)&cmd_config_speed_all_value1,
1502 : : (void *)&cmd_config_speed_all_item2,
1503 : : (void *)&cmd_config_speed_all_value2,
1504 : : NULL,
1505 : : },
1506 : : };
1507 : :
1508 : : /* *** configure speed for specific port *** */
1509 : : struct cmd_config_speed_specific {
1510 : : cmdline_fixed_string_t port;
1511 : : cmdline_fixed_string_t keyword;
1512 : : portid_t id;
1513 : : cmdline_fixed_string_t item1;
1514 : : cmdline_fixed_string_t item2;
1515 : : cmdline_fixed_string_t value1;
1516 : : cmdline_fixed_string_t value2;
1517 : : };
1518 : :
1519 : : static void
1520 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1521 : : __rte_unused struct cmdline *cl,
1522 : : __rte_unused void *data)
1523 : : {
1524 : : struct cmd_config_speed_specific *res = parsed_result;
1525 : : uint32_t link_speed;
1526 : :
1527 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1528 : 0 : return;
1529 : :
1530 : 0 : if (!port_is_stopped(res->id)) {
1531 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1532 : 0 : return;
1533 : : }
1534 : :
1535 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1536 : : &link_speed) < 0)
1537 : : return;
1538 : :
1539 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1540 : :
1541 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1542 : : }
1543 : :
1544 : :
1545 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1546 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1547 : : "port");
1548 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1549 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1550 : : "config");
1551 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1552 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1553 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1554 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1555 : : "speed");
1556 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1557 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1558 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1559 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1560 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1561 : : "duplex");
1562 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1563 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1564 : : "half#full#auto");
1565 : :
1566 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1567 : : .f = cmd_config_speed_specific_parsed,
1568 : : .data = NULL,
1569 : : .help_str = "port config <port_id> speed "
1570 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1571 : : "half|full|auto",
1572 : : .tokens = {
1573 : : (void *)&cmd_config_speed_specific_port,
1574 : : (void *)&cmd_config_speed_specific_keyword,
1575 : : (void *)&cmd_config_speed_specific_id,
1576 : : (void *)&cmd_config_speed_specific_item1,
1577 : : (void *)&cmd_config_speed_specific_value1,
1578 : : (void *)&cmd_config_speed_specific_item2,
1579 : : (void *)&cmd_config_speed_specific_value2,
1580 : : NULL,
1581 : : },
1582 : : };
1583 : :
1584 : : static int
1585 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1586 : : {
1587 : : int ret;
1588 : :
1589 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1590 : 0 : if (ret == -ENOTSUP) {
1591 : 0 : fprintf(stderr, "Function not implemented\n");
1592 : 0 : return -1;
1593 : 0 : } else if (ret < 0) {
1594 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1595 : 0 : return -1;
1596 : : }
1597 : :
1598 : : return 0;
1599 : : }
1600 : :
1601 : : static void
1602 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1603 : : {
1604 : : unsigned int i;
1605 : : uint32_t capa;
1606 : :
1607 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1608 : : printf("\n-----------------------------------\n");
1609 : 0 : for (i = 0; i < num; i++) {
1610 : 0 : printf("%-17s ",
1611 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1612 : 0 : capa = speed_lanes_capa[i].capa;
1613 : : int s = 0;
1614 : :
1615 : 0 : while (capa) {
1616 : 0 : if (capa & 0x1)
1617 : : printf("%-2d ", s);
1618 : 0 : s++;
1619 : 0 : capa = capa >> 1;
1620 : : }
1621 : : printf("\n");
1622 : : }
1623 : 0 : }
1624 : :
1625 : : /* *** display speed lanes per port capabilities *** */
1626 : : struct cmd_show_speed_lanes_result {
1627 : : cmdline_fixed_string_t cmd_show;
1628 : : cmdline_fixed_string_t cmd_port;
1629 : : cmdline_fixed_string_t cmd_keyword;
1630 : : portid_t cmd_pid;
1631 : : };
1632 : :
1633 : : static void
1634 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1635 : : __rte_unused struct cmdline *cl,
1636 : : __rte_unused void *data)
1637 : : {
1638 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1639 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1640 : : unsigned int num;
1641 : : int ret;
1642 : :
1643 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1644 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1645 : 0 : return;
1646 : : }
1647 : :
1648 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1649 : 0 : if (ret == -ENOTSUP) {
1650 : 0 : fprintf(stderr, "Function not implemented\n");
1651 : 0 : return;
1652 : 0 : } else if (ret < 0) {
1653 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1654 : 0 : return;
1655 : : }
1656 : :
1657 : 0 : num = (unsigned int)ret;
1658 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1659 : 0 : if (speed_lanes_capa == NULL) {
1660 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1661 : 0 : return;
1662 : : }
1663 : :
1664 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1665 : 0 : if (ret < 0) {
1666 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1667 : 0 : goto out;
1668 : : }
1669 : :
1670 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1671 : 0 : out:
1672 : 0 : free(speed_lanes_capa);
1673 : : }
1674 : :
1675 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1676 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1677 : : cmd_show, "show");
1678 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1679 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1680 : : cmd_port, "port");
1681 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1682 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1683 : : cmd_pid, RTE_UINT16);
1684 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1685 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1686 : : cmd_keyword, "speed_lanes");
1687 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1688 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1689 : : cmd_keyword, "capabilities");
1690 : :
1691 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1692 : : .f = cmd_show_speed_lanes_parsed,
1693 : : .data = NULL,
1694 : : .help_str = "show port <port_id> speed_lanes capabilities",
1695 : : .tokens = {
1696 : : (void *)&cmd_show_speed_lanes_show,
1697 : : (void *)&cmd_show_speed_lanes_port,
1698 : : (void *)&cmd_show_speed_lanes_pid,
1699 : : (void *)&cmd_show_speed_lanes_keyword,
1700 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1701 : : NULL,
1702 : : },
1703 : : };
1704 : :
1705 : : /* *** configure speed_lanes for all ports *** */
1706 : : struct cmd_config_speed_lanes_all {
1707 : : cmdline_fixed_string_t port;
1708 : : cmdline_fixed_string_t keyword;
1709 : : cmdline_fixed_string_t all;
1710 : : cmdline_fixed_string_t item;
1711 : : uint32_t lanes;
1712 : : };
1713 : :
1714 : : static void
1715 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1716 : : __rte_unused struct cmdline *cl,
1717 : : __rte_unused void *data)
1718 : : {
1719 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1720 : : portid_t pid;
1721 : :
1722 : 0 : if (!all_ports_stopped()) {
1723 : 0 : fprintf(stderr, "Please stop all ports first\n");
1724 : 0 : return;
1725 : : }
1726 : :
1727 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1728 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1729 : : return;
1730 : : }
1731 : :
1732 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1733 : : }
1734 : :
1735 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1736 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1737 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1738 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1739 : : "config");
1740 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1741 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1742 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1743 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1744 : : "speed_lanes");
1745 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1746 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1747 : :
1748 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1749 : : .f = cmd_config_speed_lanes_all_parsed,
1750 : : .data = NULL,
1751 : : .help_str = "port config all speed_lanes <value>",
1752 : : .tokens = {
1753 : : (void *)&cmd_config_speed_lanes_all_port,
1754 : : (void *)&cmd_config_speed_lanes_all_keyword,
1755 : : (void *)&cmd_config_speed_lanes_all_all,
1756 : : (void *)&cmd_config_speed_lanes_all_item,
1757 : : (void *)&cmd_config_speed_lanes_all_lanes,
1758 : : NULL,
1759 : : },
1760 : : };
1761 : :
1762 : : /* *** configure speed_lanes for specific port *** */
1763 : : struct cmd_config_speed_lanes_specific {
1764 : : cmdline_fixed_string_t port;
1765 : : cmdline_fixed_string_t keyword;
1766 : : uint16_t port_id;
1767 : : cmdline_fixed_string_t item;
1768 : : uint32_t lanes;
1769 : : };
1770 : :
1771 : : static void
1772 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1773 : : __rte_unused struct cmdline *cl,
1774 : : __rte_unused void *data)
1775 : : {
1776 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1777 : :
1778 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1779 : : return;
1780 : :
1781 : 0 : if (!port_is_stopped(res->port_id)) {
1782 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1783 : 0 : return;
1784 : : }
1785 : :
1786 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1787 : : return;
1788 : :
1789 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1790 : : }
1791 : :
1792 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1793 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1794 : : "port");
1795 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1796 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1797 : : "config");
1798 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1799 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1800 : : RTE_UINT16);
1801 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1802 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1803 : : "speed_lanes");
1804 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1805 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1806 : : RTE_UINT32);
1807 : :
1808 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1809 : : .f = cmd_config_speed_lanes_specific_parsed,
1810 : : .data = NULL,
1811 : : .help_str = "port config <port_id> speed_lanes <value>",
1812 : : .tokens = {
1813 : : (void *)&cmd_config_speed_lanes_specific_port,
1814 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1815 : : (void *)&cmd_config_speed_lanes_specific_id,
1816 : : (void *)&cmd_config_speed_lanes_specific_item,
1817 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1818 : : NULL,
1819 : : },
1820 : : };
1821 : :
1822 : : /* *** configure loopback for all ports *** */
1823 : : struct cmd_config_loopback_all {
1824 : : cmdline_fixed_string_t port;
1825 : : cmdline_fixed_string_t keyword;
1826 : : cmdline_fixed_string_t all;
1827 : : cmdline_fixed_string_t item;
1828 : : uint32_t mode;
1829 : : };
1830 : :
1831 : : static void
1832 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1833 : : __rte_unused struct cmdline *cl,
1834 : : __rte_unused void *data)
1835 : : {
1836 : : struct cmd_config_loopback_all *res = parsed_result;
1837 : : portid_t pid;
1838 : :
1839 : 0 : if (!all_ports_stopped()) {
1840 : 0 : fprintf(stderr, "Please stop all ports first\n");
1841 : 0 : return;
1842 : : }
1843 : :
1844 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1845 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1846 : : }
1847 : :
1848 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1849 : : }
1850 : :
1851 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1852 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1853 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1854 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1855 : : "config");
1856 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1857 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1858 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1859 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1860 : : "loopback");
1861 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1862 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1863 : :
1864 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1865 : : .f = cmd_config_loopback_all_parsed,
1866 : : .data = NULL,
1867 : : .help_str = "port config all loopback <mode>",
1868 : : .tokens = {
1869 : : (void *)&cmd_config_loopback_all_port,
1870 : : (void *)&cmd_config_loopback_all_keyword,
1871 : : (void *)&cmd_config_loopback_all_all,
1872 : : (void *)&cmd_config_loopback_all_item,
1873 : : (void *)&cmd_config_loopback_all_mode,
1874 : : NULL,
1875 : : },
1876 : : };
1877 : :
1878 : : /* *** configure loopback for specific port *** */
1879 : : struct cmd_config_loopback_specific {
1880 : : cmdline_fixed_string_t port;
1881 : : cmdline_fixed_string_t keyword;
1882 : : uint16_t port_id;
1883 : : cmdline_fixed_string_t item;
1884 : : uint32_t mode;
1885 : : };
1886 : :
1887 : : static void
1888 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1889 : : __rte_unused struct cmdline *cl,
1890 : : __rte_unused void *data)
1891 : : {
1892 : : struct cmd_config_loopback_specific *res = parsed_result;
1893 : :
1894 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1895 : : return;
1896 : :
1897 : 0 : if (!port_is_stopped(res->port_id)) {
1898 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1899 : 0 : return;
1900 : : }
1901 : :
1902 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1903 : :
1904 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1905 : : }
1906 : :
1907 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1908 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1909 : : "port");
1910 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1911 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1912 : : "config");
1913 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1914 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1915 : : RTE_UINT16);
1916 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1917 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1918 : : "loopback");
1919 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1920 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1921 : : RTE_UINT32);
1922 : :
1923 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1924 : : .f = cmd_config_loopback_specific_parsed,
1925 : : .data = NULL,
1926 : : .help_str = "port config <port_id> loopback <mode>",
1927 : : .tokens = {
1928 : : (void *)&cmd_config_loopback_specific_port,
1929 : : (void *)&cmd_config_loopback_specific_keyword,
1930 : : (void *)&cmd_config_loopback_specific_id,
1931 : : (void *)&cmd_config_loopback_specific_item,
1932 : : (void *)&cmd_config_loopback_specific_mode,
1933 : : NULL,
1934 : : },
1935 : : };
1936 : :
1937 : : /* *** configure txq/rxq, txd/rxd *** */
1938 : : struct cmd_config_rx_tx {
1939 : : cmdline_fixed_string_t port;
1940 : : cmdline_fixed_string_t keyword;
1941 : : cmdline_fixed_string_t all;
1942 : : cmdline_fixed_string_t name;
1943 : : uint16_t value;
1944 : : };
1945 : :
1946 : : static void
1947 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1948 : : __rte_unused struct cmdline *cl,
1949 : : __rte_unused void *data)
1950 : : {
1951 : : struct cmd_config_rx_tx *res = parsed_result;
1952 : :
1953 : 0 : if (!all_ports_stopped()) {
1954 : 0 : fprintf(stderr, "Please stop all ports first\n");
1955 : 0 : return;
1956 : : }
1957 : 0 : if (!strcmp(res->name, "rxq")) {
1958 : 0 : if (!res->value && !nb_txq) {
1959 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1960 : 0 : return;
1961 : : }
1962 : 0 : if (check_nb_rxq(res->value) != 0)
1963 : : return;
1964 : 0 : nb_rxq = res->value;
1965 : : }
1966 : 0 : else if (!strcmp(res->name, "txq")) {
1967 : 0 : if (!res->value && !nb_rxq) {
1968 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1969 : 0 : return;
1970 : : }
1971 : 0 : if (check_nb_txq(res->value) != 0)
1972 : : return;
1973 : 0 : nb_txq = res->value;
1974 : : }
1975 : 0 : else if (!strcmp(res->name, "rxd")) {
1976 : 0 : if (check_nb_rxd(res->value) != 0)
1977 : : return;
1978 : 0 : nb_rxd = res->value;
1979 : 0 : } else if (!strcmp(res->name, "txd")) {
1980 : 0 : if (check_nb_txd(res->value) != 0)
1981 : : return;
1982 : :
1983 : 0 : nb_txd = res->value;
1984 : : } else {
1985 : 0 : fprintf(stderr, "Unknown parameter\n");
1986 : 0 : return;
1987 : : }
1988 : :
1989 : 0 : fwd_config_setup();
1990 : :
1991 : 0 : init_port_config();
1992 : :
1993 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 : : }
1995 : :
1996 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1997 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1998 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1999 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2000 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2001 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2002 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2003 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2004 : : "rxq#txq#rxd#txd");
2005 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2006 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2007 : :
2008 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2009 : : .f = cmd_config_rx_tx_parsed,
2010 : : .data = NULL,
2011 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2012 : : .tokens = {
2013 : : (void *)&cmd_config_rx_tx_port,
2014 : : (void *)&cmd_config_rx_tx_keyword,
2015 : : (void *)&cmd_config_rx_tx_all,
2016 : : (void *)&cmd_config_rx_tx_name,
2017 : : (void *)&cmd_config_rx_tx_value,
2018 : : NULL,
2019 : : },
2020 : : };
2021 : :
2022 : : /* *** config max packet length *** */
2023 : : struct cmd_config_max_pkt_len_result {
2024 : : cmdline_fixed_string_t port;
2025 : : cmdline_fixed_string_t keyword;
2026 : : cmdline_fixed_string_t all;
2027 : : cmdline_fixed_string_t name;
2028 : : uint32_t value;
2029 : : };
2030 : :
2031 : : static void
2032 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2033 : : __rte_unused struct cmdline *cl,
2034 : : __rte_unused void *data)
2035 : : {
2036 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2037 : : portid_t port_id;
2038 : : int ret;
2039 : :
2040 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2041 : : printf("Unknown parameter\n");
2042 : 0 : return;
2043 : : }
2044 : :
2045 : 0 : if (!all_ports_stopped()) {
2046 : 0 : fprintf(stderr, "Please stop all ports first\n");
2047 : 0 : return;
2048 : : }
2049 : :
2050 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2051 : 0 : struct rte_port *port = &ports[port_id];
2052 : :
2053 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2054 : 0 : fprintf(stderr,
2055 : : "max-pkt-len can not be less than %d\n",
2056 : : RTE_ETHER_MIN_LEN);
2057 : 0 : return;
2058 : : }
2059 : :
2060 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2061 : 0 : if (ret != 0) {
2062 : 0 : fprintf(stderr,
2063 : : "rte_eth_dev_info_get() failed for port %u\n",
2064 : : port_id);
2065 : 0 : return;
2066 : : }
2067 : :
2068 : 0 : update_mtu_from_frame_size(port_id, res->value);
2069 : : }
2070 : :
2071 : 0 : init_port_config();
2072 : :
2073 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2074 : : }
2075 : :
2076 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2077 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2078 : : "port");
2079 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2080 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2081 : : "config");
2082 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2083 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2084 : : "all");
2085 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2086 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2087 : : "max-pkt-len");
2088 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2089 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2090 : : RTE_UINT32);
2091 : :
2092 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2093 : : .f = cmd_config_max_pkt_len_parsed,
2094 : : .data = NULL,
2095 : : .help_str = "port config all max-pkt-len <value>",
2096 : : .tokens = {
2097 : : (void *)&cmd_config_max_pkt_len_port,
2098 : : (void *)&cmd_config_max_pkt_len_keyword,
2099 : : (void *)&cmd_config_max_pkt_len_all,
2100 : : (void *)&cmd_config_max_pkt_len_name,
2101 : : (void *)&cmd_config_max_pkt_len_value,
2102 : : NULL,
2103 : : },
2104 : : };
2105 : :
2106 : : /* *** config max LRO aggregated packet size *** */
2107 : : struct cmd_config_max_lro_pkt_size_result {
2108 : : cmdline_fixed_string_t port;
2109 : : cmdline_fixed_string_t keyword;
2110 : : cmdline_fixed_string_t all;
2111 : : cmdline_fixed_string_t name;
2112 : : uint32_t value;
2113 : : };
2114 : :
2115 : : static void
2116 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2117 : : __rte_unused struct cmdline *cl,
2118 : : __rte_unused void *data)
2119 : : {
2120 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2121 : : portid_t pid;
2122 : :
2123 : 0 : if (!all_ports_stopped()) {
2124 : 0 : fprintf(stderr, "Please stop all ports first\n");
2125 : 0 : return;
2126 : : }
2127 : :
2128 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2129 : 0 : struct rte_port *port = &ports[pid];
2130 : :
2131 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2132 : 0 : if (res->value ==
2133 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2134 : : return;
2135 : :
2136 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2137 : : } else {
2138 : 0 : fprintf(stderr, "Unknown parameter\n");
2139 : 0 : return;
2140 : : }
2141 : : }
2142 : :
2143 : 0 : init_port_config();
2144 : :
2145 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2146 : : }
2147 : :
2148 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2149 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2150 : : port, "port");
2151 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2152 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2153 : : keyword, "config");
2154 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2155 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2156 : : all, "all");
2157 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2158 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2159 : : name, "max-lro-pkt-size");
2160 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2161 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2162 : : value, RTE_UINT32);
2163 : :
2164 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2165 : : .f = cmd_config_max_lro_pkt_size_parsed,
2166 : : .data = NULL,
2167 : : .help_str = "port config all max-lro-pkt-size <value>",
2168 : : .tokens = {
2169 : : (void *)&cmd_config_max_lro_pkt_size_port,
2170 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2171 : : (void *)&cmd_config_max_lro_pkt_size_all,
2172 : : (void *)&cmd_config_max_lro_pkt_size_name,
2173 : : (void *)&cmd_config_max_lro_pkt_size_value,
2174 : : NULL,
2175 : : },
2176 : : };
2177 : :
2178 : : /* *** configure port MTU *** */
2179 : : struct cmd_config_mtu_result {
2180 : : cmdline_fixed_string_t port;
2181 : : cmdline_fixed_string_t keyword;
2182 : : cmdline_fixed_string_t mtu;
2183 : : portid_t port_id;
2184 : : uint16_t value;
2185 : : };
2186 : :
2187 : : static void
2188 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2189 : : __rte_unused struct cmdline *cl,
2190 : : __rte_unused void *data)
2191 : : {
2192 : : struct cmd_config_mtu_result *res = parsed_result;
2193 : :
2194 : 0 : port_mtu_set(res->port_id, res->value);
2195 : 0 : }
2196 : :
2197 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2198 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2199 : : "port");
2200 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2201 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2202 : : "config");
2203 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2204 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2205 : : "mtu");
2206 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2207 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2208 : : RTE_UINT16);
2209 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2210 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2211 : : RTE_UINT16);
2212 : :
2213 : : static cmdline_parse_inst_t cmd_config_mtu = {
2214 : : .f = cmd_config_mtu_parsed,
2215 : : .data = NULL,
2216 : : .help_str = "port config mtu <port_id> <value>",
2217 : : .tokens = {
2218 : : (void *)&cmd_config_mtu_port,
2219 : : (void *)&cmd_config_mtu_keyword,
2220 : : (void *)&cmd_config_mtu_mtu,
2221 : : (void *)&cmd_config_mtu_port_id,
2222 : : (void *)&cmd_config_mtu_value,
2223 : : NULL,
2224 : : },
2225 : : };
2226 : :
2227 : : /* *** configure rx mode *** */
2228 : : struct cmd_config_rx_mode_flag {
2229 : : cmdline_fixed_string_t port;
2230 : : cmdline_fixed_string_t keyword;
2231 : : cmdline_fixed_string_t all;
2232 : : cmdline_fixed_string_t name;
2233 : : cmdline_fixed_string_t value;
2234 : : };
2235 : :
2236 : : static void
2237 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2238 : : __rte_unused struct cmdline *cl,
2239 : : __rte_unused void *data)
2240 : : {
2241 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2242 : :
2243 : 0 : if (!all_ports_stopped()) {
2244 : 0 : fprintf(stderr, "Please stop all ports first\n");
2245 : 0 : return;
2246 : : }
2247 : :
2248 : 0 : if (!strcmp(res->name, "drop-en")) {
2249 : 0 : if (!strcmp(res->value, "on"))
2250 : 0 : rx_drop_en = 1;
2251 : 0 : else if (!strcmp(res->value, "off"))
2252 : 0 : rx_drop_en = 0;
2253 : : else {
2254 : 0 : fprintf(stderr, "Unknown parameter\n");
2255 : 0 : return;
2256 : : }
2257 : : } else {
2258 : 0 : fprintf(stderr, "Unknown parameter\n");
2259 : 0 : return;
2260 : : }
2261 : :
2262 : 0 : init_port_config();
2263 : :
2264 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2265 : : }
2266 : :
2267 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2268 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2269 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2270 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2271 : : "config");
2272 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2273 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2274 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2275 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2276 : : "drop-en");
2277 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2278 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2279 : : "on#off");
2280 : :
2281 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2282 : : .f = cmd_config_rx_mode_flag_parsed,
2283 : : .data = NULL,
2284 : : .help_str = "port config all drop-en on|off",
2285 : : .tokens = {
2286 : : (void *)&cmd_config_rx_mode_flag_port,
2287 : : (void *)&cmd_config_rx_mode_flag_keyword,
2288 : : (void *)&cmd_config_rx_mode_flag_all,
2289 : : (void *)&cmd_config_rx_mode_flag_name,
2290 : : (void *)&cmd_config_rx_mode_flag_value,
2291 : : NULL,
2292 : : },
2293 : : };
2294 : :
2295 : : /* *** configure rss *** */
2296 : : struct cmd_config_rss {
2297 : : cmdline_fixed_string_t port;
2298 : : cmdline_fixed_string_t keyword;
2299 : : cmdline_fixed_string_t all;
2300 : : cmdline_fixed_string_t name;
2301 : : cmdline_fixed_string_t value;
2302 : : };
2303 : :
2304 : : static void
2305 : 0 : cmd_config_rss_parsed(void *parsed_result,
2306 : : __rte_unused struct cmdline *cl,
2307 : : __rte_unused void *data)
2308 : : {
2309 : : struct cmd_config_rss *res = parsed_result;
2310 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2311 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2312 : : int use_default = 0;
2313 : : int all_updated = 1;
2314 : : int diag;
2315 : : uint16_t i;
2316 : : int ret;
2317 : :
2318 : 0 : if (!strcmp(res->value, "level-default")) {
2319 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2320 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2321 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2322 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2323 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2324 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2325 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2326 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2327 : 0 : } else if (!strcmp(res->value, "default")) {
2328 : : use_default = 1;
2329 : 0 : } else if (isdigit(res->value[0])) {
2330 : : int value = atoi(res->value);
2331 : 0 : if (value > 0 && value < 64)
2332 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2333 : : else {
2334 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2335 : 0 : return;
2336 : : }
2337 : 0 : } else if (!strcmp(res->value, "none")) {
2338 : : rss_conf.rss_hf = 0;
2339 : : } else {
2340 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2341 : 0 : if (rss_conf.rss_hf == 0) {
2342 : 0 : fprintf(stderr, "Unknown parameter\n");
2343 : 0 : return;
2344 : : }
2345 : : }
2346 : : rss_conf.rss_key = NULL;
2347 : : /* Update global configuration for RSS types. */
2348 : 0 : RTE_ETH_FOREACH_DEV(i) {
2349 : : struct rte_eth_rss_conf local_rss_conf;
2350 : :
2351 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2352 : 0 : if (ret != 0)
2353 : 0 : return;
2354 : :
2355 : 0 : if (use_default)
2356 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2357 : :
2358 : 0 : local_rss_conf = rss_conf;
2359 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2360 : 0 : dev_info.flow_type_rss_offloads;
2361 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2362 : : printf("Port %u modified RSS hash function based on hardware support,"
2363 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2364 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2365 : : }
2366 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2367 : 0 : if (diag < 0) {
2368 : : all_updated = 0;
2369 : 0 : fprintf(stderr,
2370 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2371 : : i, -diag, strerror(-diag));
2372 : : }
2373 : : }
2374 : 0 : if (all_updated && !use_default) {
2375 : 0 : rss_hf = rss_conf.rss_hf;
2376 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2377 : : }
2378 : : }
2379 : :
2380 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2381 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2382 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2383 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2384 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2385 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2386 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2387 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2388 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2389 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2390 : :
2391 : : static cmdline_parse_inst_t cmd_config_rss = {
2392 : : .f = cmd_config_rss_parsed,
2393 : : .data = NULL,
2394 : : .help_str = "port config all rss "
2395 : : "all|default|level-default|level-outer|level-inner|"
2396 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2397 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2398 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2399 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2400 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2401 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2402 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2403 : : .tokens = {
2404 : : (void *)&cmd_config_rss_port,
2405 : : (void *)&cmd_config_rss_keyword,
2406 : : (void *)&cmd_config_rss_all,
2407 : : (void *)&cmd_config_rss_name,
2408 : : (void *)&cmd_config_rss_value,
2409 : : NULL,
2410 : : },
2411 : : };
2412 : :
2413 : : /* *** configure rss hash key *** */
2414 : : struct cmd_config_rss_hash_key {
2415 : : cmdline_fixed_string_t port;
2416 : : cmdline_fixed_string_t config;
2417 : : portid_t port_id;
2418 : : cmdline_fixed_string_t rss_hash_key;
2419 : : cmdline_fixed_string_t rss_type;
2420 : : cmdline_fixed_string_t key;
2421 : : };
2422 : :
2423 : : static uint8_t
2424 : : hexa_digit_to_value(char hexa_digit)
2425 : : {
2426 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2427 : : return (uint8_t) (hexa_digit - '0');
2428 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2429 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2430 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2431 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2432 : : /* Invalid hexa digit */
2433 : : return 0xFF;
2434 : : }
2435 : :
2436 : : static uint8_t
2437 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2438 : : {
2439 : : uint8_t hexa_v;
2440 : :
2441 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2442 : : if (hexa_v == 0xFF)
2443 : 0 : fprintf(stderr,
2444 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2445 : : key[idx], idx);
2446 : 0 : return hexa_v;
2447 : : }
2448 : :
2449 : : static void
2450 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2451 : : __rte_unused struct cmdline *cl,
2452 : : __rte_unused void *data)
2453 : : {
2454 : : struct cmd_config_rss_hash_key *res = parsed_result;
2455 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2456 : : uint8_t xdgt0;
2457 : : uint8_t xdgt1;
2458 : : int i;
2459 : : struct rte_eth_dev_info dev_info;
2460 : : uint8_t hash_key_size;
2461 : : uint32_t key_len;
2462 : : int ret;
2463 : :
2464 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2465 : 0 : if (ret != 0)
2466 : 0 : return;
2467 : :
2468 : 0 : if (dev_info.hash_key_size > 0 &&
2469 : : dev_info.hash_key_size <= sizeof(hash_key))
2470 : : hash_key_size = dev_info.hash_key_size;
2471 : : else {
2472 : 0 : fprintf(stderr,
2473 : : "dev_info did not provide a valid hash key size\n");
2474 : 0 : return;
2475 : : }
2476 : : /* Check the length of the RSS hash key */
2477 : 0 : key_len = strlen(res->key);
2478 : 0 : if (key_len != (hash_key_size * 2)) {
2479 : 0 : fprintf(stderr,
2480 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2481 : : (int)key_len, hash_key_size * 2);
2482 : 0 : return;
2483 : : }
2484 : : /* Translate RSS hash key into binary representation */
2485 : 0 : for (i = 0; i < hash_key_size; i++) {
2486 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2487 : 0 : if (xdgt0 == 0xFF)
2488 : : return;
2489 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2490 : 0 : if (xdgt1 == 0xFF)
2491 : : return;
2492 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2493 : : }
2494 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2495 : : hash_key_size);
2496 : : }
2497 : :
2498 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2499 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2500 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2501 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2502 : : "config");
2503 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2504 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2505 : : RTE_UINT16);
2506 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2507 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2508 : : rss_hash_key, "rss-hash-key");
2509 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2510 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2511 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2512 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2513 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2514 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2515 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2516 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2517 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2518 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2519 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2520 : :
2521 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2522 : : .f = cmd_config_rss_hash_key_parsed,
2523 : : .data = NULL,
2524 : : .help_str = "port config <port_id> rss-hash-key "
2525 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2526 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2527 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2528 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2529 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2530 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2531 : : "<string of hex digits (variable length, NIC dependent)>",
2532 : : .tokens = {
2533 : : (void *)&cmd_config_rss_hash_key_port,
2534 : : (void *)&cmd_config_rss_hash_key_config,
2535 : : (void *)&cmd_config_rss_hash_key_port_id,
2536 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2537 : : (void *)&cmd_config_rss_hash_key_rss_type,
2538 : : (void *)&cmd_config_rss_hash_key_value,
2539 : : NULL,
2540 : : },
2541 : : };
2542 : :
2543 : : /* *** configure rss hash algorithm *** */
2544 : : struct cmd_config_rss_hash_algo {
2545 : : cmdline_fixed_string_t port;
2546 : : cmdline_fixed_string_t config;
2547 : : portid_t port_id;
2548 : : cmdline_fixed_string_t rss_hash_algo;
2549 : : cmdline_fixed_string_t algo;
2550 : : };
2551 : :
2552 : : static void
2553 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2554 : : __rte_unused struct cmdline *cl,
2555 : : __rte_unused void *data)
2556 : : {
2557 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2558 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2559 : : struct rte_eth_rss_conf rss_conf;
2560 : : uint32_t algorithm;
2561 : : int ret;
2562 : :
2563 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2564 : 0 : rss_conf.rss_key = rss_key;
2565 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2566 : 0 : if (ret != 0) {
2567 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2568 : 0 : res->port_id);
2569 : 0 : return;
2570 : : }
2571 : :
2572 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2573 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2574 : 0 : if (ret != 0) {
2575 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2576 : 0 : res->port_id, res->algo);
2577 : 0 : return;
2578 : : }
2579 : :
2580 : 0 : rss_conf.algorithm = algorithm;
2581 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2582 : 0 : if (ret != 0) {
2583 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2584 : 0 : res->port_id);
2585 : 0 : return;
2586 : : }
2587 : : }
2588 : :
2589 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2590 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2591 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2592 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2593 : : "config");
2594 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2595 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2596 : : RTE_UINT16);
2597 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2598 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2599 : : rss_hash_algo, "rss-hash-algo");
2600 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2601 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2602 : : "default#simple_xor#toeplitz#"
2603 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2604 : :
2605 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2606 : : .f = cmd_config_rss_hash_algo_parsed,
2607 : : .data = NULL,
2608 : : .help_str = "port config <port_id> rss-hash-algo "
2609 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2610 : : .tokens = {
2611 : : (void *)&cmd_config_rss_hash_algo_port,
2612 : : (void *)&cmd_config_rss_hash_algo_config,
2613 : : (void *)&cmd_config_rss_hash_algo_port_id,
2614 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2615 : : (void *)&cmd_config_rss_hash_algo_algo,
2616 : : NULL,
2617 : : },
2618 : : };
2619 : :
2620 : : /* *** cleanup txq mbufs *** */
2621 : : struct cmd_cleanup_txq_mbufs_result {
2622 : : cmdline_fixed_string_t port;
2623 : : cmdline_fixed_string_t keyword;
2624 : : cmdline_fixed_string_t name;
2625 : : uint16_t port_id;
2626 : : uint16_t queue_id;
2627 : : uint32_t free_cnt;
2628 : : };
2629 : :
2630 : : static void
2631 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2632 : : __rte_unused struct cmdline *cl,
2633 : : __rte_unused void *data)
2634 : : {
2635 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2636 : 0 : uint16_t port_id = res->port_id;
2637 : 0 : uint16_t queue_id = res->queue_id;
2638 : 0 : uint32_t free_cnt = res->free_cnt;
2639 : : struct rte_eth_txq_info qinfo;
2640 : : int ret;
2641 : :
2642 : 0 : if (test_done == 0) {
2643 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2644 : 0 : return;
2645 : : }
2646 : :
2647 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2648 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2649 : : port_id, queue_id);
2650 : 0 : return;
2651 : : }
2652 : :
2653 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2654 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2655 : 0 : return;
2656 : : }
2657 : :
2658 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2659 : 0 : if (ret < 0) {
2660 : 0 : fprintf(stderr,
2661 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2662 : : port_id, queue_id, strerror(-ret), ret);
2663 : 0 : return;
2664 : : }
2665 : :
2666 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2667 : : port_id, queue_id, ret);
2668 : : }
2669 : :
2670 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2671 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2672 : : "port");
2673 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2674 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2675 : : "cleanup");
2676 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2677 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2678 : : RTE_UINT16);
2679 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2680 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2681 : : "txq");
2682 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2683 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2684 : : RTE_UINT16);
2685 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2686 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2687 : : RTE_UINT32);
2688 : :
2689 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2690 : : .f = cmd_cleanup_txq_mbufs_parsed,
2691 : : .data = NULL,
2692 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2693 : : .tokens = {
2694 : : (void *)&cmd_cleanup_txq_mbufs_port,
2695 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2696 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2697 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2698 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2699 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2700 : : NULL,
2701 : : },
2702 : : };
2703 : :
2704 : : /* *** configure port rxq/txq ring size *** */
2705 : : struct cmd_config_rxtx_ring_size {
2706 : : cmdline_fixed_string_t port;
2707 : : cmdline_fixed_string_t config;
2708 : : portid_t portid;
2709 : : cmdline_fixed_string_t rxtxq;
2710 : : uint16_t qid;
2711 : : cmdline_fixed_string_t rsize;
2712 : : uint16_t size;
2713 : : };
2714 : :
2715 : : static void
2716 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2717 : : __rte_unused struct cmdline *cl,
2718 : : __rte_unused void *data)
2719 : : {
2720 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2721 : : struct rte_port *port;
2722 : : uint8_t isrx;
2723 : :
2724 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2725 : : return;
2726 : :
2727 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2728 : 0 : fprintf(stderr, "Invalid port id\n");
2729 : 0 : return;
2730 : : }
2731 : :
2732 : 0 : port = &ports[res->portid];
2733 : :
2734 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2735 : : isrx = 1;
2736 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2737 : : isrx = 0;
2738 : : else {
2739 : 0 : fprintf(stderr, "Unknown parameter\n");
2740 : 0 : return;
2741 : : }
2742 : :
2743 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2744 : : return;
2745 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2746 : : return;
2747 : :
2748 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2749 : 0 : fprintf(stderr,
2750 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2751 : : rx_free_thresh);
2752 : 0 : return;
2753 : : }
2754 : :
2755 : 0 : if (isrx)
2756 : 0 : port->nb_rx_desc[res->qid] = res->size;
2757 : : else
2758 : 0 : port->nb_tx_desc[res->qid] = res->size;
2759 : :
2760 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2761 : : }
2762 : :
2763 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2764 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2765 : : port, "port");
2766 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2767 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2768 : : config, "config");
2769 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2770 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2771 : : portid, RTE_UINT16);
2772 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2773 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2774 : : rxtxq, "rxq#txq");
2775 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2776 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2777 : : qid, RTE_UINT16);
2778 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2779 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2780 : : rsize, "ring_size");
2781 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2782 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2783 : : size, RTE_UINT16);
2784 : :
2785 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2786 : : .f = cmd_config_rxtx_ring_size_parsed,
2787 : : .data = NULL,
2788 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2789 : : .tokens = {
2790 : : (void *)&cmd_config_rxtx_ring_size_port,
2791 : : (void *)&cmd_config_rxtx_ring_size_config,
2792 : : (void *)&cmd_config_rxtx_ring_size_portid,
2793 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2794 : : (void *)&cmd_config_rxtx_ring_size_qid,
2795 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2796 : : (void *)&cmd_config_rxtx_ring_size_size,
2797 : : NULL,
2798 : : },
2799 : : };
2800 : :
2801 : : /* *** configure port rxq/txq start/stop *** */
2802 : : struct cmd_config_rxtx_queue {
2803 : : cmdline_fixed_string_t port;
2804 : : portid_t portid;
2805 : : cmdline_fixed_string_t rxtxq;
2806 : : uint16_t qid;
2807 : : cmdline_fixed_string_t opname;
2808 : : };
2809 : :
2810 : : static void
2811 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2812 : : __rte_unused struct cmdline *cl,
2813 : : __rte_unused void *data)
2814 : : {
2815 : : struct cmd_config_rxtx_queue *res = parsed_result;
2816 : : struct rte_port *port;
2817 : : uint8_t isrx;
2818 : : uint8_t isstart;
2819 : : uint8_t *state;
2820 : : int ret = 0;
2821 : :
2822 : 0 : if (test_done == 0) {
2823 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2824 : 0 : return;
2825 : : }
2826 : :
2827 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2828 : : return;
2829 : :
2830 : 0 : if (port_is_started(res->portid) != 1) {
2831 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2832 : 0 : return;
2833 : : }
2834 : :
2835 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2836 : : isrx = 1;
2837 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2838 : : isrx = 0;
2839 : : else {
2840 : 0 : fprintf(stderr, "Unknown parameter\n");
2841 : 0 : return;
2842 : : }
2843 : :
2844 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2845 : : return;
2846 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2847 : : return;
2848 : :
2849 : 0 : if (!strcmp(res->opname, "start"))
2850 : : isstart = 1;
2851 : 0 : else if (!strcmp(res->opname, "stop"))
2852 : : isstart = 0;
2853 : : else {
2854 : 0 : fprintf(stderr, "Unknown parameter\n");
2855 : 0 : return;
2856 : : }
2857 : :
2858 : 0 : if (isstart && isrx)
2859 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2860 : 0 : else if (!isstart && isrx)
2861 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2862 : 0 : else if (isstart && !isrx)
2863 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2864 : : else
2865 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2866 : :
2867 : 0 : if (ret == -ENOTSUP) {
2868 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2869 : 0 : return;
2870 : : }
2871 : :
2872 : 0 : port = &ports[res->portid];
2873 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2874 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2875 : : RTE_ETH_QUEUE_STATE_STOPPED;
2876 : : }
2877 : :
2878 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2880 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2881 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2882 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2884 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2885 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2886 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2888 : : "start#stop");
2889 : :
2890 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2891 : : .f = cmd_config_rxtx_queue_parsed,
2892 : : .data = NULL,
2893 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2894 : : .tokens = {
2895 : : (void *)&cmd_config_rxtx_queue_port,
2896 : : (void *)&cmd_config_rxtx_queue_portid,
2897 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2898 : : (void *)&cmd_config_rxtx_queue_qid,
2899 : : (void *)&cmd_config_rxtx_queue_opname,
2900 : : NULL,
2901 : : },
2902 : : };
2903 : :
2904 : : /* *** configure port rxq/txq deferred start on/off *** */
2905 : : struct cmd_config_deferred_start_rxtx_queue {
2906 : : cmdline_fixed_string_t port;
2907 : : portid_t port_id;
2908 : : cmdline_fixed_string_t rxtxq;
2909 : : uint16_t qid;
2910 : : cmdline_fixed_string_t opname;
2911 : : cmdline_fixed_string_t state;
2912 : : };
2913 : :
2914 : : static void
2915 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2916 : : __rte_unused struct cmdline *cl,
2917 : : __rte_unused void *data)
2918 : : {
2919 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2920 : : struct rte_port *port;
2921 : : uint8_t isrx;
2922 : : uint8_t ison;
2923 : : uint8_t needreconfig = 0;
2924 : :
2925 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2926 : : return;
2927 : :
2928 : 0 : if (port_is_started(res->port_id) != 0) {
2929 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2930 : 0 : return;
2931 : : }
2932 : :
2933 : 0 : port = &ports[res->port_id];
2934 : :
2935 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2936 : :
2937 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2938 : : return;
2939 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2940 : : return;
2941 : :
2942 : 0 : ison = !strcmp(res->state, "on");
2943 : :
2944 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2945 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2946 : : needreconfig = 1;
2947 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2948 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2949 : : needreconfig = 1;
2950 : : }
2951 : :
2952 : : if (needreconfig)
2953 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2954 : : }
2955 : :
2956 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2957 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2958 : : port, "port");
2959 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2960 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2961 : : port_id, RTE_UINT16);
2962 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2963 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2964 : : rxtxq, "rxq#txq");
2965 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2966 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2967 : : qid, RTE_UINT16);
2968 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2969 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2970 : : opname, "deferred_start");
2971 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2972 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2973 : : state, "on#off");
2974 : :
2975 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2976 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2977 : : .data = NULL,
2978 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2979 : : .tokens = {
2980 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2981 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2982 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2983 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2984 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2985 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2986 : : NULL,
2987 : : },
2988 : : };
2989 : :
2990 : : /* *** configure port rxq/txq setup *** */
2991 : : struct cmd_setup_rxtx_queue {
2992 : : cmdline_fixed_string_t port;
2993 : : portid_t portid;
2994 : : cmdline_fixed_string_t rxtxq;
2995 : : uint16_t qid;
2996 : : cmdline_fixed_string_t setup;
2997 : : };
2998 : :
2999 : : /* Common CLI fields for queue setup */
3000 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3001 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3002 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3003 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3004 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3005 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3006 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3007 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3008 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3009 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3010 : :
3011 : : static void
3012 : 0 : cmd_setup_rxtx_queue_parsed(
3013 : : void *parsed_result,
3014 : : __rte_unused struct cmdline *cl,
3015 : : __rte_unused void *data)
3016 : : {
3017 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3018 : : struct rte_port *port;
3019 : : struct rte_mempool *mp;
3020 : : unsigned int socket_id;
3021 : : uint8_t isrx = 0;
3022 : : int ret;
3023 : :
3024 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3025 : : return;
3026 : :
3027 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3028 : 0 : fprintf(stderr, "Invalid port id\n");
3029 : 0 : return;
3030 : : }
3031 : :
3032 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3033 : : isrx = 1;
3034 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3035 : : isrx = 0;
3036 : : else {
3037 : 0 : fprintf(stderr, "Unknown parameter\n");
3038 : 0 : return;
3039 : : }
3040 : :
3041 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3042 : 0 : fprintf(stderr, "Invalid rx queue\n");
3043 : 0 : return;
3044 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3045 : 0 : fprintf(stderr, "Invalid tx queue\n");
3046 : 0 : return;
3047 : : }
3048 : :
3049 : 0 : port = &ports[res->portid];
3050 : 0 : if (isrx) {
3051 : 0 : socket_id = rxring_numa[res->portid];
3052 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3053 : 0 : socket_id = port->socket_id;
3054 : :
3055 : : mp = mbuf_pool_find(socket_id, 0);
3056 : 0 : if (mp == NULL) {
3057 : 0 : fprintf(stderr,
3058 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3059 : 0 : rxring_numa[res->portid]);
3060 : 0 : return;
3061 : : }
3062 : 0 : ret = rx_queue_setup(res->portid,
3063 : : res->qid,
3064 : 0 : port->nb_rx_desc[res->qid],
3065 : : socket_id,
3066 : 0 : &port->rxq[res->qid].conf,
3067 : : mp);
3068 : 0 : if (ret)
3069 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3070 : : } else {
3071 : 0 : socket_id = txring_numa[res->portid];
3072 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3073 : 0 : socket_id = port->socket_id;
3074 : :
3075 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3076 : 0 : fprintf(stderr,
3077 : : "Failed to setup TX queue: not enough descriptors\n");
3078 : 0 : return;
3079 : : }
3080 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3081 : : res->qid,
3082 : : port->nb_tx_desc[res->qid],
3083 : : socket_id,
3084 : 0 : &port->txq[res->qid].conf);
3085 : 0 : if (ret)
3086 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3087 : : }
3088 : : }
3089 : :
3090 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3091 : : .f = cmd_setup_rxtx_queue_parsed,
3092 : : .data = NULL,
3093 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3094 : : .tokens = {
3095 : : (void *)&cmd_setup_rxtx_queue_port,
3096 : : (void *)&cmd_setup_rxtx_queue_portid,
3097 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3098 : : (void *)&cmd_setup_rxtx_queue_qid,
3099 : : (void *)&cmd_setup_rxtx_queue_setup,
3100 : : NULL,
3101 : : },
3102 : : };
3103 : :
3104 : :
3105 : : /* *** Configure RSS RETA *** */
3106 : : struct cmd_config_rss_reta {
3107 : : cmdline_fixed_string_t port;
3108 : : cmdline_fixed_string_t keyword;
3109 : : portid_t port_id;
3110 : : cmdline_fixed_string_t name;
3111 : : cmdline_fixed_string_t list_name;
3112 : : cmdline_fixed_string_t list_of_items;
3113 : : };
3114 : :
3115 : : static int
3116 : 0 : parse_reta_config(const char *str,
3117 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3118 : : uint16_t nb_entries)
3119 : : {
3120 : : int i;
3121 : : unsigned size;
3122 : : uint16_t hash_index, idx, shift;
3123 : : uint16_t nb_queue;
3124 : : char s[256];
3125 : : const char *p, *p0 = str;
3126 : : char *end;
3127 : : enum fieldnames {
3128 : : FLD_HASH_INDEX = 0,
3129 : : FLD_QUEUE,
3130 : : _NUM_FLD
3131 : : };
3132 : : unsigned long int_fld[_NUM_FLD];
3133 : : char *str_fld[_NUM_FLD];
3134 : :
3135 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3136 : 0 : ++p;
3137 : 0 : if((p0 = strchr(p,')')) == NULL)
3138 : : return -1;
3139 : :
3140 : 0 : size = p0 - p;
3141 : 0 : if(size >= sizeof(s))
3142 : : return -1;
3143 : :
3144 : : snprintf(s, sizeof(s), "%.*s", size, p);
3145 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3146 : : return -1;
3147 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3148 : 0 : errno = 0;
3149 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3150 : 0 : if (errno != 0 || end == str_fld[i] ||
3151 : : int_fld[i] > 65535)
3152 : : return -1;
3153 : : }
3154 : :
3155 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3156 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3157 : :
3158 : 0 : if (hash_index >= nb_entries) {
3159 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3160 : : hash_index);
3161 : 0 : return -1;
3162 : : }
3163 : :
3164 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3165 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3166 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3167 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3168 : : }
3169 : :
3170 : : return 0;
3171 : : }
3172 : :
3173 : : static void
3174 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3175 : : __rte_unused struct cmdline *cl,
3176 : : __rte_unused void *data)
3177 : : {
3178 : : int ret;
3179 : : struct rte_eth_dev_info dev_info;
3180 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3181 : : struct cmd_config_rss_reta *res = parsed_result;
3182 : :
3183 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3184 : 0 : if (ret != 0)
3185 : 0 : return;
3186 : :
3187 : 0 : if (dev_info.reta_size == 0) {
3188 : 0 : fprintf(stderr,
3189 : : "Redirection table size is 0 which is invalid for RSS\n");
3190 : 0 : return;
3191 : : } else
3192 : 0 : printf("The reta size of port %d is %u\n",
3193 : 0 : res->port_id, dev_info.reta_size);
3194 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3195 : 0 : fprintf(stderr,
3196 : : "Currently do not support more than %u entries of redirection table\n",
3197 : : RTE_ETH_RSS_RETA_SIZE_512);
3198 : 0 : return;
3199 : : }
3200 : :
3201 : : memset(reta_conf, 0, sizeof(reta_conf));
3202 : 0 : if (!strcmp(res->list_name, "reta")) {
3203 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3204 : : dev_info.reta_size)) {
3205 : 0 : fprintf(stderr,
3206 : : "Invalid RSS Redirection Table config entered\n");
3207 : 0 : return;
3208 : : }
3209 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3210 : 0 : reta_conf, dev_info.reta_size);
3211 : 0 : if (ret != 0)
3212 : 0 : fprintf(stderr,
3213 : : "Bad redirection table parameter, return code = %d\n",
3214 : : ret);
3215 : : }
3216 : : }
3217 : :
3218 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3219 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3220 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3221 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3222 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3223 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3224 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3226 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3227 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3228 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3229 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3230 : : NULL);
3231 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3232 : : .f = cmd_set_rss_reta_parsed,
3233 : : .data = NULL,
3234 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3235 : : .tokens = {
3236 : : (void *)&cmd_config_rss_reta_port,
3237 : : (void *)&cmd_config_rss_reta_keyword,
3238 : : (void *)&cmd_config_rss_reta_port_id,
3239 : : (void *)&cmd_config_rss_reta_name,
3240 : : (void *)&cmd_config_rss_reta_list_name,
3241 : : (void *)&cmd_config_rss_reta_list_of_items,
3242 : : NULL,
3243 : : },
3244 : : };
3245 : :
3246 : : /* *** SHOW PORT RETA INFO *** */
3247 : : struct cmd_showport_reta {
3248 : : cmdline_fixed_string_t show;
3249 : : cmdline_fixed_string_t port;
3250 : : portid_t port_id;
3251 : : cmdline_fixed_string_t rss;
3252 : : cmdline_fixed_string_t reta;
3253 : : uint16_t size;
3254 : : cmdline_fixed_string_t list_of_items;
3255 : : };
3256 : :
3257 : : static int
3258 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3259 : : uint16_t nb_entries,
3260 : : char *str)
3261 : : {
3262 : : uint32_t size;
3263 : : const char *p, *p0 = str;
3264 : : char s[256];
3265 : : char *end;
3266 : : char *str_fld[8];
3267 : : uint16_t i;
3268 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3269 : : RTE_ETH_RETA_GROUP_SIZE;
3270 : : int ret;
3271 : :
3272 : 0 : p = strchr(p0, '(');
3273 : 0 : if (p == NULL)
3274 : : return -1;
3275 : 0 : p++;
3276 : 0 : p0 = strchr(p, ')');
3277 : 0 : if (p0 == NULL)
3278 : : return -1;
3279 : 0 : size = p0 - p;
3280 : 0 : if (size >= sizeof(s)) {
3281 : 0 : fprintf(stderr,
3282 : : "The string size exceeds the internal buffer size\n");
3283 : 0 : return -1;
3284 : : }
3285 : : snprintf(s, sizeof(s), "%.*s", size, p);
3286 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3287 : 0 : if (ret <= 0 || ret != num) {
3288 : 0 : fprintf(stderr,
3289 : : "The bits of masks do not match the number of reta entries: %u\n",
3290 : : num);
3291 : 0 : return -1;
3292 : : }
3293 : 0 : for (i = 0; i < ret; i++)
3294 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3295 : :
3296 : : return 0;
3297 : : }
3298 : :
3299 : : static void
3300 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3301 : : __rte_unused struct cmdline *cl,
3302 : : __rte_unused void *data)
3303 : : {
3304 : : struct cmd_showport_reta *res = parsed_result;
3305 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3306 : : struct rte_eth_dev_info dev_info;
3307 : : uint16_t max_reta_size;
3308 : : int ret;
3309 : :
3310 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3311 : 0 : if (ret != 0)
3312 : 0 : return;
3313 : :
3314 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3315 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3316 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3317 : : res->size, max_reta_size);
3318 : 0 : return;
3319 : : }
3320 : :
3321 : : memset(reta_conf, 0, sizeof(reta_conf));
3322 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3323 : 0 : res->list_of_items) < 0) {
3324 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3325 : : res->list_of_items);
3326 : 0 : return;
3327 : : }
3328 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3329 : : }
3330 : :
3331 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3332 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3333 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3334 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3335 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3336 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3337 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3338 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3339 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3340 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3341 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3342 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3343 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3344 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3345 : : list_of_items, NULL);
3346 : :
3347 : : static cmdline_parse_inst_t cmd_showport_reta = {
3348 : : .f = cmd_showport_reta_parsed,
3349 : : .data = NULL,
3350 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3351 : : .tokens = {
3352 : : (void *)&cmd_showport_reta_show,
3353 : : (void *)&cmd_showport_reta_port,
3354 : : (void *)&cmd_showport_reta_port_id,
3355 : : (void *)&cmd_showport_reta_rss,
3356 : : (void *)&cmd_showport_reta_reta,
3357 : : (void *)&cmd_showport_reta_size,
3358 : : (void *)&cmd_showport_reta_list_of_items,
3359 : : NULL,
3360 : : },
3361 : : };
3362 : :
3363 : : /* *** Show RSS hash configuration *** */
3364 : : struct cmd_showport_rss_hash {
3365 : : cmdline_fixed_string_t show;
3366 : : cmdline_fixed_string_t port;
3367 : : portid_t port_id;
3368 : : cmdline_fixed_string_t rss_hash;
3369 : : cmdline_fixed_string_t rss_type;
3370 : : cmdline_fixed_string_t key; /* optional argument */
3371 : : cmdline_fixed_string_t algorithm; /* optional argument */
3372 : : };
3373 : :
3374 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3375 : : __rte_unused struct cmdline *cl,
3376 : : __rte_unused void *data)
3377 : : {
3378 : : struct cmd_showport_rss_hash *res = parsed_result;
3379 : :
3380 : 0 : port_rss_hash_conf_show(res->port_id,
3381 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3382 : 0 : }
3383 : :
3384 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3385 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3386 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3387 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3388 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3389 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3390 : : RTE_UINT16);
3391 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3392 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3393 : : "rss-hash");
3394 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3395 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3396 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3397 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3398 : :
3399 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3400 : : .f = cmd_showport_rss_hash_parsed,
3401 : : .data = NULL,
3402 : : .help_str = "show port <port_id> rss-hash",
3403 : : .tokens = {
3404 : : (void *)&cmd_showport_rss_hash_show,
3405 : : (void *)&cmd_showport_rss_hash_port,
3406 : : (void *)&cmd_showport_rss_hash_port_id,
3407 : : (void *)&cmd_showport_rss_hash_rss_hash,
3408 : : NULL,
3409 : : },
3410 : : };
3411 : :
3412 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3413 : : .f = cmd_showport_rss_hash_parsed,
3414 : : .data = NULL,
3415 : : .help_str = "show port <port_id> rss-hash key",
3416 : : .tokens = {
3417 : : (void *)&cmd_showport_rss_hash_show,
3418 : : (void *)&cmd_showport_rss_hash_port,
3419 : : (void *)&cmd_showport_rss_hash_port_id,
3420 : : (void *)&cmd_showport_rss_hash_rss_hash,
3421 : : (void *)&cmd_showport_rss_hash_rss_key,
3422 : : NULL,
3423 : : },
3424 : : };
3425 : :
3426 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3427 : : .f = cmd_showport_rss_hash_parsed,
3428 : : .data = NULL,
3429 : : .help_str = "show port <port_id> rss-hash algorithm",
3430 : : .tokens = {
3431 : : (void *)&cmd_showport_rss_hash_show,
3432 : : (void *)&cmd_showport_rss_hash_port,
3433 : : (void *)&cmd_showport_rss_hash_port_id,
3434 : : (void *)&cmd_showport_rss_hash_rss_hash,
3435 : : (void *)&cmd_showport_rss_hash_rss_algo,
3436 : : NULL,
3437 : : },
3438 : : };
3439 : :
3440 : : /* *** Configure DCB *** */
3441 : : struct cmd_config_dcb {
3442 : : cmdline_fixed_string_t port;
3443 : : cmdline_fixed_string_t config;
3444 : : portid_t port_id;
3445 : : cmdline_fixed_string_t dcb;
3446 : : cmdline_fixed_string_t vt;
3447 : : cmdline_fixed_string_t vt_en;
3448 : : uint8_t num_tcs;
3449 : : cmdline_fixed_string_t pfc;
3450 : : cmdline_fixed_string_t pfc_en;
3451 : : };
3452 : :
3453 : : static void
3454 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3455 : : __rte_unused struct cmdline *cl,
3456 : : __rte_unused void *data)
3457 : : {
3458 : : struct cmd_config_dcb *res = parsed_result;
3459 : : struct rte_eth_dcb_info dcb_info;
3460 : 0 : portid_t port_id = res->port_id;
3461 : : struct rte_port *port;
3462 : : uint8_t pfc_en;
3463 : : int ret;
3464 : :
3465 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3466 : 0 : return;
3467 : :
3468 : 0 : port = &ports[port_id];
3469 : : /** Check if the port is not started **/
3470 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3471 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3472 : 0 : return;
3473 : : }
3474 : :
3475 : 0 : if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3476 : 0 : fprintf(stderr,
3477 : : "The invalid number of traffic class, only 4 or 8 allowed.\n");
3478 : 0 : return;
3479 : : }
3480 : :
3481 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3482 : 0 : fprintf(stderr,
3483 : : "nb_cores shouldn't be less than number of TCs.\n");
3484 : 0 : return;
3485 : : }
3486 : :
3487 : : /* Check whether the port supports the report of DCB info. */
3488 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3489 : 0 : if (ret == -ENOTSUP) {
3490 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3491 : 0 : return;
3492 : : }
3493 : :
3494 : 0 : if (!strncmp(res->pfc_en, "on", 2))
3495 : : pfc_en = 1;
3496 : : else
3497 : : pfc_en = 0;
3498 : :
3499 : : /* DCB in VT mode */
3500 : 0 : if (!strncmp(res->vt_en, "on", 2))
3501 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3502 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3503 : : pfc_en);
3504 : : else
3505 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3506 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3507 : : pfc_en);
3508 : 0 : if (ret != 0) {
3509 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3510 : 0 : return;
3511 : : }
3512 : :
3513 : 0 : fwd_config_setup();
3514 : :
3515 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3516 : : }
3517 : :
3518 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3519 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3520 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3521 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3522 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3523 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3524 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3525 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3526 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3527 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3528 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3529 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3530 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3531 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3532 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3533 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3534 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3535 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3536 : :
3537 : : static cmdline_parse_inst_t cmd_config_dcb = {
3538 : : .f = cmd_config_dcb_parsed,
3539 : : .data = NULL,
3540 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3541 : : .tokens = {
3542 : : (void *)&cmd_config_dcb_port,
3543 : : (void *)&cmd_config_dcb_config,
3544 : : (void *)&cmd_config_dcb_port_id,
3545 : : (void *)&cmd_config_dcb_dcb,
3546 : : (void *)&cmd_config_dcb_vt,
3547 : : (void *)&cmd_config_dcb_vt_en,
3548 : : (void *)&cmd_config_dcb_num_tcs,
3549 : : (void *)&cmd_config_dcb_pfc,
3550 : : (void *)&cmd_config_dcb_pfc_en,
3551 : : NULL,
3552 : : },
3553 : : };
3554 : :
3555 : : /* *** configure number of packets per burst *** */
3556 : : struct cmd_config_burst {
3557 : : cmdline_fixed_string_t port;
3558 : : cmdline_fixed_string_t keyword;
3559 : : cmdline_fixed_string_t all;
3560 : : cmdline_fixed_string_t name;
3561 : : uint16_t value;
3562 : : };
3563 : :
3564 : : static void
3565 : 0 : cmd_config_burst_parsed(void *parsed_result,
3566 : : __rte_unused struct cmdline *cl,
3567 : : __rte_unused void *data)
3568 : : {
3569 : : struct cmd_config_burst *res = parsed_result;
3570 : : struct rte_eth_dev_info dev_info;
3571 : : uint16_t rec_nb_pkts;
3572 : : int ret;
3573 : :
3574 : 0 : if (!all_ports_stopped()) {
3575 : 0 : fprintf(stderr, "Please stop all ports first\n");
3576 : 0 : return;
3577 : : }
3578 : :
3579 : 0 : if (!strcmp(res->name, "burst")) {
3580 : 0 : if (res->value == 0) {
3581 : : /* If user gives a value of zero, query the PMD for
3582 : : * its recommended Rx burst size. Testpmd uses a single
3583 : : * size for all ports, so assume all ports are the same
3584 : : * NIC model and use the values from Port 0.
3585 : : */
3586 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3587 : 0 : if (ret != 0)
3588 : : return;
3589 : :
3590 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3591 : :
3592 : 0 : if (rec_nb_pkts == 0) {
3593 : : printf("PMD does not recommend a burst size.\n"
3594 : : "User provided value must be between"
3595 : : " 1 and %d\n", MAX_PKT_BURST);
3596 : 0 : return;
3597 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3598 : 0 : printf("PMD recommended burst size of %d"
3599 : : " exceeds maximum value of %d\n",
3600 : : rec_nb_pkts, MAX_PKT_BURST);
3601 : 0 : return;
3602 : : }
3603 : 0 : printf("Using PMD-provided burst value of %d\n",
3604 : : rec_nb_pkts);
3605 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3606 : 0 : } else if (res->value > MAX_PKT_BURST) {
3607 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3608 : : MAX_PKT_BURST);
3609 : 0 : return;
3610 : : } else
3611 : 0 : nb_pkt_per_burst = res->value;
3612 : : } else {
3613 : 0 : fprintf(stderr, "Unknown parameter\n");
3614 : 0 : return;
3615 : : }
3616 : :
3617 : 0 : init_port_config();
3618 : :
3619 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3620 : : }
3621 : :
3622 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3623 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3624 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3625 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3626 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3627 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3628 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3629 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3630 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3631 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3632 : :
3633 : : static cmdline_parse_inst_t cmd_config_burst = {
3634 : : .f = cmd_config_burst_parsed,
3635 : : .data = NULL,
3636 : : .help_str = "port config all burst <value>",
3637 : : .tokens = {
3638 : : (void *)&cmd_config_burst_port,
3639 : : (void *)&cmd_config_burst_keyword,
3640 : : (void *)&cmd_config_burst_all,
3641 : : (void *)&cmd_config_burst_name,
3642 : : (void *)&cmd_config_burst_value,
3643 : : NULL,
3644 : : },
3645 : : };
3646 : :
3647 : : /* *** configure rx/tx queues *** */
3648 : : struct cmd_config_thresh {
3649 : : cmdline_fixed_string_t port;
3650 : : cmdline_fixed_string_t keyword;
3651 : : cmdline_fixed_string_t all;
3652 : : cmdline_fixed_string_t name;
3653 : : uint8_t value;
3654 : : };
3655 : :
3656 : : static void
3657 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3658 : : __rte_unused struct cmdline *cl,
3659 : : __rte_unused void *data)
3660 : : {
3661 : : struct cmd_config_thresh *res = parsed_result;
3662 : :
3663 : 0 : if (!all_ports_stopped()) {
3664 : 0 : fprintf(stderr, "Please stop all ports first\n");
3665 : 0 : return;
3666 : : }
3667 : :
3668 : 0 : if (!strcmp(res->name, "txpt"))
3669 : 0 : tx_pthresh = res->value;
3670 : 0 : else if(!strcmp(res->name, "txht"))
3671 : 0 : tx_hthresh = res->value;
3672 : 0 : else if(!strcmp(res->name, "txwt"))
3673 : 0 : tx_wthresh = res->value;
3674 : 0 : else if(!strcmp(res->name, "rxpt"))
3675 : 0 : rx_pthresh = res->value;
3676 : 0 : else if(!strcmp(res->name, "rxht"))
3677 : 0 : rx_hthresh = res->value;
3678 : 0 : else if(!strcmp(res->name, "rxwt"))
3679 : 0 : rx_wthresh = res->value;
3680 : : else {
3681 : 0 : fprintf(stderr, "Unknown parameter\n");
3682 : 0 : return;
3683 : : }
3684 : :
3685 : 0 : init_port_config();
3686 : :
3687 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3688 : : }
3689 : :
3690 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3691 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3692 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3693 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3694 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3695 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3696 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3697 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3698 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3699 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3700 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3701 : :
3702 : : static cmdline_parse_inst_t cmd_config_thresh = {
3703 : : .f = cmd_config_thresh_parsed,
3704 : : .data = NULL,
3705 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3706 : : .tokens = {
3707 : : (void *)&cmd_config_thresh_port,
3708 : : (void *)&cmd_config_thresh_keyword,
3709 : : (void *)&cmd_config_thresh_all,
3710 : : (void *)&cmd_config_thresh_name,
3711 : : (void *)&cmd_config_thresh_value,
3712 : : NULL,
3713 : : },
3714 : : };
3715 : :
3716 : : /* *** configure free/rs threshold *** */
3717 : : struct cmd_config_threshold {
3718 : : cmdline_fixed_string_t port;
3719 : : cmdline_fixed_string_t keyword;
3720 : : cmdline_fixed_string_t all;
3721 : : cmdline_fixed_string_t name;
3722 : : uint16_t value;
3723 : : };
3724 : :
3725 : : static void
3726 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3727 : : __rte_unused struct cmdline *cl,
3728 : : __rte_unused void *data)
3729 : : {
3730 : : struct cmd_config_threshold *res = parsed_result;
3731 : :
3732 : 0 : if (!all_ports_stopped()) {
3733 : 0 : fprintf(stderr, "Please stop all ports first\n");
3734 : 0 : return;
3735 : : }
3736 : :
3737 : 0 : if (!strcmp(res->name, "txfreet"))
3738 : 0 : tx_free_thresh = res->value;
3739 : 0 : else if (!strcmp(res->name, "txrst"))
3740 : 0 : tx_rs_thresh = res->value;
3741 : 0 : else if (!strcmp(res->name, "rxfreet"))
3742 : 0 : rx_free_thresh = res->value;
3743 : : else {
3744 : 0 : fprintf(stderr, "Unknown parameter\n");
3745 : 0 : return;
3746 : : }
3747 : :
3748 : 0 : init_port_config();
3749 : :
3750 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3751 : : }
3752 : :
3753 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3754 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3755 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3756 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3757 : : "config");
3758 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3759 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3760 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3761 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3762 : : "txfreet#txrst#rxfreet");
3763 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3764 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3765 : :
3766 : : static cmdline_parse_inst_t cmd_config_threshold = {
3767 : : .f = cmd_config_threshold_parsed,
3768 : : .data = NULL,
3769 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3770 : : .tokens = {
3771 : : (void *)&cmd_config_threshold_port,
3772 : : (void *)&cmd_config_threshold_keyword,
3773 : : (void *)&cmd_config_threshold_all,
3774 : : (void *)&cmd_config_threshold_name,
3775 : : (void *)&cmd_config_threshold_value,
3776 : : NULL,
3777 : : },
3778 : : };
3779 : :
3780 : : /* *** stop *** */
3781 : : struct cmd_stop_result {
3782 : : cmdline_fixed_string_t stop;
3783 : : };
3784 : :
3785 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3786 : : __rte_unused struct cmdline *cl,
3787 : : __rte_unused void *data)
3788 : : {
3789 : 0 : stop_packet_forwarding();
3790 : 0 : }
3791 : :
3792 : : static cmdline_parse_token_string_t cmd_stop_stop =
3793 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3794 : :
3795 : : static cmdline_parse_inst_t cmd_stop = {
3796 : : .f = cmd_stop_parsed,
3797 : : .data = NULL,
3798 : : .help_str = "stop: Stop packet forwarding",
3799 : : .tokens = {
3800 : : (void *)&cmd_stop_stop,
3801 : : NULL,
3802 : : },
3803 : : };
3804 : :
3805 : : static unsigned int
3806 : 0 : get_ptype(char *value)
3807 : : {
3808 : : uint32_t protocol;
3809 : :
3810 : 0 : if (!strcmp(value, "eth"))
3811 : : protocol = RTE_PTYPE_L2_ETHER;
3812 : 0 : else if (!strcmp(value, "ipv4"))
3813 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3814 : 0 : else if (!strcmp(value, "ipv6"))
3815 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3816 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3817 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3818 : 0 : else if (!strcmp(value, "ipv4-udp"))
3819 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3820 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3821 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3822 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3823 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3824 : 0 : else if (!strcmp(value, "ipv6-udp"))
3825 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3826 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3827 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3828 : 0 : else if (!strcmp(value, "grenat"))
3829 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3830 : 0 : else if (!strcmp(value, "inner-eth"))
3831 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3832 : 0 : else if (!strcmp(value, "inner-ipv4"))
3833 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3834 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3835 : 0 : else if (!strcmp(value, "inner-ipv6"))
3836 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3837 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3838 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
3839 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3840 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3841 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
3842 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3843 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3844 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
3845 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3846 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3847 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
3848 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3849 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3850 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
3851 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3852 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3853 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
3854 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3855 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3856 : : else {
3857 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
3858 : : protocol = RTE_PTYPE_UNKNOWN;
3859 : : }
3860 : :
3861 : 0 : return protocol;
3862 : : }
3863 : :
3864 : : /* *** SET RXHDRSLIST *** */
3865 : :
3866 : : unsigned int
3867 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
3868 : : unsigned int *parsed_items)
3869 : : {
3870 : : unsigned int nb_item;
3871 : : char *cur;
3872 : : char *tmp;
3873 : :
3874 : : nb_item = 0;
3875 : 0 : char *str2 = strdup(str);
3876 : 0 : if (str2 == NULL)
3877 : : return nb_item;
3878 : 0 : cur = strtok_r(str2, ",", &tmp);
3879 : 0 : while (cur != NULL) {
3880 : 0 : parsed_items[nb_item] = get_ptype(cur);
3881 : 0 : cur = strtok_r(NULL, ",", &tmp);
3882 : 0 : nb_item++;
3883 : : }
3884 : 0 : if (nb_item > max_items)
3885 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3886 : : item_name, nb_item + 1, max_items);
3887 : 0 : free(str2);
3888 : 0 : return nb_item;
3889 : : }
3890 : :
3891 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3892 : :
3893 : : unsigned int
3894 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3895 : : unsigned int *parsed_items, int check_unique_values)
3896 : : {
3897 : : unsigned int nb_item;
3898 : : unsigned int value;
3899 : : unsigned int i;
3900 : : unsigned int j;
3901 : : int value_ok;
3902 : : char c;
3903 : :
3904 : : /*
3905 : : * First parse all items in the list and store their value.
3906 : : */
3907 : : value = 0;
3908 : : nb_item = 0;
3909 : : value_ok = 0;
3910 : 0 : for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3911 : 0 : c = str[i];
3912 : 0 : if ((c >= '0') && (c <= '9')) {
3913 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
3914 : : value_ok = 1;
3915 : 0 : continue;
3916 : : }
3917 : 0 : if (c != ',') {
3918 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
3919 : 0 : return 0;
3920 : : }
3921 : 0 : if (! value_ok) {
3922 : 0 : fprintf(stderr, "No valid value before comma\n");
3923 : 0 : return 0;
3924 : : }
3925 : 0 : if (nb_item < max_items) {
3926 : 0 : parsed_items[nb_item] = value;
3927 : : value_ok = 0;
3928 : : value = 0;
3929 : : }
3930 : 0 : nb_item++;
3931 : : }
3932 : 0 : if (nb_item >= max_items) {
3933 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3934 : : item_name, nb_item + 1, max_items);
3935 : 0 : return 0;
3936 : : }
3937 : 0 : parsed_items[nb_item++] = value;
3938 : 0 : if (! check_unique_values)
3939 : : return nb_item;
3940 : :
3941 : : /*
3942 : : * Then, check that all values in the list are different.
3943 : : * No optimization here...
3944 : : */
3945 : 0 : for (i = 0; i < nb_item; i++) {
3946 : 0 : for (j = i + 1; j < nb_item; j++) {
3947 : 0 : if (parsed_items[j] == parsed_items[i]) {
3948 : 0 : fprintf(stderr,
3949 : : "duplicated %s %u at index %u and %u\n",
3950 : : item_name, parsed_items[i], i, j);
3951 : 0 : return 0;
3952 : : }
3953 : : }
3954 : : }
3955 : : return nb_item;
3956 : : }
3957 : :
3958 : : struct cmd_set_list_result {
3959 : : cmdline_fixed_string_t cmd_keyword;
3960 : : cmdline_fixed_string_t list_name;
3961 : : cmdline_fixed_string_t list_of_items;
3962 : : };
3963 : :
3964 : 0 : static void cmd_set_list_parsed(void *parsed_result,
3965 : : __rte_unused struct cmdline *cl,
3966 : : __rte_unused void *data)
3967 : : {
3968 : : struct cmd_set_list_result *res;
3969 : : union {
3970 : : unsigned int lcorelist[RTE_MAX_LCORE];
3971 : : unsigned int portlist[RTE_MAX_ETHPORTS];
3972 : : } parsed_items;
3973 : : unsigned int nb_item;
3974 : :
3975 : 0 : if (test_done == 0) {
3976 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3977 : 0 : return;
3978 : : }
3979 : :
3980 : : res = parsed_result;
3981 : 0 : if (!strcmp(res->list_name, "corelist")) {
3982 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
3983 : : RTE_MAX_LCORE,
3984 : : parsed_items.lcorelist, 1);
3985 : 0 : if (nb_item > 0) {
3986 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3987 : 0 : fwd_config_setup();
3988 : : }
3989 : 0 : return;
3990 : : }
3991 : 0 : if (!strcmp(res->list_name, "portlist")) {
3992 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
3993 : : RTE_MAX_ETHPORTS,
3994 : : parsed_items.portlist, 1);
3995 : 0 : if (nb_item > 0) {
3996 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
3997 : 0 : fwd_config_setup();
3998 : : }
3999 : : }
4000 : : }
4001 : :
4002 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4003 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4004 : : "set");
4005 : : static cmdline_parse_token_string_t cmd_set_list_name =
4006 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4007 : : "corelist#portlist");
4008 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4009 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4010 : : NULL);
4011 : :
4012 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4013 : : .f = cmd_set_list_parsed,
4014 : : .data = NULL,
4015 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4016 : : .tokens = {
4017 : : (void *)&cmd_set_list_keyword,
4018 : : (void *)&cmd_set_list_name,
4019 : : (void *)&cmd_set_list_of_items,
4020 : : NULL,
4021 : : },
4022 : : };
4023 : :
4024 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4025 : :
4026 : : struct cmd_setmask_result {
4027 : : cmdline_fixed_string_t set;
4028 : : cmdline_fixed_string_t mask;
4029 : : uint64_t hexavalue;
4030 : : };
4031 : :
4032 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4033 : : __rte_unused struct cmdline *cl,
4034 : : __rte_unused void *data)
4035 : : {
4036 : : struct cmd_setmask_result *res = parsed_result;
4037 : :
4038 : 0 : if (test_done == 0) {
4039 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4040 : 0 : return;
4041 : : }
4042 : 0 : if (!strcmp(res->mask, "coremask")) {
4043 : 0 : set_fwd_lcores_mask(res->hexavalue);
4044 : 0 : fwd_config_setup();
4045 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4046 : 0 : set_fwd_ports_mask(res->hexavalue);
4047 : 0 : fwd_config_setup();
4048 : : }
4049 : : }
4050 : :
4051 : : static cmdline_parse_token_string_t cmd_setmask_set =
4052 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4053 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4054 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4055 : : "coremask#portmask");
4056 : : static cmdline_parse_token_num_t cmd_setmask_value =
4057 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4058 : :
4059 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4060 : : .f = cmd_set_mask_parsed,
4061 : : .data = NULL,
4062 : : .help_str = "set coremask|portmask <hexadecimal value>",
4063 : : .tokens = {
4064 : : (void *)&cmd_setmask_set,
4065 : : (void *)&cmd_setmask_mask,
4066 : : (void *)&cmd_setmask_value,
4067 : : NULL,
4068 : : },
4069 : : };
4070 : :
4071 : : /*
4072 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4073 : : */
4074 : : struct cmd_set_result {
4075 : : cmdline_fixed_string_t set;
4076 : : cmdline_fixed_string_t what;
4077 : : uint16_t value;
4078 : : };
4079 : :
4080 : 0 : static void cmd_set_parsed(void *parsed_result,
4081 : : __rte_unused struct cmdline *cl,
4082 : : __rte_unused void *data)
4083 : : {
4084 : : struct cmd_set_result *res = parsed_result;
4085 : 0 : if (!strcmp(res->what, "nbport")) {
4086 : 0 : set_fwd_ports_number(res->value);
4087 : 0 : fwd_config_setup();
4088 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4089 : 0 : set_fwd_lcores_number(res->value);
4090 : 0 : fwd_config_setup();
4091 : 0 : } else if (!strcmp(res->what, "burst"))
4092 : 0 : set_nb_pkt_per_burst(res->value);
4093 : 0 : else if (!strcmp(res->what, "verbose"))
4094 : 0 : set_verbose_level(res->value);
4095 : 0 : }
4096 : :
4097 : : static cmdline_parse_token_string_t cmd_set_set =
4098 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4099 : : static cmdline_parse_token_string_t cmd_set_what =
4100 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4101 : : "nbport#nbcore#burst#verbose");
4102 : : static cmdline_parse_token_num_t cmd_set_value =
4103 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4104 : :
4105 : : static cmdline_parse_inst_t cmd_set_numbers = {
4106 : : .f = cmd_set_parsed,
4107 : : .data = NULL,
4108 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4109 : : .tokens = {
4110 : : (void *)&cmd_set_set,
4111 : : (void *)&cmd_set_what,
4112 : : (void *)&cmd_set_value,
4113 : : NULL,
4114 : : },
4115 : : };
4116 : :
4117 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4118 : :
4119 : : struct cmd_set_log_result {
4120 : : cmdline_fixed_string_t set;
4121 : : cmdline_fixed_string_t log;
4122 : : cmdline_fixed_string_t type;
4123 : : uint32_t level;
4124 : : };
4125 : :
4126 : : static void
4127 : 0 : cmd_set_log_parsed(void *parsed_result,
4128 : : __rte_unused struct cmdline *cl,
4129 : : __rte_unused void *data)
4130 : : {
4131 : : struct cmd_set_log_result *res;
4132 : : int ret;
4133 : :
4134 : : res = parsed_result;
4135 : 0 : if (!strcmp(res->type, "global"))
4136 : 0 : rte_log_set_global_level(res->level);
4137 : : else {
4138 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4139 : 0 : if (ret < 0)
4140 : 0 : fprintf(stderr, "Unable to set log level\n");
4141 : : }
4142 : 0 : }
4143 : :
4144 : : static cmdline_parse_token_string_t cmd_set_log_set =
4145 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4146 : : static cmdline_parse_token_string_t cmd_set_log_log =
4147 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4148 : : static cmdline_parse_token_string_t cmd_set_log_type =
4149 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4150 : : static cmdline_parse_token_num_t cmd_set_log_level =
4151 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4152 : :
4153 : : static cmdline_parse_inst_t cmd_set_log = {
4154 : : .f = cmd_set_log_parsed,
4155 : : .data = NULL,
4156 : : .help_str = "set log global|<type> <level>",
4157 : : .tokens = {
4158 : : (void *)&cmd_set_log_set,
4159 : : (void *)&cmd_set_log_log,
4160 : : (void *)&cmd_set_log_type,
4161 : : (void *)&cmd_set_log_level,
4162 : : NULL,
4163 : : },
4164 : : };
4165 : :
4166 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4167 : :
4168 : : struct cmd_set_rxoffs_result {
4169 : : cmdline_fixed_string_t cmd_keyword;
4170 : : cmdline_fixed_string_t rxoffs;
4171 : : cmdline_fixed_string_t seg_offsets;
4172 : : };
4173 : :
4174 : : static void
4175 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4176 : : __rte_unused struct cmdline *cl,
4177 : : __rte_unused void *data)
4178 : : {
4179 : : struct cmd_set_rxoffs_result *res;
4180 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4181 : : unsigned int nb_segs;
4182 : :
4183 : : res = parsed_result;
4184 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4185 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4186 : 0 : if (nb_segs > 0)
4187 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4188 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4189 : 0 : }
4190 : :
4191 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4192 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4193 : : cmd_keyword, "set");
4194 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4195 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4196 : : rxoffs, "rxoffs");
4197 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4198 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4199 : : seg_offsets, NULL);
4200 : :
4201 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4202 : : .f = cmd_set_rxoffs_parsed,
4203 : : .data = NULL,
4204 : : .help_str = "set rxoffs <len0[,len1]*>",
4205 : : .tokens = {
4206 : : (void *)&cmd_set_rxoffs_keyword,
4207 : : (void *)&cmd_set_rxoffs_name,
4208 : : (void *)&cmd_set_rxoffs_offsets,
4209 : : NULL,
4210 : : },
4211 : : };
4212 : :
4213 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4214 : :
4215 : : struct cmd_set_rxpkts_result {
4216 : : cmdline_fixed_string_t cmd_keyword;
4217 : : cmdline_fixed_string_t rxpkts;
4218 : : cmdline_fixed_string_t seg_lengths;
4219 : : };
4220 : :
4221 : : static void
4222 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4223 : : __rte_unused struct cmdline *cl,
4224 : : __rte_unused void *data)
4225 : : {
4226 : : struct cmd_set_rxpkts_result *res;
4227 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4228 : : unsigned int nb_segs;
4229 : :
4230 : : res = parsed_result;
4231 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4232 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4233 : 0 : if (nb_segs > 0)
4234 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4235 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4236 : 0 : }
4237 : :
4238 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4240 : : cmd_keyword, "set");
4241 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4242 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4243 : : rxpkts, "rxpkts");
4244 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4246 : : seg_lengths, NULL);
4247 : :
4248 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4249 : : .f = cmd_set_rxpkts_parsed,
4250 : : .data = NULL,
4251 : : .help_str = "set rxpkts <len0[,len1]*>",
4252 : : .tokens = {
4253 : : (void *)&cmd_set_rxpkts_keyword,
4254 : : (void *)&cmd_set_rxpkts_name,
4255 : : (void *)&cmd_set_rxpkts_lengths,
4256 : : NULL,
4257 : : },
4258 : : };
4259 : :
4260 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4261 : : struct cmd_set_rxhdrs_result {
4262 : : cmdline_fixed_string_t set;
4263 : : cmdline_fixed_string_t rxhdrs;
4264 : : cmdline_fixed_string_t values;
4265 : : };
4266 : :
4267 : : static void
4268 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4269 : : __rte_unused struct cmdline *cl,
4270 : : __rte_unused void *data)
4271 : : {
4272 : : struct cmd_set_rxhdrs_result *res;
4273 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4274 : : unsigned int nb_segs;
4275 : :
4276 : : res = parsed_result;
4277 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4278 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4279 : 0 : if (nb_segs > 0)
4280 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4281 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4282 : 0 : }
4283 : :
4284 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4285 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4286 : : set, "set");
4287 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4288 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4289 : : rxhdrs, "rxhdrs");
4290 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4291 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4292 : : values, NULL);
4293 : :
4294 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4295 : : .f = cmd_set_rxhdrs_parsed,
4296 : : .data = NULL,
4297 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4298 : : .tokens = {
4299 : : (void *)&cmd_set_rxhdrs_set,
4300 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4301 : : (void *)&cmd_set_rxhdrs_values,
4302 : : NULL,
4303 : : },
4304 : : };
4305 : :
4306 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4307 : :
4308 : : struct cmd_set_txpkts_result {
4309 : : cmdline_fixed_string_t cmd_keyword;
4310 : : cmdline_fixed_string_t txpkts;
4311 : : cmdline_fixed_string_t seg_lengths;
4312 : : };
4313 : :
4314 : : static void
4315 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4316 : : __rte_unused struct cmdline *cl,
4317 : : __rte_unused void *data)
4318 : : {
4319 : : struct cmd_set_txpkts_result *res;
4320 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4321 : : unsigned int nb_segs;
4322 : :
4323 : : res = parsed_result;
4324 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4325 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4326 : 0 : if (nb_segs > 0)
4327 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4328 : 0 : }
4329 : :
4330 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4331 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4332 : : cmd_keyword, "set");
4333 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4334 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4335 : : txpkts, "txpkts");
4336 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4337 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4338 : : seg_lengths, NULL);
4339 : :
4340 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4341 : : .f = cmd_set_txpkts_parsed,
4342 : : .data = NULL,
4343 : : .help_str = "set txpkts <len0[,len1]*>",
4344 : : .tokens = {
4345 : : (void *)&cmd_set_txpkts_keyword,
4346 : : (void *)&cmd_set_txpkts_name,
4347 : : (void *)&cmd_set_txpkts_lengths,
4348 : : NULL,
4349 : : },
4350 : : };
4351 : :
4352 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4353 : :
4354 : : struct cmd_set_txsplit_result {
4355 : : cmdline_fixed_string_t cmd_keyword;
4356 : : cmdline_fixed_string_t txsplit;
4357 : : cmdline_fixed_string_t mode;
4358 : : };
4359 : :
4360 : : static void
4361 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4362 : : __rte_unused struct cmdline *cl,
4363 : : __rte_unused void *data)
4364 : : {
4365 : : struct cmd_set_txsplit_result *res;
4366 : :
4367 : : res = parsed_result;
4368 : 0 : set_tx_pkt_split(res->mode);
4369 : 0 : }
4370 : :
4371 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4372 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4373 : : cmd_keyword, "set");
4374 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4376 : : txsplit, "txsplit");
4377 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4378 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4379 : : mode, NULL);
4380 : :
4381 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4382 : : .f = cmd_set_txsplit_parsed,
4383 : : .data = NULL,
4384 : : .help_str = "set txsplit on|off|rand",
4385 : : .tokens = {
4386 : : (void *)&cmd_set_txsplit_keyword,
4387 : : (void *)&cmd_set_txsplit_name,
4388 : : (void *)&cmd_set_txsplit_mode,
4389 : : NULL,
4390 : : },
4391 : : };
4392 : :
4393 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4394 : :
4395 : : struct cmd_set_txtimes_result {
4396 : : cmdline_fixed_string_t cmd_keyword;
4397 : : cmdline_fixed_string_t txtimes;
4398 : : cmdline_fixed_string_t tx_times;
4399 : : };
4400 : :
4401 : : static void
4402 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4403 : : __rte_unused struct cmdline *cl,
4404 : : __rte_unused void *data)
4405 : : {
4406 : : struct cmd_set_txtimes_result *res;
4407 : 0 : unsigned int tx_times[2] = {0, 0};
4408 : : unsigned int n_times;
4409 : :
4410 : : res = parsed_result;
4411 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4412 : : 2, tx_times, 0);
4413 : 0 : if (n_times == 2)
4414 : 0 : set_tx_pkt_times(tx_times);
4415 : 0 : }
4416 : :
4417 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4418 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4419 : : cmd_keyword, "set");
4420 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4421 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4422 : : txtimes, "txtimes");
4423 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4425 : : tx_times, NULL);
4426 : :
4427 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4428 : : .f = cmd_set_txtimes_parsed,
4429 : : .data = NULL,
4430 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4431 : : .tokens = {
4432 : : (void *)&cmd_set_txtimes_keyword,
4433 : : (void *)&cmd_set_txtimes_name,
4434 : : (void *)&cmd_set_txtimes_value,
4435 : : NULL,
4436 : : },
4437 : : };
4438 : :
4439 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4440 : : struct cmd_rx_vlan_filter_all_result {
4441 : : cmdline_fixed_string_t rx_vlan;
4442 : : cmdline_fixed_string_t what;
4443 : : cmdline_fixed_string_t all;
4444 : : portid_t port_id;
4445 : : };
4446 : :
4447 : : static void
4448 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4449 : : __rte_unused struct cmdline *cl,
4450 : : __rte_unused void *data)
4451 : : {
4452 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4453 : :
4454 : 0 : if (!strcmp(res->what, "add"))
4455 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4456 : : else
4457 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4458 : 0 : }
4459 : :
4460 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4461 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4462 : : rx_vlan, "rx_vlan");
4463 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4464 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4465 : : what, "add#rm");
4466 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4467 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4468 : : all, "all");
4469 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4470 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4471 : : port_id, RTE_UINT16);
4472 : :
4473 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4474 : : .f = cmd_rx_vlan_filter_all_parsed,
4475 : : .data = NULL,
4476 : : .help_str = "rx_vlan add|rm all <port_id>: "
4477 : : "Add/Remove all identifiers to/from the set of VLAN "
4478 : : "identifiers filtered by a port",
4479 : : .tokens = {
4480 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4481 : : (void *)&cmd_rx_vlan_filter_all_what,
4482 : : (void *)&cmd_rx_vlan_filter_all_all,
4483 : : (void *)&cmd_rx_vlan_filter_all_portid,
4484 : : NULL,
4485 : : },
4486 : : };
4487 : :
4488 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4489 : : struct cmd_vlan_offload_result {
4490 : : cmdline_fixed_string_t vlan;
4491 : : cmdline_fixed_string_t set;
4492 : : cmdline_fixed_string_t vlan_type;
4493 : : cmdline_fixed_string_t what;
4494 : : cmdline_fixed_string_t on;
4495 : : cmdline_fixed_string_t port_id;
4496 : : };
4497 : :
4498 : : static void
4499 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4500 : : __rte_unused struct cmdline *cl,
4501 : : __rte_unused void *data)
4502 : : {
4503 : : int on;
4504 : : struct cmd_vlan_offload_result *res = parsed_result;
4505 : : char *str;
4506 : : int i, len = 0;
4507 : : portid_t port_id = 0;
4508 : : unsigned int tmp;
4509 : :
4510 : 0 : str = res->port_id;
4511 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4512 : : i = 0;
4513 : : /* Get port_id first */
4514 : 0 : while(i < len){
4515 : 0 : if(str[i] == ',')
4516 : : break;
4517 : :
4518 : 0 : i++;
4519 : : }
4520 : 0 : str[i]='\0';
4521 : 0 : tmp = strtoul(str, NULL, 0);
4522 : : /* If port_id greater that what portid_t can represent, return */
4523 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4524 : : return;
4525 : 0 : port_id = (portid_t)tmp;
4526 : :
4527 : 0 : if (!strcmp(res->on, "on"))
4528 : : on = 1;
4529 : : else
4530 : : on = 0;
4531 : :
4532 : 0 : if (!strcmp(res->what, "strip"))
4533 : 0 : rx_vlan_strip_set(port_id, on);
4534 : 0 : else if(!strcmp(res->what, "stripq")){
4535 : : uint16_t queue_id = 0;
4536 : :
4537 : : /* No queue_id, return */
4538 : 0 : if(i + 1 >= len) {
4539 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4540 : 0 : return;
4541 : : }
4542 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4543 : : /* If queue_id greater that what 16-bits can represent, return */
4544 : 0 : if(tmp > 0xffff)
4545 : : return;
4546 : :
4547 : 0 : queue_id = (uint16_t)tmp;
4548 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4549 : : }
4550 : 0 : else if (!strcmp(res->what, "filter"))
4551 : 0 : rx_vlan_filter_set(port_id, on);
4552 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4553 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4554 : : else
4555 : 0 : vlan_extend_set(port_id, on);
4556 : :
4557 : : return;
4558 : : }
4559 : :
4560 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4561 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4562 : : vlan, "vlan");
4563 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4564 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4565 : : set, "set");
4566 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4567 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4568 : : what, "strip#filter#qinq_strip#extend#stripq");
4569 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4570 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4571 : : on, "on#off");
4572 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4573 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4574 : : port_id, NULL);
4575 : :
4576 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4577 : : .f = cmd_vlan_offload_parsed,
4578 : : .data = NULL,
4579 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4580 : : "<port_id[,queue_id]>: "
4581 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4582 : : .tokens = {
4583 : : (void *)&cmd_vlan_offload_vlan,
4584 : : (void *)&cmd_vlan_offload_set,
4585 : : (void *)&cmd_vlan_offload_what,
4586 : : (void *)&cmd_vlan_offload_on,
4587 : : (void *)&cmd_vlan_offload_portid,
4588 : : NULL,
4589 : : },
4590 : : };
4591 : :
4592 : : /* *** VLAN TPID SET ON A PORT *** */
4593 : : struct cmd_vlan_tpid_result {
4594 : : cmdline_fixed_string_t vlan;
4595 : : cmdline_fixed_string_t set;
4596 : : cmdline_fixed_string_t vlan_type;
4597 : : cmdline_fixed_string_t what;
4598 : : uint16_t tp_id;
4599 : : portid_t port_id;
4600 : : };
4601 : :
4602 : : static void
4603 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4604 : : __rte_unused struct cmdline *cl,
4605 : : __rte_unused void *data)
4606 : : {
4607 : : struct cmd_vlan_tpid_result *res = parsed_result;
4608 : : enum rte_vlan_type vlan_type;
4609 : :
4610 : 0 : if (!strcmp(res->vlan_type, "inner"))
4611 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4612 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4613 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4614 : : else {
4615 : 0 : fprintf(stderr, "Unknown vlan type\n");
4616 : 0 : return;
4617 : : }
4618 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4619 : : }
4620 : :
4621 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4622 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4623 : : vlan, "vlan");
4624 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4625 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4626 : : set, "set");
4627 : : static cmdline_parse_token_string_t cmd_vlan_type =
4628 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4629 : : vlan_type, "inner#outer");
4630 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4631 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4632 : : what, "tpid");
4633 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4634 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4635 : : tp_id, RTE_UINT16);
4636 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4637 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4638 : : port_id, RTE_UINT16);
4639 : :
4640 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4641 : : .f = cmd_vlan_tpid_parsed,
4642 : : .data = NULL,
4643 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4644 : : "Set the VLAN Ether type",
4645 : : .tokens = {
4646 : : (void *)&cmd_vlan_tpid_vlan,
4647 : : (void *)&cmd_vlan_tpid_set,
4648 : : (void *)&cmd_vlan_type,
4649 : : (void *)&cmd_vlan_tpid_what,
4650 : : (void *)&cmd_vlan_tpid_tpid,
4651 : : (void *)&cmd_vlan_tpid_portid,
4652 : : NULL,
4653 : : },
4654 : : };
4655 : :
4656 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4657 : : struct cmd_rx_vlan_filter_result {
4658 : : cmdline_fixed_string_t rx_vlan;
4659 : : cmdline_fixed_string_t what;
4660 : : uint16_t vlan_id;
4661 : : portid_t port_id;
4662 : : };
4663 : :
4664 : : static void
4665 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4666 : : __rte_unused struct cmdline *cl,
4667 : : __rte_unused void *data)
4668 : : {
4669 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4670 : :
4671 : 0 : if (!strcmp(res->what, "add"))
4672 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4673 : : else
4674 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4675 : 0 : }
4676 : :
4677 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4678 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4679 : : rx_vlan, "rx_vlan");
4680 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4681 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4682 : : what, "add#rm");
4683 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4684 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4685 : : vlan_id, RTE_UINT16);
4686 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4687 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4688 : : port_id, RTE_UINT16);
4689 : :
4690 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4691 : : .f = cmd_rx_vlan_filter_parsed,
4692 : : .data = NULL,
4693 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4694 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4695 : : "identifiers filtered by a port",
4696 : : .tokens = {
4697 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4698 : : (void *)&cmd_rx_vlan_filter_what,
4699 : : (void *)&cmd_rx_vlan_filter_vlanid,
4700 : : (void *)&cmd_rx_vlan_filter_portid,
4701 : : NULL,
4702 : : },
4703 : : };
4704 : :
4705 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4706 : : struct cmd_tx_vlan_set_result {
4707 : : cmdline_fixed_string_t tx_vlan;
4708 : : cmdline_fixed_string_t set;
4709 : : portid_t port_id;
4710 : : uint16_t vlan_id;
4711 : : };
4712 : :
4713 : : static void
4714 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4715 : : __rte_unused struct cmdline *cl,
4716 : : __rte_unused void *data)
4717 : : {
4718 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4719 : :
4720 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4721 : : return;
4722 : :
4723 : 0 : if (!port_is_stopped(res->port_id)) {
4724 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4725 : 0 : return;
4726 : : }
4727 : :
4728 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4729 : :
4730 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4731 : : }
4732 : :
4733 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4734 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4735 : : tx_vlan, "tx_vlan");
4736 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4737 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4738 : : set, "set");
4739 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4740 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4741 : : port_id, RTE_UINT16);
4742 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4743 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4744 : : vlan_id, RTE_UINT16);
4745 : :
4746 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4747 : : .f = cmd_tx_vlan_set_parsed,
4748 : : .data = NULL,
4749 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4750 : : "Enable hardware insertion of a single VLAN header "
4751 : : "with a given TAG Identifier in packets sent on a port",
4752 : : .tokens = {
4753 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4754 : : (void *)&cmd_tx_vlan_set_set,
4755 : : (void *)&cmd_tx_vlan_set_portid,
4756 : : (void *)&cmd_tx_vlan_set_vlanid,
4757 : : NULL,
4758 : : },
4759 : : };
4760 : :
4761 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4762 : : struct cmd_tx_vlan_set_qinq_result {
4763 : : cmdline_fixed_string_t tx_vlan;
4764 : : cmdline_fixed_string_t set;
4765 : : portid_t port_id;
4766 : : uint16_t vlan_id;
4767 : : uint16_t vlan_id_outer;
4768 : : };
4769 : :
4770 : : static void
4771 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4772 : : __rte_unused struct cmdline *cl,
4773 : : __rte_unused void *data)
4774 : : {
4775 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4776 : :
4777 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4778 : : return;
4779 : :
4780 : 0 : if (!port_is_stopped(res->port_id)) {
4781 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4782 : 0 : return;
4783 : : }
4784 : :
4785 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4786 : :
4787 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4788 : : }
4789 : :
4790 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4791 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4792 : : tx_vlan, "tx_vlan");
4793 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4794 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4795 : : set, "set");
4796 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4797 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4798 : : port_id, RTE_UINT16);
4799 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4800 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4801 : : vlan_id, RTE_UINT16);
4802 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4803 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4804 : : vlan_id_outer, RTE_UINT16);
4805 : :
4806 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4807 : : .f = cmd_tx_vlan_set_qinq_parsed,
4808 : : .data = NULL,
4809 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4810 : : "Enable hardware insertion of double VLAN header "
4811 : : "with given TAG Identifiers in packets sent on a port",
4812 : : .tokens = {
4813 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4814 : : (void *)&cmd_tx_vlan_set_qinq_set,
4815 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4816 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4817 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4818 : : NULL,
4819 : : },
4820 : : };
4821 : :
4822 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4823 : : struct cmd_tx_vlan_set_pvid_result {
4824 : : cmdline_fixed_string_t tx_vlan;
4825 : : cmdline_fixed_string_t set;
4826 : : cmdline_fixed_string_t pvid;
4827 : : portid_t port_id;
4828 : : uint16_t vlan_id;
4829 : : cmdline_fixed_string_t mode;
4830 : : };
4831 : :
4832 : : static void
4833 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4834 : : __rte_unused struct cmdline *cl,
4835 : : __rte_unused void *data)
4836 : : {
4837 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4838 : :
4839 : 0 : if (strcmp(res->mode, "on") == 0)
4840 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4841 : : else
4842 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4843 : 0 : }
4844 : :
4845 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4846 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4847 : : tx_vlan, "tx_vlan");
4848 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4849 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4850 : : set, "set");
4851 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4852 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4853 : : pvid, "pvid");
4854 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4855 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4856 : : port_id, RTE_UINT16);
4857 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4858 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4859 : : vlan_id, RTE_UINT16);
4860 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4861 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4862 : : mode, "on#off");
4863 : :
4864 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4865 : : .f = cmd_tx_vlan_set_pvid_parsed,
4866 : : .data = NULL,
4867 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4868 : : .tokens = {
4869 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4870 : : (void *)&cmd_tx_vlan_set_pvid_set,
4871 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
4872 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
4873 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4874 : : (void *)&cmd_tx_vlan_set_pvid_mode,
4875 : : NULL,
4876 : : },
4877 : : };
4878 : :
4879 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4880 : : struct cmd_tx_vlan_reset_result {
4881 : : cmdline_fixed_string_t tx_vlan;
4882 : : cmdline_fixed_string_t reset;
4883 : : portid_t port_id;
4884 : : };
4885 : :
4886 : : static void
4887 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
4888 : : __rte_unused struct cmdline *cl,
4889 : : __rte_unused void *data)
4890 : : {
4891 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
4892 : :
4893 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4894 : : return;
4895 : :
4896 : 0 : if (!port_is_stopped(res->port_id)) {
4897 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4898 : 0 : return;
4899 : : }
4900 : :
4901 : 0 : tx_vlan_reset(res->port_id);
4902 : :
4903 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4904 : : }
4905 : :
4906 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4907 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4908 : : tx_vlan, "tx_vlan");
4909 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4910 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4911 : : reset, "reset");
4912 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4913 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4914 : : port_id, RTE_UINT16);
4915 : :
4916 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4917 : : .f = cmd_tx_vlan_reset_parsed,
4918 : : .data = NULL,
4919 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4920 : : "VLAN header in packets sent on a port",
4921 : : .tokens = {
4922 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
4923 : : (void *)&cmd_tx_vlan_reset_reset,
4924 : : (void *)&cmd_tx_vlan_reset_portid,
4925 : : NULL,
4926 : : },
4927 : : };
4928 : :
4929 : :
4930 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4931 : : struct cmd_csum_result {
4932 : : cmdline_fixed_string_t csum;
4933 : : cmdline_fixed_string_t mode;
4934 : : cmdline_fixed_string_t proto;
4935 : : cmdline_fixed_string_t hwsw;
4936 : : portid_t port_id;
4937 : : };
4938 : :
4939 : : static void
4940 : 0 : csum_show(int port_id)
4941 : : {
4942 : : struct rte_eth_dev_info dev_info;
4943 : : uint64_t tx_offloads;
4944 : : int ret;
4945 : :
4946 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4947 : 0 : printf("Parse tunnel is %s\n",
4948 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
4949 : 0 : printf("IP checksum offload is %s\n",
4950 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4951 : 0 : printf("UDP checksum offload is %s\n",
4952 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4953 : 0 : printf("TCP checksum offload is %s\n",
4954 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4955 : 0 : printf("SCTP checksum offload is %s\n",
4956 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4957 : 0 : printf("Outer-Ip checksum offload is %s\n",
4958 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4959 : 0 : printf("Outer-Udp checksum offload is %s\n",
4960 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4961 : :
4962 : : /* display warnings if configuration is not supported by the NIC */
4963 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
4964 : 0 : if (ret != 0)
4965 : 0 : return;
4966 : :
4967 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4968 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4969 : 0 : fprintf(stderr,
4970 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
4971 : : port_id);
4972 : : }
4973 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4974 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4975 : 0 : fprintf(stderr,
4976 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4977 : : port_id);
4978 : : }
4979 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4980 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4981 : 0 : fprintf(stderr,
4982 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4983 : : port_id);
4984 : : }
4985 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4986 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4987 : 0 : fprintf(stderr,
4988 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4989 : : port_id);
4990 : : }
4991 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4992 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4993 : 0 : fprintf(stderr,
4994 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4995 : : port_id);
4996 : : }
4997 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4998 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4999 : : == 0) {
5000 : 0 : fprintf(stderr,
5001 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5002 : : port_id);
5003 : : }
5004 : : }
5005 : :
5006 : : static void
5007 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5008 : : {
5009 : : int k;
5010 : :
5011 : : /* Apply queue tx offloads configuration */
5012 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5013 : 0 : port->txq[k].conf.offloads =
5014 : 0 : port->dev_conf.txmode.offloads;
5015 : : }
5016 : :
5017 : : static void
5018 : 0 : cmd_csum_parsed(void *parsed_result,
5019 : : __rte_unused struct cmdline *cl,
5020 : : __rte_unused void *data)
5021 : : {
5022 : : struct cmd_csum_result *res = parsed_result;
5023 : : int hw = 0;
5024 : : uint64_t csum_offloads = 0;
5025 : : struct rte_eth_dev_info dev_info;
5026 : : int ret;
5027 : :
5028 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5029 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5030 : 0 : return;
5031 : : }
5032 : 0 : if (!port_is_stopped(res->port_id)) {
5033 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5034 : 0 : return;
5035 : : }
5036 : :
5037 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5038 : 0 : if (ret != 0)
5039 : : return;
5040 : :
5041 : 0 : if (!strcmp(res->mode, "set")) {
5042 : :
5043 : 0 : if (!strcmp(res->hwsw, "hw"))
5044 : : hw = 1;
5045 : :
5046 : 0 : if (!strcmp(res->proto, "ip")) {
5047 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5048 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5049 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5050 : : } else {
5051 : 0 : fprintf(stderr,
5052 : : "IP checksum offload is not supported by port %u\n",
5053 : 0 : res->port_id);
5054 : : }
5055 : 0 : } else if (!strcmp(res->proto, "udp")) {
5056 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5057 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5058 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5059 : : } else {
5060 : 0 : fprintf(stderr,
5061 : : "UDP checksum offload is not supported by port %u\n",
5062 : 0 : res->port_id);
5063 : : }
5064 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5065 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5066 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5067 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5068 : : } else {
5069 : 0 : fprintf(stderr,
5070 : : "TCP checksum offload is not supported by port %u\n",
5071 : 0 : res->port_id);
5072 : : }
5073 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5074 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5075 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5076 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5077 : : } else {
5078 : 0 : fprintf(stderr,
5079 : : "SCTP checksum offload is not supported by port %u\n",
5080 : 0 : res->port_id);
5081 : : }
5082 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5083 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5084 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5085 : : csum_offloads |=
5086 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5087 : : } else {
5088 : 0 : fprintf(stderr,
5089 : : "Outer IP checksum offload is not supported by port %u\n",
5090 : 0 : res->port_id);
5091 : : }
5092 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5093 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5094 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5095 : : csum_offloads |=
5096 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5097 : : } else {
5098 : 0 : fprintf(stderr,
5099 : : "Outer UDP checksum offload is not supported by port %u\n",
5100 : 0 : res->port_id);
5101 : : }
5102 : : }
5103 : :
5104 : 0 : if (hw) {
5105 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5106 : : csum_offloads;
5107 : : } else {
5108 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5109 : 0 : (~csum_offloads);
5110 : : }
5111 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5112 : : }
5113 : 0 : csum_show(res->port_id);
5114 : :
5115 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5116 : : }
5117 : :
5118 : : static cmdline_parse_token_string_t cmd_csum_csum =
5119 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5120 : : csum, "csum");
5121 : : static cmdline_parse_token_string_t cmd_csum_mode =
5122 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5123 : : mode, "set");
5124 : : static cmdline_parse_token_string_t cmd_csum_proto =
5125 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5126 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5127 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5128 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5129 : : hwsw, "hw#sw");
5130 : : static cmdline_parse_token_num_t cmd_csum_portid =
5131 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5132 : : port_id, RTE_UINT16);
5133 : :
5134 : : static cmdline_parse_inst_t cmd_csum_set = {
5135 : : .f = cmd_csum_parsed,
5136 : : .data = NULL,
5137 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5138 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5139 : : "using csum forward engine",
5140 : : .tokens = {
5141 : : (void *)&cmd_csum_csum,
5142 : : (void *)&cmd_csum_mode,
5143 : : (void *)&cmd_csum_proto,
5144 : : (void *)&cmd_csum_hwsw,
5145 : : (void *)&cmd_csum_portid,
5146 : : NULL,
5147 : : },
5148 : : };
5149 : :
5150 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5151 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5152 : : mode, "show");
5153 : :
5154 : : static cmdline_parse_inst_t cmd_csum_show = {
5155 : : .f = cmd_csum_parsed,
5156 : : .data = NULL,
5157 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5158 : : .tokens = {
5159 : : (void *)&cmd_csum_csum,
5160 : : (void *)&cmd_csum_mode_show,
5161 : : (void *)&cmd_csum_portid,
5162 : : NULL,
5163 : : },
5164 : : };
5165 : :
5166 : : /* Enable/disable tunnel parsing */
5167 : : struct cmd_csum_tunnel_result {
5168 : : cmdline_fixed_string_t csum;
5169 : : cmdline_fixed_string_t parse;
5170 : : cmdline_fixed_string_t onoff;
5171 : : portid_t port_id;
5172 : : };
5173 : :
5174 : : static void
5175 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5176 : : __rte_unused struct cmdline *cl,
5177 : : __rte_unused void *data)
5178 : : {
5179 : : struct cmd_csum_tunnel_result *res = parsed_result;
5180 : :
5181 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5182 : : return;
5183 : :
5184 : 0 : if (!strcmp(res->onoff, "on"))
5185 : 0 : ports[res->port_id].parse_tunnel = 1;
5186 : : else
5187 : 0 : ports[res->port_id].parse_tunnel = 0;
5188 : :
5189 : 0 : csum_show(res->port_id);
5190 : : }
5191 : :
5192 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5193 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5194 : : csum, "csum");
5195 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5196 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5197 : : parse, "parse-tunnel");
5198 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5199 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5200 : : onoff, "on#off");
5201 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5202 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5203 : : port_id, RTE_UINT16);
5204 : :
5205 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5206 : : .f = cmd_csum_tunnel_parsed,
5207 : : .data = NULL,
5208 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5209 : : "Enable/Disable parsing of tunnels for csum engine",
5210 : : .tokens = {
5211 : : (void *)&cmd_csum_tunnel_csum,
5212 : : (void *)&cmd_csum_tunnel_parse,
5213 : : (void *)&cmd_csum_tunnel_onoff,
5214 : : (void *)&cmd_csum_tunnel_portid,
5215 : : NULL,
5216 : : },
5217 : : };
5218 : :
5219 : : struct cmd_csum_mac_swap_result {
5220 : : cmdline_fixed_string_t csum;
5221 : : cmdline_fixed_string_t parse;
5222 : : cmdline_fixed_string_t onoff;
5223 : : portid_t port_id;
5224 : : };
5225 : :
5226 : : static void
5227 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5228 : : __rte_unused struct cmdline *cl,
5229 : : __rte_unused void *data)
5230 : : {
5231 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5232 : :
5233 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5234 : : return;
5235 : 0 : if (strcmp(res->onoff, "on") == 0)
5236 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5237 : : else
5238 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5239 : : }
5240 : :
5241 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5242 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5243 : : csum, "csum");
5244 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5245 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5246 : : parse, "mac-swap");
5247 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5248 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5249 : : onoff, "on#off");
5250 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5251 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5252 : : port_id, RTE_UINT16);
5253 : :
5254 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5255 : : .f = cmd_csum_mac_swap_parsed,
5256 : : .data = NULL,
5257 : : .help_str = "csum mac-swap on|off <port_id>: "
5258 : : "Enable/Disable forward mac address swap",
5259 : : .tokens = {
5260 : : (void *)&cmd_csum_mac_swap_csum,
5261 : : (void *)&cmd_csum_mac_swap_parse,
5262 : : (void *)&cmd_csum_mac_swap_onoff,
5263 : : (void *)&cmd_csum_mac_swap_portid,
5264 : : NULL,
5265 : : },
5266 : : };
5267 : :
5268 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5269 : : struct cmd_tso_set_result {
5270 : : cmdline_fixed_string_t tso;
5271 : : cmdline_fixed_string_t mode;
5272 : : uint16_t tso_segsz;
5273 : : portid_t port_id;
5274 : : };
5275 : :
5276 : : static void
5277 : 0 : cmd_tso_set_parsed(void *parsed_result,
5278 : : __rte_unused struct cmdline *cl,
5279 : : __rte_unused void *data)
5280 : : {
5281 : : struct cmd_tso_set_result *res = parsed_result;
5282 : : struct rte_eth_dev_info dev_info;
5283 : : uint64_t offloads;
5284 : : int ret;
5285 : :
5286 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5287 : 0 : return;
5288 : 0 : if (!port_is_stopped(res->port_id)) {
5289 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5290 : 0 : return;
5291 : : }
5292 : :
5293 : 0 : if (!strcmp(res->mode, "set"))
5294 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5295 : :
5296 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5297 : 0 : if (ret != 0)
5298 : : return;
5299 : :
5300 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5301 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5302 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5303 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5304 : : res->port_id);
5305 : 0 : return;
5306 : : }
5307 : : /* display warnings if configuration is not supported by the NIC */
5308 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5309 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5310 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5311 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5312 : : }
5313 : :
5314 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5315 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5316 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5317 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5318 : : } else {
5319 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5320 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5321 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5322 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5323 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5324 : 0 : printf("segment size for non-tunneled packets is %d\n",
5325 : : ports[res->port_id].tso_segsz);
5326 : : }
5327 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5328 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5329 : : }
5330 : :
5331 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5332 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5333 : : tso, "tso");
5334 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5335 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5336 : : mode, "set");
5337 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5338 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5339 : : tso_segsz, RTE_UINT16);
5340 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5341 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5342 : : port_id, RTE_UINT16);
5343 : :
5344 : : static cmdline_parse_inst_t cmd_tso_set = {
5345 : : .f = cmd_tso_set_parsed,
5346 : : .data = NULL,
5347 : : .help_str = "tso set <tso_segsz> <port_id>: "
5348 : : "Set TSO segment size of non-tunneled packets for csum engine "
5349 : : "(0 to disable)",
5350 : : .tokens = {
5351 : : (void *)&cmd_tso_set_tso,
5352 : : (void *)&cmd_tso_set_mode,
5353 : : (void *)&cmd_tso_set_tso_segsz,
5354 : : (void *)&cmd_tso_set_portid,
5355 : : NULL,
5356 : : },
5357 : : };
5358 : :
5359 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5360 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5361 : : mode, "show");
5362 : :
5363 : :
5364 : : static cmdline_parse_inst_t cmd_tso_show = {
5365 : : .f = cmd_tso_set_parsed,
5366 : : .data = NULL,
5367 : : .help_str = "tso show <port_id>: "
5368 : : "Show TSO segment size of non-tunneled packets for csum engine",
5369 : : .tokens = {
5370 : : (void *)&cmd_tso_set_tso,
5371 : : (void *)&cmd_tso_show_mode,
5372 : : (void *)&cmd_tso_set_portid,
5373 : : NULL,
5374 : : },
5375 : : };
5376 : :
5377 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5378 : : struct cmd_tunnel_tso_set_result {
5379 : : cmdline_fixed_string_t tso;
5380 : : cmdline_fixed_string_t mode;
5381 : : uint16_t tso_segsz;
5382 : : portid_t port_id;
5383 : : };
5384 : :
5385 : : static void
5386 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5387 : : {
5388 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5389 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5390 : : port_id);
5391 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5392 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5393 : : port_id);
5394 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5395 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5396 : : port_id);
5397 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5398 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5399 : : port_id);
5400 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5401 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5402 : : port_id);
5403 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5404 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5405 : : port_id);
5406 : 0 : }
5407 : :
5408 : : static void
5409 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5410 : : __rte_unused struct cmdline *cl,
5411 : : __rte_unused void *data)
5412 : : {
5413 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5414 : : struct rte_eth_dev_info dev_info;
5415 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5416 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5417 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5418 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5419 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5420 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5421 : : int ret;
5422 : :
5423 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5424 : 0 : return;
5425 : 0 : if (!port_is_stopped(res->port_id)) {
5426 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5427 : 0 : return;
5428 : : }
5429 : :
5430 : 0 : if (!strcmp(res->mode, "set"))
5431 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5432 : :
5433 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5434 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5435 : : printf("TSO for tunneled packets is disabled\n");
5436 : : } else {
5437 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5438 : 0 : if (ret != 0)
5439 : : return;
5440 : :
5441 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5442 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5443 : 0 : res->port_id);
5444 : 0 : return;
5445 : : }
5446 : :
5447 : : /* Below conditions are needed to make it work:
5448 : : * (1) tunnel TSO is supported by the NIC;
5449 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5450 : : * are recognized;
5451 : : * (3) for tunneled pkts with outer L3 of IPv4,
5452 : : * "csum set outer-ip" must be set to hw, because after tso,
5453 : : * total_len of outer IP header is changed, and the checksum
5454 : : * of outer IP header calculated by sw should be wrong; that
5455 : : * is not necessary for IPv6 tunneled pkts because there's no
5456 : : * checksum in IP header anymore.
5457 : : */
5458 : 0 : if (!ports[res->port_id].parse_tunnel) {
5459 : 0 : fprintf(stderr,
5460 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5461 : 0 : return;
5462 : : }
5463 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5464 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5465 : 0 : fprintf(stderr,
5466 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5467 : 0 : return;
5468 : : }
5469 : :
5470 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5471 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5472 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5473 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5474 : 0 : ports[res->port_id].tunnel_tso_segsz);
5475 : : }
5476 : :
5477 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5478 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5479 : : }
5480 : :
5481 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5482 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5483 : : tso, "tunnel_tso");
5484 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5485 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5486 : : mode, "set");
5487 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5488 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5489 : : tso_segsz, RTE_UINT16);
5490 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5491 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5492 : : port_id, RTE_UINT16);
5493 : :
5494 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5495 : : .f = cmd_tunnel_tso_set_parsed,
5496 : : .data = NULL,
5497 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5498 : : "Set TSO segment size of tunneled packets for csum engine "
5499 : : "(0 to disable)",
5500 : : .tokens = {
5501 : : (void *)&cmd_tunnel_tso_set_tso,
5502 : : (void *)&cmd_tunnel_tso_set_mode,
5503 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5504 : : (void *)&cmd_tunnel_tso_set_portid,
5505 : : NULL,
5506 : : },
5507 : : };
5508 : :
5509 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5510 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5511 : : mode, "show");
5512 : :
5513 : :
5514 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5515 : : .f = cmd_tunnel_tso_set_parsed,
5516 : : .data = NULL,
5517 : : .help_str = "tunnel_tso show <port_id> "
5518 : : "Show TSO segment size of tunneled packets for csum engine",
5519 : : .tokens = {
5520 : : (void *)&cmd_tunnel_tso_set_tso,
5521 : : (void *)&cmd_tunnel_tso_show_mode,
5522 : : (void *)&cmd_tunnel_tso_set_portid,
5523 : : NULL,
5524 : : },
5525 : : };
5526 : :
5527 : : #ifdef RTE_LIB_GRO
5528 : : /* *** SET GRO FOR A PORT *** */
5529 : : struct cmd_gro_enable_result {
5530 : : cmdline_fixed_string_t cmd_set;
5531 : : cmdline_fixed_string_t cmd_port;
5532 : : cmdline_fixed_string_t cmd_keyword;
5533 : : cmdline_fixed_string_t cmd_onoff;
5534 : : portid_t cmd_pid;
5535 : : };
5536 : :
5537 : : static void
5538 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5539 : : __rte_unused struct cmdline *cl,
5540 : : __rte_unused void *data)
5541 : : {
5542 : : struct cmd_gro_enable_result *res;
5543 : :
5544 : : res = parsed_result;
5545 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5546 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5547 : 0 : }
5548 : :
5549 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5550 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5551 : : cmd_set, "set");
5552 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5553 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5554 : : cmd_keyword, "port");
5555 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5556 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5557 : : cmd_pid, RTE_UINT16);
5558 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5559 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5560 : : cmd_keyword, "gro");
5561 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5562 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5563 : : cmd_onoff, "on#off");
5564 : :
5565 : : static cmdline_parse_inst_t cmd_gro_enable = {
5566 : : .f = cmd_gro_enable_parsed,
5567 : : .data = NULL,
5568 : : .help_str = "set port <port_id> gro on|off",
5569 : : .tokens = {
5570 : : (void *)&cmd_gro_enable_set,
5571 : : (void *)&cmd_gro_enable_port,
5572 : : (void *)&cmd_gro_enable_pid,
5573 : : (void *)&cmd_gro_enable_keyword,
5574 : : (void *)&cmd_gro_enable_onoff,
5575 : : NULL,
5576 : : },
5577 : : };
5578 : :
5579 : : /* *** DISPLAY GRO CONFIGURATION *** */
5580 : : struct cmd_gro_show_result {
5581 : : cmdline_fixed_string_t cmd_show;
5582 : : cmdline_fixed_string_t cmd_port;
5583 : : cmdline_fixed_string_t cmd_keyword;
5584 : : portid_t cmd_pid;
5585 : : };
5586 : :
5587 : : static void
5588 : 0 : cmd_gro_show_parsed(void *parsed_result,
5589 : : __rte_unused struct cmdline *cl,
5590 : : __rte_unused void *data)
5591 : : {
5592 : : struct cmd_gro_show_result *res;
5593 : :
5594 : : res = parsed_result;
5595 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5596 : 0 : show_gro(res->cmd_pid);
5597 : 0 : }
5598 : :
5599 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5600 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5601 : : cmd_show, "show");
5602 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5603 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5604 : : cmd_port, "port");
5605 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5606 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5607 : : cmd_pid, RTE_UINT16);
5608 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5609 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5610 : : cmd_keyword, "gro");
5611 : :
5612 : : static cmdline_parse_inst_t cmd_gro_show = {
5613 : : .f = cmd_gro_show_parsed,
5614 : : .data = NULL,
5615 : : .help_str = "show port <port_id> gro",
5616 : : .tokens = {
5617 : : (void *)&cmd_gro_show_show,
5618 : : (void *)&cmd_gro_show_port,
5619 : : (void *)&cmd_gro_show_pid,
5620 : : (void *)&cmd_gro_show_keyword,
5621 : : NULL,
5622 : : },
5623 : : };
5624 : :
5625 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5626 : : struct cmd_gro_flush_result {
5627 : : cmdline_fixed_string_t cmd_set;
5628 : : cmdline_fixed_string_t cmd_keyword;
5629 : : cmdline_fixed_string_t cmd_flush;
5630 : : uint8_t cmd_cycles;
5631 : : };
5632 : :
5633 : : static void
5634 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5635 : : __rte_unused struct cmdline *cl,
5636 : : __rte_unused void *data)
5637 : : {
5638 : : struct cmd_gro_flush_result *res;
5639 : :
5640 : : res = parsed_result;
5641 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5642 : 0 : (!strcmp(res->cmd_flush, "flush")))
5643 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5644 : 0 : }
5645 : :
5646 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5647 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5648 : : cmd_set, "set");
5649 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5650 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5651 : : cmd_keyword, "gro");
5652 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5653 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5654 : : cmd_flush, "flush");
5655 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5656 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5657 : : cmd_cycles, RTE_UINT8);
5658 : :
5659 : : static cmdline_parse_inst_t cmd_gro_flush = {
5660 : : .f = cmd_gro_flush_parsed,
5661 : : .data = NULL,
5662 : : .help_str = "set gro flush <cycles>",
5663 : : .tokens = {
5664 : : (void *)&cmd_gro_flush_set,
5665 : : (void *)&cmd_gro_flush_keyword,
5666 : : (void *)&cmd_gro_flush_flush,
5667 : : (void *)&cmd_gro_flush_cycles,
5668 : : NULL,
5669 : : },
5670 : : };
5671 : : #endif /* RTE_LIB_GRO */
5672 : :
5673 : : #ifdef RTE_LIB_GSO
5674 : : /* *** ENABLE/DISABLE GSO *** */
5675 : : struct cmd_gso_enable_result {
5676 : : cmdline_fixed_string_t cmd_set;
5677 : : cmdline_fixed_string_t cmd_port;
5678 : : cmdline_fixed_string_t cmd_keyword;
5679 : : cmdline_fixed_string_t cmd_mode;
5680 : : portid_t cmd_pid;
5681 : : };
5682 : :
5683 : : static void
5684 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5685 : : __rte_unused struct cmdline *cl,
5686 : : __rte_unused void *data)
5687 : : {
5688 : : struct cmd_gso_enable_result *res;
5689 : :
5690 : : res = parsed_result;
5691 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5692 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5693 : 0 : }
5694 : :
5695 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5696 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5697 : : cmd_set, "set");
5698 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5699 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5700 : : cmd_port, "port");
5701 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5702 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5703 : : cmd_keyword, "gso");
5704 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5705 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5706 : : cmd_mode, "on#off");
5707 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5708 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5709 : : cmd_pid, RTE_UINT16);
5710 : :
5711 : : static cmdline_parse_inst_t cmd_gso_enable = {
5712 : : .f = cmd_gso_enable_parsed,
5713 : : .data = NULL,
5714 : : .help_str = "set port <port_id> gso on|off",
5715 : : .tokens = {
5716 : : (void *)&cmd_gso_enable_set,
5717 : : (void *)&cmd_gso_enable_port,
5718 : : (void *)&cmd_gso_enable_pid,
5719 : : (void *)&cmd_gso_enable_keyword,
5720 : : (void *)&cmd_gso_enable_mode,
5721 : : NULL,
5722 : : },
5723 : : };
5724 : :
5725 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5726 : : struct cmd_gso_size_result {
5727 : : cmdline_fixed_string_t cmd_set;
5728 : : cmdline_fixed_string_t cmd_keyword;
5729 : : cmdline_fixed_string_t cmd_segsz;
5730 : : uint16_t cmd_size;
5731 : : };
5732 : :
5733 : : static void
5734 : 0 : cmd_gso_size_parsed(void *parsed_result,
5735 : : __rte_unused struct cmdline *cl,
5736 : : __rte_unused void *data)
5737 : : {
5738 : : struct cmd_gso_size_result *res = parsed_result;
5739 : :
5740 : 0 : if (test_done == 0) {
5741 : 0 : fprintf(stderr,
5742 : : "Before setting GSO segsz, please first stop forwarding\n");
5743 : 0 : return;
5744 : : }
5745 : :
5746 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5747 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5748 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5749 : 0 : fprintf(stderr,
5750 : : "gso_size should be larger than %zu. Please input a legal value\n",
5751 : : RTE_GSO_SEG_SIZE_MIN);
5752 : : else
5753 : 0 : gso_max_segment_size = res->cmd_size;
5754 : : }
5755 : : }
5756 : :
5757 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5758 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5759 : : cmd_set, "set");
5760 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5761 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5762 : : cmd_keyword, "gso");
5763 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5764 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5765 : : cmd_segsz, "segsz");
5766 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5767 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5768 : : cmd_size, RTE_UINT16);
5769 : :
5770 : : static cmdline_parse_inst_t cmd_gso_size = {
5771 : : .f = cmd_gso_size_parsed,
5772 : : .data = NULL,
5773 : : .help_str = "set gso segsz <length>",
5774 : : .tokens = {
5775 : : (void *)&cmd_gso_size_set,
5776 : : (void *)&cmd_gso_size_keyword,
5777 : : (void *)&cmd_gso_size_segsz,
5778 : : (void *)&cmd_gso_size_size,
5779 : : NULL,
5780 : : },
5781 : : };
5782 : :
5783 : : /* *** SHOW GSO CONFIGURATION *** */
5784 : : struct cmd_gso_show_result {
5785 : : cmdline_fixed_string_t cmd_show;
5786 : : cmdline_fixed_string_t cmd_port;
5787 : : cmdline_fixed_string_t cmd_keyword;
5788 : : portid_t cmd_pid;
5789 : : };
5790 : :
5791 : : static void
5792 : 0 : cmd_gso_show_parsed(void *parsed_result,
5793 : : __rte_unused struct cmdline *cl,
5794 : : __rte_unused void *data)
5795 : : {
5796 : : struct cmd_gso_show_result *res = parsed_result;
5797 : :
5798 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5799 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5800 : 0 : return;
5801 : : }
5802 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5803 : 0 : if (gso_ports[res->cmd_pid].enable) {
5804 : 0 : printf("Max GSO'd packet size: %uB\n"
5805 : : "Supported GSO types: TCP/IPv4, "
5806 : : "UDP/IPv4, VxLAN with inner "
5807 : : "TCP/IPv4 packet, GRE with inner "
5808 : : "TCP/IPv4 packet\n",
5809 : : gso_max_segment_size);
5810 : : } else
5811 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5812 : : }
5813 : : }
5814 : :
5815 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5816 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5817 : : cmd_show, "show");
5818 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5819 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5820 : : cmd_port, "port");
5821 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5822 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5823 : : cmd_keyword, "gso");
5824 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5825 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5826 : : cmd_pid, RTE_UINT16);
5827 : :
5828 : : static cmdline_parse_inst_t cmd_gso_show = {
5829 : : .f = cmd_gso_show_parsed,
5830 : : .data = NULL,
5831 : : .help_str = "show port <port_id> gso",
5832 : : .tokens = {
5833 : : (void *)&cmd_gso_show_show,
5834 : : (void *)&cmd_gso_show_port,
5835 : : (void *)&cmd_gso_show_pid,
5836 : : (void *)&cmd_gso_show_keyword,
5837 : : NULL,
5838 : : },
5839 : : };
5840 : : #endif /* RTE_LIB_GSO */
5841 : :
5842 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5843 : : struct cmd_set_flush_rx {
5844 : : cmdline_fixed_string_t set;
5845 : : cmdline_fixed_string_t flush_rx;
5846 : : cmdline_fixed_string_t mode;
5847 : : };
5848 : :
5849 : : static void
5850 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
5851 : : __rte_unused struct cmdline *cl,
5852 : : __rte_unused void *data)
5853 : : {
5854 : : struct cmd_set_flush_rx *res = parsed_result;
5855 : :
5856 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5857 : : printf("multi-process doesn't support to flush Rx queues.\n");
5858 : 0 : return;
5859 : : }
5860 : :
5861 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5862 : : }
5863 : :
5864 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
5865 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5866 : : set, "set");
5867 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5868 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5869 : : flush_rx, "flush_rx");
5870 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
5871 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5872 : : mode, "on#off");
5873 : :
5874 : :
5875 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
5876 : : .f = cmd_set_flush_rx_parsed,
5877 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5878 : : .data = NULL,
5879 : : .tokens = {
5880 : : (void *)&cmd_setflushrx_set,
5881 : : (void *)&cmd_setflushrx_flush_rx,
5882 : : (void *)&cmd_setflushrx_mode,
5883 : : NULL,
5884 : : },
5885 : : };
5886 : :
5887 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5888 : : struct cmd_set_link_check {
5889 : : cmdline_fixed_string_t set;
5890 : : cmdline_fixed_string_t link_check;
5891 : : cmdline_fixed_string_t mode;
5892 : : };
5893 : :
5894 : : static void
5895 : 0 : cmd_set_link_check_parsed(void *parsed_result,
5896 : : __rte_unused struct cmdline *cl,
5897 : : __rte_unused void *data)
5898 : : {
5899 : : struct cmd_set_link_check *res = parsed_result;
5900 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5901 : 0 : }
5902 : :
5903 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5904 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5905 : : set, "set");
5906 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5907 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5908 : : link_check, "link_check");
5909 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5910 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5911 : : mode, "on#off");
5912 : :
5913 : :
5914 : : static cmdline_parse_inst_t cmd_set_link_check = {
5915 : : .f = cmd_set_link_check_parsed,
5916 : : .help_str = "set link_check on|off: Enable/Disable link status check "
5917 : : "when starting/stopping a port",
5918 : : .data = NULL,
5919 : : .tokens = {
5920 : : (void *)&cmd_setlinkcheck_set,
5921 : : (void *)&cmd_setlinkcheck_link_check,
5922 : : (void *)&cmd_setlinkcheck_mode,
5923 : : NULL,
5924 : : },
5925 : : };
5926 : :
5927 : : /* *** SET FORWARDING MODE *** */
5928 : : struct cmd_set_fwd_mode_result {
5929 : : cmdline_fixed_string_t set;
5930 : : cmdline_fixed_string_t fwd;
5931 : : cmdline_fixed_string_t mode;
5932 : : };
5933 : :
5934 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
5935 : : __rte_unused struct cmdline *cl,
5936 : : __rte_unused void *data)
5937 : : {
5938 : : struct cmd_set_fwd_mode_result *res = parsed_result;
5939 : :
5940 : 0 : retry_enabled = 0;
5941 : 0 : set_pkt_forwarding_mode(res->mode);
5942 : 0 : }
5943 : :
5944 : : static cmdline_parse_token_string_t cmd_setfwd_set =
5945 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5946 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
5947 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5948 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
5949 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5950 : : "" /* defined at init */);
5951 : :
5952 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
5953 : : .f = cmd_set_fwd_mode_parsed,
5954 : : .data = NULL,
5955 : : .help_str = NULL, /* defined at init */
5956 : : .tokens = {
5957 : : (void *)&cmd_setfwd_set,
5958 : : (void *)&cmd_setfwd_fwd,
5959 : : (void *)&cmd_setfwd_mode,
5960 : : NULL,
5961 : : },
5962 : : };
5963 : :
5964 : 0 : static void cmd_set_fwd_mode_init(void)
5965 : : {
5966 : : char *modes, *c;
5967 : : static char token[128];
5968 : : static char help[256];
5969 : : cmdline_parse_token_string_t *token_struct;
5970 : :
5971 : 0 : modes = list_pkt_forwarding_modes();
5972 : : snprintf(help, sizeof(help), "set fwd %s: "
5973 : : "Set packet forwarding mode", modes);
5974 : 0 : cmd_set_fwd_mode.help_str = help;
5975 : :
5976 : : /* string token separator is # */
5977 : 0 : for (c = token; *modes != '\0'; modes++)
5978 : 0 : if (*modes == '|')
5979 : 0 : *c++ = '#';
5980 : : else
5981 : 0 : *c++ = *modes;
5982 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5983 : 0 : token_struct->string_data.str = token;
5984 : 0 : }
5985 : :
5986 : : /* *** SET RETRY FORWARDING MODE *** */
5987 : : struct cmd_set_fwd_retry_mode_result {
5988 : : cmdline_fixed_string_t set;
5989 : : cmdline_fixed_string_t fwd;
5990 : : cmdline_fixed_string_t mode;
5991 : : cmdline_fixed_string_t retry;
5992 : : };
5993 : :
5994 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5995 : : __rte_unused struct cmdline *cl,
5996 : : __rte_unused void *data)
5997 : : {
5998 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5999 : :
6000 : 0 : retry_enabled = 1;
6001 : 0 : set_pkt_forwarding_mode(res->mode);
6002 : 0 : }
6003 : :
6004 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6005 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6006 : : set, "set");
6007 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6008 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6009 : : fwd, "fwd");
6010 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6011 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6012 : : mode,
6013 : : "" /* defined at init */);
6014 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6015 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6016 : : retry, "retry");
6017 : :
6018 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6019 : : .f = cmd_set_fwd_retry_mode_parsed,
6020 : : .data = NULL,
6021 : : .help_str = NULL, /* defined at init */
6022 : : .tokens = {
6023 : : (void *)&cmd_setfwd_retry_set,
6024 : : (void *)&cmd_setfwd_retry_fwd,
6025 : : (void *)&cmd_setfwd_retry_mode,
6026 : : (void *)&cmd_setfwd_retry_retry,
6027 : : NULL,
6028 : : },
6029 : : };
6030 : :
6031 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6032 : : {
6033 : : char *modes, *c;
6034 : : static char token[128];
6035 : : static char help[256];
6036 : : cmdline_parse_token_string_t *token_struct;
6037 : :
6038 : 0 : modes = list_pkt_forwarding_retry_modes();
6039 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6040 : : "Set packet forwarding mode with retry", modes);
6041 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6042 : :
6043 : : /* string token separator is # */
6044 : 0 : for (c = token; *modes != '\0'; modes++)
6045 : 0 : if (*modes == '|')
6046 : 0 : *c++ = '#';
6047 : : else
6048 : 0 : *c++ = *modes;
6049 : 0 : token_struct = (cmdline_parse_token_string_t *)
6050 : : cmd_set_fwd_retry_mode.tokens[2];
6051 : 0 : token_struct->string_data.str = token;
6052 : 0 : }
6053 : :
6054 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6055 : : struct cmd_set_burst_tx_retry_result {
6056 : : cmdline_fixed_string_t set;
6057 : : cmdline_fixed_string_t burst;
6058 : : cmdline_fixed_string_t tx;
6059 : : cmdline_fixed_string_t delay;
6060 : : uint32_t time;
6061 : : cmdline_fixed_string_t retry;
6062 : : uint32_t retry_num;
6063 : : };
6064 : :
6065 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6066 : : __rte_unused struct cmdline *cl,
6067 : : __rte_unused void *data)
6068 : : {
6069 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6070 : :
6071 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6072 : 0 : && !strcmp(res->tx, "tx")) {
6073 : 0 : if (!strcmp(res->delay, "delay"))
6074 : 0 : burst_tx_delay_time = res->time;
6075 : 0 : if (!strcmp(res->retry, "retry"))
6076 : 0 : burst_tx_retry_num = res->retry_num;
6077 : : }
6078 : :
6079 : 0 : }
6080 : :
6081 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6082 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6083 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6084 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6085 : : "burst");
6086 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6087 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6088 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6089 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6090 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6091 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6092 : : RTE_UINT32);
6093 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6094 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6095 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6096 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6097 : : RTE_UINT32);
6098 : :
6099 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6100 : : .f = cmd_set_burst_tx_retry_parsed,
6101 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6102 : : .tokens = {
6103 : : (void *)&cmd_set_burst_tx_retry_set,
6104 : : (void *)&cmd_set_burst_tx_retry_burst,
6105 : : (void *)&cmd_set_burst_tx_retry_tx,
6106 : : (void *)&cmd_set_burst_tx_retry_delay,
6107 : : (void *)&cmd_set_burst_tx_retry_time,
6108 : : (void *)&cmd_set_burst_tx_retry_retry,
6109 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6110 : : NULL,
6111 : : },
6112 : : };
6113 : :
6114 : : /* *** SET PROMISC MODE *** */
6115 : : struct cmd_set_promisc_mode_result {
6116 : : cmdline_fixed_string_t set;
6117 : : cmdline_fixed_string_t promisc;
6118 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6119 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6120 : : cmdline_fixed_string_t mode;
6121 : : };
6122 : :
6123 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6124 : : __rte_unused struct cmdline *cl,
6125 : : void *allports)
6126 : : {
6127 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6128 : : int enable;
6129 : : portid_t i;
6130 : :
6131 : 0 : if (!strcmp(res->mode, "on"))
6132 : : enable = 1;
6133 : : else
6134 : : enable = 0;
6135 : :
6136 : : /* all ports */
6137 : 0 : if (allports) {
6138 : 0 : RTE_ETH_FOREACH_DEV(i)
6139 : 0 : eth_set_promisc_mode(i, enable);
6140 : : } else {
6141 : 0 : eth_set_promisc_mode(res->port_num, enable);
6142 : : }
6143 : 0 : }
6144 : :
6145 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6146 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6147 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6148 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6149 : : "promisc");
6150 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6151 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6152 : : "all");
6153 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6154 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6155 : : RTE_UINT16);
6156 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6157 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6158 : : "on#off");
6159 : :
6160 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6161 : : .f = cmd_set_promisc_mode_parsed,
6162 : : .data = (void *)1,
6163 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6164 : : .tokens = {
6165 : : (void *)&cmd_setpromisc_set,
6166 : : (void *)&cmd_setpromisc_promisc,
6167 : : (void *)&cmd_setpromisc_portall,
6168 : : (void *)&cmd_setpromisc_mode,
6169 : : NULL,
6170 : : },
6171 : : };
6172 : :
6173 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6174 : : .f = cmd_set_promisc_mode_parsed,
6175 : : .data = (void *)0,
6176 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6177 : : .tokens = {
6178 : : (void *)&cmd_setpromisc_set,
6179 : : (void *)&cmd_setpromisc_promisc,
6180 : : (void *)&cmd_setpromisc_portnum,
6181 : : (void *)&cmd_setpromisc_mode,
6182 : : NULL,
6183 : : },
6184 : : };
6185 : :
6186 : : /* *** SET ALLMULTI MODE *** */
6187 : : struct cmd_set_allmulti_mode_result {
6188 : : cmdline_fixed_string_t set;
6189 : : cmdline_fixed_string_t allmulti;
6190 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6191 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6192 : : cmdline_fixed_string_t mode;
6193 : : };
6194 : :
6195 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6196 : : __rte_unused struct cmdline *cl,
6197 : : void *allports)
6198 : : {
6199 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6200 : : int enable;
6201 : : portid_t i;
6202 : :
6203 : 0 : if (!strcmp(res->mode, "on"))
6204 : : enable = 1;
6205 : : else
6206 : : enable = 0;
6207 : :
6208 : : /* all ports */
6209 : 0 : if (allports) {
6210 : 0 : RTE_ETH_FOREACH_DEV(i) {
6211 : 0 : eth_set_allmulticast_mode(i, enable);
6212 : : }
6213 : : }
6214 : : else {
6215 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6216 : : }
6217 : 0 : }
6218 : :
6219 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6221 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6222 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6223 : : "allmulti");
6224 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6226 : : "all");
6227 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6228 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6229 : : RTE_UINT16);
6230 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6232 : : "on#off");
6233 : :
6234 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6235 : : .f = cmd_set_allmulti_mode_parsed,
6236 : : .data = (void *)1,
6237 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6238 : : .tokens = {
6239 : : (void *)&cmd_setallmulti_set,
6240 : : (void *)&cmd_setallmulti_allmulti,
6241 : : (void *)&cmd_setallmulti_portall,
6242 : : (void *)&cmd_setallmulti_mode,
6243 : : NULL,
6244 : : },
6245 : : };
6246 : :
6247 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6248 : : .f = cmd_set_allmulti_mode_parsed,
6249 : : .data = (void *)0,
6250 : : .help_str = "set allmulti <port_id> on|off: "
6251 : : "Set allmulti mode on port_id",
6252 : : .tokens = {
6253 : : (void *)&cmd_setallmulti_set,
6254 : : (void *)&cmd_setallmulti_allmulti,
6255 : : (void *)&cmd_setallmulti_portnum,
6256 : : (void *)&cmd_setallmulti_mode,
6257 : : NULL,
6258 : : },
6259 : : };
6260 : :
6261 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6262 : : struct cmd_link_flow_ctrl_show {
6263 : : cmdline_fixed_string_t show;
6264 : : cmdline_fixed_string_t port;
6265 : : portid_t port_id;
6266 : : cmdline_fixed_string_t flow_ctrl;
6267 : : };
6268 : :
6269 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6270 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6271 : : show, "show");
6272 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6273 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6274 : : port, "port");
6275 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6276 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6277 : : port_id, RTE_UINT16);
6278 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6279 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6280 : : flow_ctrl, "flow_ctrl");
6281 : :
6282 : : static void
6283 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6284 : : __rte_unused struct cmdline *cl,
6285 : : __rte_unused void *data)
6286 : : {
6287 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6288 : : static const char *info_border = "*********************";
6289 : : struct rte_eth_fc_conf fc_conf;
6290 : : bool rx_fc_en = false;
6291 : : bool tx_fc_en = false;
6292 : : int ret;
6293 : :
6294 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6295 : 0 : if (ret != 0) {
6296 : 0 : fprintf(stderr,
6297 : : "Failed to get current flow ctrl information: err = %d\n",
6298 : : ret);
6299 : 0 : return;
6300 : : }
6301 : :
6302 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6303 : : rx_fc_en = true;
6304 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6305 : : tx_fc_en = true;
6306 : :
6307 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6308 : 0 : info_border, res->port_id, info_border);
6309 : : printf("FC mode:\n");
6310 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6311 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6312 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6313 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6314 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6315 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6316 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6317 : 0 : printf("Forward MAC control frames: %s\n",
6318 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6319 : 0 : printf("\n%s************** End ***********%s\n",
6320 : : info_border, info_border);
6321 : : }
6322 : :
6323 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6324 : : .f = cmd_link_flow_ctrl_show_parsed,
6325 : : .data = NULL,
6326 : : .help_str = "show port <port_id> flow_ctrl",
6327 : : .tokens = {
6328 : : (void *)&cmd_lfc_show_show,
6329 : : (void *)&cmd_lfc_show_port,
6330 : : (void *)&cmd_lfc_show_portid,
6331 : : (void *)&cmd_lfc_show_flow_ctrl,
6332 : : NULL,
6333 : : },
6334 : : };
6335 : :
6336 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6337 : : struct cmd_link_flow_ctrl_set_result {
6338 : : cmdline_fixed_string_t set;
6339 : : cmdline_fixed_string_t flow_ctrl;
6340 : : cmdline_fixed_string_t rx;
6341 : : cmdline_fixed_string_t rx_lfc_mode;
6342 : : cmdline_fixed_string_t tx;
6343 : : cmdline_fixed_string_t tx_lfc_mode;
6344 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6345 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6346 : : cmdline_fixed_string_t autoneg_str;
6347 : : cmdline_fixed_string_t autoneg;
6348 : : cmdline_fixed_string_t hw_str;
6349 : : uint32_t high_water;
6350 : : cmdline_fixed_string_t lw_str;
6351 : : uint32_t low_water;
6352 : : cmdline_fixed_string_t pt_str;
6353 : : uint16_t pause_time;
6354 : : cmdline_fixed_string_t xon_str;
6355 : : uint16_t send_xon;
6356 : : portid_t port_id;
6357 : : };
6358 : :
6359 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6360 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6361 : : set, "set");
6362 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6363 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6364 : : flow_ctrl, "flow_ctrl");
6365 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6366 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6367 : : rx, "rx");
6368 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6369 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6370 : : rx_lfc_mode, "on#off");
6371 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6372 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6373 : : tx, "tx");
6374 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6375 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6376 : : tx_lfc_mode, "on#off");
6377 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6378 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6379 : : hw_str, "high_water");
6380 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6381 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6382 : : high_water, RTE_UINT32);
6383 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6384 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6385 : : lw_str, "low_water");
6386 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6387 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6388 : : low_water, RTE_UINT32);
6389 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6390 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6391 : : pt_str, "pause_time");
6392 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6393 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6394 : : pause_time, RTE_UINT16);
6395 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6396 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6397 : : xon_str, "send_xon");
6398 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6399 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6400 : : send_xon, RTE_UINT16);
6401 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6402 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6403 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6404 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6405 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6406 : : mac_ctrl_frame_fwd_mode, "on#off");
6407 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6408 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6409 : : autoneg_str, "autoneg");
6410 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6411 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6412 : : autoneg, "on#off");
6413 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6414 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6415 : : port_id, RTE_UINT16);
6416 : :
6417 : : /* forward declaration */
6418 : : static void
6419 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6420 : : void *data);
6421 : :
6422 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6423 : : .f = cmd_link_flow_ctrl_set_parsed,
6424 : : .data = NULL,
6425 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6426 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6427 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6428 : : .tokens = {
6429 : : (void *)&cmd_lfc_set_set,
6430 : : (void *)&cmd_lfc_set_flow_ctrl,
6431 : : (void *)&cmd_lfc_set_rx,
6432 : : (void *)&cmd_lfc_set_rx_mode,
6433 : : (void *)&cmd_lfc_set_tx,
6434 : : (void *)&cmd_lfc_set_tx_mode,
6435 : : (void *)&cmd_lfc_set_high_water,
6436 : : (void *)&cmd_lfc_set_low_water,
6437 : : (void *)&cmd_lfc_set_pause_time,
6438 : : (void *)&cmd_lfc_set_send_xon,
6439 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6440 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6441 : : (void *)&cmd_lfc_set_autoneg_str,
6442 : : (void *)&cmd_lfc_set_autoneg,
6443 : : (void *)&cmd_lfc_set_portid,
6444 : : NULL,
6445 : : },
6446 : : };
6447 : :
6448 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6449 : : .f = cmd_link_flow_ctrl_set_parsed,
6450 : : .data = (void *)&cmd_link_flow_control_set_rx,
6451 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6452 : : "Change rx flow control parameter",
6453 : : .tokens = {
6454 : : (void *)&cmd_lfc_set_set,
6455 : : (void *)&cmd_lfc_set_flow_ctrl,
6456 : : (void *)&cmd_lfc_set_rx,
6457 : : (void *)&cmd_lfc_set_rx_mode,
6458 : : (void *)&cmd_lfc_set_portid,
6459 : : NULL,
6460 : : },
6461 : : };
6462 : :
6463 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6464 : : .f = cmd_link_flow_ctrl_set_parsed,
6465 : : .data = (void *)&cmd_link_flow_control_set_tx,
6466 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6467 : : "Change tx flow control parameter",
6468 : : .tokens = {
6469 : : (void *)&cmd_lfc_set_set,
6470 : : (void *)&cmd_lfc_set_flow_ctrl,
6471 : : (void *)&cmd_lfc_set_tx,
6472 : : (void *)&cmd_lfc_set_tx_mode,
6473 : : (void *)&cmd_lfc_set_portid,
6474 : : NULL,
6475 : : },
6476 : : };
6477 : :
6478 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6479 : : .f = cmd_link_flow_ctrl_set_parsed,
6480 : : .data = (void *)&cmd_link_flow_control_set_hw,
6481 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6482 : : "Change high water flow control parameter",
6483 : : .tokens = {
6484 : : (void *)&cmd_lfc_set_set,
6485 : : (void *)&cmd_lfc_set_flow_ctrl,
6486 : : (void *)&cmd_lfc_set_high_water_str,
6487 : : (void *)&cmd_lfc_set_high_water,
6488 : : (void *)&cmd_lfc_set_portid,
6489 : : NULL,
6490 : : },
6491 : : };
6492 : :
6493 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6494 : : .f = cmd_link_flow_ctrl_set_parsed,
6495 : : .data = (void *)&cmd_link_flow_control_set_lw,
6496 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6497 : : "Change low water flow control parameter",
6498 : : .tokens = {
6499 : : (void *)&cmd_lfc_set_set,
6500 : : (void *)&cmd_lfc_set_flow_ctrl,
6501 : : (void *)&cmd_lfc_set_low_water_str,
6502 : : (void *)&cmd_lfc_set_low_water,
6503 : : (void *)&cmd_lfc_set_portid,
6504 : : NULL,
6505 : : },
6506 : : };
6507 : :
6508 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6509 : : .f = cmd_link_flow_ctrl_set_parsed,
6510 : : .data = (void *)&cmd_link_flow_control_set_pt,
6511 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6512 : : "Change pause time flow control parameter",
6513 : : .tokens = {
6514 : : (void *)&cmd_lfc_set_set,
6515 : : (void *)&cmd_lfc_set_flow_ctrl,
6516 : : (void *)&cmd_lfc_set_pause_time_str,
6517 : : (void *)&cmd_lfc_set_pause_time,
6518 : : (void *)&cmd_lfc_set_portid,
6519 : : NULL,
6520 : : },
6521 : : };
6522 : :
6523 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6524 : : .f = cmd_link_flow_ctrl_set_parsed,
6525 : : .data = (void *)&cmd_link_flow_control_set_xon,
6526 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6527 : : "Change send_xon flow control parameter",
6528 : : .tokens = {
6529 : : (void *)&cmd_lfc_set_set,
6530 : : (void *)&cmd_lfc_set_flow_ctrl,
6531 : : (void *)&cmd_lfc_set_send_xon_str,
6532 : : (void *)&cmd_lfc_set_send_xon,
6533 : : (void *)&cmd_lfc_set_portid,
6534 : : NULL,
6535 : : },
6536 : : };
6537 : :
6538 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6539 : : .f = cmd_link_flow_ctrl_set_parsed,
6540 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6541 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6542 : : "Change mac ctrl fwd flow control parameter",
6543 : : .tokens = {
6544 : : (void *)&cmd_lfc_set_set,
6545 : : (void *)&cmd_lfc_set_flow_ctrl,
6546 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6547 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6548 : : (void *)&cmd_lfc_set_portid,
6549 : : NULL,
6550 : : },
6551 : : };
6552 : :
6553 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6554 : : .f = cmd_link_flow_ctrl_set_parsed,
6555 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6556 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6557 : : "Change autoneg flow control parameter",
6558 : : .tokens = {
6559 : : (void *)&cmd_lfc_set_set,
6560 : : (void *)&cmd_lfc_set_flow_ctrl,
6561 : : (void *)&cmd_lfc_set_autoneg_str,
6562 : : (void *)&cmd_lfc_set_autoneg,
6563 : : (void *)&cmd_lfc_set_portid,
6564 : : NULL,
6565 : : },
6566 : : };
6567 : :
6568 : : static void
6569 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6570 : : __rte_unused struct cmdline *cl,
6571 : : void *data)
6572 : : {
6573 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6574 : : cmdline_parse_inst_t *cmd = data;
6575 : : struct rte_eth_fc_conf fc_conf;
6576 : : int rx_fc_en = 0;
6577 : : int tx_fc_en = 0;
6578 : : int ret;
6579 : :
6580 : : /*
6581 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6582 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6583 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6584 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6585 : : */
6586 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6587 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6588 : : };
6589 : :
6590 : : /* Partial command line, retrieve current configuration */
6591 : 0 : if (cmd) {
6592 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6593 : 0 : if (ret != 0) {
6594 : 0 : fprintf(stderr,
6595 : : "cannot get current flow ctrl parameters, return code = %d\n",
6596 : : ret);
6597 : 0 : return;
6598 : : }
6599 : :
6600 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6601 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6602 : : rx_fc_en = 1;
6603 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6604 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6605 : : tx_fc_en = 1;
6606 : : }
6607 : :
6608 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6609 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6610 : :
6611 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6612 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6613 : :
6614 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6615 : :
6616 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6617 : 0 : fc_conf.high_water = res->high_water;
6618 : :
6619 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6620 : 0 : fc_conf.low_water = res->low_water;
6621 : :
6622 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6623 : 0 : fc_conf.pause_time = res->pause_time;
6624 : :
6625 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6626 : 0 : fc_conf.send_xon = res->send_xon;
6627 : :
6628 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6629 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6630 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6631 : : else
6632 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6633 : : }
6634 : :
6635 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6636 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6637 : :
6638 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6639 : 0 : if (ret != 0)
6640 : 0 : fprintf(stderr,
6641 : : "bad flow control parameter, return code = %d\n",
6642 : : ret);
6643 : : }
6644 : :
6645 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6646 : : struct cmd_priority_flow_ctrl_set_result {
6647 : : cmdline_fixed_string_t set;
6648 : : cmdline_fixed_string_t pfc_ctrl;
6649 : : cmdline_fixed_string_t rx;
6650 : : cmdline_fixed_string_t rx_pfc_mode;
6651 : : cmdline_fixed_string_t tx;
6652 : : cmdline_fixed_string_t tx_pfc_mode;
6653 : : uint32_t high_water;
6654 : : uint32_t low_water;
6655 : : uint16_t pause_time;
6656 : : uint8_t priority;
6657 : : portid_t port_id;
6658 : : };
6659 : :
6660 : : static void
6661 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6662 : : __rte_unused struct cmdline *cl,
6663 : : __rte_unused void *data)
6664 : : {
6665 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6666 : : struct rte_eth_pfc_conf pfc_conf;
6667 : : int rx_fc_enable, tx_fc_enable;
6668 : : int ret;
6669 : :
6670 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
6671 : 0 : return;
6672 : :
6673 : : /*
6674 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6675 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6676 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6677 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6678 : : */
6679 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6680 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6681 : : };
6682 : :
6683 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6684 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6685 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6686 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6687 : 0 : pfc_conf.fc.high_water = res->high_water;
6688 : 0 : pfc_conf.fc.low_water = res->low_water;
6689 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6690 : 0 : pfc_conf.priority = res->priority;
6691 : :
6692 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6693 : 0 : if (ret != 0)
6694 : 0 : fprintf(stderr,
6695 : : "bad priority flow control parameter, return code = %d\n",
6696 : : ret);
6697 : : }
6698 : :
6699 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6700 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6701 : : set, "set");
6702 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6703 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6704 : : pfc_ctrl, "pfc_ctrl");
6705 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6706 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6707 : : rx, "rx");
6708 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6709 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6710 : : rx_pfc_mode, "on#off");
6711 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6712 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6713 : : tx, "tx");
6714 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6715 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6716 : : tx_pfc_mode, "on#off");
6717 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6718 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6719 : : high_water, RTE_UINT32);
6720 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6721 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6722 : : low_water, RTE_UINT32);
6723 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6724 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6725 : : pause_time, RTE_UINT16);
6726 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6727 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6728 : : priority, RTE_UINT8);
6729 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6730 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6731 : : port_id, RTE_UINT16);
6732 : :
6733 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6734 : : .f = cmd_priority_flow_ctrl_set_parsed,
6735 : : .data = NULL,
6736 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6737 : : "<pause_time> <priority> <port_id>: "
6738 : : "Configure the Ethernet priority flow control",
6739 : : .tokens = {
6740 : : (void *)&cmd_pfc_set_set,
6741 : : (void *)&cmd_pfc_set_flow_ctrl,
6742 : : (void *)&cmd_pfc_set_rx,
6743 : : (void *)&cmd_pfc_set_rx_mode,
6744 : : (void *)&cmd_pfc_set_tx,
6745 : : (void *)&cmd_pfc_set_tx_mode,
6746 : : (void *)&cmd_pfc_set_high_water,
6747 : : (void *)&cmd_pfc_set_low_water,
6748 : : (void *)&cmd_pfc_set_pause_time,
6749 : : (void *)&cmd_pfc_set_priority,
6750 : : (void *)&cmd_pfc_set_portid,
6751 : : NULL,
6752 : : },
6753 : : };
6754 : :
6755 : : struct cmd_queue_priority_flow_ctrl_set_result {
6756 : : cmdline_fixed_string_t set;
6757 : : cmdline_fixed_string_t pfc_queue_ctrl;
6758 : : portid_t port_id;
6759 : : cmdline_fixed_string_t rx;
6760 : : cmdline_fixed_string_t rx_pfc_mode;
6761 : : uint16_t tx_qid;
6762 : : uint8_t tx_tc;
6763 : : cmdline_fixed_string_t tx;
6764 : : cmdline_fixed_string_t tx_pfc_mode;
6765 : : uint16_t rx_qid;
6766 : : uint8_t rx_tc;
6767 : : uint16_t pause_time;
6768 : : };
6769 : :
6770 : : static void
6771 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6772 : : __rte_unused struct cmdline *cl,
6773 : : __rte_unused void *data)
6774 : : {
6775 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6776 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6777 : : int rx_fc_enable, tx_fc_enable;
6778 : : int ret;
6779 : :
6780 : : /*
6781 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6782 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6783 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6784 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6785 : : * the Tx side.
6786 : : */
6787 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6788 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6789 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6790 : : };
6791 : :
6792 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6793 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6794 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6795 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6796 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6797 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6798 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6799 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6800 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6801 : :
6802 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6803 : : &pfc_queue_conf);
6804 : 0 : if (ret != 0) {
6805 : 0 : fprintf(stderr,
6806 : : "bad queue priority flow control parameter, rc = %d\n",
6807 : : ret);
6808 : : }
6809 : 0 : }
6810 : :
6811 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6812 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6813 : : set, "set");
6814 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6815 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6816 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6817 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6818 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6819 : : port_id, RTE_UINT16);
6820 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6821 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6822 : : rx, "rx");
6823 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6824 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6825 : : rx_pfc_mode, "on#off");
6826 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6827 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6828 : : tx_qid, RTE_UINT16);
6829 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6830 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6831 : : tx_tc, RTE_UINT8);
6832 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6833 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6834 : : tx, "tx");
6835 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6836 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6837 : : tx_pfc_mode, "on#off");
6838 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6839 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6840 : : rx_qid, RTE_UINT16);
6841 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6842 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6843 : : rx_tc, RTE_UINT8);
6844 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
6845 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6846 : : pause_time, RTE_UINT16);
6847 : :
6848 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
6849 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
6850 : : .data = NULL,
6851 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
6852 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
6853 : : "Configure the Ethernet queue priority flow control",
6854 : : .tokens = {
6855 : : (void *)&cmd_q_pfc_set_set,
6856 : : (void *)&cmd_q_pfc_set_flow_ctrl,
6857 : : (void *)&cmd_q_pfc_set_portid,
6858 : : (void *)&cmd_q_pfc_set_rx,
6859 : : (void *)&cmd_q_pfc_set_rx_mode,
6860 : : (void *)&cmd_q_pfc_set_tx_qid,
6861 : : (void *)&cmd_q_pfc_set_tx_tc,
6862 : : (void *)&cmd_q_pfc_set_tx,
6863 : : (void *)&cmd_q_pfc_set_tx_mode,
6864 : : (void *)&cmd_q_pfc_set_rx_qid,
6865 : : (void *)&cmd_q_pfc_set_rx_tc,
6866 : : (void *)&cmd_q_pfc_set_pause_time,
6867 : : NULL,
6868 : : },
6869 : : };
6870 : :
6871 : : /* *** RESET CONFIGURATION *** */
6872 : : struct cmd_reset_result {
6873 : : cmdline_fixed_string_t reset;
6874 : : cmdline_fixed_string_t def;
6875 : : };
6876 : :
6877 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
6878 : : struct cmdline *cl,
6879 : : __rte_unused void *data)
6880 : : {
6881 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6882 : 0 : set_def_fwd_config();
6883 : 0 : }
6884 : :
6885 : : static cmdline_parse_token_string_t cmd_reset_set =
6886 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6887 : : static cmdline_parse_token_string_t cmd_reset_def =
6888 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6889 : : "default");
6890 : :
6891 : : static cmdline_parse_inst_t cmd_reset = {
6892 : : .f = cmd_reset_parsed,
6893 : : .data = NULL,
6894 : : .help_str = "set default: Reset default forwarding configuration",
6895 : : .tokens = {
6896 : : (void *)&cmd_reset_set,
6897 : : (void *)&cmd_reset_def,
6898 : : NULL,
6899 : : },
6900 : : };
6901 : :
6902 : : /* *** START FORWARDING *** */
6903 : : struct cmd_start_result {
6904 : : cmdline_fixed_string_t start;
6905 : : };
6906 : :
6907 : : static cmdline_parse_token_string_t cmd_start_start =
6908 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6909 : :
6910 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
6911 : : __rte_unused struct cmdline *cl,
6912 : : __rte_unused void *data)
6913 : : {
6914 : 0 : start_packet_forwarding(0);
6915 : 0 : }
6916 : :
6917 : : static cmdline_parse_inst_t cmd_start = {
6918 : : .f = cmd_start_parsed,
6919 : : .data = NULL,
6920 : : .help_str = "start: Start packet forwarding",
6921 : : .tokens = {
6922 : : (void *)&cmd_start_start,
6923 : : NULL,
6924 : : },
6925 : : };
6926 : :
6927 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6928 : : struct cmd_start_tx_first_result {
6929 : : cmdline_fixed_string_t start;
6930 : : cmdline_fixed_string_t tx_first;
6931 : : };
6932 : :
6933 : : static void
6934 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
6935 : : __rte_unused struct cmdline *cl,
6936 : : __rte_unused void *data)
6937 : : {
6938 : 0 : start_packet_forwarding(1);
6939 : 0 : }
6940 : :
6941 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
6942 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6943 : : "start");
6944 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6945 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6946 : : tx_first, "tx_first");
6947 : :
6948 : : static cmdline_parse_inst_t cmd_start_tx_first = {
6949 : : .f = cmd_start_tx_first_parsed,
6950 : : .data = NULL,
6951 : : .help_str = "start tx_first: Start packet forwarding, "
6952 : : "after sending 1 burst of packets",
6953 : : .tokens = {
6954 : : (void *)&cmd_start_tx_first_start,
6955 : : (void *)&cmd_start_tx_first_tx_first,
6956 : : NULL,
6957 : : },
6958 : : };
6959 : :
6960 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
6961 : : struct cmd_start_tx_first_n_result {
6962 : : cmdline_fixed_string_t start;
6963 : : cmdline_fixed_string_t tx_first;
6964 : : uint32_t tx_num;
6965 : : };
6966 : :
6967 : : static void
6968 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
6969 : : __rte_unused struct cmdline *cl,
6970 : : __rte_unused void *data)
6971 : : {
6972 : : struct cmd_start_tx_first_n_result *res = parsed_result;
6973 : :
6974 : 0 : start_packet_forwarding(res->tx_num);
6975 : 0 : }
6976 : :
6977 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6978 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6979 : : start, "start");
6980 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6981 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6982 : : tx_first, "tx_first");
6983 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6984 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6985 : : tx_num, RTE_UINT32);
6986 : :
6987 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
6988 : : .f = cmd_start_tx_first_n_parsed,
6989 : : .data = NULL,
6990 : : .help_str = "start tx_first <num>: "
6991 : : "packet forwarding, after sending <num> bursts of packets",
6992 : : .tokens = {
6993 : : (void *)&cmd_start_tx_first_n_start,
6994 : : (void *)&cmd_start_tx_first_n_tx_first,
6995 : : (void *)&cmd_start_tx_first_n_tx_num,
6996 : : NULL,
6997 : : },
6998 : : };
6999 : :
7000 : : /* *** SET LINK UP *** */
7001 : : struct cmd_set_link_up_result {
7002 : : cmdline_fixed_string_t set;
7003 : : cmdline_fixed_string_t link_up;
7004 : : cmdline_fixed_string_t port;
7005 : : portid_t port_id;
7006 : : };
7007 : :
7008 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7009 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7010 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7011 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7012 : : "link-up");
7013 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7014 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7015 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7016 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7017 : : RTE_UINT16);
7018 : :
7019 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7020 : : __rte_unused struct cmdline *cl,
7021 : : __rte_unused void *data)
7022 : : {
7023 : : struct cmd_set_link_up_result *res = parsed_result;
7024 : 0 : dev_set_link_up(res->port_id);
7025 : 0 : }
7026 : :
7027 : : static cmdline_parse_inst_t cmd_set_link_up = {
7028 : : .f = cmd_set_link_up_parsed,
7029 : : .data = NULL,
7030 : : .help_str = "set link-up port <port id>",
7031 : : .tokens = {
7032 : : (void *)&cmd_set_link_up_set,
7033 : : (void *)&cmd_set_link_up_link_up,
7034 : : (void *)&cmd_set_link_up_port,
7035 : : (void *)&cmd_set_link_up_port_id,
7036 : : NULL,
7037 : : },
7038 : : };
7039 : :
7040 : : /* *** SET LINK DOWN *** */
7041 : : struct cmd_set_link_down_result {
7042 : : cmdline_fixed_string_t set;
7043 : : cmdline_fixed_string_t link_down;
7044 : : cmdline_fixed_string_t port;
7045 : : portid_t port_id;
7046 : : };
7047 : :
7048 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7049 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7050 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7051 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7052 : : "link-down");
7053 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7054 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7055 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7056 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7057 : : RTE_UINT16);
7058 : :
7059 : 0 : static void cmd_set_link_down_parsed(
7060 : : __rte_unused void *parsed_result,
7061 : : __rte_unused struct cmdline *cl,
7062 : : __rte_unused void *data)
7063 : : {
7064 : : struct cmd_set_link_down_result *res = parsed_result;
7065 : 0 : dev_set_link_down(res->port_id);
7066 : 0 : }
7067 : :
7068 : : static cmdline_parse_inst_t cmd_set_link_down = {
7069 : : .f = cmd_set_link_down_parsed,
7070 : : .data = NULL,
7071 : : .help_str = "set link-down port <port id>",
7072 : : .tokens = {
7073 : : (void *)&cmd_set_link_down_set,
7074 : : (void *)&cmd_set_link_down_link_down,
7075 : : (void *)&cmd_set_link_down_port,
7076 : : (void *)&cmd_set_link_down_port_id,
7077 : : NULL,
7078 : : },
7079 : : };
7080 : :
7081 : : /* *** SHOW CFG *** */
7082 : : struct cmd_showcfg_result {
7083 : : cmdline_fixed_string_t show;
7084 : : cmdline_fixed_string_t cfg;
7085 : : cmdline_fixed_string_t what;
7086 : : };
7087 : :
7088 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7089 : : __rte_unused struct cmdline *cl,
7090 : : __rte_unused void *data)
7091 : : {
7092 : : struct cmd_showcfg_result *res = parsed_result;
7093 : 0 : if (!strcmp(res->what, "rxtx"))
7094 : 0 : rxtx_config_display();
7095 : 0 : else if (!strcmp(res->what, "cores"))
7096 : 0 : fwd_lcores_config_display();
7097 : 0 : else if (!strcmp(res->what, "fwd"))
7098 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7099 : 0 : else if (!strcmp(res->what, "rxoffs"))
7100 : 0 : show_rx_pkt_offsets();
7101 : 0 : else if (!strcmp(res->what, "rxpkts"))
7102 : 0 : show_rx_pkt_segments();
7103 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7104 : 0 : show_rx_pkt_hdrs();
7105 : 0 : else if (!strcmp(res->what, "txpkts"))
7106 : 0 : show_tx_pkt_segments();
7107 : 0 : else if (!strcmp(res->what, "txtimes"))
7108 : 0 : show_tx_pkt_times();
7109 : 0 : }
7110 : :
7111 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7112 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7113 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7114 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7115 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7116 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7117 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
7118 : :
7119 : : static cmdline_parse_inst_t cmd_showcfg = {
7120 : : .f = cmd_showcfg_parsed,
7121 : : .data = NULL,
7122 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
7123 : : .tokens = {
7124 : : (void *)&cmd_showcfg_show,
7125 : : (void *)&cmd_showcfg_port,
7126 : : (void *)&cmd_showcfg_what,
7127 : : NULL,
7128 : : },
7129 : : };
7130 : :
7131 : : /* *** SHOW ALL PORT INFO *** */
7132 : : struct cmd_showportall_result {
7133 : : cmdline_fixed_string_t show;
7134 : : cmdline_fixed_string_t port;
7135 : : cmdline_fixed_string_t what;
7136 : : cmdline_fixed_string_t all;
7137 : : };
7138 : :
7139 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7140 : : __rte_unused struct cmdline *cl,
7141 : : __rte_unused void *data)
7142 : : {
7143 : : portid_t i;
7144 : :
7145 : : struct cmd_showportall_result *res = parsed_result;
7146 : 0 : if (!strcmp(res->show, "clear")) {
7147 : 0 : if (!strcmp(res->what, "stats"))
7148 : 0 : RTE_ETH_FOREACH_DEV(i)
7149 : 0 : nic_stats_clear(i);
7150 : 0 : else if (!strcmp(res->what, "xstats"))
7151 : 0 : RTE_ETH_FOREACH_DEV(i)
7152 : 0 : nic_xstats_clear(i);
7153 : 0 : } else if (!strcmp(res->what, "info"))
7154 : 0 : RTE_ETH_FOREACH_DEV(i)
7155 : 0 : port_infos_display(i);
7156 : 0 : else if (!strcmp(res->what, "summary")) {
7157 : 0 : port_summary_header_display();
7158 : 0 : RTE_ETH_FOREACH_DEV(i)
7159 : 0 : port_summary_display(i);
7160 : : }
7161 : 0 : else if (!strcmp(res->what, "stats"))
7162 : 0 : RTE_ETH_FOREACH_DEV(i)
7163 : 0 : nic_stats_display(i);
7164 : 0 : else if (!strcmp(res->what, "xstats"))
7165 : 0 : RTE_ETH_FOREACH_DEV(i)
7166 : 0 : nic_xstats_display(i);
7167 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7168 : 0 : else if (!strcmp(res->what, "fdir"))
7169 : 0 : RTE_ETH_FOREACH_DEV(i)
7170 : 0 : fdir_get_infos(i);
7171 : : #endif
7172 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7173 : 0 : RTE_ETH_FOREACH_DEV(i)
7174 : 0 : port_dcb_info_display(i);
7175 : 0 : }
7176 : :
7177 : : static cmdline_parse_token_string_t cmd_showportall_show =
7178 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7179 : : "show#clear");
7180 : : static cmdline_parse_token_string_t cmd_showportall_port =
7181 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7182 : : static cmdline_parse_token_string_t cmd_showportall_what =
7183 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7184 : : "info#summary#stats#xstats#fdir#dcb_tc");
7185 : : static cmdline_parse_token_string_t cmd_showportall_all =
7186 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7187 : : static cmdline_parse_inst_t cmd_showportall = {
7188 : : .f = cmd_showportall_parsed,
7189 : : .data = NULL,
7190 : : .help_str = "show|clear port "
7191 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7192 : : .tokens = {
7193 : : (void *)&cmd_showportall_show,
7194 : : (void *)&cmd_showportall_port,
7195 : : (void *)&cmd_showportall_what,
7196 : : (void *)&cmd_showportall_all,
7197 : : NULL,
7198 : : },
7199 : : };
7200 : :
7201 : : /* *** SHOW PORT INFO *** */
7202 : : struct cmd_showport_result {
7203 : : cmdline_fixed_string_t show;
7204 : : cmdline_fixed_string_t port;
7205 : : cmdline_fixed_string_t what;
7206 : : uint16_t portnum;
7207 : : };
7208 : :
7209 : 0 : static void cmd_showport_parsed(void *parsed_result,
7210 : : __rte_unused struct cmdline *cl,
7211 : : __rte_unused void *data)
7212 : : {
7213 : : struct cmd_showport_result *res = parsed_result;
7214 : 0 : if (!strcmp(res->show, "clear")) {
7215 : 0 : if (!strcmp(res->what, "stats"))
7216 : 0 : nic_stats_clear(res->portnum);
7217 : 0 : else if (!strcmp(res->what, "xstats"))
7218 : 0 : nic_xstats_clear(res->portnum);
7219 : 0 : } else if (!strcmp(res->what, "info"))
7220 : 0 : port_infos_display(res->portnum);
7221 : 0 : else if (!strcmp(res->what, "summary")) {
7222 : 0 : port_summary_header_display();
7223 : 0 : port_summary_display(res->portnum);
7224 : : }
7225 : 0 : else if (!strcmp(res->what, "stats"))
7226 : 0 : nic_stats_display(res->portnum);
7227 : 0 : else if (!strcmp(res->what, "xstats"))
7228 : 0 : nic_xstats_display(res->portnum);
7229 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7230 : 0 : else if (!strcmp(res->what, "fdir"))
7231 : 0 : fdir_get_infos(res->portnum);
7232 : : #endif
7233 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7234 : 0 : port_dcb_info_display(res->portnum);
7235 : 0 : }
7236 : :
7237 : : static cmdline_parse_token_string_t cmd_showport_show =
7238 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7239 : : "show#clear");
7240 : : static cmdline_parse_token_string_t cmd_showport_port =
7241 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7242 : : static cmdline_parse_token_string_t cmd_showport_what =
7243 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7244 : : "info#summary#stats#xstats#fdir#dcb_tc");
7245 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7246 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7247 : :
7248 : : static cmdline_parse_inst_t cmd_showport = {
7249 : : .f = cmd_showport_parsed,
7250 : : .data = NULL,
7251 : : .help_str = "show|clear port "
7252 : : "info|summary|stats|xstats|fdir|dcb_tc "
7253 : : "<port_id>",
7254 : : .tokens = {
7255 : : (void *)&cmd_showport_show,
7256 : : (void *)&cmd_showport_port,
7257 : : (void *)&cmd_showport_what,
7258 : : (void *)&cmd_showport_portnum,
7259 : : NULL,
7260 : : },
7261 : : };
7262 : :
7263 : : /* *** show port representors information *** */
7264 : : struct cmd_representor_info_result {
7265 : : cmdline_fixed_string_t cmd_show;
7266 : : cmdline_fixed_string_t cmd_port;
7267 : : cmdline_fixed_string_t cmd_info;
7268 : : cmdline_fixed_string_t cmd_keyword;
7269 : : portid_t cmd_pid;
7270 : : };
7271 : :
7272 : : static void
7273 : 0 : cmd_representor_info_parsed(void *parsed_result,
7274 : : __rte_unused struct cmdline *cl,
7275 : : __rte_unused void *data)
7276 : : {
7277 : : struct cmd_representor_info_result *res = parsed_result;
7278 : : struct rte_eth_representor_info *info;
7279 : : struct rte_eth_representor_range *range;
7280 : : uint32_t range_diff;
7281 : : uint32_t i;
7282 : : int ret;
7283 : : int num;
7284 : :
7285 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7286 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7287 : 0 : return;
7288 : : }
7289 : :
7290 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7291 : 0 : if (ret < 0) {
7292 : 0 : fprintf(stderr,
7293 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7294 : 0 : res->cmd_pid, rte_strerror(-ret));
7295 : 0 : return;
7296 : : }
7297 : : num = ret;
7298 : :
7299 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7300 : 0 : if (info == NULL) {
7301 : 0 : fprintf(stderr,
7302 : : "Failed to allocate memory for representor info for port %hu\n",
7303 : 0 : res->cmd_pid);
7304 : 0 : return;
7305 : : }
7306 : 0 : info->nb_ranges_alloc = num;
7307 : :
7308 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7309 : 0 : if (ret < 0) {
7310 : 0 : fprintf(stderr,
7311 : : "Failed to get the representor info for port %hu: %s\n",
7312 : 0 : res->cmd_pid, rte_strerror(-ret));
7313 : 0 : free(info);
7314 : 0 : return;
7315 : : }
7316 : :
7317 : 0 : printf("Port controller: %hu\n", info->controller);
7318 : 0 : printf("Port PF: %hu\n", info->pf);
7319 : :
7320 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7321 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7322 : : range = &info->ranges[i];
7323 : 0 : range_diff = range->id_end - range->id_base;
7324 : :
7325 : 0 : printf("%u. ", i + 1);
7326 : 0 : printf("'%s' ", range->name);
7327 : 0 : if (range_diff > 0)
7328 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7329 : : else
7330 : 0 : printf("[%u]: ", range->id_base);
7331 : :
7332 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7333 : :
7334 : 0 : switch (range->type) {
7335 : : case RTE_ETH_REPRESENTOR_NONE:
7336 : : printf(", NONE\n");
7337 : : break;
7338 : 0 : case RTE_ETH_REPRESENTOR_VF:
7339 : 0 : if (range_diff > 0)
7340 : 0 : printf(", VF %d..%d\n", range->vf,
7341 : 0 : range->vf + range_diff);
7342 : : else
7343 : 0 : printf(", VF %d\n", range->vf);
7344 : : break;
7345 : 0 : case RTE_ETH_REPRESENTOR_SF:
7346 : 0 : printf(", SF %d\n", range->sf);
7347 : : break;
7348 : 0 : case RTE_ETH_REPRESENTOR_PF:
7349 : 0 : if (range_diff > 0)
7350 : 0 : printf("..%d\n", range->pf + range_diff);
7351 : : else
7352 : : printf("\n");
7353 : : break;
7354 : 0 : default:
7355 : : printf(", UNKNOWN TYPE %d\n", range->type);
7356 : : break;
7357 : : }
7358 : : }
7359 : :
7360 : 0 : free(info);
7361 : : }
7362 : :
7363 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7364 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7365 : : cmd_show, "show");
7366 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7367 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7368 : : cmd_port, "port");
7369 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7370 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7371 : : cmd_info, "info");
7372 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7373 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7374 : : cmd_pid, RTE_UINT16);
7375 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7376 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7377 : : cmd_keyword, "representor");
7378 : :
7379 : : static cmdline_parse_inst_t cmd_representor_info = {
7380 : : .f = cmd_representor_info_parsed,
7381 : : .data = NULL,
7382 : : .help_str = "show port info <port_id> representor",
7383 : : .tokens = {
7384 : : (void *)&cmd_representor_info_show,
7385 : : (void *)&cmd_representor_info_port,
7386 : : (void *)&cmd_representor_info_info,
7387 : : (void *)&cmd_representor_info_pid,
7388 : : (void *)&cmd_representor_info_keyword,
7389 : : NULL,
7390 : : },
7391 : : };
7392 : :
7393 : :
7394 : : /* *** SHOW DEVICE INFO *** */
7395 : : struct cmd_showdevice_result {
7396 : : cmdline_fixed_string_t show;
7397 : : cmdline_fixed_string_t device;
7398 : : cmdline_fixed_string_t what;
7399 : : cmdline_fixed_string_t identifier;
7400 : : };
7401 : :
7402 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7403 : : __rte_unused struct cmdline *cl,
7404 : : __rte_unused void *data)
7405 : : {
7406 : : struct cmd_showdevice_result *res = parsed_result;
7407 : 0 : if (!strcmp(res->what, "info")) {
7408 : 0 : if (!strcmp(res->identifier, "all"))
7409 : 0 : device_infos_display(NULL);
7410 : : else
7411 : 0 : device_infos_display(res->identifier);
7412 : : }
7413 : 0 : }
7414 : :
7415 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7416 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7417 : : "show");
7418 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7419 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7420 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7421 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7422 : : "info");
7423 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7424 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7425 : : identifier, NULL);
7426 : :
7427 : : static cmdline_parse_inst_t cmd_showdevice = {
7428 : : .f = cmd_showdevice_parsed,
7429 : : .data = NULL,
7430 : : .help_str = "show device info <identifier>|all",
7431 : : .tokens = {
7432 : : (void *)&cmd_showdevice_show,
7433 : : (void *)&cmd_showdevice_device,
7434 : : (void *)&cmd_showdevice_what,
7435 : : (void *)&cmd_showdevice_identifier,
7436 : : NULL,
7437 : : },
7438 : : };
7439 : :
7440 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7441 : : struct cmd_showeeprom_result {
7442 : : cmdline_fixed_string_t show;
7443 : : cmdline_fixed_string_t port;
7444 : : uint16_t portnum;
7445 : : cmdline_fixed_string_t type;
7446 : : };
7447 : :
7448 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7449 : : __rte_unused struct cmdline *cl,
7450 : : __rte_unused void *data)
7451 : : {
7452 : : struct cmd_showeeprom_result *res = parsed_result;
7453 : :
7454 : 0 : if (!strcmp(res->type, "eeprom"))
7455 : 0 : port_eeprom_display(res->portnum);
7456 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7457 : 0 : port_module_eeprom_display(res->portnum);
7458 : : else
7459 : 0 : fprintf(stderr, "Unknown argument\n");
7460 : 0 : }
7461 : :
7462 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7463 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7464 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7465 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7466 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7467 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7468 : : RTE_UINT16);
7469 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7470 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7471 : :
7472 : : static cmdline_parse_inst_t cmd_showeeprom = {
7473 : : .f = cmd_showeeprom_parsed,
7474 : : .data = NULL,
7475 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7476 : : .tokens = {
7477 : : (void *)&cmd_showeeprom_show,
7478 : : (void *)&cmd_showeeprom_port,
7479 : : (void *)&cmd_showeeprom_portnum,
7480 : : (void *)&cmd_showeeprom_type,
7481 : : NULL,
7482 : : },
7483 : : };
7484 : :
7485 : : /* *** SET PORT EEPROM *** */
7486 : : struct cmd_seteeprom_result {
7487 : : cmdline_fixed_string_t set;
7488 : : cmdline_fixed_string_t port;
7489 : : uint16_t portnum;
7490 : : cmdline_fixed_string_t eeprom;
7491 : : cmdline_fixed_string_t confirm_str;
7492 : : cmdline_fixed_string_t magic_str;
7493 : : uint32_t magic;
7494 : : cmdline_fixed_string_t value;
7495 : : cmdline_multi_string_t token_str;
7496 : : };
7497 : :
7498 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7499 : : __rte_unused struct cmdline *cl,
7500 : : __rte_unused void *data)
7501 : : {
7502 : : struct cmd_seteeprom_result *res = parsed_result;
7503 : : uint32_t offset = 0;
7504 : : uint32_t length;
7505 : : uint8_t *value;
7506 : : char *token_str;
7507 : : char *token;
7508 : :
7509 : 0 : token_str = res->token_str;
7510 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7511 : :
7512 : : /* Parse Hex string to Byte data */
7513 : 0 : if (strlen(token) % 2 != 0) {
7514 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7515 : : token);
7516 : 0 : return;
7517 : : }
7518 : :
7519 : 0 : length = strlen(token) / 2;
7520 : 0 : value = calloc(length, sizeof(uint8_t));
7521 : 0 : for (int count = 0; count < (int)(length); count++) {
7522 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7523 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7524 : 0 : token - (count + 1));
7525 : 0 : goto out;
7526 : : }
7527 : 0 : token += 2;
7528 : : }
7529 : :
7530 : : /* Second token: offset string */
7531 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7532 : 0 : if (token != NULL) {
7533 : 0 : if (strcmp(token, "offset") == 0) {
7534 : : /* Third token: offset */
7535 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7536 : 0 : if (token == NULL) {
7537 : 0 : fprintf(stderr, "No offset specified\n");
7538 : 0 : goto out;
7539 : : }
7540 : :
7541 : : char *end;
7542 : 0 : offset = strtoul(token, &end, 10);
7543 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7544 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7545 : 0 : goto out;
7546 : : }
7547 : : } else {
7548 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7549 : 0 : goto out;
7550 : : }
7551 : : }
7552 : :
7553 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7554 : :
7555 : 0 : out:
7556 : 0 : free(value);
7557 : : }
7558 : :
7559 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7560 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7561 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7562 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7563 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7564 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7565 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7566 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7567 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7568 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7569 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7570 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7571 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7572 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7573 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7574 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7575 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7576 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7577 : :
7578 : : static cmdline_parse_inst_t cmd_seteeprom = {
7579 : : .f = cmd_seteeprom_parsed,
7580 : : .data = NULL,
7581 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7582 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7583 : : "Note:\n"
7584 : : "This is a high-risk command and its misuse may result in "
7585 : : "unexpected behaviour from the NIC.\n"
7586 : : "By inserting \"accept_risk\" into the command, the user is "
7587 : : "acknowledging and taking responsibility for this risk.",
7588 : : .tokens = {
7589 : : (void *)&cmd_seteeprom_set,
7590 : : (void *)&cmd_seteeprom_port,
7591 : : (void *)&cmd_seteeprom_portnum,
7592 : : (void *)&cmd_seteeprom_eeprom,
7593 : : (void *)&cmd_seteeprom_confirm_str,
7594 : : (void *)&cmd_seteeprom_magic_str,
7595 : : (void *)&cmd_seteeprom_magic,
7596 : : (void *)&cmd_seteeprom_value,
7597 : : (void *)&cmd_seteeprom_token_str,
7598 : : NULL,
7599 : : },
7600 : : };
7601 : :
7602 : : /* *** SHOW QUEUE INFO *** */
7603 : : struct cmd_showqueue_result {
7604 : : cmdline_fixed_string_t show;
7605 : : cmdline_fixed_string_t type;
7606 : : cmdline_fixed_string_t what;
7607 : : uint16_t portnum;
7608 : : uint16_t queuenum;
7609 : : };
7610 : :
7611 : : static void
7612 : 0 : cmd_showqueue_parsed(void *parsed_result,
7613 : : __rte_unused struct cmdline *cl,
7614 : : __rte_unused void *data)
7615 : : {
7616 : : struct cmd_showqueue_result *res = parsed_result;
7617 : :
7618 : 0 : if (!strcmp(res->type, "rxq"))
7619 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7620 : 0 : else if (!strcmp(res->type, "txq"))
7621 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7622 : 0 : }
7623 : :
7624 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7625 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7626 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7627 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7628 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7629 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7630 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7631 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7632 : : RTE_UINT16);
7633 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7634 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7635 : : RTE_UINT16);
7636 : :
7637 : : static cmdline_parse_inst_t cmd_showqueue = {
7638 : : .f = cmd_showqueue_parsed,
7639 : : .data = NULL,
7640 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7641 : : .tokens = {
7642 : : (void *)&cmd_showqueue_show,
7643 : : (void *)&cmd_showqueue_type,
7644 : : (void *)&cmd_showqueue_what,
7645 : : (void *)&cmd_showqueue_portnum,
7646 : : (void *)&cmd_showqueue_queuenum,
7647 : : NULL,
7648 : : },
7649 : : };
7650 : :
7651 : : /* show/clear fwd engine statistics */
7652 : : struct fwd_result {
7653 : : cmdline_fixed_string_t action;
7654 : : cmdline_fixed_string_t fwd;
7655 : : cmdline_fixed_string_t stats;
7656 : : cmdline_fixed_string_t all;
7657 : : };
7658 : :
7659 : : static cmdline_parse_token_string_t cmd_fwd_action =
7660 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7661 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7662 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7663 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7664 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7665 : : static cmdline_parse_token_string_t cmd_fwd_all =
7666 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7667 : :
7668 : : static void
7669 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7670 : : __rte_unused struct cmdline *cl,
7671 : : __rte_unused void *data)
7672 : : {
7673 : : struct fwd_result *res = parsed_result;
7674 : :
7675 : 0 : if (!strcmp(res->action, "show"))
7676 : 0 : fwd_stats_display();
7677 : : else
7678 : 0 : fwd_stats_reset();
7679 : 0 : }
7680 : :
7681 : : static cmdline_parse_inst_t cmd_showfwdall = {
7682 : : .f = cmd_showfwdall_parsed,
7683 : : .data = NULL,
7684 : : .help_str = "show|clear fwd stats all",
7685 : : .tokens = {
7686 : : (void *)&cmd_fwd_action,
7687 : : (void *)&cmd_fwd_fwd,
7688 : : (void *)&cmd_fwd_stats,
7689 : : (void *)&cmd_fwd_all,
7690 : : NULL,
7691 : : },
7692 : : };
7693 : :
7694 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7695 : : struct cmd_read_rxd_txd_result {
7696 : : cmdline_fixed_string_t read;
7697 : : cmdline_fixed_string_t rxd_txd;
7698 : : portid_t port_id;
7699 : : uint16_t queue_id;
7700 : : uint16_t desc_id;
7701 : : };
7702 : :
7703 : : static void
7704 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7705 : : __rte_unused struct cmdline *cl,
7706 : : __rte_unused void *data)
7707 : : {
7708 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7709 : :
7710 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7711 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7712 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7713 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7714 : 0 : }
7715 : :
7716 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7717 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7718 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7719 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7720 : : "rxd#txd");
7721 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7722 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7723 : : RTE_UINT16);
7724 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7725 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7726 : : RTE_UINT16);
7727 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7728 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7729 : : RTE_UINT16);
7730 : :
7731 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7732 : : .f = cmd_read_rxd_txd_parsed,
7733 : : .data = NULL,
7734 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7735 : : .tokens = {
7736 : : (void *)&cmd_read_rxd_txd_read,
7737 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7738 : : (void *)&cmd_read_rxd_txd_port_id,
7739 : : (void *)&cmd_read_rxd_txd_queue_id,
7740 : : (void *)&cmd_read_rxd_txd_desc_id,
7741 : : NULL,
7742 : : },
7743 : : };
7744 : :
7745 : : /* *** QUIT *** */
7746 : : struct cmd_quit_result {
7747 : : cmdline_fixed_string_t quit;
7748 : : };
7749 : :
7750 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7751 : : struct cmdline *cl,
7752 : : __rte_unused void *data)
7753 : : {
7754 : 0 : cmdline_quit(cl);
7755 : 0 : cl_quit = 1;
7756 : 0 : }
7757 : :
7758 : : static cmdline_parse_token_string_t cmd_quit_quit =
7759 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7760 : :
7761 : : static cmdline_parse_inst_t cmd_quit = {
7762 : : .f = cmd_quit_parsed,
7763 : : .data = NULL,
7764 : : .help_str = "quit: Exit application",
7765 : : .tokens = {
7766 : : (void *)&cmd_quit_quit,
7767 : : NULL,
7768 : : },
7769 : : };
7770 : :
7771 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7772 : : struct cmd_mac_addr_result {
7773 : : cmdline_fixed_string_t mac_addr_cmd;
7774 : : cmdline_fixed_string_t what;
7775 : : uint16_t port_num;
7776 : : struct rte_ether_addr address;
7777 : : };
7778 : :
7779 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7780 : : __rte_unused struct cmdline *cl,
7781 : : __rte_unused void *data)
7782 : : {
7783 : : struct cmd_mac_addr_result *res = parsed_result;
7784 : : int ret;
7785 : :
7786 : 0 : if (strcmp(res->what, "add") == 0)
7787 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7788 : 0 : else if (strcmp(res->what, "set") == 0)
7789 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7790 : : &res->address);
7791 : : else
7792 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7793 : :
7794 : : /* check the return value and print it if is < 0 */
7795 : 0 : if(ret < 0)
7796 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7797 : :
7798 : 0 : }
7799 : :
7800 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7801 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7802 : : "mac_addr");
7803 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7804 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7805 : : "add#remove#set");
7806 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7807 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7808 : : RTE_UINT16);
7809 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7810 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7811 : :
7812 : : static cmdline_parse_inst_t cmd_mac_addr = {
7813 : : .f = cmd_mac_addr_parsed,
7814 : : .data = (void *)0,
7815 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7816 : : "Add/Remove/Set MAC address on port_id",
7817 : : .tokens = {
7818 : : (void *)&cmd_mac_addr_cmd,
7819 : : (void *)&cmd_mac_addr_what,
7820 : : (void *)&cmd_mac_addr_portnum,
7821 : : (void *)&cmd_mac_addr_addr,
7822 : : NULL,
7823 : : },
7824 : : };
7825 : :
7826 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7827 : : struct cmd_eth_peer_result {
7828 : : cmdline_fixed_string_t set;
7829 : : cmdline_fixed_string_t eth_peer;
7830 : : portid_t port_id;
7831 : : cmdline_fixed_string_t peer_addr;
7832 : : };
7833 : :
7834 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7835 : : __rte_unused struct cmdline *cl,
7836 : : __rte_unused void *data)
7837 : : {
7838 : : struct cmd_eth_peer_result *res = parsed_result;
7839 : :
7840 : 0 : if (test_done == 0) {
7841 : 0 : fprintf(stderr, "Please stop forwarding first\n");
7842 : 0 : return;
7843 : : }
7844 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
7845 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
7846 : 0 : fwd_config_setup();
7847 : : }
7848 : : }
7849 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
7850 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7851 : : static cmdline_parse_token_string_t cmd_eth_peer =
7852 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7853 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
7854 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
7855 : : RTE_UINT16);
7856 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
7857 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7858 : :
7859 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7860 : : .f = cmd_set_eth_peer_parsed,
7861 : : .data = NULL,
7862 : : .help_str = "set eth-peer <port_id> <peer_mac>",
7863 : : .tokens = {
7864 : : (void *)&cmd_eth_peer_set,
7865 : : (void *)&cmd_eth_peer,
7866 : : (void *)&cmd_eth_peer_port_id,
7867 : : (void *)&cmd_eth_peer_addr,
7868 : : NULL,
7869 : : },
7870 : : };
7871 : :
7872 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7873 : : struct cmd_set_qmap_result {
7874 : : cmdline_fixed_string_t set;
7875 : : cmdline_fixed_string_t qmap;
7876 : : cmdline_fixed_string_t what;
7877 : : portid_t port_id;
7878 : : uint16_t queue_id;
7879 : : uint8_t map_value;
7880 : : };
7881 : :
7882 : : static void
7883 : 0 : cmd_set_qmap_parsed(void *parsed_result,
7884 : : __rte_unused struct cmdline *cl,
7885 : : __rte_unused void *data)
7886 : : {
7887 : : struct cmd_set_qmap_result *res = parsed_result;
7888 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7889 : :
7890 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7891 : 0 : }
7892 : :
7893 : : static cmdline_parse_token_string_t cmd_setqmap_set =
7894 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7895 : : set, "set");
7896 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
7897 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7898 : : qmap, "stat_qmap");
7899 : : static cmdline_parse_token_string_t cmd_setqmap_what =
7900 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7901 : : what, "tx#rx");
7902 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
7903 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7904 : : port_id, RTE_UINT16);
7905 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
7906 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7907 : : queue_id, RTE_UINT16);
7908 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7909 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7910 : : map_value, RTE_UINT8);
7911 : :
7912 : : static cmdline_parse_inst_t cmd_set_qmap = {
7913 : : .f = cmd_set_qmap_parsed,
7914 : : .data = NULL,
7915 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7916 : : "Set statistics mapping value on tx|rx queue_id of port_id",
7917 : : .tokens = {
7918 : : (void *)&cmd_setqmap_set,
7919 : : (void *)&cmd_setqmap_qmap,
7920 : : (void *)&cmd_setqmap_what,
7921 : : (void *)&cmd_setqmap_portid,
7922 : : (void *)&cmd_setqmap_queueid,
7923 : : (void *)&cmd_setqmap_mapvalue,
7924 : : NULL,
7925 : : },
7926 : : };
7927 : :
7928 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7929 : : struct cmd_set_xstats_hide_zero_result {
7930 : : cmdline_fixed_string_t keyword;
7931 : : cmdline_fixed_string_t name;
7932 : : cmdline_fixed_string_t on_off;
7933 : : };
7934 : :
7935 : : static void
7936 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7937 : : __rte_unused struct cmdline *cl,
7938 : : __rte_unused void *data)
7939 : : {
7940 : : struct cmd_set_xstats_hide_zero_result *res;
7941 : : uint16_t on_off = 0;
7942 : :
7943 : : res = parsed_result;
7944 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7945 : 0 : set_xstats_hide_zero(on_off);
7946 : 0 : }
7947 : :
7948 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7949 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7950 : : keyword, "set");
7951 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7952 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7953 : : name, "xstats-hide-zero");
7954 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7955 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7956 : : on_off, "on#off");
7957 : :
7958 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7959 : : .f = cmd_set_xstats_hide_zero_parsed,
7960 : : .data = NULL,
7961 : : .help_str = "set xstats-hide-zero on|off",
7962 : : .tokens = {
7963 : : (void *)&cmd_set_xstats_hide_zero_keyword,
7964 : : (void *)&cmd_set_xstats_hide_zero_name,
7965 : : (void *)&cmd_set_xstats_hide_zero_on_off,
7966 : : NULL,
7967 : : },
7968 : : };
7969 : :
7970 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
7971 : : struct cmd_set_xstats_show_state_result {
7972 : : cmdline_fixed_string_t keyword;
7973 : : cmdline_fixed_string_t name;
7974 : : uint8_t on_off;
7975 : : };
7976 : : static void
7977 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
7978 : : __rte_unused struct cmdline *cl,
7979 : : __rte_unused void *data)
7980 : : {
7981 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
7982 : 0 : set_xstats_show_state(res->on_off);
7983 : 0 : }
7984 : :
7985 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
7986 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
7987 : : keyword, "set");
7988 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
7989 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
7990 : : name, "xstats-show-state");
7991 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
7992 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
7993 : : on_off);
7994 : :
7995 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
7996 : : .f = cmd_set_xstats_show_state_parsed,
7997 : : .data = NULL,
7998 : : .help_str = "set xstats-show-state on|off",
7999 : : .tokens = {
8000 : : (void *)&cmd_set_xstats_show_state_keyword,
8001 : : (void *)&cmd_set_xstats_show_state_name,
8002 : : (void *)&cmd_set_xstats_show_state_on_off,
8003 : : NULL,
8004 : : },
8005 : : };
8006 : :
8007 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8008 : : struct cmd_set_xstats_hide_disabled_result {
8009 : : cmdline_fixed_string_t keyword;
8010 : : cmdline_fixed_string_t name;
8011 : : uint8_t on_off;
8012 : : };
8013 : :
8014 : : static void
8015 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8016 : : __rte_unused struct cmdline *cl,
8017 : : __rte_unused void *data)
8018 : : {
8019 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8020 : 0 : set_xstats_hide_disabled(res->on_off);
8021 : 0 : }
8022 : :
8023 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8024 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8025 : : keyword, "set");
8026 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8027 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8028 : : name, "xstats-hide-disabled");
8029 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8030 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8031 : : on_off);
8032 : :
8033 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8034 : : .f = cmd_set_xstats_hide_disabled_parsed,
8035 : : .data = NULL,
8036 : : .help_str = "set xstats-hide-disabled on|off",
8037 : : .tokens = {
8038 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8039 : : (void *)&cmd_set_xstats_hide_disabled_name,
8040 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8041 : : NULL,
8042 : : },
8043 : : };
8044 : :
8045 : : /* *** enable/disable counter by name *** */
8046 : : struct cmd_operate_set_counter_result {
8047 : : cmdline_fixed_string_t port;
8048 : : portid_t port_id;
8049 : : cmdline_fixed_string_t what;
8050 : : cmdline_multi_string_t counter_name;
8051 : : };
8052 : :
8053 : : static void
8054 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8055 : : __rte_unused struct cmdline *cl,
8056 : : __rte_unused void *data)
8057 : : {
8058 : : struct cmd_operate_set_counter_result *res = parsed_result;
8059 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8060 : :
8061 : 0 : if ((strcmp(res->port, "port") == 0))
8062 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8063 : 0 : }
8064 : :
8065 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8066 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8067 : : port, "port");
8068 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8069 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8070 : : port_id, RTE_UINT16);
8071 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8072 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8073 : : what, "enable#disable");
8074 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8075 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8076 : : counter_name, TOKEN_STRING_MULTI);
8077 : :
8078 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8079 : : .f = cmd_operate_set_counter_parsed,
8080 : : .data = NULL,
8081 : : .help_str = "port (port_id) enable|disable <counter_name>",
8082 : : .tokens = {
8083 : : (void *)&cmd_operate_set_counter_port,
8084 : : (void *)&cmd_operate_set_counter_port_id,
8085 : : (void *)&cmd_operate_set_counter_what,
8086 : : (void *)&cmd_operate_set_counter_name,
8087 : : NULL,
8088 : : },
8089 : : };
8090 : :
8091 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8092 : : struct cmd_set_record_core_cycles_result {
8093 : : cmdline_fixed_string_t keyword;
8094 : : cmdline_fixed_string_t name;
8095 : : cmdline_fixed_string_t on_off;
8096 : : };
8097 : :
8098 : : static void
8099 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8100 : : __rte_unused struct cmdline *cl,
8101 : : __rte_unused void *data)
8102 : : {
8103 : : struct cmd_set_record_core_cycles_result *res;
8104 : : uint16_t on_off = 0;
8105 : :
8106 : : res = parsed_result;
8107 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8108 : 0 : set_record_core_cycles(on_off);
8109 : 0 : }
8110 : :
8111 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8112 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8113 : : keyword, "set");
8114 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8115 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8116 : : name, "record-core-cycles");
8117 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8118 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8119 : : on_off, "on#off");
8120 : :
8121 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8122 : : .f = cmd_set_record_core_cycles_parsed,
8123 : : .data = NULL,
8124 : : .help_str = "set record-core-cycles on|off",
8125 : : .tokens = {
8126 : : (void *)&cmd_set_record_core_cycles_keyword,
8127 : : (void *)&cmd_set_record_core_cycles_name,
8128 : : (void *)&cmd_set_record_core_cycles_on_off,
8129 : : NULL,
8130 : : },
8131 : : };
8132 : :
8133 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8134 : : struct cmd_set_record_burst_stats_result {
8135 : : cmdline_fixed_string_t keyword;
8136 : : cmdline_fixed_string_t name;
8137 : : cmdline_fixed_string_t on_off;
8138 : : };
8139 : :
8140 : : static void
8141 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8142 : : __rte_unused struct cmdline *cl,
8143 : : __rte_unused void *data)
8144 : : {
8145 : : struct cmd_set_record_burst_stats_result *res;
8146 : : uint16_t on_off = 0;
8147 : :
8148 : : res = parsed_result;
8149 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8150 : 0 : set_record_burst_stats(on_off);
8151 : 0 : }
8152 : :
8153 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8154 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8155 : : keyword, "set");
8156 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8157 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8158 : : name, "record-burst-stats");
8159 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8160 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8161 : : on_off, "on#off");
8162 : :
8163 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8164 : : .f = cmd_set_record_burst_stats_parsed,
8165 : : .data = NULL,
8166 : : .help_str = "set record-burst-stats on|off",
8167 : : .tokens = {
8168 : : (void *)&cmd_set_record_burst_stats_keyword,
8169 : : (void *)&cmd_set_record_burst_stats_name,
8170 : : (void *)&cmd_set_record_burst_stats_on_off,
8171 : : NULL,
8172 : : },
8173 : : };
8174 : :
8175 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8176 : : struct cmd_set_uc_hash_table {
8177 : : cmdline_fixed_string_t set;
8178 : : cmdline_fixed_string_t port;
8179 : : portid_t port_id;
8180 : : cmdline_fixed_string_t what;
8181 : : struct rte_ether_addr address;
8182 : : cmdline_fixed_string_t mode;
8183 : : };
8184 : :
8185 : : static void
8186 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8187 : : __rte_unused struct cmdline *cl,
8188 : : __rte_unused void *data)
8189 : : {
8190 : : int ret=0;
8191 : : struct cmd_set_uc_hash_table *res = parsed_result;
8192 : :
8193 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8194 : :
8195 : 0 : if (strcmp(res->what, "uta") == 0)
8196 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8197 : : &res->address,(uint8_t)is_on);
8198 : 0 : if (ret < 0)
8199 : 0 : fprintf(stderr,
8200 : : "bad unicast hash table parameter, return code = %d\n",
8201 : : ret);
8202 : :
8203 : 0 : }
8204 : :
8205 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8206 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8207 : : set, "set");
8208 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8209 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8210 : : port, "port");
8211 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8212 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8213 : : port_id, RTE_UINT16);
8214 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8215 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8216 : : what, "uta");
8217 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8218 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8219 : : address);
8220 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8221 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8222 : : mode, "on#off");
8223 : :
8224 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8225 : : .f = cmd_set_uc_hash_parsed,
8226 : : .data = NULL,
8227 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8228 : : .tokens = {
8229 : : (void *)&cmd_set_uc_hash_set,
8230 : : (void *)&cmd_set_uc_hash_port,
8231 : : (void *)&cmd_set_uc_hash_portid,
8232 : : (void *)&cmd_set_uc_hash_what,
8233 : : (void *)&cmd_set_uc_hash_mac,
8234 : : (void *)&cmd_set_uc_hash_mode,
8235 : : NULL,
8236 : : },
8237 : : };
8238 : :
8239 : : struct cmd_set_uc_all_hash_table {
8240 : : cmdline_fixed_string_t set;
8241 : : cmdline_fixed_string_t port;
8242 : : portid_t port_id;
8243 : : cmdline_fixed_string_t what;
8244 : : cmdline_fixed_string_t value;
8245 : : cmdline_fixed_string_t mode;
8246 : : };
8247 : :
8248 : : static void
8249 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8250 : : __rte_unused struct cmdline *cl,
8251 : : __rte_unused void *data)
8252 : : {
8253 : : int ret=0;
8254 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8255 : :
8256 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8257 : :
8258 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8259 : 0 : (strcmp(res->value, "all") == 0))
8260 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8261 : 0 : if (ret < 0)
8262 : 0 : fprintf(stderr,
8263 : : "bad unicast hash table parameter, return code = %d\n",
8264 : : ret);
8265 : 0 : }
8266 : :
8267 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8268 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8269 : : set, "set");
8270 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8271 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8272 : : port, "port");
8273 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8274 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8275 : : port_id, RTE_UINT16);
8276 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8277 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8278 : : what, "uta");
8279 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8280 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8281 : : value,"all");
8282 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8283 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8284 : : mode, "on#off");
8285 : :
8286 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8287 : : .f = cmd_set_uc_all_hash_parsed,
8288 : : .data = NULL,
8289 : : .help_str = "set port <port_id> uta all on|off",
8290 : : .tokens = {
8291 : : (void *)&cmd_set_uc_all_hash_set,
8292 : : (void *)&cmd_set_uc_all_hash_port,
8293 : : (void *)&cmd_set_uc_all_hash_portid,
8294 : : (void *)&cmd_set_uc_all_hash_what,
8295 : : (void *)&cmd_set_uc_all_hash_value,
8296 : : (void *)&cmd_set_uc_all_hash_mode,
8297 : : NULL,
8298 : : },
8299 : : };
8300 : :
8301 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8302 : : struct cmd_set_vf_traffic {
8303 : : cmdline_fixed_string_t set;
8304 : : cmdline_fixed_string_t port;
8305 : : portid_t port_id;
8306 : : cmdline_fixed_string_t vf;
8307 : : uint8_t vf_id;
8308 : : cmdline_fixed_string_t what;
8309 : : cmdline_fixed_string_t mode;
8310 : : };
8311 : :
8312 : : static void
8313 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8314 : : __rte_unused struct cmdline *cl,
8315 : : __rte_unused void *data)
8316 : : {
8317 : : struct cmd_set_vf_traffic *res = parsed_result;
8318 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8319 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8320 : :
8321 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8322 : 0 : }
8323 : :
8324 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8326 : : set, "set");
8327 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8328 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8329 : : port, "port");
8330 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8331 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8332 : : port_id, RTE_UINT16);
8333 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8334 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8335 : : vf, "vf");
8336 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8337 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8338 : : vf_id, RTE_UINT8);
8339 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8340 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8341 : : what, "tx#rx");
8342 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8343 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8344 : : mode, "on#off");
8345 : :
8346 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8347 : : .f = cmd_set_vf_traffic_parsed,
8348 : : .data = NULL,
8349 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8350 : : .tokens = {
8351 : : (void *)&cmd_setvf_traffic_set,
8352 : : (void *)&cmd_setvf_traffic_port,
8353 : : (void *)&cmd_setvf_traffic_portid,
8354 : : (void *)&cmd_setvf_traffic_vf,
8355 : : (void *)&cmd_setvf_traffic_vfid,
8356 : : (void *)&cmd_setvf_traffic_what,
8357 : : (void *)&cmd_setvf_traffic_mode,
8358 : : NULL,
8359 : : },
8360 : : };
8361 : :
8362 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8363 : : struct cmd_set_vf_rxmode {
8364 : : cmdline_fixed_string_t set;
8365 : : cmdline_fixed_string_t port;
8366 : : portid_t port_id;
8367 : : cmdline_fixed_string_t vf;
8368 : : uint8_t vf_id;
8369 : : cmdline_fixed_string_t what;
8370 : : cmdline_fixed_string_t mode;
8371 : : cmdline_fixed_string_t on;
8372 : : };
8373 : :
8374 : : static void
8375 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8376 : : __rte_unused struct cmdline *cl,
8377 : : __rte_unused void *data)
8378 : : {
8379 : : int ret = -ENOTSUP;
8380 : : uint16_t vf_rxmode = 0;
8381 : : struct cmd_set_vf_rxmode *res = parsed_result;
8382 : :
8383 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8384 : 0 : if (!strcmp(res->what,"rxmode")) {
8385 : 0 : if (!strcmp(res->mode, "AUPE"))
8386 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8387 : 0 : else if (!strcmp(res->mode, "ROPE"))
8388 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8389 : 0 : else if (!strcmp(res->mode, "BAM"))
8390 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8391 : 0 : else if (!strncmp(res->mode, "MPE",3))
8392 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8393 : : }
8394 : :
8395 : : RTE_SET_USED(is_on);
8396 : : RTE_SET_USED(vf_rxmode);
8397 : :
8398 : : #ifdef RTE_NET_IXGBE
8399 : : if (ret == -ENOTSUP)
8400 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8401 : : vf_rxmode, (uint8_t)is_on);
8402 : : #endif
8403 : : #ifdef RTE_NET_BNXT
8404 : 0 : if (ret == -ENOTSUP)
8405 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8406 : : vf_rxmode, (uint8_t)is_on);
8407 : : #endif
8408 : 0 : if (ret < 0)
8409 : 0 : fprintf(stderr,
8410 : : "bad VF receive mode parameter, return code = %d\n",
8411 : : ret);
8412 : 0 : }
8413 : :
8414 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8415 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8416 : : set, "set");
8417 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8418 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8419 : : port, "port");
8420 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8421 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8422 : : port_id, RTE_UINT16);
8423 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8425 : : vf, "vf");
8426 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8427 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8428 : : vf_id, RTE_UINT8);
8429 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8431 : : what, "rxmode");
8432 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8434 : : mode, "AUPE#ROPE#BAM#MPE");
8435 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8437 : : on, "on#off");
8438 : :
8439 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8440 : : .f = cmd_set_vf_rxmode_parsed,
8441 : : .data = NULL,
8442 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8443 : : "AUPE|ROPE|BAM|MPE on|off",
8444 : : .tokens = {
8445 : : (void *)&cmd_set_vf_rxmode_set,
8446 : : (void *)&cmd_set_vf_rxmode_port,
8447 : : (void *)&cmd_set_vf_rxmode_portid,
8448 : : (void *)&cmd_set_vf_rxmode_vf,
8449 : : (void *)&cmd_set_vf_rxmode_vfid,
8450 : : (void *)&cmd_set_vf_rxmode_what,
8451 : : (void *)&cmd_set_vf_rxmode_mode,
8452 : : (void *)&cmd_set_vf_rxmode_on,
8453 : : NULL,
8454 : : },
8455 : : };
8456 : :
8457 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8458 : : struct cmd_vf_mac_addr_result {
8459 : : cmdline_fixed_string_t mac_addr_cmd;
8460 : : cmdline_fixed_string_t what;
8461 : : cmdline_fixed_string_t port;
8462 : : uint16_t port_num;
8463 : : cmdline_fixed_string_t vf;
8464 : : uint8_t vf_num;
8465 : : struct rte_ether_addr address;
8466 : : };
8467 : :
8468 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8469 : : __rte_unused struct cmdline *cl,
8470 : : __rte_unused void *data)
8471 : : {
8472 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8473 : : int ret = -ENOTSUP;
8474 : :
8475 : 0 : if (strcmp(res->what, "add") != 0)
8476 : : return;
8477 : :
8478 : : #ifdef RTE_NET_I40E
8479 : : if (ret == -ENOTSUP)
8480 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8481 : : &res->address);
8482 : : #endif
8483 : : #ifdef RTE_NET_BNXT
8484 : 0 : if (ret == -ENOTSUP)
8485 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8486 : 0 : res->vf_num);
8487 : : #endif
8488 : :
8489 : 0 : if(ret < 0)
8490 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8491 : :
8492 : : }
8493 : :
8494 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8495 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8496 : : mac_addr_cmd,"mac_addr");
8497 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8498 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8499 : : what,"add");
8500 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8501 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8502 : : port,"port");
8503 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8504 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8505 : : port_num, RTE_UINT16);
8506 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8507 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8508 : : vf,"vf");
8509 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8510 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8511 : : vf_num, RTE_UINT8);
8512 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8513 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8514 : : address);
8515 : :
8516 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8517 : : .f = cmd_vf_mac_addr_parsed,
8518 : : .data = (void *)0,
8519 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8520 : : "Add MAC address filtering for a VF on port_id",
8521 : : .tokens = {
8522 : : (void *)&cmd_vf_mac_addr_cmd,
8523 : : (void *)&cmd_vf_mac_addr_what,
8524 : : (void *)&cmd_vf_mac_addr_port,
8525 : : (void *)&cmd_vf_mac_addr_portnum,
8526 : : (void *)&cmd_vf_mac_addr_vf,
8527 : : (void *)&cmd_vf_mac_addr_vfnum,
8528 : : (void *)&cmd_vf_mac_addr_addr,
8529 : : NULL,
8530 : : },
8531 : : };
8532 : :
8533 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8534 : : struct cmd_vf_rx_vlan_filter {
8535 : : cmdline_fixed_string_t rx_vlan;
8536 : : cmdline_fixed_string_t what;
8537 : : uint16_t vlan_id;
8538 : : cmdline_fixed_string_t port;
8539 : : portid_t port_id;
8540 : : cmdline_fixed_string_t vf;
8541 : : uint64_t vf_mask;
8542 : : };
8543 : :
8544 : : static void
8545 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8546 : : __rte_unused struct cmdline *cl,
8547 : : __rte_unused void *data)
8548 : : {
8549 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8550 : : int ret = -ENOTSUP;
8551 : :
8552 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8553 : :
8554 : : #ifdef RTE_NET_IXGBE
8555 : : if (ret == -ENOTSUP)
8556 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8557 : 0 : res->vlan_id, res->vf_mask, is_add);
8558 : : #endif
8559 : : #ifdef RTE_NET_I40E
8560 : 0 : if (ret == -ENOTSUP)
8561 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8562 : 0 : res->vlan_id, res->vf_mask, is_add);
8563 : : #endif
8564 : : #ifdef RTE_NET_BNXT
8565 : 0 : if (ret == -ENOTSUP)
8566 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8567 : 0 : res->vlan_id, res->vf_mask, is_add);
8568 : : #endif
8569 : :
8570 : 0 : switch (ret) {
8571 : : case 0:
8572 : : break;
8573 : 0 : case -EINVAL:
8574 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8575 : 0 : res->vlan_id, res->vf_mask);
8576 : : break;
8577 : 0 : case -ENODEV:
8578 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8579 : : break;
8580 : 0 : case -ENOTSUP:
8581 : 0 : fprintf(stderr, "function not implemented or supported\n");
8582 : : break;
8583 : 0 : default:
8584 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8585 : : }
8586 : 0 : }
8587 : :
8588 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8589 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8590 : : rx_vlan, "rx_vlan");
8591 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8592 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8593 : : what, "add#rm");
8594 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8595 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8596 : : vlan_id, RTE_UINT16);
8597 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8598 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8599 : : port, "port");
8600 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8601 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8602 : : port_id, RTE_UINT16);
8603 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8604 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8605 : : vf, "vf");
8606 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8607 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8608 : : vf_mask, RTE_UINT64);
8609 : :
8610 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8611 : : .f = cmd_vf_rx_vlan_filter_parsed,
8612 : : .data = NULL,
8613 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8614 : : "(vf_mask = hexadecimal VF mask)",
8615 : : .tokens = {
8616 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8617 : : (void *)&cmd_vf_rx_vlan_filter_what,
8618 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8619 : : (void *)&cmd_vf_rx_vlan_filter_port,
8620 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8621 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8622 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8623 : : NULL,
8624 : : },
8625 : : };
8626 : :
8627 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8628 : : struct cmd_queue_rate_limit_result {
8629 : : cmdline_fixed_string_t set;
8630 : : cmdline_fixed_string_t port;
8631 : : uint16_t port_num;
8632 : : cmdline_fixed_string_t queue;
8633 : : uint8_t queue_num;
8634 : : cmdline_fixed_string_t rate;
8635 : : uint32_t rate_num;
8636 : : };
8637 : :
8638 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8639 : : __rte_unused struct cmdline *cl,
8640 : : __rte_unused void *data)
8641 : : {
8642 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8643 : : int ret = 0;
8644 : :
8645 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8646 : 0 : && (strcmp(res->queue, "queue") == 0)
8647 : 0 : && (strcmp(res->rate, "rate") == 0))
8648 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8649 : : res->rate_num);
8650 : 0 : if (ret < 0)
8651 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8652 : : strerror(-ret));
8653 : :
8654 : 0 : }
8655 : :
8656 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8657 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8658 : : set, "set");
8659 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8660 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8661 : : port, "port");
8662 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8663 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8664 : : port_num, RTE_UINT16);
8665 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8666 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8667 : : queue, "queue");
8668 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8669 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8670 : : queue_num, RTE_UINT8);
8671 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8672 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8673 : : rate, "rate");
8674 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8675 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8676 : : rate_num, RTE_UINT32);
8677 : :
8678 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8679 : : .f = cmd_queue_rate_limit_parsed,
8680 : : .data = (void *)0,
8681 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8682 : : "Set rate limit for a queue on port_id",
8683 : : .tokens = {
8684 : : (void *)&cmd_queue_rate_limit_set,
8685 : : (void *)&cmd_queue_rate_limit_port,
8686 : : (void *)&cmd_queue_rate_limit_portnum,
8687 : : (void *)&cmd_queue_rate_limit_queue,
8688 : : (void *)&cmd_queue_rate_limit_queuenum,
8689 : : (void *)&cmd_queue_rate_limit_rate,
8690 : : (void *)&cmd_queue_rate_limit_ratenum,
8691 : : NULL,
8692 : : },
8693 : : };
8694 : :
8695 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8696 : : struct cmd_vf_rate_limit_result {
8697 : : cmdline_fixed_string_t set;
8698 : : cmdline_fixed_string_t port;
8699 : : uint16_t port_num;
8700 : : cmdline_fixed_string_t vf;
8701 : : uint8_t vf_num;
8702 : : cmdline_fixed_string_t rate;
8703 : : uint32_t rate_num;
8704 : : cmdline_fixed_string_t q_msk;
8705 : : uint64_t q_msk_val;
8706 : : };
8707 : :
8708 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8709 : : __rte_unused struct cmdline *cl,
8710 : : __rte_unused void *data)
8711 : : {
8712 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8713 : : int ret = 0;
8714 : :
8715 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8716 : 0 : && (strcmp(res->vf, "vf") == 0)
8717 : 0 : && (strcmp(res->rate, "rate") == 0)
8718 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8719 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8720 : : res->rate_num, res->q_msk_val);
8721 : 0 : if (ret < 0)
8722 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8723 : : strerror(-ret));
8724 : :
8725 : 0 : }
8726 : :
8727 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8728 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8729 : : set, "set");
8730 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8731 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8732 : : port, "port");
8733 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8734 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8735 : : port_num, RTE_UINT16);
8736 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8737 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8738 : : vf, "vf");
8739 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8740 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8741 : : vf_num, RTE_UINT8);
8742 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8743 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8744 : : rate, "rate");
8745 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8746 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8747 : : rate_num, RTE_UINT32);
8748 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8749 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8750 : : q_msk, "queue_mask");
8751 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8752 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8753 : : q_msk_val, RTE_UINT64);
8754 : :
8755 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8756 : : .f = cmd_vf_rate_limit_parsed,
8757 : : .data = (void *)0,
8758 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8759 : : "queue_mask <queue_mask_value>: "
8760 : : "Set rate limit for queues of VF on port_id",
8761 : : .tokens = {
8762 : : (void *)&cmd_vf_rate_limit_set,
8763 : : (void *)&cmd_vf_rate_limit_port,
8764 : : (void *)&cmd_vf_rate_limit_portnum,
8765 : : (void *)&cmd_vf_rate_limit_vf,
8766 : : (void *)&cmd_vf_rate_limit_vfnum,
8767 : : (void *)&cmd_vf_rate_limit_rate,
8768 : : (void *)&cmd_vf_rate_limit_ratenum,
8769 : : (void *)&cmd_vf_rate_limit_q_msk,
8770 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8771 : : NULL,
8772 : : },
8773 : : };
8774 : :
8775 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8776 : : struct cmd_tunnel_udp_config {
8777 : : cmdline_fixed_string_t rx_vxlan_port;
8778 : : cmdline_fixed_string_t what;
8779 : : uint16_t udp_port;
8780 : : portid_t port_id;
8781 : : };
8782 : :
8783 : : static void
8784 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8785 : : __rte_unused struct cmdline *cl,
8786 : : __rte_unused void *data)
8787 : : {
8788 : : struct cmd_tunnel_udp_config *res = parsed_result;
8789 : : struct rte_eth_udp_tunnel tunnel_udp;
8790 : : int ret;
8791 : :
8792 : 0 : tunnel_udp.udp_port = res->udp_port;
8793 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8794 : :
8795 : 0 : if (!strcmp(res->what, "add"))
8796 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8797 : : &tunnel_udp);
8798 : : else
8799 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8800 : : &tunnel_udp);
8801 : :
8802 : 0 : if (ret < 0)
8803 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8804 : : strerror(-ret));
8805 : 0 : }
8806 : :
8807 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8808 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8809 : : rx_vxlan_port, "rx_vxlan_port");
8810 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8811 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8812 : : what, "add#rm");
8813 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8814 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8815 : : udp_port, RTE_UINT16);
8816 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8817 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8818 : : port_id, RTE_UINT16);
8819 : :
8820 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8821 : : .f = cmd_tunnel_udp_config_parsed,
8822 : : .data = (void *)0,
8823 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8824 : : "Add/Remove a tunneling UDP port filter",
8825 : : .tokens = {
8826 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8827 : : (void *)&cmd_tunnel_udp_config_what,
8828 : : (void *)&cmd_tunnel_udp_config_udp_port,
8829 : : (void *)&cmd_tunnel_udp_config_port_id,
8830 : : NULL,
8831 : : },
8832 : : };
8833 : :
8834 : : struct cmd_config_tunnel_udp_port {
8835 : : cmdline_fixed_string_t port;
8836 : : cmdline_fixed_string_t config;
8837 : : portid_t port_id;
8838 : : cmdline_fixed_string_t udp_tunnel_port;
8839 : : cmdline_fixed_string_t action;
8840 : : cmdline_fixed_string_t tunnel_type;
8841 : : uint16_t udp_port;
8842 : : };
8843 : :
8844 : : static void
8845 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8846 : : __rte_unused struct cmdline *cl,
8847 : : __rte_unused void *data)
8848 : : {
8849 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
8850 : : struct rte_eth_udp_tunnel tunnel_udp;
8851 : : int ret = 0;
8852 : :
8853 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8854 : 0 : return;
8855 : :
8856 : 0 : tunnel_udp.udp_port = res->udp_port;
8857 : :
8858 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
8859 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8860 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
8861 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8862 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8863 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8864 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
8865 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8866 : : } else {
8867 : 0 : fprintf(stderr, "Invalid tunnel type\n");
8868 : 0 : return;
8869 : : }
8870 : :
8871 : 0 : if (!strcmp(res->action, "add"))
8872 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8873 : : &tunnel_udp);
8874 : : else
8875 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8876 : : &tunnel_udp);
8877 : :
8878 : 0 : if (ret < 0)
8879 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
8880 : : strerror(-ret));
8881 : : }
8882 : :
8883 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8884 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8885 : : "port");
8886 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8888 : : "config");
8889 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8890 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8891 : : RTE_UINT16);
8892 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8893 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8894 : : udp_tunnel_port,
8895 : : "udp_tunnel_port");
8896 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8897 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8898 : : "add#rm");
8899 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8900 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8901 : : "vxlan#geneve#vxlan-gpe#ecpri");
8902 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8903 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8904 : : RTE_UINT16);
8905 : :
8906 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8907 : : .f = cmd_cfg_tunnel_udp_port_parsed,
8908 : : .data = NULL,
8909 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
8910 : : "geneve|vxlan-gpe|ecpri <udp_port>",
8911 : : .tokens = {
8912 : : (void *)&cmd_config_tunnel_udp_port_port,
8913 : : (void *)&cmd_config_tunnel_udp_port_config,
8914 : : (void *)&cmd_config_tunnel_udp_port_port_id,
8915 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8916 : : (void *)&cmd_config_tunnel_udp_port_action,
8917 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8918 : : (void *)&cmd_config_tunnel_udp_port_value,
8919 : : NULL,
8920 : : },
8921 : : };
8922 : :
8923 : : /* ******************************************************************************** */
8924 : :
8925 : : struct cmd_dump_result {
8926 : : cmdline_fixed_string_t dump;
8927 : : };
8928 : :
8929 : : static void
8930 : 0 : dump_struct_sizes(void)
8931 : : {
8932 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8933 : : DUMP_SIZE(struct rte_mbuf);
8934 : : DUMP_SIZE(struct rte_mempool);
8935 : : DUMP_SIZE(struct rte_ring);
8936 : : #undef DUMP_SIZE
8937 : 0 : }
8938 : :
8939 : :
8940 : : /* Dump the socket memory statistics on console */
8941 : : static void
8942 : 0 : dump_socket_mem(FILE *f)
8943 : : {
8944 : : struct rte_malloc_socket_stats socket_stats;
8945 : : unsigned int i;
8946 : : size_t total = 0;
8947 : : size_t alloc = 0;
8948 : : size_t free = 0;
8949 : : unsigned int n_alloc = 0;
8950 : : unsigned int n_free = 0;
8951 : : static size_t last_allocs;
8952 : : static size_t last_total;
8953 : :
8954 : :
8955 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
8956 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
8957 : 0 : !socket_stats.heap_totalsz_bytes)
8958 : 0 : continue;
8959 : 0 : total += socket_stats.heap_totalsz_bytes;
8960 : 0 : alloc += socket_stats.heap_allocsz_bytes;
8961 : 0 : free += socket_stats.heap_freesz_bytes;
8962 : 0 : n_alloc += socket_stats.alloc_count;
8963 : 0 : n_free += socket_stats.free_count;
8964 : 0 : fprintf(f,
8965 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8966 : : i,
8967 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
8968 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
8969 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
8970 : 0 : (double)socket_stats.heap_totalsz_bytes,
8971 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
8972 : : socket_stats.alloc_count,
8973 : : socket_stats.free_count);
8974 : : }
8975 : 0 : fprintf(f,
8976 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8977 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
8978 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
8979 : 0 : (double)free / (1024 * 1024),
8980 : : n_alloc, n_free);
8981 : 0 : if (last_allocs)
8982 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
8983 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
8984 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
8985 : 0 : last_allocs = alloc;
8986 : 0 : last_total = total;
8987 : 0 : }
8988 : :
8989 : 0 : static void cmd_dump_parsed(void *parsed_result,
8990 : : __rte_unused struct cmdline *cl,
8991 : : __rte_unused void *data)
8992 : : {
8993 : : struct cmd_dump_result *res = parsed_result;
8994 : :
8995 : 0 : if (!strcmp(res->dump, "dump_physmem"))
8996 : 0 : rte_dump_physmem_layout(stdout);
8997 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
8998 : 0 : dump_socket_mem(stdout);
8999 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
9000 : 0 : rte_memzone_dump(stdout);
9001 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
9002 : 0 : dump_struct_sizes();
9003 : 0 : else if (!strcmp(res->dump, "dump_ring"))
9004 : 0 : rte_ring_list_dump(stdout);
9005 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
9006 : 0 : rte_mempool_list_dump(stdout);
9007 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
9008 : 0 : rte_devargs_dump(stdout);
9009 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
9010 : 0 : rte_lcore_dump(stdout);
9011 : : #ifndef RTE_EXEC_ENV_WINDOWS
9012 : 0 : else if (!strcmp(res->dump, "dump_trace"))
9013 : 0 : rte_trace_save();
9014 : : #endif
9015 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
9016 : 0 : rte_log_dump(stdout);
9017 : 0 : }
9018 : :
9019 : : static cmdline_parse_token_string_t cmd_dump_dump =
9020 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9021 : : "dump_physmem#"
9022 : : "dump_memzone#"
9023 : : "dump_socket_mem#"
9024 : : "dump_struct_sizes#"
9025 : : "dump_ring#"
9026 : : "dump_mempool#"
9027 : : "dump_devargs#"
9028 : : "dump_lcores#"
9029 : : #ifndef RTE_EXEC_ENV_WINDOWS
9030 : : "dump_trace#"
9031 : : #endif
9032 : : "dump_log_types");
9033 : :
9034 : : static cmdline_parse_inst_t cmd_dump = {
9035 : : .f = cmd_dump_parsed, /* function to call */
9036 : : .data = NULL, /* 2nd arg of func */
9037 : : .help_str = "Dump status",
9038 : : .tokens = { /* token list, NULL terminated */
9039 : : (void *)&cmd_dump_dump,
9040 : : NULL,
9041 : : },
9042 : : };
9043 : :
9044 : : /* ******************************************************************************** */
9045 : :
9046 : : struct cmd_dump_one_result {
9047 : : cmdline_fixed_string_t dump;
9048 : : cmdline_fixed_string_t name;
9049 : : };
9050 : :
9051 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9052 : : __rte_unused void *data)
9053 : : {
9054 : : struct cmd_dump_one_result *res = parsed_result;
9055 : :
9056 : 0 : if (!strcmp(res->dump, "dump_ring")) {
9057 : : struct rte_ring *r;
9058 : 0 : r = rte_ring_lookup(res->name);
9059 : 0 : if (r == NULL) {
9060 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9061 : 0 : return;
9062 : : }
9063 : 0 : rte_ring_dump(stdout, r);
9064 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
9065 : : struct rte_mempool *mp;
9066 : 0 : mp = rte_mempool_lookup(res->name);
9067 : 0 : if (mp == NULL) {
9068 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9069 : 0 : return;
9070 : : }
9071 : 0 : rte_mempool_dump(stdout, mp);
9072 : : }
9073 : : }
9074 : :
9075 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
9076 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9077 : : "dump_ring#dump_mempool");
9078 : :
9079 : : static cmdline_parse_token_string_t cmd_dump_one_name =
9080 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9081 : :
9082 : : static cmdline_parse_inst_t cmd_dump_one = {
9083 : : .f = cmd_dump_one_parsed, /* function to call */
9084 : : .data = NULL, /* 2nd arg of func */
9085 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9086 : : .tokens = { /* token list, NULL terminated */
9087 : : (void *)&cmd_dump_one_dump,
9088 : : (void *)&cmd_dump_one_name,
9089 : : NULL,
9090 : : },
9091 : : };
9092 : :
9093 : : /* *** Filters Control *** */
9094 : :
9095 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9096 : : do { \
9097 : : if ((ip_addr).family == AF_INET) \
9098 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9099 : : else { \
9100 : : fprintf(stderr, "invalid parameter.\n"); \
9101 : : return; \
9102 : : } \
9103 : : } while (0)
9104 : :
9105 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9106 : : do { \
9107 : : if ((ip_addr).family == AF_INET6) \
9108 : : ip = ip_addr.addr.ipv6; \
9109 : : else { \
9110 : : fprintf(stderr, "invalid parameter.\n"); \
9111 : : return; \
9112 : : } \
9113 : : } while (0)
9114 : :
9115 : : /* Generic flow interface command. */
9116 : : extern cmdline_parse_inst_t cmd_flow;
9117 : :
9118 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9119 : : struct cmd_mcast_addr_result {
9120 : : cmdline_fixed_string_t mcast_addr_cmd;
9121 : : cmdline_fixed_string_t what;
9122 : : uint16_t port_num;
9123 : : struct rte_ether_addr mc_addr;
9124 : : };
9125 : :
9126 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9127 : : __rte_unused struct cmdline *cl,
9128 : : __rte_unused void *data)
9129 : : {
9130 : : struct cmd_mcast_addr_result *res = parsed_result;
9131 : :
9132 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9133 : 0 : fprintf(stderr,
9134 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9135 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9136 : 0 : return;
9137 : : }
9138 : 0 : if (strcmp(res->what, "add") == 0)
9139 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9140 : : else
9141 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9142 : : }
9143 : :
9144 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9145 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9146 : : mcast_addr_cmd, "mcast_addr");
9147 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9148 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9149 : : "add#remove");
9150 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9151 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9152 : : RTE_UINT16);
9153 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9154 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9155 : :
9156 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9157 : : .f = cmd_mcast_addr_parsed,
9158 : : .data = (void *)0,
9159 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9160 : : "Add/Remove multicast MAC address on port_id",
9161 : : .tokens = {
9162 : : (void *)&cmd_mcast_addr_cmd,
9163 : : (void *)&cmd_mcast_addr_what,
9164 : : (void *)&cmd_mcast_addr_portnum,
9165 : : (void *)&cmd_mcast_addr_addr,
9166 : : NULL,
9167 : : },
9168 : : };
9169 : :
9170 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9171 : : struct cmd_mcast_addr_flush_result {
9172 : : cmdline_fixed_string_t mcast_addr_cmd;
9173 : : cmdline_fixed_string_t what;
9174 : : uint16_t port_num;
9175 : : };
9176 : :
9177 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9178 : : __rte_unused struct cmdline *cl,
9179 : : __rte_unused void *data)
9180 : : {
9181 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9182 : :
9183 : 0 : mcast_addr_flush(res->port_num);
9184 : 0 : }
9185 : :
9186 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9187 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9188 : : mcast_addr_cmd, "mcast_addr");
9189 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9190 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9191 : : "flush");
9192 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9193 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9194 : : RTE_UINT16);
9195 : :
9196 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9197 : : .f = cmd_mcast_addr_flush_parsed,
9198 : : .data = (void *)0,
9199 : : .help_str = "mcast_addr flush <port_id> : "
9200 : : "flush all multicast MAC addresses on port_id",
9201 : : .tokens = {
9202 : : (void *)&cmd_mcast_addr_flush_cmd,
9203 : : (void *)&cmd_mcast_addr_flush_what,
9204 : : (void *)&cmd_mcast_addr_flush_portnum,
9205 : : NULL,
9206 : : },
9207 : : };
9208 : :
9209 : : /* vf vlan anti spoof configuration */
9210 : :
9211 : : /* Common result structure for vf vlan anti spoof */
9212 : : struct cmd_vf_vlan_anti_spoof_result {
9213 : : cmdline_fixed_string_t set;
9214 : : cmdline_fixed_string_t vf;
9215 : : cmdline_fixed_string_t vlan;
9216 : : cmdline_fixed_string_t antispoof;
9217 : : portid_t port_id;
9218 : : uint32_t vf_id;
9219 : : cmdline_fixed_string_t on_off;
9220 : : };
9221 : :
9222 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9223 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9224 : : TOKEN_STRING_INITIALIZER
9225 : : (struct cmd_vf_vlan_anti_spoof_result,
9226 : : set, "set");
9227 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9228 : : TOKEN_STRING_INITIALIZER
9229 : : (struct cmd_vf_vlan_anti_spoof_result,
9230 : : vf, "vf");
9231 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9232 : : TOKEN_STRING_INITIALIZER
9233 : : (struct cmd_vf_vlan_anti_spoof_result,
9234 : : vlan, "vlan");
9235 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9236 : : TOKEN_STRING_INITIALIZER
9237 : : (struct cmd_vf_vlan_anti_spoof_result,
9238 : : antispoof, "antispoof");
9239 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9240 : : TOKEN_NUM_INITIALIZER
9241 : : (struct cmd_vf_vlan_anti_spoof_result,
9242 : : port_id, RTE_UINT16);
9243 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9244 : : TOKEN_NUM_INITIALIZER
9245 : : (struct cmd_vf_vlan_anti_spoof_result,
9246 : : vf_id, RTE_UINT32);
9247 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9248 : : TOKEN_STRING_INITIALIZER
9249 : : (struct cmd_vf_vlan_anti_spoof_result,
9250 : : on_off, "on#off");
9251 : :
9252 : : static void
9253 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9254 : : void *parsed_result,
9255 : : __rte_unused struct cmdline *cl,
9256 : : __rte_unused void *data)
9257 : : {
9258 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9259 : : int ret = -ENOTSUP;
9260 : :
9261 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9262 : :
9263 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9264 : : return;
9265 : :
9266 : : #ifdef RTE_NET_IXGBE
9267 : : if (ret == -ENOTSUP)
9268 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9269 : 0 : res->vf_id, is_on);
9270 : : #endif
9271 : : #ifdef RTE_NET_I40E
9272 : 0 : if (ret == -ENOTSUP)
9273 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9274 : 0 : res->vf_id, is_on);
9275 : : #endif
9276 : : #ifdef RTE_NET_BNXT
9277 : 0 : if (ret == -ENOTSUP)
9278 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9279 : 0 : res->vf_id, is_on);
9280 : : #endif
9281 : :
9282 : 0 : switch (ret) {
9283 : : case 0:
9284 : : break;
9285 : 0 : case -EINVAL:
9286 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9287 : : break;
9288 : 0 : case -ENODEV:
9289 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9290 : : break;
9291 : 0 : case -ENOTSUP:
9292 : 0 : fprintf(stderr, "function not implemented\n");
9293 : : break;
9294 : 0 : default:
9295 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9296 : : }
9297 : : }
9298 : :
9299 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9300 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9301 : : .data = NULL,
9302 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9303 : : .tokens = {
9304 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9305 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9306 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9307 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9308 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9309 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9310 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9311 : : NULL,
9312 : : },
9313 : : };
9314 : :
9315 : : /* vf mac anti spoof configuration */
9316 : :
9317 : : /* Common result structure for vf mac anti spoof */
9318 : : struct cmd_vf_mac_anti_spoof_result {
9319 : : cmdline_fixed_string_t set;
9320 : : cmdline_fixed_string_t vf;
9321 : : cmdline_fixed_string_t mac;
9322 : : cmdline_fixed_string_t antispoof;
9323 : : portid_t port_id;
9324 : : uint32_t vf_id;
9325 : : cmdline_fixed_string_t on_off;
9326 : : };
9327 : :
9328 : : /* Common CLI fields for vf mac anti spoof enable disable */
9329 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9330 : : TOKEN_STRING_INITIALIZER
9331 : : (struct cmd_vf_mac_anti_spoof_result,
9332 : : set, "set");
9333 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9334 : : TOKEN_STRING_INITIALIZER
9335 : : (struct cmd_vf_mac_anti_spoof_result,
9336 : : vf, "vf");
9337 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9338 : : TOKEN_STRING_INITIALIZER
9339 : : (struct cmd_vf_mac_anti_spoof_result,
9340 : : mac, "mac");
9341 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9342 : : TOKEN_STRING_INITIALIZER
9343 : : (struct cmd_vf_mac_anti_spoof_result,
9344 : : antispoof, "antispoof");
9345 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9346 : : TOKEN_NUM_INITIALIZER
9347 : : (struct cmd_vf_mac_anti_spoof_result,
9348 : : port_id, RTE_UINT16);
9349 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9350 : : TOKEN_NUM_INITIALIZER
9351 : : (struct cmd_vf_mac_anti_spoof_result,
9352 : : vf_id, RTE_UINT32);
9353 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9354 : : TOKEN_STRING_INITIALIZER
9355 : : (struct cmd_vf_mac_anti_spoof_result,
9356 : : on_off, "on#off");
9357 : :
9358 : : static void
9359 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9360 : : void *parsed_result,
9361 : : __rte_unused struct cmdline *cl,
9362 : : __rte_unused void *data)
9363 : : {
9364 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9365 : : int ret = -ENOTSUP;
9366 : :
9367 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9368 : :
9369 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9370 : : return;
9371 : :
9372 : : #ifdef RTE_NET_IXGBE
9373 : : if (ret == -ENOTSUP)
9374 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9375 : 0 : res->vf_id, is_on);
9376 : : #endif
9377 : : #ifdef RTE_NET_I40E
9378 : 0 : if (ret == -ENOTSUP)
9379 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9380 : 0 : res->vf_id, is_on);
9381 : : #endif
9382 : : #ifdef RTE_NET_BNXT
9383 : 0 : if (ret == -ENOTSUP)
9384 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9385 : 0 : res->vf_id, is_on);
9386 : : #endif
9387 : :
9388 : 0 : switch (ret) {
9389 : : case 0:
9390 : : break;
9391 : 0 : case -EINVAL:
9392 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9393 : : res->vf_id, is_on);
9394 : : break;
9395 : 0 : case -ENODEV:
9396 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9397 : : break;
9398 : 0 : case -ENOTSUP:
9399 : 0 : fprintf(stderr, "function not implemented\n");
9400 : : break;
9401 : 0 : default:
9402 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9403 : : }
9404 : : }
9405 : :
9406 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9407 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9408 : : .data = NULL,
9409 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9410 : : .tokens = {
9411 : : (void *)&cmd_vf_mac_anti_spoof_set,
9412 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9413 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9414 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9415 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9416 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9417 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9418 : : NULL,
9419 : : },
9420 : : };
9421 : :
9422 : : /* vf vlan strip queue configuration */
9423 : :
9424 : : /* Common result structure for vf mac anti spoof */
9425 : : struct cmd_vf_vlan_stripq_result {
9426 : : cmdline_fixed_string_t set;
9427 : : cmdline_fixed_string_t vf;
9428 : : cmdline_fixed_string_t vlan;
9429 : : cmdline_fixed_string_t stripq;
9430 : : portid_t port_id;
9431 : : uint16_t vf_id;
9432 : : cmdline_fixed_string_t on_off;
9433 : : };
9434 : :
9435 : : /* Common CLI fields for vf vlan strip enable disable */
9436 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9437 : : TOKEN_STRING_INITIALIZER
9438 : : (struct cmd_vf_vlan_stripq_result,
9439 : : set, "set");
9440 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9441 : : TOKEN_STRING_INITIALIZER
9442 : : (struct cmd_vf_vlan_stripq_result,
9443 : : vf, "vf");
9444 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9445 : : TOKEN_STRING_INITIALIZER
9446 : : (struct cmd_vf_vlan_stripq_result,
9447 : : vlan, "vlan");
9448 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9449 : : TOKEN_STRING_INITIALIZER
9450 : : (struct cmd_vf_vlan_stripq_result,
9451 : : stripq, "stripq");
9452 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9453 : : TOKEN_NUM_INITIALIZER
9454 : : (struct cmd_vf_vlan_stripq_result,
9455 : : port_id, RTE_UINT16);
9456 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9457 : : TOKEN_NUM_INITIALIZER
9458 : : (struct cmd_vf_vlan_stripq_result,
9459 : : vf_id, RTE_UINT16);
9460 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9461 : : TOKEN_STRING_INITIALIZER
9462 : : (struct cmd_vf_vlan_stripq_result,
9463 : : on_off, "on#off");
9464 : :
9465 : : static void
9466 : 0 : cmd_set_vf_vlan_stripq_parsed(
9467 : : void *parsed_result,
9468 : : __rte_unused struct cmdline *cl,
9469 : : __rte_unused void *data)
9470 : : {
9471 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9472 : : int ret = -ENOTSUP;
9473 : :
9474 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9475 : :
9476 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9477 : : return;
9478 : :
9479 : : #ifdef RTE_NET_IXGBE
9480 : : if (ret == -ENOTSUP)
9481 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9482 : 0 : res->vf_id, is_on);
9483 : : #endif
9484 : : #ifdef RTE_NET_I40E
9485 : 0 : if (ret == -ENOTSUP)
9486 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9487 : 0 : res->vf_id, is_on);
9488 : : #endif
9489 : : #ifdef RTE_NET_BNXT
9490 : 0 : if (ret == -ENOTSUP)
9491 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9492 : 0 : res->vf_id, is_on);
9493 : : #endif
9494 : :
9495 : 0 : switch (ret) {
9496 : : case 0:
9497 : : break;
9498 : 0 : case -EINVAL:
9499 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9500 : 0 : res->vf_id, is_on);
9501 : : break;
9502 : 0 : case -ENODEV:
9503 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9504 : : break;
9505 : 0 : case -ENOTSUP:
9506 : 0 : fprintf(stderr, "function not implemented\n");
9507 : : break;
9508 : 0 : default:
9509 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9510 : : }
9511 : : }
9512 : :
9513 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9514 : : .f = cmd_set_vf_vlan_stripq_parsed,
9515 : : .data = NULL,
9516 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9517 : : .tokens = {
9518 : : (void *)&cmd_vf_vlan_stripq_set,
9519 : : (void *)&cmd_vf_vlan_stripq_vf,
9520 : : (void *)&cmd_vf_vlan_stripq_vlan,
9521 : : (void *)&cmd_vf_vlan_stripq_stripq,
9522 : : (void *)&cmd_vf_vlan_stripq_port_id,
9523 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9524 : : (void *)&cmd_vf_vlan_stripq_on_off,
9525 : : NULL,
9526 : : },
9527 : : };
9528 : :
9529 : : /* vf vlan insert configuration */
9530 : :
9531 : : /* Common result structure for vf vlan insert */
9532 : : struct cmd_vf_vlan_insert_result {
9533 : : cmdline_fixed_string_t set;
9534 : : cmdline_fixed_string_t vf;
9535 : : cmdline_fixed_string_t vlan;
9536 : : cmdline_fixed_string_t insert;
9537 : : portid_t port_id;
9538 : : uint16_t vf_id;
9539 : : uint16_t vlan_id;
9540 : : };
9541 : :
9542 : : /* Common CLI fields for vf vlan insert enable disable */
9543 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9544 : : TOKEN_STRING_INITIALIZER
9545 : : (struct cmd_vf_vlan_insert_result,
9546 : : set, "set");
9547 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9548 : : TOKEN_STRING_INITIALIZER
9549 : : (struct cmd_vf_vlan_insert_result,
9550 : : vf, "vf");
9551 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9552 : : TOKEN_STRING_INITIALIZER
9553 : : (struct cmd_vf_vlan_insert_result,
9554 : : vlan, "vlan");
9555 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9556 : : TOKEN_STRING_INITIALIZER
9557 : : (struct cmd_vf_vlan_insert_result,
9558 : : insert, "insert");
9559 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9560 : : TOKEN_NUM_INITIALIZER
9561 : : (struct cmd_vf_vlan_insert_result,
9562 : : port_id, RTE_UINT16);
9563 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9564 : : TOKEN_NUM_INITIALIZER
9565 : : (struct cmd_vf_vlan_insert_result,
9566 : : vf_id, RTE_UINT16);
9567 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9568 : : TOKEN_NUM_INITIALIZER
9569 : : (struct cmd_vf_vlan_insert_result,
9570 : : vlan_id, RTE_UINT16);
9571 : :
9572 : : static void
9573 : 0 : cmd_set_vf_vlan_insert_parsed(
9574 : : void *parsed_result,
9575 : : __rte_unused struct cmdline *cl,
9576 : : __rte_unused void *data)
9577 : : {
9578 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9579 : : int ret = -ENOTSUP;
9580 : :
9581 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9582 : : return;
9583 : :
9584 : : #ifdef RTE_NET_IXGBE
9585 : : if (ret == -ENOTSUP)
9586 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9587 : 0 : res->vlan_id);
9588 : : #endif
9589 : : #ifdef RTE_NET_I40E
9590 : 0 : if (ret == -ENOTSUP)
9591 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9592 : 0 : res->vlan_id);
9593 : : #endif
9594 : : #ifdef RTE_NET_BNXT
9595 : 0 : if (ret == -ENOTSUP)
9596 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9597 : 0 : res->vlan_id);
9598 : : #endif
9599 : :
9600 : 0 : switch (ret) {
9601 : : case 0:
9602 : : break;
9603 : 0 : case -EINVAL:
9604 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9605 : 0 : res->vf_id, res->vlan_id);
9606 : : break;
9607 : 0 : case -ENODEV:
9608 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9609 : : break;
9610 : 0 : case -ENOTSUP:
9611 : 0 : fprintf(stderr, "function not implemented\n");
9612 : : break;
9613 : 0 : default:
9614 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9615 : : }
9616 : : }
9617 : :
9618 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9619 : : .f = cmd_set_vf_vlan_insert_parsed,
9620 : : .data = NULL,
9621 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9622 : : .tokens = {
9623 : : (void *)&cmd_vf_vlan_insert_set,
9624 : : (void *)&cmd_vf_vlan_insert_vf,
9625 : : (void *)&cmd_vf_vlan_insert_vlan,
9626 : : (void *)&cmd_vf_vlan_insert_insert,
9627 : : (void *)&cmd_vf_vlan_insert_port_id,
9628 : : (void *)&cmd_vf_vlan_insert_vf_id,
9629 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9630 : : NULL,
9631 : : },
9632 : : };
9633 : :
9634 : : /* tx loopback configuration */
9635 : :
9636 : : /* Common result structure for tx loopback */
9637 : : struct cmd_tx_loopback_result {
9638 : : cmdline_fixed_string_t set;
9639 : : cmdline_fixed_string_t tx;
9640 : : cmdline_fixed_string_t loopback;
9641 : : portid_t port_id;
9642 : : cmdline_fixed_string_t on_off;
9643 : : };
9644 : :
9645 : : /* Common CLI fields for tx loopback enable disable */
9646 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9647 : : TOKEN_STRING_INITIALIZER
9648 : : (struct cmd_tx_loopback_result,
9649 : : set, "set");
9650 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9651 : : TOKEN_STRING_INITIALIZER
9652 : : (struct cmd_tx_loopback_result,
9653 : : tx, "tx");
9654 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9655 : : TOKEN_STRING_INITIALIZER
9656 : : (struct cmd_tx_loopback_result,
9657 : : loopback, "loopback");
9658 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9659 : : TOKEN_NUM_INITIALIZER
9660 : : (struct cmd_tx_loopback_result,
9661 : : port_id, RTE_UINT16);
9662 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9663 : : TOKEN_STRING_INITIALIZER
9664 : : (struct cmd_tx_loopback_result,
9665 : : on_off, "on#off");
9666 : :
9667 : : static void
9668 : 0 : cmd_set_tx_loopback_parsed(
9669 : : void *parsed_result,
9670 : : __rte_unused struct cmdline *cl,
9671 : : __rte_unused void *data)
9672 : : {
9673 : : struct cmd_tx_loopback_result *res = parsed_result;
9674 : : int ret = -ENOTSUP;
9675 : :
9676 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9677 : :
9678 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9679 : : return;
9680 : :
9681 : : #ifdef RTE_NET_IXGBE
9682 : : if (ret == -ENOTSUP)
9683 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9684 : : #endif
9685 : : #ifdef RTE_NET_I40E
9686 : 0 : if (ret == -ENOTSUP)
9687 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9688 : : #endif
9689 : : #ifdef RTE_NET_BNXT
9690 : 0 : if (ret == -ENOTSUP)
9691 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9692 : : #endif
9693 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9694 : 0 : if (ret == -ENOTSUP)
9695 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9696 : : #endif
9697 : :
9698 : 0 : switch (ret) {
9699 : : case 0:
9700 : : break;
9701 : 0 : case -EINVAL:
9702 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9703 : : break;
9704 : 0 : case -ENODEV:
9705 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9706 : : break;
9707 : 0 : case -ENOTSUP:
9708 : 0 : fprintf(stderr, "function not implemented\n");
9709 : : break;
9710 : 0 : default:
9711 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9712 : : }
9713 : : }
9714 : :
9715 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9716 : : .f = cmd_set_tx_loopback_parsed,
9717 : : .data = NULL,
9718 : : .help_str = "set tx loopback <port_id> on|off",
9719 : : .tokens = {
9720 : : (void *)&cmd_tx_loopback_set,
9721 : : (void *)&cmd_tx_loopback_tx,
9722 : : (void *)&cmd_tx_loopback_loopback,
9723 : : (void *)&cmd_tx_loopback_port_id,
9724 : : (void *)&cmd_tx_loopback_on_off,
9725 : : NULL,
9726 : : },
9727 : : };
9728 : :
9729 : : /* all queues drop enable configuration */
9730 : :
9731 : : /* Common result structure for all queues drop enable */
9732 : : struct cmd_all_queues_drop_en_result {
9733 : : cmdline_fixed_string_t set;
9734 : : cmdline_fixed_string_t all;
9735 : : cmdline_fixed_string_t queues;
9736 : : cmdline_fixed_string_t drop;
9737 : : portid_t port_id;
9738 : : cmdline_fixed_string_t on_off;
9739 : : };
9740 : :
9741 : : /* Common CLI fields for tx loopback enable disable */
9742 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9743 : : TOKEN_STRING_INITIALIZER
9744 : : (struct cmd_all_queues_drop_en_result,
9745 : : set, "set");
9746 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9747 : : TOKEN_STRING_INITIALIZER
9748 : : (struct cmd_all_queues_drop_en_result,
9749 : : all, "all");
9750 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9751 : : TOKEN_STRING_INITIALIZER
9752 : : (struct cmd_all_queues_drop_en_result,
9753 : : queues, "queues");
9754 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9755 : : TOKEN_STRING_INITIALIZER
9756 : : (struct cmd_all_queues_drop_en_result,
9757 : : drop, "drop");
9758 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9759 : : TOKEN_NUM_INITIALIZER
9760 : : (struct cmd_all_queues_drop_en_result,
9761 : : port_id, RTE_UINT16);
9762 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9763 : : TOKEN_STRING_INITIALIZER
9764 : : (struct cmd_all_queues_drop_en_result,
9765 : : on_off, "on#off");
9766 : :
9767 : : static void
9768 : 0 : cmd_set_all_queues_drop_en_parsed(
9769 : : void *parsed_result,
9770 : : __rte_unused struct cmdline *cl,
9771 : : __rte_unused void *data)
9772 : : {
9773 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9774 : : int ret = -ENOTSUP;
9775 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9776 : :
9777 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9778 : : return;
9779 : :
9780 : : #ifdef RTE_NET_IXGBE
9781 : : if (ret == -ENOTSUP)
9782 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9783 : : #endif
9784 : : #ifdef RTE_NET_BNXT
9785 : 0 : if (ret == -ENOTSUP)
9786 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9787 : : #endif
9788 : 0 : switch (ret) {
9789 : : case 0:
9790 : : break;
9791 : 0 : case -EINVAL:
9792 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9793 : : break;
9794 : 0 : case -ENODEV:
9795 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9796 : : break;
9797 : 0 : case -ENOTSUP:
9798 : 0 : fprintf(stderr, "function not implemented\n");
9799 : : break;
9800 : 0 : default:
9801 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9802 : : }
9803 : : }
9804 : :
9805 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9806 : : .f = cmd_set_all_queues_drop_en_parsed,
9807 : : .data = NULL,
9808 : : .help_str = "set all queues drop <port_id> on|off",
9809 : : .tokens = {
9810 : : (void *)&cmd_all_queues_drop_en_set,
9811 : : (void *)&cmd_all_queues_drop_en_all,
9812 : : (void *)&cmd_all_queues_drop_en_queues,
9813 : : (void *)&cmd_all_queues_drop_en_drop,
9814 : : (void *)&cmd_all_queues_drop_en_port_id,
9815 : : (void *)&cmd_all_queues_drop_en_on_off,
9816 : : NULL,
9817 : : },
9818 : : };
9819 : :
9820 : : /* vf mac address configuration */
9821 : :
9822 : : /* Common result structure for vf mac address */
9823 : : struct cmd_set_vf_mac_addr_result {
9824 : : cmdline_fixed_string_t set;
9825 : : cmdline_fixed_string_t vf;
9826 : : cmdline_fixed_string_t mac;
9827 : : cmdline_fixed_string_t addr;
9828 : : portid_t port_id;
9829 : : uint16_t vf_id;
9830 : : struct rte_ether_addr mac_addr;
9831 : :
9832 : : };
9833 : :
9834 : : /* Common CLI fields for vf split drop enable disable */
9835 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9836 : : TOKEN_STRING_INITIALIZER
9837 : : (struct cmd_set_vf_mac_addr_result,
9838 : : set, "set");
9839 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
9840 : : TOKEN_STRING_INITIALIZER
9841 : : (struct cmd_set_vf_mac_addr_result,
9842 : : vf, "vf");
9843 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
9844 : : TOKEN_STRING_INITIALIZER
9845 : : (struct cmd_set_vf_mac_addr_result,
9846 : : mac, "mac");
9847 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
9848 : : TOKEN_STRING_INITIALIZER
9849 : : (struct cmd_set_vf_mac_addr_result,
9850 : : addr, "addr");
9851 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
9852 : : TOKEN_NUM_INITIALIZER
9853 : : (struct cmd_set_vf_mac_addr_result,
9854 : : port_id, RTE_UINT16);
9855 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
9856 : : TOKEN_NUM_INITIALIZER
9857 : : (struct cmd_set_vf_mac_addr_result,
9858 : : vf_id, RTE_UINT16);
9859 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
9860 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
9861 : : mac_addr);
9862 : :
9863 : : static void
9864 : 0 : cmd_set_vf_mac_addr_parsed(
9865 : : void *parsed_result,
9866 : : __rte_unused struct cmdline *cl,
9867 : : __rte_unused void *data)
9868 : : {
9869 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
9870 : : int ret = -ENOTSUP;
9871 : :
9872 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9873 : : return;
9874 : :
9875 : : #ifdef RTE_NET_IXGBE
9876 : : if (ret == -ENOTSUP)
9877 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
9878 : : &res->mac_addr);
9879 : : #endif
9880 : : #ifdef RTE_NET_I40E
9881 : 0 : if (ret == -ENOTSUP)
9882 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
9883 : : &res->mac_addr);
9884 : : #endif
9885 : : #ifdef RTE_NET_BNXT
9886 : 0 : if (ret == -ENOTSUP)
9887 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
9888 : : &res->mac_addr);
9889 : : #endif
9890 : :
9891 : 0 : switch (ret) {
9892 : : case 0:
9893 : : break;
9894 : 0 : case -EINVAL:
9895 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
9896 : : break;
9897 : 0 : case -ENODEV:
9898 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9899 : : break;
9900 : 0 : case -ENOTSUP:
9901 : 0 : fprintf(stderr, "function not implemented\n");
9902 : : break;
9903 : 0 : default:
9904 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9905 : : }
9906 : : }
9907 : :
9908 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
9909 : : .f = cmd_set_vf_mac_addr_parsed,
9910 : : .data = NULL,
9911 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
9912 : : .tokens = {
9913 : : (void *)&cmd_set_vf_mac_addr_set,
9914 : : (void *)&cmd_set_vf_mac_addr_vf,
9915 : : (void *)&cmd_set_vf_mac_addr_mac,
9916 : : (void *)&cmd_set_vf_mac_addr_addr,
9917 : : (void *)&cmd_set_vf_mac_addr_port_id,
9918 : : (void *)&cmd_set_vf_mac_addr_vf_id,
9919 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
9920 : : NULL,
9921 : : },
9922 : : };
9923 : :
9924 : : /** Set VXLAN encapsulation details */
9925 : : struct cmd_set_vxlan_result {
9926 : : cmdline_fixed_string_t set;
9927 : : cmdline_fixed_string_t vxlan;
9928 : : cmdline_fixed_string_t pos_token;
9929 : : cmdline_fixed_string_t ip_version;
9930 : : uint32_t vlan_present:1;
9931 : : uint32_t vni;
9932 : : uint16_t udp_src;
9933 : : uint16_t udp_dst;
9934 : : cmdline_ipaddr_t ip_src;
9935 : : cmdline_ipaddr_t ip_dst;
9936 : : uint16_t tci;
9937 : : uint8_t tos;
9938 : : uint8_t ttl;
9939 : : struct rte_ether_addr eth_src;
9940 : : struct rte_ether_addr eth_dst;
9941 : : };
9942 : :
9943 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
9944 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
9945 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
9946 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
9947 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
9948 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9949 : : "vxlan-tos-ttl");
9950 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
9951 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9952 : : "vxlan-with-vlan");
9953 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
9954 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9955 : : "ip-version");
9956 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
9957 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
9958 : : "ipv4#ipv6");
9959 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
9960 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9961 : : "vni");
9962 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
9963 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
9964 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
9965 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9966 : : "udp-src");
9967 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
9968 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
9969 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
9970 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9971 : : "udp-dst");
9972 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
9973 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
9974 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
9975 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9976 : : "ip-tos");
9977 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
9978 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
9979 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
9980 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9981 : : "ip-ttl");
9982 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
9983 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
9984 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
9985 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9986 : : "ip-src");
9987 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
9988 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
9989 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
9990 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9991 : : "ip-dst");
9992 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
9993 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
9994 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
9995 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9996 : : "vlan-tci");
9997 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
9998 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
9999 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10000 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10001 : : "eth-src");
10002 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10003 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10004 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10005 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10006 : : "eth-dst");
10007 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10008 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10009 : :
10010 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10011 : : __rte_unused struct cmdline *cl,
10012 : : __rte_unused void *data)
10013 : : {
10014 : : struct cmd_set_vxlan_result *res = parsed_result;
10015 : : union {
10016 : : uint32_t vxlan_id;
10017 : : uint8_t vni[4];
10018 : 0 : } id = {
10019 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10020 : : };
10021 : :
10022 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10023 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10024 : 0 : vxlan_encap_conf.select_vlan = 0;
10025 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10026 : 0 : vxlan_encap_conf.select_vlan = 1;
10027 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10028 : 0 : vxlan_encap_conf.select_vlan = 0;
10029 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10030 : : }
10031 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10032 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10033 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10034 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10035 : : else
10036 : 0 : return;
10037 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10038 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10039 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10040 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10041 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10042 : 0 : if (vxlan_encap_conf.select_ipv4) {
10043 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10044 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10045 : : } else {
10046 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10047 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10048 : : }
10049 : 0 : if (vxlan_encap_conf.select_vlan)
10050 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10051 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10052 : : RTE_ETHER_ADDR_LEN);
10053 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10054 : : RTE_ETHER_ADDR_LEN);
10055 : : }
10056 : :
10057 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10058 : : .f = cmd_set_vxlan_parsed,
10059 : : .data = NULL,
10060 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10061 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10062 : : " eth-src <eth-src> eth-dst <eth-dst>",
10063 : : .tokens = {
10064 : : (void *)&cmd_set_vxlan_set,
10065 : : (void *)&cmd_set_vxlan_vxlan,
10066 : : (void *)&cmd_set_vxlan_ip_version,
10067 : : (void *)&cmd_set_vxlan_ip_version_value,
10068 : : (void *)&cmd_set_vxlan_vni,
10069 : : (void *)&cmd_set_vxlan_vni_value,
10070 : : (void *)&cmd_set_vxlan_udp_src,
10071 : : (void *)&cmd_set_vxlan_udp_src_value,
10072 : : (void *)&cmd_set_vxlan_udp_dst,
10073 : : (void *)&cmd_set_vxlan_udp_dst_value,
10074 : : (void *)&cmd_set_vxlan_ip_src,
10075 : : (void *)&cmd_set_vxlan_ip_src_value,
10076 : : (void *)&cmd_set_vxlan_ip_dst,
10077 : : (void *)&cmd_set_vxlan_ip_dst_value,
10078 : : (void *)&cmd_set_vxlan_eth_src,
10079 : : (void *)&cmd_set_vxlan_eth_src_value,
10080 : : (void *)&cmd_set_vxlan_eth_dst,
10081 : : (void *)&cmd_set_vxlan_eth_dst_value,
10082 : : NULL,
10083 : : },
10084 : : };
10085 : :
10086 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10087 : : .f = cmd_set_vxlan_parsed,
10088 : : .data = NULL,
10089 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10090 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10091 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10092 : : " eth-dst <eth-dst>",
10093 : : .tokens = {
10094 : : (void *)&cmd_set_vxlan_set,
10095 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10096 : : (void *)&cmd_set_vxlan_ip_version,
10097 : : (void *)&cmd_set_vxlan_ip_version_value,
10098 : : (void *)&cmd_set_vxlan_vni,
10099 : : (void *)&cmd_set_vxlan_vni_value,
10100 : : (void *)&cmd_set_vxlan_udp_src,
10101 : : (void *)&cmd_set_vxlan_udp_src_value,
10102 : : (void *)&cmd_set_vxlan_udp_dst,
10103 : : (void *)&cmd_set_vxlan_udp_dst_value,
10104 : : (void *)&cmd_set_vxlan_ip_tos,
10105 : : (void *)&cmd_set_vxlan_ip_tos_value,
10106 : : (void *)&cmd_set_vxlan_ip_ttl,
10107 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10108 : : (void *)&cmd_set_vxlan_ip_src,
10109 : : (void *)&cmd_set_vxlan_ip_src_value,
10110 : : (void *)&cmd_set_vxlan_ip_dst,
10111 : : (void *)&cmd_set_vxlan_ip_dst_value,
10112 : : (void *)&cmd_set_vxlan_eth_src,
10113 : : (void *)&cmd_set_vxlan_eth_src_value,
10114 : : (void *)&cmd_set_vxlan_eth_dst,
10115 : : (void *)&cmd_set_vxlan_eth_dst_value,
10116 : : NULL,
10117 : : },
10118 : : };
10119 : :
10120 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10121 : : .f = cmd_set_vxlan_parsed,
10122 : : .data = NULL,
10123 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10124 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10125 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10126 : : " <eth-dst>",
10127 : : .tokens = {
10128 : : (void *)&cmd_set_vxlan_set,
10129 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10130 : : (void *)&cmd_set_vxlan_ip_version,
10131 : : (void *)&cmd_set_vxlan_ip_version_value,
10132 : : (void *)&cmd_set_vxlan_vni,
10133 : : (void *)&cmd_set_vxlan_vni_value,
10134 : : (void *)&cmd_set_vxlan_udp_src,
10135 : : (void *)&cmd_set_vxlan_udp_src_value,
10136 : : (void *)&cmd_set_vxlan_udp_dst,
10137 : : (void *)&cmd_set_vxlan_udp_dst_value,
10138 : : (void *)&cmd_set_vxlan_ip_src,
10139 : : (void *)&cmd_set_vxlan_ip_src_value,
10140 : : (void *)&cmd_set_vxlan_ip_dst,
10141 : : (void *)&cmd_set_vxlan_ip_dst_value,
10142 : : (void *)&cmd_set_vxlan_vlan,
10143 : : (void *)&cmd_set_vxlan_vlan_value,
10144 : : (void *)&cmd_set_vxlan_eth_src,
10145 : : (void *)&cmd_set_vxlan_eth_src_value,
10146 : : (void *)&cmd_set_vxlan_eth_dst,
10147 : : (void *)&cmd_set_vxlan_eth_dst_value,
10148 : : NULL,
10149 : : },
10150 : : };
10151 : :
10152 : : /** Set NVGRE encapsulation details */
10153 : : struct cmd_set_nvgre_result {
10154 : : cmdline_fixed_string_t set;
10155 : : cmdline_fixed_string_t nvgre;
10156 : : cmdline_fixed_string_t pos_token;
10157 : : cmdline_fixed_string_t ip_version;
10158 : : uint32_t tni;
10159 : : cmdline_ipaddr_t ip_src;
10160 : : cmdline_ipaddr_t ip_dst;
10161 : : uint16_t tci;
10162 : : struct rte_ether_addr eth_src;
10163 : : struct rte_ether_addr eth_dst;
10164 : : };
10165 : :
10166 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10167 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10168 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10170 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10172 : : "nvgre-with-vlan");
10173 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10174 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10175 : : "ip-version");
10176 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10177 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10178 : : "ipv4#ipv6");
10179 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10180 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10181 : : "tni");
10182 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10183 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10184 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10185 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10186 : : "ip-src");
10187 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10188 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10189 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10191 : : "ip-dst");
10192 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10193 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10194 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10195 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10196 : : "vlan-tci");
10197 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10198 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10199 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10200 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10201 : : "eth-src");
10202 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10203 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10204 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10205 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10206 : : "eth-dst");
10207 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10208 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10209 : :
10210 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10211 : : __rte_unused struct cmdline *cl,
10212 : : __rte_unused void *data)
10213 : : {
10214 : : struct cmd_set_nvgre_result *res = parsed_result;
10215 : : union {
10216 : : uint32_t nvgre_tni;
10217 : : uint8_t tni[4];
10218 : 0 : } id = {
10219 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10220 : : };
10221 : :
10222 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10223 : 0 : nvgre_encap_conf.select_vlan = 0;
10224 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10225 : 0 : nvgre_encap_conf.select_vlan = 1;
10226 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10227 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10228 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10229 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10230 : : else
10231 : 0 : return;
10232 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10233 : 0 : if (nvgre_encap_conf.select_ipv4) {
10234 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10235 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10236 : : } else {
10237 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10238 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10239 : : }
10240 : 0 : if (nvgre_encap_conf.select_vlan)
10241 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10242 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10243 : : RTE_ETHER_ADDR_LEN);
10244 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10245 : : RTE_ETHER_ADDR_LEN);
10246 : : }
10247 : :
10248 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10249 : : .f = cmd_set_nvgre_parsed,
10250 : : .data = NULL,
10251 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10252 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10253 : : " eth-dst <eth-dst>",
10254 : : .tokens = {
10255 : : (void *)&cmd_set_nvgre_set,
10256 : : (void *)&cmd_set_nvgre_nvgre,
10257 : : (void *)&cmd_set_nvgre_ip_version,
10258 : : (void *)&cmd_set_nvgre_ip_version_value,
10259 : : (void *)&cmd_set_nvgre_tni,
10260 : : (void *)&cmd_set_nvgre_tni_value,
10261 : : (void *)&cmd_set_nvgre_ip_src,
10262 : : (void *)&cmd_set_nvgre_ip_src_value,
10263 : : (void *)&cmd_set_nvgre_ip_dst,
10264 : : (void *)&cmd_set_nvgre_ip_dst_value,
10265 : : (void *)&cmd_set_nvgre_eth_src,
10266 : : (void *)&cmd_set_nvgre_eth_src_value,
10267 : : (void *)&cmd_set_nvgre_eth_dst,
10268 : : (void *)&cmd_set_nvgre_eth_dst_value,
10269 : : NULL,
10270 : : },
10271 : : };
10272 : :
10273 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10274 : : .f = cmd_set_nvgre_parsed,
10275 : : .data = NULL,
10276 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10277 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10278 : : " eth-src <eth-src> eth-dst <eth-dst>",
10279 : : .tokens = {
10280 : : (void *)&cmd_set_nvgre_set,
10281 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10282 : : (void *)&cmd_set_nvgre_ip_version,
10283 : : (void *)&cmd_set_nvgre_ip_version_value,
10284 : : (void *)&cmd_set_nvgre_tni,
10285 : : (void *)&cmd_set_nvgre_tni_value,
10286 : : (void *)&cmd_set_nvgre_ip_src,
10287 : : (void *)&cmd_set_nvgre_ip_src_value,
10288 : : (void *)&cmd_set_nvgre_ip_dst,
10289 : : (void *)&cmd_set_nvgre_ip_dst_value,
10290 : : (void *)&cmd_set_nvgre_vlan,
10291 : : (void *)&cmd_set_nvgre_vlan_value,
10292 : : (void *)&cmd_set_nvgre_eth_src,
10293 : : (void *)&cmd_set_nvgre_eth_src_value,
10294 : : (void *)&cmd_set_nvgre_eth_dst,
10295 : : (void *)&cmd_set_nvgre_eth_dst_value,
10296 : : NULL,
10297 : : },
10298 : : };
10299 : :
10300 : : /** Set L2 encapsulation details */
10301 : : struct cmd_set_l2_encap_result {
10302 : : cmdline_fixed_string_t set;
10303 : : cmdline_fixed_string_t l2_encap;
10304 : : cmdline_fixed_string_t pos_token;
10305 : : cmdline_fixed_string_t ip_version;
10306 : : uint32_t vlan_present:1;
10307 : : uint16_t tci;
10308 : : struct rte_ether_addr eth_src;
10309 : : struct rte_ether_addr eth_dst;
10310 : : };
10311 : :
10312 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10313 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10314 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10315 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10316 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10317 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10318 : : "l2_encap-with-vlan");
10319 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10320 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10321 : : "ip-version");
10322 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10324 : : "ipv4#ipv6");
10325 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10327 : : "vlan-tci");
10328 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10329 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10330 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10331 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10332 : : "eth-src");
10333 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10334 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10335 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10336 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10337 : : "eth-dst");
10338 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10339 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10340 : :
10341 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10342 : : __rte_unused struct cmdline *cl,
10343 : : __rte_unused void *data)
10344 : : {
10345 : : struct cmd_set_l2_encap_result *res = parsed_result;
10346 : :
10347 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10348 : 0 : l2_encap_conf.select_vlan = 0;
10349 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10350 : 0 : l2_encap_conf.select_vlan = 1;
10351 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10352 : 0 : l2_encap_conf.select_ipv4 = 1;
10353 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10354 : 0 : l2_encap_conf.select_ipv4 = 0;
10355 : : else
10356 : : return;
10357 : 0 : if (l2_encap_conf.select_vlan)
10358 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10359 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10360 : : RTE_ETHER_ADDR_LEN);
10361 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10362 : : RTE_ETHER_ADDR_LEN);
10363 : : }
10364 : :
10365 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10366 : : .f = cmd_set_l2_encap_parsed,
10367 : : .data = NULL,
10368 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10369 : : " eth-src <eth-src> eth-dst <eth-dst>",
10370 : : .tokens = {
10371 : : (void *)&cmd_set_l2_encap_set,
10372 : : (void *)&cmd_set_l2_encap_l2_encap,
10373 : : (void *)&cmd_set_l2_encap_ip_version,
10374 : : (void *)&cmd_set_l2_encap_ip_version_value,
10375 : : (void *)&cmd_set_l2_encap_eth_src,
10376 : : (void *)&cmd_set_l2_encap_eth_src_value,
10377 : : (void *)&cmd_set_l2_encap_eth_dst,
10378 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10379 : : NULL,
10380 : : },
10381 : : };
10382 : :
10383 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10384 : : .f = cmd_set_l2_encap_parsed,
10385 : : .data = NULL,
10386 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10387 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10388 : : .tokens = {
10389 : : (void *)&cmd_set_l2_encap_set,
10390 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10391 : : (void *)&cmd_set_l2_encap_ip_version,
10392 : : (void *)&cmd_set_l2_encap_ip_version_value,
10393 : : (void *)&cmd_set_l2_encap_vlan,
10394 : : (void *)&cmd_set_l2_encap_vlan_value,
10395 : : (void *)&cmd_set_l2_encap_eth_src,
10396 : : (void *)&cmd_set_l2_encap_eth_src_value,
10397 : : (void *)&cmd_set_l2_encap_eth_dst,
10398 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10399 : : NULL,
10400 : : },
10401 : : };
10402 : :
10403 : : /** Set L2 decapsulation details */
10404 : : struct cmd_set_l2_decap_result {
10405 : : cmdline_fixed_string_t set;
10406 : : cmdline_fixed_string_t l2_decap;
10407 : : cmdline_fixed_string_t pos_token;
10408 : : uint32_t vlan_present:1;
10409 : : };
10410 : :
10411 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10412 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10413 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10414 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10415 : : "l2_decap");
10416 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10417 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10418 : : "l2_decap-with-vlan");
10419 : :
10420 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10421 : : __rte_unused struct cmdline *cl,
10422 : : __rte_unused void *data)
10423 : : {
10424 : : struct cmd_set_l2_decap_result *res = parsed_result;
10425 : :
10426 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10427 : 0 : l2_decap_conf.select_vlan = 0;
10428 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10429 : 0 : l2_decap_conf.select_vlan = 1;
10430 : 0 : }
10431 : :
10432 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10433 : : .f = cmd_set_l2_decap_parsed,
10434 : : .data = NULL,
10435 : : .help_str = "set l2_decap",
10436 : : .tokens = {
10437 : : (void *)&cmd_set_l2_decap_set,
10438 : : (void *)&cmd_set_l2_decap_l2_decap,
10439 : : NULL,
10440 : : },
10441 : : };
10442 : :
10443 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10444 : : .f = cmd_set_l2_decap_parsed,
10445 : : .data = NULL,
10446 : : .help_str = "set l2_decap-with-vlan",
10447 : : .tokens = {
10448 : : (void *)&cmd_set_l2_decap_set,
10449 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10450 : : NULL,
10451 : : },
10452 : : };
10453 : :
10454 : : /** Set MPLSoGRE encapsulation details */
10455 : : struct cmd_set_mplsogre_encap_result {
10456 : : cmdline_fixed_string_t set;
10457 : : cmdline_fixed_string_t mplsogre;
10458 : : cmdline_fixed_string_t pos_token;
10459 : : cmdline_fixed_string_t ip_version;
10460 : : uint32_t vlan_present:1;
10461 : : uint32_t label;
10462 : : cmdline_ipaddr_t ip_src;
10463 : : cmdline_ipaddr_t ip_dst;
10464 : : uint16_t tci;
10465 : : struct rte_ether_addr eth_src;
10466 : : struct rte_ether_addr eth_dst;
10467 : : };
10468 : :
10469 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10470 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10471 : : "set");
10472 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10473 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10474 : : "mplsogre_encap");
10475 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10476 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10477 : : mplsogre, "mplsogre_encap-with-vlan");
10478 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10479 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10480 : : pos_token, "ip-version");
10481 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10482 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10483 : : ip_version, "ipv4#ipv6");
10484 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10486 : : pos_token, "label");
10487 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10488 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10489 : : RTE_UINT32);
10490 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10491 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10492 : : pos_token, "ip-src");
10493 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10494 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10495 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10497 : : pos_token, "ip-dst");
10498 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10499 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10500 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10502 : : pos_token, "vlan-tci");
10503 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10504 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10505 : : RTE_UINT16);
10506 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10508 : : pos_token, "eth-src");
10509 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10510 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10511 : : eth_src);
10512 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10514 : : pos_token, "eth-dst");
10515 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10516 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10517 : : eth_dst);
10518 : :
10519 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10520 : : __rte_unused struct cmdline *cl,
10521 : : __rte_unused void *data)
10522 : : {
10523 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10524 : : union {
10525 : : uint32_t mplsogre_label;
10526 : : uint8_t label[4];
10527 : 0 : } id = {
10528 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10529 : : };
10530 : :
10531 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10532 : 0 : mplsogre_encap_conf.select_vlan = 0;
10533 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10534 : 0 : mplsogre_encap_conf.select_vlan = 1;
10535 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10536 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10537 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10538 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10539 : : else
10540 : 0 : return;
10541 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10542 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10543 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10544 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10545 : : } else {
10546 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10547 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10548 : : }
10549 : 0 : if (mplsogre_encap_conf.select_vlan)
10550 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10551 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10552 : : RTE_ETHER_ADDR_LEN);
10553 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10554 : : RTE_ETHER_ADDR_LEN);
10555 : : }
10556 : :
10557 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10558 : : .f = cmd_set_mplsogre_encap_parsed,
10559 : : .data = NULL,
10560 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10561 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10562 : : " eth-dst <eth-dst>",
10563 : : .tokens = {
10564 : : (void *)&cmd_set_mplsogre_encap_set,
10565 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10566 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10567 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10568 : : (void *)&cmd_set_mplsogre_encap_label,
10569 : : (void *)&cmd_set_mplsogre_encap_label_value,
10570 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10571 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10572 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10573 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10574 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10575 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10576 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10577 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10578 : : NULL,
10579 : : },
10580 : : };
10581 : :
10582 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10583 : : .f = cmd_set_mplsogre_encap_parsed,
10584 : : .data = NULL,
10585 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10586 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10587 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10588 : : .tokens = {
10589 : : (void *)&cmd_set_mplsogre_encap_set,
10590 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10591 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10592 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10593 : : (void *)&cmd_set_mplsogre_encap_label,
10594 : : (void *)&cmd_set_mplsogre_encap_label_value,
10595 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10596 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10597 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10598 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10599 : : (void *)&cmd_set_mplsogre_encap_vlan,
10600 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10601 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10602 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10603 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10604 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10605 : : NULL,
10606 : : },
10607 : : };
10608 : :
10609 : : /** Set MPLSoGRE decapsulation details */
10610 : : struct cmd_set_mplsogre_decap_result {
10611 : : cmdline_fixed_string_t set;
10612 : : cmdline_fixed_string_t mplsogre;
10613 : : cmdline_fixed_string_t pos_token;
10614 : : cmdline_fixed_string_t ip_version;
10615 : : uint32_t vlan_present:1;
10616 : : };
10617 : :
10618 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10619 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10620 : : "set");
10621 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10622 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10623 : : "mplsogre_decap");
10624 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10625 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10626 : : mplsogre, "mplsogre_decap-with-vlan");
10627 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10628 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10629 : : pos_token, "ip-version");
10630 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10631 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10632 : : ip_version, "ipv4#ipv6");
10633 : :
10634 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10635 : : __rte_unused struct cmdline *cl,
10636 : : __rte_unused void *data)
10637 : : {
10638 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10639 : :
10640 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10641 : 0 : mplsogre_decap_conf.select_vlan = 0;
10642 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10643 : 0 : mplsogre_decap_conf.select_vlan = 1;
10644 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10645 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10646 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10647 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10648 : 0 : }
10649 : :
10650 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10651 : : .f = cmd_set_mplsogre_decap_parsed,
10652 : : .data = NULL,
10653 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10654 : : .tokens = {
10655 : : (void *)&cmd_set_mplsogre_decap_set,
10656 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10657 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10658 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10659 : : NULL,
10660 : : },
10661 : : };
10662 : :
10663 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10664 : : .f = cmd_set_mplsogre_decap_parsed,
10665 : : .data = NULL,
10666 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10667 : : .tokens = {
10668 : : (void *)&cmd_set_mplsogre_decap_set,
10669 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10670 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10671 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10672 : : NULL,
10673 : : },
10674 : : };
10675 : :
10676 : : /** Set MPLSoUDP encapsulation details */
10677 : : struct cmd_set_mplsoudp_encap_result {
10678 : : cmdline_fixed_string_t set;
10679 : : cmdline_fixed_string_t mplsoudp;
10680 : : cmdline_fixed_string_t pos_token;
10681 : : cmdline_fixed_string_t ip_version;
10682 : : uint32_t vlan_present:1;
10683 : : uint32_t label;
10684 : : uint16_t udp_src;
10685 : : uint16_t udp_dst;
10686 : : cmdline_ipaddr_t ip_src;
10687 : : cmdline_ipaddr_t ip_dst;
10688 : : uint16_t tci;
10689 : : struct rte_ether_addr eth_src;
10690 : : struct rte_ether_addr eth_dst;
10691 : : };
10692 : :
10693 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10694 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10695 : : "set");
10696 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10697 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10698 : : "mplsoudp_encap");
10699 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10700 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10701 : : mplsoudp, "mplsoudp_encap-with-vlan");
10702 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10703 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10704 : : pos_token, "ip-version");
10705 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10706 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10707 : : ip_version, "ipv4#ipv6");
10708 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10709 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10710 : : pos_token, "label");
10711 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10712 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10713 : : RTE_UINT32);
10714 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10715 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10716 : : pos_token, "udp-src");
10717 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10718 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10719 : : RTE_UINT16);
10720 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10721 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10722 : : pos_token, "udp-dst");
10723 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10724 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10725 : : RTE_UINT16);
10726 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10727 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10728 : : pos_token, "ip-src");
10729 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10730 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10731 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10732 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10733 : : pos_token, "ip-dst");
10734 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10735 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10736 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10738 : : pos_token, "vlan-tci");
10739 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10740 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10741 : : RTE_UINT16);
10742 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10743 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10744 : : pos_token, "eth-src");
10745 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10746 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10747 : : eth_src);
10748 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10749 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10750 : : pos_token, "eth-dst");
10751 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10752 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10753 : : eth_dst);
10754 : :
10755 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10756 : : __rte_unused struct cmdline *cl,
10757 : : __rte_unused void *data)
10758 : : {
10759 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10760 : : union {
10761 : : uint32_t mplsoudp_label;
10762 : : uint8_t label[4];
10763 : 0 : } id = {
10764 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10765 : : };
10766 : :
10767 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10768 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10769 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10770 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10771 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10772 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10773 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10774 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10775 : : else
10776 : 0 : return;
10777 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10778 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10779 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10780 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10781 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10782 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10783 : : } else {
10784 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10785 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10786 : : }
10787 : 0 : if (mplsoudp_encap_conf.select_vlan)
10788 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10789 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10790 : : RTE_ETHER_ADDR_LEN);
10791 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10792 : : RTE_ETHER_ADDR_LEN);
10793 : : }
10794 : :
10795 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10796 : : .f = cmd_set_mplsoudp_encap_parsed,
10797 : : .data = NULL,
10798 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10799 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10800 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10801 : : .tokens = {
10802 : : (void *)&cmd_set_mplsoudp_encap_set,
10803 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10804 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10805 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10806 : : (void *)&cmd_set_mplsoudp_encap_label,
10807 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10808 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10809 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10810 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10811 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10812 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10813 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10814 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10815 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10816 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10817 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10818 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10819 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10820 : : NULL,
10821 : : },
10822 : : };
10823 : :
10824 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10825 : : .f = cmd_set_mplsoudp_encap_parsed,
10826 : : .data = NULL,
10827 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10828 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10829 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10830 : : " eth-src <eth-src> eth-dst <eth-dst>",
10831 : : .tokens = {
10832 : : (void *)&cmd_set_mplsoudp_encap_set,
10833 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10834 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10835 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10836 : : (void *)&cmd_set_mplsoudp_encap_label,
10837 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10838 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10839 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10840 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10841 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10842 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10843 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10844 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10845 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10846 : : (void *)&cmd_set_mplsoudp_encap_vlan,
10847 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
10848 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10849 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10850 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10851 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10852 : : NULL,
10853 : : },
10854 : : };
10855 : :
10856 : : /** Set MPLSoUDP decapsulation details */
10857 : : struct cmd_set_mplsoudp_decap_result {
10858 : : cmdline_fixed_string_t set;
10859 : : cmdline_fixed_string_t mplsoudp;
10860 : : cmdline_fixed_string_t pos_token;
10861 : : cmdline_fixed_string_t ip_version;
10862 : : uint32_t vlan_present:1;
10863 : : };
10864 : :
10865 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
10866 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
10867 : : "set");
10868 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
10869 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
10870 : : "mplsoudp_decap");
10871 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
10872 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10873 : : mplsoudp, "mplsoudp_decap-with-vlan");
10874 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
10875 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10876 : : pos_token, "ip-version");
10877 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
10878 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10879 : : ip_version, "ipv4#ipv6");
10880 : :
10881 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
10882 : : __rte_unused struct cmdline *cl,
10883 : : __rte_unused void *data)
10884 : : {
10885 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
10886 : :
10887 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
10888 : 0 : mplsoudp_decap_conf.select_vlan = 0;
10889 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
10890 : 0 : mplsoudp_decap_conf.select_vlan = 1;
10891 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10892 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
10893 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10894 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
10895 : 0 : }
10896 : :
10897 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
10898 : : .f = cmd_set_mplsoudp_decap_parsed,
10899 : : .data = NULL,
10900 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
10901 : : .tokens = {
10902 : : (void *)&cmd_set_mplsoudp_decap_set,
10903 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
10904 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10905 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10906 : : NULL,
10907 : : },
10908 : : };
10909 : :
10910 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
10911 : : .f = cmd_set_mplsoudp_decap_parsed,
10912 : : .data = NULL,
10913 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
10914 : : .tokens = {
10915 : : (void *)&cmd_set_mplsoudp_decap_set,
10916 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
10917 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10918 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10919 : : NULL,
10920 : : },
10921 : : };
10922 : :
10923 : : /** Set connection tracking object common details */
10924 : : struct cmd_set_conntrack_common_result {
10925 : : cmdline_fixed_string_t set;
10926 : : cmdline_fixed_string_t conntrack;
10927 : : cmdline_fixed_string_t common;
10928 : : cmdline_fixed_string_t peer;
10929 : : cmdline_fixed_string_t is_orig;
10930 : : cmdline_fixed_string_t enable;
10931 : : cmdline_fixed_string_t live;
10932 : : cmdline_fixed_string_t sack;
10933 : : cmdline_fixed_string_t cack;
10934 : : cmdline_fixed_string_t last_dir;
10935 : : cmdline_fixed_string_t liberal;
10936 : : cmdline_fixed_string_t state;
10937 : : cmdline_fixed_string_t max_ack_win;
10938 : : cmdline_fixed_string_t retrans;
10939 : : cmdline_fixed_string_t last_win;
10940 : : cmdline_fixed_string_t last_seq;
10941 : : cmdline_fixed_string_t last_ack;
10942 : : cmdline_fixed_string_t last_end;
10943 : : cmdline_fixed_string_t last_index;
10944 : : uint8_t stat;
10945 : : uint8_t factor;
10946 : : uint16_t peer_port;
10947 : : uint32_t is_original;
10948 : : uint32_t en;
10949 : : uint32_t is_live;
10950 : : uint32_t s_ack;
10951 : : uint32_t c_ack;
10952 : : uint32_t ld;
10953 : : uint32_t lb;
10954 : : uint8_t re_num;
10955 : : uint8_t li;
10956 : : uint16_t lw;
10957 : : uint32_t ls;
10958 : : uint32_t la;
10959 : : uint32_t le;
10960 : : };
10961 : :
10962 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
10963 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10964 : : set, "set");
10965 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
10966 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10967 : : conntrack, "conntrack");
10968 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
10969 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10970 : : common, "com");
10971 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
10972 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10973 : : peer, "peer");
10974 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
10975 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10976 : : peer_port, RTE_UINT16);
10977 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
10978 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10979 : : is_orig, "is_orig");
10980 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
10981 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10982 : : is_original, RTE_UINT32);
10983 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
10984 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10985 : : enable, "enable");
10986 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
10987 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10988 : : en, RTE_UINT32);
10989 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
10990 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10991 : : live, "live");
10992 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
10993 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10994 : : is_live, RTE_UINT32);
10995 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
10996 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10997 : : sack, "sack");
10998 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
10999 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11000 : : s_ack, RTE_UINT32);
11001 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11002 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11003 : : cack, "cack");
11004 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11005 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11006 : : c_ack, RTE_UINT32);
11007 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11008 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11009 : : last_dir, "last_dir");
11010 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11011 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11012 : : ld, RTE_UINT32);
11013 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11014 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11015 : : liberal, "liberal");
11016 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11017 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11018 : : lb, RTE_UINT32);
11019 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11020 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11021 : : state, "state");
11022 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11023 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11024 : : stat, RTE_UINT8);
11025 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11026 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11027 : : max_ack_win, "max_ack_win");
11028 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11029 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11030 : : factor, RTE_UINT8);
11031 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11032 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11033 : : retrans, "r_lim");
11034 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11035 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11036 : : re_num, RTE_UINT8);
11037 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11038 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11039 : : last_win, "last_win");
11040 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11041 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11042 : : lw, RTE_UINT16);
11043 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11044 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11045 : : last_seq, "last_seq");
11046 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11047 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11048 : : ls, RTE_UINT32);
11049 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11050 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11051 : : last_ack, "last_ack");
11052 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11053 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11054 : : la, RTE_UINT32);
11055 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11056 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11057 : : last_end, "last_end");
11058 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11059 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11060 : : le, RTE_UINT32);
11061 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11062 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11063 : : last_index, "last_index");
11064 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11065 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11066 : : li, RTE_UINT8);
11067 : :
11068 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11069 : : __rte_unused struct cmdline *cl,
11070 : : __rte_unused void *data)
11071 : : {
11072 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11073 : :
11074 : : /* No need to swap to big endian. */
11075 : 0 : conntrack_context.peer_port = res->peer_port;
11076 : 0 : conntrack_context.is_original_dir = res->is_original;
11077 : 0 : conntrack_context.enable = res->en;
11078 : 0 : conntrack_context.live_connection = res->is_live;
11079 : 0 : conntrack_context.selective_ack = res->s_ack;
11080 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11081 : 0 : conntrack_context.last_direction = res->ld;
11082 : 0 : conntrack_context.liberal_mode = res->lb;
11083 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11084 : 0 : conntrack_context.max_ack_window = res->factor;
11085 : 0 : conntrack_context.retransmission_limit = res->re_num;
11086 : 0 : conntrack_context.last_window = res->lw;
11087 : 0 : conntrack_context.last_index =
11088 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11089 : 0 : conntrack_context.last_seq = res->ls;
11090 : 0 : conntrack_context.last_ack = res->la;
11091 : 0 : conntrack_context.last_end = res->le;
11092 : 0 : }
11093 : :
11094 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11095 : : .f = cmd_set_conntrack_common_parsed,
11096 : : .data = NULL,
11097 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11098 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11099 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11100 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11101 : : " last_index <flag>",
11102 : : .tokens = {
11103 : : (void *)&cmd_set_conntrack_set,
11104 : : (void *)&cmd_set_conntrack_conntrack,
11105 : : (void *)&cmd_set_conntrack_common_com,
11106 : : (void *)&cmd_set_conntrack_common_peer,
11107 : : (void *)&cmd_set_conntrack_common_peer_value,
11108 : : (void *)&cmd_set_conntrack_common_is_orig,
11109 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11110 : : (void *)&cmd_set_conntrack_common_enable,
11111 : : (void *)&cmd_set_conntrack_common_enable_value,
11112 : : (void *)&cmd_set_conntrack_common_live,
11113 : : (void *)&cmd_set_conntrack_common_live_value,
11114 : : (void *)&cmd_set_conntrack_common_sack,
11115 : : (void *)&cmd_set_conntrack_common_sack_value,
11116 : : (void *)&cmd_set_conntrack_common_cack,
11117 : : (void *)&cmd_set_conntrack_common_cack_value,
11118 : : (void *)&cmd_set_conntrack_common_last_dir,
11119 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11120 : : (void *)&cmd_set_conntrack_common_liberal,
11121 : : (void *)&cmd_set_conntrack_common_liberal_value,
11122 : : (void *)&cmd_set_conntrack_common_state,
11123 : : (void *)&cmd_set_conntrack_common_state_value,
11124 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11125 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11126 : : (void *)&cmd_set_conntrack_common_retrans,
11127 : : (void *)&cmd_set_conntrack_common_retrans_value,
11128 : : (void *)&cmd_set_conntrack_common_last_win,
11129 : : (void *)&cmd_set_conntrack_common_last_win_value,
11130 : : (void *)&cmd_set_conntrack_common_last_seq,
11131 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11132 : : (void *)&cmd_set_conntrack_common_last_ack,
11133 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11134 : : (void *)&cmd_set_conntrack_common_last_end,
11135 : : (void *)&cmd_set_conntrack_common_last_end_value,
11136 : : (void *)&cmd_set_conntrack_common_last_index,
11137 : : (void *)&cmd_set_conntrack_common_last_index_value,
11138 : : NULL,
11139 : : },
11140 : : };
11141 : :
11142 : : /** Set connection tracking object both directions' details */
11143 : : struct cmd_set_conntrack_dir_result {
11144 : : cmdline_fixed_string_t set;
11145 : : cmdline_fixed_string_t conntrack;
11146 : : cmdline_fixed_string_t dir;
11147 : : cmdline_fixed_string_t scale;
11148 : : cmdline_fixed_string_t fin;
11149 : : cmdline_fixed_string_t ack_seen;
11150 : : cmdline_fixed_string_t unack;
11151 : : cmdline_fixed_string_t sent_end;
11152 : : cmdline_fixed_string_t reply_end;
11153 : : cmdline_fixed_string_t max_win;
11154 : : cmdline_fixed_string_t max_ack;
11155 : : uint32_t factor;
11156 : : uint32_t f;
11157 : : uint32_t as;
11158 : : uint32_t un;
11159 : : uint32_t se;
11160 : : uint32_t re;
11161 : : uint32_t mw;
11162 : : uint32_t ma;
11163 : : };
11164 : :
11165 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11166 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11167 : : dir, "orig#rply");
11168 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11170 : : scale, "scale");
11171 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11172 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11173 : : factor, RTE_UINT32);
11174 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11175 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11176 : : fin, "fin");
11177 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11178 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11179 : : f, RTE_UINT32);
11180 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11181 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11182 : : ack_seen, "acked");
11183 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11184 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11185 : : as, RTE_UINT32);
11186 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11188 : : unack, "unack_data");
11189 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11190 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11191 : : un, RTE_UINT32);
11192 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11193 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11194 : : sent_end, "sent_end");
11195 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11196 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11197 : : se, RTE_UINT32);
11198 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11199 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11200 : : reply_end, "reply_end");
11201 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11202 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11203 : : re, RTE_UINT32);
11204 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11205 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11206 : : max_win, "max_win");
11207 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11208 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11209 : : mw, RTE_UINT32);
11210 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11211 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11212 : : max_ack, "max_ack");
11213 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11214 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11215 : : ma, RTE_UINT32);
11216 : :
11217 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11218 : : __rte_unused struct cmdline *cl,
11219 : : __rte_unused void *data)
11220 : : {
11221 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11222 : : struct rte_flow_tcp_dir_param *dir = NULL;
11223 : :
11224 : 0 : if (strcmp(res->dir, "orig") == 0)
11225 : : dir = &conntrack_context.original_dir;
11226 : 0 : else if (strcmp(res->dir, "rply") == 0)
11227 : : dir = &conntrack_context.reply_dir;
11228 : : else
11229 : : return;
11230 : 0 : dir->scale = res->factor;
11231 : 0 : dir->close_initiated = res->f;
11232 : 0 : dir->last_ack_seen = res->as;
11233 : 0 : dir->data_unacked = res->un;
11234 : 0 : dir->sent_end = res->se;
11235 : 0 : dir->reply_end = res->re;
11236 : 0 : dir->max_ack = res->ma;
11237 : 0 : dir->max_win = res->mw;
11238 : : }
11239 : :
11240 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11241 : : .f = cmd_set_conntrack_dir_parsed,
11242 : : .data = NULL,
11243 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11244 : : " acked <seen> unack_data <unack> sent_end <sent>"
11245 : : " reply_end <reply> max_win <win> max_ack <ack>",
11246 : : .tokens = {
11247 : : (void *)&cmd_set_conntrack_set,
11248 : : (void *)&cmd_set_conntrack_conntrack,
11249 : : (void *)&cmd_set_conntrack_dir_dir,
11250 : : (void *)&cmd_set_conntrack_dir_scale,
11251 : : (void *)&cmd_set_conntrack_dir_scale_value,
11252 : : (void *)&cmd_set_conntrack_dir_fin,
11253 : : (void *)&cmd_set_conntrack_dir_fin_value,
11254 : : (void *)&cmd_set_conntrack_dir_ack,
11255 : : (void *)&cmd_set_conntrack_dir_ack_value,
11256 : : (void *)&cmd_set_conntrack_dir_unack_data,
11257 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11258 : : (void *)&cmd_set_conntrack_dir_sent_end,
11259 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11260 : : (void *)&cmd_set_conntrack_dir_reply_end,
11261 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11262 : : (void *)&cmd_set_conntrack_dir_max_win,
11263 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11264 : : (void *)&cmd_set_conntrack_dir_max_ack,
11265 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11266 : : NULL,
11267 : : },
11268 : : };
11269 : :
11270 : : /* show vf stats */
11271 : :
11272 : : /* Common result structure for show vf stats */
11273 : : struct cmd_show_vf_stats_result {
11274 : : cmdline_fixed_string_t show;
11275 : : cmdline_fixed_string_t vf;
11276 : : cmdline_fixed_string_t stats;
11277 : : portid_t port_id;
11278 : : uint16_t vf_id;
11279 : : };
11280 : :
11281 : : /* Common CLI fields show vf stats*/
11282 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11283 : : TOKEN_STRING_INITIALIZER
11284 : : (struct cmd_show_vf_stats_result,
11285 : : show, "show");
11286 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11287 : : TOKEN_STRING_INITIALIZER
11288 : : (struct cmd_show_vf_stats_result,
11289 : : vf, "vf");
11290 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11291 : : TOKEN_STRING_INITIALIZER
11292 : : (struct cmd_show_vf_stats_result,
11293 : : stats, "stats");
11294 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11295 : : TOKEN_NUM_INITIALIZER
11296 : : (struct cmd_show_vf_stats_result,
11297 : : port_id, RTE_UINT16);
11298 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11299 : : TOKEN_NUM_INITIALIZER
11300 : : (struct cmd_show_vf_stats_result,
11301 : : vf_id, RTE_UINT16);
11302 : :
11303 : : static void
11304 : 0 : cmd_show_vf_stats_parsed(
11305 : : void *parsed_result,
11306 : : __rte_unused struct cmdline *cl,
11307 : : __rte_unused void *data)
11308 : : {
11309 : : struct cmd_show_vf_stats_result *res = parsed_result;
11310 : : struct rte_eth_stats stats;
11311 : : int ret = -ENOTSUP;
11312 : : static const char *nic_stats_border = "########################";
11313 : :
11314 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11315 : 0 : return;
11316 : :
11317 : : memset(&stats, 0, sizeof(stats));
11318 : :
11319 : : #ifdef RTE_NET_I40E
11320 : : if (ret == -ENOTSUP)
11321 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11322 : 0 : res->vf_id,
11323 : : &stats);
11324 : : #endif
11325 : : #ifdef RTE_NET_BNXT
11326 : 0 : if (ret == -ENOTSUP)
11327 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11328 : 0 : res->vf_id,
11329 : : &stats);
11330 : : #endif
11331 : :
11332 : 0 : switch (ret) {
11333 : : case 0:
11334 : : break;
11335 : 0 : case -EINVAL:
11336 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11337 : : break;
11338 : 0 : case -ENODEV:
11339 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11340 : : break;
11341 : 0 : case -ENOTSUP:
11342 : 0 : fprintf(stderr, "function not implemented\n");
11343 : : break;
11344 : 0 : default:
11345 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11346 : : }
11347 : :
11348 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11349 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11350 : :
11351 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11352 : : "%-"PRIu64"\n",
11353 : : stats.ipackets, stats.imissed, stats.ibytes);
11354 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11355 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11356 : : stats.rx_nombuf);
11357 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11358 : : "%-"PRIu64"\n",
11359 : : stats.opackets, stats.oerrors, stats.obytes);
11360 : :
11361 : 0 : printf(" %s############################%s\n",
11362 : : nic_stats_border, nic_stats_border);
11363 : : }
11364 : :
11365 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11366 : : .f = cmd_show_vf_stats_parsed,
11367 : : .data = NULL,
11368 : : .help_str = "show vf stats <port_id> <vf_id>",
11369 : : .tokens = {
11370 : : (void *)&cmd_show_vf_stats_show,
11371 : : (void *)&cmd_show_vf_stats_vf,
11372 : : (void *)&cmd_show_vf_stats_stats,
11373 : : (void *)&cmd_show_vf_stats_port_id,
11374 : : (void *)&cmd_show_vf_stats_vf_id,
11375 : : NULL,
11376 : : },
11377 : : };
11378 : :
11379 : : /* clear vf stats */
11380 : :
11381 : : /* Common result structure for clear vf stats */
11382 : : struct cmd_clear_vf_stats_result {
11383 : : cmdline_fixed_string_t clear;
11384 : : cmdline_fixed_string_t vf;
11385 : : cmdline_fixed_string_t stats;
11386 : : portid_t port_id;
11387 : : uint16_t vf_id;
11388 : : };
11389 : :
11390 : : /* Common CLI fields clear vf stats*/
11391 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11392 : : TOKEN_STRING_INITIALIZER
11393 : : (struct cmd_clear_vf_stats_result,
11394 : : clear, "clear");
11395 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11396 : : TOKEN_STRING_INITIALIZER
11397 : : (struct cmd_clear_vf_stats_result,
11398 : : vf, "vf");
11399 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11400 : : TOKEN_STRING_INITIALIZER
11401 : : (struct cmd_clear_vf_stats_result,
11402 : : stats, "stats");
11403 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11404 : : TOKEN_NUM_INITIALIZER
11405 : : (struct cmd_clear_vf_stats_result,
11406 : : port_id, RTE_UINT16);
11407 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11408 : : TOKEN_NUM_INITIALIZER
11409 : : (struct cmd_clear_vf_stats_result,
11410 : : vf_id, RTE_UINT16);
11411 : :
11412 : : static void
11413 : 0 : cmd_clear_vf_stats_parsed(
11414 : : void *parsed_result,
11415 : : __rte_unused struct cmdline *cl,
11416 : : __rte_unused void *data)
11417 : : {
11418 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11419 : : int ret = -ENOTSUP;
11420 : :
11421 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11422 : : return;
11423 : :
11424 : : #ifdef RTE_NET_I40E
11425 : : if (ret == -ENOTSUP)
11426 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11427 : 0 : res->vf_id);
11428 : : #endif
11429 : : #ifdef RTE_NET_BNXT
11430 : 0 : if (ret == -ENOTSUP)
11431 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11432 : 0 : res->vf_id);
11433 : : #endif
11434 : :
11435 : 0 : switch (ret) {
11436 : : case 0:
11437 : : break;
11438 : 0 : case -EINVAL:
11439 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11440 : : break;
11441 : 0 : case -ENODEV:
11442 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11443 : : break;
11444 : 0 : case -ENOTSUP:
11445 : 0 : fprintf(stderr, "function not implemented\n");
11446 : : break;
11447 : 0 : default:
11448 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11449 : : }
11450 : : }
11451 : :
11452 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11453 : : .f = cmd_clear_vf_stats_parsed,
11454 : : .data = NULL,
11455 : : .help_str = "clear vf stats <port_id> <vf_id>",
11456 : : .tokens = {
11457 : : (void *)&cmd_clear_vf_stats_clear,
11458 : : (void *)&cmd_clear_vf_stats_vf,
11459 : : (void *)&cmd_clear_vf_stats_stats,
11460 : : (void *)&cmd_clear_vf_stats_port_id,
11461 : : (void *)&cmd_clear_vf_stats_vf_id,
11462 : : NULL,
11463 : : },
11464 : : };
11465 : :
11466 : : /* Common result structure for file commands */
11467 : : struct cmd_cmdfile_result {
11468 : : cmdline_fixed_string_t load;
11469 : : cmdline_fixed_string_t filename;
11470 : : };
11471 : :
11472 : : /* Common CLI fields for file commands */
11473 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11474 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11475 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11476 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11477 : :
11478 : : static void
11479 : 0 : cmd_load_from_file_parsed(
11480 : : void *parsed_result,
11481 : : __rte_unused struct cmdline *cl,
11482 : : __rte_unused void *data)
11483 : : {
11484 : : struct cmd_cmdfile_result *res = parsed_result;
11485 : :
11486 : 0 : cmdline_read_from_file(res->filename);
11487 : 0 : }
11488 : :
11489 : : static cmdline_parse_inst_t cmd_load_from_file = {
11490 : : .f = cmd_load_from_file_parsed,
11491 : : .data = NULL,
11492 : : .help_str = "load <filename>",
11493 : : .tokens = {
11494 : : (void *)&cmd_load_cmdfile,
11495 : : (void *)&cmd_load_cmdfile_filename,
11496 : : NULL,
11497 : : },
11498 : : };
11499 : :
11500 : : /* Get Rx offloads capabilities */
11501 : : struct cmd_rx_offload_get_capa_result {
11502 : : cmdline_fixed_string_t show;
11503 : : cmdline_fixed_string_t port;
11504 : : portid_t port_id;
11505 : : cmdline_fixed_string_t rx_offload;
11506 : : cmdline_fixed_string_t capabilities;
11507 : : };
11508 : :
11509 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11510 : : TOKEN_STRING_INITIALIZER
11511 : : (struct cmd_rx_offload_get_capa_result,
11512 : : show, "show");
11513 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11514 : : TOKEN_STRING_INITIALIZER
11515 : : (struct cmd_rx_offload_get_capa_result,
11516 : : port, "port");
11517 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11518 : : TOKEN_NUM_INITIALIZER
11519 : : (struct cmd_rx_offload_get_capa_result,
11520 : : port_id, RTE_UINT16);
11521 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11522 : : TOKEN_STRING_INITIALIZER
11523 : : (struct cmd_rx_offload_get_capa_result,
11524 : : rx_offload, "rx_offload");
11525 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11526 : : TOKEN_STRING_INITIALIZER
11527 : : (struct cmd_rx_offload_get_capa_result,
11528 : : capabilities, "capabilities");
11529 : :
11530 : : static void
11531 : 0 : print_rx_offloads(uint64_t offloads)
11532 : : {
11533 : : uint64_t single_offload;
11534 : : int begin;
11535 : : int end;
11536 : : int bit;
11537 : :
11538 : 0 : if (offloads == 0)
11539 : : return;
11540 : :
11541 : : begin = rte_ctz64(offloads);
11542 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11543 : :
11544 : 0 : single_offload = 1ULL << begin;
11545 : 0 : for (bit = begin; bit < end; bit++) {
11546 : 0 : if (offloads & single_offload)
11547 : 0 : printf(" %s",
11548 : : rte_eth_dev_rx_offload_name(single_offload));
11549 : 0 : single_offload <<= 1;
11550 : : }
11551 : : }
11552 : :
11553 : : static void
11554 : 0 : cmd_rx_offload_get_capa_parsed(
11555 : : void *parsed_result,
11556 : : __rte_unused struct cmdline *cl,
11557 : : __rte_unused void *data)
11558 : : {
11559 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11560 : : struct rte_eth_dev_info dev_info;
11561 : 0 : portid_t port_id = res->port_id;
11562 : : uint64_t queue_offloads;
11563 : : uint64_t port_offloads;
11564 : : int ret;
11565 : :
11566 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11567 : 0 : if (ret != 0)
11568 : 0 : return;
11569 : :
11570 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11571 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11572 : :
11573 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11574 : : printf(" Per Queue :");
11575 : 0 : print_rx_offloads(queue_offloads);
11576 : :
11577 : : printf("\n");
11578 : : printf(" Per Port :");
11579 : 0 : print_rx_offloads(port_offloads);
11580 : : printf("\n\n");
11581 : : }
11582 : :
11583 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11584 : : .f = cmd_rx_offload_get_capa_parsed,
11585 : : .data = NULL,
11586 : : .help_str = "show port <port_id> rx_offload capabilities",
11587 : : .tokens = {
11588 : : (void *)&cmd_rx_offload_get_capa_show,
11589 : : (void *)&cmd_rx_offload_get_capa_port,
11590 : : (void *)&cmd_rx_offload_get_capa_port_id,
11591 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11592 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11593 : : NULL,
11594 : : }
11595 : : };
11596 : :
11597 : : /* Get Rx offloads configuration */
11598 : : struct cmd_rx_offload_get_configuration_result {
11599 : : cmdline_fixed_string_t show;
11600 : : cmdline_fixed_string_t port;
11601 : : portid_t port_id;
11602 : : cmdline_fixed_string_t rx_offload;
11603 : : cmdline_fixed_string_t configuration;
11604 : : };
11605 : :
11606 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11607 : : TOKEN_STRING_INITIALIZER
11608 : : (struct cmd_rx_offload_get_configuration_result,
11609 : : show, "show");
11610 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11611 : : TOKEN_STRING_INITIALIZER
11612 : : (struct cmd_rx_offload_get_configuration_result,
11613 : : port, "port");
11614 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11615 : : TOKEN_NUM_INITIALIZER
11616 : : (struct cmd_rx_offload_get_configuration_result,
11617 : : port_id, RTE_UINT16);
11618 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11619 : : TOKEN_STRING_INITIALIZER
11620 : : (struct cmd_rx_offload_get_configuration_result,
11621 : : rx_offload, "rx_offload");
11622 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11623 : : TOKEN_STRING_INITIALIZER
11624 : : (struct cmd_rx_offload_get_configuration_result,
11625 : : configuration, "configuration");
11626 : :
11627 : : static void
11628 : 0 : cmd_rx_offload_get_configuration_parsed(
11629 : : void *parsed_result,
11630 : : __rte_unused struct cmdline *cl,
11631 : : __rte_unused void *data)
11632 : : {
11633 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11634 : : struct rte_eth_dev_info dev_info;
11635 : 0 : portid_t port_id = res->port_id;
11636 : : struct rte_port *port;
11637 : : struct rte_eth_conf dev_conf;
11638 : : uint64_t port_offloads;
11639 : : uint64_t queue_offloads;
11640 : : uint16_t nb_rx_queues;
11641 : : int q;
11642 : : int ret;
11643 : :
11644 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11645 : 0 : if (ret != 0)
11646 : 0 : return;
11647 : :
11648 : 0 : port = &ports[port_id];
11649 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
11650 : :
11651 : 0 : port_offloads = dev_conf.rxmode.offloads;
11652 : : printf(" Port :");
11653 : 0 : print_rx_offloads(port_offloads);
11654 : : printf("\n");
11655 : :
11656 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11657 : 0 : if (ret != 0)
11658 : : return;
11659 : :
11660 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11661 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11662 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11663 : : printf(" Queue[%2d] :", q);
11664 : 0 : print_rx_offloads(queue_offloads);
11665 : : printf("\n");
11666 : : }
11667 : : printf("\n");
11668 : : }
11669 : :
11670 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11671 : : .f = cmd_rx_offload_get_configuration_parsed,
11672 : : .data = NULL,
11673 : : .help_str = "show port <port_id> rx_offload configuration",
11674 : : .tokens = {
11675 : : (void *)&cmd_rx_offload_get_configuration_show,
11676 : : (void *)&cmd_rx_offload_get_configuration_port,
11677 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11678 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11679 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11680 : : NULL,
11681 : : }
11682 : : };
11683 : :
11684 : : /* Enable/Disable a per port offloading */
11685 : : struct cmd_config_per_port_rx_offload_result {
11686 : : cmdline_fixed_string_t port;
11687 : : cmdline_fixed_string_t config;
11688 : : portid_t port_id;
11689 : : cmdline_fixed_string_t rx_offload;
11690 : : cmdline_fixed_string_t offload;
11691 : : cmdline_fixed_string_t on_off;
11692 : : };
11693 : :
11694 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11695 : : TOKEN_STRING_INITIALIZER
11696 : : (struct cmd_config_per_port_rx_offload_result,
11697 : : port, "port");
11698 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11699 : : TOKEN_STRING_INITIALIZER
11700 : : (struct cmd_config_per_port_rx_offload_result,
11701 : : config, "config");
11702 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11703 : : TOKEN_NUM_INITIALIZER
11704 : : (struct cmd_config_per_port_rx_offload_result,
11705 : : port_id, RTE_UINT16);
11706 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11707 : : TOKEN_STRING_INITIALIZER
11708 : : (struct cmd_config_per_port_rx_offload_result,
11709 : : rx_offload, "rx_offload");
11710 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11711 : : TOKEN_STRING_INITIALIZER
11712 : : (struct cmd_config_per_port_rx_offload_result,
11713 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11714 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11715 : : "vlan_filter#vlan_extend#"
11716 : : "scatter#buffer_split#timestamp#security#"
11717 : : "keep_crc#rss_hash");
11718 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11719 : : TOKEN_STRING_INITIALIZER
11720 : : (struct cmd_config_per_port_rx_offload_result,
11721 : : on_off, "on#off");
11722 : :
11723 : : static uint64_t
11724 : 0 : search_rx_offload(const char *name)
11725 : : {
11726 : : uint64_t single_offload;
11727 : : const char *single_name;
11728 : : int found = 0;
11729 : : unsigned int bit;
11730 : :
11731 : : single_offload = 1;
11732 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11733 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11734 : 0 : if (!strcasecmp(single_name, name)) {
11735 : : found = 1;
11736 : : break;
11737 : : }
11738 : 0 : single_offload <<= 1;
11739 : : }
11740 : :
11741 : 0 : if (found)
11742 : 0 : return single_offload;
11743 : :
11744 : : return 0;
11745 : : }
11746 : :
11747 : : static void
11748 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11749 : : {
11750 : : struct rte_eth_dev_info dev_info;
11751 : : struct rte_port *port;
11752 : : uint16_t nb_rx_queues;
11753 : : uint64_t offload;
11754 : : int q;
11755 : : int ret;
11756 : :
11757 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11758 : 0 : if (ret != 0)
11759 : 0 : return;
11760 : :
11761 : 0 : port = &ports[port_id];
11762 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11763 : 0 : fprintf(stderr,
11764 : : "Error: Can't config offload when Port %d is not stopped\n",
11765 : : port_id);
11766 : 0 : return;
11767 : : }
11768 : :
11769 : 0 : if (!strcmp(name, "all")) {
11770 : 0 : offload = dev_info.rx_offload_capa;
11771 : : } else {
11772 : 0 : offload = search_rx_offload(name);
11773 : 0 : if (offload == 0) {
11774 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11775 : 0 : return;
11776 : : }
11777 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11778 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11779 : : port_id, name);
11780 : 0 : return;
11781 : : }
11782 : : }
11783 : :
11784 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11785 : 0 : if (on) {
11786 : 0 : port->dev_conf.rxmode.offloads |= offload;
11787 : 0 : for (q = 0; q < nb_rx_queues; q++)
11788 : 0 : port->rxq[q].conf.offloads |= offload;
11789 : : } else {
11790 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11791 : 0 : for (q = 0; q < nb_rx_queues; q++)
11792 : 0 : port->rxq[q].conf.offloads &= ~offload;
11793 : : }
11794 : :
11795 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11796 : : }
11797 : :
11798 : : static void
11799 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11800 : : __rte_unused struct cmdline *cl,
11801 : : __rte_unused void *data)
11802 : : {
11803 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11804 : : bool on;
11805 : :
11806 : 0 : on = strcmp(res->on_off, "on") == 0;
11807 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11808 : 0 : }
11809 : :
11810 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11811 : : .f = cmd_config_per_port_rx_offload_parsed,
11812 : : .data = NULL,
11813 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11814 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11815 : : "macsec_strip|vlan_filter|vlan_extend|"
11816 : : "scatter|buffer_split|timestamp|security|"
11817 : : "keep_crc|rss_hash on|off",
11818 : : .tokens = {
11819 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11820 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11821 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11822 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11823 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11824 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11825 : : NULL,
11826 : : }
11827 : : };
11828 : :
11829 : : /* Enable/Disable all port Rx offloading */
11830 : : struct cmd_config_all_port_rx_offload_result {
11831 : : cmdline_fixed_string_t port;
11832 : : cmdline_fixed_string_t config;
11833 : : cmdline_fixed_string_t port_all;
11834 : : cmdline_fixed_string_t rx_offload;
11835 : : cmdline_fixed_string_t offload;
11836 : : cmdline_fixed_string_t on_off;
11837 : : };
11838 : :
11839 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
11840 : : TOKEN_STRING_INITIALIZER
11841 : : (struct cmd_config_all_port_rx_offload_result,
11842 : : port, "port");
11843 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
11844 : : TOKEN_STRING_INITIALIZER
11845 : : (struct cmd_config_all_port_rx_offload_result,
11846 : : config, "config");
11847 : :
11848 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
11849 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
11850 : : port_all, "all");
11851 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
11852 : : TOKEN_STRING_INITIALIZER
11853 : : (struct cmd_config_all_port_rx_offload_result,
11854 : : rx_offload, "rx_offload");
11855 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
11856 : : TOKEN_STRING_INITIALIZER
11857 : : (struct cmd_config_all_port_rx_offload_result,
11858 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11859 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11860 : : "vlan_filter#vlan_extend#"
11861 : : "scatter#buffer_split#timestamp#security#"
11862 : : "keep_crc#rss_hash");
11863 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
11864 : : TOKEN_STRING_INITIALIZER
11865 : : (struct cmd_config_all_port_rx_offload_result,
11866 : : on_off, "on#off");
11867 : :
11868 : : static void
11869 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
11870 : : __rte_unused struct cmdline *cl,
11871 : : __rte_unused void *data)
11872 : : {
11873 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
11874 : : bool on_off;
11875 : : portid_t i;
11876 : :
11877 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11878 : 0 : RTE_ETH_FOREACH_DEV(i)
11879 : 0 : config_port_rx_offload(i, res->offload, on_off);
11880 : :
11881 : 0 : }
11882 : :
11883 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
11884 : : .f = cmd_config_all_port_rx_offload_parsed,
11885 : : .data = NULL,
11886 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
11887 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11888 : : "macsec_strip|vlan_filter|vlan_extend|"
11889 : : "scatter|buffer_split|timestamp|security|"
11890 : : "keep_crc|rss_hash on|off",
11891 : : .tokens = {
11892 : : (void *)&cmd_config_all_port_rx_offload_result_port,
11893 : : (void *)&cmd_config_all_port_rx_offload_result_config,
11894 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
11895 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
11896 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
11897 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
11898 : : NULL,
11899 : : }
11900 : : };
11901 : :
11902 : : /* Enable/Disable a per queue offloading */
11903 : : struct cmd_config_per_queue_rx_offload_result {
11904 : : cmdline_fixed_string_t port;
11905 : : portid_t port_id;
11906 : : cmdline_fixed_string_t rxq;
11907 : : uint16_t queue_id;
11908 : : cmdline_fixed_string_t rx_offload;
11909 : : cmdline_fixed_string_t offload;
11910 : : cmdline_fixed_string_t on_off;
11911 : : };
11912 : :
11913 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
11914 : : TOKEN_STRING_INITIALIZER
11915 : : (struct cmd_config_per_queue_rx_offload_result,
11916 : : port, "port");
11917 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
11918 : : TOKEN_NUM_INITIALIZER
11919 : : (struct cmd_config_per_queue_rx_offload_result,
11920 : : port_id, RTE_UINT16);
11921 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
11922 : : TOKEN_STRING_INITIALIZER
11923 : : (struct cmd_config_per_queue_rx_offload_result,
11924 : : rxq, "rxq");
11925 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
11926 : : TOKEN_NUM_INITIALIZER
11927 : : (struct cmd_config_per_queue_rx_offload_result,
11928 : : queue_id, RTE_UINT16);
11929 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
11930 : : TOKEN_STRING_INITIALIZER
11931 : : (struct cmd_config_per_queue_rx_offload_result,
11932 : : rx_offload, "rx_offload");
11933 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
11934 : : TOKEN_STRING_INITIALIZER
11935 : : (struct cmd_config_per_queue_rx_offload_result,
11936 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11937 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11938 : : "vlan_filter#vlan_extend#"
11939 : : "scatter#buffer_split#timestamp#security#keep_crc");
11940 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
11941 : : TOKEN_STRING_INITIALIZER
11942 : : (struct cmd_config_per_queue_rx_offload_result,
11943 : : on_off, "on#off");
11944 : :
11945 : : static void
11946 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
11947 : : __rte_unused struct cmdline *cl,
11948 : : __rte_unused void *data)
11949 : : {
11950 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
11951 : : struct rte_eth_dev_info dev_info;
11952 : 0 : portid_t port_id = res->port_id;
11953 : 0 : uint16_t queue_id = res->queue_id;
11954 : : struct rte_port *port;
11955 : : uint64_t offload;
11956 : : int ret;
11957 : :
11958 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11959 : 0 : if (ret != 0)
11960 : 0 : return;
11961 : :
11962 : 0 : port = &ports[port_id];
11963 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11964 : 0 : fprintf(stderr,
11965 : : "Error: Can't config offload when Port %d is not stopped\n",
11966 : : port_id);
11967 : 0 : return;
11968 : : }
11969 : :
11970 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
11971 : 0 : fprintf(stderr,
11972 : : "Error: input queue_id should be 0 ... %d\n",
11973 : 0 : dev_info.nb_rx_queues - 1);
11974 : 0 : return;
11975 : : }
11976 : :
11977 : 0 : if (!strcmp(res->offload, "all")) {
11978 : 0 : offload = dev_info.rx_queue_offload_capa;
11979 : : } else {
11980 : 0 : offload = search_rx_offload(res->offload);
11981 : 0 : if (offload == 0) {
11982 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11983 : 0 : return;
11984 : : }
11985 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
11986 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11987 : : port_id, res->offload);
11988 : 0 : return;
11989 : : }
11990 : : }
11991 : :
11992 : 0 : if (!strcmp(res->on_off, "on"))
11993 : 0 : port->rxq[queue_id].conf.offloads |= offload;
11994 : : else
11995 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
11996 : :
11997 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11998 : : }
11999 : :
12000 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12001 : : .f = cmd_config_per_queue_rx_offload_parsed,
12002 : : .data = NULL,
12003 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12004 : : "all|vlan_strip|ipv4_cksum|"
12005 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12006 : : "macsec_strip|vlan_filter|vlan_extend|"
12007 : : "scatter|buffer_split|timestamp|security|"
12008 : : "keep_crc on|off",
12009 : : .tokens = {
12010 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12011 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12012 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12013 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12014 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12015 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12016 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12017 : : NULL,
12018 : : }
12019 : : };
12020 : :
12021 : : /* Get Tx offloads capabilities */
12022 : : struct cmd_tx_offload_get_capa_result {
12023 : : cmdline_fixed_string_t show;
12024 : : cmdline_fixed_string_t port;
12025 : : portid_t port_id;
12026 : : cmdline_fixed_string_t tx_offload;
12027 : : cmdline_fixed_string_t capabilities;
12028 : : };
12029 : :
12030 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12031 : : TOKEN_STRING_INITIALIZER
12032 : : (struct cmd_tx_offload_get_capa_result,
12033 : : show, "show");
12034 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12035 : : TOKEN_STRING_INITIALIZER
12036 : : (struct cmd_tx_offload_get_capa_result,
12037 : : port, "port");
12038 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12039 : : TOKEN_NUM_INITIALIZER
12040 : : (struct cmd_tx_offload_get_capa_result,
12041 : : port_id, RTE_UINT16);
12042 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12043 : : TOKEN_STRING_INITIALIZER
12044 : : (struct cmd_tx_offload_get_capa_result,
12045 : : tx_offload, "tx_offload");
12046 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12047 : : TOKEN_STRING_INITIALIZER
12048 : : (struct cmd_tx_offload_get_capa_result,
12049 : : capabilities, "capabilities");
12050 : :
12051 : : static void
12052 : 0 : print_tx_offloads(uint64_t offloads)
12053 : : {
12054 : : uint64_t single_offload;
12055 : : int begin;
12056 : : int end;
12057 : : int bit;
12058 : :
12059 : 0 : if (offloads == 0)
12060 : : return;
12061 : :
12062 : : begin = rte_ctz64(offloads);
12063 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12064 : :
12065 : 0 : single_offload = 1ULL << begin;
12066 : 0 : for (bit = begin; bit < end; bit++) {
12067 : 0 : if (offloads & single_offload)
12068 : 0 : printf(" %s",
12069 : : rte_eth_dev_tx_offload_name(single_offload));
12070 : 0 : single_offload <<= 1;
12071 : : }
12072 : : }
12073 : :
12074 : : static void
12075 : 0 : cmd_tx_offload_get_capa_parsed(
12076 : : void *parsed_result,
12077 : : __rte_unused struct cmdline *cl,
12078 : : __rte_unused void *data)
12079 : : {
12080 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12081 : : struct rte_eth_dev_info dev_info;
12082 : 0 : portid_t port_id = res->port_id;
12083 : : uint64_t queue_offloads;
12084 : : uint64_t port_offloads;
12085 : : int ret;
12086 : :
12087 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12088 : 0 : if (ret != 0)
12089 : 0 : return;
12090 : :
12091 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12092 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12093 : :
12094 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12095 : : printf(" Per Queue :");
12096 : 0 : print_tx_offloads(queue_offloads);
12097 : :
12098 : : printf("\n");
12099 : : printf(" Per Port :");
12100 : 0 : print_tx_offloads(port_offloads);
12101 : : printf("\n\n");
12102 : : }
12103 : :
12104 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12105 : : .f = cmd_tx_offload_get_capa_parsed,
12106 : : .data = NULL,
12107 : : .help_str = "show port <port_id> tx_offload capabilities",
12108 : : .tokens = {
12109 : : (void *)&cmd_tx_offload_get_capa_show,
12110 : : (void *)&cmd_tx_offload_get_capa_port,
12111 : : (void *)&cmd_tx_offload_get_capa_port_id,
12112 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12113 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12114 : : NULL,
12115 : : }
12116 : : };
12117 : :
12118 : : /* Get Tx offloads configuration */
12119 : : struct cmd_tx_offload_get_configuration_result {
12120 : : cmdline_fixed_string_t show;
12121 : : cmdline_fixed_string_t port;
12122 : : portid_t port_id;
12123 : : cmdline_fixed_string_t tx_offload;
12124 : : cmdline_fixed_string_t configuration;
12125 : : };
12126 : :
12127 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12128 : : TOKEN_STRING_INITIALIZER
12129 : : (struct cmd_tx_offload_get_configuration_result,
12130 : : show, "show");
12131 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12132 : : TOKEN_STRING_INITIALIZER
12133 : : (struct cmd_tx_offload_get_configuration_result,
12134 : : port, "port");
12135 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12136 : : TOKEN_NUM_INITIALIZER
12137 : : (struct cmd_tx_offload_get_configuration_result,
12138 : : port_id, RTE_UINT16);
12139 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12140 : : TOKEN_STRING_INITIALIZER
12141 : : (struct cmd_tx_offload_get_configuration_result,
12142 : : tx_offload, "tx_offload");
12143 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12144 : : TOKEN_STRING_INITIALIZER
12145 : : (struct cmd_tx_offload_get_configuration_result,
12146 : : configuration, "configuration");
12147 : :
12148 : : static void
12149 : 0 : cmd_tx_offload_get_configuration_parsed(
12150 : : void *parsed_result,
12151 : : __rte_unused struct cmdline *cl,
12152 : : __rte_unused void *data)
12153 : : {
12154 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12155 : : struct rte_eth_dev_info dev_info;
12156 : 0 : portid_t port_id = res->port_id;
12157 : : struct rte_port *port;
12158 : : struct rte_eth_conf dev_conf;
12159 : : uint64_t port_offloads;
12160 : : uint64_t queue_offloads;
12161 : : uint16_t nb_tx_queues;
12162 : : int q;
12163 : : int ret;
12164 : :
12165 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12166 : 0 : if (ret != 0)
12167 : 0 : return;
12168 : :
12169 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12170 : 0 : port = &ports[port_id];
12171 : 0 : port_offloads = dev_conf.txmode.offloads;
12172 : : printf(" Port :");
12173 : 0 : print_tx_offloads(port_offloads);
12174 : : printf("\n");
12175 : :
12176 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12177 : 0 : if (ret != 0)
12178 : : return;
12179 : :
12180 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12181 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12182 : 0 : queue_offloads = port->txq[q].conf.offloads;
12183 : : printf(" Queue[%2d] :", q);
12184 : 0 : print_tx_offloads(queue_offloads);
12185 : : printf("\n");
12186 : : }
12187 : : printf("\n");
12188 : : }
12189 : :
12190 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12191 : : .f = cmd_tx_offload_get_configuration_parsed,
12192 : : .data = NULL,
12193 : : .help_str = "show port <port_id> tx_offload configuration",
12194 : : .tokens = {
12195 : : (void *)&cmd_tx_offload_get_configuration_show,
12196 : : (void *)&cmd_tx_offload_get_configuration_port,
12197 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12198 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12199 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12200 : : NULL,
12201 : : }
12202 : : };
12203 : :
12204 : : /* Enable/Disable a per port offloading */
12205 : : struct cmd_config_per_port_tx_offload_result {
12206 : : cmdline_fixed_string_t port;
12207 : : cmdline_fixed_string_t config;
12208 : : portid_t port_id;
12209 : : cmdline_fixed_string_t tx_offload;
12210 : : cmdline_fixed_string_t offload;
12211 : : cmdline_fixed_string_t on_off;
12212 : : };
12213 : :
12214 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12215 : : TOKEN_STRING_INITIALIZER
12216 : : (struct cmd_config_per_port_tx_offload_result,
12217 : : port, "port");
12218 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12219 : : TOKEN_STRING_INITIALIZER
12220 : : (struct cmd_config_per_port_tx_offload_result,
12221 : : config, "config");
12222 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12223 : : TOKEN_NUM_INITIALIZER
12224 : : (struct cmd_config_per_port_tx_offload_result,
12225 : : port_id, RTE_UINT16);
12226 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12227 : : TOKEN_STRING_INITIALIZER
12228 : : (struct cmd_config_per_port_tx_offload_result,
12229 : : tx_offload, "tx_offload");
12230 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12231 : : TOKEN_STRING_INITIALIZER
12232 : : (struct cmd_config_per_port_tx_offload_result,
12233 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12234 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12235 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12236 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12237 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12238 : : "send_on_timestamp");
12239 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12240 : : TOKEN_STRING_INITIALIZER
12241 : : (struct cmd_config_per_port_tx_offload_result,
12242 : : on_off, "on#off");
12243 : :
12244 : : static uint64_t
12245 : 0 : search_tx_offload(const char *name)
12246 : : {
12247 : : uint64_t single_offload;
12248 : : const char *single_name;
12249 : : int found = 0;
12250 : : unsigned int bit;
12251 : :
12252 : : single_offload = 1;
12253 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12254 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12255 : 0 : if (single_name == NULL)
12256 : : break;
12257 : 0 : if (!strcasecmp(single_name, name)) {
12258 : : found = 1;
12259 : : break;
12260 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12261 : : break;
12262 : 0 : single_offload <<= 1;
12263 : : }
12264 : :
12265 : 0 : if (found)
12266 : 0 : return single_offload;
12267 : :
12268 : : return 0;
12269 : : }
12270 : :
12271 : : static void
12272 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12273 : : {
12274 : : struct rte_eth_dev_info dev_info;
12275 : : struct rte_port *port;
12276 : : uint16_t nb_tx_queues;
12277 : : uint64_t offload;
12278 : : int q;
12279 : : int ret;
12280 : :
12281 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12282 : 0 : if (ret != 0)
12283 : 0 : return;
12284 : :
12285 : 0 : port = &ports[port_id];
12286 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12287 : 0 : fprintf(stderr,
12288 : : "Error: Can't config offload when Port %d is not stopped\n",
12289 : : port_id);
12290 : 0 : return;
12291 : : }
12292 : :
12293 : 0 : if (!strcmp(name, "all")) {
12294 : 0 : offload = dev_info.tx_offload_capa;
12295 : : } else {
12296 : 0 : offload = search_tx_offload(name);
12297 : 0 : if (offload == 0) {
12298 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12299 : 0 : return;
12300 : : }
12301 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12302 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12303 : : port_id, name);
12304 : 0 : return;
12305 : : }
12306 : : }
12307 : :
12308 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12309 : 0 : if (on) {
12310 : 0 : port->dev_conf.txmode.offloads |= offload;
12311 : 0 : for (q = 0; q < nb_tx_queues; q++)
12312 : 0 : port->txq[q].conf.offloads |= offload;
12313 : : } else {
12314 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12315 : 0 : for (q = 0; q < nb_tx_queues; q++)
12316 : 0 : port->txq[q].conf.offloads &= ~offload;
12317 : : }
12318 : :
12319 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12320 : : }
12321 : :
12322 : : static void
12323 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12324 : : __rte_unused struct cmdline *cl,
12325 : : __rte_unused void *data)
12326 : : {
12327 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12328 : : bool on;
12329 : :
12330 : 0 : on = strcmp(res->on_off, "on") == 0;
12331 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12332 : 0 : }
12333 : :
12334 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12335 : : .f = cmd_config_per_port_tx_offload_parsed,
12336 : : .data = NULL,
12337 : : .help_str = "port config <port_id> tx_offload "
12338 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12339 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12340 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12341 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12342 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12343 : : "send_on_timestamp on|off",
12344 : : .tokens = {
12345 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12346 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12347 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12348 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12349 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12350 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12351 : : NULL,
12352 : : }
12353 : : };
12354 : :
12355 : : /* Enable/Disable all port Tx offloading */
12356 : : struct cmd_config_all_port_tx_offload_result {
12357 : : cmdline_fixed_string_t port;
12358 : : cmdline_fixed_string_t config;
12359 : : cmdline_fixed_string_t port_all;
12360 : : cmdline_fixed_string_t tx_offload;
12361 : : cmdline_fixed_string_t offload;
12362 : : cmdline_fixed_string_t on_off;
12363 : : };
12364 : :
12365 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12366 : : TOKEN_STRING_INITIALIZER
12367 : : (struct cmd_config_all_port_tx_offload_result,
12368 : : port, "port");
12369 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12370 : : TOKEN_STRING_INITIALIZER
12371 : : (struct cmd_config_all_port_tx_offload_result,
12372 : : config, "config");
12373 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12374 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12375 : : port_all, "all");
12376 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12377 : : TOKEN_STRING_INITIALIZER
12378 : : (struct cmd_config_all_port_tx_offload_result,
12379 : : tx_offload, "tx_offload");
12380 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12381 : : TOKEN_STRING_INITIALIZER
12382 : : (struct cmd_config_all_port_tx_offload_result,
12383 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12384 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12385 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12386 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12387 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12388 : : "send_on_timestamp");
12389 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12390 : : TOKEN_STRING_INITIALIZER
12391 : : (struct cmd_config_all_port_tx_offload_result,
12392 : : on_off, "on#off");
12393 : :
12394 : : static void
12395 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12396 : : __rte_unused struct cmdline *cl,
12397 : : __rte_unused void *data)
12398 : : {
12399 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12400 : : portid_t i;
12401 : : bool on_off;
12402 : :
12403 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12404 : 0 : RTE_ETH_FOREACH_DEV(i)
12405 : 0 : config_port_tx_offload(i, res->offload, on_off);
12406 : 0 : }
12407 : :
12408 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12409 : : .f = cmd_config_all_port_tx_offload_parsed,
12410 : : .data = NULL,
12411 : : .help_str = "port config all tx_offload "
12412 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12413 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12414 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12415 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12416 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12417 : : "send_on_timestamp on|off",
12418 : : .tokens = {
12419 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12420 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12421 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12422 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12423 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12424 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12425 : : NULL,
12426 : : }
12427 : : };
12428 : :
12429 : : /* Enable/Disable a per queue offloading */
12430 : : struct cmd_config_per_queue_tx_offload_result {
12431 : : cmdline_fixed_string_t port;
12432 : : portid_t port_id;
12433 : : cmdline_fixed_string_t txq;
12434 : : uint16_t queue_id;
12435 : : cmdline_fixed_string_t tx_offload;
12436 : : cmdline_fixed_string_t offload;
12437 : : cmdline_fixed_string_t on_off;
12438 : : };
12439 : :
12440 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12441 : : TOKEN_STRING_INITIALIZER
12442 : : (struct cmd_config_per_queue_tx_offload_result,
12443 : : port, "port");
12444 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12445 : : TOKEN_NUM_INITIALIZER
12446 : : (struct cmd_config_per_queue_tx_offload_result,
12447 : : port_id, RTE_UINT16);
12448 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12449 : : TOKEN_STRING_INITIALIZER
12450 : : (struct cmd_config_per_queue_tx_offload_result,
12451 : : txq, "txq");
12452 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12453 : : TOKEN_NUM_INITIALIZER
12454 : : (struct cmd_config_per_queue_tx_offload_result,
12455 : : queue_id, RTE_UINT16);
12456 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12457 : : TOKEN_STRING_INITIALIZER
12458 : : (struct cmd_config_per_queue_tx_offload_result,
12459 : : tx_offload, "tx_offload");
12460 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12461 : : TOKEN_STRING_INITIALIZER
12462 : : (struct cmd_config_per_queue_tx_offload_result,
12463 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12464 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12465 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12466 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12467 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12468 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12469 : : TOKEN_STRING_INITIALIZER
12470 : : (struct cmd_config_per_queue_tx_offload_result,
12471 : : on_off, "on#off");
12472 : :
12473 : : static void
12474 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12475 : : __rte_unused struct cmdline *cl,
12476 : : __rte_unused void *data)
12477 : : {
12478 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12479 : : struct rte_eth_dev_info dev_info;
12480 : 0 : portid_t port_id = res->port_id;
12481 : 0 : uint16_t queue_id = res->queue_id;
12482 : : struct rte_port *port;
12483 : : uint64_t offload;
12484 : : int ret;
12485 : :
12486 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12487 : 0 : if (ret != 0)
12488 : 0 : return;
12489 : :
12490 : 0 : port = &ports[port_id];
12491 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12492 : 0 : fprintf(stderr,
12493 : : "Error: Can't config offload when Port %d is not stopped\n",
12494 : : port_id);
12495 : 0 : return;
12496 : : }
12497 : :
12498 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12499 : 0 : fprintf(stderr,
12500 : : "Error: input queue_id should be 0 ... %d\n",
12501 : 0 : dev_info.nb_tx_queues - 1);
12502 : 0 : return;
12503 : : }
12504 : :
12505 : 0 : if (!strcmp(res->offload, "all")) {
12506 : 0 : offload = dev_info.tx_queue_offload_capa;
12507 : : } else {
12508 : 0 : offload = search_tx_offload(res->offload);
12509 : 0 : if (offload == 0) {
12510 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12511 : 0 : return;
12512 : : }
12513 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12514 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12515 : : port_id, res->offload);
12516 : 0 : return;
12517 : : }
12518 : : }
12519 : :
12520 : 0 : if (!strcmp(res->on_off, "on"))
12521 : 0 : port->txq[queue_id].conf.offloads |= offload;
12522 : : else
12523 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12524 : :
12525 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12526 : : }
12527 : :
12528 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12529 : : .f = cmd_config_per_queue_tx_offload_parsed,
12530 : : .data = NULL,
12531 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12532 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12533 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12534 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12535 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12536 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12537 : : "on|off",
12538 : : .tokens = {
12539 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12540 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12541 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12542 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12543 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12544 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12545 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12546 : : NULL,
12547 : : }
12548 : : };
12549 : :
12550 : : /* *** configure tx_metadata for specific port *** */
12551 : : struct cmd_config_tx_metadata_specific_result {
12552 : : cmdline_fixed_string_t port;
12553 : : cmdline_fixed_string_t keyword;
12554 : : uint16_t port_id;
12555 : : cmdline_fixed_string_t item;
12556 : : uint32_t value;
12557 : : };
12558 : :
12559 : : static void
12560 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12561 : : __rte_unused struct cmdline *cl,
12562 : : __rte_unused void *data)
12563 : : {
12564 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12565 : :
12566 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12567 : : return;
12568 : 0 : ports[res->port_id].tx_metadata = res->value;
12569 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12570 : 0 : if (ports[res->port_id].tx_metadata)
12571 : 0 : add_tx_md_callback(res->port_id);
12572 : : else
12573 : 0 : remove_tx_md_callback(res->port_id);
12574 : 0 : rte_flow_dynf_metadata_register();
12575 : : }
12576 : :
12577 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12578 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12579 : : port, "port");
12580 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12581 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12582 : : keyword, "config");
12583 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12584 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12585 : : port_id, RTE_UINT16);
12586 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12587 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12588 : : item, "tx_metadata");
12589 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12590 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12591 : : value, RTE_UINT32);
12592 : :
12593 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12594 : : .f = cmd_config_tx_metadata_specific_parsed,
12595 : : .data = NULL,
12596 : : .help_str = "port config <port_id> tx_metadata <value>",
12597 : : .tokens = {
12598 : : (void *)&cmd_config_tx_metadata_specific_port,
12599 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12600 : : (void *)&cmd_config_tx_metadata_specific_id,
12601 : : (void *)&cmd_config_tx_metadata_specific_item,
12602 : : (void *)&cmd_config_tx_metadata_specific_value,
12603 : : NULL,
12604 : : },
12605 : : };
12606 : :
12607 : : /* *** set dynf *** */
12608 : : struct cmd_config_tx_dynf_specific_result {
12609 : : cmdline_fixed_string_t port;
12610 : : cmdline_fixed_string_t keyword;
12611 : : uint16_t port_id;
12612 : : cmdline_fixed_string_t item;
12613 : : cmdline_fixed_string_t name;
12614 : : cmdline_fixed_string_t value;
12615 : : };
12616 : :
12617 : : static void
12618 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12619 : : __rte_unused struct cmdline *cl,
12620 : : __rte_unused void *data)
12621 : : {
12622 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12623 : : struct rte_mbuf_dynflag desc_flag;
12624 : : int flag;
12625 : : uint64_t old_port_flags;
12626 : :
12627 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12628 : 0 : return;
12629 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12630 : 0 : if (flag <= 0) {
12631 : 0 : if (strlcpy(desc_flag.name, res->name,
12632 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12633 : 0 : fprintf(stderr, "Flag name too long\n");
12634 : 0 : return;
12635 : : }
12636 : 0 : desc_flag.flags = 0;
12637 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12638 : 0 : if (flag < 0) {
12639 : 0 : fprintf(stderr, "Can't register flag\n");
12640 : 0 : return;
12641 : : }
12642 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12643 : : }
12644 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12645 : 0 : if (!strcmp(res->value, "set")) {
12646 : 0 : ports[res->port_id].mbuf_dynf |= 1UL << flag;
12647 : 0 : if (old_port_flags == 0)
12648 : 0 : add_tx_dynf_callback(res->port_id);
12649 : : } else {
12650 : 0 : ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
12651 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12652 : 0 : remove_tx_dynf_callback(res->port_id);
12653 : : }
12654 : : }
12655 : :
12656 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12657 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12658 : : keyword, "port");
12659 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12660 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12661 : : keyword, "config");
12662 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12663 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12664 : : port_id, RTE_UINT16);
12665 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12666 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12667 : : item, "dynf");
12668 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12669 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12670 : : name, NULL);
12671 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12672 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12673 : : value, "set#clear");
12674 : :
12675 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12676 : : .f = cmd_config_dynf_specific_parsed,
12677 : : .data = NULL,
12678 : : .help_str = "port config <port id> dynf <name> set|clear",
12679 : : .tokens = {
12680 : : (void *)&cmd_config_tx_dynf_specific_port,
12681 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12682 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12683 : : (void *)&cmd_config_tx_dynf_specific_item,
12684 : : (void *)&cmd_config_tx_dynf_specific_name,
12685 : : (void *)&cmd_config_tx_dynf_specific_value,
12686 : : NULL,
12687 : : },
12688 : : };
12689 : :
12690 : : /* *** display tx_metadata per port configuration *** */
12691 : : struct cmd_show_tx_metadata_result {
12692 : : cmdline_fixed_string_t cmd_show;
12693 : : cmdline_fixed_string_t cmd_port;
12694 : : cmdline_fixed_string_t cmd_keyword;
12695 : : portid_t cmd_pid;
12696 : : };
12697 : :
12698 : : static void
12699 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12700 : : __rte_unused struct cmdline *cl,
12701 : : __rte_unused void *data)
12702 : : {
12703 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12704 : :
12705 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12706 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12707 : 0 : return;
12708 : : }
12709 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12710 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12711 : 0 : ports[res->cmd_pid].tx_metadata);
12712 : : }
12713 : : }
12714 : :
12715 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12716 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12717 : : cmd_show, "show");
12718 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12719 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12720 : : cmd_port, "port");
12721 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12722 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12723 : : cmd_pid, RTE_UINT16);
12724 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12725 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12726 : : cmd_keyword, "tx_metadata");
12727 : :
12728 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12729 : : .f = cmd_show_tx_metadata_parsed,
12730 : : .data = NULL,
12731 : : .help_str = "show port <port_id> tx_metadata",
12732 : : .tokens = {
12733 : : (void *)&cmd_show_tx_metadata_show,
12734 : : (void *)&cmd_show_tx_metadata_port,
12735 : : (void *)&cmd_show_tx_metadata_pid,
12736 : : (void *)&cmd_show_tx_metadata_keyword,
12737 : : NULL,
12738 : : },
12739 : : };
12740 : :
12741 : : /* *** show fec capability per port configuration *** */
12742 : : struct cmd_show_fec_capability_result {
12743 : : cmdline_fixed_string_t cmd_show;
12744 : : cmdline_fixed_string_t cmd_port;
12745 : : cmdline_fixed_string_t cmd_fec;
12746 : : cmdline_fixed_string_t cmd_keyword;
12747 : : portid_t cmd_pid;
12748 : : };
12749 : :
12750 : : static void
12751 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12752 : : __rte_unused struct cmdline *cl,
12753 : : __rte_unused void *data)
12754 : : {
12755 : : struct cmd_show_fec_capability_result *res = parsed_result;
12756 : : struct rte_eth_fec_capa *speed_fec_capa;
12757 : : unsigned int num;
12758 : : int ret;
12759 : :
12760 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12761 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12762 : 0 : return;
12763 : : }
12764 : :
12765 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12766 : 0 : if (ret == -ENOTSUP) {
12767 : 0 : fprintf(stderr, "Function not implemented\n");
12768 : 0 : return;
12769 : 0 : } else if (ret < 0) {
12770 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12771 : 0 : return;
12772 : : }
12773 : :
12774 : 0 : num = (unsigned int)ret;
12775 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12776 : 0 : if (speed_fec_capa == NULL) {
12777 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12778 : 0 : return;
12779 : : }
12780 : :
12781 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12782 : 0 : if (ret < 0) {
12783 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12784 : 0 : goto out;
12785 : : }
12786 : :
12787 : 0 : show_fec_capability(num, speed_fec_capa);
12788 : 0 : out:
12789 : 0 : free(speed_fec_capa);
12790 : : }
12791 : :
12792 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12793 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12794 : : cmd_show, "show");
12795 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12796 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12797 : : cmd_port, "port");
12798 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12799 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12800 : : cmd_pid, RTE_UINT16);
12801 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12802 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12803 : : cmd_fec, "fec");
12804 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12805 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12806 : : cmd_keyword, "capabilities");
12807 : :
12808 : : static cmdline_parse_inst_t cmd_show_capability = {
12809 : : .f = cmd_show_fec_capability_parsed,
12810 : : .data = NULL,
12811 : : .help_str = "show port <port_id> fec capabilities",
12812 : : .tokens = {
12813 : : (void *)&cmd_show_fec_capability_show,
12814 : : (void *)&cmd_show_fec_capability_port,
12815 : : (void *)&cmd_show_fec_capability_pid,
12816 : : (void *)&cmd_show_fec_capability_fec,
12817 : : (void *)&cmd_show_fec_capability_keyword,
12818 : : NULL,
12819 : : },
12820 : : };
12821 : :
12822 : : /* *** show fec mode per port configuration *** */
12823 : : struct cmd_show_fec_metadata_result {
12824 : : cmdline_fixed_string_t cmd_show;
12825 : : cmdline_fixed_string_t cmd_port;
12826 : : cmdline_fixed_string_t cmd_keyword;
12827 : : portid_t cmd_pid;
12828 : : };
12829 : :
12830 : : static void
12831 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
12832 : : __rte_unused struct cmdline *cl,
12833 : : __rte_unused void *data)
12834 : : {
12835 : : #define FEC_NAME_SIZE 16
12836 : : struct cmd_show_fec_metadata_result *res = parsed_result;
12837 : : uint32_t mode;
12838 : : char buf[FEC_NAME_SIZE];
12839 : : int ret;
12840 : :
12841 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12842 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12843 : 0 : return;
12844 : : }
12845 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
12846 : 0 : if (ret == -ENOTSUP) {
12847 : 0 : fprintf(stderr, "Function not implemented\n");
12848 : 0 : return;
12849 : 0 : } else if (ret < 0) {
12850 : 0 : fprintf(stderr, "Get FEC mode failed\n");
12851 : 0 : return;
12852 : : }
12853 : :
12854 : 0 : switch (mode) {
12855 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
12856 : : strlcpy(buf, "off", sizeof(buf));
12857 : : break;
12858 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
12859 : : strlcpy(buf, "auto", sizeof(buf));
12860 : : break;
12861 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
12862 : : strlcpy(buf, "baser", sizeof(buf));
12863 : : break;
12864 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
12865 : : strlcpy(buf, "rs", sizeof(buf));
12866 : : break;
12867 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
12868 : : strlcpy(buf, "llrs", sizeof(buf));
12869 : : break;
12870 : : default:
12871 : : return;
12872 : : }
12873 : :
12874 : : printf("%s\n", buf);
12875 : : }
12876 : :
12877 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
12878 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12879 : : cmd_show, "show");
12880 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
12881 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12882 : : cmd_port, "port");
12883 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
12884 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
12885 : : cmd_pid, RTE_UINT16);
12886 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
12887 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12888 : : cmd_keyword, "fec_mode");
12889 : :
12890 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
12891 : : .f = cmd_show_fec_mode_parsed,
12892 : : .data = NULL,
12893 : : .help_str = "show port <port_id> fec_mode",
12894 : : .tokens = {
12895 : : (void *)&cmd_show_fec_mode_show,
12896 : : (void *)&cmd_show_fec_mode_port,
12897 : : (void *)&cmd_show_fec_mode_pid,
12898 : : (void *)&cmd_show_fec_mode_keyword,
12899 : : NULL,
12900 : : },
12901 : : };
12902 : :
12903 : : /* *** set fec mode per port configuration *** */
12904 : : struct cmd_set_port_fec_mode {
12905 : : cmdline_fixed_string_t set;
12906 : : cmdline_fixed_string_t port;
12907 : : portid_t port_id;
12908 : : cmdline_fixed_string_t fec_mode;
12909 : : cmdline_fixed_string_t fec_value;
12910 : : };
12911 : :
12912 : : /* Common CLI fields for set fec mode */
12913 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
12914 : : TOKEN_STRING_INITIALIZER
12915 : : (struct cmd_set_port_fec_mode,
12916 : : set, "set");
12917 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
12918 : : TOKEN_STRING_INITIALIZER
12919 : : (struct cmd_set_port_fec_mode,
12920 : : port, "port");
12921 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
12922 : : TOKEN_NUM_INITIALIZER
12923 : : (struct cmd_set_port_fec_mode,
12924 : : port_id, RTE_UINT16);
12925 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
12926 : : TOKEN_STRING_INITIALIZER
12927 : : (struct cmd_set_port_fec_mode,
12928 : : fec_mode, "fec_mode");
12929 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
12930 : : TOKEN_STRING_INITIALIZER
12931 : : (struct cmd_set_port_fec_mode,
12932 : : fec_value, NULL);
12933 : :
12934 : : static void
12935 : 0 : cmd_set_port_fec_mode_parsed(
12936 : : void *parsed_result,
12937 : : __rte_unused struct cmdline *cl,
12938 : : __rte_unused void *data)
12939 : : {
12940 : : struct cmd_set_port_fec_mode *res = parsed_result;
12941 : 0 : uint16_t port_id = res->port_id;
12942 : : uint32_t fec_capa;
12943 : : int ret;
12944 : :
12945 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
12946 : 0 : if (ret < 0) {
12947 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
12948 : : res->fec_value, port_id);
12949 : 0 : return;
12950 : : }
12951 : :
12952 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
12953 : 0 : if (ret == -ENOTSUP) {
12954 : 0 : fprintf(stderr, "Function not implemented\n");
12955 : 0 : return;
12956 : 0 : } else if (ret < 0) {
12957 : 0 : fprintf(stderr, "Set FEC mode failed\n");
12958 : 0 : return;
12959 : : }
12960 : : }
12961 : :
12962 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
12963 : : .f = cmd_set_port_fec_mode_parsed,
12964 : : .data = NULL,
12965 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
12966 : : .tokens = {
12967 : : (void *)&cmd_set_port_fec_mode_set,
12968 : : (void *)&cmd_set_port_fec_mode_port,
12969 : : (void *)&cmd_set_port_fec_mode_port_id,
12970 : : (void *)&cmd_set_port_fec_mode_str,
12971 : : (void *)&cmd_set_port_fec_mode_value,
12972 : : NULL,
12973 : : },
12974 : : };
12975 : :
12976 : : /* *** set available descriptors threshold for an RxQ of a port *** */
12977 : : struct cmd_set_rxq_avail_thresh_result {
12978 : : cmdline_fixed_string_t set;
12979 : : cmdline_fixed_string_t port;
12980 : : uint16_t port_num;
12981 : : cmdline_fixed_string_t rxq;
12982 : : uint16_t rxq_num;
12983 : : cmdline_fixed_string_t avail_thresh;
12984 : : uint8_t avail_thresh_num;
12985 : : };
12986 : :
12987 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
12988 : : __rte_unused struct cmdline *cl,
12989 : : __rte_unused void *data)
12990 : : {
12991 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
12992 : : int ret = 0;
12993 : :
12994 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
12995 : 0 : && (strcmp(res->rxq, "rxq") == 0)
12996 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
12997 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
12998 : 0 : res->avail_thresh_num);
12999 : 0 : if (ret < 0)
13000 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13001 : :
13002 : 0 : }
13003 : :
13004 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13005 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13006 : : set, "set");
13007 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13008 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13009 : : port, "port");
13010 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13011 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13012 : : port_num, RTE_UINT16);
13013 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13014 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13015 : : rxq, "rxq");
13016 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13017 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13018 : : rxq_num, RTE_UINT16);
13019 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13020 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13021 : : avail_thresh, "avail_thresh");
13022 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13023 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13024 : : avail_thresh_num, RTE_UINT8);
13025 : :
13026 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13027 : : .f = cmd_set_rxq_avail_thresh_parsed,
13028 : : .data = (void *)0,
13029 : : .help_str =
13030 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13031 : : "Set available descriptors threshold for Rx queue",
13032 : : .tokens = {
13033 : : (void *)&cmd_set_rxq_avail_thresh_set,
13034 : : (void *)&cmd_set_rxq_avail_thresh_port,
13035 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13036 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13037 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13038 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13039 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13040 : : NULL,
13041 : : },
13042 : : };
13043 : :
13044 : : /* show port supported ptypes */
13045 : :
13046 : : /* Common result structure for show port ptypes */
13047 : : struct cmd_show_port_supported_ptypes_result {
13048 : : cmdline_fixed_string_t show;
13049 : : cmdline_fixed_string_t port;
13050 : : portid_t port_id;
13051 : : cmdline_fixed_string_t ptypes;
13052 : : };
13053 : :
13054 : : /* Common CLI fields for show port ptypes */
13055 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13056 : : TOKEN_STRING_INITIALIZER
13057 : : (struct cmd_show_port_supported_ptypes_result,
13058 : : show, "show");
13059 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13060 : : TOKEN_STRING_INITIALIZER
13061 : : (struct cmd_show_port_supported_ptypes_result,
13062 : : port, "port");
13063 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13064 : : TOKEN_NUM_INITIALIZER
13065 : : (struct cmd_show_port_supported_ptypes_result,
13066 : : port_id, RTE_UINT16);
13067 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13068 : : TOKEN_STRING_INITIALIZER
13069 : : (struct cmd_show_port_supported_ptypes_result,
13070 : : ptypes, "ptypes");
13071 : :
13072 : : static void
13073 : 0 : cmd_show_port_supported_ptypes_parsed(
13074 : : void *parsed_result,
13075 : : __rte_unused struct cmdline *cl,
13076 : : __rte_unused void *data)
13077 : : {
13078 : : #define RSVD_PTYPE_MASK 0xf0000000
13079 : : #define MAX_PTYPES_PER_LAYER 16
13080 : : #define LTYPE_NAMESIZE 32
13081 : : #define PTYPE_NAMESIZE 256
13082 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13083 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13084 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13085 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13086 : 0 : uint16_t port_id = res->port_id;
13087 : : int ret, i;
13088 : :
13089 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13090 : 0 : if (ret < 0)
13091 : 0 : return;
13092 : :
13093 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13094 : :
13095 : 0 : switch (ptype_mask) {
13096 : : case RTE_PTYPE_L2_MASK:
13097 : : strlcpy(ltype, "L2", sizeof(ltype));
13098 : : break;
13099 : : case RTE_PTYPE_L3_MASK:
13100 : : strlcpy(ltype, "L3", sizeof(ltype));
13101 : : break;
13102 : : case RTE_PTYPE_L4_MASK:
13103 : : strlcpy(ltype, "L4", sizeof(ltype));
13104 : : break;
13105 : : case RTE_PTYPE_TUNNEL_MASK:
13106 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13107 : : break;
13108 : : case RTE_PTYPE_INNER_L2_MASK:
13109 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13110 : : break;
13111 : : case RTE_PTYPE_INNER_L3_MASK:
13112 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13113 : : break;
13114 : : case RTE_PTYPE_INNER_L4_MASK:
13115 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13116 : : break;
13117 : : default:
13118 : : return;
13119 : : }
13120 : :
13121 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13122 : : ptype_mask, ptypes,
13123 : : MAX_PTYPES_PER_LAYER);
13124 : :
13125 : 0 : if (ret > 0)
13126 : : printf("Supported %s ptypes:\n", ltype);
13127 : : else
13128 : : printf("%s ptypes unsupported\n", ltype);
13129 : :
13130 : 0 : for (i = 0; i < ret; ++i) {
13131 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13132 : : printf("%s\n", buf);
13133 : : }
13134 : :
13135 : 0 : ptype_mask <<= 4;
13136 : : }
13137 : : }
13138 : :
13139 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13140 : : .f = cmd_show_port_supported_ptypes_parsed,
13141 : : .data = NULL,
13142 : : .help_str = "show port <port_id> ptypes",
13143 : : .tokens = {
13144 : : (void *)&cmd_show_port_supported_ptypes_show,
13145 : : (void *)&cmd_show_port_supported_ptypes_port,
13146 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13147 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13148 : : NULL,
13149 : : },
13150 : : };
13151 : :
13152 : : /* *** display rx/tx descriptor status *** */
13153 : : struct cmd_show_rx_tx_desc_status_result {
13154 : : cmdline_fixed_string_t cmd_show;
13155 : : cmdline_fixed_string_t cmd_port;
13156 : : cmdline_fixed_string_t cmd_keyword;
13157 : : cmdline_fixed_string_t cmd_desc;
13158 : : cmdline_fixed_string_t cmd_status;
13159 : : portid_t cmd_pid;
13160 : : portid_t cmd_qid;
13161 : : portid_t cmd_did;
13162 : : };
13163 : :
13164 : : static void
13165 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13166 : : __rte_unused struct cmdline *cl,
13167 : : __rte_unused void *data)
13168 : : {
13169 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13170 : : int rc;
13171 : :
13172 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13173 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13174 : 0 : fprintf(stderr,
13175 : : "Invalid input: port id = %d, queue id = %d\n",
13176 : 0 : res->cmd_pid, res->cmd_qid);
13177 : 0 : return;
13178 : : }
13179 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13180 : 0 : res->cmd_did);
13181 : 0 : if (rc < 0) {
13182 : 0 : fprintf(stderr,
13183 : : "Invalid input: queue id = %d, desc id = %d\n",
13184 : 0 : res->cmd_qid, res->cmd_did);
13185 : 0 : return;
13186 : : }
13187 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13188 : : printf("Desc status = AVAILABLE\n");
13189 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13190 : : printf("Desc status = DONE\n");
13191 : : else
13192 : : printf("Desc status = UNAVAILABLE\n");
13193 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13194 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13195 : 0 : fprintf(stderr,
13196 : : "Invalid input: port id = %d, queue id = %d\n",
13197 : 0 : res->cmd_pid, res->cmd_qid);
13198 : 0 : return;
13199 : : }
13200 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13201 : 0 : res->cmd_did);
13202 : 0 : if (rc < 0) {
13203 : 0 : fprintf(stderr,
13204 : : "Invalid input: queue id = %d, desc id = %d\n",
13205 : 0 : res->cmd_qid, res->cmd_did);
13206 : 0 : return;
13207 : : }
13208 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13209 : : printf("Desc status = FULL\n");
13210 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13211 : : printf("Desc status = DONE\n");
13212 : : else
13213 : : printf("Desc status = UNAVAILABLE\n");
13214 : : }
13215 : : }
13216 : :
13217 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13218 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13219 : : cmd_show, "show");
13220 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13221 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13222 : : cmd_port, "port");
13223 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13224 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13225 : : cmd_pid, RTE_UINT16);
13226 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13227 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13228 : : cmd_keyword, "rxq#txq");
13229 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13230 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13231 : : cmd_qid, RTE_UINT16);
13232 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13233 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13234 : : cmd_desc, "desc");
13235 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13236 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13237 : : cmd_did, RTE_UINT16);
13238 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13239 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13240 : : cmd_status, "status");
13241 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13242 : : .f = cmd_show_rx_tx_desc_status_parsed,
13243 : : .data = NULL,
13244 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13245 : : "status",
13246 : : .tokens = {
13247 : : (void *)&cmd_show_rx_tx_desc_status_show,
13248 : : (void *)&cmd_show_rx_tx_desc_status_port,
13249 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13250 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13251 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13252 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13253 : : (void *)&cmd_show_rx_tx_desc_status_did,
13254 : : (void *)&cmd_show_rx_tx_desc_status_status,
13255 : : NULL,
13256 : : },
13257 : : };
13258 : :
13259 : : /* *** display rx/tx queue descriptor used count *** */
13260 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13261 : : cmdline_fixed_string_t cmd_show;
13262 : : cmdline_fixed_string_t cmd_port;
13263 : : cmdline_fixed_string_t cmd_dir;
13264 : : cmdline_fixed_string_t cmd_desc;
13265 : : cmdline_fixed_string_t cmd_used;
13266 : : cmdline_fixed_string_t cmd_count;
13267 : : portid_t cmd_pid;
13268 : : portid_t cmd_qid;
13269 : : };
13270 : :
13271 : : static void
13272 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13273 : : __rte_unused void *data)
13274 : : {
13275 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13276 : : int rc;
13277 : :
13278 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13279 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13280 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13281 : 0 : res->cmd_pid, res->cmd_qid);
13282 : 0 : return;
13283 : : }
13284 : :
13285 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13286 : 0 : if (rc < 0) {
13287 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13288 : 0 : res->cmd_qid);
13289 : 0 : return;
13290 : : }
13291 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13292 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13293 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13294 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13295 : 0 : res->cmd_pid, res->cmd_qid);
13296 : 0 : return;
13297 : : }
13298 : :
13299 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13300 : 0 : if (rc < 0) {
13301 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13302 : 0 : res->cmd_qid);
13303 : 0 : return;
13304 : : }
13305 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13306 : : }
13307 : : }
13308 : :
13309 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13310 : : TOKEN_STRING_INITIALIZER
13311 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13312 : : cmd_show, "show");
13313 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13314 : : TOKEN_STRING_INITIALIZER
13315 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13316 : : cmd_port, "port");
13317 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13318 : : TOKEN_NUM_INITIALIZER
13319 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13320 : : cmd_pid, RTE_UINT16);
13321 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13322 : : TOKEN_STRING_INITIALIZER
13323 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13324 : : cmd_dir, "rxq#txq");
13325 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13326 : : TOKEN_NUM_INITIALIZER
13327 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13328 : : cmd_qid, RTE_UINT16);
13329 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13330 : : TOKEN_STRING_INITIALIZER
13331 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13332 : : cmd_desc, "desc");
13333 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13334 : : TOKEN_STRING_INITIALIZER
13335 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13336 : : cmd_count, "used");
13337 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13338 : : TOKEN_STRING_INITIALIZER
13339 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13340 : : cmd_count, "count");
13341 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13342 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13343 : : .data = NULL,
13344 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13345 : : .tokens = {
13346 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13347 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13348 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13349 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13350 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13351 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13352 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13353 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13354 : : NULL,
13355 : : },
13356 : : };
13357 : :
13358 : : /* Common result structure for set port ptypes */
13359 : : struct cmd_set_port_ptypes_result {
13360 : : cmdline_fixed_string_t set;
13361 : : cmdline_fixed_string_t port;
13362 : : portid_t port_id;
13363 : : cmdline_fixed_string_t ptype_mask;
13364 : : uint32_t mask;
13365 : : };
13366 : :
13367 : : /* Common CLI fields for set port ptypes */
13368 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13369 : : TOKEN_STRING_INITIALIZER
13370 : : (struct cmd_set_port_ptypes_result,
13371 : : set, "set");
13372 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13373 : : TOKEN_STRING_INITIALIZER
13374 : : (struct cmd_set_port_ptypes_result,
13375 : : port, "port");
13376 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13377 : : TOKEN_NUM_INITIALIZER
13378 : : (struct cmd_set_port_ptypes_result,
13379 : : port_id, RTE_UINT16);
13380 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13381 : : TOKEN_STRING_INITIALIZER
13382 : : (struct cmd_set_port_ptypes_result,
13383 : : ptype_mask, "ptype_mask");
13384 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13385 : : TOKEN_NUM_INITIALIZER
13386 : : (struct cmd_set_port_ptypes_result,
13387 : : mask, RTE_UINT32);
13388 : :
13389 : : static void
13390 : 0 : cmd_set_port_ptypes_parsed(
13391 : : void *parsed_result,
13392 : : __rte_unused struct cmdline *cl,
13393 : : __rte_unused void *data)
13394 : : {
13395 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13396 : : #define PTYPE_NAMESIZE 256
13397 : : char ptype_name[PTYPE_NAMESIZE];
13398 : 0 : uint16_t port_id = res->port_id;
13399 : 0 : uint32_t ptype_mask = res->mask;
13400 : : int ret, i;
13401 : :
13402 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13403 : : NULL, 0);
13404 : 0 : if (ret <= 0) {
13405 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13406 : : port_id);
13407 : 0 : return;
13408 : : }
13409 : :
13410 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13411 : :
13412 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13413 : 0 : if (ret < 0) {
13414 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13415 : : port_id);
13416 : 0 : return;
13417 : : }
13418 : :
13419 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13420 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13421 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13422 : : printf("%s\n", ptype_name);
13423 : : }
13424 : :
13425 : 0 : clear_ptypes = false;
13426 : : }
13427 : :
13428 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13429 : : .f = cmd_set_port_ptypes_parsed,
13430 : : .data = NULL,
13431 : : .help_str = "set port <port_id> ptype_mask <mask>",
13432 : : .tokens = {
13433 : : (void *)&cmd_set_port_ptypes_set,
13434 : : (void *)&cmd_set_port_ptypes_port,
13435 : : (void *)&cmd_set_port_ptypes_port_id,
13436 : : (void *)&cmd_set_port_ptypes_mask_str,
13437 : : (void *)&cmd_set_port_ptypes_mask_u32,
13438 : : NULL,
13439 : : },
13440 : : };
13441 : :
13442 : : /* *** display mac addresses added to a port *** */
13443 : : struct cmd_showport_macs_result {
13444 : : cmdline_fixed_string_t cmd_show;
13445 : : cmdline_fixed_string_t cmd_port;
13446 : : cmdline_fixed_string_t cmd_keyword;
13447 : : portid_t cmd_pid;
13448 : : };
13449 : :
13450 : : static void
13451 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13452 : : __rte_unused struct cmdline *cl,
13453 : : __rte_unused void *data)
13454 : : {
13455 : : struct cmd_showport_macs_result *res = parsed_result;
13456 : :
13457 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13458 : : return;
13459 : :
13460 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13461 : 0 : show_macs(res->cmd_pid);
13462 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13463 : 0 : show_mcast_macs(res->cmd_pid);
13464 : : }
13465 : :
13466 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13467 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13468 : : cmd_show, "show");
13469 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13470 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13471 : : cmd_port, "port");
13472 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13473 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13474 : : cmd_pid, RTE_UINT16);
13475 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13476 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13477 : : cmd_keyword, "macs#mcast_macs");
13478 : :
13479 : : static cmdline_parse_inst_t cmd_showport_macs = {
13480 : : .f = cmd_showport_macs_parsed,
13481 : : .data = NULL,
13482 : : .help_str = "show port <port_id> macs|mcast_macs",
13483 : : .tokens = {
13484 : : (void *)&cmd_showport_macs_show,
13485 : : (void *)&cmd_showport_macs_port,
13486 : : (void *)&cmd_showport_macs_pid,
13487 : : (void *)&cmd_showport_macs_keyword,
13488 : : NULL,
13489 : : },
13490 : : };
13491 : :
13492 : : /* *** show flow transfer proxy port ID for the given port *** */
13493 : : struct cmd_show_port_flow_transfer_proxy_result {
13494 : : cmdline_fixed_string_t show;
13495 : : cmdline_fixed_string_t port;
13496 : : portid_t port_id;
13497 : : cmdline_fixed_string_t flow;
13498 : : cmdline_fixed_string_t transfer;
13499 : : cmdline_fixed_string_t proxy;
13500 : : };
13501 : :
13502 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13503 : : TOKEN_STRING_INITIALIZER
13504 : : (struct cmd_show_port_flow_transfer_proxy_result,
13505 : : show, "show");
13506 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13507 : : TOKEN_STRING_INITIALIZER
13508 : : (struct cmd_show_port_flow_transfer_proxy_result,
13509 : : port, "port");
13510 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13511 : : TOKEN_NUM_INITIALIZER
13512 : : (struct cmd_show_port_flow_transfer_proxy_result,
13513 : : port_id, RTE_UINT16);
13514 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13515 : : TOKEN_STRING_INITIALIZER
13516 : : (struct cmd_show_port_flow_transfer_proxy_result,
13517 : : flow, "flow");
13518 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13519 : : TOKEN_STRING_INITIALIZER
13520 : : (struct cmd_show_port_flow_transfer_proxy_result,
13521 : : transfer, "transfer");
13522 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13523 : : TOKEN_STRING_INITIALIZER
13524 : : (struct cmd_show_port_flow_transfer_proxy_result,
13525 : : proxy, "proxy");
13526 : :
13527 : : static void
13528 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13529 : : __rte_unused struct cmdline *cl,
13530 : : __rte_unused void *data)
13531 : : {
13532 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13533 : : portid_t proxy_port_id;
13534 : : int ret;
13535 : :
13536 : : printf("\n");
13537 : :
13538 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13539 : 0 : if (ret != 0) {
13540 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13541 : : rte_strerror(-ret));
13542 : 0 : return;
13543 : : }
13544 : :
13545 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13546 : : }
13547 : :
13548 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13549 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13550 : : .data = NULL,
13551 : : .help_str = "show port <port_id> flow transfer proxy",
13552 : : .tokens = {
13553 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13554 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13555 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13556 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13557 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13558 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13559 : : NULL,
13560 : : }
13561 : : };
13562 : :
13563 : : /* *** configure port txq affinity value *** */
13564 : : struct cmd_config_tx_affinity_map {
13565 : : cmdline_fixed_string_t port;
13566 : : cmdline_fixed_string_t config;
13567 : : portid_t portid;
13568 : : cmdline_fixed_string_t txq;
13569 : : uint16_t qid;
13570 : : cmdline_fixed_string_t affinity;
13571 : : uint8_t value;
13572 : : };
13573 : :
13574 : : static void
13575 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13576 : : __rte_unused struct cmdline *cl,
13577 : : __rte_unused void *data)
13578 : : {
13579 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13580 : : int ret;
13581 : :
13582 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13583 : : return;
13584 : :
13585 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13586 : : printf("Invalid port id\n");
13587 : 0 : return;
13588 : : }
13589 : :
13590 : 0 : if (strcmp(res->txq, "txq")) {
13591 : : printf("Unknown parameter\n");
13592 : 0 : return;
13593 : : }
13594 : 0 : if (tx_queue_id_is_invalid(res->qid))
13595 : : return;
13596 : :
13597 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13598 : 0 : if (ret < 0) {
13599 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13600 : : strerror(-ret));
13601 : 0 : return;
13602 : : }
13603 : :
13604 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13605 : 0 : if (ret != 0) {
13606 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13607 : : rte_strerror(-ret));
13608 : 0 : return;
13609 : : }
13610 : : }
13611 : :
13612 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13613 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13614 : : port, "port");
13615 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13616 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13617 : : config, "config");
13618 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13619 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13620 : : portid, RTE_UINT16);
13621 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13622 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13623 : : txq, "txq");
13624 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13625 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13626 : : qid, RTE_UINT16);
13627 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13628 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13629 : : affinity, "affinity");
13630 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13631 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13632 : : value, RTE_UINT8);
13633 : :
13634 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13635 : : .f = cmd_config_tx_affinity_map_parsed,
13636 : : .data = (void *)0,
13637 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13638 : : .tokens = {
13639 : : (void *)&cmd_config_tx_affinity_map_port,
13640 : : (void *)&cmd_config_tx_affinity_map_config,
13641 : : (void *)&cmd_config_tx_affinity_map_portid,
13642 : : (void *)&cmd_config_tx_affinity_map_txq,
13643 : : (void *)&cmd_config_tx_affinity_map_qid,
13644 : : (void *)&cmd_config_tx_affinity_map_affinity,
13645 : : (void *)&cmd_config_tx_affinity_map_value,
13646 : : NULL,
13647 : : },
13648 : : };
13649 : :
13650 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
13651 : : struct cmd_dev_led_result {
13652 : : cmdline_fixed_string_t set;
13653 : : cmdline_fixed_string_t port;
13654 : : portid_t port_id;
13655 : : cmdline_fixed_string_t led;
13656 : : cmdline_fixed_string_t state;
13657 : : };
13658 : :
13659 : : static void
13660 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
13661 : : __rte_unused struct cmdline *cl,
13662 : : __rte_unused void *data)
13663 : : {
13664 : : struct cmd_dev_led_result *res = parsed_result;
13665 : :
13666 : 0 : if (strcmp(res->state, "on") == 0)
13667 : 0 : set_dev_led(res->port_id, true);
13668 : : else
13669 : 0 : set_dev_led(res->port_id, false);
13670 : 0 : }
13671 : :
13672 : : static cmdline_parse_token_string_t cmd_dev_led_set =
13673 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
13674 : : static cmdline_parse_token_string_t cmd_dev_led_port =
13675 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
13676 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
13677 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
13678 : : static cmdline_parse_token_string_t cmd_dev_led =
13679 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
13680 : : static cmdline_parse_token_string_t cmd_dev_state =
13681 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
13682 : :
13683 : : static cmdline_parse_inst_t cmd_set_dev_led = {
13684 : : .f = cmd_set_dev_led_parsed,
13685 : : .data = NULL,
13686 : : .help_str = "set port <port_id> led <on/off>",
13687 : : .tokens = {
13688 : : (void *)&cmd_dev_led_set,
13689 : : (void *)&cmd_dev_led_port,
13690 : : (void *)&cmd_dev_led_port_id,
13691 : : (void *)&cmd_dev_led,
13692 : : (void *)&cmd_dev_state,
13693 : : NULL,
13694 : : },
13695 : : };
13696 : :
13697 : : /* ******************************************************************************** */
13698 : :
13699 : : /* list of instructions */
13700 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13701 : : &cmd_help_brief,
13702 : : &cmd_help_long,
13703 : : &cmd_quit,
13704 : : &cmd_load_from_file,
13705 : : &cmd_showport,
13706 : : &cmd_showqueue,
13707 : : &cmd_showeeprom,
13708 : : &cmd_seteeprom,
13709 : : &cmd_showportall,
13710 : : &cmd_representor_info,
13711 : : &cmd_showdevice,
13712 : : &cmd_showcfg,
13713 : : &cmd_showfwdall,
13714 : : &cmd_start,
13715 : : &cmd_start_tx_first,
13716 : : &cmd_start_tx_first_n,
13717 : : &cmd_set_link_up,
13718 : : &cmd_set_link_down,
13719 : : &cmd_reset,
13720 : : &cmd_set_numbers,
13721 : : &cmd_set_log,
13722 : : &cmd_set_rxoffs,
13723 : : &cmd_set_rxpkts,
13724 : : &cmd_set_rxhdrs,
13725 : : &cmd_set_txpkts,
13726 : : &cmd_set_txsplit,
13727 : : &cmd_set_txtimes,
13728 : : &cmd_set_fwd_list,
13729 : : &cmd_set_fwd_mask,
13730 : : &cmd_set_fwd_mode,
13731 : : &cmd_set_fwd_retry_mode,
13732 : : &cmd_set_burst_tx_retry,
13733 : : &cmd_set_promisc_mode_one,
13734 : : &cmd_set_promisc_mode_all,
13735 : : &cmd_set_allmulti_mode_one,
13736 : : &cmd_set_allmulti_mode_all,
13737 : : &cmd_set_flush_rx,
13738 : : &cmd_set_link_check,
13739 : : &cmd_vlan_offload,
13740 : : &cmd_vlan_tpid,
13741 : : &cmd_rx_vlan_filter_all,
13742 : : &cmd_rx_vlan_filter,
13743 : : &cmd_tx_vlan_set,
13744 : : &cmd_tx_vlan_set_qinq,
13745 : : &cmd_tx_vlan_reset,
13746 : : &cmd_tx_vlan_set_pvid,
13747 : : &cmd_csum_set,
13748 : : &cmd_csum_show,
13749 : : &cmd_csum_tunnel,
13750 : : &cmd_csum_mac_swap,
13751 : : &cmd_tso_set,
13752 : : &cmd_tso_show,
13753 : : &cmd_tunnel_tso_set,
13754 : : &cmd_tunnel_tso_show,
13755 : : #ifdef RTE_LIB_GRO
13756 : : &cmd_gro_enable,
13757 : : &cmd_gro_flush,
13758 : : &cmd_gro_show,
13759 : : #endif
13760 : : #ifdef RTE_LIB_GSO
13761 : : &cmd_gso_enable,
13762 : : &cmd_gso_size,
13763 : : &cmd_gso_show,
13764 : : #endif
13765 : : &cmd_link_flow_control_set,
13766 : : &cmd_link_flow_control_set_rx,
13767 : : &cmd_link_flow_control_set_tx,
13768 : : &cmd_link_flow_control_set_hw,
13769 : : &cmd_link_flow_control_set_lw,
13770 : : &cmd_link_flow_control_set_pt,
13771 : : &cmd_link_flow_control_set_xon,
13772 : : &cmd_link_flow_control_set_macfwd,
13773 : : &cmd_link_flow_control_set_autoneg,
13774 : : &cmd_link_flow_control_show,
13775 : : &cmd_priority_flow_control_set,
13776 : : &cmd_queue_priority_flow_control_set,
13777 : : &cmd_config_dcb,
13778 : : &cmd_read_rxd_txd,
13779 : : &cmd_stop,
13780 : : &cmd_mac_addr,
13781 : : &cmd_set_fwd_eth_peer,
13782 : : &cmd_set_qmap,
13783 : : &cmd_set_xstats_hide_zero,
13784 : : &cmd_set_xstats_show_state,
13785 : : &cmd_set_xstats_hide_disabled,
13786 : : &cmd_operate_set_counter,
13787 : : &cmd_set_record_core_cycles,
13788 : : &cmd_set_record_burst_stats,
13789 : : &cmd_operate_port,
13790 : : &cmd_operate_specific_port,
13791 : : &cmd_operate_attach_port,
13792 : : &cmd_operate_detach_port,
13793 : : &cmd_operate_detach_device,
13794 : : &cmd_set_port_setup_on,
13795 : : &cmd_config_speed_all,
13796 : : &cmd_config_speed_specific,
13797 : : &cmd_config_speed_lanes_all,
13798 : : &cmd_config_speed_lanes_specific,
13799 : : &cmd_show_speed_lanes,
13800 : : &cmd_config_loopback_all,
13801 : : &cmd_config_loopback_specific,
13802 : : &cmd_config_rx_tx,
13803 : : &cmd_config_mtu,
13804 : : &cmd_config_max_pkt_len,
13805 : : &cmd_config_max_lro_pkt_size,
13806 : : &cmd_config_rx_mode_flag,
13807 : : &cmd_config_rss,
13808 : : &cmd_config_rxtx_ring_size,
13809 : : &cmd_config_rxtx_queue,
13810 : : &cmd_config_deferred_start_rxtx_queue,
13811 : : &cmd_setup_rxtx_queue,
13812 : : &cmd_config_rss_reta,
13813 : : &cmd_showport_reta,
13814 : : &cmd_showport_macs,
13815 : : &cmd_show_port_flow_transfer_proxy,
13816 : : &cmd_config_burst,
13817 : : &cmd_config_thresh,
13818 : : &cmd_config_threshold,
13819 : : &cmd_set_uc_hash_filter,
13820 : : &cmd_set_uc_all_hash_filter,
13821 : : &cmd_vf_mac_addr_filter,
13822 : : &cmd_queue_rate_limit,
13823 : : &cmd_tunnel_udp_config,
13824 : : &cmd_showport_rss_hash,
13825 : : &cmd_showport_rss_hash_key,
13826 : : &cmd_showport_rss_hash_algo,
13827 : : &cmd_config_rss_hash_key,
13828 : : &cmd_config_rss_hash_algo,
13829 : : &cmd_cleanup_txq_mbufs,
13830 : : &cmd_dump,
13831 : : &cmd_dump_one,
13832 : : &cmd_flow,
13833 : : &cmd_show_port_meter_cap,
13834 : : &cmd_add_port_meter_profile_srtcm,
13835 : : &cmd_add_port_meter_profile_trtcm,
13836 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
13837 : : &cmd_del_port_meter_profile,
13838 : : &cmd_create_port_meter,
13839 : : &cmd_enable_port_meter,
13840 : : &cmd_disable_port_meter,
13841 : : &cmd_del_port_meter,
13842 : : &cmd_del_port_meter_policy,
13843 : : &cmd_set_port_meter_profile,
13844 : : &cmd_set_port_meter_dscp_table,
13845 : : &cmd_set_port_meter_vlan_table,
13846 : : &cmd_set_port_meter_in_proto,
13847 : : &cmd_get_port_meter_in_proto,
13848 : : &cmd_get_port_meter_in_proto_prio,
13849 : : &cmd_set_port_meter_stats_mask,
13850 : : &cmd_show_port_meter_stats,
13851 : : &cmd_mcast_addr,
13852 : : &cmd_mcast_addr_flush,
13853 : : &cmd_set_vf_vlan_anti_spoof,
13854 : : &cmd_set_vf_mac_anti_spoof,
13855 : : &cmd_set_vf_vlan_stripq,
13856 : : &cmd_set_vf_vlan_insert,
13857 : : &cmd_set_tx_loopback,
13858 : : &cmd_set_all_queues_drop_en,
13859 : : &cmd_set_vf_traffic,
13860 : : &cmd_set_vf_rxmode,
13861 : : &cmd_vf_rate_limit,
13862 : : &cmd_vf_rxvlan_filter,
13863 : : &cmd_set_vf_mac_addr,
13864 : : &cmd_set_vxlan,
13865 : : &cmd_set_vxlan_tos_ttl,
13866 : : &cmd_set_vxlan_with_vlan,
13867 : : &cmd_set_nvgre,
13868 : : &cmd_set_nvgre_with_vlan,
13869 : : &cmd_set_l2_encap,
13870 : : &cmd_set_l2_encap_with_vlan,
13871 : : &cmd_set_l2_decap,
13872 : : &cmd_set_l2_decap_with_vlan,
13873 : : &cmd_set_mplsogre_encap,
13874 : : &cmd_set_mplsogre_encap_with_vlan,
13875 : : &cmd_set_mplsogre_decap,
13876 : : &cmd_set_mplsogre_decap_with_vlan,
13877 : : &cmd_set_mplsoudp_encap,
13878 : : &cmd_set_mplsoudp_encap_with_vlan,
13879 : : &cmd_set_mplsoudp_decap,
13880 : : &cmd_set_mplsoudp_decap_with_vlan,
13881 : : &cmd_set_conntrack_common,
13882 : : &cmd_set_conntrack_dir,
13883 : : &cmd_show_vf_stats,
13884 : : &cmd_clear_vf_stats,
13885 : : &cmd_show_port_supported_ptypes,
13886 : : &cmd_set_port_ptypes,
13887 : : &cmd_show_port_tm_cap,
13888 : : &cmd_show_port_tm_level_cap,
13889 : : &cmd_show_port_tm_node,
13890 : : &cmd_show_port_tm_node_cap,
13891 : : &cmd_show_port_tm_node_type,
13892 : : &cmd_show_port_tm_node_stats,
13893 : : &cmd_add_port_tm_node_shaper_profile,
13894 : : &cmd_del_port_tm_node_shaper_profile,
13895 : : &cmd_add_port_tm_node_shared_shaper,
13896 : : &cmd_del_port_tm_node_shared_shaper,
13897 : : &cmd_add_port_tm_node_wred_profile,
13898 : : &cmd_del_port_tm_node_wred_profile,
13899 : : &cmd_set_port_tm_node_shaper_profile,
13900 : : &cmd_add_port_tm_nonleaf_node,
13901 : : &cmd_add_port_tm_nonleaf_node_pmode,
13902 : : &cmd_add_port_tm_leaf_node,
13903 : : &cmd_del_port_tm_node,
13904 : : &cmd_set_port_tm_node_parent,
13905 : : &cmd_suspend_port_tm_node,
13906 : : &cmd_resume_port_tm_node,
13907 : : &cmd_port_tm_hierarchy_commit,
13908 : : &cmd_port_tm_mark_ip_ecn,
13909 : : &cmd_port_tm_mark_ip_dscp,
13910 : : &cmd_port_tm_mark_vlan_dei,
13911 : : &cmd_cfg_tunnel_udp_port,
13912 : : &cmd_rx_offload_get_capa,
13913 : : &cmd_rx_offload_get_configuration,
13914 : : &cmd_config_per_port_rx_offload,
13915 : : &cmd_config_all_port_rx_offload,
13916 : : &cmd_config_per_queue_rx_offload,
13917 : : &cmd_tx_offload_get_capa,
13918 : : &cmd_tx_offload_get_configuration,
13919 : : &cmd_config_per_port_tx_offload,
13920 : : &cmd_config_all_port_tx_offload,
13921 : : &cmd_config_per_queue_tx_offload,
13922 : : #ifdef RTE_LIB_BPF
13923 : : &cmd_operate_bpf_ld_parse,
13924 : : &cmd_operate_bpf_unld_parse,
13925 : : #endif
13926 : : &cmd_config_tx_metadata_specific,
13927 : : &cmd_show_tx_metadata,
13928 : : &cmd_show_rx_tx_desc_status,
13929 : : &cmd_show_rx_tx_queue_desc_used_count,
13930 : : &cmd_set_raw,
13931 : : &cmd_show_set_raw,
13932 : : &cmd_show_set_raw_all,
13933 : : &cmd_config_tx_dynf_specific,
13934 : : &cmd_show_fec_mode,
13935 : : &cmd_set_fec_mode,
13936 : : &cmd_set_rxq_avail_thresh,
13937 : : &cmd_show_capability,
13938 : : &cmd_set_flex_is_pattern,
13939 : : &cmd_set_flex_spec_pattern,
13940 : : &cmd_show_port_cman_capa,
13941 : : &cmd_show_port_cman_config,
13942 : : &cmd_set_port_cman_config,
13943 : : &cmd_config_tx_affinity_map,
13944 : : &cmd_set_dev_led,
13945 : : NULL,
13946 : : };
13947 : :
13948 : : void
13949 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
13950 : : {
13951 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
13952 : 0 : }
13953 : :
13954 : : int
13955 : 0 : init_cmdline(void)
13956 : : {
13957 : : struct testpmd_driver_commands *c;
13958 : : unsigned int count;
13959 : : unsigned int i;
13960 : :
13961 : : /* initialize non-constant commands */
13962 : 0 : cmd_set_fwd_mode_init();
13963 : 0 : cmd_set_fwd_retry_mode_init();
13964 : :
13965 : : count = 0;
13966 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
13967 : 0 : count++;
13968 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13969 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
13970 : 0 : count++;
13971 : : }
13972 : :
13973 : : /* cmdline expects a NULL terminated array */
13974 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
13975 : 0 : if (main_ctx == NULL)
13976 : : return -1;
13977 : :
13978 : : count = 0;
13979 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
13980 : 0 : main_ctx[count] = builtin_ctx[i];
13981 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13982 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
13983 : 0 : main_ctx[count] = c->commands[i].ctx;
13984 : : }
13985 : :
13986 : : return 0;
13987 : : }
13988 : :
13989 : : /* read cmdline commands from file */
13990 : : void
13991 : 0 : cmdline_read_from_file(const char *filename)
13992 : : {
13993 : : struct cmdline *cl;
13994 : : int fd = -1;
13995 : :
13996 : : /* cmdline_file_new does not produce any output
13997 : : * so when echoing is requested we open filename directly
13998 : : * and then pass that to cmdline_new with stdout as the output path.
13999 : : */
14000 : 0 : if (!echo_cmdline_file) {
14001 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14002 : : } else {
14003 : : fd = open(filename, O_RDONLY);
14004 : 0 : if (fd < 0) {
14005 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14006 : 0 : filename, strerror(errno));
14007 : 0 : return;
14008 : : }
14009 : :
14010 : 0 : cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO);
14011 : : }
14012 : 0 : if (cl == NULL) {
14013 : 0 : fprintf(stderr,
14014 : : "Failed to create file based cmdline context: %s\n",
14015 : : filename);
14016 : 0 : goto end;
14017 : : }
14018 : :
14019 : 0 : cmdline_interact(cl);
14020 : 0 : cmdline_quit(cl);
14021 : :
14022 : 0 : cmdline_free(cl);
14023 : :
14024 : : printf("Read CLI commands from %s\n", filename);
14025 : :
14026 : 0 : end:
14027 : 0 : if (fd >= 0)
14028 : 0 : close(fd);
14029 : : }
14030 : :
14031 : : void
14032 : 0 : prompt_exit(void)
14033 : : {
14034 : 0 : cmdline_quit(testpmd_cl);
14035 : 0 : }
14036 : :
14037 : : /* prompt function, called from main on MAIN lcore */
14038 : : void
14039 : 0 : prompt(void)
14040 : : {
14041 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14042 : 0 : if (testpmd_cl == NULL) {
14043 : 0 : fprintf(stderr,
14044 : : "Failed to create stdin based cmdline context\n");
14045 : 0 : return;
14046 : : }
14047 : :
14048 : 0 : cmdline_interact(testpmd_cl);
14049 : 0 : cmdline_stdin_exit(testpmd_cl);
14050 : : }
14051 : :
14052 : : void
14053 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14054 : : {
14055 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14056 : : portid_t pid;
14057 : :
14058 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14059 : : /* check if need_reconfig has been set to 1 */
14060 : 0 : if (ports[pid].need_reconfig == 0)
14061 : 0 : ports[pid].need_reconfig = dev;
14062 : : /* check if need_reconfig_queues has been set to 1 */
14063 : 0 : if (ports[pid].need_reconfig_queues == 0)
14064 : 0 : ports[pid].need_reconfig_queues = queue;
14065 : : }
14066 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14067 : : /* check if need_reconfig has been set to 1 */
14068 : 0 : if (ports[id].need_reconfig == 0)
14069 : 0 : ports[id].need_reconfig = dev;
14070 : : /* check if need_reconfig_queues has been set to 1 */
14071 : 0 : if (ports[id].need_reconfig_queues == 0)
14072 : 0 : ports[id].need_reconfig_queues = queue;
14073 : : }
14074 : 0 : }
|