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|"
714 : : "100000|200000|400000|800000|auto)"
715 : : " duplex (half|full|auto)\n"
716 : : " Set speed and duplex for all ports or port_id\n\n"
717 : :
718 : : "port config (port_id|all) loopback (mode)\n"
719 : : " Set loopback mode for all ports or port_id\n\n"
720 : :
721 : : "port config all (rxq|txq|rxd|txd) (value)\n"
722 : : " Set number for rxq/txq/rxd/txd.\n\n"
723 : :
724 : : "port config all max-pkt-len (value)\n"
725 : : " Set the max packet length.\n\n"
726 : :
727 : : "port config all max-lro-pkt-size (value)\n"
728 : : " Set the max LRO aggregated packet size.\n\n"
729 : :
730 : : "port config all drop-en (on|off)\n"
731 : : " Enable or disable packet drop on all RX queues of all ports when no "
732 : : "receive buffers available.\n\n"
733 : :
734 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
735 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
736 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
737 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
738 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
739 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
740 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
741 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
742 : : " Set the RSS mode.\n\n"
743 : :
744 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
745 : : " Set the RSS redirection table.\n\n"
746 : :
747 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
748 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
749 : : " Set the RSS hash algorithm.\n\n"
750 : :
751 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
752 : : " pfc (on|off)\n"
753 : : " Set the DCB mode.\n\n"
754 : :
755 : : "port config all burst (value)\n"
756 : : " Set the number of packets per burst.\n\n"
757 : :
758 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
759 : : " (value)\n"
760 : : " Set the ring prefetch/host/writeback threshold"
761 : : " for tx/rx queue.\n\n"
762 : :
763 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
764 : : " Set free threshold for rx/tx, or set"
765 : : " tx rs bit threshold.\n\n"
766 : : "port config mtu X value\n"
767 : : " Set the MTU of port X to a given value\n\n"
768 : :
769 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
770 : : " Set a rx/tx queue's ring size configuration, the new"
771 : : " value will take effect after command that (re-)start the port"
772 : : " or command that setup the specific queue\n\n"
773 : :
774 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
775 : : " Start/stop a rx/tx queue of port X. Only take effect"
776 : : " when port X is started\n\n"
777 : :
778 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
779 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
780 : : " take effect when port X is stopped.\n\n"
781 : :
782 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
783 : : " Setup a rx/tx queue of port X.\n\n"
784 : :
785 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
786 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
787 : :
788 : : "port config (port_id|all) rx_offload all|vlan_strip|"
789 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
790 : : "outer_ipv4_cksum|macsec_strip|"
791 : : "vlan_filter|vlan_extend|scatter|"
792 : : "buffer_split|timestamp|security|keep_crc on|off\n"
793 : : " Enable or disable a per port Rx offloading"
794 : : " on all Rx queues of a port\n\n"
795 : :
796 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
797 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
798 : : "outer_ipv4_cksum|macsec_strip|"
799 : : "vlan_filter|vlan_extend|scatter|"
800 : : "buffer_split|timestamp|security|keep_crc on|off\n"
801 : : " Enable or disable a per queue Rx offloading"
802 : : " only on a specific Rx queue\n\n"
803 : :
804 : : "port config (port_id|all) tx_offload all|vlan_insert|"
805 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
806 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
807 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
808 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
809 : : "security on|off\n"
810 : : " Enable or disable a per port Tx offloading"
811 : : " on all Tx queues of a port\n\n"
812 : :
813 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
814 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
815 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
816 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
817 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
818 : : " on|off\n"
819 : : " Enable or disable a per queue Tx offloading"
820 : : " only on a specific Tx queue\n\n"
821 : :
822 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
823 : : " Load an eBPF program as a callback"
824 : : " for particular RX/TX queue\n\n"
825 : :
826 : : "bpf-unload rx|tx (port) (queue)\n"
827 : : " Unload previously loaded eBPF program"
828 : : " for particular RX/TX queue\n\n"
829 : :
830 : : "port config (port_id) tx_metadata (value)\n"
831 : : " Set Tx metadata value per port. Testpmd will add this value"
832 : : " to any Tx packet sent from this port\n\n"
833 : :
834 : : "port config (port_id) dynf (name) set|clear\n"
835 : : " Register a dynf and Set/clear this flag on Tx. "
836 : : "Testpmd will set this value to any Tx packet "
837 : : "sent from this port\n\n"
838 : :
839 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
840 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
841 : :
842 : : "port config (port_id) txq (queue_id) affinity (value)\n"
843 : : " Map a Tx queue with an aggregated port "
844 : : "of the DPDK port\n\n"
845 : :
846 : : "port config (port_id|all) speed_lanes (value)\n"
847 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
848 : : );
849 : : }
850 : :
851 : 0 : if (show_all || !strcmp(res->section, "filters")) {
852 : :
853 : 0 : cmdline_printf(
854 : : cl,
855 : : "\n"
856 : : "filters:\n"
857 : : "--------\n\n"
858 : :
859 : : "flow validate {port_id}"
860 : : " [group {group_id}] [priority {level}]"
861 : : " [ingress] [egress]"
862 : : " pattern {item} [/ {item} [...]] / end"
863 : : " actions {action} [/ {action} [...]] / end\n"
864 : : " Check whether a flow rule can be created.\n\n"
865 : :
866 : : "flow create {port_id}"
867 : : " [group {group_id}] [priority {level}]"
868 : : " [ingress] [egress]"
869 : : " pattern {item} [/ {item} [...]] / end"
870 : : " actions {action} [/ {action} [...]] / end\n"
871 : : " Create a flow rule.\n\n"
872 : :
873 : : "flow destroy {port_id} rule {rule_id} [...]\n"
874 : : " Destroy specific flow rules.\n\n"
875 : :
876 : : "flow update {port_id} {rule_id}"
877 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
878 : : " Update a flow rule with new actions.\n\n"
879 : :
880 : : "flow flush {port_id}\n"
881 : : " Destroy all flow rules.\n\n"
882 : :
883 : : "flow query {port_id} {rule_id} {action}\n"
884 : : " Query an existing flow rule.\n\n"
885 : :
886 : : "flow list {port_id} [group {group_id}] [...]\n"
887 : : " List existing flow rules sorted by priority,"
888 : : " filtered by group identifiers.\n\n"
889 : :
890 : : "flow isolate {port_id} {boolean}\n"
891 : : " Restrict ingress traffic to the defined"
892 : : " flow rules\n\n"
893 : :
894 : : "flow aged {port_id} [destroy]\n"
895 : : " List and destroy aged flows"
896 : : " flow rules\n\n"
897 : :
898 : : "flow indirect_action {port_id} create"
899 : : " [action_id {indirect_action_id}]"
900 : : " [ingress] [egress]"
901 : : " action {action} / end\n"
902 : : " Create indirect action.\n\n"
903 : :
904 : : "flow indirect_action {port_id} update"
905 : : " {indirect_action_id} action {action} / end\n"
906 : : " Update indirect action.\n\n"
907 : :
908 : : "flow indirect_action {port_id} destroy"
909 : : " action_id {indirect_action_id} [...]\n"
910 : : " Destroy specific indirect actions.\n\n"
911 : :
912 : : "flow indirect_action {port_id} query"
913 : : " {indirect_action_id}\n"
914 : : " Query an existing indirect action.\n\n"
915 : :
916 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
917 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
918 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
919 : : " Configure the VXLAN encapsulation for flows.\n\n"
920 : :
921 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
922 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
923 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
924 : : " eth-dst (eth-dst)\n"
925 : : " Configure the VXLAN encapsulation for flows.\n\n"
926 : :
927 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
928 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
929 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
930 : : " eth-dst (eth-dst)\n"
931 : : " Configure the VXLAN encapsulation for flows.\n\n"
932 : :
933 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
934 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
935 : : " (eth-dst)\n"
936 : : " Configure the NVGRE encapsulation for flows.\n\n"
937 : :
938 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
939 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
940 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
941 : : " Configure the NVGRE encapsulation for flows.\n\n"
942 : :
943 : : "set raw_encap {flow items}\n"
944 : : " Configure the encapsulation with raw data.\n\n"
945 : :
946 : : "set raw_decap {flow items}\n"
947 : : " Configure the decapsulation with raw data.\n\n"
948 : :
949 : : );
950 : : }
951 : :
952 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
953 : 0 : cmdline_printf(
954 : : cl,
955 : : "\n"
956 : : "Traffic Management:\n"
957 : : "--------------\n"
958 : : "show port tm cap (port_id)\n"
959 : : " Display the port TM capability.\n\n"
960 : :
961 : : "show port tm level cap (port_id) (level_id)\n"
962 : : " Display the port TM hierarchical level capability.\n\n"
963 : :
964 : : "show port tm node cap (port_id) (node_id)\n"
965 : : " Display the port TM node capability.\n\n"
966 : :
967 : : "show port tm node type (port_id) (node_id)\n"
968 : : " Display the port TM node type.\n\n"
969 : :
970 : : "show port tm node stats (port_id) (node_id) (clear)\n"
971 : : " Display the port TM node stats.\n\n"
972 : :
973 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
974 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
975 : : " (packet_length_adjust) (packet_mode)\n"
976 : : " Add port tm node private shaper profile.\n\n"
977 : :
978 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
979 : : " Delete port tm node private shaper profile.\n\n"
980 : :
981 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
982 : : " (shaper_profile_id)\n"
983 : : " Add/update port tm node shared shaper.\n\n"
984 : :
985 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
986 : : " Delete port tm node shared shaper.\n\n"
987 : :
988 : : "set port tm node shaper profile (port_id) (node_id)"
989 : : " (shaper_profile_id)\n"
990 : : " Set port tm node shaper profile.\n\n"
991 : :
992 : : "add port tm node wred profile (port_id) (wred_profile_id)"
993 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
994 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
995 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
996 : : " Add port tm node wred profile.\n\n"
997 : :
998 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
999 : : " Delete port tm node wred profile.\n\n"
1000 : :
1001 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1002 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1003 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1004 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1005 : : " Add port tm nonleaf node.\n\n"
1006 : :
1007 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1008 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1009 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1010 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1011 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1012 : :
1013 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1014 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1015 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1016 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1017 : : " Add port tm leaf node.\n\n"
1018 : :
1019 : : "del port tm node (port_id) (node_id)\n"
1020 : : " Delete port tm node.\n\n"
1021 : :
1022 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1023 : : " (priority) (weight)\n"
1024 : : " Set port tm node parent.\n\n"
1025 : :
1026 : : "suspend port tm node (port_id) (node_id)"
1027 : : " Suspend tm node.\n\n"
1028 : :
1029 : : "resume port tm node (port_id) (node_id)"
1030 : : " Resume tm node.\n\n"
1031 : :
1032 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1033 : : " Commit tm hierarchy.\n\n"
1034 : :
1035 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1036 : : " (red)\n"
1037 : : " Enables/Disables the traffic management marking"
1038 : : " for IP ECN (Explicit Congestion Notification)"
1039 : : " packets on a given port\n\n"
1040 : :
1041 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1042 : : " (red)\n"
1043 : : " Enables/Disables the traffic management marking"
1044 : : " on the port for IP dscp packets\n\n"
1045 : :
1046 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1047 : : " (red)\n"
1048 : : " Enables/Disables the traffic management marking"
1049 : : " on the port for VLAN packets with DEI enabled\n\n"
1050 : : );
1051 : : }
1052 : :
1053 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1054 : 0 : cmdline_printf(
1055 : : cl,
1056 : : "\n"
1057 : : "Device Operations:\n"
1058 : : "--------------\n"
1059 : : "device detach (identifier)\n"
1060 : : " Detach device by identifier.\n\n"
1061 : : );
1062 : : }
1063 : :
1064 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1065 : : struct testpmd_driver_commands *c;
1066 : : unsigned int i;
1067 : :
1068 : 0 : cmdline_printf(
1069 : : cl,
1070 : : "\n"
1071 : : "Driver specific:\n"
1072 : : "----------------\n"
1073 : : );
1074 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1075 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1076 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1077 : : }
1078 : : }
1079 : 0 : }
1080 : :
1081 : : static cmdline_parse_token_string_t cmd_help_long_help =
1082 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1083 : :
1084 : : static cmdline_parse_token_string_t cmd_help_long_section =
1085 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1086 : : "all#control#display#config#ports#"
1087 : : "filters#traffic_management#devices#drivers");
1088 : :
1089 : : static cmdline_parse_inst_t cmd_help_long = {
1090 : : .f = cmd_help_long_parsed,
1091 : : .data = NULL,
1092 : : .help_str = "help all|control|display|config|ports|"
1093 : : "filters|traffic_management|devices|drivers: "
1094 : : "Show help",
1095 : : .tokens = {
1096 : : (void *)&cmd_help_long_help,
1097 : : (void *)&cmd_help_long_section,
1098 : : NULL,
1099 : : },
1100 : : };
1101 : :
1102 : :
1103 : : /* *** start/stop/close all ports *** */
1104 : : struct cmd_operate_port_result {
1105 : : cmdline_fixed_string_t keyword;
1106 : : cmdline_fixed_string_t name;
1107 : : cmdline_fixed_string_t value;
1108 : : };
1109 : :
1110 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1111 : : __rte_unused struct cmdline *cl,
1112 : : __rte_unused void *data)
1113 : : {
1114 : : struct cmd_operate_port_result *res = parsed_result;
1115 : :
1116 : 0 : if (!strcmp(res->name, "start"))
1117 : 0 : start_port(RTE_PORT_ALL);
1118 : 0 : else if (!strcmp(res->name, "stop"))
1119 : 0 : stop_port(RTE_PORT_ALL);
1120 : 0 : else if (!strcmp(res->name, "close"))
1121 : 0 : close_port(RTE_PORT_ALL);
1122 : 0 : else if (!strcmp(res->name, "reset"))
1123 : 0 : reset_port(RTE_PORT_ALL);
1124 : : else
1125 : 0 : fprintf(stderr, "Unknown parameter\n");
1126 : 0 : }
1127 : :
1128 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1129 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1130 : : "port");
1131 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1132 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1133 : : "start#stop#close#reset");
1134 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1135 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1136 : :
1137 : : static cmdline_parse_inst_t cmd_operate_port = {
1138 : : .f = cmd_operate_port_parsed,
1139 : : .data = NULL,
1140 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1141 : : .tokens = {
1142 : : (void *)&cmd_operate_port_all_cmd,
1143 : : (void *)&cmd_operate_port_all_port,
1144 : : (void *)&cmd_operate_port_all_all,
1145 : : NULL,
1146 : : },
1147 : : };
1148 : :
1149 : : /* *** start/stop/close specific port *** */
1150 : : struct cmd_operate_specific_port_result {
1151 : : cmdline_fixed_string_t keyword;
1152 : : cmdline_fixed_string_t name;
1153 : : uint8_t value;
1154 : : };
1155 : :
1156 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1157 : : __rte_unused struct cmdline *cl,
1158 : : __rte_unused void *data)
1159 : : {
1160 : : struct cmd_operate_specific_port_result *res = parsed_result;
1161 : :
1162 : 0 : if (!strcmp(res->name, "start"))
1163 : 0 : start_port(res->value);
1164 : 0 : else if (!strcmp(res->name, "stop"))
1165 : 0 : stop_port(res->value);
1166 : 0 : else if (!strcmp(res->name, "close"))
1167 : 0 : close_port(res->value);
1168 : 0 : else if (!strcmp(res->name, "reset"))
1169 : 0 : reset_port(res->value);
1170 : : else
1171 : 0 : fprintf(stderr, "Unknown parameter\n");
1172 : 0 : }
1173 : :
1174 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1175 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1176 : : keyword, "port");
1177 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1178 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1179 : : name, "start#stop#close#reset");
1180 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1181 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1182 : : value, RTE_UINT8);
1183 : :
1184 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1185 : : .f = cmd_operate_specific_port_parsed,
1186 : : .data = NULL,
1187 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1188 : : .tokens = {
1189 : : (void *)&cmd_operate_specific_port_cmd,
1190 : : (void *)&cmd_operate_specific_port_port,
1191 : : (void *)&cmd_operate_specific_port_id,
1192 : : NULL,
1193 : : },
1194 : : };
1195 : :
1196 : : /* *** enable port setup (after attach) via iterator or event *** */
1197 : : struct cmd_set_port_setup_on_result {
1198 : : cmdline_fixed_string_t set;
1199 : : cmdline_fixed_string_t port;
1200 : : cmdline_fixed_string_t setup;
1201 : : cmdline_fixed_string_t on;
1202 : : cmdline_fixed_string_t mode;
1203 : : };
1204 : :
1205 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1206 : : __rte_unused struct cmdline *cl,
1207 : : __rte_unused void *data)
1208 : : {
1209 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1210 : :
1211 : 0 : if (strcmp(res->mode, "event") == 0)
1212 : 0 : setup_on_probe_event = true;
1213 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1214 : 0 : setup_on_probe_event = false;
1215 : : else
1216 : 0 : fprintf(stderr, "Unknown mode\n");
1217 : 0 : }
1218 : :
1219 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1221 : : set, "set");
1222 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1223 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1224 : : port, "port");
1225 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1227 : : setup, "setup");
1228 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1229 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1230 : : on, "on");
1231 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1233 : : mode, "iterator#event");
1234 : :
1235 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1236 : : .f = cmd_set_port_setup_on_parsed,
1237 : : .data = NULL,
1238 : : .help_str = "set port setup on iterator|event",
1239 : : .tokens = {
1240 : : (void *)&cmd_set_port_setup_on_set,
1241 : : (void *)&cmd_set_port_setup_on_port,
1242 : : (void *)&cmd_set_port_setup_on_setup,
1243 : : (void *)&cmd_set_port_setup_on_on,
1244 : : (void *)&cmd_set_port_setup_on_mode,
1245 : : NULL,
1246 : : },
1247 : : };
1248 : :
1249 : : /* *** attach a specified port *** */
1250 : : struct cmd_operate_attach_port_result {
1251 : : cmdline_fixed_string_t port;
1252 : : cmdline_fixed_string_t keyword;
1253 : : cmdline_multi_string_t identifier;
1254 : : };
1255 : :
1256 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1257 : : __rte_unused struct cmdline *cl,
1258 : : __rte_unused void *data)
1259 : : {
1260 : : struct cmd_operate_attach_port_result *res = parsed_result;
1261 : :
1262 : 0 : if (!strcmp(res->keyword, "attach"))
1263 : 0 : attach_port(res->identifier);
1264 : : else
1265 : 0 : fprintf(stderr, "Unknown parameter\n");
1266 : 0 : }
1267 : :
1268 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1269 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1270 : : port, "port");
1271 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1272 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1273 : : keyword, "attach");
1274 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1275 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1276 : : identifier, TOKEN_STRING_MULTI);
1277 : :
1278 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1279 : : .f = cmd_operate_attach_port_parsed,
1280 : : .data = NULL,
1281 : : .help_str = "port attach <identifier>: "
1282 : : "(identifier: pci address or virtual dev name)",
1283 : : .tokens = {
1284 : : (void *)&cmd_operate_attach_port_port,
1285 : : (void *)&cmd_operate_attach_port_keyword,
1286 : : (void *)&cmd_operate_attach_port_identifier,
1287 : : NULL,
1288 : : },
1289 : : };
1290 : :
1291 : : /* *** detach a specified port *** */
1292 : : struct cmd_operate_detach_port_result {
1293 : : cmdline_fixed_string_t port;
1294 : : cmdline_fixed_string_t keyword;
1295 : : portid_t port_id;
1296 : : };
1297 : :
1298 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1299 : : __rte_unused struct cmdline *cl,
1300 : : __rte_unused void *data)
1301 : : {
1302 : : struct cmd_operate_detach_port_result *res = parsed_result;
1303 : :
1304 : 0 : if (!strcmp(res->keyword, "detach")) {
1305 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1306 : 0 : detach_port_device(res->port_id);
1307 : : } else {
1308 : 0 : fprintf(stderr, "Unknown parameter\n");
1309 : : }
1310 : : }
1311 : :
1312 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1313 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1314 : : port, "port");
1315 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1316 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1317 : : keyword, "detach");
1318 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1319 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1320 : : port_id, RTE_UINT16);
1321 : :
1322 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1323 : : .f = cmd_operate_detach_port_parsed,
1324 : : .data = NULL,
1325 : : .help_str = "port detach <port_id>",
1326 : : .tokens = {
1327 : : (void *)&cmd_operate_detach_port_port,
1328 : : (void *)&cmd_operate_detach_port_keyword,
1329 : : (void *)&cmd_operate_detach_port_port_id,
1330 : : NULL,
1331 : : },
1332 : : };
1333 : :
1334 : : /* *** detach device by identifier *** */
1335 : : struct cmd_operate_detach_device_result {
1336 : : cmdline_fixed_string_t device;
1337 : : cmdline_fixed_string_t keyword;
1338 : : cmdline_fixed_string_t identifier;
1339 : : };
1340 : :
1341 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1342 : : __rte_unused struct cmdline *cl,
1343 : : __rte_unused void *data)
1344 : : {
1345 : : struct cmd_operate_detach_device_result *res = parsed_result;
1346 : :
1347 : 0 : if (!strcmp(res->keyword, "detach"))
1348 : 0 : detach_devargs(res->identifier);
1349 : : else
1350 : 0 : fprintf(stderr, "Unknown parameter\n");
1351 : 0 : }
1352 : :
1353 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1354 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1355 : : device, "device");
1356 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1357 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1358 : : keyword, "detach");
1359 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1360 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1361 : : identifier, NULL);
1362 : :
1363 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1364 : : .f = cmd_operate_detach_device_parsed,
1365 : : .data = NULL,
1366 : : .help_str = "device detach <identifier>:"
1367 : : "(identifier: pci address or virtual dev name)",
1368 : : .tokens = {
1369 : : (void *)&cmd_operate_detach_device_device,
1370 : : (void *)&cmd_operate_detach_device_keyword,
1371 : : (void *)&cmd_operate_detach_device_identifier,
1372 : : NULL,
1373 : : },
1374 : : };
1375 : : /* *** configure speed for all ports *** */
1376 : : struct cmd_config_speed_all {
1377 : : cmdline_fixed_string_t port;
1378 : : cmdline_fixed_string_t keyword;
1379 : : cmdline_fixed_string_t all;
1380 : : cmdline_fixed_string_t item1;
1381 : : cmdline_fixed_string_t item2;
1382 : : cmdline_fixed_string_t value1;
1383 : : cmdline_fixed_string_t value2;
1384 : : };
1385 : :
1386 : : static int
1387 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1388 : : {
1389 : :
1390 : : int duplex;
1391 : :
1392 : 0 : if (!strcmp(duplexstr, "half")) {
1393 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1394 : 0 : } else if (!strcmp(duplexstr, "full")) {
1395 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1396 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1397 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1398 : : } else {
1399 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1400 : 0 : return -1;
1401 : : }
1402 : :
1403 : 0 : if (!strcmp(speedstr, "10")) {
1404 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1405 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1406 : 0 : } else if (!strcmp(speedstr, "100")) {
1407 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1408 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1409 : : } else {
1410 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1411 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1412 : 0 : return -1;
1413 : : }
1414 : 0 : if (!strcmp(speedstr, "1000")) {
1415 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1416 : 0 : } else if (!strcmp(speedstr, "2500")) {
1417 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1418 : 0 : } else if (!strcmp(speedstr, "5000")) {
1419 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1420 : 0 : } else if (!strcmp(speedstr, "10000")) {
1421 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1422 : 0 : } else if (!strcmp(speedstr, "25000")) {
1423 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1424 : 0 : } else if (!strcmp(speedstr, "40000")) {
1425 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1426 : 0 : } else if (!strcmp(speedstr, "50000")) {
1427 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1428 : 0 : } else if (!strcmp(speedstr, "100000")) {
1429 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1430 : 0 : } else if (!strcmp(speedstr, "200000")) {
1431 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1432 : 0 : } else if (!strcmp(speedstr, "400000")) {
1433 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1434 : 0 : } else if (!strcmp(speedstr, "800000")) {
1435 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1436 : 0 : } else if (!strcmp(speedstr, "auto")) {
1437 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1438 : : } else {
1439 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1440 : 0 : return -1;
1441 : : }
1442 : : }
1443 : :
1444 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1445 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1446 : :
1447 : : return 0;
1448 : : }
1449 : :
1450 : : static void
1451 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1452 : : __rte_unused struct cmdline *cl,
1453 : : __rte_unused void *data)
1454 : : {
1455 : : struct cmd_config_speed_all *res = parsed_result;
1456 : : uint32_t link_speed;
1457 : : portid_t pid;
1458 : :
1459 : 0 : if (!all_ports_stopped()) {
1460 : 0 : fprintf(stderr, "Please stop all ports first\n");
1461 : 0 : return;
1462 : : }
1463 : :
1464 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1465 : : &link_speed) < 0)
1466 : : return;
1467 : :
1468 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1469 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1470 : : }
1471 : :
1472 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1473 : : }
1474 : :
1475 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1476 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1477 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1478 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1479 : : "config");
1480 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1481 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1482 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1483 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1484 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1485 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1486 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1487 : : "100000#200000#400000#800000#auto");
1488 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1489 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1490 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1491 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1492 : : "half#full#auto");
1493 : :
1494 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1495 : : .f = cmd_config_speed_all_parsed,
1496 : : .data = NULL,
1497 : : .help_str = "port config all speed "
1498 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1499 : : "100000|200000|400000|800000|auto "
1500 : : "duplex half|full|auto",
1501 : : .tokens = {
1502 : : (void *)&cmd_config_speed_all_port,
1503 : : (void *)&cmd_config_speed_all_keyword,
1504 : : (void *)&cmd_config_speed_all_all,
1505 : : (void *)&cmd_config_speed_all_item1,
1506 : : (void *)&cmd_config_speed_all_value1,
1507 : : (void *)&cmd_config_speed_all_item2,
1508 : : (void *)&cmd_config_speed_all_value2,
1509 : : NULL,
1510 : : },
1511 : : };
1512 : :
1513 : : /* *** configure speed for specific port *** */
1514 : : struct cmd_config_speed_specific {
1515 : : cmdline_fixed_string_t port;
1516 : : cmdline_fixed_string_t keyword;
1517 : : portid_t id;
1518 : : cmdline_fixed_string_t item1;
1519 : : cmdline_fixed_string_t item2;
1520 : : cmdline_fixed_string_t value1;
1521 : : cmdline_fixed_string_t value2;
1522 : : };
1523 : :
1524 : : static void
1525 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1526 : : __rte_unused struct cmdline *cl,
1527 : : __rte_unused void *data)
1528 : : {
1529 : : struct cmd_config_speed_specific *res = parsed_result;
1530 : : uint32_t link_speed;
1531 : :
1532 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1533 : 0 : return;
1534 : :
1535 : 0 : if (!port_is_stopped(res->id)) {
1536 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1537 : 0 : return;
1538 : : }
1539 : :
1540 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1541 : : &link_speed) < 0)
1542 : : return;
1543 : :
1544 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1545 : :
1546 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1547 : : }
1548 : :
1549 : :
1550 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1551 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1552 : : "port");
1553 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1554 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1555 : : "config");
1556 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1557 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1558 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1559 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1560 : : "speed");
1561 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1562 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1563 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1564 : : "100000#200000#400000#800000#auto");
1565 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1566 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1567 : : "duplex");
1568 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1569 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1570 : : "half#full#auto");
1571 : :
1572 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1573 : : .f = cmd_config_speed_specific_parsed,
1574 : : .data = NULL,
1575 : : .help_str = "port config <port_id> speed "
1576 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1577 : : "100000|200000|400000|800000|auto "
1578 : : "duplex half|full|auto",
1579 : : .tokens = {
1580 : : (void *)&cmd_config_speed_specific_port,
1581 : : (void *)&cmd_config_speed_specific_keyword,
1582 : : (void *)&cmd_config_speed_specific_id,
1583 : : (void *)&cmd_config_speed_specific_item1,
1584 : : (void *)&cmd_config_speed_specific_value1,
1585 : : (void *)&cmd_config_speed_specific_item2,
1586 : : (void *)&cmd_config_speed_specific_value2,
1587 : : NULL,
1588 : : },
1589 : : };
1590 : :
1591 : : static int
1592 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1593 : : {
1594 : : int ret;
1595 : :
1596 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1597 : 0 : if (ret == -ENOTSUP) {
1598 : 0 : fprintf(stderr, "Function not implemented\n");
1599 : 0 : return -1;
1600 : 0 : } else if (ret < 0) {
1601 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1602 : 0 : return -1;
1603 : : }
1604 : :
1605 : : return 0;
1606 : : }
1607 : :
1608 : : static void
1609 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1610 : : {
1611 : : unsigned int i;
1612 : : uint32_t capa;
1613 : :
1614 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1615 : : printf("\n-----------------------------------\n");
1616 : 0 : for (i = 0; i < num; i++) {
1617 : 0 : printf("%-17s ",
1618 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1619 : 0 : capa = speed_lanes_capa[i].capa;
1620 : : int s = 0;
1621 : :
1622 : 0 : while (capa) {
1623 : 0 : if (capa & 0x1)
1624 : : printf("%-2d ", s);
1625 : 0 : s++;
1626 : 0 : capa = capa >> 1;
1627 : : }
1628 : : printf("\n");
1629 : : }
1630 : 0 : }
1631 : :
1632 : : /* *** display speed lanes per port capabilities *** */
1633 : : struct cmd_show_speed_lanes_result {
1634 : : cmdline_fixed_string_t cmd_show;
1635 : : cmdline_fixed_string_t cmd_port;
1636 : : cmdline_fixed_string_t cmd_keyword;
1637 : : portid_t cmd_pid;
1638 : : };
1639 : :
1640 : : static void
1641 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1642 : : __rte_unused struct cmdline *cl,
1643 : : __rte_unused void *data)
1644 : : {
1645 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1646 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1647 : : unsigned int num;
1648 : : int ret;
1649 : :
1650 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1651 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1652 : 0 : return;
1653 : : }
1654 : :
1655 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1656 : 0 : if (ret == -ENOTSUP) {
1657 : 0 : fprintf(stderr, "Function not implemented\n");
1658 : 0 : return;
1659 : 0 : } else if (ret < 0) {
1660 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1661 : 0 : return;
1662 : : }
1663 : :
1664 : 0 : num = (unsigned int)ret;
1665 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1666 : 0 : if (speed_lanes_capa == NULL) {
1667 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1668 : 0 : return;
1669 : : }
1670 : :
1671 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1672 : 0 : if (ret < 0) {
1673 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1674 : 0 : goto out;
1675 : : }
1676 : :
1677 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1678 : 0 : out:
1679 : 0 : free(speed_lanes_capa);
1680 : : }
1681 : :
1682 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1683 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1684 : : cmd_show, "show");
1685 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1686 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1687 : : cmd_port, "port");
1688 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1689 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1690 : : cmd_pid, RTE_UINT16);
1691 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1692 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1693 : : cmd_keyword, "speed_lanes");
1694 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1695 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1696 : : cmd_keyword, "capabilities");
1697 : :
1698 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1699 : : .f = cmd_show_speed_lanes_parsed,
1700 : : .data = NULL,
1701 : : .help_str = "show port <port_id> speed_lanes capabilities",
1702 : : .tokens = {
1703 : : (void *)&cmd_show_speed_lanes_show,
1704 : : (void *)&cmd_show_speed_lanes_port,
1705 : : (void *)&cmd_show_speed_lanes_pid,
1706 : : (void *)&cmd_show_speed_lanes_keyword,
1707 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1708 : : NULL,
1709 : : },
1710 : : };
1711 : :
1712 : : /* *** configure speed_lanes for all ports *** */
1713 : : struct cmd_config_speed_lanes_all {
1714 : : cmdline_fixed_string_t port;
1715 : : cmdline_fixed_string_t keyword;
1716 : : cmdline_fixed_string_t all;
1717 : : cmdline_fixed_string_t item;
1718 : : uint32_t lanes;
1719 : : };
1720 : :
1721 : : static void
1722 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1723 : : __rte_unused struct cmdline *cl,
1724 : : __rte_unused void *data)
1725 : : {
1726 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1727 : : portid_t pid;
1728 : :
1729 : 0 : if (!all_ports_stopped()) {
1730 : 0 : fprintf(stderr, "Please stop all ports first\n");
1731 : 0 : return;
1732 : : }
1733 : :
1734 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1735 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1736 : : return;
1737 : : }
1738 : :
1739 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1740 : : }
1741 : :
1742 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1743 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1744 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1745 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1746 : : "config");
1747 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1748 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1749 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1750 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1751 : : "speed_lanes");
1752 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1753 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1754 : :
1755 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1756 : : .f = cmd_config_speed_lanes_all_parsed,
1757 : : .data = NULL,
1758 : : .help_str = "port config all speed_lanes <value>",
1759 : : .tokens = {
1760 : : (void *)&cmd_config_speed_lanes_all_port,
1761 : : (void *)&cmd_config_speed_lanes_all_keyword,
1762 : : (void *)&cmd_config_speed_lanes_all_all,
1763 : : (void *)&cmd_config_speed_lanes_all_item,
1764 : : (void *)&cmd_config_speed_lanes_all_lanes,
1765 : : NULL,
1766 : : },
1767 : : };
1768 : :
1769 : : /* *** configure speed_lanes for specific port *** */
1770 : : struct cmd_config_speed_lanes_specific {
1771 : : cmdline_fixed_string_t port;
1772 : : cmdline_fixed_string_t keyword;
1773 : : uint16_t port_id;
1774 : : cmdline_fixed_string_t item;
1775 : : uint32_t lanes;
1776 : : };
1777 : :
1778 : : static void
1779 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1780 : : __rte_unused struct cmdline *cl,
1781 : : __rte_unused void *data)
1782 : : {
1783 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1784 : :
1785 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1786 : : return;
1787 : :
1788 : 0 : if (!port_is_stopped(res->port_id)) {
1789 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1790 : 0 : return;
1791 : : }
1792 : :
1793 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1794 : : return;
1795 : :
1796 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1797 : : }
1798 : :
1799 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1800 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1801 : : "port");
1802 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1804 : : "config");
1805 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1806 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1807 : : RTE_UINT16);
1808 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1809 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1810 : : "speed_lanes");
1811 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1812 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1813 : : RTE_UINT32);
1814 : :
1815 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1816 : : .f = cmd_config_speed_lanes_specific_parsed,
1817 : : .data = NULL,
1818 : : .help_str = "port config <port_id> speed_lanes <value>",
1819 : : .tokens = {
1820 : : (void *)&cmd_config_speed_lanes_specific_port,
1821 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1822 : : (void *)&cmd_config_speed_lanes_specific_id,
1823 : : (void *)&cmd_config_speed_lanes_specific_item,
1824 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1825 : : NULL,
1826 : : },
1827 : : };
1828 : :
1829 : : /* *** configure loopback for all ports *** */
1830 : : struct cmd_config_loopback_all {
1831 : : cmdline_fixed_string_t port;
1832 : : cmdline_fixed_string_t keyword;
1833 : : cmdline_fixed_string_t all;
1834 : : cmdline_fixed_string_t item;
1835 : : uint32_t mode;
1836 : : };
1837 : :
1838 : : static void
1839 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1840 : : __rte_unused struct cmdline *cl,
1841 : : __rte_unused void *data)
1842 : : {
1843 : : struct cmd_config_loopback_all *res = parsed_result;
1844 : : portid_t pid;
1845 : :
1846 : 0 : if (!all_ports_stopped()) {
1847 : 0 : fprintf(stderr, "Please stop all ports first\n");
1848 : 0 : return;
1849 : : }
1850 : :
1851 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1852 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1853 : : }
1854 : :
1855 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1856 : : }
1857 : :
1858 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1859 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1860 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1861 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1862 : : "config");
1863 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1864 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1865 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1866 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1867 : : "loopback");
1868 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1869 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1870 : :
1871 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1872 : : .f = cmd_config_loopback_all_parsed,
1873 : : .data = NULL,
1874 : : .help_str = "port config all loopback <mode>",
1875 : : .tokens = {
1876 : : (void *)&cmd_config_loopback_all_port,
1877 : : (void *)&cmd_config_loopback_all_keyword,
1878 : : (void *)&cmd_config_loopback_all_all,
1879 : : (void *)&cmd_config_loopback_all_item,
1880 : : (void *)&cmd_config_loopback_all_mode,
1881 : : NULL,
1882 : : },
1883 : : };
1884 : :
1885 : : /* *** configure loopback for specific port *** */
1886 : : struct cmd_config_loopback_specific {
1887 : : cmdline_fixed_string_t port;
1888 : : cmdline_fixed_string_t keyword;
1889 : : uint16_t port_id;
1890 : : cmdline_fixed_string_t item;
1891 : : uint32_t mode;
1892 : : };
1893 : :
1894 : : static void
1895 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1896 : : __rte_unused struct cmdline *cl,
1897 : : __rte_unused void *data)
1898 : : {
1899 : : struct cmd_config_loopback_specific *res = parsed_result;
1900 : :
1901 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1902 : : return;
1903 : :
1904 : 0 : if (!port_is_stopped(res->port_id)) {
1905 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1906 : 0 : return;
1907 : : }
1908 : :
1909 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1910 : :
1911 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1912 : : }
1913 : :
1914 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1915 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1916 : : "port");
1917 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1918 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1919 : : "config");
1920 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1921 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1922 : : RTE_UINT16);
1923 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1924 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1925 : : "loopback");
1926 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1927 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1928 : : RTE_UINT32);
1929 : :
1930 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1931 : : .f = cmd_config_loopback_specific_parsed,
1932 : : .data = NULL,
1933 : : .help_str = "port config <port_id> loopback <mode>",
1934 : : .tokens = {
1935 : : (void *)&cmd_config_loopback_specific_port,
1936 : : (void *)&cmd_config_loopback_specific_keyword,
1937 : : (void *)&cmd_config_loopback_specific_id,
1938 : : (void *)&cmd_config_loopback_specific_item,
1939 : : (void *)&cmd_config_loopback_specific_mode,
1940 : : NULL,
1941 : : },
1942 : : };
1943 : :
1944 : : /* *** configure txq/rxq, txd/rxd *** */
1945 : : struct cmd_config_rx_tx {
1946 : : cmdline_fixed_string_t port;
1947 : : cmdline_fixed_string_t keyword;
1948 : : cmdline_fixed_string_t all;
1949 : : cmdline_fixed_string_t name;
1950 : : uint16_t value;
1951 : : };
1952 : :
1953 : : static void
1954 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1955 : : __rte_unused struct cmdline *cl,
1956 : : __rte_unused void *data)
1957 : : {
1958 : : struct cmd_config_rx_tx *res = parsed_result;
1959 : :
1960 : 0 : if (!all_ports_stopped()) {
1961 : 0 : fprintf(stderr, "Please stop all ports first\n");
1962 : 0 : return;
1963 : : }
1964 : 0 : if (!strcmp(res->name, "rxq")) {
1965 : 0 : if (!res->value && !nb_txq) {
1966 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1967 : 0 : return;
1968 : : }
1969 : 0 : if (check_nb_rxq(res->value) != 0)
1970 : : return;
1971 : 0 : nb_rxq = res->value;
1972 : : }
1973 : 0 : else if (!strcmp(res->name, "txq")) {
1974 : 0 : if (!res->value && !nb_rxq) {
1975 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1976 : 0 : return;
1977 : : }
1978 : 0 : if (check_nb_txq(res->value) != 0)
1979 : : return;
1980 : 0 : nb_txq = res->value;
1981 : : }
1982 : 0 : else if (!strcmp(res->name, "rxd")) {
1983 : 0 : if (check_nb_rxd(res->value) != 0)
1984 : : return;
1985 : 0 : nb_rxd = res->value;
1986 : 0 : } else if (!strcmp(res->name, "txd")) {
1987 : 0 : if (check_nb_txd(res->value) != 0)
1988 : : return;
1989 : :
1990 : 0 : nb_txd = res->value;
1991 : : } else {
1992 : 0 : fprintf(stderr, "Unknown parameter\n");
1993 : 0 : return;
1994 : : }
1995 : :
1996 : 0 : fwd_config_setup();
1997 : :
1998 : 0 : init_port_config();
1999 : :
2000 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2001 : : }
2002 : :
2003 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2004 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2005 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2006 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2007 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2008 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2009 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2011 : : "rxq#txq#rxd#txd");
2012 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2013 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2014 : :
2015 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2016 : : .f = cmd_config_rx_tx_parsed,
2017 : : .data = NULL,
2018 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2019 : : .tokens = {
2020 : : (void *)&cmd_config_rx_tx_port,
2021 : : (void *)&cmd_config_rx_tx_keyword,
2022 : : (void *)&cmd_config_rx_tx_all,
2023 : : (void *)&cmd_config_rx_tx_name,
2024 : : (void *)&cmd_config_rx_tx_value,
2025 : : NULL,
2026 : : },
2027 : : };
2028 : :
2029 : : /* *** config max packet length *** */
2030 : : struct cmd_config_max_pkt_len_result {
2031 : : cmdline_fixed_string_t port;
2032 : : cmdline_fixed_string_t keyword;
2033 : : cmdline_fixed_string_t all;
2034 : : cmdline_fixed_string_t name;
2035 : : uint32_t value;
2036 : : };
2037 : :
2038 : : static void
2039 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2040 : : __rte_unused struct cmdline *cl,
2041 : : __rte_unused void *data)
2042 : : {
2043 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2044 : : portid_t port_id;
2045 : : int ret;
2046 : :
2047 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2048 : : printf("Unknown parameter\n");
2049 : 0 : return;
2050 : : }
2051 : :
2052 : 0 : if (!all_ports_stopped()) {
2053 : 0 : fprintf(stderr, "Please stop all ports first\n");
2054 : 0 : return;
2055 : : }
2056 : :
2057 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2058 : 0 : struct rte_port *port = &ports[port_id];
2059 : :
2060 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2061 : 0 : fprintf(stderr,
2062 : : "max-pkt-len can not be less than %d\n",
2063 : : RTE_ETHER_MIN_LEN);
2064 : 0 : return;
2065 : : }
2066 : :
2067 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2068 : 0 : if (ret != 0) {
2069 : 0 : fprintf(stderr,
2070 : : "rte_eth_dev_info_get() failed for port %u\n",
2071 : : port_id);
2072 : 0 : return;
2073 : : }
2074 : :
2075 : 0 : update_mtu_from_frame_size(port_id, res->value);
2076 : : }
2077 : :
2078 : 0 : init_port_config();
2079 : :
2080 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2081 : : }
2082 : :
2083 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2084 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2085 : : "port");
2086 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2087 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2088 : : "config");
2089 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2090 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2091 : : "all");
2092 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2093 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2094 : : "max-pkt-len");
2095 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2096 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2097 : : RTE_UINT32);
2098 : :
2099 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2100 : : .f = cmd_config_max_pkt_len_parsed,
2101 : : .data = NULL,
2102 : : .help_str = "port config all max-pkt-len <value>",
2103 : : .tokens = {
2104 : : (void *)&cmd_config_max_pkt_len_port,
2105 : : (void *)&cmd_config_max_pkt_len_keyword,
2106 : : (void *)&cmd_config_max_pkt_len_all,
2107 : : (void *)&cmd_config_max_pkt_len_name,
2108 : : (void *)&cmd_config_max_pkt_len_value,
2109 : : NULL,
2110 : : },
2111 : : };
2112 : :
2113 : : /* *** config max LRO aggregated packet size *** */
2114 : : struct cmd_config_max_lro_pkt_size_result {
2115 : : cmdline_fixed_string_t port;
2116 : : cmdline_fixed_string_t keyword;
2117 : : cmdline_fixed_string_t all;
2118 : : cmdline_fixed_string_t name;
2119 : : uint32_t value;
2120 : : };
2121 : :
2122 : : static void
2123 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2124 : : __rte_unused struct cmdline *cl,
2125 : : __rte_unused void *data)
2126 : : {
2127 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2128 : : portid_t pid;
2129 : :
2130 : 0 : if (!all_ports_stopped()) {
2131 : 0 : fprintf(stderr, "Please stop all ports first\n");
2132 : 0 : return;
2133 : : }
2134 : :
2135 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2136 : 0 : struct rte_port *port = &ports[pid];
2137 : :
2138 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2139 : 0 : if (res->value ==
2140 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2141 : : return;
2142 : :
2143 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2144 : : } else {
2145 : 0 : fprintf(stderr, "Unknown parameter\n");
2146 : 0 : return;
2147 : : }
2148 : : }
2149 : :
2150 : 0 : init_port_config();
2151 : :
2152 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2153 : : }
2154 : :
2155 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2156 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2157 : : port, "port");
2158 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2159 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2160 : : keyword, "config");
2161 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2162 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2163 : : all, "all");
2164 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2165 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2166 : : name, "max-lro-pkt-size");
2167 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2168 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2169 : : value, RTE_UINT32);
2170 : :
2171 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2172 : : .f = cmd_config_max_lro_pkt_size_parsed,
2173 : : .data = NULL,
2174 : : .help_str = "port config all max-lro-pkt-size <value>",
2175 : : .tokens = {
2176 : : (void *)&cmd_config_max_lro_pkt_size_port,
2177 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2178 : : (void *)&cmd_config_max_lro_pkt_size_all,
2179 : : (void *)&cmd_config_max_lro_pkt_size_name,
2180 : : (void *)&cmd_config_max_lro_pkt_size_value,
2181 : : NULL,
2182 : : },
2183 : : };
2184 : :
2185 : : /* *** configure port MTU *** */
2186 : : struct cmd_config_mtu_result {
2187 : : cmdline_fixed_string_t port;
2188 : : cmdline_fixed_string_t keyword;
2189 : : cmdline_fixed_string_t mtu;
2190 : : portid_t port_id;
2191 : : uint16_t value;
2192 : : };
2193 : :
2194 : : static void
2195 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2196 : : __rte_unused struct cmdline *cl,
2197 : : __rte_unused void *data)
2198 : : {
2199 : : struct cmd_config_mtu_result *res = parsed_result;
2200 : :
2201 : 0 : port_mtu_set(res->port_id, res->value);
2202 : 0 : }
2203 : :
2204 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2205 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2206 : : "port");
2207 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2208 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2209 : : "config");
2210 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2211 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2212 : : "mtu");
2213 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2214 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2215 : : RTE_UINT16);
2216 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2217 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2218 : : RTE_UINT16);
2219 : :
2220 : : static cmdline_parse_inst_t cmd_config_mtu = {
2221 : : .f = cmd_config_mtu_parsed,
2222 : : .data = NULL,
2223 : : .help_str = "port config mtu <port_id> <value>",
2224 : : .tokens = {
2225 : : (void *)&cmd_config_mtu_port,
2226 : : (void *)&cmd_config_mtu_keyword,
2227 : : (void *)&cmd_config_mtu_mtu,
2228 : : (void *)&cmd_config_mtu_port_id,
2229 : : (void *)&cmd_config_mtu_value,
2230 : : NULL,
2231 : : },
2232 : : };
2233 : :
2234 : : /* *** configure rx mode *** */
2235 : : struct cmd_config_rx_mode_flag {
2236 : : cmdline_fixed_string_t port;
2237 : : cmdline_fixed_string_t keyword;
2238 : : cmdline_fixed_string_t all;
2239 : : cmdline_fixed_string_t name;
2240 : : cmdline_fixed_string_t value;
2241 : : };
2242 : :
2243 : : static void
2244 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2245 : : __rte_unused struct cmdline *cl,
2246 : : __rte_unused void *data)
2247 : : {
2248 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2249 : :
2250 : 0 : if (!all_ports_stopped()) {
2251 : 0 : fprintf(stderr, "Please stop all ports first\n");
2252 : 0 : return;
2253 : : }
2254 : :
2255 : 0 : if (!strcmp(res->name, "drop-en")) {
2256 : 0 : if (!strcmp(res->value, "on"))
2257 : 0 : rx_drop_en = 1;
2258 : 0 : else if (!strcmp(res->value, "off"))
2259 : 0 : rx_drop_en = 0;
2260 : : else {
2261 : 0 : fprintf(stderr, "Unknown parameter\n");
2262 : 0 : return;
2263 : : }
2264 : : } else {
2265 : 0 : fprintf(stderr, "Unknown parameter\n");
2266 : 0 : return;
2267 : : }
2268 : :
2269 : 0 : init_port_config();
2270 : :
2271 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2272 : : }
2273 : :
2274 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2275 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2276 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2277 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2278 : : "config");
2279 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2280 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2281 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2282 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2283 : : "drop-en");
2284 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2285 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2286 : : "on#off");
2287 : :
2288 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2289 : : .f = cmd_config_rx_mode_flag_parsed,
2290 : : .data = NULL,
2291 : : .help_str = "port config all drop-en on|off",
2292 : : .tokens = {
2293 : : (void *)&cmd_config_rx_mode_flag_port,
2294 : : (void *)&cmd_config_rx_mode_flag_keyword,
2295 : : (void *)&cmd_config_rx_mode_flag_all,
2296 : : (void *)&cmd_config_rx_mode_flag_name,
2297 : : (void *)&cmd_config_rx_mode_flag_value,
2298 : : NULL,
2299 : : },
2300 : : };
2301 : :
2302 : : /* *** configure rss *** */
2303 : : struct cmd_config_rss {
2304 : : cmdline_fixed_string_t port;
2305 : : cmdline_fixed_string_t keyword;
2306 : : cmdline_fixed_string_t all;
2307 : : cmdline_fixed_string_t name;
2308 : : cmdline_fixed_string_t value;
2309 : : };
2310 : :
2311 : : static void
2312 : 0 : cmd_config_rss_parsed(void *parsed_result,
2313 : : __rte_unused struct cmdline *cl,
2314 : : __rte_unused void *data)
2315 : : {
2316 : : struct cmd_config_rss *res = parsed_result;
2317 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2318 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2319 : : int use_default = 0;
2320 : : int all_updated = 1;
2321 : : int diag;
2322 : : uint16_t i;
2323 : : int ret;
2324 : :
2325 : 0 : if (!strcmp(res->value, "level-default")) {
2326 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2327 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2328 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2329 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2330 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2331 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2332 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2333 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2334 : 0 : } else if (!strcmp(res->value, "default")) {
2335 : : use_default = 1;
2336 : 0 : } else if (isdigit(res->value[0])) {
2337 : : int value = atoi(res->value);
2338 : 0 : if (value > 0 && value < 64)
2339 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2340 : : else {
2341 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2342 : 0 : return;
2343 : : }
2344 : 0 : } else if (!strcmp(res->value, "none")) {
2345 : : rss_conf.rss_hf = 0;
2346 : : } else {
2347 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2348 : 0 : if (rss_conf.rss_hf == 0) {
2349 : 0 : fprintf(stderr, "Unknown parameter\n");
2350 : 0 : return;
2351 : : }
2352 : : }
2353 : : rss_conf.rss_key = NULL;
2354 : : /* Update global configuration for RSS types. */
2355 : 0 : RTE_ETH_FOREACH_DEV(i) {
2356 : : struct rte_eth_rss_conf local_rss_conf;
2357 : :
2358 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2359 : 0 : if (ret != 0)
2360 : 0 : return;
2361 : :
2362 : 0 : if (use_default)
2363 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2364 : :
2365 : 0 : local_rss_conf = rss_conf;
2366 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2367 : 0 : dev_info.flow_type_rss_offloads;
2368 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2369 : : printf("Port %u modified RSS hash function based on hardware support,"
2370 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2371 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2372 : : }
2373 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2374 : 0 : if (diag < 0) {
2375 : : all_updated = 0;
2376 : 0 : fprintf(stderr,
2377 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2378 : : i, -diag, strerror(-diag));
2379 : : }
2380 : : }
2381 : 0 : if (all_updated && !use_default) {
2382 : 0 : rss_hf = rss_conf.rss_hf;
2383 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2384 : : }
2385 : : }
2386 : :
2387 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2388 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2389 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2390 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2391 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2392 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2393 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2394 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2395 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2396 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2397 : :
2398 : : static cmdline_parse_inst_t cmd_config_rss = {
2399 : : .f = cmd_config_rss_parsed,
2400 : : .data = NULL,
2401 : : .help_str = "port config all rss "
2402 : : "all|default|level-default|level-outer|level-inner|"
2403 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2404 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2405 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2406 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2407 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2408 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2409 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2410 : : .tokens = {
2411 : : (void *)&cmd_config_rss_port,
2412 : : (void *)&cmd_config_rss_keyword,
2413 : : (void *)&cmd_config_rss_all,
2414 : : (void *)&cmd_config_rss_name,
2415 : : (void *)&cmd_config_rss_value,
2416 : : NULL,
2417 : : },
2418 : : };
2419 : :
2420 : : /* *** configure rss hash key *** */
2421 : : struct cmd_config_rss_hash_key {
2422 : : cmdline_fixed_string_t port;
2423 : : cmdline_fixed_string_t config;
2424 : : portid_t port_id;
2425 : : cmdline_fixed_string_t rss_hash_key;
2426 : : cmdline_fixed_string_t rss_type;
2427 : : cmdline_fixed_string_t key;
2428 : : };
2429 : :
2430 : : static uint8_t
2431 : : hexa_digit_to_value(char hexa_digit)
2432 : : {
2433 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2434 : : return (uint8_t) (hexa_digit - '0');
2435 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2436 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2437 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2438 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2439 : : /* Invalid hexa digit */
2440 : : return 0xFF;
2441 : : }
2442 : :
2443 : : static uint8_t
2444 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2445 : : {
2446 : : uint8_t hexa_v;
2447 : :
2448 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2449 : : if (hexa_v == 0xFF)
2450 : 0 : fprintf(stderr,
2451 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2452 : : key[idx], idx);
2453 : 0 : return hexa_v;
2454 : : }
2455 : :
2456 : : static void
2457 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2458 : : __rte_unused struct cmdline *cl,
2459 : : __rte_unused void *data)
2460 : : {
2461 : : struct cmd_config_rss_hash_key *res = parsed_result;
2462 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2463 : : uint8_t xdgt0;
2464 : : uint8_t xdgt1;
2465 : : int i;
2466 : : struct rte_eth_dev_info dev_info;
2467 : : uint8_t hash_key_size;
2468 : : uint32_t key_len;
2469 : : int ret;
2470 : :
2471 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2472 : 0 : if (ret != 0)
2473 : 0 : return;
2474 : :
2475 : 0 : if (dev_info.hash_key_size > 0 &&
2476 : : dev_info.hash_key_size <= sizeof(hash_key))
2477 : : hash_key_size = dev_info.hash_key_size;
2478 : : else {
2479 : 0 : fprintf(stderr,
2480 : : "dev_info did not provide a valid hash key size\n");
2481 : 0 : return;
2482 : : }
2483 : : /* Check the length of the RSS hash key */
2484 : 0 : key_len = strlen(res->key);
2485 : 0 : if (key_len != (hash_key_size * 2)) {
2486 : 0 : fprintf(stderr,
2487 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2488 : : (int)key_len, hash_key_size * 2);
2489 : 0 : return;
2490 : : }
2491 : : /* Translate RSS hash key into binary representation */
2492 : 0 : for (i = 0; i < hash_key_size; i++) {
2493 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2494 : 0 : if (xdgt0 == 0xFF)
2495 : : return;
2496 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2497 : 0 : if (xdgt1 == 0xFF)
2498 : : return;
2499 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2500 : : }
2501 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2502 : : hash_key_size);
2503 : : }
2504 : :
2505 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2506 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2507 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2508 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2509 : : "config");
2510 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2511 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2512 : : RTE_UINT16);
2513 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2514 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2515 : : rss_hash_key, "rss-hash-key");
2516 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2517 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2518 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2519 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2520 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2521 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2522 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2523 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2524 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2525 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2526 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2527 : :
2528 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2529 : : .f = cmd_config_rss_hash_key_parsed,
2530 : : .data = NULL,
2531 : : .help_str = "port config <port_id> rss-hash-key "
2532 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2533 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2534 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2535 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2536 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2537 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2538 : : "<string of hex digits (variable length, NIC dependent)>",
2539 : : .tokens = {
2540 : : (void *)&cmd_config_rss_hash_key_port,
2541 : : (void *)&cmd_config_rss_hash_key_config,
2542 : : (void *)&cmd_config_rss_hash_key_port_id,
2543 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2544 : : (void *)&cmd_config_rss_hash_key_rss_type,
2545 : : (void *)&cmd_config_rss_hash_key_value,
2546 : : NULL,
2547 : : },
2548 : : };
2549 : :
2550 : : /* *** configure rss hash algorithm *** */
2551 : : struct cmd_config_rss_hash_algo {
2552 : : cmdline_fixed_string_t port;
2553 : : cmdline_fixed_string_t config;
2554 : : portid_t port_id;
2555 : : cmdline_fixed_string_t rss_hash_algo;
2556 : : cmdline_fixed_string_t algo;
2557 : : };
2558 : :
2559 : : static void
2560 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2561 : : __rte_unused struct cmdline *cl,
2562 : : __rte_unused void *data)
2563 : : {
2564 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2565 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2566 : : struct rte_eth_rss_conf rss_conf;
2567 : : uint32_t algorithm;
2568 : : int ret;
2569 : :
2570 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2571 : 0 : rss_conf.rss_key = rss_key;
2572 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2573 : 0 : if (ret != 0) {
2574 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2575 : 0 : res->port_id);
2576 : 0 : return;
2577 : : }
2578 : :
2579 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2580 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2581 : 0 : if (ret != 0) {
2582 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2583 : 0 : res->port_id, res->algo);
2584 : 0 : return;
2585 : : }
2586 : :
2587 : 0 : rss_conf.algorithm = algorithm;
2588 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2589 : 0 : if (ret != 0) {
2590 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2591 : 0 : res->port_id);
2592 : 0 : return;
2593 : : }
2594 : : }
2595 : :
2596 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2597 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2598 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2599 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2600 : : "config");
2601 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2602 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2603 : : RTE_UINT16);
2604 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2605 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2606 : : rss_hash_algo, "rss-hash-algo");
2607 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2608 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2609 : : "default#simple_xor#toeplitz#"
2610 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2611 : :
2612 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2613 : : .f = cmd_config_rss_hash_algo_parsed,
2614 : : .data = NULL,
2615 : : .help_str = "port config <port_id> rss-hash-algo "
2616 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2617 : : .tokens = {
2618 : : (void *)&cmd_config_rss_hash_algo_port,
2619 : : (void *)&cmd_config_rss_hash_algo_config,
2620 : : (void *)&cmd_config_rss_hash_algo_port_id,
2621 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2622 : : (void *)&cmd_config_rss_hash_algo_algo,
2623 : : NULL,
2624 : : },
2625 : : };
2626 : :
2627 : : /* *** cleanup txq mbufs *** */
2628 : : struct cmd_cleanup_txq_mbufs_result {
2629 : : cmdline_fixed_string_t port;
2630 : : cmdline_fixed_string_t keyword;
2631 : : cmdline_fixed_string_t name;
2632 : : uint16_t port_id;
2633 : : uint16_t queue_id;
2634 : : uint32_t free_cnt;
2635 : : };
2636 : :
2637 : : static void
2638 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2639 : : __rte_unused struct cmdline *cl,
2640 : : __rte_unused void *data)
2641 : : {
2642 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2643 : 0 : uint16_t port_id = res->port_id;
2644 : 0 : uint16_t queue_id = res->queue_id;
2645 : 0 : uint32_t free_cnt = res->free_cnt;
2646 : : struct rte_eth_txq_info qinfo;
2647 : : int ret;
2648 : :
2649 : 0 : if (test_done == 0) {
2650 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2651 : 0 : return;
2652 : : }
2653 : :
2654 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2655 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2656 : : port_id, queue_id);
2657 : 0 : return;
2658 : : }
2659 : :
2660 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2661 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2662 : 0 : return;
2663 : : }
2664 : :
2665 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2666 : 0 : if (ret < 0) {
2667 : 0 : fprintf(stderr,
2668 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2669 : : port_id, queue_id, strerror(-ret), ret);
2670 : 0 : return;
2671 : : }
2672 : :
2673 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2674 : : port_id, queue_id, ret);
2675 : : }
2676 : :
2677 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2678 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2679 : : "port");
2680 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2681 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2682 : : "cleanup");
2683 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2684 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2685 : : RTE_UINT16);
2686 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2687 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2688 : : "txq");
2689 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2690 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2691 : : RTE_UINT16);
2692 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2693 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2694 : : RTE_UINT32);
2695 : :
2696 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2697 : : .f = cmd_cleanup_txq_mbufs_parsed,
2698 : : .data = NULL,
2699 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2700 : : .tokens = {
2701 : : (void *)&cmd_cleanup_txq_mbufs_port,
2702 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2703 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2704 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2705 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2706 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2707 : : NULL,
2708 : : },
2709 : : };
2710 : :
2711 : : /* *** configure port rxq/txq ring size *** */
2712 : : struct cmd_config_rxtx_ring_size {
2713 : : cmdline_fixed_string_t port;
2714 : : cmdline_fixed_string_t config;
2715 : : portid_t portid;
2716 : : cmdline_fixed_string_t rxtxq;
2717 : : uint16_t qid;
2718 : : cmdline_fixed_string_t rsize;
2719 : : uint16_t size;
2720 : : };
2721 : :
2722 : : static void
2723 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2724 : : __rte_unused struct cmdline *cl,
2725 : : __rte_unused void *data)
2726 : : {
2727 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2728 : : struct rte_port *port;
2729 : : uint8_t isrx;
2730 : :
2731 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2732 : : return;
2733 : :
2734 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2735 : 0 : fprintf(stderr, "Invalid port id\n");
2736 : 0 : return;
2737 : : }
2738 : :
2739 : 0 : port = &ports[res->portid];
2740 : :
2741 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2742 : : isrx = 1;
2743 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2744 : : isrx = 0;
2745 : : else {
2746 : 0 : fprintf(stderr, "Unknown parameter\n");
2747 : 0 : return;
2748 : : }
2749 : :
2750 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2751 : : return;
2752 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2753 : : return;
2754 : :
2755 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2756 : 0 : fprintf(stderr,
2757 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2758 : : rx_free_thresh);
2759 : 0 : return;
2760 : : }
2761 : :
2762 : 0 : if (isrx)
2763 : 0 : port->nb_rx_desc[res->qid] = res->size;
2764 : : else
2765 : 0 : port->nb_tx_desc[res->qid] = res->size;
2766 : :
2767 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2768 : : }
2769 : :
2770 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2771 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2772 : : port, "port");
2773 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2774 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2775 : : config, "config");
2776 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2777 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2778 : : portid, RTE_UINT16);
2779 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2780 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2781 : : rxtxq, "rxq#txq");
2782 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2783 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2784 : : qid, RTE_UINT16);
2785 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2786 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2787 : : rsize, "ring_size");
2788 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2789 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2790 : : size, RTE_UINT16);
2791 : :
2792 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2793 : : .f = cmd_config_rxtx_ring_size_parsed,
2794 : : .data = NULL,
2795 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2796 : : .tokens = {
2797 : : (void *)&cmd_config_rxtx_ring_size_port,
2798 : : (void *)&cmd_config_rxtx_ring_size_config,
2799 : : (void *)&cmd_config_rxtx_ring_size_portid,
2800 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2801 : : (void *)&cmd_config_rxtx_ring_size_qid,
2802 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2803 : : (void *)&cmd_config_rxtx_ring_size_size,
2804 : : NULL,
2805 : : },
2806 : : };
2807 : :
2808 : : /* *** configure port rxq/txq start/stop *** */
2809 : : struct cmd_config_rxtx_queue {
2810 : : cmdline_fixed_string_t port;
2811 : : portid_t portid;
2812 : : cmdline_fixed_string_t rxtxq;
2813 : : uint16_t qid;
2814 : : cmdline_fixed_string_t opname;
2815 : : };
2816 : :
2817 : : static void
2818 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2819 : : __rte_unused struct cmdline *cl,
2820 : : __rte_unused void *data)
2821 : : {
2822 : : struct cmd_config_rxtx_queue *res = parsed_result;
2823 : : struct rte_port *port;
2824 : : uint8_t isrx;
2825 : : uint8_t isstart;
2826 : : uint8_t *state;
2827 : : int ret = 0;
2828 : :
2829 : 0 : if (test_done == 0) {
2830 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2831 : 0 : return;
2832 : : }
2833 : :
2834 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2835 : : return;
2836 : :
2837 : 0 : if (port_is_started(res->portid) != 1) {
2838 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2839 : 0 : return;
2840 : : }
2841 : :
2842 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2843 : : isrx = 1;
2844 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2845 : : isrx = 0;
2846 : : else {
2847 : 0 : fprintf(stderr, "Unknown parameter\n");
2848 : 0 : return;
2849 : : }
2850 : :
2851 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2852 : : return;
2853 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2854 : : return;
2855 : :
2856 : 0 : if (!strcmp(res->opname, "start"))
2857 : : isstart = 1;
2858 : 0 : else if (!strcmp(res->opname, "stop"))
2859 : : isstart = 0;
2860 : : else {
2861 : 0 : fprintf(stderr, "Unknown parameter\n");
2862 : 0 : return;
2863 : : }
2864 : :
2865 : 0 : if (isstart && isrx)
2866 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2867 : 0 : else if (!isstart && isrx)
2868 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2869 : 0 : else if (isstart && !isrx)
2870 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2871 : : else
2872 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2873 : :
2874 : 0 : if (ret == -ENOTSUP) {
2875 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2876 : 0 : return;
2877 : : }
2878 : :
2879 : 0 : port = &ports[res->portid];
2880 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2881 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2882 : : RTE_ETH_QUEUE_STATE_STOPPED;
2883 : : }
2884 : :
2885 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2886 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2887 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2888 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2889 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2890 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2891 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2892 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2893 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2894 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2895 : : "start#stop");
2896 : :
2897 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2898 : : .f = cmd_config_rxtx_queue_parsed,
2899 : : .data = NULL,
2900 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2901 : : .tokens = {
2902 : : (void *)&cmd_config_rxtx_queue_port,
2903 : : (void *)&cmd_config_rxtx_queue_portid,
2904 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2905 : : (void *)&cmd_config_rxtx_queue_qid,
2906 : : (void *)&cmd_config_rxtx_queue_opname,
2907 : : NULL,
2908 : : },
2909 : : };
2910 : :
2911 : : /* *** configure port rxq/txq deferred start on/off *** */
2912 : : struct cmd_config_deferred_start_rxtx_queue {
2913 : : cmdline_fixed_string_t port;
2914 : : portid_t port_id;
2915 : : cmdline_fixed_string_t rxtxq;
2916 : : uint16_t qid;
2917 : : cmdline_fixed_string_t opname;
2918 : : cmdline_fixed_string_t state;
2919 : : };
2920 : :
2921 : : static void
2922 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2923 : : __rte_unused struct cmdline *cl,
2924 : : __rte_unused void *data)
2925 : : {
2926 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2927 : : struct rte_port *port;
2928 : : uint8_t isrx;
2929 : : uint8_t ison;
2930 : : uint8_t needreconfig = 0;
2931 : :
2932 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2933 : : return;
2934 : :
2935 : 0 : if (port_is_started(res->port_id) != 0) {
2936 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2937 : 0 : return;
2938 : : }
2939 : :
2940 : 0 : port = &ports[res->port_id];
2941 : :
2942 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2943 : :
2944 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2945 : : return;
2946 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2947 : : return;
2948 : :
2949 : 0 : ison = !strcmp(res->state, "on");
2950 : :
2951 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2952 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2953 : : needreconfig = 1;
2954 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2955 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2956 : : needreconfig = 1;
2957 : : }
2958 : :
2959 : : if (needreconfig)
2960 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2961 : : }
2962 : :
2963 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2964 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2965 : : port, "port");
2966 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2967 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2968 : : port_id, RTE_UINT16);
2969 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2970 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2971 : : rxtxq, "rxq#txq");
2972 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2973 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2974 : : qid, RTE_UINT16);
2975 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2976 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2977 : : opname, "deferred_start");
2978 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2979 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2980 : : state, "on#off");
2981 : :
2982 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2983 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2984 : : .data = NULL,
2985 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2986 : : .tokens = {
2987 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2988 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2989 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2990 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2991 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2992 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2993 : : NULL,
2994 : : },
2995 : : };
2996 : :
2997 : : /* *** configure port rxq/txq setup *** */
2998 : : struct cmd_setup_rxtx_queue {
2999 : : cmdline_fixed_string_t port;
3000 : : portid_t portid;
3001 : : cmdline_fixed_string_t rxtxq;
3002 : : uint16_t qid;
3003 : : cmdline_fixed_string_t setup;
3004 : : };
3005 : :
3006 : : /* Common CLI fields for queue setup */
3007 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3008 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3009 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3010 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3011 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3012 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3013 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3014 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3015 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3016 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3017 : :
3018 : : static void
3019 : 0 : cmd_setup_rxtx_queue_parsed(
3020 : : void *parsed_result,
3021 : : __rte_unused struct cmdline *cl,
3022 : : __rte_unused void *data)
3023 : : {
3024 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3025 : : struct rte_port *port;
3026 : : struct rte_mempool *mp;
3027 : : unsigned int socket_id;
3028 : : uint8_t isrx = 0;
3029 : : int ret;
3030 : :
3031 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3032 : : return;
3033 : :
3034 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3035 : 0 : fprintf(stderr, "Invalid port id\n");
3036 : 0 : return;
3037 : : }
3038 : :
3039 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3040 : : isrx = 1;
3041 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3042 : : isrx = 0;
3043 : : else {
3044 : 0 : fprintf(stderr, "Unknown parameter\n");
3045 : 0 : return;
3046 : : }
3047 : :
3048 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3049 : 0 : fprintf(stderr, "Invalid rx queue\n");
3050 : 0 : return;
3051 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3052 : 0 : fprintf(stderr, "Invalid tx queue\n");
3053 : 0 : return;
3054 : : }
3055 : :
3056 : 0 : port = &ports[res->portid];
3057 : 0 : if (isrx) {
3058 : 0 : socket_id = rxring_numa[res->portid];
3059 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3060 : 0 : socket_id = port->socket_id;
3061 : :
3062 : : mp = mbuf_pool_find(socket_id, 0);
3063 : 0 : if (mp == NULL) {
3064 : 0 : fprintf(stderr,
3065 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3066 : 0 : rxring_numa[res->portid]);
3067 : 0 : return;
3068 : : }
3069 : 0 : ret = rx_queue_setup(res->portid,
3070 : : res->qid,
3071 : 0 : port->nb_rx_desc[res->qid],
3072 : : socket_id,
3073 : 0 : &port->rxq[res->qid].conf,
3074 : : mp);
3075 : 0 : if (ret)
3076 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3077 : : } else {
3078 : 0 : socket_id = txring_numa[res->portid];
3079 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3080 : 0 : socket_id = port->socket_id;
3081 : :
3082 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3083 : 0 : fprintf(stderr,
3084 : : "Failed to setup TX queue: not enough descriptors\n");
3085 : 0 : return;
3086 : : }
3087 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3088 : : res->qid,
3089 : : port->nb_tx_desc[res->qid],
3090 : : socket_id,
3091 : 0 : &port->txq[res->qid].conf);
3092 : 0 : if (ret)
3093 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3094 : : }
3095 : : }
3096 : :
3097 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3098 : : .f = cmd_setup_rxtx_queue_parsed,
3099 : : .data = NULL,
3100 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3101 : : .tokens = {
3102 : : (void *)&cmd_setup_rxtx_queue_port,
3103 : : (void *)&cmd_setup_rxtx_queue_portid,
3104 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3105 : : (void *)&cmd_setup_rxtx_queue_qid,
3106 : : (void *)&cmd_setup_rxtx_queue_setup,
3107 : : NULL,
3108 : : },
3109 : : };
3110 : :
3111 : :
3112 : : /* *** Configure RSS RETA *** */
3113 : : struct cmd_config_rss_reta {
3114 : : cmdline_fixed_string_t port;
3115 : : cmdline_fixed_string_t keyword;
3116 : : portid_t port_id;
3117 : : cmdline_fixed_string_t name;
3118 : : cmdline_fixed_string_t list_name;
3119 : : cmdline_fixed_string_t list_of_items;
3120 : : };
3121 : :
3122 : : static int
3123 : 0 : parse_reta_config(const char *str,
3124 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3125 : : uint16_t nb_entries)
3126 : : {
3127 : : int i;
3128 : : unsigned size;
3129 : : uint16_t hash_index, idx, shift;
3130 : : uint16_t nb_queue;
3131 : : char s[256];
3132 : : const char *p, *p0 = str;
3133 : : char *end;
3134 : : enum fieldnames {
3135 : : FLD_HASH_INDEX = 0,
3136 : : FLD_QUEUE,
3137 : : _NUM_FLD
3138 : : };
3139 : : unsigned long int_fld[_NUM_FLD];
3140 : : char *str_fld[_NUM_FLD];
3141 : :
3142 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3143 : 0 : ++p;
3144 : 0 : if((p0 = strchr(p,')')) == NULL)
3145 : : return -1;
3146 : :
3147 : 0 : size = p0 - p;
3148 : 0 : if(size >= sizeof(s))
3149 : : return -1;
3150 : :
3151 : : snprintf(s, sizeof(s), "%.*s", size, p);
3152 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3153 : : return -1;
3154 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3155 : 0 : errno = 0;
3156 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3157 : 0 : if (errno != 0 || end == str_fld[i] ||
3158 : : int_fld[i] > 65535)
3159 : : return -1;
3160 : : }
3161 : :
3162 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3163 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3164 : :
3165 : 0 : if (hash_index >= nb_entries) {
3166 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3167 : : hash_index);
3168 : 0 : return -1;
3169 : : }
3170 : :
3171 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3172 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3173 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3174 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3175 : : }
3176 : :
3177 : : return 0;
3178 : : }
3179 : :
3180 : : static void
3181 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3182 : : __rte_unused struct cmdline *cl,
3183 : : __rte_unused void *data)
3184 : : {
3185 : : int ret;
3186 : : struct rte_eth_dev_info dev_info;
3187 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3188 : : struct cmd_config_rss_reta *res = parsed_result;
3189 : :
3190 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3191 : 0 : if (ret != 0)
3192 : 0 : return;
3193 : :
3194 : 0 : if (dev_info.reta_size == 0) {
3195 : 0 : fprintf(stderr,
3196 : : "Redirection table size is 0 which is invalid for RSS\n");
3197 : 0 : return;
3198 : : } else
3199 : 0 : printf("The reta size of port %d is %u\n",
3200 : 0 : res->port_id, dev_info.reta_size);
3201 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3202 : 0 : fprintf(stderr,
3203 : : "Currently do not support more than %u entries of redirection table\n",
3204 : : RTE_ETH_RSS_RETA_SIZE_512);
3205 : 0 : return;
3206 : : }
3207 : :
3208 : : memset(reta_conf, 0, sizeof(reta_conf));
3209 : 0 : if (!strcmp(res->list_name, "reta")) {
3210 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3211 : : dev_info.reta_size)) {
3212 : 0 : fprintf(stderr,
3213 : : "Invalid RSS Redirection Table config entered\n");
3214 : 0 : return;
3215 : : }
3216 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3217 : 0 : reta_conf, dev_info.reta_size);
3218 : 0 : if (ret != 0)
3219 : 0 : fprintf(stderr,
3220 : : "Bad redirection table parameter, return code = %d\n",
3221 : : ret);
3222 : : }
3223 : : }
3224 : :
3225 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3226 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3227 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3228 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3229 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3230 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3231 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3232 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3233 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3234 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3235 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3236 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3237 : : NULL);
3238 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3239 : : .f = cmd_set_rss_reta_parsed,
3240 : : .data = NULL,
3241 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3242 : : .tokens = {
3243 : : (void *)&cmd_config_rss_reta_port,
3244 : : (void *)&cmd_config_rss_reta_keyword,
3245 : : (void *)&cmd_config_rss_reta_port_id,
3246 : : (void *)&cmd_config_rss_reta_name,
3247 : : (void *)&cmd_config_rss_reta_list_name,
3248 : : (void *)&cmd_config_rss_reta_list_of_items,
3249 : : NULL,
3250 : : },
3251 : : };
3252 : :
3253 : : /* *** SHOW PORT RETA INFO *** */
3254 : : struct cmd_showport_reta {
3255 : : cmdline_fixed_string_t show;
3256 : : cmdline_fixed_string_t port;
3257 : : portid_t port_id;
3258 : : cmdline_fixed_string_t rss;
3259 : : cmdline_fixed_string_t reta;
3260 : : uint16_t size;
3261 : : cmdline_fixed_string_t list_of_items;
3262 : : };
3263 : :
3264 : : static int
3265 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3266 : : uint16_t nb_entries,
3267 : : char *str)
3268 : : {
3269 : : uint32_t size;
3270 : : const char *p, *p0 = str;
3271 : : char s[256];
3272 : : char *end;
3273 : : char *str_fld[8];
3274 : : uint16_t i;
3275 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3276 : : RTE_ETH_RETA_GROUP_SIZE;
3277 : : int ret;
3278 : :
3279 : 0 : p = strchr(p0, '(');
3280 : 0 : if (p == NULL)
3281 : : return -1;
3282 : 0 : p++;
3283 : 0 : p0 = strchr(p, ')');
3284 : 0 : if (p0 == NULL)
3285 : : return -1;
3286 : 0 : size = p0 - p;
3287 : 0 : if (size >= sizeof(s)) {
3288 : 0 : fprintf(stderr,
3289 : : "The string size exceeds the internal buffer size\n");
3290 : 0 : return -1;
3291 : : }
3292 : : snprintf(s, sizeof(s), "%.*s", size, p);
3293 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3294 : 0 : if (ret <= 0 || ret != num) {
3295 : 0 : fprintf(stderr,
3296 : : "The bits of masks do not match the number of reta entries: %u\n",
3297 : : num);
3298 : 0 : return -1;
3299 : : }
3300 : 0 : for (i = 0; i < ret; i++)
3301 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3302 : :
3303 : : return 0;
3304 : : }
3305 : :
3306 : : static void
3307 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3308 : : __rte_unused struct cmdline *cl,
3309 : : __rte_unused void *data)
3310 : : {
3311 : : struct cmd_showport_reta *res = parsed_result;
3312 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3313 : : struct rte_eth_dev_info dev_info;
3314 : : uint16_t max_reta_size;
3315 : : int ret;
3316 : :
3317 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3318 : 0 : if (ret != 0)
3319 : 0 : return;
3320 : :
3321 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3322 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3323 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3324 : : res->size, max_reta_size);
3325 : 0 : return;
3326 : : }
3327 : :
3328 : : memset(reta_conf, 0, sizeof(reta_conf));
3329 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3330 : 0 : res->list_of_items) < 0) {
3331 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3332 : : res->list_of_items);
3333 : 0 : return;
3334 : : }
3335 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3336 : : }
3337 : :
3338 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3339 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3340 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3341 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3342 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3343 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3344 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3345 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3346 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3347 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3348 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3349 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3350 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3351 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3352 : : list_of_items, NULL);
3353 : :
3354 : : static cmdline_parse_inst_t cmd_showport_reta = {
3355 : : .f = cmd_showport_reta_parsed,
3356 : : .data = NULL,
3357 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3358 : : .tokens = {
3359 : : (void *)&cmd_showport_reta_show,
3360 : : (void *)&cmd_showport_reta_port,
3361 : : (void *)&cmd_showport_reta_port_id,
3362 : : (void *)&cmd_showport_reta_rss,
3363 : : (void *)&cmd_showport_reta_reta,
3364 : : (void *)&cmd_showport_reta_size,
3365 : : (void *)&cmd_showport_reta_list_of_items,
3366 : : NULL,
3367 : : },
3368 : : };
3369 : :
3370 : : /* *** Show RSS hash configuration *** */
3371 : : struct cmd_showport_rss_hash {
3372 : : cmdline_fixed_string_t show;
3373 : : cmdline_fixed_string_t port;
3374 : : portid_t port_id;
3375 : : cmdline_fixed_string_t rss_hash;
3376 : : cmdline_fixed_string_t rss_type;
3377 : : cmdline_fixed_string_t key; /* optional argument */
3378 : : cmdline_fixed_string_t algorithm; /* optional argument */
3379 : : };
3380 : :
3381 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3382 : : __rte_unused struct cmdline *cl,
3383 : : __rte_unused void *data)
3384 : : {
3385 : : struct cmd_showport_rss_hash *res = parsed_result;
3386 : :
3387 : 0 : port_rss_hash_conf_show(res->port_id,
3388 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3389 : 0 : }
3390 : :
3391 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3392 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3393 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3394 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3395 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3396 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3397 : : RTE_UINT16);
3398 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3399 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3400 : : "rss-hash");
3401 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3402 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3403 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3404 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3405 : :
3406 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3407 : : .f = cmd_showport_rss_hash_parsed,
3408 : : .data = NULL,
3409 : : .help_str = "show port <port_id> rss-hash",
3410 : : .tokens = {
3411 : : (void *)&cmd_showport_rss_hash_show,
3412 : : (void *)&cmd_showport_rss_hash_port,
3413 : : (void *)&cmd_showport_rss_hash_port_id,
3414 : : (void *)&cmd_showport_rss_hash_rss_hash,
3415 : : NULL,
3416 : : },
3417 : : };
3418 : :
3419 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3420 : : .f = cmd_showport_rss_hash_parsed,
3421 : : .data = NULL,
3422 : : .help_str = "show port <port_id> rss-hash key",
3423 : : .tokens = {
3424 : : (void *)&cmd_showport_rss_hash_show,
3425 : : (void *)&cmd_showport_rss_hash_port,
3426 : : (void *)&cmd_showport_rss_hash_port_id,
3427 : : (void *)&cmd_showport_rss_hash_rss_hash,
3428 : : (void *)&cmd_showport_rss_hash_rss_key,
3429 : : NULL,
3430 : : },
3431 : : };
3432 : :
3433 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3434 : : .f = cmd_showport_rss_hash_parsed,
3435 : : .data = NULL,
3436 : : .help_str = "show port <port_id> rss-hash algorithm",
3437 : : .tokens = {
3438 : : (void *)&cmd_showport_rss_hash_show,
3439 : : (void *)&cmd_showport_rss_hash_port,
3440 : : (void *)&cmd_showport_rss_hash_port_id,
3441 : : (void *)&cmd_showport_rss_hash_rss_hash,
3442 : : (void *)&cmd_showport_rss_hash_rss_algo,
3443 : : NULL,
3444 : : },
3445 : : };
3446 : :
3447 : : /* *** Configure DCB *** */
3448 : : struct cmd_config_dcb {
3449 : : cmdline_fixed_string_t port;
3450 : : cmdline_fixed_string_t config;
3451 : : portid_t port_id;
3452 : : cmdline_fixed_string_t dcb;
3453 : : cmdline_fixed_string_t vt;
3454 : : cmdline_fixed_string_t vt_en;
3455 : : uint8_t num_tcs;
3456 : : cmdline_fixed_string_t pfc;
3457 : : cmdline_multi_string_t token_str;
3458 : : };
3459 : :
3460 : : static int
3461 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3462 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3463 : : uint8_t *prio_tc_en)
3464 : : {
3465 : : unsigned long prio, tc;
3466 : : int prio_tc_maps = 0;
3467 : : char *param, *end;
3468 : : int i;
3469 : :
3470 : 0 : for (i = 0; i < param_num; i++) {
3471 : 0 : param = param_str[i];
3472 : 0 : prio = strtoul(param, &end, 10);
3473 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3474 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3475 : 0 : return -1;
3476 : : }
3477 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3478 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3479 : 0 : return -1;
3480 : : }
3481 : 0 : tc = strtoul(end + 1, &end, 10);
3482 : 0 : if (tc >= RTE_ETH_8_TCS) {
3483 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3484 : 0 : return -1;
3485 : : }
3486 : 0 : if (*end != '\0') {
3487 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3488 : 0 : return -1;
3489 : : }
3490 : 0 : prio_tc[prio] = tc;
3491 : 0 : prio_tc_maps++;
3492 : : } while (0);
3493 : :
3494 : 0 : if (prio_tc_maps == 0) {
3495 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3496 : 0 : return -1;
3497 : : }
3498 : 0 : *prio_tc_en = 1;
3499 : :
3500 : 0 : return 0;
3501 : : }
3502 : :
3503 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3504 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3505 : :
3506 : : static int
3507 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3508 : : {
3509 : : int i;
3510 : :
3511 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3512 : 0 : *param_num = 0;
3513 : 0 : return 0;
3514 : : }
3515 : :
3516 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3517 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3518 : 0 : return -EINVAL;
3519 : : }
3520 : :
3521 : 0 : for (i = 1; i < split_num; i++) {
3522 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3523 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3524 : : continue;
3525 : : /* find another optional parameter, then exit. */
3526 : : break;
3527 : : }
3528 : :
3529 : 0 : *param_num = i - 1;
3530 : :
3531 : 0 : return 0;
3532 : : }
3533 : :
3534 : : static int
3535 : 0 : parse_dcb_token_value(char *token_str,
3536 : : uint8_t *pfc_en,
3537 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3538 : : uint8_t *prio_tc_en,
3539 : : uint8_t *keep_qnum)
3540 : : {
3541 : : #define MAX_TOKEN_NUM 128
3542 : : char *split_str[MAX_TOKEN_NUM];
3543 : : int param_num, start, ret;
3544 : : int split_num = 0;
3545 : : char *token;
3546 : :
3547 : : /* split multiple token to split str. */
3548 : : do {
3549 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3550 : 0 : if (token == NULL)
3551 : : break;
3552 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3553 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3554 : 0 : return -1;
3555 : : }
3556 : 0 : split_str[split_num++] = token;
3557 : : } while (1);
3558 : :
3559 : : /* parse fixed parameter "pfc-en" first. */
3560 : 0 : token = split_str[0];
3561 : 0 : if (strcmp(token, "on") == 0)
3562 : 0 : *pfc_en = 1;
3563 : 0 : else if (strcmp(token, "off") == 0)
3564 : 0 : *pfc_en = 0;
3565 : : else {
3566 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3567 : 0 : return -EINVAL;
3568 : : }
3569 : :
3570 : 0 : if (split_num == 1)
3571 : : return 0;
3572 : :
3573 : : /* start parse optional parameter. */
3574 : : start = 1;
3575 : : do {
3576 : 0 : param_num = 0;
3577 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3578 : 0 : if (ret != 0)
3579 : 0 : return ret;
3580 : :
3581 : 0 : token = split_str[start];
3582 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3583 : 0 : if (*prio_tc_en == 1) {
3584 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3585 : : DCB_TOKEN_PRIO_TC);
3586 : 0 : return -1;
3587 : : }
3588 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3589 : : prio_tc_en);
3590 : 0 : if (ret != 0)
3591 : 0 : return ret;
3592 : : } else {
3593 : : /* this must be keep-qnum. */
3594 : 0 : if (*keep_qnum == 1) {
3595 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3596 : : DCB_TOKEN_KEEP_QNUM);
3597 : 0 : return -1;
3598 : : }
3599 : 0 : *keep_qnum = 1;
3600 : : }
3601 : :
3602 : 0 : start += param_num + 1;
3603 : 0 : if (start >= split_num)
3604 : : break;
3605 : : } while (1);
3606 : :
3607 : : return 0;
3608 : : }
3609 : :
3610 : : static void
3611 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3612 : : __rte_unused struct cmdline *cl,
3613 : : __rte_unused void *data)
3614 : : {
3615 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3616 : : struct cmd_config_dcb *res = parsed_result;
3617 : : struct rte_eth_dcb_info dcb_info;
3618 : 0 : portid_t port_id = res->port_id;
3619 : 0 : uint8_t prio_tc_en = 0;
3620 : 0 : uint8_t keep_qnum = 0;
3621 : : struct rte_port *port;
3622 : 0 : uint8_t pfc_en = 0;
3623 : : int ret;
3624 : :
3625 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3626 : 0 : return;
3627 : :
3628 : 0 : port = &ports[port_id];
3629 : : /** Check if the port is not started **/
3630 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3631 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3632 : 0 : return;
3633 : : }
3634 : :
3635 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3636 : 0 : fprintf(stderr,
3637 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3638 : 0 : return;
3639 : : }
3640 : :
3641 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3642 : 0 : fprintf(stderr,
3643 : : "nb_cores shouldn't be less than number of TCs.\n");
3644 : 0 : return;
3645 : : }
3646 : :
3647 : : /* Check whether the port supports the report of DCB info. */
3648 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3649 : 0 : if (ret == -ENOTSUP) {
3650 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3651 : 0 : return;
3652 : : }
3653 : :
3654 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3655 : 0 : if (ret != 0)
3656 : : return;
3657 : :
3658 : : /* DCB in VT mode */
3659 : 0 : if (!strncmp(res->vt_en, "on", 2))
3660 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3661 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3662 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3663 : : else
3664 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3665 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3666 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3667 : 0 : if (ret != 0) {
3668 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3669 : 0 : return;
3670 : : }
3671 : :
3672 : 0 : fwd_config_setup();
3673 : :
3674 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3675 : : }
3676 : :
3677 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3678 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3679 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3680 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3681 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3682 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3683 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3684 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3685 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3686 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3687 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3688 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3689 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3690 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3691 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3692 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3693 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3694 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3695 : :
3696 : : static cmdline_parse_inst_t cmd_config_dcb = {
3697 : : .f = cmd_config_dcb_parsed,
3698 : : .data = NULL,
3699 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3700 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3701 : : " PRIO-MAPPING := PRIO:TC\n"
3702 : : " PRIO: { 0 .. 7 }\n"
3703 : : " TC: { 0 .. 7 }",
3704 : : .tokens = {
3705 : : (void *)&cmd_config_dcb_port,
3706 : : (void *)&cmd_config_dcb_config,
3707 : : (void *)&cmd_config_dcb_port_id,
3708 : : (void *)&cmd_config_dcb_dcb,
3709 : : (void *)&cmd_config_dcb_vt,
3710 : : (void *)&cmd_config_dcb_vt_en,
3711 : : (void *)&cmd_config_dcb_num_tcs,
3712 : : (void *)&cmd_config_dcb_pfc,
3713 : : (void *)&cmd_config_dcb_token_str,
3714 : : NULL,
3715 : : },
3716 : : };
3717 : :
3718 : : /* *** configure number of packets per burst *** */
3719 : : struct cmd_config_burst {
3720 : : cmdline_fixed_string_t port;
3721 : : cmdline_fixed_string_t keyword;
3722 : : cmdline_fixed_string_t all;
3723 : : cmdline_fixed_string_t name;
3724 : : uint16_t value;
3725 : : };
3726 : :
3727 : : static void
3728 : 0 : cmd_config_burst_parsed(void *parsed_result,
3729 : : __rte_unused struct cmdline *cl,
3730 : : __rte_unused void *data)
3731 : : {
3732 : : struct cmd_config_burst *res = parsed_result;
3733 : : struct rte_eth_dev_info dev_info;
3734 : : uint16_t rec_nb_pkts;
3735 : : int ret;
3736 : :
3737 : 0 : if (!all_ports_stopped()) {
3738 : 0 : fprintf(stderr, "Please stop all ports first\n");
3739 : 0 : return;
3740 : : }
3741 : :
3742 : 0 : if (!strcmp(res->name, "burst")) {
3743 : 0 : if (res->value == 0) {
3744 : : /* If user gives a value of zero, query the PMD for
3745 : : * its recommended Rx burst size. Testpmd uses a single
3746 : : * size for all ports, so assume all ports are the same
3747 : : * NIC model and use the values from Port 0.
3748 : : */
3749 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3750 : 0 : if (ret != 0)
3751 : : return;
3752 : :
3753 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3754 : :
3755 : 0 : if (rec_nb_pkts == 0) {
3756 : : printf("PMD does not recommend a burst size.\n"
3757 : : "User provided value must be between"
3758 : : " 1 and %d\n", MAX_PKT_BURST);
3759 : 0 : return;
3760 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3761 : 0 : printf("PMD recommended burst size of %d"
3762 : : " exceeds maximum value of %d\n",
3763 : : rec_nb_pkts, MAX_PKT_BURST);
3764 : 0 : return;
3765 : : }
3766 : 0 : printf("Using PMD-provided burst value of %d\n",
3767 : : rec_nb_pkts);
3768 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3769 : 0 : } else if (res->value > MAX_PKT_BURST) {
3770 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3771 : : MAX_PKT_BURST);
3772 : 0 : return;
3773 : : } else
3774 : 0 : nb_pkt_per_burst = res->value;
3775 : : } else {
3776 : 0 : fprintf(stderr, "Unknown parameter\n");
3777 : 0 : return;
3778 : : }
3779 : :
3780 : 0 : init_port_config();
3781 : :
3782 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3783 : : }
3784 : :
3785 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3786 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3787 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3788 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3789 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3790 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3791 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3792 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3793 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3794 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3795 : :
3796 : : static cmdline_parse_inst_t cmd_config_burst = {
3797 : : .f = cmd_config_burst_parsed,
3798 : : .data = NULL,
3799 : : .help_str = "port config all burst <value>",
3800 : : .tokens = {
3801 : : (void *)&cmd_config_burst_port,
3802 : : (void *)&cmd_config_burst_keyword,
3803 : : (void *)&cmd_config_burst_all,
3804 : : (void *)&cmd_config_burst_name,
3805 : : (void *)&cmd_config_burst_value,
3806 : : NULL,
3807 : : },
3808 : : };
3809 : :
3810 : : /* *** configure rx/tx queues *** */
3811 : : struct cmd_config_thresh {
3812 : : cmdline_fixed_string_t port;
3813 : : cmdline_fixed_string_t keyword;
3814 : : cmdline_fixed_string_t all;
3815 : : cmdline_fixed_string_t name;
3816 : : uint8_t value;
3817 : : };
3818 : :
3819 : : static void
3820 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3821 : : __rte_unused struct cmdline *cl,
3822 : : __rte_unused void *data)
3823 : : {
3824 : : struct cmd_config_thresh *res = parsed_result;
3825 : :
3826 : 0 : if (!all_ports_stopped()) {
3827 : 0 : fprintf(stderr, "Please stop all ports first\n");
3828 : 0 : return;
3829 : : }
3830 : :
3831 : 0 : if (!strcmp(res->name, "txpt"))
3832 : 0 : tx_pthresh = res->value;
3833 : 0 : else if(!strcmp(res->name, "txht"))
3834 : 0 : tx_hthresh = res->value;
3835 : 0 : else if(!strcmp(res->name, "txwt"))
3836 : 0 : tx_wthresh = res->value;
3837 : 0 : else if(!strcmp(res->name, "rxpt"))
3838 : 0 : rx_pthresh = res->value;
3839 : 0 : else if(!strcmp(res->name, "rxht"))
3840 : 0 : rx_hthresh = res->value;
3841 : 0 : else if(!strcmp(res->name, "rxwt"))
3842 : 0 : rx_wthresh = res->value;
3843 : : else {
3844 : 0 : fprintf(stderr, "Unknown parameter\n");
3845 : 0 : return;
3846 : : }
3847 : :
3848 : 0 : init_port_config();
3849 : :
3850 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3851 : : }
3852 : :
3853 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3854 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3855 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3856 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3857 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3858 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3859 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3860 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3861 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3862 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3863 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3864 : :
3865 : : static cmdline_parse_inst_t cmd_config_thresh = {
3866 : : .f = cmd_config_thresh_parsed,
3867 : : .data = NULL,
3868 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3869 : : .tokens = {
3870 : : (void *)&cmd_config_thresh_port,
3871 : : (void *)&cmd_config_thresh_keyword,
3872 : : (void *)&cmd_config_thresh_all,
3873 : : (void *)&cmd_config_thresh_name,
3874 : : (void *)&cmd_config_thresh_value,
3875 : : NULL,
3876 : : },
3877 : : };
3878 : :
3879 : : /* *** configure free/rs threshold *** */
3880 : : struct cmd_config_threshold {
3881 : : cmdline_fixed_string_t port;
3882 : : cmdline_fixed_string_t keyword;
3883 : : cmdline_fixed_string_t all;
3884 : : cmdline_fixed_string_t name;
3885 : : uint16_t value;
3886 : : };
3887 : :
3888 : : static void
3889 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3890 : : __rte_unused struct cmdline *cl,
3891 : : __rte_unused void *data)
3892 : : {
3893 : : struct cmd_config_threshold *res = parsed_result;
3894 : :
3895 : 0 : if (!all_ports_stopped()) {
3896 : 0 : fprintf(stderr, "Please stop all ports first\n");
3897 : 0 : return;
3898 : : }
3899 : :
3900 : 0 : if (!strcmp(res->name, "txfreet"))
3901 : 0 : tx_free_thresh = res->value;
3902 : 0 : else if (!strcmp(res->name, "txrst"))
3903 : 0 : tx_rs_thresh = res->value;
3904 : 0 : else if (!strcmp(res->name, "rxfreet"))
3905 : 0 : rx_free_thresh = res->value;
3906 : : else {
3907 : 0 : fprintf(stderr, "Unknown parameter\n");
3908 : 0 : return;
3909 : : }
3910 : :
3911 : 0 : init_port_config();
3912 : :
3913 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3914 : : }
3915 : :
3916 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3917 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3918 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3919 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3920 : : "config");
3921 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3922 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3923 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3924 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3925 : : "txfreet#txrst#rxfreet");
3926 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3927 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3928 : :
3929 : : static cmdline_parse_inst_t cmd_config_threshold = {
3930 : : .f = cmd_config_threshold_parsed,
3931 : : .data = NULL,
3932 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3933 : : .tokens = {
3934 : : (void *)&cmd_config_threshold_port,
3935 : : (void *)&cmd_config_threshold_keyword,
3936 : : (void *)&cmd_config_threshold_all,
3937 : : (void *)&cmd_config_threshold_name,
3938 : : (void *)&cmd_config_threshold_value,
3939 : : NULL,
3940 : : },
3941 : : };
3942 : :
3943 : : /* *** stop *** */
3944 : : struct cmd_stop_result {
3945 : : cmdline_fixed_string_t stop;
3946 : : };
3947 : :
3948 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3949 : : __rte_unused struct cmdline *cl,
3950 : : __rte_unused void *data)
3951 : : {
3952 : 0 : stop_packet_forwarding();
3953 : 0 : }
3954 : :
3955 : : static cmdline_parse_token_string_t cmd_stop_stop =
3956 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3957 : :
3958 : : static cmdline_parse_inst_t cmd_stop = {
3959 : : .f = cmd_stop_parsed,
3960 : : .data = NULL,
3961 : : .help_str = "stop: Stop packet forwarding",
3962 : : .tokens = {
3963 : : (void *)&cmd_stop_stop,
3964 : : NULL,
3965 : : },
3966 : : };
3967 : :
3968 : : static unsigned int
3969 : 0 : get_ptype(char *value)
3970 : : {
3971 : : uint32_t protocol;
3972 : :
3973 : 0 : if (!strcmp(value, "eth"))
3974 : : protocol = RTE_PTYPE_L2_ETHER;
3975 : 0 : else if (!strcmp(value, "ipv4"))
3976 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3977 : 0 : else if (!strcmp(value, "ipv6"))
3978 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3979 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3980 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3981 : 0 : else if (!strcmp(value, "ipv4-udp"))
3982 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3983 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3984 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3985 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3986 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3987 : 0 : else if (!strcmp(value, "ipv6-udp"))
3988 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3989 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3990 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3991 : 0 : else if (!strcmp(value, "grenat"))
3992 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3993 : 0 : else if (!strcmp(value, "inner-eth"))
3994 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3995 : 0 : else if (!strcmp(value, "inner-ipv4"))
3996 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3997 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3998 : 0 : else if (!strcmp(value, "inner-ipv6"))
3999 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4000 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4001 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4002 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4003 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4004 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4005 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4006 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4007 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4008 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4009 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4010 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4011 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4012 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4013 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4014 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4015 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4016 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4017 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4018 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4019 : : else {
4020 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4021 : : protocol = RTE_PTYPE_UNKNOWN;
4022 : : }
4023 : :
4024 : 0 : return protocol;
4025 : : }
4026 : :
4027 : : /* *** SET RXHDRSLIST *** */
4028 : :
4029 : : unsigned int
4030 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4031 : : unsigned int *parsed_items)
4032 : : {
4033 : : unsigned int nb_item;
4034 : : char *cur;
4035 : : char *tmp;
4036 : :
4037 : : nb_item = 0;
4038 : 0 : char *str2 = strdup(str);
4039 : 0 : if (str2 == NULL)
4040 : : return nb_item;
4041 : 0 : cur = strtok_r(str2, ",", &tmp);
4042 : 0 : while (cur != NULL) {
4043 : 0 : parsed_items[nb_item] = get_ptype(cur);
4044 : 0 : cur = strtok_r(NULL, ",", &tmp);
4045 : 0 : nb_item++;
4046 : : }
4047 : 0 : if (nb_item > max_items)
4048 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4049 : : item_name, nb_item + 1, max_items);
4050 : 0 : free(str2);
4051 : 0 : return nb_item;
4052 : : }
4053 : :
4054 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4055 : :
4056 : : unsigned int
4057 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4058 : : unsigned int *parsed_items, int check_unique_values)
4059 : : {
4060 : : unsigned int nb_item;
4061 : : unsigned int value;
4062 : : unsigned int i;
4063 : : unsigned int j;
4064 : : int value_ok;
4065 : : char c;
4066 : :
4067 : : /*
4068 : : * First parse all items in the list and store their value.
4069 : : */
4070 : : value = 0;
4071 : : nb_item = 0;
4072 : : value_ok = 0;
4073 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4074 : 0 : c = str[i];
4075 : 0 : if ((c >= '0') && (c <= '9')) {
4076 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4077 : : value_ok = 1;
4078 : 0 : continue;
4079 : : }
4080 : 0 : if (c != ',') {
4081 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4082 : 0 : return 0;
4083 : : }
4084 : 0 : if (! value_ok) {
4085 : 0 : fprintf(stderr, "No valid value before comma\n");
4086 : 0 : return 0;
4087 : : }
4088 : 0 : if (nb_item < max_items) {
4089 : 0 : parsed_items[nb_item] = value;
4090 : : value_ok = 0;
4091 : : value = 0;
4092 : : }
4093 : 0 : nb_item++;
4094 : : }
4095 : 0 : if (nb_item >= max_items) {
4096 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4097 : : item_name, nb_item + 1, max_items);
4098 : 0 : return 0;
4099 : : }
4100 : 0 : parsed_items[nb_item++] = value;
4101 : 0 : if (! check_unique_values)
4102 : : return nb_item;
4103 : :
4104 : : /*
4105 : : * Then, check that all values in the list are different.
4106 : : * No optimization here...
4107 : : */
4108 : 0 : for (i = 0; i < nb_item; i++) {
4109 : 0 : for (j = i + 1; j < nb_item; j++) {
4110 : 0 : if (parsed_items[j] == parsed_items[i]) {
4111 : 0 : fprintf(stderr,
4112 : : "duplicated %s %u at index %u and %u\n",
4113 : : item_name, parsed_items[i], i, j);
4114 : 0 : return 0;
4115 : : }
4116 : : }
4117 : : }
4118 : : return nb_item;
4119 : : }
4120 : :
4121 : : struct cmd_set_list_result {
4122 : : cmdline_fixed_string_t cmd_keyword;
4123 : : cmdline_fixed_string_t list_name;
4124 : : cmdline_multi_string_t list_of_items;
4125 : : };
4126 : :
4127 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4128 : : __rte_unused struct cmdline *cl,
4129 : : __rte_unused void *data)
4130 : : {
4131 : : struct cmd_set_list_result *res;
4132 : : union {
4133 : : unsigned int lcorelist[RTE_MAX_LCORE];
4134 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4135 : : } parsed_items;
4136 : : unsigned int nb_item;
4137 : :
4138 : 0 : if (test_done == 0) {
4139 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4140 : 0 : return;
4141 : : }
4142 : :
4143 : : res = parsed_result;
4144 : 0 : if (!strcmp(res->list_name, "corelist")) {
4145 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4146 : : RTE_MAX_LCORE,
4147 : : parsed_items.lcorelist, 1);
4148 : 0 : if (nb_item > 0) {
4149 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4150 : 0 : fwd_config_setup();
4151 : : }
4152 : 0 : return;
4153 : : }
4154 : 0 : if (!strcmp(res->list_name, "portlist")) {
4155 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4156 : : RTE_MAX_ETHPORTS,
4157 : : parsed_items.portlist, 1);
4158 : 0 : if (nb_item > 0) {
4159 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4160 : 0 : fwd_config_setup();
4161 : : }
4162 : : }
4163 : : }
4164 : :
4165 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4166 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4167 : : "set");
4168 : : static cmdline_parse_token_string_t cmd_set_list_name =
4169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4170 : : "corelist#portlist");
4171 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4172 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4173 : : TOKEN_STRING_MULTI);
4174 : :
4175 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4176 : : .f = cmd_set_list_parsed,
4177 : : .data = NULL,
4178 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4179 : : .tokens = {
4180 : : (void *)&cmd_set_list_keyword,
4181 : : (void *)&cmd_set_list_name,
4182 : : (void *)&cmd_set_list_of_items,
4183 : : NULL,
4184 : : },
4185 : : };
4186 : :
4187 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4188 : :
4189 : : struct cmd_setmask_result {
4190 : : cmdline_fixed_string_t set;
4191 : : cmdline_fixed_string_t mask;
4192 : : uint64_t hexavalue;
4193 : : };
4194 : :
4195 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4196 : : __rte_unused struct cmdline *cl,
4197 : : __rte_unused void *data)
4198 : : {
4199 : : struct cmd_setmask_result *res = parsed_result;
4200 : :
4201 : 0 : if (test_done == 0) {
4202 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4203 : 0 : return;
4204 : : }
4205 : 0 : if (!strcmp(res->mask, "coremask")) {
4206 : 0 : set_fwd_lcores_mask(res->hexavalue);
4207 : 0 : fwd_config_setup();
4208 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4209 : 0 : set_fwd_ports_mask(res->hexavalue);
4210 : 0 : fwd_config_setup();
4211 : : }
4212 : : }
4213 : :
4214 : : static cmdline_parse_token_string_t cmd_setmask_set =
4215 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4216 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4217 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4218 : : "coremask#portmask");
4219 : : static cmdline_parse_token_num_t cmd_setmask_value =
4220 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4221 : :
4222 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4223 : : .f = cmd_set_mask_parsed,
4224 : : .data = NULL,
4225 : : .help_str = "set coremask|portmask <hexadecimal value>",
4226 : : .tokens = {
4227 : : (void *)&cmd_setmask_set,
4228 : : (void *)&cmd_setmask_mask,
4229 : : (void *)&cmd_setmask_value,
4230 : : NULL,
4231 : : },
4232 : : };
4233 : :
4234 : : /*
4235 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4236 : : */
4237 : : struct cmd_set_result {
4238 : : cmdline_fixed_string_t set;
4239 : : cmdline_fixed_string_t what;
4240 : : uint16_t value;
4241 : : };
4242 : :
4243 : 0 : static void cmd_set_parsed(void *parsed_result,
4244 : : __rte_unused struct cmdline *cl,
4245 : : __rte_unused void *data)
4246 : : {
4247 : : struct cmd_set_result *res = parsed_result;
4248 : 0 : if (!strcmp(res->what, "nbport")) {
4249 : 0 : set_fwd_ports_number(res->value);
4250 : 0 : fwd_config_setup();
4251 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4252 : 0 : set_fwd_lcores_number(res->value);
4253 : 0 : fwd_config_setup();
4254 : 0 : } else if (!strcmp(res->what, "burst"))
4255 : 0 : set_nb_pkt_per_burst(res->value);
4256 : 0 : else if (!strcmp(res->what, "verbose"))
4257 : 0 : set_verbose_level(res->value);
4258 : 0 : }
4259 : :
4260 : : static cmdline_parse_token_string_t cmd_set_set =
4261 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4262 : : static cmdline_parse_token_string_t cmd_set_what =
4263 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4264 : : "nbport#nbcore#burst#verbose");
4265 : : static cmdline_parse_token_num_t cmd_set_value =
4266 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4267 : :
4268 : : static cmdline_parse_inst_t cmd_set_numbers = {
4269 : : .f = cmd_set_parsed,
4270 : : .data = NULL,
4271 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4272 : : .tokens = {
4273 : : (void *)&cmd_set_set,
4274 : : (void *)&cmd_set_what,
4275 : : (void *)&cmd_set_value,
4276 : : NULL,
4277 : : },
4278 : : };
4279 : :
4280 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4281 : :
4282 : : struct cmd_set_log_result {
4283 : : cmdline_fixed_string_t set;
4284 : : cmdline_fixed_string_t log;
4285 : : cmdline_fixed_string_t type;
4286 : : uint32_t level;
4287 : : };
4288 : :
4289 : : static void
4290 : 0 : cmd_set_log_parsed(void *parsed_result,
4291 : : __rte_unused struct cmdline *cl,
4292 : : __rte_unused void *data)
4293 : : {
4294 : : struct cmd_set_log_result *res;
4295 : : int ret;
4296 : :
4297 : : res = parsed_result;
4298 : 0 : if (!strcmp(res->type, "global"))
4299 : 0 : rte_log_set_global_level(res->level);
4300 : : else {
4301 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4302 : 0 : if (ret < 0)
4303 : 0 : fprintf(stderr, "Unable to set log level\n");
4304 : : }
4305 : 0 : }
4306 : :
4307 : : static cmdline_parse_token_string_t cmd_set_log_set =
4308 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4309 : : static cmdline_parse_token_string_t cmd_set_log_log =
4310 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4311 : : static cmdline_parse_token_string_t cmd_set_log_type =
4312 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4313 : : static cmdline_parse_token_num_t cmd_set_log_level =
4314 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4315 : :
4316 : : static cmdline_parse_inst_t cmd_set_log = {
4317 : : .f = cmd_set_log_parsed,
4318 : : .data = NULL,
4319 : : .help_str = "set log global|<type> <level>",
4320 : : .tokens = {
4321 : : (void *)&cmd_set_log_set,
4322 : : (void *)&cmd_set_log_log,
4323 : : (void *)&cmd_set_log_type,
4324 : : (void *)&cmd_set_log_level,
4325 : : NULL,
4326 : : },
4327 : : };
4328 : :
4329 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4330 : :
4331 : : struct cmd_set_rxoffs_result {
4332 : : cmdline_fixed_string_t cmd_keyword;
4333 : : cmdline_fixed_string_t rxoffs;
4334 : : cmdline_fixed_string_t seg_offsets;
4335 : : };
4336 : :
4337 : : static void
4338 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4339 : : __rte_unused struct cmdline *cl,
4340 : : __rte_unused void *data)
4341 : : {
4342 : : struct cmd_set_rxoffs_result *res;
4343 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4344 : : unsigned int nb_segs;
4345 : :
4346 : : res = parsed_result;
4347 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4348 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4349 : 0 : if (nb_segs > 0)
4350 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4351 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4352 : 0 : }
4353 : :
4354 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4355 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4356 : : cmd_keyword, "set");
4357 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4359 : : rxoffs, "rxoffs");
4360 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4361 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4362 : : seg_offsets, NULL);
4363 : :
4364 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4365 : : .f = cmd_set_rxoffs_parsed,
4366 : : .data = NULL,
4367 : : .help_str = "set rxoffs <len0[,len1]*>",
4368 : : .tokens = {
4369 : : (void *)&cmd_set_rxoffs_keyword,
4370 : : (void *)&cmd_set_rxoffs_name,
4371 : : (void *)&cmd_set_rxoffs_offsets,
4372 : : NULL,
4373 : : },
4374 : : };
4375 : :
4376 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4377 : :
4378 : : struct cmd_set_rxpkts_result {
4379 : : cmdline_fixed_string_t cmd_keyword;
4380 : : cmdline_fixed_string_t rxpkts;
4381 : : cmdline_fixed_string_t seg_lengths;
4382 : : };
4383 : :
4384 : : static void
4385 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4386 : : __rte_unused struct cmdline *cl,
4387 : : __rte_unused void *data)
4388 : : {
4389 : : struct cmd_set_rxpkts_result *res;
4390 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4391 : : unsigned int nb_segs;
4392 : :
4393 : : res = parsed_result;
4394 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4395 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4396 : 0 : if (nb_segs > 0)
4397 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4398 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4399 : 0 : }
4400 : :
4401 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4402 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4403 : : cmd_keyword, "set");
4404 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4406 : : rxpkts, "rxpkts");
4407 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4408 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4409 : : seg_lengths, NULL);
4410 : :
4411 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4412 : : .f = cmd_set_rxpkts_parsed,
4413 : : .data = NULL,
4414 : : .help_str = "set rxpkts <len0[,len1]*>",
4415 : : .tokens = {
4416 : : (void *)&cmd_set_rxpkts_keyword,
4417 : : (void *)&cmd_set_rxpkts_name,
4418 : : (void *)&cmd_set_rxpkts_lengths,
4419 : : NULL,
4420 : : },
4421 : : };
4422 : :
4423 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4424 : : struct cmd_set_rxhdrs_result {
4425 : : cmdline_fixed_string_t set;
4426 : : cmdline_fixed_string_t rxhdrs;
4427 : : cmdline_fixed_string_t values;
4428 : : };
4429 : :
4430 : : static void
4431 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4432 : : __rte_unused struct cmdline *cl,
4433 : : __rte_unused void *data)
4434 : : {
4435 : : struct cmd_set_rxhdrs_result *res;
4436 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4437 : : unsigned int nb_segs;
4438 : :
4439 : : res = parsed_result;
4440 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4441 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4442 : 0 : if (nb_segs > 0)
4443 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4444 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4445 : 0 : }
4446 : :
4447 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4449 : : set, "set");
4450 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4452 : : rxhdrs, "rxhdrs");
4453 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4455 : : values, NULL);
4456 : :
4457 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4458 : : .f = cmd_set_rxhdrs_parsed,
4459 : : .data = NULL,
4460 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4461 : : .tokens = {
4462 : : (void *)&cmd_set_rxhdrs_set,
4463 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4464 : : (void *)&cmd_set_rxhdrs_values,
4465 : : NULL,
4466 : : },
4467 : : };
4468 : :
4469 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4470 : :
4471 : : struct cmd_set_txpkts_result {
4472 : : cmdline_fixed_string_t cmd_keyword;
4473 : : cmdline_fixed_string_t txpkts;
4474 : : cmdline_fixed_string_t seg_lengths;
4475 : : };
4476 : :
4477 : : static void
4478 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4479 : : __rte_unused struct cmdline *cl,
4480 : : __rte_unused void *data)
4481 : : {
4482 : : struct cmd_set_txpkts_result *res;
4483 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4484 : : unsigned int nb_segs;
4485 : :
4486 : : res = parsed_result;
4487 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4488 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4489 : 0 : if (nb_segs > 0)
4490 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4491 : 0 : }
4492 : :
4493 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4494 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4495 : : cmd_keyword, "set");
4496 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4497 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4498 : : txpkts, "txpkts");
4499 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4501 : : seg_lengths, NULL);
4502 : :
4503 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4504 : : .f = cmd_set_txpkts_parsed,
4505 : : .data = NULL,
4506 : : .help_str = "set txpkts <len0[,len1]*>",
4507 : : .tokens = {
4508 : : (void *)&cmd_set_txpkts_keyword,
4509 : : (void *)&cmd_set_txpkts_name,
4510 : : (void *)&cmd_set_txpkts_lengths,
4511 : : NULL,
4512 : : },
4513 : : };
4514 : :
4515 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4516 : :
4517 : : struct cmd_set_txsplit_result {
4518 : : cmdline_fixed_string_t cmd_keyword;
4519 : : cmdline_fixed_string_t txsplit;
4520 : : cmdline_fixed_string_t mode;
4521 : : };
4522 : :
4523 : : static void
4524 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4525 : : __rte_unused struct cmdline *cl,
4526 : : __rte_unused void *data)
4527 : : {
4528 : : struct cmd_set_txsplit_result *res;
4529 : :
4530 : : res = parsed_result;
4531 : 0 : set_tx_pkt_split(res->mode);
4532 : 0 : }
4533 : :
4534 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4535 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4536 : : cmd_keyword, "set");
4537 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4538 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4539 : : txsplit, "txsplit");
4540 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4541 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4542 : : mode, NULL);
4543 : :
4544 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4545 : : .f = cmd_set_txsplit_parsed,
4546 : : .data = NULL,
4547 : : .help_str = "set txsplit on|off|rand",
4548 : : .tokens = {
4549 : : (void *)&cmd_set_txsplit_keyword,
4550 : : (void *)&cmd_set_txsplit_name,
4551 : : (void *)&cmd_set_txsplit_mode,
4552 : : NULL,
4553 : : },
4554 : : };
4555 : :
4556 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4557 : :
4558 : : struct cmd_set_txtimes_result {
4559 : : cmdline_fixed_string_t cmd_keyword;
4560 : : cmdline_fixed_string_t txtimes;
4561 : : cmdline_fixed_string_t tx_times;
4562 : : };
4563 : :
4564 : : static void
4565 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4566 : : __rte_unused struct cmdline *cl,
4567 : : __rte_unused void *data)
4568 : : {
4569 : : struct cmd_set_txtimes_result *res;
4570 : 0 : unsigned int tx_times[2] = {0, 0};
4571 : : unsigned int n_times;
4572 : :
4573 : : res = parsed_result;
4574 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4575 : : 2, tx_times, 0);
4576 : 0 : if (n_times == 2)
4577 : 0 : set_tx_pkt_times(tx_times);
4578 : 0 : }
4579 : :
4580 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4581 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4582 : : cmd_keyword, "set");
4583 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4584 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4585 : : txtimes, "txtimes");
4586 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4587 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4588 : : tx_times, NULL);
4589 : :
4590 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4591 : : .f = cmd_set_txtimes_parsed,
4592 : : .data = NULL,
4593 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4594 : : .tokens = {
4595 : : (void *)&cmd_set_txtimes_keyword,
4596 : : (void *)&cmd_set_txtimes_name,
4597 : : (void *)&cmd_set_txtimes_value,
4598 : : NULL,
4599 : : },
4600 : : };
4601 : :
4602 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4603 : : struct cmd_rx_vlan_filter_all_result {
4604 : : cmdline_fixed_string_t rx_vlan;
4605 : : cmdline_fixed_string_t what;
4606 : : cmdline_fixed_string_t all;
4607 : : portid_t port_id;
4608 : : };
4609 : :
4610 : : static void
4611 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4612 : : __rte_unused struct cmdline *cl,
4613 : : __rte_unused void *data)
4614 : : {
4615 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4616 : :
4617 : 0 : if (!strcmp(res->what, "add"))
4618 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4619 : : else
4620 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4621 : 0 : }
4622 : :
4623 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4624 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4625 : : rx_vlan, "rx_vlan");
4626 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4627 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4628 : : what, "add#rm");
4629 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4630 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4631 : : all, "all");
4632 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4633 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4634 : : port_id, RTE_UINT16);
4635 : :
4636 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4637 : : .f = cmd_rx_vlan_filter_all_parsed,
4638 : : .data = NULL,
4639 : : .help_str = "rx_vlan add|rm all <port_id>: "
4640 : : "Add/Remove all identifiers to/from the set of VLAN "
4641 : : "identifiers filtered by a port",
4642 : : .tokens = {
4643 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4644 : : (void *)&cmd_rx_vlan_filter_all_what,
4645 : : (void *)&cmd_rx_vlan_filter_all_all,
4646 : : (void *)&cmd_rx_vlan_filter_all_portid,
4647 : : NULL,
4648 : : },
4649 : : };
4650 : :
4651 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4652 : : struct cmd_vlan_offload_result {
4653 : : cmdline_fixed_string_t vlan;
4654 : : cmdline_fixed_string_t set;
4655 : : cmdline_fixed_string_t vlan_type;
4656 : : cmdline_fixed_string_t what;
4657 : : cmdline_fixed_string_t on;
4658 : : cmdline_fixed_string_t port_id;
4659 : : };
4660 : :
4661 : : static void
4662 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4663 : : __rte_unused struct cmdline *cl,
4664 : : __rte_unused void *data)
4665 : : {
4666 : : int on;
4667 : : struct cmd_vlan_offload_result *res = parsed_result;
4668 : : char *str;
4669 : : int i, len = 0;
4670 : : portid_t port_id = 0;
4671 : : unsigned int tmp;
4672 : :
4673 : 0 : str = res->port_id;
4674 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4675 : : i = 0;
4676 : : /* Get port_id first */
4677 : 0 : while(i < len){
4678 : 0 : if(str[i] == ',')
4679 : : break;
4680 : :
4681 : 0 : i++;
4682 : : }
4683 : 0 : str[i]='\0';
4684 : 0 : tmp = strtoul(str, NULL, 0);
4685 : : /* If port_id greater that what portid_t can represent, return */
4686 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4687 : : return;
4688 : 0 : port_id = (portid_t)tmp;
4689 : :
4690 : 0 : if (!strcmp(res->on, "on"))
4691 : : on = 1;
4692 : : else
4693 : : on = 0;
4694 : :
4695 : 0 : if (!strcmp(res->what, "strip"))
4696 : 0 : rx_vlan_strip_set(port_id, on);
4697 : 0 : else if(!strcmp(res->what, "stripq")){
4698 : : uint16_t queue_id = 0;
4699 : :
4700 : : /* No queue_id, return */
4701 : 0 : if(i + 1 >= len) {
4702 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4703 : 0 : return;
4704 : : }
4705 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4706 : : /* If queue_id greater that what 16-bits can represent, return */
4707 : 0 : if(tmp > 0xffff)
4708 : : return;
4709 : :
4710 : 0 : queue_id = (uint16_t)tmp;
4711 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4712 : : }
4713 : 0 : else if (!strcmp(res->what, "filter"))
4714 : 0 : rx_vlan_filter_set(port_id, on);
4715 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4716 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4717 : : else
4718 : 0 : vlan_extend_set(port_id, on);
4719 : :
4720 : : return;
4721 : : }
4722 : :
4723 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4724 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4725 : : vlan, "vlan");
4726 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4727 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4728 : : set, "set");
4729 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4730 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4731 : : what, "strip#filter#qinq_strip#extend#stripq");
4732 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4733 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4734 : : on, "on#off");
4735 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4736 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4737 : : port_id, NULL);
4738 : :
4739 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4740 : : .f = cmd_vlan_offload_parsed,
4741 : : .data = NULL,
4742 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4743 : : "<port_id[,queue_id]>: "
4744 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4745 : : .tokens = {
4746 : : (void *)&cmd_vlan_offload_vlan,
4747 : : (void *)&cmd_vlan_offload_set,
4748 : : (void *)&cmd_vlan_offload_what,
4749 : : (void *)&cmd_vlan_offload_on,
4750 : : (void *)&cmd_vlan_offload_portid,
4751 : : NULL,
4752 : : },
4753 : : };
4754 : :
4755 : : /* *** VLAN TPID SET ON A PORT *** */
4756 : : struct cmd_vlan_tpid_result {
4757 : : cmdline_fixed_string_t vlan;
4758 : : cmdline_fixed_string_t set;
4759 : : cmdline_fixed_string_t vlan_type;
4760 : : cmdline_fixed_string_t what;
4761 : : uint16_t tp_id;
4762 : : portid_t port_id;
4763 : : };
4764 : :
4765 : : static void
4766 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4767 : : __rte_unused struct cmdline *cl,
4768 : : __rte_unused void *data)
4769 : : {
4770 : : struct cmd_vlan_tpid_result *res = parsed_result;
4771 : : enum rte_vlan_type vlan_type;
4772 : :
4773 : 0 : if (!strcmp(res->vlan_type, "inner"))
4774 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4775 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4776 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4777 : : else {
4778 : 0 : fprintf(stderr, "Unknown vlan type\n");
4779 : 0 : return;
4780 : : }
4781 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4782 : : }
4783 : :
4784 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4785 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4786 : : vlan, "vlan");
4787 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4788 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4789 : : set, "set");
4790 : : static cmdline_parse_token_string_t cmd_vlan_type =
4791 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4792 : : vlan_type, "inner#outer");
4793 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4794 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4795 : : what, "tpid");
4796 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4797 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4798 : : tp_id, RTE_UINT16);
4799 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4800 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4801 : : port_id, RTE_UINT16);
4802 : :
4803 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4804 : : .f = cmd_vlan_tpid_parsed,
4805 : : .data = NULL,
4806 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4807 : : "Set the VLAN Ether type",
4808 : : .tokens = {
4809 : : (void *)&cmd_vlan_tpid_vlan,
4810 : : (void *)&cmd_vlan_tpid_set,
4811 : : (void *)&cmd_vlan_type,
4812 : : (void *)&cmd_vlan_tpid_what,
4813 : : (void *)&cmd_vlan_tpid_tpid,
4814 : : (void *)&cmd_vlan_tpid_portid,
4815 : : NULL,
4816 : : },
4817 : : };
4818 : :
4819 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4820 : : struct cmd_rx_vlan_filter_result {
4821 : : cmdline_fixed_string_t rx_vlan;
4822 : : cmdline_fixed_string_t what;
4823 : : uint16_t vlan_id;
4824 : : portid_t port_id;
4825 : : };
4826 : :
4827 : : static void
4828 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4829 : : __rte_unused struct cmdline *cl,
4830 : : __rte_unused void *data)
4831 : : {
4832 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4833 : :
4834 : 0 : if (!strcmp(res->what, "add"))
4835 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4836 : : else
4837 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4838 : 0 : }
4839 : :
4840 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4841 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4842 : : rx_vlan, "rx_vlan");
4843 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4844 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4845 : : what, "add#rm");
4846 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4847 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4848 : : vlan_id, RTE_UINT16);
4849 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4850 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4851 : : port_id, RTE_UINT16);
4852 : :
4853 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4854 : : .f = cmd_rx_vlan_filter_parsed,
4855 : : .data = NULL,
4856 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4857 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4858 : : "identifiers filtered by a port",
4859 : : .tokens = {
4860 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4861 : : (void *)&cmd_rx_vlan_filter_what,
4862 : : (void *)&cmd_rx_vlan_filter_vlanid,
4863 : : (void *)&cmd_rx_vlan_filter_portid,
4864 : : NULL,
4865 : : },
4866 : : };
4867 : :
4868 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4869 : : struct cmd_tx_vlan_set_result {
4870 : : cmdline_fixed_string_t tx_vlan;
4871 : : cmdline_fixed_string_t set;
4872 : : portid_t port_id;
4873 : : uint16_t vlan_id;
4874 : : };
4875 : :
4876 : : static void
4877 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4878 : : __rte_unused struct cmdline *cl,
4879 : : __rte_unused void *data)
4880 : : {
4881 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4882 : :
4883 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4884 : : return;
4885 : :
4886 : 0 : if (!port_is_stopped(res->port_id)) {
4887 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4888 : 0 : return;
4889 : : }
4890 : :
4891 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4892 : :
4893 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4894 : : }
4895 : :
4896 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4897 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4898 : : tx_vlan, "tx_vlan");
4899 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4900 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4901 : : set, "set");
4902 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4903 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4904 : : port_id, RTE_UINT16);
4905 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4906 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4907 : : vlan_id, RTE_UINT16);
4908 : :
4909 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4910 : : .f = cmd_tx_vlan_set_parsed,
4911 : : .data = NULL,
4912 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4913 : : "Enable hardware insertion of a single VLAN header "
4914 : : "with a given TAG Identifier in packets sent on a port",
4915 : : .tokens = {
4916 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4917 : : (void *)&cmd_tx_vlan_set_set,
4918 : : (void *)&cmd_tx_vlan_set_portid,
4919 : : (void *)&cmd_tx_vlan_set_vlanid,
4920 : : NULL,
4921 : : },
4922 : : };
4923 : :
4924 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4925 : : struct cmd_tx_vlan_set_qinq_result {
4926 : : cmdline_fixed_string_t tx_vlan;
4927 : : cmdline_fixed_string_t set;
4928 : : portid_t port_id;
4929 : : uint16_t vlan_id;
4930 : : uint16_t vlan_id_outer;
4931 : : };
4932 : :
4933 : : static void
4934 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4935 : : __rte_unused struct cmdline *cl,
4936 : : __rte_unused void *data)
4937 : : {
4938 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4939 : :
4940 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4941 : : return;
4942 : :
4943 : 0 : if (!port_is_stopped(res->port_id)) {
4944 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4945 : 0 : return;
4946 : : }
4947 : :
4948 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4949 : :
4950 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4951 : : }
4952 : :
4953 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4954 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4955 : : tx_vlan, "tx_vlan");
4956 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4957 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4958 : : set, "set");
4959 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4960 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4961 : : port_id, RTE_UINT16);
4962 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4963 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4964 : : vlan_id, RTE_UINT16);
4965 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4966 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4967 : : vlan_id_outer, RTE_UINT16);
4968 : :
4969 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4970 : : .f = cmd_tx_vlan_set_qinq_parsed,
4971 : : .data = NULL,
4972 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4973 : : "Enable hardware insertion of double VLAN header "
4974 : : "with given TAG Identifiers in packets sent on a port",
4975 : : .tokens = {
4976 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4977 : : (void *)&cmd_tx_vlan_set_qinq_set,
4978 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4979 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4980 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4981 : : NULL,
4982 : : },
4983 : : };
4984 : :
4985 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4986 : : struct cmd_tx_vlan_set_pvid_result {
4987 : : cmdline_fixed_string_t tx_vlan;
4988 : : cmdline_fixed_string_t set;
4989 : : cmdline_fixed_string_t pvid;
4990 : : portid_t port_id;
4991 : : uint16_t vlan_id;
4992 : : cmdline_fixed_string_t mode;
4993 : : };
4994 : :
4995 : : static void
4996 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4997 : : __rte_unused struct cmdline *cl,
4998 : : __rte_unused void *data)
4999 : : {
5000 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5001 : :
5002 : 0 : if (strcmp(res->mode, "on") == 0)
5003 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5004 : : else
5005 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5006 : 0 : }
5007 : :
5008 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5009 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5010 : : tx_vlan, "tx_vlan");
5011 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5012 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5013 : : set, "set");
5014 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5015 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5016 : : pvid, "pvid");
5017 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5018 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5019 : : port_id, RTE_UINT16);
5020 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5021 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5022 : : vlan_id, RTE_UINT16);
5023 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5024 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5025 : : mode, "on#off");
5026 : :
5027 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5028 : : .f = cmd_tx_vlan_set_pvid_parsed,
5029 : : .data = NULL,
5030 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5031 : : .tokens = {
5032 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5033 : : (void *)&cmd_tx_vlan_set_pvid_set,
5034 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5035 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5036 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5037 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5038 : : NULL,
5039 : : },
5040 : : };
5041 : :
5042 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5043 : : struct cmd_tx_vlan_reset_result {
5044 : : cmdline_fixed_string_t tx_vlan;
5045 : : cmdline_fixed_string_t reset;
5046 : : portid_t port_id;
5047 : : };
5048 : :
5049 : : static void
5050 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5051 : : __rte_unused struct cmdline *cl,
5052 : : __rte_unused void *data)
5053 : : {
5054 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5055 : :
5056 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5057 : : return;
5058 : :
5059 : 0 : if (!port_is_stopped(res->port_id)) {
5060 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5061 : 0 : return;
5062 : : }
5063 : :
5064 : 0 : tx_vlan_reset(res->port_id);
5065 : :
5066 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5067 : : }
5068 : :
5069 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5070 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5071 : : tx_vlan, "tx_vlan");
5072 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5073 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5074 : : reset, "reset");
5075 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5076 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5077 : : port_id, RTE_UINT16);
5078 : :
5079 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5080 : : .f = cmd_tx_vlan_reset_parsed,
5081 : : .data = NULL,
5082 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5083 : : "VLAN header in packets sent on a port",
5084 : : .tokens = {
5085 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5086 : : (void *)&cmd_tx_vlan_reset_reset,
5087 : : (void *)&cmd_tx_vlan_reset_portid,
5088 : : NULL,
5089 : : },
5090 : : };
5091 : :
5092 : :
5093 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5094 : : struct cmd_csum_result {
5095 : : cmdline_fixed_string_t csum;
5096 : : cmdline_fixed_string_t mode;
5097 : : cmdline_fixed_string_t proto;
5098 : : cmdline_fixed_string_t hwsw;
5099 : : portid_t port_id;
5100 : : };
5101 : :
5102 : : static void
5103 : 0 : csum_show(int port_id)
5104 : : {
5105 : : struct rte_eth_dev_info dev_info;
5106 : : uint64_t tx_offloads;
5107 : : int ret;
5108 : :
5109 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5110 : 0 : printf("Parse tunnel is %s\n",
5111 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5112 : 0 : printf("IP checksum offload is %s\n",
5113 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5114 : 0 : printf("UDP checksum offload is %s\n",
5115 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5116 : 0 : printf("TCP checksum offload is %s\n",
5117 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5118 : 0 : printf("SCTP checksum offload is %s\n",
5119 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5120 : 0 : printf("Outer-Ip checksum offload is %s\n",
5121 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5122 : 0 : printf("Outer-Udp checksum offload is %s\n",
5123 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5124 : :
5125 : : /* display warnings if configuration is not supported by the NIC */
5126 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5127 : 0 : if (ret != 0)
5128 : 0 : return;
5129 : :
5130 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5131 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5132 : 0 : fprintf(stderr,
5133 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5134 : : port_id);
5135 : : }
5136 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5137 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5138 : 0 : fprintf(stderr,
5139 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5140 : : port_id);
5141 : : }
5142 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5143 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5144 : 0 : fprintf(stderr,
5145 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5146 : : port_id);
5147 : : }
5148 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5149 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5150 : 0 : fprintf(stderr,
5151 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5152 : : port_id);
5153 : : }
5154 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5155 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5156 : 0 : fprintf(stderr,
5157 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5158 : : port_id);
5159 : : }
5160 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5161 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5162 : : == 0) {
5163 : 0 : fprintf(stderr,
5164 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5165 : : port_id);
5166 : : }
5167 : : }
5168 : :
5169 : : static void
5170 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5171 : : {
5172 : : int k;
5173 : :
5174 : : /* Apply queue tx offloads configuration */
5175 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5176 : 0 : port->txq[k].conf.offloads =
5177 : 0 : port->dev_conf.txmode.offloads;
5178 : : }
5179 : :
5180 : : static void
5181 : 0 : cmd_csum_parsed(void *parsed_result,
5182 : : __rte_unused struct cmdline *cl,
5183 : : __rte_unused void *data)
5184 : : {
5185 : : struct cmd_csum_result *res = parsed_result;
5186 : : int hw = 0;
5187 : : uint64_t csum_offloads = 0;
5188 : : struct rte_eth_dev_info dev_info;
5189 : : int ret;
5190 : :
5191 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5192 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5193 : 0 : return;
5194 : : }
5195 : 0 : if (!port_is_stopped(res->port_id)) {
5196 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5197 : 0 : return;
5198 : : }
5199 : :
5200 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5201 : 0 : if (ret != 0)
5202 : : return;
5203 : :
5204 : 0 : if (!strcmp(res->mode, "set")) {
5205 : :
5206 : 0 : if (!strcmp(res->hwsw, "hw"))
5207 : : hw = 1;
5208 : :
5209 : 0 : if (!strcmp(res->proto, "ip")) {
5210 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5211 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5212 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5213 : : } else {
5214 : 0 : fprintf(stderr,
5215 : : "IP checksum offload is not supported by port %u\n",
5216 : 0 : res->port_id);
5217 : : }
5218 : 0 : } else if (!strcmp(res->proto, "udp")) {
5219 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5220 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5221 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5222 : : } else {
5223 : 0 : fprintf(stderr,
5224 : : "UDP checksum offload is not supported by port %u\n",
5225 : 0 : res->port_id);
5226 : : }
5227 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5228 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5229 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5230 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5231 : : } else {
5232 : 0 : fprintf(stderr,
5233 : : "TCP checksum offload is not supported by port %u\n",
5234 : 0 : res->port_id);
5235 : : }
5236 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5237 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5238 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5239 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5240 : : } else {
5241 : 0 : fprintf(stderr,
5242 : : "SCTP checksum offload is not supported by port %u\n",
5243 : 0 : res->port_id);
5244 : : }
5245 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5246 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5247 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5248 : : csum_offloads |=
5249 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5250 : : } else {
5251 : 0 : fprintf(stderr,
5252 : : "Outer IP checksum offload is not supported by port %u\n",
5253 : 0 : res->port_id);
5254 : : }
5255 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5256 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5257 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5258 : : csum_offloads |=
5259 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5260 : : } else {
5261 : 0 : fprintf(stderr,
5262 : : "Outer UDP checksum offload is not supported by port %u\n",
5263 : 0 : res->port_id);
5264 : : }
5265 : : }
5266 : :
5267 : 0 : if (hw) {
5268 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5269 : : csum_offloads;
5270 : : } else {
5271 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5272 : 0 : (~csum_offloads);
5273 : : }
5274 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5275 : : }
5276 : 0 : csum_show(res->port_id);
5277 : :
5278 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5279 : : }
5280 : :
5281 : : static cmdline_parse_token_string_t cmd_csum_csum =
5282 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5283 : : csum, "csum");
5284 : : static cmdline_parse_token_string_t cmd_csum_mode =
5285 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5286 : : mode, "set");
5287 : : static cmdline_parse_token_string_t cmd_csum_proto =
5288 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5289 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5290 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5291 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5292 : : hwsw, "hw#sw");
5293 : : static cmdline_parse_token_num_t cmd_csum_portid =
5294 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5295 : : port_id, RTE_UINT16);
5296 : :
5297 : : static cmdline_parse_inst_t cmd_csum_set = {
5298 : : .f = cmd_csum_parsed,
5299 : : .data = NULL,
5300 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5301 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5302 : : "using csum forward engine",
5303 : : .tokens = {
5304 : : (void *)&cmd_csum_csum,
5305 : : (void *)&cmd_csum_mode,
5306 : : (void *)&cmd_csum_proto,
5307 : : (void *)&cmd_csum_hwsw,
5308 : : (void *)&cmd_csum_portid,
5309 : : NULL,
5310 : : },
5311 : : };
5312 : :
5313 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5314 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5315 : : mode, "show");
5316 : :
5317 : : static cmdline_parse_inst_t cmd_csum_show = {
5318 : : .f = cmd_csum_parsed,
5319 : : .data = NULL,
5320 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5321 : : .tokens = {
5322 : : (void *)&cmd_csum_csum,
5323 : : (void *)&cmd_csum_mode_show,
5324 : : (void *)&cmd_csum_portid,
5325 : : NULL,
5326 : : },
5327 : : };
5328 : :
5329 : : /* Enable/disable tunnel parsing */
5330 : : struct cmd_csum_tunnel_result {
5331 : : cmdline_fixed_string_t csum;
5332 : : cmdline_fixed_string_t parse;
5333 : : cmdline_fixed_string_t onoff;
5334 : : portid_t port_id;
5335 : : };
5336 : :
5337 : : static void
5338 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5339 : : __rte_unused struct cmdline *cl,
5340 : : __rte_unused void *data)
5341 : : {
5342 : : struct cmd_csum_tunnel_result *res = parsed_result;
5343 : :
5344 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5345 : : return;
5346 : :
5347 : 0 : if (!strcmp(res->onoff, "on"))
5348 : 0 : ports[res->port_id].parse_tunnel = 1;
5349 : : else
5350 : 0 : ports[res->port_id].parse_tunnel = 0;
5351 : :
5352 : 0 : csum_show(res->port_id);
5353 : : }
5354 : :
5355 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5356 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5357 : : csum, "csum");
5358 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5359 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5360 : : parse, "parse-tunnel");
5361 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5362 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5363 : : onoff, "on#off");
5364 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5365 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5366 : : port_id, RTE_UINT16);
5367 : :
5368 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5369 : : .f = cmd_csum_tunnel_parsed,
5370 : : .data = NULL,
5371 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5372 : : "Enable/Disable parsing of tunnels for csum engine",
5373 : : .tokens = {
5374 : : (void *)&cmd_csum_tunnel_csum,
5375 : : (void *)&cmd_csum_tunnel_parse,
5376 : : (void *)&cmd_csum_tunnel_onoff,
5377 : : (void *)&cmd_csum_tunnel_portid,
5378 : : NULL,
5379 : : },
5380 : : };
5381 : :
5382 : : struct cmd_csum_mac_swap_result {
5383 : : cmdline_fixed_string_t csum;
5384 : : cmdline_fixed_string_t parse;
5385 : : cmdline_fixed_string_t onoff;
5386 : : portid_t port_id;
5387 : : };
5388 : :
5389 : : static void
5390 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5391 : : __rte_unused struct cmdline *cl,
5392 : : __rte_unused void *data)
5393 : : {
5394 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5395 : :
5396 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5397 : : return;
5398 : 0 : if (strcmp(res->onoff, "on") == 0)
5399 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5400 : : else
5401 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5402 : : }
5403 : :
5404 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5405 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5406 : : csum, "csum");
5407 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5408 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5409 : : parse, "mac-swap");
5410 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5411 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5412 : : onoff, "on#off");
5413 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5414 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5415 : : port_id, RTE_UINT16);
5416 : :
5417 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5418 : : .f = cmd_csum_mac_swap_parsed,
5419 : : .data = NULL,
5420 : : .help_str = "csum mac-swap on|off <port_id>: "
5421 : : "Enable/Disable forward mac address swap",
5422 : : .tokens = {
5423 : : (void *)&cmd_csum_mac_swap_csum,
5424 : : (void *)&cmd_csum_mac_swap_parse,
5425 : : (void *)&cmd_csum_mac_swap_onoff,
5426 : : (void *)&cmd_csum_mac_swap_portid,
5427 : : NULL,
5428 : : },
5429 : : };
5430 : :
5431 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5432 : : struct cmd_tso_set_result {
5433 : : cmdline_fixed_string_t tso;
5434 : : cmdline_fixed_string_t mode;
5435 : : uint16_t tso_segsz;
5436 : : portid_t port_id;
5437 : : };
5438 : :
5439 : : static void
5440 : 0 : cmd_tso_set_parsed(void *parsed_result,
5441 : : __rte_unused struct cmdline *cl,
5442 : : __rte_unused void *data)
5443 : : {
5444 : : struct cmd_tso_set_result *res = parsed_result;
5445 : : struct rte_eth_dev_info dev_info;
5446 : : uint64_t offloads;
5447 : : int ret;
5448 : :
5449 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5450 : 0 : return;
5451 : 0 : if (!port_is_stopped(res->port_id)) {
5452 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5453 : 0 : return;
5454 : : }
5455 : :
5456 : 0 : if (!strcmp(res->mode, "set"))
5457 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5458 : :
5459 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5460 : 0 : if (ret != 0)
5461 : : return;
5462 : :
5463 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5464 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5465 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5466 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5467 : : res->port_id);
5468 : 0 : return;
5469 : : }
5470 : : /* display warnings if configuration is not supported by the NIC */
5471 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5472 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5473 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5474 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5475 : : }
5476 : :
5477 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5478 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5479 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5480 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5481 : : } else {
5482 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5483 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5484 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5485 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5486 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5487 : 0 : printf("segment size for non-tunneled packets is %d\n",
5488 : : ports[res->port_id].tso_segsz);
5489 : : }
5490 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5491 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5492 : : }
5493 : :
5494 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5495 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5496 : : tso, "tso");
5497 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5498 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5499 : : mode, "set");
5500 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5501 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5502 : : tso_segsz, RTE_UINT16);
5503 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5504 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5505 : : port_id, RTE_UINT16);
5506 : :
5507 : : static cmdline_parse_inst_t cmd_tso_set = {
5508 : : .f = cmd_tso_set_parsed,
5509 : : .data = NULL,
5510 : : .help_str = "tso set <tso_segsz> <port_id>: "
5511 : : "Set TSO segment size of non-tunneled packets for csum engine "
5512 : : "(0 to disable)",
5513 : : .tokens = {
5514 : : (void *)&cmd_tso_set_tso,
5515 : : (void *)&cmd_tso_set_mode,
5516 : : (void *)&cmd_tso_set_tso_segsz,
5517 : : (void *)&cmd_tso_set_portid,
5518 : : NULL,
5519 : : },
5520 : : };
5521 : :
5522 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5523 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5524 : : mode, "show");
5525 : :
5526 : :
5527 : : static cmdline_parse_inst_t cmd_tso_show = {
5528 : : .f = cmd_tso_set_parsed,
5529 : : .data = NULL,
5530 : : .help_str = "tso show <port_id>: "
5531 : : "Show TSO segment size of non-tunneled packets for csum engine",
5532 : : .tokens = {
5533 : : (void *)&cmd_tso_set_tso,
5534 : : (void *)&cmd_tso_show_mode,
5535 : : (void *)&cmd_tso_set_portid,
5536 : : NULL,
5537 : : },
5538 : : };
5539 : :
5540 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5541 : : struct cmd_tunnel_tso_set_result {
5542 : : cmdline_fixed_string_t tso;
5543 : : cmdline_fixed_string_t mode;
5544 : : uint16_t tso_segsz;
5545 : : portid_t port_id;
5546 : : };
5547 : :
5548 : : static void
5549 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5550 : : {
5551 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5552 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5553 : : port_id);
5554 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5555 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5556 : : port_id);
5557 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5558 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5559 : : port_id);
5560 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5561 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5562 : : port_id);
5563 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5564 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5565 : : port_id);
5566 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5567 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5568 : : port_id);
5569 : 0 : }
5570 : :
5571 : : static void
5572 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5573 : : __rte_unused struct cmdline *cl,
5574 : : __rte_unused void *data)
5575 : : {
5576 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5577 : : struct rte_eth_dev_info dev_info;
5578 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5579 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5580 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5581 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5582 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5583 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5584 : : int ret;
5585 : :
5586 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5587 : 0 : return;
5588 : 0 : if (!port_is_stopped(res->port_id)) {
5589 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5590 : 0 : return;
5591 : : }
5592 : :
5593 : 0 : if (!strcmp(res->mode, "set"))
5594 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5595 : :
5596 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5597 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5598 : : printf("TSO for tunneled packets is disabled\n");
5599 : : } else {
5600 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5601 : 0 : if (ret != 0)
5602 : : return;
5603 : :
5604 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5605 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5606 : 0 : res->port_id);
5607 : 0 : return;
5608 : : }
5609 : :
5610 : : /* Below conditions are needed to make it work:
5611 : : * (1) tunnel TSO is supported by the NIC;
5612 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5613 : : * are recognized;
5614 : : * (3) for tunneled pkts with outer L3 of IPv4,
5615 : : * "csum set outer-ip" must be set to hw, because after tso,
5616 : : * total_len of outer IP header is changed, and the checksum
5617 : : * of outer IP header calculated by sw should be wrong; that
5618 : : * is not necessary for IPv6 tunneled pkts because there's no
5619 : : * checksum in IP header anymore.
5620 : : */
5621 : 0 : if (!ports[res->port_id].parse_tunnel) {
5622 : 0 : fprintf(stderr,
5623 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5624 : 0 : return;
5625 : : }
5626 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5627 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5628 : 0 : fprintf(stderr,
5629 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5630 : 0 : return;
5631 : : }
5632 : :
5633 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5634 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5635 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5636 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5637 : 0 : ports[res->port_id].tunnel_tso_segsz);
5638 : : }
5639 : :
5640 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5641 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5642 : : }
5643 : :
5644 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5645 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5646 : : tso, "tunnel_tso");
5647 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5648 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5649 : : mode, "set");
5650 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5651 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5652 : : tso_segsz, RTE_UINT16);
5653 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5654 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5655 : : port_id, RTE_UINT16);
5656 : :
5657 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5658 : : .f = cmd_tunnel_tso_set_parsed,
5659 : : .data = NULL,
5660 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5661 : : "Set TSO segment size of tunneled packets for csum engine "
5662 : : "(0 to disable)",
5663 : : .tokens = {
5664 : : (void *)&cmd_tunnel_tso_set_tso,
5665 : : (void *)&cmd_tunnel_tso_set_mode,
5666 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5667 : : (void *)&cmd_tunnel_tso_set_portid,
5668 : : NULL,
5669 : : },
5670 : : };
5671 : :
5672 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5673 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5674 : : mode, "show");
5675 : :
5676 : :
5677 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5678 : : .f = cmd_tunnel_tso_set_parsed,
5679 : : .data = NULL,
5680 : : .help_str = "tunnel_tso show <port_id> "
5681 : : "Show TSO segment size of tunneled packets for csum engine",
5682 : : .tokens = {
5683 : : (void *)&cmd_tunnel_tso_set_tso,
5684 : : (void *)&cmd_tunnel_tso_show_mode,
5685 : : (void *)&cmd_tunnel_tso_set_portid,
5686 : : NULL,
5687 : : },
5688 : : };
5689 : :
5690 : : #ifdef RTE_LIB_GRO
5691 : : /* *** SET GRO FOR A PORT *** */
5692 : : struct cmd_gro_enable_result {
5693 : : cmdline_fixed_string_t cmd_set;
5694 : : cmdline_fixed_string_t cmd_port;
5695 : : cmdline_fixed_string_t cmd_keyword;
5696 : : cmdline_fixed_string_t cmd_onoff;
5697 : : portid_t cmd_pid;
5698 : : };
5699 : :
5700 : : static void
5701 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5702 : : __rte_unused struct cmdline *cl,
5703 : : __rte_unused void *data)
5704 : : {
5705 : : struct cmd_gro_enable_result *res;
5706 : :
5707 : : res = parsed_result;
5708 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5709 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5710 : 0 : }
5711 : :
5712 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5713 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5714 : : cmd_set, "set");
5715 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5716 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5717 : : cmd_keyword, "port");
5718 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5719 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5720 : : cmd_pid, RTE_UINT16);
5721 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5722 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5723 : : cmd_keyword, "gro");
5724 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5725 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5726 : : cmd_onoff, "on#off");
5727 : :
5728 : : static cmdline_parse_inst_t cmd_gro_enable = {
5729 : : .f = cmd_gro_enable_parsed,
5730 : : .data = NULL,
5731 : : .help_str = "set port <port_id> gro on|off",
5732 : : .tokens = {
5733 : : (void *)&cmd_gro_enable_set,
5734 : : (void *)&cmd_gro_enable_port,
5735 : : (void *)&cmd_gro_enable_pid,
5736 : : (void *)&cmd_gro_enable_keyword,
5737 : : (void *)&cmd_gro_enable_onoff,
5738 : : NULL,
5739 : : },
5740 : : };
5741 : :
5742 : : /* *** DISPLAY GRO CONFIGURATION *** */
5743 : : struct cmd_gro_show_result {
5744 : : cmdline_fixed_string_t cmd_show;
5745 : : cmdline_fixed_string_t cmd_port;
5746 : : cmdline_fixed_string_t cmd_keyword;
5747 : : portid_t cmd_pid;
5748 : : };
5749 : :
5750 : : static void
5751 : 0 : cmd_gro_show_parsed(void *parsed_result,
5752 : : __rte_unused struct cmdline *cl,
5753 : : __rte_unused void *data)
5754 : : {
5755 : : struct cmd_gro_show_result *res;
5756 : :
5757 : : res = parsed_result;
5758 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5759 : 0 : show_gro(res->cmd_pid);
5760 : 0 : }
5761 : :
5762 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5763 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5764 : : cmd_show, "show");
5765 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5766 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5767 : : cmd_port, "port");
5768 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5769 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5770 : : cmd_pid, RTE_UINT16);
5771 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5772 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5773 : : cmd_keyword, "gro");
5774 : :
5775 : : static cmdline_parse_inst_t cmd_gro_show = {
5776 : : .f = cmd_gro_show_parsed,
5777 : : .data = NULL,
5778 : : .help_str = "show port <port_id> gro",
5779 : : .tokens = {
5780 : : (void *)&cmd_gro_show_show,
5781 : : (void *)&cmd_gro_show_port,
5782 : : (void *)&cmd_gro_show_pid,
5783 : : (void *)&cmd_gro_show_keyword,
5784 : : NULL,
5785 : : },
5786 : : };
5787 : :
5788 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5789 : : struct cmd_gro_flush_result {
5790 : : cmdline_fixed_string_t cmd_set;
5791 : : cmdline_fixed_string_t cmd_keyword;
5792 : : cmdline_fixed_string_t cmd_flush;
5793 : : uint8_t cmd_cycles;
5794 : : };
5795 : :
5796 : : static void
5797 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5798 : : __rte_unused struct cmdline *cl,
5799 : : __rte_unused void *data)
5800 : : {
5801 : : struct cmd_gro_flush_result *res;
5802 : :
5803 : : res = parsed_result;
5804 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5805 : 0 : (!strcmp(res->cmd_flush, "flush")))
5806 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5807 : 0 : }
5808 : :
5809 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5810 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5811 : : cmd_set, "set");
5812 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5813 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5814 : : cmd_keyword, "gro");
5815 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5816 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5817 : : cmd_flush, "flush");
5818 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5819 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5820 : : cmd_cycles, RTE_UINT8);
5821 : :
5822 : : static cmdline_parse_inst_t cmd_gro_flush = {
5823 : : .f = cmd_gro_flush_parsed,
5824 : : .data = NULL,
5825 : : .help_str = "set gro flush <cycles>",
5826 : : .tokens = {
5827 : : (void *)&cmd_gro_flush_set,
5828 : : (void *)&cmd_gro_flush_keyword,
5829 : : (void *)&cmd_gro_flush_flush,
5830 : : (void *)&cmd_gro_flush_cycles,
5831 : : NULL,
5832 : : },
5833 : : };
5834 : : #endif /* RTE_LIB_GRO */
5835 : :
5836 : : #ifdef RTE_LIB_GSO
5837 : : /* *** ENABLE/DISABLE GSO *** */
5838 : : struct cmd_gso_enable_result {
5839 : : cmdline_fixed_string_t cmd_set;
5840 : : cmdline_fixed_string_t cmd_port;
5841 : : cmdline_fixed_string_t cmd_keyword;
5842 : : cmdline_fixed_string_t cmd_mode;
5843 : : portid_t cmd_pid;
5844 : : };
5845 : :
5846 : : static void
5847 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5848 : : __rte_unused struct cmdline *cl,
5849 : : __rte_unused void *data)
5850 : : {
5851 : : struct cmd_gso_enable_result *res;
5852 : :
5853 : : res = parsed_result;
5854 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5855 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5856 : 0 : }
5857 : :
5858 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5859 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5860 : : cmd_set, "set");
5861 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5862 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5863 : : cmd_port, "port");
5864 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5865 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5866 : : cmd_keyword, "gso");
5867 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5868 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5869 : : cmd_mode, "on#off");
5870 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5871 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5872 : : cmd_pid, RTE_UINT16);
5873 : :
5874 : : static cmdline_parse_inst_t cmd_gso_enable = {
5875 : : .f = cmd_gso_enable_parsed,
5876 : : .data = NULL,
5877 : : .help_str = "set port <port_id> gso on|off",
5878 : : .tokens = {
5879 : : (void *)&cmd_gso_enable_set,
5880 : : (void *)&cmd_gso_enable_port,
5881 : : (void *)&cmd_gso_enable_pid,
5882 : : (void *)&cmd_gso_enable_keyword,
5883 : : (void *)&cmd_gso_enable_mode,
5884 : : NULL,
5885 : : },
5886 : : };
5887 : :
5888 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5889 : : struct cmd_gso_size_result {
5890 : : cmdline_fixed_string_t cmd_set;
5891 : : cmdline_fixed_string_t cmd_keyword;
5892 : : cmdline_fixed_string_t cmd_segsz;
5893 : : uint16_t cmd_size;
5894 : : };
5895 : :
5896 : : static void
5897 : 0 : cmd_gso_size_parsed(void *parsed_result,
5898 : : __rte_unused struct cmdline *cl,
5899 : : __rte_unused void *data)
5900 : : {
5901 : : struct cmd_gso_size_result *res = parsed_result;
5902 : :
5903 : 0 : if (test_done == 0) {
5904 : 0 : fprintf(stderr,
5905 : : "Before setting GSO segsz, please first stop forwarding\n");
5906 : 0 : return;
5907 : : }
5908 : :
5909 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5910 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5911 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5912 : 0 : fprintf(stderr,
5913 : : "gso_size should be larger than %zu. Please input a legal value\n",
5914 : : RTE_GSO_SEG_SIZE_MIN);
5915 : : else
5916 : 0 : gso_max_segment_size = res->cmd_size;
5917 : : }
5918 : : }
5919 : :
5920 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5921 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5922 : : cmd_set, "set");
5923 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5924 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5925 : : cmd_keyword, "gso");
5926 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5927 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5928 : : cmd_segsz, "segsz");
5929 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5930 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5931 : : cmd_size, RTE_UINT16);
5932 : :
5933 : : static cmdline_parse_inst_t cmd_gso_size = {
5934 : : .f = cmd_gso_size_parsed,
5935 : : .data = NULL,
5936 : : .help_str = "set gso segsz <length>",
5937 : : .tokens = {
5938 : : (void *)&cmd_gso_size_set,
5939 : : (void *)&cmd_gso_size_keyword,
5940 : : (void *)&cmd_gso_size_segsz,
5941 : : (void *)&cmd_gso_size_size,
5942 : : NULL,
5943 : : },
5944 : : };
5945 : :
5946 : : /* *** SHOW GSO CONFIGURATION *** */
5947 : : struct cmd_gso_show_result {
5948 : : cmdline_fixed_string_t cmd_show;
5949 : : cmdline_fixed_string_t cmd_port;
5950 : : cmdline_fixed_string_t cmd_keyword;
5951 : : portid_t cmd_pid;
5952 : : };
5953 : :
5954 : : static void
5955 : 0 : cmd_gso_show_parsed(void *parsed_result,
5956 : : __rte_unused struct cmdline *cl,
5957 : : __rte_unused void *data)
5958 : : {
5959 : : struct cmd_gso_show_result *res = parsed_result;
5960 : :
5961 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5962 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5963 : 0 : return;
5964 : : }
5965 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5966 : 0 : if (gso_ports[res->cmd_pid].enable) {
5967 : 0 : printf("Max GSO'd packet size: %uB\n"
5968 : : "Supported GSO types: TCP/IPv4, "
5969 : : "UDP/IPv4, VxLAN with inner "
5970 : : "TCP/IPv4 packet, GRE with inner "
5971 : : "TCP/IPv4 packet\n",
5972 : : gso_max_segment_size);
5973 : : } else
5974 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5975 : : }
5976 : : }
5977 : :
5978 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5979 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5980 : : cmd_show, "show");
5981 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5982 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5983 : : cmd_port, "port");
5984 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5985 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5986 : : cmd_keyword, "gso");
5987 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5988 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5989 : : cmd_pid, RTE_UINT16);
5990 : :
5991 : : static cmdline_parse_inst_t cmd_gso_show = {
5992 : : .f = cmd_gso_show_parsed,
5993 : : .data = NULL,
5994 : : .help_str = "show port <port_id> gso",
5995 : : .tokens = {
5996 : : (void *)&cmd_gso_show_show,
5997 : : (void *)&cmd_gso_show_port,
5998 : : (void *)&cmd_gso_show_pid,
5999 : : (void *)&cmd_gso_show_keyword,
6000 : : NULL,
6001 : : },
6002 : : };
6003 : : #endif /* RTE_LIB_GSO */
6004 : :
6005 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6006 : : struct cmd_set_flush_rx {
6007 : : cmdline_fixed_string_t set;
6008 : : cmdline_fixed_string_t flush_rx;
6009 : : cmdline_fixed_string_t mode;
6010 : : };
6011 : :
6012 : : static void
6013 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6014 : : __rte_unused struct cmdline *cl,
6015 : : __rte_unused void *data)
6016 : : {
6017 : : struct cmd_set_flush_rx *res = parsed_result;
6018 : :
6019 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6020 : : printf("multi-process doesn't support to flush Rx queues.\n");
6021 : 0 : return;
6022 : : }
6023 : :
6024 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6025 : : }
6026 : :
6027 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6028 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6029 : : set, "set");
6030 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6031 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6032 : : flush_rx, "flush_rx");
6033 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6034 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6035 : : mode, "on#off");
6036 : :
6037 : :
6038 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6039 : : .f = cmd_set_flush_rx_parsed,
6040 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6041 : : .data = NULL,
6042 : : .tokens = {
6043 : : (void *)&cmd_setflushrx_set,
6044 : : (void *)&cmd_setflushrx_flush_rx,
6045 : : (void *)&cmd_setflushrx_mode,
6046 : : NULL,
6047 : : },
6048 : : };
6049 : :
6050 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6051 : : struct cmd_set_link_check {
6052 : : cmdline_fixed_string_t set;
6053 : : cmdline_fixed_string_t link_check;
6054 : : cmdline_fixed_string_t mode;
6055 : : };
6056 : :
6057 : : static void
6058 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6059 : : __rte_unused struct cmdline *cl,
6060 : : __rte_unused void *data)
6061 : : {
6062 : : struct cmd_set_link_check *res = parsed_result;
6063 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6064 : 0 : }
6065 : :
6066 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6067 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6068 : : set, "set");
6069 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6070 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6071 : : link_check, "link_check");
6072 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6073 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6074 : : mode, "on#off");
6075 : :
6076 : :
6077 : : static cmdline_parse_inst_t cmd_set_link_check = {
6078 : : .f = cmd_set_link_check_parsed,
6079 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6080 : : "when starting/stopping a port",
6081 : : .data = NULL,
6082 : : .tokens = {
6083 : : (void *)&cmd_setlinkcheck_set,
6084 : : (void *)&cmd_setlinkcheck_link_check,
6085 : : (void *)&cmd_setlinkcheck_mode,
6086 : : NULL,
6087 : : },
6088 : : };
6089 : :
6090 : : /* *** SET FORWARDING MODE *** */
6091 : : struct cmd_set_fwd_mode_result {
6092 : : cmdline_fixed_string_t set;
6093 : : cmdline_fixed_string_t fwd;
6094 : : cmdline_fixed_string_t mode;
6095 : : };
6096 : :
6097 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6098 : : __rte_unused struct cmdline *cl,
6099 : : __rte_unused void *data)
6100 : : {
6101 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6102 : :
6103 : 0 : retry_enabled = 0;
6104 : 0 : set_pkt_forwarding_mode(res->mode);
6105 : 0 : }
6106 : :
6107 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6108 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6109 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6110 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6111 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6112 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6113 : : "" /* defined at init */);
6114 : :
6115 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6116 : : .f = cmd_set_fwd_mode_parsed,
6117 : : .data = NULL,
6118 : : .help_str = NULL, /* defined at init */
6119 : : .tokens = {
6120 : : (void *)&cmd_setfwd_set,
6121 : : (void *)&cmd_setfwd_fwd,
6122 : : (void *)&cmd_setfwd_mode,
6123 : : NULL,
6124 : : },
6125 : : };
6126 : :
6127 : 0 : static void cmd_set_fwd_mode_init(void)
6128 : : {
6129 : : char *modes, *c;
6130 : : static char token[128];
6131 : : static char help[256];
6132 : : cmdline_parse_token_string_t *token_struct;
6133 : :
6134 : 0 : modes = list_pkt_forwarding_modes();
6135 : : snprintf(help, sizeof(help), "set fwd %s: "
6136 : : "Set packet forwarding mode", modes);
6137 : 0 : cmd_set_fwd_mode.help_str = help;
6138 : :
6139 : : /* string token separator is # */
6140 : 0 : for (c = token; *modes != '\0'; modes++)
6141 : 0 : if (*modes == '|')
6142 : 0 : *c++ = '#';
6143 : : else
6144 : 0 : *c++ = *modes;
6145 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6146 : 0 : token_struct->string_data.str = token;
6147 : 0 : }
6148 : :
6149 : : /* *** SET RETRY FORWARDING MODE *** */
6150 : : struct cmd_set_fwd_retry_mode_result {
6151 : : cmdline_fixed_string_t set;
6152 : : cmdline_fixed_string_t fwd;
6153 : : cmdline_fixed_string_t mode;
6154 : : cmdline_fixed_string_t retry;
6155 : : };
6156 : :
6157 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6158 : : __rte_unused struct cmdline *cl,
6159 : : __rte_unused void *data)
6160 : : {
6161 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6162 : :
6163 : 0 : retry_enabled = 1;
6164 : 0 : set_pkt_forwarding_mode(res->mode);
6165 : 0 : }
6166 : :
6167 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6168 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6169 : : set, "set");
6170 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6172 : : fwd, "fwd");
6173 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6174 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6175 : : mode,
6176 : : "" /* defined at init */);
6177 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6178 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6179 : : retry, "retry");
6180 : :
6181 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6182 : : .f = cmd_set_fwd_retry_mode_parsed,
6183 : : .data = NULL,
6184 : : .help_str = NULL, /* defined at init */
6185 : : .tokens = {
6186 : : (void *)&cmd_setfwd_retry_set,
6187 : : (void *)&cmd_setfwd_retry_fwd,
6188 : : (void *)&cmd_setfwd_retry_mode,
6189 : : (void *)&cmd_setfwd_retry_retry,
6190 : : NULL,
6191 : : },
6192 : : };
6193 : :
6194 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6195 : : {
6196 : : char *modes, *c;
6197 : : static char token[128];
6198 : : static char help[256];
6199 : : cmdline_parse_token_string_t *token_struct;
6200 : :
6201 : 0 : modes = list_pkt_forwarding_retry_modes();
6202 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6203 : : "Set packet forwarding mode with retry", modes);
6204 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6205 : :
6206 : : /* string token separator is # */
6207 : 0 : for (c = token; *modes != '\0'; modes++)
6208 : 0 : if (*modes == '|')
6209 : 0 : *c++ = '#';
6210 : : else
6211 : 0 : *c++ = *modes;
6212 : 0 : token_struct = (cmdline_parse_token_string_t *)
6213 : : cmd_set_fwd_retry_mode.tokens[2];
6214 : 0 : token_struct->string_data.str = token;
6215 : 0 : }
6216 : :
6217 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6218 : : struct cmd_set_burst_tx_retry_result {
6219 : : cmdline_fixed_string_t set;
6220 : : cmdline_fixed_string_t burst;
6221 : : cmdline_fixed_string_t tx;
6222 : : cmdline_fixed_string_t delay;
6223 : : uint32_t time;
6224 : : cmdline_fixed_string_t retry;
6225 : : uint32_t retry_num;
6226 : : };
6227 : :
6228 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6229 : : __rte_unused struct cmdline *cl,
6230 : : __rte_unused void *data)
6231 : : {
6232 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6233 : :
6234 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6235 : 0 : && !strcmp(res->tx, "tx")) {
6236 : 0 : if (!strcmp(res->delay, "delay"))
6237 : 0 : burst_tx_delay_time = res->time;
6238 : 0 : if (!strcmp(res->retry, "retry"))
6239 : 0 : burst_tx_retry_num = res->retry_num;
6240 : : }
6241 : :
6242 : 0 : }
6243 : :
6244 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6246 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6247 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6248 : : "burst");
6249 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6250 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6251 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6252 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6253 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6254 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6255 : : RTE_UINT32);
6256 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6257 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6258 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6259 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6260 : : RTE_UINT32);
6261 : :
6262 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6263 : : .f = cmd_set_burst_tx_retry_parsed,
6264 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6265 : : .tokens = {
6266 : : (void *)&cmd_set_burst_tx_retry_set,
6267 : : (void *)&cmd_set_burst_tx_retry_burst,
6268 : : (void *)&cmd_set_burst_tx_retry_tx,
6269 : : (void *)&cmd_set_burst_tx_retry_delay,
6270 : : (void *)&cmd_set_burst_tx_retry_time,
6271 : : (void *)&cmd_set_burst_tx_retry_retry,
6272 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6273 : : NULL,
6274 : : },
6275 : : };
6276 : :
6277 : : /* *** SET PROMISC MODE *** */
6278 : : struct cmd_set_promisc_mode_result {
6279 : : cmdline_fixed_string_t set;
6280 : : cmdline_fixed_string_t promisc;
6281 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6282 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6283 : : cmdline_fixed_string_t mode;
6284 : : };
6285 : :
6286 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6287 : : __rte_unused struct cmdline *cl,
6288 : : void *allports)
6289 : : {
6290 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6291 : : int enable;
6292 : : portid_t i;
6293 : :
6294 : 0 : if (!strcmp(res->mode, "on"))
6295 : : enable = 1;
6296 : : else
6297 : : enable = 0;
6298 : :
6299 : : /* all ports */
6300 : 0 : if (allports) {
6301 : 0 : RTE_ETH_FOREACH_DEV(i)
6302 : 0 : eth_set_promisc_mode(i, enable);
6303 : : } else {
6304 : 0 : eth_set_promisc_mode(res->port_num, enable);
6305 : : }
6306 : 0 : }
6307 : :
6308 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6309 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6310 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6311 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6312 : : "promisc");
6313 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6314 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6315 : : "all");
6316 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6317 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6318 : : RTE_UINT16);
6319 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6320 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6321 : : "on#off");
6322 : :
6323 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6324 : : .f = cmd_set_promisc_mode_parsed,
6325 : : .data = (void *)1,
6326 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6327 : : .tokens = {
6328 : : (void *)&cmd_setpromisc_set,
6329 : : (void *)&cmd_setpromisc_promisc,
6330 : : (void *)&cmd_setpromisc_portall,
6331 : : (void *)&cmd_setpromisc_mode,
6332 : : NULL,
6333 : : },
6334 : : };
6335 : :
6336 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6337 : : .f = cmd_set_promisc_mode_parsed,
6338 : : .data = (void *)0,
6339 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6340 : : .tokens = {
6341 : : (void *)&cmd_setpromisc_set,
6342 : : (void *)&cmd_setpromisc_promisc,
6343 : : (void *)&cmd_setpromisc_portnum,
6344 : : (void *)&cmd_setpromisc_mode,
6345 : : NULL,
6346 : : },
6347 : : };
6348 : :
6349 : : /* *** SET ALLMULTI MODE *** */
6350 : : struct cmd_set_allmulti_mode_result {
6351 : : cmdline_fixed_string_t set;
6352 : : cmdline_fixed_string_t allmulti;
6353 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6354 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6355 : : cmdline_fixed_string_t mode;
6356 : : };
6357 : :
6358 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6359 : : __rte_unused struct cmdline *cl,
6360 : : void *allports)
6361 : : {
6362 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6363 : : int enable;
6364 : : portid_t i;
6365 : :
6366 : 0 : if (!strcmp(res->mode, "on"))
6367 : : enable = 1;
6368 : : else
6369 : : enable = 0;
6370 : :
6371 : : /* all ports */
6372 : 0 : if (allports) {
6373 : 0 : RTE_ETH_FOREACH_DEV(i) {
6374 : 0 : eth_set_allmulticast_mode(i, enable);
6375 : : }
6376 : : }
6377 : : else {
6378 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6379 : : }
6380 : 0 : }
6381 : :
6382 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6383 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6384 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6385 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6386 : : "allmulti");
6387 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6388 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6389 : : "all");
6390 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6391 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6392 : : RTE_UINT16);
6393 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6394 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6395 : : "on#off");
6396 : :
6397 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6398 : : .f = cmd_set_allmulti_mode_parsed,
6399 : : .data = (void *)1,
6400 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6401 : : .tokens = {
6402 : : (void *)&cmd_setallmulti_set,
6403 : : (void *)&cmd_setallmulti_allmulti,
6404 : : (void *)&cmd_setallmulti_portall,
6405 : : (void *)&cmd_setallmulti_mode,
6406 : : NULL,
6407 : : },
6408 : : };
6409 : :
6410 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6411 : : .f = cmd_set_allmulti_mode_parsed,
6412 : : .data = (void *)0,
6413 : : .help_str = "set allmulti <port_id> on|off: "
6414 : : "Set allmulti mode on port_id",
6415 : : .tokens = {
6416 : : (void *)&cmd_setallmulti_set,
6417 : : (void *)&cmd_setallmulti_allmulti,
6418 : : (void *)&cmd_setallmulti_portnum,
6419 : : (void *)&cmd_setallmulti_mode,
6420 : : NULL,
6421 : : },
6422 : : };
6423 : :
6424 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6425 : : struct cmd_link_flow_ctrl_show {
6426 : : cmdline_fixed_string_t show;
6427 : : cmdline_fixed_string_t port;
6428 : : portid_t port_id;
6429 : : cmdline_fixed_string_t flow_ctrl;
6430 : : };
6431 : :
6432 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6433 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6434 : : show, "show");
6435 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6436 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6437 : : port, "port");
6438 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6439 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6440 : : port_id, RTE_UINT16);
6441 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6442 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6443 : : flow_ctrl, "flow_ctrl");
6444 : :
6445 : : static void
6446 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6447 : : __rte_unused struct cmdline *cl,
6448 : : __rte_unused void *data)
6449 : : {
6450 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6451 : : static const char *info_border = "*********************";
6452 : : struct rte_eth_fc_conf fc_conf;
6453 : : bool rx_fc_en = false;
6454 : : bool tx_fc_en = false;
6455 : : int ret;
6456 : :
6457 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6458 : 0 : if (ret != 0) {
6459 : 0 : fprintf(stderr,
6460 : : "Failed to get current flow ctrl information: err = %d\n",
6461 : : ret);
6462 : 0 : return;
6463 : : }
6464 : :
6465 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6466 : : rx_fc_en = true;
6467 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6468 : : tx_fc_en = true;
6469 : :
6470 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6471 : 0 : info_border, res->port_id, info_border);
6472 : : printf("FC mode:\n");
6473 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6474 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6475 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6476 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6477 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6478 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6479 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6480 : 0 : printf("Forward MAC control frames: %s\n",
6481 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6482 : 0 : printf("\n%s************** End ***********%s\n",
6483 : : info_border, info_border);
6484 : : }
6485 : :
6486 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6487 : : .f = cmd_link_flow_ctrl_show_parsed,
6488 : : .data = NULL,
6489 : : .help_str = "show port <port_id> flow_ctrl",
6490 : : .tokens = {
6491 : : (void *)&cmd_lfc_show_show,
6492 : : (void *)&cmd_lfc_show_port,
6493 : : (void *)&cmd_lfc_show_portid,
6494 : : (void *)&cmd_lfc_show_flow_ctrl,
6495 : : NULL,
6496 : : },
6497 : : };
6498 : :
6499 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6500 : : struct cmd_link_flow_ctrl_set_result {
6501 : : cmdline_fixed_string_t set;
6502 : : cmdline_fixed_string_t flow_ctrl;
6503 : : cmdline_fixed_string_t rx;
6504 : : cmdline_fixed_string_t rx_lfc_mode;
6505 : : cmdline_fixed_string_t tx;
6506 : : cmdline_fixed_string_t tx_lfc_mode;
6507 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6508 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6509 : : cmdline_fixed_string_t autoneg_str;
6510 : : cmdline_fixed_string_t autoneg;
6511 : : cmdline_fixed_string_t hw_str;
6512 : : uint32_t high_water;
6513 : : cmdline_fixed_string_t lw_str;
6514 : : uint32_t low_water;
6515 : : cmdline_fixed_string_t pt_str;
6516 : : uint16_t pause_time;
6517 : : cmdline_fixed_string_t xon_str;
6518 : : uint16_t send_xon;
6519 : : portid_t port_id;
6520 : : };
6521 : :
6522 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6523 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6524 : : set, "set");
6525 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6526 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6527 : : flow_ctrl, "flow_ctrl");
6528 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6529 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6530 : : rx, "rx");
6531 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6532 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6533 : : rx_lfc_mode, "on#off");
6534 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6535 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6536 : : tx, "tx");
6537 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6538 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6539 : : tx_lfc_mode, "on#off");
6540 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6541 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6542 : : hw_str, "high_water");
6543 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6544 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6545 : : high_water, RTE_UINT32);
6546 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6547 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6548 : : lw_str, "low_water");
6549 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6550 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6551 : : low_water, RTE_UINT32);
6552 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6553 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6554 : : pt_str, "pause_time");
6555 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6556 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6557 : : pause_time, RTE_UINT16);
6558 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6559 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6560 : : xon_str, "send_xon");
6561 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6562 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6563 : : send_xon, RTE_UINT16);
6564 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6565 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6566 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6567 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6568 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6569 : : mac_ctrl_frame_fwd_mode, "on#off");
6570 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6571 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6572 : : autoneg_str, "autoneg");
6573 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6574 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6575 : : autoneg, "on#off");
6576 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6577 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6578 : : port_id, RTE_UINT16);
6579 : :
6580 : : /* forward declaration */
6581 : : static void
6582 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6583 : : void *data);
6584 : :
6585 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6586 : : .f = cmd_link_flow_ctrl_set_parsed,
6587 : : .data = NULL,
6588 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6589 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6590 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6591 : : .tokens = {
6592 : : (void *)&cmd_lfc_set_set,
6593 : : (void *)&cmd_lfc_set_flow_ctrl,
6594 : : (void *)&cmd_lfc_set_rx,
6595 : : (void *)&cmd_lfc_set_rx_mode,
6596 : : (void *)&cmd_lfc_set_tx,
6597 : : (void *)&cmd_lfc_set_tx_mode,
6598 : : (void *)&cmd_lfc_set_high_water,
6599 : : (void *)&cmd_lfc_set_low_water,
6600 : : (void *)&cmd_lfc_set_pause_time,
6601 : : (void *)&cmd_lfc_set_send_xon,
6602 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6603 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6604 : : (void *)&cmd_lfc_set_autoneg_str,
6605 : : (void *)&cmd_lfc_set_autoneg,
6606 : : (void *)&cmd_lfc_set_portid,
6607 : : NULL,
6608 : : },
6609 : : };
6610 : :
6611 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6612 : : .f = cmd_link_flow_ctrl_set_parsed,
6613 : : .data = (void *)&cmd_link_flow_control_set_rx,
6614 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6615 : : "Change rx flow control parameter",
6616 : : .tokens = {
6617 : : (void *)&cmd_lfc_set_set,
6618 : : (void *)&cmd_lfc_set_flow_ctrl,
6619 : : (void *)&cmd_lfc_set_rx,
6620 : : (void *)&cmd_lfc_set_rx_mode,
6621 : : (void *)&cmd_lfc_set_portid,
6622 : : NULL,
6623 : : },
6624 : : };
6625 : :
6626 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6627 : : .f = cmd_link_flow_ctrl_set_parsed,
6628 : : .data = (void *)&cmd_link_flow_control_set_tx,
6629 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6630 : : "Change tx flow control parameter",
6631 : : .tokens = {
6632 : : (void *)&cmd_lfc_set_set,
6633 : : (void *)&cmd_lfc_set_flow_ctrl,
6634 : : (void *)&cmd_lfc_set_tx,
6635 : : (void *)&cmd_lfc_set_tx_mode,
6636 : : (void *)&cmd_lfc_set_portid,
6637 : : NULL,
6638 : : },
6639 : : };
6640 : :
6641 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6642 : : .f = cmd_link_flow_ctrl_set_parsed,
6643 : : .data = (void *)&cmd_link_flow_control_set_hw,
6644 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6645 : : "Change high water flow control parameter",
6646 : : .tokens = {
6647 : : (void *)&cmd_lfc_set_set,
6648 : : (void *)&cmd_lfc_set_flow_ctrl,
6649 : : (void *)&cmd_lfc_set_high_water_str,
6650 : : (void *)&cmd_lfc_set_high_water,
6651 : : (void *)&cmd_lfc_set_portid,
6652 : : NULL,
6653 : : },
6654 : : };
6655 : :
6656 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6657 : : .f = cmd_link_flow_ctrl_set_parsed,
6658 : : .data = (void *)&cmd_link_flow_control_set_lw,
6659 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6660 : : "Change low water flow control parameter",
6661 : : .tokens = {
6662 : : (void *)&cmd_lfc_set_set,
6663 : : (void *)&cmd_lfc_set_flow_ctrl,
6664 : : (void *)&cmd_lfc_set_low_water_str,
6665 : : (void *)&cmd_lfc_set_low_water,
6666 : : (void *)&cmd_lfc_set_portid,
6667 : : NULL,
6668 : : },
6669 : : };
6670 : :
6671 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6672 : : .f = cmd_link_flow_ctrl_set_parsed,
6673 : : .data = (void *)&cmd_link_flow_control_set_pt,
6674 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6675 : : "Change pause time flow control parameter",
6676 : : .tokens = {
6677 : : (void *)&cmd_lfc_set_set,
6678 : : (void *)&cmd_lfc_set_flow_ctrl,
6679 : : (void *)&cmd_lfc_set_pause_time_str,
6680 : : (void *)&cmd_lfc_set_pause_time,
6681 : : (void *)&cmd_lfc_set_portid,
6682 : : NULL,
6683 : : },
6684 : : };
6685 : :
6686 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6687 : : .f = cmd_link_flow_ctrl_set_parsed,
6688 : : .data = (void *)&cmd_link_flow_control_set_xon,
6689 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6690 : : "Change send_xon flow control parameter",
6691 : : .tokens = {
6692 : : (void *)&cmd_lfc_set_set,
6693 : : (void *)&cmd_lfc_set_flow_ctrl,
6694 : : (void *)&cmd_lfc_set_send_xon_str,
6695 : : (void *)&cmd_lfc_set_send_xon,
6696 : : (void *)&cmd_lfc_set_portid,
6697 : : NULL,
6698 : : },
6699 : : };
6700 : :
6701 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6702 : : .f = cmd_link_flow_ctrl_set_parsed,
6703 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6704 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6705 : : "Change mac ctrl fwd flow control parameter",
6706 : : .tokens = {
6707 : : (void *)&cmd_lfc_set_set,
6708 : : (void *)&cmd_lfc_set_flow_ctrl,
6709 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6710 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6711 : : (void *)&cmd_lfc_set_portid,
6712 : : NULL,
6713 : : },
6714 : : };
6715 : :
6716 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6717 : : .f = cmd_link_flow_ctrl_set_parsed,
6718 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6719 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6720 : : "Change autoneg flow control parameter",
6721 : : .tokens = {
6722 : : (void *)&cmd_lfc_set_set,
6723 : : (void *)&cmd_lfc_set_flow_ctrl,
6724 : : (void *)&cmd_lfc_set_autoneg_str,
6725 : : (void *)&cmd_lfc_set_autoneg,
6726 : : (void *)&cmd_lfc_set_portid,
6727 : : NULL,
6728 : : },
6729 : : };
6730 : :
6731 : : static void
6732 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6733 : : __rte_unused struct cmdline *cl,
6734 : : void *data)
6735 : : {
6736 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6737 : : cmdline_parse_inst_t *cmd = data;
6738 : : struct rte_eth_fc_conf fc_conf;
6739 : : int rx_fc_en = 0;
6740 : : int tx_fc_en = 0;
6741 : : int ret;
6742 : :
6743 : : /*
6744 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6745 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6746 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6747 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6748 : : */
6749 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6750 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6751 : : };
6752 : :
6753 : : /* Partial command line, retrieve current configuration */
6754 : 0 : if (cmd) {
6755 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6756 : 0 : if (ret != 0) {
6757 : 0 : fprintf(stderr,
6758 : : "cannot get current flow ctrl parameters, return code = %d\n",
6759 : : ret);
6760 : 0 : return;
6761 : : }
6762 : :
6763 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6764 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6765 : : rx_fc_en = 1;
6766 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6767 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6768 : : tx_fc_en = 1;
6769 : : }
6770 : :
6771 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6772 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6773 : :
6774 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6775 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6776 : :
6777 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6778 : :
6779 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6780 : 0 : fc_conf.high_water = res->high_water;
6781 : :
6782 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6783 : 0 : fc_conf.low_water = res->low_water;
6784 : :
6785 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6786 : 0 : fc_conf.pause_time = res->pause_time;
6787 : :
6788 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6789 : 0 : fc_conf.send_xon = res->send_xon;
6790 : :
6791 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6792 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6793 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6794 : : else
6795 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6796 : : }
6797 : :
6798 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6799 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6800 : :
6801 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6802 : 0 : if (ret != 0)
6803 : 0 : fprintf(stderr,
6804 : : "bad flow control parameter, return code = %d\n",
6805 : : ret);
6806 : : }
6807 : :
6808 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6809 : : struct cmd_priority_flow_ctrl_set_result {
6810 : : cmdline_fixed_string_t set;
6811 : : cmdline_fixed_string_t pfc_ctrl;
6812 : : cmdline_fixed_string_t rx;
6813 : : cmdline_fixed_string_t rx_pfc_mode;
6814 : : cmdline_fixed_string_t tx;
6815 : : cmdline_fixed_string_t tx_pfc_mode;
6816 : : uint32_t high_water;
6817 : : uint32_t low_water;
6818 : : uint16_t pause_time;
6819 : : uint8_t priority;
6820 : : portid_t port_id;
6821 : : };
6822 : :
6823 : : static void
6824 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6825 : : __rte_unused struct cmdline *cl,
6826 : : __rte_unused void *data)
6827 : : {
6828 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6829 : : struct rte_eth_pfc_conf pfc_conf;
6830 : : int rx_fc_enable, tx_fc_enable;
6831 : : int ret;
6832 : :
6833 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
6834 : 0 : return;
6835 : :
6836 : : /*
6837 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6838 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6839 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6840 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6841 : : */
6842 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6843 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6844 : : };
6845 : :
6846 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6847 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6848 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6849 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6850 : 0 : pfc_conf.fc.high_water = res->high_water;
6851 : 0 : pfc_conf.fc.low_water = res->low_water;
6852 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6853 : 0 : pfc_conf.priority = res->priority;
6854 : :
6855 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6856 : 0 : if (ret != 0)
6857 : 0 : fprintf(stderr,
6858 : : "bad priority flow control parameter, return code = %d\n",
6859 : : ret);
6860 : : }
6861 : :
6862 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6863 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6864 : : set, "set");
6865 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6866 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6867 : : pfc_ctrl, "pfc_ctrl");
6868 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6869 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6870 : : rx, "rx");
6871 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6872 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6873 : : rx_pfc_mode, "on#off");
6874 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6875 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6876 : : tx, "tx");
6877 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6878 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6879 : : tx_pfc_mode, "on#off");
6880 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6881 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6882 : : high_water, RTE_UINT32);
6883 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6884 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6885 : : low_water, RTE_UINT32);
6886 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6887 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6888 : : pause_time, RTE_UINT16);
6889 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6890 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6891 : : priority, RTE_UINT8);
6892 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6893 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6894 : : port_id, RTE_UINT16);
6895 : :
6896 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6897 : : .f = cmd_priority_flow_ctrl_set_parsed,
6898 : : .data = NULL,
6899 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6900 : : "<pause_time> <priority> <port_id>: "
6901 : : "Configure the Ethernet priority flow control",
6902 : : .tokens = {
6903 : : (void *)&cmd_pfc_set_set,
6904 : : (void *)&cmd_pfc_set_flow_ctrl,
6905 : : (void *)&cmd_pfc_set_rx,
6906 : : (void *)&cmd_pfc_set_rx_mode,
6907 : : (void *)&cmd_pfc_set_tx,
6908 : : (void *)&cmd_pfc_set_tx_mode,
6909 : : (void *)&cmd_pfc_set_high_water,
6910 : : (void *)&cmd_pfc_set_low_water,
6911 : : (void *)&cmd_pfc_set_pause_time,
6912 : : (void *)&cmd_pfc_set_priority,
6913 : : (void *)&cmd_pfc_set_portid,
6914 : : NULL,
6915 : : },
6916 : : };
6917 : :
6918 : : struct cmd_queue_priority_flow_ctrl_set_result {
6919 : : cmdline_fixed_string_t set;
6920 : : cmdline_fixed_string_t pfc_queue_ctrl;
6921 : : portid_t port_id;
6922 : : cmdline_fixed_string_t rx;
6923 : : cmdline_fixed_string_t rx_pfc_mode;
6924 : : uint16_t tx_qid;
6925 : : uint8_t tx_tc;
6926 : : cmdline_fixed_string_t tx;
6927 : : cmdline_fixed_string_t tx_pfc_mode;
6928 : : uint16_t rx_qid;
6929 : : uint8_t rx_tc;
6930 : : uint16_t pause_time;
6931 : : };
6932 : :
6933 : : static void
6934 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6935 : : __rte_unused struct cmdline *cl,
6936 : : __rte_unused void *data)
6937 : : {
6938 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6939 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6940 : : int rx_fc_enable, tx_fc_enable;
6941 : : int ret;
6942 : :
6943 : : /*
6944 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6945 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6946 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6947 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6948 : : * the Tx side.
6949 : : */
6950 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6951 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6952 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6953 : : };
6954 : :
6955 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6956 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6957 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6958 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6959 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6960 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6961 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6962 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6963 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6964 : :
6965 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6966 : : &pfc_queue_conf);
6967 : 0 : if (ret != 0) {
6968 : 0 : fprintf(stderr,
6969 : : "bad queue priority flow control parameter, rc = %d\n",
6970 : : ret);
6971 : : }
6972 : 0 : }
6973 : :
6974 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6975 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6976 : : set, "set");
6977 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6978 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6979 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6980 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6981 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6982 : : port_id, RTE_UINT16);
6983 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6984 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6985 : : rx, "rx");
6986 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6987 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6988 : : rx_pfc_mode, "on#off");
6989 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6990 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6991 : : tx_qid, RTE_UINT16);
6992 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6993 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6994 : : tx_tc, RTE_UINT8);
6995 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6996 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6997 : : tx, "tx");
6998 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6999 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7000 : : tx_pfc_mode, "on#off");
7001 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7002 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7003 : : rx_qid, RTE_UINT16);
7004 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7005 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7006 : : rx_tc, RTE_UINT8);
7007 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7008 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7009 : : pause_time, RTE_UINT16);
7010 : :
7011 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7012 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7013 : : .data = NULL,
7014 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7015 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7016 : : "Configure the Ethernet queue priority flow control",
7017 : : .tokens = {
7018 : : (void *)&cmd_q_pfc_set_set,
7019 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7020 : : (void *)&cmd_q_pfc_set_portid,
7021 : : (void *)&cmd_q_pfc_set_rx,
7022 : : (void *)&cmd_q_pfc_set_rx_mode,
7023 : : (void *)&cmd_q_pfc_set_tx_qid,
7024 : : (void *)&cmd_q_pfc_set_tx_tc,
7025 : : (void *)&cmd_q_pfc_set_tx,
7026 : : (void *)&cmd_q_pfc_set_tx_mode,
7027 : : (void *)&cmd_q_pfc_set_rx_qid,
7028 : : (void *)&cmd_q_pfc_set_rx_tc,
7029 : : (void *)&cmd_q_pfc_set_pause_time,
7030 : : NULL,
7031 : : },
7032 : : };
7033 : :
7034 : : /* *** RESET CONFIGURATION *** */
7035 : : struct cmd_reset_result {
7036 : : cmdline_fixed_string_t reset;
7037 : : cmdline_fixed_string_t def;
7038 : : };
7039 : :
7040 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7041 : : struct cmdline *cl,
7042 : : __rte_unused void *data)
7043 : : {
7044 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7045 : 0 : set_def_fwd_config();
7046 : 0 : }
7047 : :
7048 : : static cmdline_parse_token_string_t cmd_reset_set =
7049 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7050 : : static cmdline_parse_token_string_t cmd_reset_def =
7051 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7052 : : "default");
7053 : :
7054 : : static cmdline_parse_inst_t cmd_reset = {
7055 : : .f = cmd_reset_parsed,
7056 : : .data = NULL,
7057 : : .help_str = "set default: Reset default forwarding configuration",
7058 : : .tokens = {
7059 : : (void *)&cmd_reset_set,
7060 : : (void *)&cmd_reset_def,
7061 : : NULL,
7062 : : },
7063 : : };
7064 : :
7065 : : /* *** START FORWARDING *** */
7066 : : struct cmd_start_result {
7067 : : cmdline_fixed_string_t start;
7068 : : };
7069 : :
7070 : : static cmdline_parse_token_string_t cmd_start_start =
7071 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7072 : :
7073 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7074 : : __rte_unused struct cmdline *cl,
7075 : : __rte_unused void *data)
7076 : : {
7077 : 0 : start_packet_forwarding(0);
7078 : 0 : }
7079 : :
7080 : : static cmdline_parse_inst_t cmd_start = {
7081 : : .f = cmd_start_parsed,
7082 : : .data = NULL,
7083 : : .help_str = "start: Start packet forwarding",
7084 : : .tokens = {
7085 : : (void *)&cmd_start_start,
7086 : : NULL,
7087 : : },
7088 : : };
7089 : :
7090 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7091 : : struct cmd_start_tx_first_result {
7092 : : cmdline_fixed_string_t start;
7093 : : cmdline_fixed_string_t tx_first;
7094 : : };
7095 : :
7096 : : static void
7097 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7098 : : __rte_unused struct cmdline *cl,
7099 : : __rte_unused void *data)
7100 : : {
7101 : 0 : start_packet_forwarding(1);
7102 : 0 : }
7103 : :
7104 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7105 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7106 : : "start");
7107 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7108 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7109 : : tx_first, "tx_first");
7110 : :
7111 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7112 : : .f = cmd_start_tx_first_parsed,
7113 : : .data = NULL,
7114 : : .help_str = "start tx_first: Start packet forwarding, "
7115 : : "after sending 1 burst of packets",
7116 : : .tokens = {
7117 : : (void *)&cmd_start_tx_first_start,
7118 : : (void *)&cmd_start_tx_first_tx_first,
7119 : : NULL,
7120 : : },
7121 : : };
7122 : :
7123 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7124 : : struct cmd_start_tx_first_n_result {
7125 : : cmdline_fixed_string_t start;
7126 : : cmdline_fixed_string_t tx_first;
7127 : : uint32_t tx_num;
7128 : : };
7129 : :
7130 : : static void
7131 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7132 : : __rte_unused struct cmdline *cl,
7133 : : __rte_unused void *data)
7134 : : {
7135 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7136 : :
7137 : 0 : start_packet_forwarding(res->tx_num);
7138 : 0 : }
7139 : :
7140 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7141 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7142 : : start, "start");
7143 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7144 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7145 : : tx_first, "tx_first");
7146 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7147 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7148 : : tx_num, RTE_UINT32);
7149 : :
7150 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7151 : : .f = cmd_start_tx_first_n_parsed,
7152 : : .data = NULL,
7153 : : .help_str = "start tx_first <num>: "
7154 : : "packet forwarding, after sending <num> bursts of packets",
7155 : : .tokens = {
7156 : : (void *)&cmd_start_tx_first_n_start,
7157 : : (void *)&cmd_start_tx_first_n_tx_first,
7158 : : (void *)&cmd_start_tx_first_n_tx_num,
7159 : : NULL,
7160 : : },
7161 : : };
7162 : :
7163 : : /* *** SET LINK UP *** */
7164 : : struct cmd_set_link_up_result {
7165 : : cmdline_fixed_string_t set;
7166 : : cmdline_fixed_string_t link_up;
7167 : : cmdline_fixed_string_t port;
7168 : : portid_t port_id;
7169 : : };
7170 : :
7171 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7172 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7173 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7174 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7175 : : "link-up");
7176 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7177 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7178 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7179 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7180 : : RTE_UINT16);
7181 : :
7182 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7183 : : __rte_unused struct cmdline *cl,
7184 : : __rte_unused void *data)
7185 : : {
7186 : : struct cmd_set_link_up_result *res = parsed_result;
7187 : 0 : dev_set_link_up(res->port_id);
7188 : 0 : }
7189 : :
7190 : : static cmdline_parse_inst_t cmd_set_link_up = {
7191 : : .f = cmd_set_link_up_parsed,
7192 : : .data = NULL,
7193 : : .help_str = "set link-up port <port id>",
7194 : : .tokens = {
7195 : : (void *)&cmd_set_link_up_set,
7196 : : (void *)&cmd_set_link_up_link_up,
7197 : : (void *)&cmd_set_link_up_port,
7198 : : (void *)&cmd_set_link_up_port_id,
7199 : : NULL,
7200 : : },
7201 : : };
7202 : :
7203 : : /* *** SET LINK DOWN *** */
7204 : : struct cmd_set_link_down_result {
7205 : : cmdline_fixed_string_t set;
7206 : : cmdline_fixed_string_t link_down;
7207 : : cmdline_fixed_string_t port;
7208 : : portid_t port_id;
7209 : : };
7210 : :
7211 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7212 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7213 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7214 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7215 : : "link-down");
7216 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7217 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7218 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7219 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7220 : : RTE_UINT16);
7221 : :
7222 : 0 : static void cmd_set_link_down_parsed(
7223 : : __rte_unused void *parsed_result,
7224 : : __rte_unused struct cmdline *cl,
7225 : : __rte_unused void *data)
7226 : : {
7227 : : struct cmd_set_link_down_result *res = parsed_result;
7228 : 0 : dev_set_link_down(res->port_id);
7229 : 0 : }
7230 : :
7231 : : static cmdline_parse_inst_t cmd_set_link_down = {
7232 : : .f = cmd_set_link_down_parsed,
7233 : : .data = NULL,
7234 : : .help_str = "set link-down port <port id>",
7235 : : .tokens = {
7236 : : (void *)&cmd_set_link_down_set,
7237 : : (void *)&cmd_set_link_down_link_down,
7238 : : (void *)&cmd_set_link_down_port,
7239 : : (void *)&cmd_set_link_down_port_id,
7240 : : NULL,
7241 : : },
7242 : : };
7243 : :
7244 : : /* *** SHOW CFG *** */
7245 : : struct cmd_showcfg_result {
7246 : : cmdline_fixed_string_t show;
7247 : : cmdline_fixed_string_t cfg;
7248 : : cmdline_fixed_string_t what;
7249 : : };
7250 : :
7251 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7252 : : __rte_unused struct cmdline *cl,
7253 : : __rte_unused void *data)
7254 : : {
7255 : : struct cmd_showcfg_result *res = parsed_result;
7256 : 0 : if (!strcmp(res->what, "rxtx"))
7257 : 0 : rxtx_config_display();
7258 : 0 : else if (!strcmp(res->what, "cores"))
7259 : 0 : fwd_lcores_config_display();
7260 : 0 : else if (!strcmp(res->what, "fwd"))
7261 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7262 : 0 : else if (!strcmp(res->what, "rxoffs"))
7263 : 0 : show_rx_pkt_offsets();
7264 : 0 : else if (!strcmp(res->what, "rxpkts"))
7265 : 0 : show_rx_pkt_segments();
7266 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7267 : 0 : show_rx_pkt_hdrs();
7268 : 0 : else if (!strcmp(res->what, "txpkts"))
7269 : 0 : show_tx_pkt_segments();
7270 : 0 : else if (!strcmp(res->what, "txtimes"))
7271 : 0 : show_tx_pkt_times();
7272 : 0 : }
7273 : :
7274 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7275 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7276 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7277 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7278 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7279 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7280 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
7281 : :
7282 : : static cmdline_parse_inst_t cmd_showcfg = {
7283 : : .f = cmd_showcfg_parsed,
7284 : : .data = NULL,
7285 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
7286 : : .tokens = {
7287 : : (void *)&cmd_showcfg_show,
7288 : : (void *)&cmd_showcfg_port,
7289 : : (void *)&cmd_showcfg_what,
7290 : : NULL,
7291 : : },
7292 : : };
7293 : :
7294 : : /* *** SHOW ALL PORT INFO *** */
7295 : : struct cmd_showportall_result {
7296 : : cmdline_fixed_string_t show;
7297 : : cmdline_fixed_string_t port;
7298 : : cmdline_fixed_string_t what;
7299 : : cmdline_fixed_string_t all;
7300 : : };
7301 : :
7302 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7303 : : __rte_unused struct cmdline *cl,
7304 : : __rte_unused void *data)
7305 : : {
7306 : : portid_t i;
7307 : :
7308 : : struct cmd_showportall_result *res = parsed_result;
7309 : 0 : if (!strcmp(res->show, "clear")) {
7310 : 0 : if (!strcmp(res->what, "stats"))
7311 : 0 : RTE_ETH_FOREACH_DEV(i)
7312 : 0 : nic_stats_clear(i);
7313 : 0 : else if (!strcmp(res->what, "xstats"))
7314 : 0 : RTE_ETH_FOREACH_DEV(i)
7315 : 0 : nic_xstats_clear(i);
7316 : 0 : } else if (!strcmp(res->what, "info"))
7317 : 0 : RTE_ETH_FOREACH_DEV(i)
7318 : 0 : port_infos_display(i);
7319 : 0 : else if (!strcmp(res->what, "summary")) {
7320 : 0 : port_summary_header_display();
7321 : 0 : RTE_ETH_FOREACH_DEV(i)
7322 : 0 : port_summary_display(i);
7323 : : }
7324 : 0 : else if (!strcmp(res->what, "stats"))
7325 : 0 : RTE_ETH_FOREACH_DEV(i)
7326 : 0 : nic_stats_display(i);
7327 : 0 : else if (!strcmp(res->what, "xstats"))
7328 : 0 : RTE_ETH_FOREACH_DEV(i)
7329 : 0 : nic_xstats_display(i);
7330 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7331 : 0 : else if (!strcmp(res->what, "fdir"))
7332 : 0 : RTE_ETH_FOREACH_DEV(i)
7333 : 0 : fdir_get_infos(i);
7334 : : #endif
7335 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7336 : 0 : RTE_ETH_FOREACH_DEV(i)
7337 : 0 : port_dcb_info_display(i);
7338 : 0 : }
7339 : :
7340 : : static cmdline_parse_token_string_t cmd_showportall_show =
7341 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7342 : : "show#clear");
7343 : : static cmdline_parse_token_string_t cmd_showportall_port =
7344 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7345 : : static cmdline_parse_token_string_t cmd_showportall_what =
7346 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7347 : : "info#summary#stats#xstats#fdir#dcb_tc");
7348 : : static cmdline_parse_token_string_t cmd_showportall_all =
7349 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7350 : : static cmdline_parse_inst_t cmd_showportall = {
7351 : : .f = cmd_showportall_parsed,
7352 : : .data = NULL,
7353 : : .help_str = "show|clear port "
7354 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7355 : : .tokens = {
7356 : : (void *)&cmd_showportall_show,
7357 : : (void *)&cmd_showportall_port,
7358 : : (void *)&cmd_showportall_what,
7359 : : (void *)&cmd_showportall_all,
7360 : : NULL,
7361 : : },
7362 : : };
7363 : :
7364 : : /* *** SHOW PORT INFO *** */
7365 : : struct cmd_showport_result {
7366 : : cmdline_fixed_string_t show;
7367 : : cmdline_fixed_string_t port;
7368 : : cmdline_fixed_string_t what;
7369 : : uint16_t portnum;
7370 : : };
7371 : :
7372 : 0 : static void cmd_showport_parsed(void *parsed_result,
7373 : : __rte_unused struct cmdline *cl,
7374 : : __rte_unused void *data)
7375 : : {
7376 : : struct cmd_showport_result *res = parsed_result;
7377 : 0 : if (!strcmp(res->show, "clear")) {
7378 : 0 : if (!strcmp(res->what, "stats"))
7379 : 0 : nic_stats_clear(res->portnum);
7380 : 0 : else if (!strcmp(res->what, "xstats"))
7381 : 0 : nic_xstats_clear(res->portnum);
7382 : 0 : } else if (!strcmp(res->what, "info"))
7383 : 0 : port_infos_display(res->portnum);
7384 : 0 : else if (!strcmp(res->what, "summary")) {
7385 : 0 : port_summary_header_display();
7386 : 0 : port_summary_display(res->portnum);
7387 : : }
7388 : 0 : else if (!strcmp(res->what, "stats"))
7389 : 0 : nic_stats_display(res->portnum);
7390 : 0 : else if (!strcmp(res->what, "xstats"))
7391 : 0 : nic_xstats_display(res->portnum);
7392 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7393 : 0 : else if (!strcmp(res->what, "fdir"))
7394 : 0 : fdir_get_infos(res->portnum);
7395 : : #endif
7396 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7397 : 0 : port_dcb_info_display(res->portnum);
7398 : 0 : }
7399 : :
7400 : : static cmdline_parse_token_string_t cmd_showport_show =
7401 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7402 : : "show#clear");
7403 : : static cmdline_parse_token_string_t cmd_showport_port =
7404 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7405 : : static cmdline_parse_token_string_t cmd_showport_what =
7406 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7407 : : "info#summary#stats#xstats#fdir#dcb_tc");
7408 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7409 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7410 : :
7411 : : static cmdline_parse_inst_t cmd_showport = {
7412 : : .f = cmd_showport_parsed,
7413 : : .data = NULL,
7414 : : .help_str = "show|clear port "
7415 : : "info|summary|stats|xstats|fdir|dcb_tc "
7416 : : "<port_id>",
7417 : : .tokens = {
7418 : : (void *)&cmd_showport_show,
7419 : : (void *)&cmd_showport_port,
7420 : : (void *)&cmd_showport_what,
7421 : : (void *)&cmd_showport_portnum,
7422 : : NULL,
7423 : : },
7424 : : };
7425 : :
7426 : : /* *** show port representors information *** */
7427 : : struct cmd_representor_info_result {
7428 : : cmdline_fixed_string_t cmd_show;
7429 : : cmdline_fixed_string_t cmd_port;
7430 : : cmdline_fixed_string_t cmd_info;
7431 : : cmdline_fixed_string_t cmd_keyword;
7432 : : portid_t cmd_pid;
7433 : : };
7434 : :
7435 : : static void
7436 : 0 : cmd_representor_info_parsed(void *parsed_result,
7437 : : __rte_unused struct cmdline *cl,
7438 : : __rte_unused void *data)
7439 : : {
7440 : : struct cmd_representor_info_result *res = parsed_result;
7441 : : struct rte_eth_representor_info *info;
7442 : : struct rte_eth_representor_range *range;
7443 : : uint32_t range_diff;
7444 : : uint32_t i;
7445 : : int ret;
7446 : : int num;
7447 : :
7448 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7449 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7450 : 0 : return;
7451 : : }
7452 : :
7453 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7454 : 0 : if (ret < 0) {
7455 : 0 : fprintf(stderr,
7456 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7457 : 0 : res->cmd_pid, rte_strerror(-ret));
7458 : 0 : return;
7459 : : }
7460 : : num = ret;
7461 : :
7462 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7463 : 0 : if (info == NULL) {
7464 : 0 : fprintf(stderr,
7465 : : "Failed to allocate memory for representor info for port %hu\n",
7466 : 0 : res->cmd_pid);
7467 : 0 : return;
7468 : : }
7469 : 0 : info->nb_ranges_alloc = num;
7470 : :
7471 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7472 : 0 : if (ret < 0) {
7473 : 0 : fprintf(stderr,
7474 : : "Failed to get the representor info for port %hu: %s\n",
7475 : 0 : res->cmd_pid, rte_strerror(-ret));
7476 : 0 : free(info);
7477 : 0 : return;
7478 : : }
7479 : :
7480 : 0 : printf("Port controller: %hu\n", info->controller);
7481 : 0 : printf("Port PF: %hu\n", info->pf);
7482 : :
7483 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7484 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7485 : : range = &info->ranges[i];
7486 : 0 : range_diff = range->id_end - range->id_base;
7487 : :
7488 : 0 : printf("%u. ", i + 1);
7489 : 0 : printf("'%s' ", range->name);
7490 : 0 : if (range_diff > 0)
7491 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7492 : : else
7493 : 0 : printf("[%u]: ", range->id_base);
7494 : :
7495 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7496 : :
7497 : 0 : switch (range->type) {
7498 : : case RTE_ETH_REPRESENTOR_NONE:
7499 : : printf(", NONE\n");
7500 : : break;
7501 : 0 : case RTE_ETH_REPRESENTOR_VF:
7502 : 0 : if (range_diff > 0)
7503 : 0 : printf(", VF %d..%d\n", range->vf,
7504 : 0 : range->vf + range_diff);
7505 : : else
7506 : 0 : printf(", VF %d\n", range->vf);
7507 : : break;
7508 : 0 : case RTE_ETH_REPRESENTOR_SF:
7509 : 0 : printf(", SF %d\n", range->sf);
7510 : : break;
7511 : 0 : case RTE_ETH_REPRESENTOR_PF:
7512 : 0 : if (range_diff > 0)
7513 : 0 : printf("..%d\n", range->pf + range_diff);
7514 : : else
7515 : : printf("\n");
7516 : : break;
7517 : 0 : default:
7518 : : printf(", UNKNOWN TYPE %d\n", range->type);
7519 : : break;
7520 : : }
7521 : : }
7522 : :
7523 : 0 : free(info);
7524 : : }
7525 : :
7526 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7527 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7528 : : cmd_show, "show");
7529 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7530 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7531 : : cmd_port, "port");
7532 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7533 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7534 : : cmd_info, "info");
7535 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7536 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7537 : : cmd_pid, RTE_UINT16);
7538 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7539 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7540 : : cmd_keyword, "representor");
7541 : :
7542 : : static cmdline_parse_inst_t cmd_representor_info = {
7543 : : .f = cmd_representor_info_parsed,
7544 : : .data = NULL,
7545 : : .help_str = "show port info <port_id> representor",
7546 : : .tokens = {
7547 : : (void *)&cmd_representor_info_show,
7548 : : (void *)&cmd_representor_info_port,
7549 : : (void *)&cmd_representor_info_info,
7550 : : (void *)&cmd_representor_info_pid,
7551 : : (void *)&cmd_representor_info_keyword,
7552 : : NULL,
7553 : : },
7554 : : };
7555 : :
7556 : :
7557 : : /* *** SHOW DEVICE INFO *** */
7558 : : struct cmd_showdevice_result {
7559 : : cmdline_fixed_string_t show;
7560 : : cmdline_fixed_string_t device;
7561 : : cmdline_fixed_string_t what;
7562 : : cmdline_fixed_string_t identifier;
7563 : : };
7564 : :
7565 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7566 : : __rte_unused struct cmdline *cl,
7567 : : __rte_unused void *data)
7568 : : {
7569 : : struct cmd_showdevice_result *res = parsed_result;
7570 : 0 : if (!strcmp(res->what, "info")) {
7571 : 0 : if (!strcmp(res->identifier, "all"))
7572 : 0 : device_infos_display(NULL);
7573 : : else
7574 : 0 : device_infos_display(res->identifier);
7575 : : }
7576 : 0 : }
7577 : :
7578 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7579 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7580 : : "show");
7581 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7582 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7583 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7584 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7585 : : "info");
7586 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7587 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7588 : : identifier, NULL);
7589 : :
7590 : : static cmdline_parse_inst_t cmd_showdevice = {
7591 : : .f = cmd_showdevice_parsed,
7592 : : .data = NULL,
7593 : : .help_str = "show device info <identifier>|all",
7594 : : .tokens = {
7595 : : (void *)&cmd_showdevice_show,
7596 : : (void *)&cmd_showdevice_device,
7597 : : (void *)&cmd_showdevice_what,
7598 : : (void *)&cmd_showdevice_identifier,
7599 : : NULL,
7600 : : },
7601 : : };
7602 : :
7603 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7604 : : struct cmd_showeeprom_result {
7605 : : cmdline_fixed_string_t show;
7606 : : cmdline_fixed_string_t port;
7607 : : uint16_t portnum;
7608 : : cmdline_fixed_string_t type;
7609 : : };
7610 : :
7611 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7612 : : __rte_unused struct cmdline *cl,
7613 : : __rte_unused void *data)
7614 : : {
7615 : : struct cmd_showeeprom_result *res = parsed_result;
7616 : :
7617 : 0 : if (!strcmp(res->type, "eeprom"))
7618 : 0 : port_eeprom_display(res->portnum);
7619 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7620 : 0 : port_module_eeprom_display(res->portnum);
7621 : : else
7622 : 0 : fprintf(stderr, "Unknown argument\n");
7623 : 0 : }
7624 : :
7625 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7626 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7627 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7628 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7629 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7630 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7631 : : RTE_UINT16);
7632 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7633 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7634 : :
7635 : : static cmdline_parse_inst_t cmd_showeeprom = {
7636 : : .f = cmd_showeeprom_parsed,
7637 : : .data = NULL,
7638 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7639 : : .tokens = {
7640 : : (void *)&cmd_showeeprom_show,
7641 : : (void *)&cmd_showeeprom_port,
7642 : : (void *)&cmd_showeeprom_portnum,
7643 : : (void *)&cmd_showeeprom_type,
7644 : : NULL,
7645 : : },
7646 : : };
7647 : :
7648 : : /* *** SET PORT EEPROM *** */
7649 : : struct cmd_seteeprom_result {
7650 : : cmdline_fixed_string_t set;
7651 : : cmdline_fixed_string_t port;
7652 : : uint16_t portnum;
7653 : : cmdline_fixed_string_t eeprom;
7654 : : cmdline_fixed_string_t confirm_str;
7655 : : cmdline_fixed_string_t magic_str;
7656 : : uint32_t magic;
7657 : : cmdline_fixed_string_t value;
7658 : : cmdline_multi_string_t token_str;
7659 : : };
7660 : :
7661 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7662 : : __rte_unused struct cmdline *cl,
7663 : : __rte_unused void *data)
7664 : : {
7665 : : struct cmd_seteeprom_result *res = parsed_result;
7666 : : uint32_t offset = 0;
7667 : : uint32_t length;
7668 : : uint8_t *value;
7669 : : char *token_str;
7670 : : char *token;
7671 : :
7672 : 0 : token_str = res->token_str;
7673 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7674 : :
7675 : : /* Parse Hex string to Byte data */
7676 : 0 : if (strlen(token) % 2 != 0) {
7677 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7678 : : token);
7679 : 0 : return;
7680 : : }
7681 : :
7682 : 0 : length = strlen(token) / 2;
7683 : 0 : value = calloc(length, sizeof(uint8_t));
7684 : 0 : for (int count = 0; count < (int)(length); count++) {
7685 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7686 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7687 : 0 : token - (count + 1));
7688 : 0 : goto out;
7689 : : }
7690 : 0 : token += 2;
7691 : : }
7692 : :
7693 : : /* Second token: offset string */
7694 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7695 : 0 : if (token != NULL) {
7696 : 0 : if (strcmp(token, "offset") == 0) {
7697 : : /* Third token: offset */
7698 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7699 : 0 : if (token == NULL) {
7700 : 0 : fprintf(stderr, "No offset specified\n");
7701 : 0 : goto out;
7702 : : }
7703 : :
7704 : : char *end;
7705 : 0 : offset = strtoul(token, &end, 10);
7706 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7707 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7708 : 0 : goto out;
7709 : : }
7710 : : } else {
7711 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7712 : 0 : goto out;
7713 : : }
7714 : : }
7715 : :
7716 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7717 : :
7718 : 0 : out:
7719 : 0 : free(value);
7720 : : }
7721 : :
7722 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7723 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7724 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7725 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7726 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7727 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7728 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7729 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7730 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7731 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7732 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7733 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7734 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7735 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7736 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7737 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7738 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7739 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7740 : :
7741 : : static cmdline_parse_inst_t cmd_seteeprom = {
7742 : : .f = cmd_seteeprom_parsed,
7743 : : .data = NULL,
7744 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7745 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7746 : : "Note:\n"
7747 : : "This is a high-risk command and its misuse may result in "
7748 : : "unexpected behaviour from the NIC.\n"
7749 : : "By inserting \"accept_risk\" into the command, the user is "
7750 : : "acknowledging and taking responsibility for this risk.",
7751 : : .tokens = {
7752 : : (void *)&cmd_seteeprom_set,
7753 : : (void *)&cmd_seteeprom_port,
7754 : : (void *)&cmd_seteeprom_portnum,
7755 : : (void *)&cmd_seteeprom_eeprom,
7756 : : (void *)&cmd_seteeprom_confirm_str,
7757 : : (void *)&cmd_seteeprom_magic_str,
7758 : : (void *)&cmd_seteeprom_magic,
7759 : : (void *)&cmd_seteeprom_value,
7760 : : (void *)&cmd_seteeprom_token_str,
7761 : : NULL,
7762 : : },
7763 : : };
7764 : :
7765 : : /* *** SHOW QUEUE INFO *** */
7766 : : struct cmd_showqueue_result {
7767 : : cmdline_fixed_string_t show;
7768 : : cmdline_fixed_string_t type;
7769 : : cmdline_fixed_string_t what;
7770 : : uint16_t portnum;
7771 : : uint16_t queuenum;
7772 : : };
7773 : :
7774 : : static void
7775 : 0 : cmd_showqueue_parsed(void *parsed_result,
7776 : : __rte_unused struct cmdline *cl,
7777 : : __rte_unused void *data)
7778 : : {
7779 : : struct cmd_showqueue_result *res = parsed_result;
7780 : :
7781 : 0 : if (!strcmp(res->type, "rxq"))
7782 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7783 : 0 : else if (!strcmp(res->type, "txq"))
7784 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7785 : 0 : }
7786 : :
7787 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7788 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7789 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7790 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7791 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7792 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7793 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7794 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7795 : : RTE_UINT16);
7796 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7797 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7798 : : RTE_UINT16);
7799 : :
7800 : : static cmdline_parse_inst_t cmd_showqueue = {
7801 : : .f = cmd_showqueue_parsed,
7802 : : .data = NULL,
7803 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7804 : : .tokens = {
7805 : : (void *)&cmd_showqueue_show,
7806 : : (void *)&cmd_showqueue_type,
7807 : : (void *)&cmd_showqueue_what,
7808 : : (void *)&cmd_showqueue_portnum,
7809 : : (void *)&cmd_showqueue_queuenum,
7810 : : NULL,
7811 : : },
7812 : : };
7813 : :
7814 : : /* show/clear fwd engine statistics */
7815 : : struct fwd_result {
7816 : : cmdline_fixed_string_t action;
7817 : : cmdline_fixed_string_t fwd;
7818 : : cmdline_fixed_string_t stats;
7819 : : cmdline_fixed_string_t all;
7820 : : };
7821 : :
7822 : : static cmdline_parse_token_string_t cmd_fwd_action =
7823 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7824 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7825 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7826 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7827 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7828 : : static cmdline_parse_token_string_t cmd_fwd_all =
7829 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7830 : :
7831 : : static void
7832 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7833 : : __rte_unused struct cmdline *cl,
7834 : : __rte_unused void *data)
7835 : : {
7836 : : struct fwd_result *res = parsed_result;
7837 : :
7838 : 0 : if (!strcmp(res->action, "show"))
7839 : 0 : fwd_stats_display();
7840 : : else
7841 : 0 : fwd_stats_reset();
7842 : 0 : }
7843 : :
7844 : : static cmdline_parse_inst_t cmd_showfwdall = {
7845 : : .f = cmd_showfwdall_parsed,
7846 : : .data = NULL,
7847 : : .help_str = "show|clear fwd stats all",
7848 : : .tokens = {
7849 : : (void *)&cmd_fwd_action,
7850 : : (void *)&cmd_fwd_fwd,
7851 : : (void *)&cmd_fwd_stats,
7852 : : (void *)&cmd_fwd_all,
7853 : : NULL,
7854 : : },
7855 : : };
7856 : :
7857 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7858 : : struct cmd_read_rxd_txd_result {
7859 : : cmdline_fixed_string_t read;
7860 : : cmdline_fixed_string_t rxd_txd;
7861 : : portid_t port_id;
7862 : : uint16_t queue_id;
7863 : : uint16_t desc_id;
7864 : : };
7865 : :
7866 : : static void
7867 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7868 : : __rte_unused struct cmdline *cl,
7869 : : __rte_unused void *data)
7870 : : {
7871 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7872 : :
7873 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7874 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7875 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7876 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7877 : 0 : }
7878 : :
7879 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7880 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7881 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7882 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7883 : : "rxd#txd");
7884 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7885 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7886 : : RTE_UINT16);
7887 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7888 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7889 : : RTE_UINT16);
7890 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7891 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7892 : : RTE_UINT16);
7893 : :
7894 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7895 : : .f = cmd_read_rxd_txd_parsed,
7896 : : .data = NULL,
7897 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7898 : : .tokens = {
7899 : : (void *)&cmd_read_rxd_txd_read,
7900 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7901 : : (void *)&cmd_read_rxd_txd_port_id,
7902 : : (void *)&cmd_read_rxd_txd_queue_id,
7903 : : (void *)&cmd_read_rxd_txd_desc_id,
7904 : : NULL,
7905 : : },
7906 : : };
7907 : :
7908 : : /* *** QUIT *** */
7909 : : struct cmd_quit_result {
7910 : : cmdline_fixed_string_t quit;
7911 : : };
7912 : :
7913 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7914 : : struct cmdline *cl,
7915 : : __rte_unused void *data)
7916 : : {
7917 : 0 : cmdline_quit(cl);
7918 : 0 : cl_quit = 1;
7919 : 0 : }
7920 : :
7921 : : static cmdline_parse_token_string_t cmd_quit_quit =
7922 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7923 : :
7924 : : static cmdline_parse_inst_t cmd_quit = {
7925 : : .f = cmd_quit_parsed,
7926 : : .data = NULL,
7927 : : .help_str = "quit: Exit application",
7928 : : .tokens = {
7929 : : (void *)&cmd_quit_quit,
7930 : : NULL,
7931 : : },
7932 : : };
7933 : :
7934 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7935 : : struct cmd_mac_addr_result {
7936 : : cmdline_fixed_string_t mac_addr_cmd;
7937 : : cmdline_fixed_string_t what;
7938 : : uint16_t port_num;
7939 : : struct rte_ether_addr address;
7940 : : };
7941 : :
7942 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7943 : : __rte_unused struct cmdline *cl,
7944 : : __rte_unused void *data)
7945 : : {
7946 : : struct cmd_mac_addr_result *res = parsed_result;
7947 : : int ret;
7948 : :
7949 : 0 : if (strcmp(res->what, "add") == 0)
7950 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7951 : 0 : else if (strcmp(res->what, "set") == 0)
7952 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7953 : : &res->address);
7954 : : else
7955 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7956 : :
7957 : : /* check the return value and print it if is < 0 */
7958 : 0 : if(ret < 0)
7959 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7960 : :
7961 : 0 : }
7962 : :
7963 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7964 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7965 : : "mac_addr");
7966 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7967 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7968 : : "add#remove#set");
7969 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7970 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7971 : : RTE_UINT16);
7972 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7973 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7974 : :
7975 : : static cmdline_parse_inst_t cmd_mac_addr = {
7976 : : .f = cmd_mac_addr_parsed,
7977 : : .data = (void *)0,
7978 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7979 : : "Add/Remove/Set MAC address on port_id",
7980 : : .tokens = {
7981 : : (void *)&cmd_mac_addr_cmd,
7982 : : (void *)&cmd_mac_addr_what,
7983 : : (void *)&cmd_mac_addr_portnum,
7984 : : (void *)&cmd_mac_addr_addr,
7985 : : NULL,
7986 : : },
7987 : : };
7988 : :
7989 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7990 : : struct cmd_eth_peer_result {
7991 : : cmdline_fixed_string_t set;
7992 : : cmdline_fixed_string_t eth_peer;
7993 : : portid_t port_id;
7994 : : cmdline_fixed_string_t peer_addr;
7995 : : };
7996 : :
7997 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7998 : : __rte_unused struct cmdline *cl,
7999 : : __rte_unused void *data)
8000 : : {
8001 : : struct cmd_eth_peer_result *res = parsed_result;
8002 : :
8003 : 0 : if (test_done == 0) {
8004 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8005 : 0 : return;
8006 : : }
8007 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8008 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8009 : 0 : fwd_config_setup();
8010 : : }
8011 : : }
8012 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8013 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8014 : : static cmdline_parse_token_string_t cmd_eth_peer =
8015 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8016 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8017 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8018 : : RTE_UINT16);
8019 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8020 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8021 : :
8022 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8023 : : .f = cmd_set_eth_peer_parsed,
8024 : : .data = NULL,
8025 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8026 : : .tokens = {
8027 : : (void *)&cmd_eth_peer_set,
8028 : : (void *)&cmd_eth_peer,
8029 : : (void *)&cmd_eth_peer_port_id,
8030 : : (void *)&cmd_eth_peer_addr,
8031 : : NULL,
8032 : : },
8033 : : };
8034 : :
8035 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8036 : : struct cmd_set_qmap_result {
8037 : : cmdline_fixed_string_t set;
8038 : : cmdline_fixed_string_t qmap;
8039 : : cmdline_fixed_string_t what;
8040 : : portid_t port_id;
8041 : : uint16_t queue_id;
8042 : : uint8_t map_value;
8043 : : };
8044 : :
8045 : : static void
8046 : 0 : cmd_set_qmap_parsed(void *parsed_result,
8047 : : __rte_unused struct cmdline *cl,
8048 : : __rte_unused void *data)
8049 : : {
8050 : : struct cmd_set_qmap_result *res = parsed_result;
8051 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8052 : :
8053 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8054 : 0 : }
8055 : :
8056 : : static cmdline_parse_token_string_t cmd_setqmap_set =
8057 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8058 : : set, "set");
8059 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
8060 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8061 : : qmap, "stat_qmap");
8062 : : static cmdline_parse_token_string_t cmd_setqmap_what =
8063 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8064 : : what, "tx#rx");
8065 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
8066 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8067 : : port_id, RTE_UINT16);
8068 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
8069 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8070 : : queue_id, RTE_UINT16);
8071 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8072 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8073 : : map_value, RTE_UINT8);
8074 : :
8075 : : static cmdline_parse_inst_t cmd_set_qmap = {
8076 : : .f = cmd_set_qmap_parsed,
8077 : : .data = NULL,
8078 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8079 : : "Set statistics mapping value on tx|rx queue_id of port_id",
8080 : : .tokens = {
8081 : : (void *)&cmd_setqmap_set,
8082 : : (void *)&cmd_setqmap_qmap,
8083 : : (void *)&cmd_setqmap_what,
8084 : : (void *)&cmd_setqmap_portid,
8085 : : (void *)&cmd_setqmap_queueid,
8086 : : (void *)&cmd_setqmap_mapvalue,
8087 : : NULL,
8088 : : },
8089 : : };
8090 : :
8091 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8092 : : struct cmd_set_xstats_hide_zero_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_xstats_hide_zero_parsed(void *parsed_result,
8100 : : __rte_unused struct cmdline *cl,
8101 : : __rte_unused void *data)
8102 : : {
8103 : : struct cmd_set_xstats_hide_zero_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_xstats_hide_zero(on_off);
8109 : 0 : }
8110 : :
8111 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8112 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8113 : : keyword, "set");
8114 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8115 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8116 : : name, "xstats-hide-zero");
8117 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8118 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8119 : : on_off, "on#off");
8120 : :
8121 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8122 : : .f = cmd_set_xstats_hide_zero_parsed,
8123 : : .data = NULL,
8124 : : .help_str = "set xstats-hide-zero on|off",
8125 : : .tokens = {
8126 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8127 : : (void *)&cmd_set_xstats_hide_zero_name,
8128 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8129 : : NULL,
8130 : : },
8131 : : };
8132 : :
8133 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8134 : : struct cmd_set_xstats_show_state_result {
8135 : : cmdline_fixed_string_t keyword;
8136 : : cmdline_fixed_string_t name;
8137 : : uint8_t on_off;
8138 : : };
8139 : : static void
8140 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8141 : : __rte_unused struct cmdline *cl,
8142 : : __rte_unused void *data)
8143 : : {
8144 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8145 : 0 : set_xstats_show_state(res->on_off);
8146 : 0 : }
8147 : :
8148 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8149 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8150 : : keyword, "set");
8151 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8152 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8153 : : name, "xstats-show-state");
8154 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8155 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8156 : : on_off);
8157 : :
8158 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8159 : : .f = cmd_set_xstats_show_state_parsed,
8160 : : .data = NULL,
8161 : : .help_str = "set xstats-show-state on|off",
8162 : : .tokens = {
8163 : : (void *)&cmd_set_xstats_show_state_keyword,
8164 : : (void *)&cmd_set_xstats_show_state_name,
8165 : : (void *)&cmd_set_xstats_show_state_on_off,
8166 : : NULL,
8167 : : },
8168 : : };
8169 : :
8170 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8171 : : struct cmd_set_xstats_hide_disabled_result {
8172 : : cmdline_fixed_string_t keyword;
8173 : : cmdline_fixed_string_t name;
8174 : : uint8_t on_off;
8175 : : };
8176 : :
8177 : : static void
8178 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8179 : : __rte_unused struct cmdline *cl,
8180 : : __rte_unused void *data)
8181 : : {
8182 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8183 : 0 : set_xstats_hide_disabled(res->on_off);
8184 : 0 : }
8185 : :
8186 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8188 : : keyword, "set");
8189 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8191 : : name, "xstats-hide-disabled");
8192 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8193 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8194 : : on_off);
8195 : :
8196 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8197 : : .f = cmd_set_xstats_hide_disabled_parsed,
8198 : : .data = NULL,
8199 : : .help_str = "set xstats-hide-disabled on|off",
8200 : : .tokens = {
8201 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8202 : : (void *)&cmd_set_xstats_hide_disabled_name,
8203 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8204 : : NULL,
8205 : : },
8206 : : };
8207 : :
8208 : : /* *** enable/disable counter by name *** */
8209 : : struct cmd_operate_set_counter_result {
8210 : : cmdline_fixed_string_t port;
8211 : : portid_t port_id;
8212 : : cmdline_fixed_string_t what;
8213 : : cmdline_multi_string_t counter_name;
8214 : : };
8215 : :
8216 : : static void
8217 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8218 : : __rte_unused struct cmdline *cl,
8219 : : __rte_unused void *data)
8220 : : {
8221 : : struct cmd_operate_set_counter_result *res = parsed_result;
8222 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8223 : :
8224 : 0 : if ((strcmp(res->port, "port") == 0))
8225 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8226 : 0 : }
8227 : :
8228 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8229 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8230 : : port, "port");
8231 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8232 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8233 : : port_id, RTE_UINT16);
8234 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8235 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8236 : : what, "enable#disable");
8237 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8238 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8239 : : counter_name, TOKEN_STRING_MULTI);
8240 : :
8241 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8242 : : .f = cmd_operate_set_counter_parsed,
8243 : : .data = NULL,
8244 : : .help_str = "port (port_id) enable|disable <counter_name>",
8245 : : .tokens = {
8246 : : (void *)&cmd_operate_set_counter_port,
8247 : : (void *)&cmd_operate_set_counter_port_id,
8248 : : (void *)&cmd_operate_set_counter_what,
8249 : : (void *)&cmd_operate_set_counter_name,
8250 : : NULL,
8251 : : },
8252 : : };
8253 : :
8254 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8255 : : struct cmd_set_record_core_cycles_result {
8256 : : cmdline_fixed_string_t keyword;
8257 : : cmdline_fixed_string_t name;
8258 : : cmdline_fixed_string_t on_off;
8259 : : };
8260 : :
8261 : : static void
8262 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8263 : : __rte_unused struct cmdline *cl,
8264 : : __rte_unused void *data)
8265 : : {
8266 : : struct cmd_set_record_core_cycles_result *res;
8267 : : uint16_t on_off = 0;
8268 : :
8269 : : res = parsed_result;
8270 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8271 : 0 : set_record_core_cycles(on_off);
8272 : 0 : }
8273 : :
8274 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8275 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8276 : : keyword, "set");
8277 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8278 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8279 : : name, "record-core-cycles");
8280 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8281 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8282 : : on_off, "on#off");
8283 : :
8284 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8285 : : .f = cmd_set_record_core_cycles_parsed,
8286 : : .data = NULL,
8287 : : .help_str = "set record-core-cycles on|off",
8288 : : .tokens = {
8289 : : (void *)&cmd_set_record_core_cycles_keyword,
8290 : : (void *)&cmd_set_record_core_cycles_name,
8291 : : (void *)&cmd_set_record_core_cycles_on_off,
8292 : : NULL,
8293 : : },
8294 : : };
8295 : :
8296 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8297 : : struct cmd_set_record_burst_stats_result {
8298 : : cmdline_fixed_string_t keyword;
8299 : : cmdline_fixed_string_t name;
8300 : : cmdline_fixed_string_t on_off;
8301 : : };
8302 : :
8303 : : static void
8304 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8305 : : __rte_unused struct cmdline *cl,
8306 : : __rte_unused void *data)
8307 : : {
8308 : : struct cmd_set_record_burst_stats_result *res;
8309 : : uint16_t on_off = 0;
8310 : :
8311 : : res = parsed_result;
8312 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8313 : 0 : set_record_burst_stats(on_off);
8314 : 0 : }
8315 : :
8316 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8317 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8318 : : keyword, "set");
8319 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8320 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8321 : : name, "record-burst-stats");
8322 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8324 : : on_off, "on#off");
8325 : :
8326 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8327 : : .f = cmd_set_record_burst_stats_parsed,
8328 : : .data = NULL,
8329 : : .help_str = "set record-burst-stats on|off",
8330 : : .tokens = {
8331 : : (void *)&cmd_set_record_burst_stats_keyword,
8332 : : (void *)&cmd_set_record_burst_stats_name,
8333 : : (void *)&cmd_set_record_burst_stats_on_off,
8334 : : NULL,
8335 : : },
8336 : : };
8337 : :
8338 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8339 : : struct cmd_set_uc_hash_table {
8340 : : cmdline_fixed_string_t set;
8341 : : cmdline_fixed_string_t port;
8342 : : portid_t port_id;
8343 : : cmdline_fixed_string_t what;
8344 : : struct rte_ether_addr address;
8345 : : cmdline_fixed_string_t mode;
8346 : : };
8347 : :
8348 : : static void
8349 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8350 : : __rte_unused struct cmdline *cl,
8351 : : __rte_unused void *data)
8352 : : {
8353 : : int ret=0;
8354 : : struct cmd_set_uc_hash_table *res = parsed_result;
8355 : :
8356 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8357 : :
8358 : 0 : if (strcmp(res->what, "uta") == 0)
8359 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8360 : : &res->address,(uint8_t)is_on);
8361 : 0 : if (ret < 0)
8362 : 0 : fprintf(stderr,
8363 : : "bad unicast hash table parameter, return code = %d\n",
8364 : : ret);
8365 : :
8366 : 0 : }
8367 : :
8368 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8369 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8370 : : set, "set");
8371 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8372 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8373 : : port, "port");
8374 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8375 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8376 : : port_id, RTE_UINT16);
8377 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8378 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8379 : : what, "uta");
8380 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8381 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8382 : : address);
8383 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8384 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8385 : : mode, "on#off");
8386 : :
8387 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8388 : : .f = cmd_set_uc_hash_parsed,
8389 : : .data = NULL,
8390 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8391 : : .tokens = {
8392 : : (void *)&cmd_set_uc_hash_set,
8393 : : (void *)&cmd_set_uc_hash_port,
8394 : : (void *)&cmd_set_uc_hash_portid,
8395 : : (void *)&cmd_set_uc_hash_what,
8396 : : (void *)&cmd_set_uc_hash_mac,
8397 : : (void *)&cmd_set_uc_hash_mode,
8398 : : NULL,
8399 : : },
8400 : : };
8401 : :
8402 : : struct cmd_set_uc_all_hash_table {
8403 : : cmdline_fixed_string_t set;
8404 : : cmdline_fixed_string_t port;
8405 : : portid_t port_id;
8406 : : cmdline_fixed_string_t what;
8407 : : cmdline_fixed_string_t value;
8408 : : cmdline_fixed_string_t mode;
8409 : : };
8410 : :
8411 : : static void
8412 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8413 : : __rte_unused struct cmdline *cl,
8414 : : __rte_unused void *data)
8415 : : {
8416 : : int ret=0;
8417 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8418 : :
8419 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8420 : :
8421 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8422 : 0 : (strcmp(res->value, "all") == 0))
8423 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8424 : 0 : if (ret < 0)
8425 : 0 : fprintf(stderr,
8426 : : "bad unicast hash table parameter, return code = %d\n",
8427 : : ret);
8428 : 0 : }
8429 : :
8430 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8431 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8432 : : set, "set");
8433 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8434 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8435 : : port, "port");
8436 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8437 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8438 : : port_id, RTE_UINT16);
8439 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8440 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8441 : : what, "uta");
8442 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8443 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8444 : : value,"all");
8445 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8446 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8447 : : mode, "on#off");
8448 : :
8449 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8450 : : .f = cmd_set_uc_all_hash_parsed,
8451 : : .data = NULL,
8452 : : .help_str = "set port <port_id> uta all on|off",
8453 : : .tokens = {
8454 : : (void *)&cmd_set_uc_all_hash_set,
8455 : : (void *)&cmd_set_uc_all_hash_port,
8456 : : (void *)&cmd_set_uc_all_hash_portid,
8457 : : (void *)&cmd_set_uc_all_hash_what,
8458 : : (void *)&cmd_set_uc_all_hash_value,
8459 : : (void *)&cmd_set_uc_all_hash_mode,
8460 : : NULL,
8461 : : },
8462 : : };
8463 : :
8464 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8465 : : struct cmd_set_vf_traffic {
8466 : : cmdline_fixed_string_t set;
8467 : : cmdline_fixed_string_t port;
8468 : : portid_t port_id;
8469 : : cmdline_fixed_string_t vf;
8470 : : uint8_t vf_id;
8471 : : cmdline_fixed_string_t what;
8472 : : cmdline_fixed_string_t mode;
8473 : : };
8474 : :
8475 : : static void
8476 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8477 : : __rte_unused struct cmdline *cl,
8478 : : __rte_unused void *data)
8479 : : {
8480 : : struct cmd_set_vf_traffic *res = parsed_result;
8481 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8482 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8483 : :
8484 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8485 : 0 : }
8486 : :
8487 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8488 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8489 : : set, "set");
8490 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8491 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8492 : : port, "port");
8493 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8494 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8495 : : port_id, RTE_UINT16);
8496 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8497 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8498 : : vf, "vf");
8499 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8500 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8501 : : vf_id, RTE_UINT8);
8502 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8504 : : what, "tx#rx");
8505 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8506 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8507 : : mode, "on#off");
8508 : :
8509 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8510 : : .f = cmd_set_vf_traffic_parsed,
8511 : : .data = NULL,
8512 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8513 : : .tokens = {
8514 : : (void *)&cmd_setvf_traffic_set,
8515 : : (void *)&cmd_setvf_traffic_port,
8516 : : (void *)&cmd_setvf_traffic_portid,
8517 : : (void *)&cmd_setvf_traffic_vf,
8518 : : (void *)&cmd_setvf_traffic_vfid,
8519 : : (void *)&cmd_setvf_traffic_what,
8520 : : (void *)&cmd_setvf_traffic_mode,
8521 : : NULL,
8522 : : },
8523 : : };
8524 : :
8525 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8526 : : struct cmd_set_vf_rxmode {
8527 : : cmdline_fixed_string_t set;
8528 : : cmdline_fixed_string_t port;
8529 : : portid_t port_id;
8530 : : cmdline_fixed_string_t vf;
8531 : : uint8_t vf_id;
8532 : : cmdline_fixed_string_t what;
8533 : : cmdline_fixed_string_t mode;
8534 : : cmdline_fixed_string_t on;
8535 : : };
8536 : :
8537 : : static void
8538 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8539 : : __rte_unused struct cmdline *cl,
8540 : : __rte_unused void *data)
8541 : : {
8542 : : int ret = -ENOTSUP;
8543 : : uint16_t vf_rxmode = 0;
8544 : : struct cmd_set_vf_rxmode *res = parsed_result;
8545 : :
8546 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8547 : 0 : if (!strcmp(res->what,"rxmode")) {
8548 : 0 : if (!strcmp(res->mode, "AUPE"))
8549 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8550 : 0 : else if (!strcmp(res->mode, "ROPE"))
8551 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8552 : 0 : else if (!strcmp(res->mode, "BAM"))
8553 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8554 : 0 : else if (!strncmp(res->mode, "MPE",3))
8555 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8556 : : }
8557 : :
8558 : : RTE_SET_USED(is_on);
8559 : : RTE_SET_USED(vf_rxmode);
8560 : :
8561 : : #ifdef RTE_NET_IXGBE
8562 : : if (ret == -ENOTSUP)
8563 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8564 : : vf_rxmode, (uint8_t)is_on);
8565 : : #endif
8566 : : #ifdef RTE_NET_BNXT
8567 : 0 : if (ret == -ENOTSUP)
8568 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8569 : : vf_rxmode, (uint8_t)is_on);
8570 : : #endif
8571 : 0 : if (ret < 0)
8572 : 0 : fprintf(stderr,
8573 : : "bad VF receive mode parameter, return code = %d\n",
8574 : : ret);
8575 : 0 : }
8576 : :
8577 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8578 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8579 : : set, "set");
8580 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8581 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8582 : : port, "port");
8583 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8584 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8585 : : port_id, RTE_UINT16);
8586 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8587 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8588 : : vf, "vf");
8589 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8590 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8591 : : vf_id, RTE_UINT8);
8592 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8593 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8594 : : what, "rxmode");
8595 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8596 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8597 : : mode, "AUPE#ROPE#BAM#MPE");
8598 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8599 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8600 : : on, "on#off");
8601 : :
8602 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8603 : : .f = cmd_set_vf_rxmode_parsed,
8604 : : .data = NULL,
8605 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8606 : : "AUPE|ROPE|BAM|MPE on|off",
8607 : : .tokens = {
8608 : : (void *)&cmd_set_vf_rxmode_set,
8609 : : (void *)&cmd_set_vf_rxmode_port,
8610 : : (void *)&cmd_set_vf_rxmode_portid,
8611 : : (void *)&cmd_set_vf_rxmode_vf,
8612 : : (void *)&cmd_set_vf_rxmode_vfid,
8613 : : (void *)&cmd_set_vf_rxmode_what,
8614 : : (void *)&cmd_set_vf_rxmode_mode,
8615 : : (void *)&cmd_set_vf_rxmode_on,
8616 : : NULL,
8617 : : },
8618 : : };
8619 : :
8620 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8621 : : struct cmd_vf_mac_addr_result {
8622 : : cmdline_fixed_string_t mac_addr_cmd;
8623 : : cmdline_fixed_string_t what;
8624 : : cmdline_fixed_string_t port;
8625 : : uint16_t port_num;
8626 : : cmdline_fixed_string_t vf;
8627 : : uint8_t vf_num;
8628 : : struct rte_ether_addr address;
8629 : : };
8630 : :
8631 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8632 : : __rte_unused struct cmdline *cl,
8633 : : __rte_unused void *data)
8634 : : {
8635 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8636 : : int ret = -ENOTSUP;
8637 : :
8638 : 0 : if (strcmp(res->what, "add") != 0)
8639 : : return;
8640 : :
8641 : : #ifdef RTE_NET_I40E
8642 : : if (ret == -ENOTSUP)
8643 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8644 : : &res->address);
8645 : : #endif
8646 : : #ifdef RTE_NET_BNXT
8647 : 0 : if (ret == -ENOTSUP)
8648 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8649 : 0 : res->vf_num);
8650 : : #endif
8651 : :
8652 : 0 : if(ret < 0)
8653 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8654 : :
8655 : : }
8656 : :
8657 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8658 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8659 : : mac_addr_cmd,"mac_addr");
8660 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8661 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8662 : : what,"add");
8663 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8664 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8665 : : port,"port");
8666 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8667 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8668 : : port_num, RTE_UINT16);
8669 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8670 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8671 : : vf,"vf");
8672 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8673 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8674 : : vf_num, RTE_UINT8);
8675 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8676 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8677 : : address);
8678 : :
8679 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8680 : : .f = cmd_vf_mac_addr_parsed,
8681 : : .data = (void *)0,
8682 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8683 : : "Add MAC address filtering for a VF on port_id",
8684 : : .tokens = {
8685 : : (void *)&cmd_vf_mac_addr_cmd,
8686 : : (void *)&cmd_vf_mac_addr_what,
8687 : : (void *)&cmd_vf_mac_addr_port,
8688 : : (void *)&cmd_vf_mac_addr_portnum,
8689 : : (void *)&cmd_vf_mac_addr_vf,
8690 : : (void *)&cmd_vf_mac_addr_vfnum,
8691 : : (void *)&cmd_vf_mac_addr_addr,
8692 : : NULL,
8693 : : },
8694 : : };
8695 : :
8696 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8697 : : struct cmd_vf_rx_vlan_filter {
8698 : : cmdline_fixed_string_t rx_vlan;
8699 : : cmdline_fixed_string_t what;
8700 : : uint16_t vlan_id;
8701 : : cmdline_fixed_string_t port;
8702 : : portid_t port_id;
8703 : : cmdline_fixed_string_t vf;
8704 : : uint64_t vf_mask;
8705 : : };
8706 : :
8707 : : static void
8708 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8709 : : __rte_unused struct cmdline *cl,
8710 : : __rte_unused void *data)
8711 : : {
8712 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8713 : : int ret = -ENOTSUP;
8714 : :
8715 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8716 : :
8717 : : #ifdef RTE_NET_IXGBE
8718 : : if (ret == -ENOTSUP)
8719 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8720 : 0 : res->vlan_id, res->vf_mask, is_add);
8721 : : #endif
8722 : : #ifdef RTE_NET_I40E
8723 : 0 : if (ret == -ENOTSUP)
8724 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8725 : 0 : res->vlan_id, res->vf_mask, is_add);
8726 : : #endif
8727 : : #ifdef RTE_NET_BNXT
8728 : 0 : if (ret == -ENOTSUP)
8729 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8730 : 0 : res->vlan_id, res->vf_mask, is_add);
8731 : : #endif
8732 : :
8733 : 0 : switch (ret) {
8734 : : case 0:
8735 : : break;
8736 : 0 : case -EINVAL:
8737 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8738 : 0 : res->vlan_id, res->vf_mask);
8739 : : break;
8740 : 0 : case -ENODEV:
8741 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8742 : : break;
8743 : 0 : case -ENOTSUP:
8744 : 0 : fprintf(stderr, "function not implemented or supported\n");
8745 : : break;
8746 : 0 : default:
8747 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8748 : : }
8749 : 0 : }
8750 : :
8751 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8752 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8753 : : rx_vlan, "rx_vlan");
8754 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8755 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8756 : : what, "add#rm");
8757 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8758 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8759 : : vlan_id, RTE_UINT16);
8760 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8761 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8762 : : port, "port");
8763 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8764 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8765 : : port_id, RTE_UINT16);
8766 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8767 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8768 : : vf, "vf");
8769 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8770 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8771 : : vf_mask, RTE_UINT64);
8772 : :
8773 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8774 : : .f = cmd_vf_rx_vlan_filter_parsed,
8775 : : .data = NULL,
8776 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8777 : : "(vf_mask = hexadecimal VF mask)",
8778 : : .tokens = {
8779 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8780 : : (void *)&cmd_vf_rx_vlan_filter_what,
8781 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8782 : : (void *)&cmd_vf_rx_vlan_filter_port,
8783 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8784 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8785 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8786 : : NULL,
8787 : : },
8788 : : };
8789 : :
8790 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8791 : : struct cmd_queue_rate_limit_result {
8792 : : cmdline_fixed_string_t set;
8793 : : cmdline_fixed_string_t port;
8794 : : uint16_t port_num;
8795 : : cmdline_fixed_string_t queue;
8796 : : uint8_t queue_num;
8797 : : cmdline_fixed_string_t rate;
8798 : : uint32_t rate_num;
8799 : : };
8800 : :
8801 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8802 : : __rte_unused struct cmdline *cl,
8803 : : __rte_unused void *data)
8804 : : {
8805 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8806 : : int ret = 0;
8807 : :
8808 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8809 : 0 : && (strcmp(res->queue, "queue") == 0)
8810 : 0 : && (strcmp(res->rate, "rate") == 0))
8811 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8812 : : res->rate_num);
8813 : 0 : if (ret < 0)
8814 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8815 : : strerror(-ret));
8816 : :
8817 : 0 : }
8818 : :
8819 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8820 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8821 : : set, "set");
8822 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8823 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8824 : : port, "port");
8825 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8826 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8827 : : port_num, RTE_UINT16);
8828 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8829 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8830 : : queue, "queue");
8831 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8832 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8833 : : queue_num, RTE_UINT8);
8834 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8835 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8836 : : rate, "rate");
8837 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8838 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8839 : : rate_num, RTE_UINT32);
8840 : :
8841 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8842 : : .f = cmd_queue_rate_limit_parsed,
8843 : : .data = (void *)0,
8844 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8845 : : "Set rate limit for a queue on port_id",
8846 : : .tokens = {
8847 : : (void *)&cmd_queue_rate_limit_set,
8848 : : (void *)&cmd_queue_rate_limit_port,
8849 : : (void *)&cmd_queue_rate_limit_portnum,
8850 : : (void *)&cmd_queue_rate_limit_queue,
8851 : : (void *)&cmd_queue_rate_limit_queuenum,
8852 : : (void *)&cmd_queue_rate_limit_rate,
8853 : : (void *)&cmd_queue_rate_limit_ratenum,
8854 : : NULL,
8855 : : },
8856 : : };
8857 : :
8858 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8859 : : struct cmd_vf_rate_limit_result {
8860 : : cmdline_fixed_string_t set;
8861 : : cmdline_fixed_string_t port;
8862 : : uint16_t port_num;
8863 : : cmdline_fixed_string_t vf;
8864 : : uint8_t vf_num;
8865 : : cmdline_fixed_string_t rate;
8866 : : uint32_t rate_num;
8867 : : cmdline_fixed_string_t q_msk;
8868 : : uint64_t q_msk_val;
8869 : : };
8870 : :
8871 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8872 : : __rte_unused struct cmdline *cl,
8873 : : __rte_unused void *data)
8874 : : {
8875 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8876 : : int ret = 0;
8877 : :
8878 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8879 : 0 : && (strcmp(res->vf, "vf") == 0)
8880 : 0 : && (strcmp(res->rate, "rate") == 0)
8881 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8882 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8883 : : res->rate_num, res->q_msk_val);
8884 : 0 : if (ret < 0)
8885 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8886 : : strerror(-ret));
8887 : :
8888 : 0 : }
8889 : :
8890 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8891 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8892 : : set, "set");
8893 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8894 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8895 : : port, "port");
8896 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8897 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8898 : : port_num, RTE_UINT16);
8899 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8900 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8901 : : vf, "vf");
8902 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8903 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8904 : : vf_num, RTE_UINT8);
8905 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8906 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8907 : : rate, "rate");
8908 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8909 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8910 : : rate_num, RTE_UINT32);
8911 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8912 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8913 : : q_msk, "queue_mask");
8914 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8915 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8916 : : q_msk_val, RTE_UINT64);
8917 : :
8918 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8919 : : .f = cmd_vf_rate_limit_parsed,
8920 : : .data = (void *)0,
8921 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8922 : : "queue_mask <queue_mask_value>: "
8923 : : "Set rate limit for queues of VF on port_id",
8924 : : .tokens = {
8925 : : (void *)&cmd_vf_rate_limit_set,
8926 : : (void *)&cmd_vf_rate_limit_port,
8927 : : (void *)&cmd_vf_rate_limit_portnum,
8928 : : (void *)&cmd_vf_rate_limit_vf,
8929 : : (void *)&cmd_vf_rate_limit_vfnum,
8930 : : (void *)&cmd_vf_rate_limit_rate,
8931 : : (void *)&cmd_vf_rate_limit_ratenum,
8932 : : (void *)&cmd_vf_rate_limit_q_msk,
8933 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8934 : : NULL,
8935 : : },
8936 : : };
8937 : :
8938 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8939 : : struct cmd_tunnel_udp_config {
8940 : : cmdline_fixed_string_t rx_vxlan_port;
8941 : : cmdline_fixed_string_t what;
8942 : : uint16_t udp_port;
8943 : : portid_t port_id;
8944 : : };
8945 : :
8946 : : static void
8947 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8948 : : __rte_unused struct cmdline *cl,
8949 : : __rte_unused void *data)
8950 : : {
8951 : : struct cmd_tunnel_udp_config *res = parsed_result;
8952 : : struct rte_eth_udp_tunnel tunnel_udp;
8953 : : int ret;
8954 : :
8955 : 0 : tunnel_udp.udp_port = res->udp_port;
8956 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8957 : :
8958 : 0 : if (!strcmp(res->what, "add"))
8959 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8960 : : &tunnel_udp);
8961 : : else
8962 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8963 : : &tunnel_udp);
8964 : :
8965 : 0 : if (ret < 0)
8966 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8967 : : strerror(-ret));
8968 : 0 : }
8969 : :
8970 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8971 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8972 : : rx_vxlan_port, "rx_vxlan_port");
8973 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8974 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8975 : : what, "add#rm");
8976 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8977 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8978 : : udp_port, RTE_UINT16);
8979 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8980 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8981 : : port_id, RTE_UINT16);
8982 : :
8983 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8984 : : .f = cmd_tunnel_udp_config_parsed,
8985 : : .data = (void *)0,
8986 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8987 : : "Add/Remove a tunneling UDP port filter",
8988 : : .tokens = {
8989 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8990 : : (void *)&cmd_tunnel_udp_config_what,
8991 : : (void *)&cmd_tunnel_udp_config_udp_port,
8992 : : (void *)&cmd_tunnel_udp_config_port_id,
8993 : : NULL,
8994 : : },
8995 : : };
8996 : :
8997 : : struct cmd_config_tunnel_udp_port {
8998 : : cmdline_fixed_string_t port;
8999 : : cmdline_fixed_string_t config;
9000 : : portid_t port_id;
9001 : : cmdline_fixed_string_t udp_tunnel_port;
9002 : : cmdline_fixed_string_t action;
9003 : : cmdline_fixed_string_t tunnel_type;
9004 : : uint16_t udp_port;
9005 : : };
9006 : :
9007 : : static void
9008 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9009 : : __rte_unused struct cmdline *cl,
9010 : : __rte_unused void *data)
9011 : : {
9012 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9013 : : struct rte_eth_udp_tunnel tunnel_udp;
9014 : : int ret = 0;
9015 : :
9016 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9017 : 0 : return;
9018 : :
9019 : 0 : tunnel_udp.udp_port = res->udp_port;
9020 : :
9021 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9022 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9023 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9024 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9025 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9026 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9027 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9028 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9029 : : } else {
9030 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9031 : 0 : return;
9032 : : }
9033 : :
9034 : 0 : if (!strcmp(res->action, "add"))
9035 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9036 : : &tunnel_udp);
9037 : : else
9038 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9039 : : &tunnel_udp);
9040 : :
9041 : 0 : if (ret < 0)
9042 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9043 : : strerror(-ret));
9044 : : }
9045 : :
9046 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9047 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9048 : : "port");
9049 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9050 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9051 : : "config");
9052 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9053 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9054 : : RTE_UINT16);
9055 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9056 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9057 : : udp_tunnel_port,
9058 : : "udp_tunnel_port");
9059 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9060 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9061 : : "add#rm");
9062 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9063 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9064 : : "vxlan#geneve#vxlan-gpe#ecpri");
9065 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9066 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9067 : : RTE_UINT16);
9068 : :
9069 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9070 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9071 : : .data = NULL,
9072 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9073 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9074 : : .tokens = {
9075 : : (void *)&cmd_config_tunnel_udp_port_port,
9076 : : (void *)&cmd_config_tunnel_udp_port_config,
9077 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9078 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9079 : : (void *)&cmd_config_tunnel_udp_port_action,
9080 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9081 : : (void *)&cmd_config_tunnel_udp_port_value,
9082 : : NULL,
9083 : : },
9084 : : };
9085 : :
9086 : : /* ******************************************************************************** */
9087 : :
9088 : : struct cmd_dump_result {
9089 : : cmdline_fixed_string_t dump;
9090 : : };
9091 : :
9092 : : static void
9093 : 0 : dump_struct_sizes(void)
9094 : : {
9095 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9096 : : DUMP_SIZE(struct rte_mbuf);
9097 : : DUMP_SIZE(struct rte_mempool);
9098 : : DUMP_SIZE(struct rte_ring);
9099 : : #undef DUMP_SIZE
9100 : 0 : }
9101 : :
9102 : :
9103 : : /* Dump the socket memory statistics on console */
9104 : : static void
9105 : 0 : dump_socket_mem(FILE *f)
9106 : : {
9107 : : struct rte_malloc_socket_stats socket_stats;
9108 : : unsigned int i;
9109 : : size_t total = 0;
9110 : : size_t alloc = 0;
9111 : : size_t free = 0;
9112 : : unsigned int n_alloc = 0;
9113 : : unsigned int n_free = 0;
9114 : : static size_t last_allocs;
9115 : : static size_t last_total;
9116 : :
9117 : :
9118 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9119 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9120 : 0 : !socket_stats.heap_totalsz_bytes)
9121 : 0 : continue;
9122 : 0 : total += socket_stats.heap_totalsz_bytes;
9123 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9124 : 0 : free += socket_stats.heap_freesz_bytes;
9125 : 0 : n_alloc += socket_stats.alloc_count;
9126 : 0 : n_free += socket_stats.free_count;
9127 : 0 : fprintf(f,
9128 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9129 : : i,
9130 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9131 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9132 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9133 : 0 : (double)socket_stats.heap_totalsz_bytes,
9134 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9135 : : socket_stats.alloc_count,
9136 : : socket_stats.free_count);
9137 : : }
9138 : 0 : fprintf(f,
9139 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9140 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9141 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9142 : 0 : (double)free / (1024 * 1024),
9143 : : n_alloc, n_free);
9144 : 0 : if (last_allocs)
9145 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9146 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9147 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9148 : 0 : last_allocs = alloc;
9149 : 0 : last_total = total;
9150 : 0 : }
9151 : :
9152 : 0 : static void cmd_dump_parsed(void *parsed_result,
9153 : : __rte_unused struct cmdline *cl,
9154 : : __rte_unused void *data)
9155 : : {
9156 : : struct cmd_dump_result *res = parsed_result;
9157 : :
9158 : 0 : if (!strcmp(res->dump, "dump_physmem"))
9159 : 0 : rte_dump_physmem_layout(stdout);
9160 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
9161 : 0 : dump_socket_mem(stdout);
9162 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
9163 : 0 : rte_memzone_dump(stdout);
9164 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
9165 : 0 : dump_struct_sizes();
9166 : 0 : else if (!strcmp(res->dump, "dump_ring"))
9167 : 0 : rte_ring_list_dump(stdout);
9168 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
9169 : 0 : rte_mempool_list_dump(stdout);
9170 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
9171 : 0 : rte_devargs_dump(stdout);
9172 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
9173 : 0 : rte_lcore_dump(stdout);
9174 : : #ifndef RTE_EXEC_ENV_WINDOWS
9175 : 0 : else if (!strcmp(res->dump, "dump_trace"))
9176 : 0 : rte_trace_save();
9177 : : #endif
9178 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
9179 : 0 : rte_log_dump(stdout);
9180 : 0 : }
9181 : :
9182 : : static cmdline_parse_token_string_t cmd_dump_dump =
9183 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9184 : : "" /* defined at init */);
9185 : :
9186 : : static void
9187 : : cmd_dump_init(void)
9188 : : {
9189 : 0 : cmd_dump_dump.string_data.str =
9190 : : "dump_physmem#"
9191 : : "dump_memzone#"
9192 : : "dump_socket_mem#"
9193 : : "dump_struct_sizes#"
9194 : : "dump_ring#"
9195 : : "dump_mempool#"
9196 : : "dump_devargs#"
9197 : : "dump_lcores#"
9198 : : #ifndef RTE_EXEC_ENV_WINDOWS
9199 : : "dump_trace#"
9200 : : #endif
9201 : : "dump_log_types";
9202 : : }
9203 : :
9204 : : static cmdline_parse_inst_t cmd_dump = {
9205 : : .f = cmd_dump_parsed, /* function to call */
9206 : : .data = NULL, /* 2nd arg of func */
9207 : : .help_str = "Dump status",
9208 : : .tokens = { /* token list, NULL terminated */
9209 : : (void *)&cmd_dump_dump,
9210 : : NULL,
9211 : : },
9212 : : };
9213 : :
9214 : : /* ******************************************************************************** */
9215 : :
9216 : : struct cmd_dump_one_result {
9217 : : cmdline_fixed_string_t dump;
9218 : : cmdline_fixed_string_t name;
9219 : : };
9220 : :
9221 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9222 : : __rte_unused void *data)
9223 : : {
9224 : : struct cmd_dump_one_result *res = parsed_result;
9225 : :
9226 : 0 : if (!strcmp(res->dump, "dump_ring")) {
9227 : : struct rte_ring *r;
9228 : 0 : r = rte_ring_lookup(res->name);
9229 : 0 : if (r == NULL) {
9230 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9231 : 0 : return;
9232 : : }
9233 : 0 : rte_ring_dump(stdout, r);
9234 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
9235 : : struct rte_mempool *mp;
9236 : 0 : mp = rte_mempool_lookup(res->name);
9237 : 0 : if (mp == NULL) {
9238 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9239 : 0 : return;
9240 : : }
9241 : 0 : rte_mempool_dump(stdout, mp);
9242 : : }
9243 : : }
9244 : :
9245 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
9246 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9247 : : "dump_ring#dump_mempool");
9248 : :
9249 : : static cmdline_parse_token_string_t cmd_dump_one_name =
9250 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9251 : :
9252 : : static cmdline_parse_inst_t cmd_dump_one = {
9253 : : .f = cmd_dump_one_parsed, /* function to call */
9254 : : .data = NULL, /* 2nd arg of func */
9255 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9256 : : .tokens = { /* token list, NULL terminated */
9257 : : (void *)&cmd_dump_one_dump,
9258 : : (void *)&cmd_dump_one_name,
9259 : : NULL,
9260 : : },
9261 : : };
9262 : :
9263 : : /* *** Filters Control *** */
9264 : :
9265 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9266 : : do { \
9267 : : if ((ip_addr).family == AF_INET) \
9268 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9269 : : else { \
9270 : : fprintf(stderr, "invalid parameter.\n"); \
9271 : : return; \
9272 : : } \
9273 : : } while (0)
9274 : :
9275 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9276 : : do { \
9277 : : if ((ip_addr).family == AF_INET6) \
9278 : : ip = ip_addr.addr.ipv6; \
9279 : : else { \
9280 : : fprintf(stderr, "invalid parameter.\n"); \
9281 : : return; \
9282 : : } \
9283 : : } while (0)
9284 : :
9285 : : /* Generic flow interface command. */
9286 : : extern cmdline_parse_inst_t cmd_flow;
9287 : :
9288 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9289 : : struct cmd_mcast_addr_result {
9290 : : cmdline_fixed_string_t mcast_addr_cmd;
9291 : : cmdline_fixed_string_t what;
9292 : : uint16_t port_num;
9293 : : struct rte_ether_addr mc_addr;
9294 : : };
9295 : :
9296 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9297 : : __rte_unused struct cmdline *cl,
9298 : : __rte_unused void *data)
9299 : : {
9300 : : struct cmd_mcast_addr_result *res = parsed_result;
9301 : :
9302 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9303 : 0 : fprintf(stderr,
9304 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9305 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9306 : 0 : return;
9307 : : }
9308 : 0 : if (strcmp(res->what, "add") == 0)
9309 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9310 : : else
9311 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9312 : : }
9313 : :
9314 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9315 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9316 : : mcast_addr_cmd, "mcast_addr");
9317 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9318 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9319 : : "add#remove");
9320 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9321 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9322 : : RTE_UINT16);
9323 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9324 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9325 : :
9326 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9327 : : .f = cmd_mcast_addr_parsed,
9328 : : .data = (void *)0,
9329 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9330 : : "Add/Remove multicast MAC address on port_id",
9331 : : .tokens = {
9332 : : (void *)&cmd_mcast_addr_cmd,
9333 : : (void *)&cmd_mcast_addr_what,
9334 : : (void *)&cmd_mcast_addr_portnum,
9335 : : (void *)&cmd_mcast_addr_addr,
9336 : : NULL,
9337 : : },
9338 : : };
9339 : :
9340 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9341 : : struct cmd_mcast_addr_flush_result {
9342 : : cmdline_fixed_string_t mcast_addr_cmd;
9343 : : cmdline_fixed_string_t what;
9344 : : uint16_t port_num;
9345 : : };
9346 : :
9347 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9348 : : __rte_unused struct cmdline *cl,
9349 : : __rte_unused void *data)
9350 : : {
9351 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9352 : :
9353 : 0 : mcast_addr_flush(res->port_num);
9354 : 0 : }
9355 : :
9356 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9357 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9358 : : mcast_addr_cmd, "mcast_addr");
9359 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9360 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9361 : : "flush");
9362 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9363 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9364 : : RTE_UINT16);
9365 : :
9366 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9367 : : .f = cmd_mcast_addr_flush_parsed,
9368 : : .data = (void *)0,
9369 : : .help_str = "mcast_addr flush <port_id> : "
9370 : : "flush all multicast MAC addresses on port_id",
9371 : : .tokens = {
9372 : : (void *)&cmd_mcast_addr_flush_cmd,
9373 : : (void *)&cmd_mcast_addr_flush_what,
9374 : : (void *)&cmd_mcast_addr_flush_portnum,
9375 : : NULL,
9376 : : },
9377 : : };
9378 : :
9379 : : /* vf vlan anti spoof configuration */
9380 : :
9381 : : /* Common result structure for vf vlan anti spoof */
9382 : : struct cmd_vf_vlan_anti_spoof_result {
9383 : : cmdline_fixed_string_t set;
9384 : : cmdline_fixed_string_t vf;
9385 : : cmdline_fixed_string_t vlan;
9386 : : cmdline_fixed_string_t antispoof;
9387 : : portid_t port_id;
9388 : : uint32_t vf_id;
9389 : : cmdline_fixed_string_t on_off;
9390 : : };
9391 : :
9392 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9393 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9394 : : TOKEN_STRING_INITIALIZER
9395 : : (struct cmd_vf_vlan_anti_spoof_result,
9396 : : set, "set");
9397 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9398 : : TOKEN_STRING_INITIALIZER
9399 : : (struct cmd_vf_vlan_anti_spoof_result,
9400 : : vf, "vf");
9401 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9402 : : TOKEN_STRING_INITIALIZER
9403 : : (struct cmd_vf_vlan_anti_spoof_result,
9404 : : vlan, "vlan");
9405 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9406 : : TOKEN_STRING_INITIALIZER
9407 : : (struct cmd_vf_vlan_anti_spoof_result,
9408 : : antispoof, "antispoof");
9409 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9410 : : TOKEN_NUM_INITIALIZER
9411 : : (struct cmd_vf_vlan_anti_spoof_result,
9412 : : port_id, RTE_UINT16);
9413 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9414 : : TOKEN_NUM_INITIALIZER
9415 : : (struct cmd_vf_vlan_anti_spoof_result,
9416 : : vf_id, RTE_UINT32);
9417 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9418 : : TOKEN_STRING_INITIALIZER
9419 : : (struct cmd_vf_vlan_anti_spoof_result,
9420 : : on_off, "on#off");
9421 : :
9422 : : static void
9423 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9424 : : void *parsed_result,
9425 : : __rte_unused struct cmdline *cl,
9426 : : __rte_unused void *data)
9427 : : {
9428 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9429 : : int ret = -ENOTSUP;
9430 : :
9431 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9432 : :
9433 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9434 : : return;
9435 : :
9436 : : #ifdef RTE_NET_IXGBE
9437 : : if (ret == -ENOTSUP)
9438 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9439 : 0 : res->vf_id, is_on);
9440 : : #endif
9441 : : #ifdef RTE_NET_I40E
9442 : 0 : if (ret == -ENOTSUP)
9443 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9444 : 0 : res->vf_id, is_on);
9445 : : #endif
9446 : : #ifdef RTE_NET_BNXT
9447 : 0 : if (ret == -ENOTSUP)
9448 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9449 : 0 : res->vf_id, is_on);
9450 : : #endif
9451 : :
9452 : 0 : switch (ret) {
9453 : : case 0:
9454 : : break;
9455 : 0 : case -EINVAL:
9456 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9457 : : break;
9458 : 0 : case -ENODEV:
9459 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9460 : : break;
9461 : 0 : case -ENOTSUP:
9462 : 0 : fprintf(stderr, "function not implemented\n");
9463 : : break;
9464 : 0 : default:
9465 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9466 : : }
9467 : : }
9468 : :
9469 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9470 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9471 : : .data = NULL,
9472 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9473 : : .tokens = {
9474 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9475 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9476 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9477 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9478 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9479 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9480 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9481 : : NULL,
9482 : : },
9483 : : };
9484 : :
9485 : : /* vf mac anti spoof configuration */
9486 : :
9487 : : /* Common result structure for vf mac anti spoof */
9488 : : struct cmd_vf_mac_anti_spoof_result {
9489 : : cmdline_fixed_string_t set;
9490 : : cmdline_fixed_string_t vf;
9491 : : cmdline_fixed_string_t mac;
9492 : : cmdline_fixed_string_t antispoof;
9493 : : portid_t port_id;
9494 : : uint32_t vf_id;
9495 : : cmdline_fixed_string_t on_off;
9496 : : };
9497 : :
9498 : : /* Common CLI fields for vf mac anti spoof enable disable */
9499 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9500 : : TOKEN_STRING_INITIALIZER
9501 : : (struct cmd_vf_mac_anti_spoof_result,
9502 : : set, "set");
9503 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9504 : : TOKEN_STRING_INITIALIZER
9505 : : (struct cmd_vf_mac_anti_spoof_result,
9506 : : vf, "vf");
9507 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9508 : : TOKEN_STRING_INITIALIZER
9509 : : (struct cmd_vf_mac_anti_spoof_result,
9510 : : mac, "mac");
9511 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9512 : : TOKEN_STRING_INITIALIZER
9513 : : (struct cmd_vf_mac_anti_spoof_result,
9514 : : antispoof, "antispoof");
9515 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9516 : : TOKEN_NUM_INITIALIZER
9517 : : (struct cmd_vf_mac_anti_spoof_result,
9518 : : port_id, RTE_UINT16);
9519 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9520 : : TOKEN_NUM_INITIALIZER
9521 : : (struct cmd_vf_mac_anti_spoof_result,
9522 : : vf_id, RTE_UINT32);
9523 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9524 : : TOKEN_STRING_INITIALIZER
9525 : : (struct cmd_vf_mac_anti_spoof_result,
9526 : : on_off, "on#off");
9527 : :
9528 : : static void
9529 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9530 : : void *parsed_result,
9531 : : __rte_unused struct cmdline *cl,
9532 : : __rte_unused void *data)
9533 : : {
9534 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9535 : : int ret = -ENOTSUP;
9536 : :
9537 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9538 : :
9539 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9540 : : return;
9541 : :
9542 : : #ifdef RTE_NET_IXGBE
9543 : : if (ret == -ENOTSUP)
9544 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9545 : 0 : res->vf_id, is_on);
9546 : : #endif
9547 : : #ifdef RTE_NET_I40E
9548 : 0 : if (ret == -ENOTSUP)
9549 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9550 : 0 : res->vf_id, is_on);
9551 : : #endif
9552 : : #ifdef RTE_NET_BNXT
9553 : 0 : if (ret == -ENOTSUP)
9554 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9555 : 0 : res->vf_id, is_on);
9556 : : #endif
9557 : :
9558 : 0 : switch (ret) {
9559 : : case 0:
9560 : : break;
9561 : 0 : case -EINVAL:
9562 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9563 : : res->vf_id, is_on);
9564 : : break;
9565 : 0 : case -ENODEV:
9566 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9567 : : break;
9568 : 0 : case -ENOTSUP:
9569 : 0 : fprintf(stderr, "function not implemented\n");
9570 : : break;
9571 : 0 : default:
9572 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9573 : : }
9574 : : }
9575 : :
9576 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9577 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9578 : : .data = NULL,
9579 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9580 : : .tokens = {
9581 : : (void *)&cmd_vf_mac_anti_spoof_set,
9582 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9583 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9584 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9585 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9586 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9587 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9588 : : NULL,
9589 : : },
9590 : : };
9591 : :
9592 : : /* vf vlan strip queue configuration */
9593 : :
9594 : : /* Common result structure for vf mac anti spoof */
9595 : : struct cmd_vf_vlan_stripq_result {
9596 : : cmdline_fixed_string_t set;
9597 : : cmdline_fixed_string_t vf;
9598 : : cmdline_fixed_string_t vlan;
9599 : : cmdline_fixed_string_t stripq;
9600 : : portid_t port_id;
9601 : : uint16_t vf_id;
9602 : : cmdline_fixed_string_t on_off;
9603 : : };
9604 : :
9605 : : /* Common CLI fields for vf vlan strip enable disable */
9606 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9607 : : TOKEN_STRING_INITIALIZER
9608 : : (struct cmd_vf_vlan_stripq_result,
9609 : : set, "set");
9610 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9611 : : TOKEN_STRING_INITIALIZER
9612 : : (struct cmd_vf_vlan_stripq_result,
9613 : : vf, "vf");
9614 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9615 : : TOKEN_STRING_INITIALIZER
9616 : : (struct cmd_vf_vlan_stripq_result,
9617 : : vlan, "vlan");
9618 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9619 : : TOKEN_STRING_INITIALIZER
9620 : : (struct cmd_vf_vlan_stripq_result,
9621 : : stripq, "stripq");
9622 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9623 : : TOKEN_NUM_INITIALIZER
9624 : : (struct cmd_vf_vlan_stripq_result,
9625 : : port_id, RTE_UINT16);
9626 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9627 : : TOKEN_NUM_INITIALIZER
9628 : : (struct cmd_vf_vlan_stripq_result,
9629 : : vf_id, RTE_UINT16);
9630 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9631 : : TOKEN_STRING_INITIALIZER
9632 : : (struct cmd_vf_vlan_stripq_result,
9633 : : on_off, "on#off");
9634 : :
9635 : : static void
9636 : 0 : cmd_set_vf_vlan_stripq_parsed(
9637 : : void *parsed_result,
9638 : : __rte_unused struct cmdline *cl,
9639 : : __rte_unused void *data)
9640 : : {
9641 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9642 : : int ret = -ENOTSUP;
9643 : :
9644 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9645 : :
9646 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9647 : : return;
9648 : :
9649 : : #ifdef RTE_NET_IXGBE
9650 : : if (ret == -ENOTSUP)
9651 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9652 : 0 : res->vf_id, is_on);
9653 : : #endif
9654 : : #ifdef RTE_NET_I40E
9655 : 0 : if (ret == -ENOTSUP)
9656 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9657 : 0 : res->vf_id, is_on);
9658 : : #endif
9659 : : #ifdef RTE_NET_BNXT
9660 : 0 : if (ret == -ENOTSUP)
9661 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9662 : 0 : res->vf_id, is_on);
9663 : : #endif
9664 : :
9665 : 0 : switch (ret) {
9666 : : case 0:
9667 : : break;
9668 : 0 : case -EINVAL:
9669 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9670 : 0 : res->vf_id, is_on);
9671 : : break;
9672 : 0 : case -ENODEV:
9673 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9674 : : break;
9675 : 0 : case -ENOTSUP:
9676 : 0 : fprintf(stderr, "function not implemented\n");
9677 : : break;
9678 : 0 : default:
9679 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9680 : : }
9681 : : }
9682 : :
9683 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9684 : : .f = cmd_set_vf_vlan_stripq_parsed,
9685 : : .data = NULL,
9686 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9687 : : .tokens = {
9688 : : (void *)&cmd_vf_vlan_stripq_set,
9689 : : (void *)&cmd_vf_vlan_stripq_vf,
9690 : : (void *)&cmd_vf_vlan_stripq_vlan,
9691 : : (void *)&cmd_vf_vlan_stripq_stripq,
9692 : : (void *)&cmd_vf_vlan_stripq_port_id,
9693 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9694 : : (void *)&cmd_vf_vlan_stripq_on_off,
9695 : : NULL,
9696 : : },
9697 : : };
9698 : :
9699 : : /* vf vlan insert configuration */
9700 : :
9701 : : /* Common result structure for vf vlan insert */
9702 : : struct cmd_vf_vlan_insert_result {
9703 : : cmdline_fixed_string_t set;
9704 : : cmdline_fixed_string_t vf;
9705 : : cmdline_fixed_string_t vlan;
9706 : : cmdline_fixed_string_t insert;
9707 : : portid_t port_id;
9708 : : uint16_t vf_id;
9709 : : uint16_t vlan_id;
9710 : : };
9711 : :
9712 : : /* Common CLI fields for vf vlan insert enable disable */
9713 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9714 : : TOKEN_STRING_INITIALIZER
9715 : : (struct cmd_vf_vlan_insert_result,
9716 : : set, "set");
9717 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9718 : : TOKEN_STRING_INITIALIZER
9719 : : (struct cmd_vf_vlan_insert_result,
9720 : : vf, "vf");
9721 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9722 : : TOKEN_STRING_INITIALIZER
9723 : : (struct cmd_vf_vlan_insert_result,
9724 : : vlan, "vlan");
9725 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9726 : : TOKEN_STRING_INITIALIZER
9727 : : (struct cmd_vf_vlan_insert_result,
9728 : : insert, "insert");
9729 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9730 : : TOKEN_NUM_INITIALIZER
9731 : : (struct cmd_vf_vlan_insert_result,
9732 : : port_id, RTE_UINT16);
9733 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9734 : : TOKEN_NUM_INITIALIZER
9735 : : (struct cmd_vf_vlan_insert_result,
9736 : : vf_id, RTE_UINT16);
9737 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9738 : : TOKEN_NUM_INITIALIZER
9739 : : (struct cmd_vf_vlan_insert_result,
9740 : : vlan_id, RTE_UINT16);
9741 : :
9742 : : static void
9743 : 0 : cmd_set_vf_vlan_insert_parsed(
9744 : : void *parsed_result,
9745 : : __rte_unused struct cmdline *cl,
9746 : : __rte_unused void *data)
9747 : : {
9748 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9749 : : int ret = -ENOTSUP;
9750 : :
9751 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9752 : : return;
9753 : :
9754 : : #ifdef RTE_NET_IXGBE
9755 : : if (ret == -ENOTSUP)
9756 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9757 : 0 : res->vlan_id);
9758 : : #endif
9759 : : #ifdef RTE_NET_I40E
9760 : 0 : if (ret == -ENOTSUP)
9761 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9762 : 0 : res->vlan_id);
9763 : : #endif
9764 : : #ifdef RTE_NET_BNXT
9765 : 0 : if (ret == -ENOTSUP)
9766 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9767 : 0 : res->vlan_id);
9768 : : #endif
9769 : :
9770 : 0 : switch (ret) {
9771 : : case 0:
9772 : : break;
9773 : 0 : case -EINVAL:
9774 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9775 : 0 : res->vf_id, res->vlan_id);
9776 : : break;
9777 : 0 : case -ENODEV:
9778 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9779 : : break;
9780 : 0 : case -ENOTSUP:
9781 : 0 : fprintf(stderr, "function not implemented\n");
9782 : : break;
9783 : 0 : default:
9784 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9785 : : }
9786 : : }
9787 : :
9788 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9789 : : .f = cmd_set_vf_vlan_insert_parsed,
9790 : : .data = NULL,
9791 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9792 : : .tokens = {
9793 : : (void *)&cmd_vf_vlan_insert_set,
9794 : : (void *)&cmd_vf_vlan_insert_vf,
9795 : : (void *)&cmd_vf_vlan_insert_vlan,
9796 : : (void *)&cmd_vf_vlan_insert_insert,
9797 : : (void *)&cmd_vf_vlan_insert_port_id,
9798 : : (void *)&cmd_vf_vlan_insert_vf_id,
9799 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9800 : : NULL,
9801 : : },
9802 : : };
9803 : :
9804 : : /* tx loopback configuration */
9805 : :
9806 : : /* Common result structure for tx loopback */
9807 : : struct cmd_tx_loopback_result {
9808 : : cmdline_fixed_string_t set;
9809 : : cmdline_fixed_string_t tx;
9810 : : cmdline_fixed_string_t loopback;
9811 : : portid_t port_id;
9812 : : cmdline_fixed_string_t on_off;
9813 : : };
9814 : :
9815 : : /* Common CLI fields for tx loopback enable disable */
9816 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9817 : : TOKEN_STRING_INITIALIZER
9818 : : (struct cmd_tx_loopback_result,
9819 : : set, "set");
9820 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9821 : : TOKEN_STRING_INITIALIZER
9822 : : (struct cmd_tx_loopback_result,
9823 : : tx, "tx");
9824 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9825 : : TOKEN_STRING_INITIALIZER
9826 : : (struct cmd_tx_loopback_result,
9827 : : loopback, "loopback");
9828 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9829 : : TOKEN_NUM_INITIALIZER
9830 : : (struct cmd_tx_loopback_result,
9831 : : port_id, RTE_UINT16);
9832 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9833 : : TOKEN_STRING_INITIALIZER
9834 : : (struct cmd_tx_loopback_result,
9835 : : on_off, "on#off");
9836 : :
9837 : : static void
9838 : 0 : cmd_set_tx_loopback_parsed(
9839 : : void *parsed_result,
9840 : : __rte_unused struct cmdline *cl,
9841 : : __rte_unused void *data)
9842 : : {
9843 : : struct cmd_tx_loopback_result *res = parsed_result;
9844 : : int ret = -ENOTSUP;
9845 : :
9846 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9847 : :
9848 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9849 : : return;
9850 : :
9851 : : #ifdef RTE_NET_IXGBE
9852 : : if (ret == -ENOTSUP)
9853 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9854 : : #endif
9855 : : #ifdef RTE_NET_I40E
9856 : 0 : if (ret == -ENOTSUP)
9857 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9858 : : #endif
9859 : : #ifdef RTE_NET_BNXT
9860 : 0 : if (ret == -ENOTSUP)
9861 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9862 : : #endif
9863 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9864 : 0 : if (ret == -ENOTSUP)
9865 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9866 : : #endif
9867 : :
9868 : 0 : switch (ret) {
9869 : : case 0:
9870 : : break;
9871 : 0 : case -EINVAL:
9872 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9873 : : break;
9874 : 0 : case -ENODEV:
9875 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9876 : : break;
9877 : 0 : case -ENOTSUP:
9878 : 0 : fprintf(stderr, "function not implemented\n");
9879 : : break;
9880 : 0 : default:
9881 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9882 : : }
9883 : : }
9884 : :
9885 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9886 : : .f = cmd_set_tx_loopback_parsed,
9887 : : .data = NULL,
9888 : : .help_str = "set tx loopback <port_id> on|off",
9889 : : .tokens = {
9890 : : (void *)&cmd_tx_loopback_set,
9891 : : (void *)&cmd_tx_loopback_tx,
9892 : : (void *)&cmd_tx_loopback_loopback,
9893 : : (void *)&cmd_tx_loopback_port_id,
9894 : : (void *)&cmd_tx_loopback_on_off,
9895 : : NULL,
9896 : : },
9897 : : };
9898 : :
9899 : : /* all queues drop enable configuration */
9900 : :
9901 : : /* Common result structure for all queues drop enable */
9902 : : struct cmd_all_queues_drop_en_result {
9903 : : cmdline_fixed_string_t set;
9904 : : cmdline_fixed_string_t all;
9905 : : cmdline_fixed_string_t queues;
9906 : : cmdline_fixed_string_t drop;
9907 : : portid_t port_id;
9908 : : cmdline_fixed_string_t on_off;
9909 : : };
9910 : :
9911 : : /* Common CLI fields for tx loopback enable disable */
9912 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9913 : : TOKEN_STRING_INITIALIZER
9914 : : (struct cmd_all_queues_drop_en_result,
9915 : : set, "set");
9916 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9917 : : TOKEN_STRING_INITIALIZER
9918 : : (struct cmd_all_queues_drop_en_result,
9919 : : all, "all");
9920 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9921 : : TOKEN_STRING_INITIALIZER
9922 : : (struct cmd_all_queues_drop_en_result,
9923 : : queues, "queues");
9924 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9925 : : TOKEN_STRING_INITIALIZER
9926 : : (struct cmd_all_queues_drop_en_result,
9927 : : drop, "drop");
9928 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9929 : : TOKEN_NUM_INITIALIZER
9930 : : (struct cmd_all_queues_drop_en_result,
9931 : : port_id, RTE_UINT16);
9932 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9933 : : TOKEN_STRING_INITIALIZER
9934 : : (struct cmd_all_queues_drop_en_result,
9935 : : on_off, "on#off");
9936 : :
9937 : : static void
9938 : 0 : cmd_set_all_queues_drop_en_parsed(
9939 : : void *parsed_result,
9940 : : __rte_unused struct cmdline *cl,
9941 : : __rte_unused void *data)
9942 : : {
9943 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9944 : : int ret = -ENOTSUP;
9945 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9946 : :
9947 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9948 : : return;
9949 : :
9950 : : #ifdef RTE_NET_IXGBE
9951 : : if (ret == -ENOTSUP)
9952 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9953 : : #endif
9954 : : #ifdef RTE_NET_BNXT
9955 : 0 : if (ret == -ENOTSUP)
9956 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9957 : : #endif
9958 : 0 : switch (ret) {
9959 : : case 0:
9960 : : break;
9961 : 0 : case -EINVAL:
9962 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9963 : : break;
9964 : 0 : case -ENODEV:
9965 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9966 : : break;
9967 : 0 : case -ENOTSUP:
9968 : 0 : fprintf(stderr, "function not implemented\n");
9969 : : break;
9970 : 0 : default:
9971 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9972 : : }
9973 : : }
9974 : :
9975 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9976 : : .f = cmd_set_all_queues_drop_en_parsed,
9977 : : .data = NULL,
9978 : : .help_str = "set all queues drop <port_id> on|off",
9979 : : .tokens = {
9980 : : (void *)&cmd_all_queues_drop_en_set,
9981 : : (void *)&cmd_all_queues_drop_en_all,
9982 : : (void *)&cmd_all_queues_drop_en_queues,
9983 : : (void *)&cmd_all_queues_drop_en_drop,
9984 : : (void *)&cmd_all_queues_drop_en_port_id,
9985 : : (void *)&cmd_all_queues_drop_en_on_off,
9986 : : NULL,
9987 : : },
9988 : : };
9989 : :
9990 : : /* vf mac address configuration */
9991 : :
9992 : : /* Common result structure for vf mac address */
9993 : : struct cmd_set_vf_mac_addr_result {
9994 : : cmdline_fixed_string_t set;
9995 : : cmdline_fixed_string_t vf;
9996 : : cmdline_fixed_string_t mac;
9997 : : cmdline_fixed_string_t addr;
9998 : : portid_t port_id;
9999 : : uint16_t vf_id;
10000 : : struct rte_ether_addr mac_addr;
10001 : :
10002 : : };
10003 : :
10004 : : /* Common CLI fields for vf split drop enable disable */
10005 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10006 : : TOKEN_STRING_INITIALIZER
10007 : : (struct cmd_set_vf_mac_addr_result,
10008 : : set, "set");
10009 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10010 : : TOKEN_STRING_INITIALIZER
10011 : : (struct cmd_set_vf_mac_addr_result,
10012 : : vf, "vf");
10013 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10014 : : TOKEN_STRING_INITIALIZER
10015 : : (struct cmd_set_vf_mac_addr_result,
10016 : : mac, "mac");
10017 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10018 : : TOKEN_STRING_INITIALIZER
10019 : : (struct cmd_set_vf_mac_addr_result,
10020 : : addr, "addr");
10021 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10022 : : TOKEN_NUM_INITIALIZER
10023 : : (struct cmd_set_vf_mac_addr_result,
10024 : : port_id, RTE_UINT16);
10025 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10026 : : TOKEN_NUM_INITIALIZER
10027 : : (struct cmd_set_vf_mac_addr_result,
10028 : : vf_id, RTE_UINT16);
10029 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10030 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10031 : : mac_addr);
10032 : :
10033 : : static void
10034 : 0 : cmd_set_vf_mac_addr_parsed(
10035 : : void *parsed_result,
10036 : : __rte_unused struct cmdline *cl,
10037 : : __rte_unused void *data)
10038 : : {
10039 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10040 : : int ret = -ENOTSUP;
10041 : :
10042 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10043 : : return;
10044 : :
10045 : : #ifdef RTE_NET_IXGBE
10046 : : if (ret == -ENOTSUP)
10047 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10048 : : &res->mac_addr);
10049 : : #endif
10050 : : #ifdef RTE_NET_I40E
10051 : 0 : if (ret == -ENOTSUP)
10052 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10053 : : &res->mac_addr);
10054 : : #endif
10055 : : #ifdef RTE_NET_BNXT
10056 : 0 : if (ret == -ENOTSUP)
10057 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10058 : : &res->mac_addr);
10059 : : #endif
10060 : :
10061 : 0 : switch (ret) {
10062 : : case 0:
10063 : : break;
10064 : 0 : case -EINVAL:
10065 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10066 : : break;
10067 : 0 : case -ENODEV:
10068 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10069 : : break;
10070 : 0 : case -ENOTSUP:
10071 : 0 : fprintf(stderr, "function not implemented\n");
10072 : : break;
10073 : 0 : default:
10074 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10075 : : }
10076 : : }
10077 : :
10078 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10079 : : .f = cmd_set_vf_mac_addr_parsed,
10080 : : .data = NULL,
10081 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10082 : : .tokens = {
10083 : : (void *)&cmd_set_vf_mac_addr_set,
10084 : : (void *)&cmd_set_vf_mac_addr_vf,
10085 : : (void *)&cmd_set_vf_mac_addr_mac,
10086 : : (void *)&cmd_set_vf_mac_addr_addr,
10087 : : (void *)&cmd_set_vf_mac_addr_port_id,
10088 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10089 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10090 : : NULL,
10091 : : },
10092 : : };
10093 : :
10094 : : /** Set VXLAN encapsulation details */
10095 : : struct cmd_set_vxlan_result {
10096 : : cmdline_fixed_string_t set;
10097 : : cmdline_fixed_string_t vxlan;
10098 : : cmdline_fixed_string_t pos_token;
10099 : : cmdline_fixed_string_t ip_version;
10100 : : uint32_t vlan_present:1;
10101 : : uint32_t vni;
10102 : : uint16_t udp_src;
10103 : : uint16_t udp_dst;
10104 : : cmdline_ipaddr_t ip_src;
10105 : : cmdline_ipaddr_t ip_dst;
10106 : : uint16_t tci;
10107 : : uint8_t tos;
10108 : : uint8_t ttl;
10109 : : struct rte_ether_addr eth_src;
10110 : : struct rte_ether_addr eth_dst;
10111 : : };
10112 : :
10113 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10115 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10116 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10117 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10118 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10119 : : "vxlan-tos-ttl");
10120 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10121 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10122 : : "vxlan-with-vlan");
10123 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10124 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10125 : : "ip-version");
10126 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10127 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10128 : : "ipv4#ipv6");
10129 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10130 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10131 : : "vni");
10132 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10133 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10134 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10135 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10136 : : "udp-src");
10137 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10138 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10139 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10140 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10141 : : "udp-dst");
10142 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10143 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10144 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10145 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10146 : : "ip-tos");
10147 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10148 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10149 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10150 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10151 : : "ip-ttl");
10152 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10153 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10154 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10155 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10156 : : "ip-src");
10157 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10158 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10159 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10160 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10161 : : "ip-dst");
10162 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10163 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10164 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10165 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10166 : : "vlan-tci");
10167 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10168 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10169 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10170 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10171 : : "eth-src");
10172 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10173 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10174 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10175 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10176 : : "eth-dst");
10177 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10178 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10179 : :
10180 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10181 : : __rte_unused struct cmdline *cl,
10182 : : __rte_unused void *data)
10183 : : {
10184 : : struct cmd_set_vxlan_result *res = parsed_result;
10185 : : union {
10186 : : uint32_t vxlan_id;
10187 : : uint8_t vni[4];
10188 : 0 : } id = {
10189 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10190 : : };
10191 : :
10192 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10193 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10194 : 0 : vxlan_encap_conf.select_vlan = 0;
10195 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10196 : 0 : vxlan_encap_conf.select_vlan = 1;
10197 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10198 : 0 : vxlan_encap_conf.select_vlan = 0;
10199 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10200 : : }
10201 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10202 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10203 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10204 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10205 : : else
10206 : 0 : return;
10207 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10208 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10209 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10210 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10211 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10212 : 0 : if (vxlan_encap_conf.select_ipv4) {
10213 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10214 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10215 : : } else {
10216 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10217 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10218 : : }
10219 : 0 : if (vxlan_encap_conf.select_vlan)
10220 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10221 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10222 : : RTE_ETHER_ADDR_LEN);
10223 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10224 : : RTE_ETHER_ADDR_LEN);
10225 : : }
10226 : :
10227 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10228 : : .f = cmd_set_vxlan_parsed,
10229 : : .data = NULL,
10230 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10231 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10232 : : " eth-src <eth-src> eth-dst <eth-dst>",
10233 : : .tokens = {
10234 : : (void *)&cmd_set_vxlan_set,
10235 : : (void *)&cmd_set_vxlan_vxlan,
10236 : : (void *)&cmd_set_vxlan_ip_version,
10237 : : (void *)&cmd_set_vxlan_ip_version_value,
10238 : : (void *)&cmd_set_vxlan_vni,
10239 : : (void *)&cmd_set_vxlan_vni_value,
10240 : : (void *)&cmd_set_vxlan_udp_src,
10241 : : (void *)&cmd_set_vxlan_udp_src_value,
10242 : : (void *)&cmd_set_vxlan_udp_dst,
10243 : : (void *)&cmd_set_vxlan_udp_dst_value,
10244 : : (void *)&cmd_set_vxlan_ip_src,
10245 : : (void *)&cmd_set_vxlan_ip_src_value,
10246 : : (void *)&cmd_set_vxlan_ip_dst,
10247 : : (void *)&cmd_set_vxlan_ip_dst_value,
10248 : : (void *)&cmd_set_vxlan_eth_src,
10249 : : (void *)&cmd_set_vxlan_eth_src_value,
10250 : : (void *)&cmd_set_vxlan_eth_dst,
10251 : : (void *)&cmd_set_vxlan_eth_dst_value,
10252 : : NULL,
10253 : : },
10254 : : };
10255 : :
10256 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10257 : : .f = cmd_set_vxlan_parsed,
10258 : : .data = NULL,
10259 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10260 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10261 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10262 : : " eth-dst <eth-dst>",
10263 : : .tokens = {
10264 : : (void *)&cmd_set_vxlan_set,
10265 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10266 : : (void *)&cmd_set_vxlan_ip_version,
10267 : : (void *)&cmd_set_vxlan_ip_version_value,
10268 : : (void *)&cmd_set_vxlan_vni,
10269 : : (void *)&cmd_set_vxlan_vni_value,
10270 : : (void *)&cmd_set_vxlan_udp_src,
10271 : : (void *)&cmd_set_vxlan_udp_src_value,
10272 : : (void *)&cmd_set_vxlan_udp_dst,
10273 : : (void *)&cmd_set_vxlan_udp_dst_value,
10274 : : (void *)&cmd_set_vxlan_ip_tos,
10275 : : (void *)&cmd_set_vxlan_ip_tos_value,
10276 : : (void *)&cmd_set_vxlan_ip_ttl,
10277 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10278 : : (void *)&cmd_set_vxlan_ip_src,
10279 : : (void *)&cmd_set_vxlan_ip_src_value,
10280 : : (void *)&cmd_set_vxlan_ip_dst,
10281 : : (void *)&cmd_set_vxlan_ip_dst_value,
10282 : : (void *)&cmd_set_vxlan_eth_src,
10283 : : (void *)&cmd_set_vxlan_eth_src_value,
10284 : : (void *)&cmd_set_vxlan_eth_dst,
10285 : : (void *)&cmd_set_vxlan_eth_dst_value,
10286 : : NULL,
10287 : : },
10288 : : };
10289 : :
10290 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10291 : : .f = cmd_set_vxlan_parsed,
10292 : : .data = NULL,
10293 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10294 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10295 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10296 : : " <eth-dst>",
10297 : : .tokens = {
10298 : : (void *)&cmd_set_vxlan_set,
10299 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10300 : : (void *)&cmd_set_vxlan_ip_version,
10301 : : (void *)&cmd_set_vxlan_ip_version_value,
10302 : : (void *)&cmd_set_vxlan_vni,
10303 : : (void *)&cmd_set_vxlan_vni_value,
10304 : : (void *)&cmd_set_vxlan_udp_src,
10305 : : (void *)&cmd_set_vxlan_udp_src_value,
10306 : : (void *)&cmd_set_vxlan_udp_dst,
10307 : : (void *)&cmd_set_vxlan_udp_dst_value,
10308 : : (void *)&cmd_set_vxlan_ip_src,
10309 : : (void *)&cmd_set_vxlan_ip_src_value,
10310 : : (void *)&cmd_set_vxlan_ip_dst,
10311 : : (void *)&cmd_set_vxlan_ip_dst_value,
10312 : : (void *)&cmd_set_vxlan_vlan,
10313 : : (void *)&cmd_set_vxlan_vlan_value,
10314 : : (void *)&cmd_set_vxlan_eth_src,
10315 : : (void *)&cmd_set_vxlan_eth_src_value,
10316 : : (void *)&cmd_set_vxlan_eth_dst,
10317 : : (void *)&cmd_set_vxlan_eth_dst_value,
10318 : : NULL,
10319 : : },
10320 : : };
10321 : :
10322 : : /** Set NVGRE encapsulation details */
10323 : : struct cmd_set_nvgre_result {
10324 : : cmdline_fixed_string_t set;
10325 : : cmdline_fixed_string_t nvgre;
10326 : : cmdline_fixed_string_t pos_token;
10327 : : cmdline_fixed_string_t ip_version;
10328 : : uint32_t tni;
10329 : : cmdline_ipaddr_t ip_src;
10330 : : cmdline_ipaddr_t ip_dst;
10331 : : uint16_t tci;
10332 : : struct rte_ether_addr eth_src;
10333 : : struct rte_ether_addr eth_dst;
10334 : : };
10335 : :
10336 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10337 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10338 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10339 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10340 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10341 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10342 : : "nvgre-with-vlan");
10343 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10344 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10345 : : "ip-version");
10346 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10347 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10348 : : "ipv4#ipv6");
10349 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10350 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10351 : : "tni");
10352 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10353 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10354 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10355 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10356 : : "ip-src");
10357 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10358 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10359 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10360 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10361 : : "ip-dst");
10362 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10363 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10364 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10366 : : "vlan-tci");
10367 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10368 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10369 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10370 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10371 : : "eth-src");
10372 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10373 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10374 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10376 : : "eth-dst");
10377 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10378 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10379 : :
10380 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10381 : : __rte_unused struct cmdline *cl,
10382 : : __rte_unused void *data)
10383 : : {
10384 : : struct cmd_set_nvgre_result *res = parsed_result;
10385 : : union {
10386 : : uint32_t nvgre_tni;
10387 : : uint8_t tni[4];
10388 : 0 : } id = {
10389 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10390 : : };
10391 : :
10392 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10393 : 0 : nvgre_encap_conf.select_vlan = 0;
10394 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10395 : 0 : nvgre_encap_conf.select_vlan = 1;
10396 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10397 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10398 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10399 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10400 : : else
10401 : 0 : return;
10402 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10403 : 0 : if (nvgre_encap_conf.select_ipv4) {
10404 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10405 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10406 : : } else {
10407 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10408 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10409 : : }
10410 : 0 : if (nvgre_encap_conf.select_vlan)
10411 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10412 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10413 : : RTE_ETHER_ADDR_LEN);
10414 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10415 : : RTE_ETHER_ADDR_LEN);
10416 : : }
10417 : :
10418 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10419 : : .f = cmd_set_nvgre_parsed,
10420 : : .data = NULL,
10421 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10422 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10423 : : " eth-dst <eth-dst>",
10424 : : .tokens = {
10425 : : (void *)&cmd_set_nvgre_set,
10426 : : (void *)&cmd_set_nvgre_nvgre,
10427 : : (void *)&cmd_set_nvgre_ip_version,
10428 : : (void *)&cmd_set_nvgre_ip_version_value,
10429 : : (void *)&cmd_set_nvgre_tni,
10430 : : (void *)&cmd_set_nvgre_tni_value,
10431 : : (void *)&cmd_set_nvgre_ip_src,
10432 : : (void *)&cmd_set_nvgre_ip_src_value,
10433 : : (void *)&cmd_set_nvgre_ip_dst,
10434 : : (void *)&cmd_set_nvgre_ip_dst_value,
10435 : : (void *)&cmd_set_nvgre_eth_src,
10436 : : (void *)&cmd_set_nvgre_eth_src_value,
10437 : : (void *)&cmd_set_nvgre_eth_dst,
10438 : : (void *)&cmd_set_nvgre_eth_dst_value,
10439 : : NULL,
10440 : : },
10441 : : };
10442 : :
10443 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10444 : : .f = cmd_set_nvgre_parsed,
10445 : : .data = NULL,
10446 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10447 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10448 : : " eth-src <eth-src> eth-dst <eth-dst>",
10449 : : .tokens = {
10450 : : (void *)&cmd_set_nvgre_set,
10451 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10452 : : (void *)&cmd_set_nvgre_ip_version,
10453 : : (void *)&cmd_set_nvgre_ip_version_value,
10454 : : (void *)&cmd_set_nvgre_tni,
10455 : : (void *)&cmd_set_nvgre_tni_value,
10456 : : (void *)&cmd_set_nvgre_ip_src,
10457 : : (void *)&cmd_set_nvgre_ip_src_value,
10458 : : (void *)&cmd_set_nvgre_ip_dst,
10459 : : (void *)&cmd_set_nvgre_ip_dst_value,
10460 : : (void *)&cmd_set_nvgre_vlan,
10461 : : (void *)&cmd_set_nvgre_vlan_value,
10462 : : (void *)&cmd_set_nvgre_eth_src,
10463 : : (void *)&cmd_set_nvgre_eth_src_value,
10464 : : (void *)&cmd_set_nvgre_eth_dst,
10465 : : (void *)&cmd_set_nvgre_eth_dst_value,
10466 : : NULL,
10467 : : },
10468 : : };
10469 : :
10470 : : /** Set L2 encapsulation details */
10471 : : struct cmd_set_l2_encap_result {
10472 : : cmdline_fixed_string_t set;
10473 : : cmdline_fixed_string_t l2_encap;
10474 : : cmdline_fixed_string_t pos_token;
10475 : : cmdline_fixed_string_t ip_version;
10476 : : uint32_t vlan_present:1;
10477 : : uint16_t tci;
10478 : : struct rte_ether_addr eth_src;
10479 : : struct rte_ether_addr eth_dst;
10480 : : };
10481 : :
10482 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10483 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10484 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10486 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10487 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10488 : : "l2_encap-with-vlan");
10489 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10491 : : "ip-version");
10492 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10493 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10494 : : "ipv4#ipv6");
10495 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10497 : : "vlan-tci");
10498 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10499 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10500 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10502 : : "eth-src");
10503 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10504 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10505 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10506 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10507 : : "eth-dst");
10508 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10509 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10510 : :
10511 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10512 : : __rte_unused struct cmdline *cl,
10513 : : __rte_unused void *data)
10514 : : {
10515 : : struct cmd_set_l2_encap_result *res = parsed_result;
10516 : :
10517 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10518 : 0 : l2_encap_conf.select_vlan = 0;
10519 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10520 : 0 : l2_encap_conf.select_vlan = 1;
10521 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10522 : 0 : l2_encap_conf.select_ipv4 = 1;
10523 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10524 : 0 : l2_encap_conf.select_ipv4 = 0;
10525 : : else
10526 : : return;
10527 : 0 : if (l2_encap_conf.select_vlan)
10528 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10529 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10530 : : RTE_ETHER_ADDR_LEN);
10531 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10532 : : RTE_ETHER_ADDR_LEN);
10533 : : }
10534 : :
10535 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10536 : : .f = cmd_set_l2_encap_parsed,
10537 : : .data = NULL,
10538 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10539 : : " eth-src <eth-src> eth-dst <eth-dst>",
10540 : : .tokens = {
10541 : : (void *)&cmd_set_l2_encap_set,
10542 : : (void *)&cmd_set_l2_encap_l2_encap,
10543 : : (void *)&cmd_set_l2_encap_ip_version,
10544 : : (void *)&cmd_set_l2_encap_ip_version_value,
10545 : : (void *)&cmd_set_l2_encap_eth_src,
10546 : : (void *)&cmd_set_l2_encap_eth_src_value,
10547 : : (void *)&cmd_set_l2_encap_eth_dst,
10548 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10549 : : NULL,
10550 : : },
10551 : : };
10552 : :
10553 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10554 : : .f = cmd_set_l2_encap_parsed,
10555 : : .data = NULL,
10556 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10557 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10558 : : .tokens = {
10559 : : (void *)&cmd_set_l2_encap_set,
10560 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10561 : : (void *)&cmd_set_l2_encap_ip_version,
10562 : : (void *)&cmd_set_l2_encap_ip_version_value,
10563 : : (void *)&cmd_set_l2_encap_vlan,
10564 : : (void *)&cmd_set_l2_encap_vlan_value,
10565 : : (void *)&cmd_set_l2_encap_eth_src,
10566 : : (void *)&cmd_set_l2_encap_eth_src_value,
10567 : : (void *)&cmd_set_l2_encap_eth_dst,
10568 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10569 : : NULL,
10570 : : },
10571 : : };
10572 : :
10573 : : /** Set L2 decapsulation details */
10574 : : struct cmd_set_l2_decap_result {
10575 : : cmdline_fixed_string_t set;
10576 : : cmdline_fixed_string_t l2_decap;
10577 : : cmdline_fixed_string_t pos_token;
10578 : : uint32_t vlan_present:1;
10579 : : };
10580 : :
10581 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10582 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10583 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10584 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10585 : : "l2_decap");
10586 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10587 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10588 : : "l2_decap-with-vlan");
10589 : :
10590 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10591 : : __rte_unused struct cmdline *cl,
10592 : : __rte_unused void *data)
10593 : : {
10594 : : struct cmd_set_l2_decap_result *res = parsed_result;
10595 : :
10596 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10597 : 0 : l2_decap_conf.select_vlan = 0;
10598 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10599 : 0 : l2_decap_conf.select_vlan = 1;
10600 : 0 : }
10601 : :
10602 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10603 : : .f = cmd_set_l2_decap_parsed,
10604 : : .data = NULL,
10605 : : .help_str = "set l2_decap",
10606 : : .tokens = {
10607 : : (void *)&cmd_set_l2_decap_set,
10608 : : (void *)&cmd_set_l2_decap_l2_decap,
10609 : : NULL,
10610 : : },
10611 : : };
10612 : :
10613 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10614 : : .f = cmd_set_l2_decap_parsed,
10615 : : .data = NULL,
10616 : : .help_str = "set l2_decap-with-vlan",
10617 : : .tokens = {
10618 : : (void *)&cmd_set_l2_decap_set,
10619 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10620 : : NULL,
10621 : : },
10622 : : };
10623 : :
10624 : : /** Set MPLSoGRE encapsulation details */
10625 : : struct cmd_set_mplsogre_encap_result {
10626 : : cmdline_fixed_string_t set;
10627 : : cmdline_fixed_string_t mplsogre;
10628 : : cmdline_fixed_string_t pos_token;
10629 : : cmdline_fixed_string_t ip_version;
10630 : : uint32_t vlan_present:1;
10631 : : uint32_t label;
10632 : : cmdline_ipaddr_t ip_src;
10633 : : cmdline_ipaddr_t ip_dst;
10634 : : uint16_t tci;
10635 : : struct rte_ether_addr eth_src;
10636 : : struct rte_ether_addr eth_dst;
10637 : : };
10638 : :
10639 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10640 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10641 : : "set");
10642 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10644 : : "mplsogre_encap");
10645 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10646 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10647 : : mplsogre, "mplsogre_encap-with-vlan");
10648 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10649 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10650 : : pos_token, "ip-version");
10651 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10652 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10653 : : ip_version, "ipv4#ipv6");
10654 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10655 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10656 : : pos_token, "label");
10657 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10658 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10659 : : RTE_UINT32);
10660 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10661 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10662 : : pos_token, "ip-src");
10663 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10664 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10665 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10666 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10667 : : pos_token, "ip-dst");
10668 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10669 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10670 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10671 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10672 : : pos_token, "vlan-tci");
10673 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10674 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10675 : : RTE_UINT16);
10676 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10677 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10678 : : pos_token, "eth-src");
10679 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10680 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10681 : : eth_src);
10682 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10683 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10684 : : pos_token, "eth-dst");
10685 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10686 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10687 : : eth_dst);
10688 : :
10689 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10690 : : __rte_unused struct cmdline *cl,
10691 : : __rte_unused void *data)
10692 : : {
10693 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10694 : : union {
10695 : : uint32_t mplsogre_label;
10696 : : uint8_t label[4];
10697 : 0 : } id = {
10698 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10699 : : };
10700 : :
10701 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10702 : 0 : mplsogre_encap_conf.select_vlan = 0;
10703 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10704 : 0 : mplsogre_encap_conf.select_vlan = 1;
10705 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10706 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10707 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10708 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10709 : : else
10710 : 0 : return;
10711 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10712 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10713 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10714 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10715 : : } else {
10716 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10717 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10718 : : }
10719 : 0 : if (mplsogre_encap_conf.select_vlan)
10720 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10721 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10722 : : RTE_ETHER_ADDR_LEN);
10723 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10724 : : RTE_ETHER_ADDR_LEN);
10725 : : }
10726 : :
10727 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10728 : : .f = cmd_set_mplsogre_encap_parsed,
10729 : : .data = NULL,
10730 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10731 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10732 : : " eth-dst <eth-dst>",
10733 : : .tokens = {
10734 : : (void *)&cmd_set_mplsogre_encap_set,
10735 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10736 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10737 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10738 : : (void *)&cmd_set_mplsogre_encap_label,
10739 : : (void *)&cmd_set_mplsogre_encap_label_value,
10740 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10741 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10742 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10743 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10744 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10745 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10746 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10747 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10748 : : NULL,
10749 : : },
10750 : : };
10751 : :
10752 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10753 : : .f = cmd_set_mplsogre_encap_parsed,
10754 : : .data = NULL,
10755 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10756 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10757 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10758 : : .tokens = {
10759 : : (void *)&cmd_set_mplsogre_encap_set,
10760 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10761 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10762 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10763 : : (void *)&cmd_set_mplsogre_encap_label,
10764 : : (void *)&cmd_set_mplsogre_encap_label_value,
10765 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10766 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10767 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10768 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10769 : : (void *)&cmd_set_mplsogre_encap_vlan,
10770 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10771 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10772 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10773 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10774 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10775 : : NULL,
10776 : : },
10777 : : };
10778 : :
10779 : : /** Set MPLSoGRE decapsulation details */
10780 : : struct cmd_set_mplsogre_decap_result {
10781 : : cmdline_fixed_string_t set;
10782 : : cmdline_fixed_string_t mplsogre;
10783 : : cmdline_fixed_string_t pos_token;
10784 : : cmdline_fixed_string_t ip_version;
10785 : : uint32_t vlan_present:1;
10786 : : };
10787 : :
10788 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10789 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10790 : : "set");
10791 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10792 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10793 : : "mplsogre_decap");
10794 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10795 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10796 : : mplsogre, "mplsogre_decap-with-vlan");
10797 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10798 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10799 : : pos_token, "ip-version");
10800 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10801 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10802 : : ip_version, "ipv4#ipv6");
10803 : :
10804 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10805 : : __rte_unused struct cmdline *cl,
10806 : : __rte_unused void *data)
10807 : : {
10808 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10809 : :
10810 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10811 : 0 : mplsogre_decap_conf.select_vlan = 0;
10812 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10813 : 0 : mplsogre_decap_conf.select_vlan = 1;
10814 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10815 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10816 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10817 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10818 : 0 : }
10819 : :
10820 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10821 : : .f = cmd_set_mplsogre_decap_parsed,
10822 : : .data = NULL,
10823 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10824 : : .tokens = {
10825 : : (void *)&cmd_set_mplsogre_decap_set,
10826 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10827 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10828 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10829 : : NULL,
10830 : : },
10831 : : };
10832 : :
10833 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10834 : : .f = cmd_set_mplsogre_decap_parsed,
10835 : : .data = NULL,
10836 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10837 : : .tokens = {
10838 : : (void *)&cmd_set_mplsogre_decap_set,
10839 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10840 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10841 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10842 : : NULL,
10843 : : },
10844 : : };
10845 : :
10846 : : /** Set MPLSoUDP encapsulation details */
10847 : : struct cmd_set_mplsoudp_encap_result {
10848 : : cmdline_fixed_string_t set;
10849 : : cmdline_fixed_string_t mplsoudp;
10850 : : cmdline_fixed_string_t pos_token;
10851 : : cmdline_fixed_string_t ip_version;
10852 : : uint32_t vlan_present:1;
10853 : : uint32_t label;
10854 : : uint16_t udp_src;
10855 : : uint16_t udp_dst;
10856 : : cmdline_ipaddr_t ip_src;
10857 : : cmdline_ipaddr_t ip_dst;
10858 : : uint16_t tci;
10859 : : struct rte_ether_addr eth_src;
10860 : : struct rte_ether_addr eth_dst;
10861 : : };
10862 : :
10863 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10864 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10865 : : "set");
10866 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10867 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10868 : : "mplsoudp_encap");
10869 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10870 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10871 : : mplsoudp, "mplsoudp_encap-with-vlan");
10872 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10873 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10874 : : pos_token, "ip-version");
10875 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10876 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10877 : : ip_version, "ipv4#ipv6");
10878 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10879 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10880 : : pos_token, "label");
10881 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10882 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10883 : : RTE_UINT32);
10884 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10885 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10886 : : pos_token, "udp-src");
10887 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10888 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10889 : : RTE_UINT16);
10890 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10891 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10892 : : pos_token, "udp-dst");
10893 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10894 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10895 : : RTE_UINT16);
10896 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10897 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10898 : : pos_token, "ip-src");
10899 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10900 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10901 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10902 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10903 : : pos_token, "ip-dst");
10904 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10905 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10906 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10907 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10908 : : pos_token, "vlan-tci");
10909 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10910 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10911 : : RTE_UINT16);
10912 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10913 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10914 : : pos_token, "eth-src");
10915 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10916 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10917 : : eth_src);
10918 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10919 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10920 : : pos_token, "eth-dst");
10921 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10922 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10923 : : eth_dst);
10924 : :
10925 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10926 : : __rte_unused struct cmdline *cl,
10927 : : __rte_unused void *data)
10928 : : {
10929 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10930 : : union {
10931 : : uint32_t mplsoudp_label;
10932 : : uint8_t label[4];
10933 : 0 : } id = {
10934 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10935 : : };
10936 : :
10937 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10938 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10939 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10940 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10941 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10942 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10943 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10944 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10945 : : else
10946 : 0 : return;
10947 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10948 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10949 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10950 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10951 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10952 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10953 : : } else {
10954 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10955 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10956 : : }
10957 : 0 : if (mplsoudp_encap_conf.select_vlan)
10958 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10959 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10960 : : RTE_ETHER_ADDR_LEN);
10961 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10962 : : RTE_ETHER_ADDR_LEN);
10963 : : }
10964 : :
10965 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10966 : : .f = cmd_set_mplsoudp_encap_parsed,
10967 : : .data = NULL,
10968 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10969 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10970 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10971 : : .tokens = {
10972 : : (void *)&cmd_set_mplsoudp_encap_set,
10973 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10974 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10975 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10976 : : (void *)&cmd_set_mplsoudp_encap_label,
10977 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10978 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10979 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10980 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10981 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10982 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10983 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10984 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10985 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10986 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10987 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10988 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10989 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10990 : : NULL,
10991 : : },
10992 : : };
10993 : :
10994 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10995 : : .f = cmd_set_mplsoudp_encap_parsed,
10996 : : .data = NULL,
10997 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10998 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10999 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11000 : : " eth-src <eth-src> eth-dst <eth-dst>",
11001 : : .tokens = {
11002 : : (void *)&cmd_set_mplsoudp_encap_set,
11003 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11004 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11005 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11006 : : (void *)&cmd_set_mplsoudp_encap_label,
11007 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11008 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11009 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11010 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11011 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11012 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11013 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11014 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11015 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11016 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11017 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11018 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11019 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11020 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11021 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11022 : : NULL,
11023 : : },
11024 : : };
11025 : :
11026 : : /** Set MPLSoUDP decapsulation details */
11027 : : struct cmd_set_mplsoudp_decap_result {
11028 : : cmdline_fixed_string_t set;
11029 : : cmdline_fixed_string_t mplsoudp;
11030 : : cmdline_fixed_string_t pos_token;
11031 : : cmdline_fixed_string_t ip_version;
11032 : : uint32_t vlan_present:1;
11033 : : };
11034 : :
11035 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11036 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11037 : : "set");
11038 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11039 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11040 : : "mplsoudp_decap");
11041 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11042 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11043 : : mplsoudp, "mplsoudp_decap-with-vlan");
11044 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11045 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11046 : : pos_token, "ip-version");
11047 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11048 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11049 : : ip_version, "ipv4#ipv6");
11050 : :
11051 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11052 : : __rte_unused struct cmdline *cl,
11053 : : __rte_unused void *data)
11054 : : {
11055 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11056 : :
11057 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11058 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11059 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11060 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11061 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11062 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11063 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11064 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11065 : 0 : }
11066 : :
11067 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11068 : : .f = cmd_set_mplsoudp_decap_parsed,
11069 : : .data = NULL,
11070 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11071 : : .tokens = {
11072 : : (void *)&cmd_set_mplsoudp_decap_set,
11073 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11074 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11075 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11076 : : NULL,
11077 : : },
11078 : : };
11079 : :
11080 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11081 : : .f = cmd_set_mplsoudp_decap_parsed,
11082 : : .data = NULL,
11083 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11084 : : .tokens = {
11085 : : (void *)&cmd_set_mplsoudp_decap_set,
11086 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11087 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11088 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11089 : : NULL,
11090 : : },
11091 : : };
11092 : :
11093 : : /** Set connection tracking object common details */
11094 : : struct cmd_set_conntrack_common_result {
11095 : : cmdline_fixed_string_t set;
11096 : : cmdline_fixed_string_t conntrack;
11097 : : cmdline_fixed_string_t common;
11098 : : cmdline_fixed_string_t peer;
11099 : : cmdline_fixed_string_t is_orig;
11100 : : cmdline_fixed_string_t enable;
11101 : : cmdline_fixed_string_t live;
11102 : : cmdline_fixed_string_t sack;
11103 : : cmdline_fixed_string_t cack;
11104 : : cmdline_fixed_string_t last_dir;
11105 : : cmdline_fixed_string_t liberal;
11106 : : cmdline_fixed_string_t state;
11107 : : cmdline_fixed_string_t max_ack_win;
11108 : : cmdline_fixed_string_t retrans;
11109 : : cmdline_fixed_string_t last_win;
11110 : : cmdline_fixed_string_t last_seq;
11111 : : cmdline_fixed_string_t last_ack;
11112 : : cmdline_fixed_string_t last_end;
11113 : : cmdline_fixed_string_t last_index;
11114 : : uint8_t stat;
11115 : : uint8_t factor;
11116 : : uint16_t peer_port;
11117 : : uint32_t is_original;
11118 : : uint32_t en;
11119 : : uint32_t is_live;
11120 : : uint32_t s_ack;
11121 : : uint32_t c_ack;
11122 : : uint32_t ld;
11123 : : uint32_t lb;
11124 : : uint8_t re_num;
11125 : : uint8_t li;
11126 : : uint16_t lw;
11127 : : uint32_t ls;
11128 : : uint32_t la;
11129 : : uint32_t le;
11130 : : };
11131 : :
11132 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11133 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11134 : : set, "set");
11135 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11136 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11137 : : conntrack, "conntrack");
11138 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11139 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11140 : : common, "com");
11141 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11142 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11143 : : peer, "peer");
11144 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11145 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11146 : : peer_port, RTE_UINT16);
11147 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11148 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11149 : : is_orig, "is_orig");
11150 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11151 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11152 : : is_original, RTE_UINT32);
11153 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11154 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11155 : : enable, "enable");
11156 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11157 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11158 : : en, RTE_UINT32);
11159 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11160 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11161 : : live, "live");
11162 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11163 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11164 : : is_live, RTE_UINT32);
11165 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11166 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11167 : : sack, "sack");
11168 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11169 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11170 : : s_ack, RTE_UINT32);
11171 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11172 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11173 : : cack, "cack");
11174 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11175 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11176 : : c_ack, RTE_UINT32);
11177 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11178 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11179 : : last_dir, "last_dir");
11180 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11181 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11182 : : ld, RTE_UINT32);
11183 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11185 : : liberal, "liberal");
11186 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11187 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11188 : : lb, RTE_UINT32);
11189 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11191 : : state, "state");
11192 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11193 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11194 : : stat, RTE_UINT8);
11195 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11196 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11197 : : max_ack_win, "max_ack_win");
11198 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11199 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11200 : : factor, RTE_UINT8);
11201 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11202 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11203 : : retrans, "r_lim");
11204 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11205 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11206 : : re_num, RTE_UINT8);
11207 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11208 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11209 : : last_win, "last_win");
11210 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11211 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11212 : : lw, RTE_UINT16);
11213 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11214 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11215 : : last_seq, "last_seq");
11216 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11217 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11218 : : ls, RTE_UINT32);
11219 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11221 : : last_ack, "last_ack");
11222 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11223 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11224 : : la, RTE_UINT32);
11225 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11227 : : last_end, "last_end");
11228 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11229 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11230 : : le, RTE_UINT32);
11231 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11233 : : last_index, "last_index");
11234 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11235 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11236 : : li, RTE_UINT8);
11237 : :
11238 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11239 : : __rte_unused struct cmdline *cl,
11240 : : __rte_unused void *data)
11241 : : {
11242 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11243 : :
11244 : : /* No need to swap to big endian. */
11245 : 0 : conntrack_context.peer_port = res->peer_port;
11246 : 0 : conntrack_context.is_original_dir = res->is_original;
11247 : 0 : conntrack_context.enable = res->en;
11248 : 0 : conntrack_context.live_connection = res->is_live;
11249 : 0 : conntrack_context.selective_ack = res->s_ack;
11250 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11251 : 0 : conntrack_context.last_direction = res->ld;
11252 : 0 : conntrack_context.liberal_mode = res->lb;
11253 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11254 : 0 : conntrack_context.max_ack_window = res->factor;
11255 : 0 : conntrack_context.retransmission_limit = res->re_num;
11256 : 0 : conntrack_context.last_window = res->lw;
11257 : 0 : conntrack_context.last_index =
11258 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11259 : 0 : conntrack_context.last_seq = res->ls;
11260 : 0 : conntrack_context.last_ack = res->la;
11261 : 0 : conntrack_context.last_end = res->le;
11262 : 0 : }
11263 : :
11264 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11265 : : .f = cmd_set_conntrack_common_parsed,
11266 : : .data = NULL,
11267 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11268 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11269 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11270 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11271 : : " last_index <flag>",
11272 : : .tokens = {
11273 : : (void *)&cmd_set_conntrack_set,
11274 : : (void *)&cmd_set_conntrack_conntrack,
11275 : : (void *)&cmd_set_conntrack_common_com,
11276 : : (void *)&cmd_set_conntrack_common_peer,
11277 : : (void *)&cmd_set_conntrack_common_peer_value,
11278 : : (void *)&cmd_set_conntrack_common_is_orig,
11279 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11280 : : (void *)&cmd_set_conntrack_common_enable,
11281 : : (void *)&cmd_set_conntrack_common_enable_value,
11282 : : (void *)&cmd_set_conntrack_common_live,
11283 : : (void *)&cmd_set_conntrack_common_live_value,
11284 : : (void *)&cmd_set_conntrack_common_sack,
11285 : : (void *)&cmd_set_conntrack_common_sack_value,
11286 : : (void *)&cmd_set_conntrack_common_cack,
11287 : : (void *)&cmd_set_conntrack_common_cack_value,
11288 : : (void *)&cmd_set_conntrack_common_last_dir,
11289 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11290 : : (void *)&cmd_set_conntrack_common_liberal,
11291 : : (void *)&cmd_set_conntrack_common_liberal_value,
11292 : : (void *)&cmd_set_conntrack_common_state,
11293 : : (void *)&cmd_set_conntrack_common_state_value,
11294 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11295 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11296 : : (void *)&cmd_set_conntrack_common_retrans,
11297 : : (void *)&cmd_set_conntrack_common_retrans_value,
11298 : : (void *)&cmd_set_conntrack_common_last_win,
11299 : : (void *)&cmd_set_conntrack_common_last_win_value,
11300 : : (void *)&cmd_set_conntrack_common_last_seq,
11301 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11302 : : (void *)&cmd_set_conntrack_common_last_ack,
11303 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11304 : : (void *)&cmd_set_conntrack_common_last_end,
11305 : : (void *)&cmd_set_conntrack_common_last_end_value,
11306 : : (void *)&cmd_set_conntrack_common_last_index,
11307 : : (void *)&cmd_set_conntrack_common_last_index_value,
11308 : : NULL,
11309 : : },
11310 : : };
11311 : :
11312 : : /** Set connection tracking object both directions' details */
11313 : : struct cmd_set_conntrack_dir_result {
11314 : : cmdline_fixed_string_t set;
11315 : : cmdline_fixed_string_t conntrack;
11316 : : cmdline_fixed_string_t dir;
11317 : : cmdline_fixed_string_t scale;
11318 : : cmdline_fixed_string_t fin;
11319 : : cmdline_fixed_string_t ack_seen;
11320 : : cmdline_fixed_string_t unack;
11321 : : cmdline_fixed_string_t sent_end;
11322 : : cmdline_fixed_string_t reply_end;
11323 : : cmdline_fixed_string_t max_win;
11324 : : cmdline_fixed_string_t max_ack;
11325 : : uint32_t factor;
11326 : : uint32_t f;
11327 : : uint32_t as;
11328 : : uint32_t un;
11329 : : uint32_t se;
11330 : : uint32_t re;
11331 : : uint32_t mw;
11332 : : uint32_t ma;
11333 : : };
11334 : :
11335 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11336 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11337 : : dir, "orig#rply");
11338 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11339 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11340 : : scale, "scale");
11341 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11342 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11343 : : factor, RTE_UINT32);
11344 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11345 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11346 : : fin, "fin");
11347 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11348 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11349 : : f, RTE_UINT32);
11350 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11351 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11352 : : ack_seen, "acked");
11353 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11354 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11355 : : as, RTE_UINT32);
11356 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11357 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11358 : : unack, "unack_data");
11359 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11360 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11361 : : un, RTE_UINT32);
11362 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11363 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11364 : : sent_end, "sent_end");
11365 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11366 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11367 : : se, RTE_UINT32);
11368 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11369 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11370 : : reply_end, "reply_end");
11371 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11372 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11373 : : re, RTE_UINT32);
11374 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11376 : : max_win, "max_win");
11377 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11378 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11379 : : mw, RTE_UINT32);
11380 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11381 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11382 : : max_ack, "max_ack");
11383 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11384 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11385 : : ma, RTE_UINT32);
11386 : :
11387 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11388 : : __rte_unused struct cmdline *cl,
11389 : : __rte_unused void *data)
11390 : : {
11391 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11392 : : struct rte_flow_tcp_dir_param *dir = NULL;
11393 : :
11394 : 0 : if (strcmp(res->dir, "orig") == 0)
11395 : : dir = &conntrack_context.original_dir;
11396 : 0 : else if (strcmp(res->dir, "rply") == 0)
11397 : : dir = &conntrack_context.reply_dir;
11398 : : else
11399 : : return;
11400 : 0 : dir->scale = res->factor;
11401 : 0 : dir->close_initiated = res->f;
11402 : 0 : dir->last_ack_seen = res->as;
11403 : 0 : dir->data_unacked = res->un;
11404 : 0 : dir->sent_end = res->se;
11405 : 0 : dir->reply_end = res->re;
11406 : 0 : dir->max_ack = res->ma;
11407 : 0 : dir->max_win = res->mw;
11408 : : }
11409 : :
11410 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11411 : : .f = cmd_set_conntrack_dir_parsed,
11412 : : .data = NULL,
11413 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11414 : : " acked <seen> unack_data <unack> sent_end <sent>"
11415 : : " reply_end <reply> max_win <win> max_ack <ack>",
11416 : : .tokens = {
11417 : : (void *)&cmd_set_conntrack_set,
11418 : : (void *)&cmd_set_conntrack_conntrack,
11419 : : (void *)&cmd_set_conntrack_dir_dir,
11420 : : (void *)&cmd_set_conntrack_dir_scale,
11421 : : (void *)&cmd_set_conntrack_dir_scale_value,
11422 : : (void *)&cmd_set_conntrack_dir_fin,
11423 : : (void *)&cmd_set_conntrack_dir_fin_value,
11424 : : (void *)&cmd_set_conntrack_dir_ack,
11425 : : (void *)&cmd_set_conntrack_dir_ack_value,
11426 : : (void *)&cmd_set_conntrack_dir_unack_data,
11427 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11428 : : (void *)&cmd_set_conntrack_dir_sent_end,
11429 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11430 : : (void *)&cmd_set_conntrack_dir_reply_end,
11431 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11432 : : (void *)&cmd_set_conntrack_dir_max_win,
11433 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11434 : : (void *)&cmd_set_conntrack_dir_max_ack,
11435 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11436 : : NULL,
11437 : : },
11438 : : };
11439 : :
11440 : : /* show vf stats */
11441 : :
11442 : : /* Common result structure for show vf stats */
11443 : : struct cmd_show_vf_stats_result {
11444 : : cmdline_fixed_string_t show;
11445 : : cmdline_fixed_string_t vf;
11446 : : cmdline_fixed_string_t stats;
11447 : : portid_t port_id;
11448 : : uint16_t vf_id;
11449 : : };
11450 : :
11451 : : /* Common CLI fields show vf stats*/
11452 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11453 : : TOKEN_STRING_INITIALIZER
11454 : : (struct cmd_show_vf_stats_result,
11455 : : show, "show");
11456 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11457 : : TOKEN_STRING_INITIALIZER
11458 : : (struct cmd_show_vf_stats_result,
11459 : : vf, "vf");
11460 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11461 : : TOKEN_STRING_INITIALIZER
11462 : : (struct cmd_show_vf_stats_result,
11463 : : stats, "stats");
11464 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11465 : : TOKEN_NUM_INITIALIZER
11466 : : (struct cmd_show_vf_stats_result,
11467 : : port_id, RTE_UINT16);
11468 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11469 : : TOKEN_NUM_INITIALIZER
11470 : : (struct cmd_show_vf_stats_result,
11471 : : vf_id, RTE_UINT16);
11472 : :
11473 : : static void
11474 : 0 : cmd_show_vf_stats_parsed(
11475 : : void *parsed_result,
11476 : : __rte_unused struct cmdline *cl,
11477 : : __rte_unused void *data)
11478 : : {
11479 : : struct cmd_show_vf_stats_result *res = parsed_result;
11480 : : struct rte_eth_stats stats;
11481 : : int ret = -ENOTSUP;
11482 : : static const char *nic_stats_border = "########################";
11483 : :
11484 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11485 : 0 : return;
11486 : :
11487 : : memset(&stats, 0, sizeof(stats));
11488 : :
11489 : : #ifdef RTE_NET_I40E
11490 : : if (ret == -ENOTSUP)
11491 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11492 : 0 : res->vf_id,
11493 : : &stats);
11494 : : #endif
11495 : : #ifdef RTE_NET_BNXT
11496 : 0 : if (ret == -ENOTSUP)
11497 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11498 : 0 : res->vf_id,
11499 : : &stats);
11500 : : #endif
11501 : :
11502 : 0 : switch (ret) {
11503 : : case 0:
11504 : : break;
11505 : 0 : case -EINVAL:
11506 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11507 : : break;
11508 : 0 : case -ENODEV:
11509 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11510 : : break;
11511 : 0 : case -ENOTSUP:
11512 : 0 : fprintf(stderr, "function not implemented\n");
11513 : : break;
11514 : 0 : default:
11515 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11516 : : }
11517 : :
11518 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11519 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11520 : :
11521 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11522 : : "%-"PRIu64"\n",
11523 : : stats.ipackets, stats.imissed, stats.ibytes);
11524 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11525 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11526 : : stats.rx_nombuf);
11527 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11528 : : "%-"PRIu64"\n",
11529 : : stats.opackets, stats.oerrors, stats.obytes);
11530 : :
11531 : 0 : printf(" %s############################%s\n",
11532 : : nic_stats_border, nic_stats_border);
11533 : : }
11534 : :
11535 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11536 : : .f = cmd_show_vf_stats_parsed,
11537 : : .data = NULL,
11538 : : .help_str = "show vf stats <port_id> <vf_id>",
11539 : : .tokens = {
11540 : : (void *)&cmd_show_vf_stats_show,
11541 : : (void *)&cmd_show_vf_stats_vf,
11542 : : (void *)&cmd_show_vf_stats_stats,
11543 : : (void *)&cmd_show_vf_stats_port_id,
11544 : : (void *)&cmd_show_vf_stats_vf_id,
11545 : : NULL,
11546 : : },
11547 : : };
11548 : :
11549 : : /* clear vf stats */
11550 : :
11551 : : /* Common result structure for clear vf stats */
11552 : : struct cmd_clear_vf_stats_result {
11553 : : cmdline_fixed_string_t clear;
11554 : : cmdline_fixed_string_t vf;
11555 : : cmdline_fixed_string_t stats;
11556 : : portid_t port_id;
11557 : : uint16_t vf_id;
11558 : : };
11559 : :
11560 : : /* Common CLI fields clear vf stats*/
11561 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11562 : : TOKEN_STRING_INITIALIZER
11563 : : (struct cmd_clear_vf_stats_result,
11564 : : clear, "clear");
11565 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11566 : : TOKEN_STRING_INITIALIZER
11567 : : (struct cmd_clear_vf_stats_result,
11568 : : vf, "vf");
11569 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11570 : : TOKEN_STRING_INITIALIZER
11571 : : (struct cmd_clear_vf_stats_result,
11572 : : stats, "stats");
11573 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11574 : : TOKEN_NUM_INITIALIZER
11575 : : (struct cmd_clear_vf_stats_result,
11576 : : port_id, RTE_UINT16);
11577 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11578 : : TOKEN_NUM_INITIALIZER
11579 : : (struct cmd_clear_vf_stats_result,
11580 : : vf_id, RTE_UINT16);
11581 : :
11582 : : static void
11583 : 0 : cmd_clear_vf_stats_parsed(
11584 : : void *parsed_result,
11585 : : __rte_unused struct cmdline *cl,
11586 : : __rte_unused void *data)
11587 : : {
11588 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11589 : : int ret = -ENOTSUP;
11590 : :
11591 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11592 : : return;
11593 : :
11594 : : #ifdef RTE_NET_I40E
11595 : : if (ret == -ENOTSUP)
11596 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11597 : 0 : res->vf_id);
11598 : : #endif
11599 : : #ifdef RTE_NET_BNXT
11600 : 0 : if (ret == -ENOTSUP)
11601 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11602 : 0 : res->vf_id);
11603 : : #endif
11604 : :
11605 : 0 : switch (ret) {
11606 : : case 0:
11607 : : break;
11608 : 0 : case -EINVAL:
11609 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11610 : : break;
11611 : 0 : case -ENODEV:
11612 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11613 : : break;
11614 : 0 : case -ENOTSUP:
11615 : 0 : fprintf(stderr, "function not implemented\n");
11616 : : break;
11617 : 0 : default:
11618 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11619 : : }
11620 : : }
11621 : :
11622 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11623 : : .f = cmd_clear_vf_stats_parsed,
11624 : : .data = NULL,
11625 : : .help_str = "clear vf stats <port_id> <vf_id>",
11626 : : .tokens = {
11627 : : (void *)&cmd_clear_vf_stats_clear,
11628 : : (void *)&cmd_clear_vf_stats_vf,
11629 : : (void *)&cmd_clear_vf_stats_stats,
11630 : : (void *)&cmd_clear_vf_stats_port_id,
11631 : : (void *)&cmd_clear_vf_stats_vf_id,
11632 : : NULL,
11633 : : },
11634 : : };
11635 : :
11636 : : /* Common result structure for file commands */
11637 : : struct cmd_cmdfile_result {
11638 : : cmdline_fixed_string_t load;
11639 : : cmdline_fixed_string_t filename;
11640 : : };
11641 : :
11642 : : /* Common CLI fields for file commands */
11643 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11644 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11645 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11646 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11647 : :
11648 : : static void
11649 : 0 : cmd_load_from_file_parsed(
11650 : : void *parsed_result,
11651 : : __rte_unused struct cmdline *cl,
11652 : : __rte_unused void *data)
11653 : : {
11654 : : struct cmd_cmdfile_result *res = parsed_result;
11655 : :
11656 : 0 : cmdline_read_from_file(res->filename);
11657 : 0 : }
11658 : :
11659 : : static cmdline_parse_inst_t cmd_load_from_file = {
11660 : : .f = cmd_load_from_file_parsed,
11661 : : .data = NULL,
11662 : : .help_str = "load <filename>",
11663 : : .tokens = {
11664 : : (void *)&cmd_load_cmdfile,
11665 : : (void *)&cmd_load_cmdfile_filename,
11666 : : NULL,
11667 : : },
11668 : : };
11669 : :
11670 : : /* Get Rx offloads capabilities */
11671 : : struct cmd_rx_offload_get_capa_result {
11672 : : cmdline_fixed_string_t show;
11673 : : cmdline_fixed_string_t port;
11674 : : portid_t port_id;
11675 : : cmdline_fixed_string_t rx_offload;
11676 : : cmdline_fixed_string_t capabilities;
11677 : : };
11678 : :
11679 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11680 : : TOKEN_STRING_INITIALIZER
11681 : : (struct cmd_rx_offload_get_capa_result,
11682 : : show, "show");
11683 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11684 : : TOKEN_STRING_INITIALIZER
11685 : : (struct cmd_rx_offload_get_capa_result,
11686 : : port, "port");
11687 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11688 : : TOKEN_NUM_INITIALIZER
11689 : : (struct cmd_rx_offload_get_capa_result,
11690 : : port_id, RTE_UINT16);
11691 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11692 : : TOKEN_STRING_INITIALIZER
11693 : : (struct cmd_rx_offload_get_capa_result,
11694 : : rx_offload, "rx_offload");
11695 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11696 : : TOKEN_STRING_INITIALIZER
11697 : : (struct cmd_rx_offload_get_capa_result,
11698 : : capabilities, "capabilities");
11699 : :
11700 : : static void
11701 : 0 : print_rx_offloads(uint64_t offloads)
11702 : : {
11703 : : uint64_t single_offload;
11704 : : int begin;
11705 : : int end;
11706 : : int bit;
11707 : :
11708 : 0 : if (offloads == 0)
11709 : : return;
11710 : :
11711 : : begin = rte_ctz64(offloads);
11712 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11713 : :
11714 : 0 : single_offload = 1ULL << begin;
11715 : 0 : for (bit = begin; bit < end; bit++) {
11716 : 0 : if (offloads & single_offload)
11717 : 0 : printf(" %s",
11718 : : rte_eth_dev_rx_offload_name(single_offload));
11719 : 0 : single_offload <<= 1;
11720 : : }
11721 : : }
11722 : :
11723 : : static void
11724 : 0 : cmd_rx_offload_get_capa_parsed(
11725 : : void *parsed_result,
11726 : : __rte_unused struct cmdline *cl,
11727 : : __rte_unused void *data)
11728 : : {
11729 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11730 : : struct rte_eth_dev_info dev_info;
11731 : 0 : portid_t port_id = res->port_id;
11732 : : uint64_t queue_offloads;
11733 : : uint64_t port_offloads;
11734 : : int ret;
11735 : :
11736 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11737 : 0 : if (ret != 0)
11738 : 0 : return;
11739 : :
11740 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11741 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11742 : :
11743 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11744 : : printf(" Per Queue :");
11745 : 0 : print_rx_offloads(queue_offloads);
11746 : :
11747 : : printf("\n");
11748 : : printf(" Per Port :");
11749 : 0 : print_rx_offloads(port_offloads);
11750 : : printf("\n\n");
11751 : : }
11752 : :
11753 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11754 : : .f = cmd_rx_offload_get_capa_parsed,
11755 : : .data = NULL,
11756 : : .help_str = "show port <port_id> rx_offload capabilities",
11757 : : .tokens = {
11758 : : (void *)&cmd_rx_offload_get_capa_show,
11759 : : (void *)&cmd_rx_offload_get_capa_port,
11760 : : (void *)&cmd_rx_offload_get_capa_port_id,
11761 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11762 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11763 : : NULL,
11764 : : }
11765 : : };
11766 : :
11767 : : /* Get Rx offloads configuration */
11768 : : struct cmd_rx_offload_get_configuration_result {
11769 : : cmdline_fixed_string_t show;
11770 : : cmdline_fixed_string_t port;
11771 : : portid_t port_id;
11772 : : cmdline_fixed_string_t rx_offload;
11773 : : cmdline_fixed_string_t configuration;
11774 : : };
11775 : :
11776 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11777 : : TOKEN_STRING_INITIALIZER
11778 : : (struct cmd_rx_offload_get_configuration_result,
11779 : : show, "show");
11780 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11781 : : TOKEN_STRING_INITIALIZER
11782 : : (struct cmd_rx_offload_get_configuration_result,
11783 : : port, "port");
11784 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11785 : : TOKEN_NUM_INITIALIZER
11786 : : (struct cmd_rx_offload_get_configuration_result,
11787 : : port_id, RTE_UINT16);
11788 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11789 : : TOKEN_STRING_INITIALIZER
11790 : : (struct cmd_rx_offload_get_configuration_result,
11791 : : rx_offload, "rx_offload");
11792 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11793 : : TOKEN_STRING_INITIALIZER
11794 : : (struct cmd_rx_offload_get_configuration_result,
11795 : : configuration, "configuration");
11796 : :
11797 : : static void
11798 : 0 : cmd_rx_offload_get_configuration_parsed(
11799 : : void *parsed_result,
11800 : : __rte_unused struct cmdline *cl,
11801 : : __rte_unused void *data)
11802 : : {
11803 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11804 : : struct rte_eth_dev_info dev_info;
11805 : 0 : portid_t port_id = res->port_id;
11806 : : struct rte_port *port;
11807 : : struct rte_eth_conf dev_conf;
11808 : : uint64_t port_offloads;
11809 : : uint64_t queue_offloads;
11810 : : uint16_t nb_rx_queues;
11811 : : int q;
11812 : : int ret;
11813 : :
11814 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11815 : 0 : if (ret != 0)
11816 : 0 : return;
11817 : :
11818 : 0 : port = &ports[port_id];
11819 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
11820 : :
11821 : 0 : port_offloads = dev_conf.rxmode.offloads;
11822 : : printf(" Port :");
11823 : 0 : print_rx_offloads(port_offloads);
11824 : : printf("\n");
11825 : :
11826 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11827 : 0 : if (ret != 0)
11828 : : return;
11829 : :
11830 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11831 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11832 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11833 : : printf(" Queue[%2d] :", q);
11834 : 0 : print_rx_offloads(queue_offloads);
11835 : : printf("\n");
11836 : : }
11837 : : printf("\n");
11838 : : }
11839 : :
11840 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11841 : : .f = cmd_rx_offload_get_configuration_parsed,
11842 : : .data = NULL,
11843 : : .help_str = "show port <port_id> rx_offload configuration",
11844 : : .tokens = {
11845 : : (void *)&cmd_rx_offload_get_configuration_show,
11846 : : (void *)&cmd_rx_offload_get_configuration_port,
11847 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11848 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11849 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11850 : : NULL,
11851 : : }
11852 : : };
11853 : :
11854 : : /* Enable/Disable a per port offloading */
11855 : : struct cmd_config_per_port_rx_offload_result {
11856 : : cmdline_fixed_string_t port;
11857 : : cmdline_fixed_string_t config;
11858 : : portid_t port_id;
11859 : : cmdline_fixed_string_t rx_offload;
11860 : : cmdline_fixed_string_t offload;
11861 : : cmdline_fixed_string_t on_off;
11862 : : };
11863 : :
11864 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11865 : : TOKEN_STRING_INITIALIZER
11866 : : (struct cmd_config_per_port_rx_offload_result,
11867 : : port, "port");
11868 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11869 : : TOKEN_STRING_INITIALIZER
11870 : : (struct cmd_config_per_port_rx_offload_result,
11871 : : config, "config");
11872 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11873 : : TOKEN_NUM_INITIALIZER
11874 : : (struct cmd_config_per_port_rx_offload_result,
11875 : : port_id, RTE_UINT16);
11876 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11877 : : TOKEN_STRING_INITIALIZER
11878 : : (struct cmd_config_per_port_rx_offload_result,
11879 : : rx_offload, "rx_offload");
11880 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11881 : : TOKEN_STRING_INITIALIZER
11882 : : (struct cmd_config_per_port_rx_offload_result,
11883 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11884 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11885 : : "vlan_filter#vlan_extend#"
11886 : : "scatter#buffer_split#timestamp#security#"
11887 : : "keep_crc#rss_hash");
11888 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11889 : : TOKEN_STRING_INITIALIZER
11890 : : (struct cmd_config_per_port_rx_offload_result,
11891 : : on_off, "on#off");
11892 : :
11893 : : static uint64_t
11894 : 0 : search_rx_offload(const char *name)
11895 : : {
11896 : : uint64_t single_offload;
11897 : : const char *single_name;
11898 : : int found = 0;
11899 : : unsigned int bit;
11900 : :
11901 : : single_offload = 1;
11902 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11903 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11904 : 0 : if (!strcasecmp(single_name, name)) {
11905 : : found = 1;
11906 : : break;
11907 : : }
11908 : 0 : single_offload <<= 1;
11909 : : }
11910 : :
11911 : 0 : if (found)
11912 : 0 : return single_offload;
11913 : :
11914 : : return 0;
11915 : : }
11916 : :
11917 : : static void
11918 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11919 : : {
11920 : : struct rte_eth_dev_info dev_info;
11921 : : struct rte_port *port;
11922 : : uint16_t nb_rx_queues;
11923 : : uint64_t offload;
11924 : : int q;
11925 : : int ret;
11926 : :
11927 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11928 : 0 : if (ret != 0)
11929 : 0 : return;
11930 : :
11931 : 0 : port = &ports[port_id];
11932 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11933 : 0 : fprintf(stderr,
11934 : : "Error: Can't config offload when Port %d is not stopped\n",
11935 : : port_id);
11936 : 0 : return;
11937 : : }
11938 : :
11939 : 0 : if (!strcmp(name, "all")) {
11940 : 0 : offload = dev_info.rx_offload_capa;
11941 : : } else {
11942 : 0 : offload = search_rx_offload(name);
11943 : 0 : if (offload == 0) {
11944 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11945 : 0 : return;
11946 : : }
11947 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11948 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11949 : : port_id, name);
11950 : 0 : return;
11951 : : }
11952 : : }
11953 : :
11954 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11955 : 0 : if (on) {
11956 : 0 : port->dev_conf.rxmode.offloads |= offload;
11957 : 0 : for (q = 0; q < nb_rx_queues; q++)
11958 : 0 : port->rxq[q].conf.offloads |= offload;
11959 : : } else {
11960 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11961 : 0 : for (q = 0; q < nb_rx_queues; q++)
11962 : 0 : port->rxq[q].conf.offloads &= ~offload;
11963 : : }
11964 : :
11965 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11966 : : }
11967 : :
11968 : : static void
11969 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11970 : : __rte_unused struct cmdline *cl,
11971 : : __rte_unused void *data)
11972 : : {
11973 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11974 : : bool on;
11975 : :
11976 : 0 : on = strcmp(res->on_off, "on") == 0;
11977 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11978 : 0 : }
11979 : :
11980 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11981 : : .f = cmd_config_per_port_rx_offload_parsed,
11982 : : .data = NULL,
11983 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11984 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11985 : : "macsec_strip|vlan_filter|vlan_extend|"
11986 : : "scatter|buffer_split|timestamp|security|"
11987 : : "keep_crc|rss_hash on|off",
11988 : : .tokens = {
11989 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11990 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11991 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11992 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11993 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11994 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11995 : : NULL,
11996 : : }
11997 : : };
11998 : :
11999 : : /* Enable/Disable all port Rx offloading */
12000 : : struct cmd_config_all_port_rx_offload_result {
12001 : : cmdline_fixed_string_t port;
12002 : : cmdline_fixed_string_t config;
12003 : : cmdline_fixed_string_t port_all;
12004 : : cmdline_fixed_string_t rx_offload;
12005 : : cmdline_fixed_string_t offload;
12006 : : cmdline_fixed_string_t on_off;
12007 : : };
12008 : :
12009 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12010 : : TOKEN_STRING_INITIALIZER
12011 : : (struct cmd_config_all_port_rx_offload_result,
12012 : : port, "port");
12013 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12014 : : TOKEN_STRING_INITIALIZER
12015 : : (struct cmd_config_all_port_rx_offload_result,
12016 : : config, "config");
12017 : :
12018 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12019 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12020 : : port_all, "all");
12021 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12022 : : TOKEN_STRING_INITIALIZER
12023 : : (struct cmd_config_all_port_rx_offload_result,
12024 : : rx_offload, "rx_offload");
12025 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12026 : : TOKEN_STRING_INITIALIZER
12027 : : (struct cmd_config_all_port_rx_offload_result,
12028 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12029 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12030 : : "vlan_filter#vlan_extend#"
12031 : : "scatter#buffer_split#timestamp#security#"
12032 : : "keep_crc#rss_hash");
12033 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12034 : : TOKEN_STRING_INITIALIZER
12035 : : (struct cmd_config_all_port_rx_offload_result,
12036 : : on_off, "on#off");
12037 : :
12038 : : static void
12039 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12040 : : __rte_unused struct cmdline *cl,
12041 : : __rte_unused void *data)
12042 : : {
12043 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12044 : : bool on_off;
12045 : : portid_t i;
12046 : :
12047 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12048 : 0 : RTE_ETH_FOREACH_DEV(i)
12049 : 0 : config_port_rx_offload(i, res->offload, on_off);
12050 : :
12051 : 0 : }
12052 : :
12053 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12054 : : .f = cmd_config_all_port_rx_offload_parsed,
12055 : : .data = NULL,
12056 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12057 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12058 : : "macsec_strip|vlan_filter|vlan_extend|"
12059 : : "scatter|buffer_split|timestamp|security|"
12060 : : "keep_crc|rss_hash on|off",
12061 : : .tokens = {
12062 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12063 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12064 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12065 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12066 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12067 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12068 : : NULL,
12069 : : }
12070 : : };
12071 : :
12072 : : /* Enable/Disable a per queue offloading */
12073 : : struct cmd_config_per_queue_rx_offload_result {
12074 : : cmdline_fixed_string_t port;
12075 : : portid_t port_id;
12076 : : cmdline_fixed_string_t rxq;
12077 : : uint16_t queue_id;
12078 : : cmdline_fixed_string_t rx_offload;
12079 : : cmdline_fixed_string_t offload;
12080 : : cmdline_fixed_string_t on_off;
12081 : : };
12082 : :
12083 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12084 : : TOKEN_STRING_INITIALIZER
12085 : : (struct cmd_config_per_queue_rx_offload_result,
12086 : : port, "port");
12087 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12088 : : TOKEN_NUM_INITIALIZER
12089 : : (struct cmd_config_per_queue_rx_offload_result,
12090 : : port_id, RTE_UINT16);
12091 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12092 : : TOKEN_STRING_INITIALIZER
12093 : : (struct cmd_config_per_queue_rx_offload_result,
12094 : : rxq, "rxq");
12095 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12096 : : TOKEN_NUM_INITIALIZER
12097 : : (struct cmd_config_per_queue_rx_offload_result,
12098 : : queue_id, RTE_UINT16);
12099 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12100 : : TOKEN_STRING_INITIALIZER
12101 : : (struct cmd_config_per_queue_rx_offload_result,
12102 : : rx_offload, "rx_offload");
12103 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12104 : : TOKEN_STRING_INITIALIZER
12105 : : (struct cmd_config_per_queue_rx_offload_result,
12106 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12107 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12108 : : "vlan_filter#vlan_extend#"
12109 : : "scatter#buffer_split#timestamp#security#keep_crc");
12110 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12111 : : TOKEN_STRING_INITIALIZER
12112 : : (struct cmd_config_per_queue_rx_offload_result,
12113 : : on_off, "on#off");
12114 : :
12115 : : static void
12116 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12117 : : __rte_unused struct cmdline *cl,
12118 : : __rte_unused void *data)
12119 : : {
12120 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12121 : : struct rte_eth_dev_info dev_info;
12122 : 0 : portid_t port_id = res->port_id;
12123 : 0 : uint16_t queue_id = res->queue_id;
12124 : : struct rte_port *port;
12125 : : uint64_t offload;
12126 : : int ret;
12127 : :
12128 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12129 : 0 : if (ret != 0)
12130 : 0 : return;
12131 : :
12132 : 0 : port = &ports[port_id];
12133 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12134 : 0 : fprintf(stderr,
12135 : : "Error: Can't config offload when Port %d is not stopped\n",
12136 : : port_id);
12137 : 0 : return;
12138 : : }
12139 : :
12140 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12141 : 0 : fprintf(stderr,
12142 : : "Error: input queue_id should be 0 ... %d\n",
12143 : 0 : dev_info.nb_rx_queues - 1);
12144 : 0 : return;
12145 : : }
12146 : :
12147 : 0 : if (!strcmp(res->offload, "all")) {
12148 : 0 : offload = dev_info.rx_queue_offload_capa;
12149 : : } else {
12150 : 0 : offload = search_rx_offload(res->offload);
12151 : 0 : if (offload == 0) {
12152 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12153 : 0 : return;
12154 : : }
12155 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12156 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12157 : : port_id, res->offload);
12158 : 0 : return;
12159 : : }
12160 : : }
12161 : :
12162 : 0 : if (!strcmp(res->on_off, "on"))
12163 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12164 : : else
12165 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12166 : :
12167 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12168 : : }
12169 : :
12170 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12171 : : .f = cmd_config_per_queue_rx_offload_parsed,
12172 : : .data = NULL,
12173 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12174 : : "all|vlan_strip|ipv4_cksum|"
12175 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12176 : : "macsec_strip|vlan_filter|vlan_extend|"
12177 : : "scatter|buffer_split|timestamp|security|"
12178 : : "keep_crc on|off",
12179 : : .tokens = {
12180 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12181 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12182 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12183 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12184 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12185 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12186 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12187 : : NULL,
12188 : : }
12189 : : };
12190 : :
12191 : : /* Get Tx offloads capabilities */
12192 : : struct cmd_tx_offload_get_capa_result {
12193 : : cmdline_fixed_string_t show;
12194 : : cmdline_fixed_string_t port;
12195 : : portid_t port_id;
12196 : : cmdline_fixed_string_t tx_offload;
12197 : : cmdline_fixed_string_t capabilities;
12198 : : };
12199 : :
12200 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12201 : : TOKEN_STRING_INITIALIZER
12202 : : (struct cmd_tx_offload_get_capa_result,
12203 : : show, "show");
12204 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12205 : : TOKEN_STRING_INITIALIZER
12206 : : (struct cmd_tx_offload_get_capa_result,
12207 : : port, "port");
12208 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12209 : : TOKEN_NUM_INITIALIZER
12210 : : (struct cmd_tx_offload_get_capa_result,
12211 : : port_id, RTE_UINT16);
12212 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12213 : : TOKEN_STRING_INITIALIZER
12214 : : (struct cmd_tx_offload_get_capa_result,
12215 : : tx_offload, "tx_offload");
12216 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12217 : : TOKEN_STRING_INITIALIZER
12218 : : (struct cmd_tx_offload_get_capa_result,
12219 : : capabilities, "capabilities");
12220 : :
12221 : : static void
12222 : 0 : print_tx_offloads(uint64_t offloads)
12223 : : {
12224 : : uint64_t single_offload;
12225 : : int begin;
12226 : : int end;
12227 : : int bit;
12228 : :
12229 : 0 : if (offloads == 0)
12230 : : return;
12231 : :
12232 : : begin = rte_ctz64(offloads);
12233 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12234 : :
12235 : 0 : single_offload = 1ULL << begin;
12236 : 0 : for (bit = begin; bit < end; bit++) {
12237 : 0 : if (offloads & single_offload)
12238 : 0 : printf(" %s",
12239 : : rte_eth_dev_tx_offload_name(single_offload));
12240 : 0 : single_offload <<= 1;
12241 : : }
12242 : : }
12243 : :
12244 : : static void
12245 : 0 : cmd_tx_offload_get_capa_parsed(
12246 : : void *parsed_result,
12247 : : __rte_unused struct cmdline *cl,
12248 : : __rte_unused void *data)
12249 : : {
12250 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12251 : : struct rte_eth_dev_info dev_info;
12252 : 0 : portid_t port_id = res->port_id;
12253 : : uint64_t queue_offloads;
12254 : : uint64_t port_offloads;
12255 : : int ret;
12256 : :
12257 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12258 : 0 : if (ret != 0)
12259 : 0 : return;
12260 : :
12261 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12262 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12263 : :
12264 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12265 : : printf(" Per Queue :");
12266 : 0 : print_tx_offloads(queue_offloads);
12267 : :
12268 : : printf("\n");
12269 : : printf(" Per Port :");
12270 : 0 : print_tx_offloads(port_offloads);
12271 : : printf("\n\n");
12272 : : }
12273 : :
12274 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12275 : : .f = cmd_tx_offload_get_capa_parsed,
12276 : : .data = NULL,
12277 : : .help_str = "show port <port_id> tx_offload capabilities",
12278 : : .tokens = {
12279 : : (void *)&cmd_tx_offload_get_capa_show,
12280 : : (void *)&cmd_tx_offload_get_capa_port,
12281 : : (void *)&cmd_tx_offload_get_capa_port_id,
12282 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12283 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12284 : : NULL,
12285 : : }
12286 : : };
12287 : :
12288 : : /* Get Tx offloads configuration */
12289 : : struct cmd_tx_offload_get_configuration_result {
12290 : : cmdline_fixed_string_t show;
12291 : : cmdline_fixed_string_t port;
12292 : : portid_t port_id;
12293 : : cmdline_fixed_string_t tx_offload;
12294 : : cmdline_fixed_string_t configuration;
12295 : : };
12296 : :
12297 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12298 : : TOKEN_STRING_INITIALIZER
12299 : : (struct cmd_tx_offload_get_configuration_result,
12300 : : show, "show");
12301 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12302 : : TOKEN_STRING_INITIALIZER
12303 : : (struct cmd_tx_offload_get_configuration_result,
12304 : : port, "port");
12305 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12306 : : TOKEN_NUM_INITIALIZER
12307 : : (struct cmd_tx_offload_get_configuration_result,
12308 : : port_id, RTE_UINT16);
12309 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12310 : : TOKEN_STRING_INITIALIZER
12311 : : (struct cmd_tx_offload_get_configuration_result,
12312 : : tx_offload, "tx_offload");
12313 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12314 : : TOKEN_STRING_INITIALIZER
12315 : : (struct cmd_tx_offload_get_configuration_result,
12316 : : configuration, "configuration");
12317 : :
12318 : : static void
12319 : 0 : cmd_tx_offload_get_configuration_parsed(
12320 : : void *parsed_result,
12321 : : __rte_unused struct cmdline *cl,
12322 : : __rte_unused void *data)
12323 : : {
12324 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12325 : : struct rte_eth_dev_info dev_info;
12326 : 0 : portid_t port_id = res->port_id;
12327 : : struct rte_port *port;
12328 : : struct rte_eth_conf dev_conf;
12329 : : uint64_t port_offloads;
12330 : : uint64_t queue_offloads;
12331 : : uint16_t nb_tx_queues;
12332 : : int q;
12333 : : int ret;
12334 : :
12335 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12336 : 0 : if (ret != 0)
12337 : 0 : return;
12338 : :
12339 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12340 : 0 : port = &ports[port_id];
12341 : 0 : port_offloads = dev_conf.txmode.offloads;
12342 : : printf(" Port :");
12343 : 0 : print_tx_offloads(port_offloads);
12344 : : printf("\n");
12345 : :
12346 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12347 : 0 : if (ret != 0)
12348 : : return;
12349 : :
12350 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12351 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12352 : 0 : queue_offloads = port->txq[q].conf.offloads;
12353 : : printf(" Queue[%2d] :", q);
12354 : 0 : print_tx_offloads(queue_offloads);
12355 : : printf("\n");
12356 : : }
12357 : : printf("\n");
12358 : : }
12359 : :
12360 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12361 : : .f = cmd_tx_offload_get_configuration_parsed,
12362 : : .data = NULL,
12363 : : .help_str = "show port <port_id> tx_offload configuration",
12364 : : .tokens = {
12365 : : (void *)&cmd_tx_offload_get_configuration_show,
12366 : : (void *)&cmd_tx_offload_get_configuration_port,
12367 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12368 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12369 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12370 : : NULL,
12371 : : }
12372 : : };
12373 : :
12374 : : /* Enable/Disable a per port offloading */
12375 : : struct cmd_config_per_port_tx_offload_result {
12376 : : cmdline_fixed_string_t port;
12377 : : cmdline_fixed_string_t config;
12378 : : portid_t port_id;
12379 : : cmdline_fixed_string_t tx_offload;
12380 : : cmdline_fixed_string_t offload;
12381 : : cmdline_fixed_string_t on_off;
12382 : : };
12383 : :
12384 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12385 : : TOKEN_STRING_INITIALIZER
12386 : : (struct cmd_config_per_port_tx_offload_result,
12387 : : port, "port");
12388 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12389 : : TOKEN_STRING_INITIALIZER
12390 : : (struct cmd_config_per_port_tx_offload_result,
12391 : : config, "config");
12392 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12393 : : TOKEN_NUM_INITIALIZER
12394 : : (struct cmd_config_per_port_tx_offload_result,
12395 : : port_id, RTE_UINT16);
12396 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12397 : : TOKEN_STRING_INITIALIZER
12398 : : (struct cmd_config_per_port_tx_offload_result,
12399 : : tx_offload, "tx_offload");
12400 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12401 : : TOKEN_STRING_INITIALIZER
12402 : : (struct cmd_config_per_port_tx_offload_result,
12403 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12404 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12405 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12406 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12407 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12408 : : "send_on_timestamp");
12409 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12410 : : TOKEN_STRING_INITIALIZER
12411 : : (struct cmd_config_per_port_tx_offload_result,
12412 : : on_off, "on#off");
12413 : :
12414 : : static uint64_t
12415 : 0 : search_tx_offload(const char *name)
12416 : : {
12417 : : uint64_t single_offload;
12418 : : const char *single_name;
12419 : : int found = 0;
12420 : : unsigned int bit;
12421 : :
12422 : : single_offload = 1;
12423 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12424 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12425 : 0 : if (single_name == NULL)
12426 : : break;
12427 : 0 : if (!strcasecmp(single_name, name)) {
12428 : : found = 1;
12429 : : break;
12430 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12431 : : break;
12432 : 0 : single_offload <<= 1;
12433 : : }
12434 : :
12435 : 0 : if (found)
12436 : 0 : return single_offload;
12437 : :
12438 : : return 0;
12439 : : }
12440 : :
12441 : : static void
12442 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12443 : : {
12444 : : struct rte_eth_dev_info dev_info;
12445 : : struct rte_port *port;
12446 : : uint16_t nb_tx_queues;
12447 : : uint64_t offload;
12448 : : int q;
12449 : : int ret;
12450 : :
12451 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12452 : 0 : if (ret != 0)
12453 : 0 : return;
12454 : :
12455 : 0 : port = &ports[port_id];
12456 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12457 : 0 : fprintf(stderr,
12458 : : "Error: Can't config offload when Port %d is not stopped\n",
12459 : : port_id);
12460 : 0 : return;
12461 : : }
12462 : :
12463 : 0 : if (!strcmp(name, "all")) {
12464 : 0 : offload = dev_info.tx_offload_capa;
12465 : : } else {
12466 : 0 : offload = search_tx_offload(name);
12467 : 0 : if (offload == 0) {
12468 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12469 : 0 : return;
12470 : : }
12471 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12472 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12473 : : port_id, name);
12474 : 0 : return;
12475 : : }
12476 : : }
12477 : :
12478 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12479 : 0 : if (on) {
12480 : 0 : port->dev_conf.txmode.offloads |= offload;
12481 : 0 : for (q = 0; q < nb_tx_queues; q++)
12482 : 0 : port->txq[q].conf.offloads |= offload;
12483 : : } else {
12484 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12485 : 0 : for (q = 0; q < nb_tx_queues; q++)
12486 : 0 : port->txq[q].conf.offloads &= ~offload;
12487 : : }
12488 : :
12489 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12490 : : }
12491 : :
12492 : : static void
12493 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12494 : : __rte_unused struct cmdline *cl,
12495 : : __rte_unused void *data)
12496 : : {
12497 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12498 : : bool on;
12499 : :
12500 : 0 : on = strcmp(res->on_off, "on") == 0;
12501 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12502 : 0 : }
12503 : :
12504 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12505 : : .f = cmd_config_per_port_tx_offload_parsed,
12506 : : .data = NULL,
12507 : : .help_str = "port config <port_id> tx_offload "
12508 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12509 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12510 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12511 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12512 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12513 : : "send_on_timestamp on|off",
12514 : : .tokens = {
12515 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12516 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12517 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12518 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12519 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12520 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12521 : : NULL,
12522 : : }
12523 : : };
12524 : :
12525 : : /* Enable/Disable all port Tx offloading */
12526 : : struct cmd_config_all_port_tx_offload_result {
12527 : : cmdline_fixed_string_t port;
12528 : : cmdline_fixed_string_t config;
12529 : : cmdline_fixed_string_t port_all;
12530 : : cmdline_fixed_string_t tx_offload;
12531 : : cmdline_fixed_string_t offload;
12532 : : cmdline_fixed_string_t on_off;
12533 : : };
12534 : :
12535 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12536 : : TOKEN_STRING_INITIALIZER
12537 : : (struct cmd_config_all_port_tx_offload_result,
12538 : : port, "port");
12539 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12540 : : TOKEN_STRING_INITIALIZER
12541 : : (struct cmd_config_all_port_tx_offload_result,
12542 : : config, "config");
12543 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12544 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12545 : : port_all, "all");
12546 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12547 : : TOKEN_STRING_INITIALIZER
12548 : : (struct cmd_config_all_port_tx_offload_result,
12549 : : tx_offload, "tx_offload");
12550 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12551 : : TOKEN_STRING_INITIALIZER
12552 : : (struct cmd_config_all_port_tx_offload_result,
12553 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12554 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12555 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12556 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12557 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12558 : : "send_on_timestamp");
12559 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12560 : : TOKEN_STRING_INITIALIZER
12561 : : (struct cmd_config_all_port_tx_offload_result,
12562 : : on_off, "on#off");
12563 : :
12564 : : static void
12565 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12566 : : __rte_unused struct cmdline *cl,
12567 : : __rte_unused void *data)
12568 : : {
12569 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12570 : : portid_t i;
12571 : : bool on_off;
12572 : :
12573 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12574 : 0 : RTE_ETH_FOREACH_DEV(i)
12575 : 0 : config_port_tx_offload(i, res->offload, on_off);
12576 : 0 : }
12577 : :
12578 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12579 : : .f = cmd_config_all_port_tx_offload_parsed,
12580 : : .data = NULL,
12581 : : .help_str = "port config all tx_offload "
12582 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12583 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12584 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12585 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12586 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12587 : : "send_on_timestamp on|off",
12588 : : .tokens = {
12589 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12590 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12591 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12592 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12593 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12594 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12595 : : NULL,
12596 : : }
12597 : : };
12598 : :
12599 : : /* Enable/Disable a per queue offloading */
12600 : : struct cmd_config_per_queue_tx_offload_result {
12601 : : cmdline_fixed_string_t port;
12602 : : portid_t port_id;
12603 : : cmdline_fixed_string_t txq;
12604 : : uint16_t queue_id;
12605 : : cmdline_fixed_string_t tx_offload;
12606 : : cmdline_fixed_string_t offload;
12607 : : cmdline_fixed_string_t on_off;
12608 : : };
12609 : :
12610 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12611 : : TOKEN_STRING_INITIALIZER
12612 : : (struct cmd_config_per_queue_tx_offload_result,
12613 : : port, "port");
12614 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12615 : : TOKEN_NUM_INITIALIZER
12616 : : (struct cmd_config_per_queue_tx_offload_result,
12617 : : port_id, RTE_UINT16);
12618 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12619 : : TOKEN_STRING_INITIALIZER
12620 : : (struct cmd_config_per_queue_tx_offload_result,
12621 : : txq, "txq");
12622 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12623 : : TOKEN_NUM_INITIALIZER
12624 : : (struct cmd_config_per_queue_tx_offload_result,
12625 : : queue_id, RTE_UINT16);
12626 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12627 : : TOKEN_STRING_INITIALIZER
12628 : : (struct cmd_config_per_queue_tx_offload_result,
12629 : : tx_offload, "tx_offload");
12630 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12631 : : TOKEN_STRING_INITIALIZER
12632 : : (struct cmd_config_per_queue_tx_offload_result,
12633 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12634 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12635 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12636 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12637 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12638 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12639 : : TOKEN_STRING_INITIALIZER
12640 : : (struct cmd_config_per_queue_tx_offload_result,
12641 : : on_off, "on#off");
12642 : :
12643 : : static void
12644 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12645 : : __rte_unused struct cmdline *cl,
12646 : : __rte_unused void *data)
12647 : : {
12648 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12649 : : struct rte_eth_dev_info dev_info;
12650 : 0 : portid_t port_id = res->port_id;
12651 : 0 : uint16_t queue_id = res->queue_id;
12652 : : struct rte_port *port;
12653 : : uint64_t offload;
12654 : : int ret;
12655 : :
12656 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12657 : 0 : if (ret != 0)
12658 : 0 : return;
12659 : :
12660 : 0 : port = &ports[port_id];
12661 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12662 : 0 : fprintf(stderr,
12663 : : "Error: Can't config offload when Port %d is not stopped\n",
12664 : : port_id);
12665 : 0 : return;
12666 : : }
12667 : :
12668 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12669 : 0 : fprintf(stderr,
12670 : : "Error: input queue_id should be 0 ... %d\n",
12671 : 0 : dev_info.nb_tx_queues - 1);
12672 : 0 : return;
12673 : : }
12674 : :
12675 : 0 : if (!strcmp(res->offload, "all")) {
12676 : 0 : offload = dev_info.tx_queue_offload_capa;
12677 : : } else {
12678 : 0 : offload = search_tx_offload(res->offload);
12679 : 0 : if (offload == 0) {
12680 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12681 : 0 : return;
12682 : : }
12683 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12684 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12685 : : port_id, res->offload);
12686 : 0 : return;
12687 : : }
12688 : : }
12689 : :
12690 : 0 : if (!strcmp(res->on_off, "on"))
12691 : 0 : port->txq[queue_id].conf.offloads |= offload;
12692 : : else
12693 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12694 : :
12695 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12696 : : }
12697 : :
12698 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12699 : : .f = cmd_config_per_queue_tx_offload_parsed,
12700 : : .data = NULL,
12701 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12702 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12703 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12704 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12705 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12706 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12707 : : "on|off",
12708 : : .tokens = {
12709 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12710 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12711 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12712 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12713 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12714 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12715 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12716 : : NULL,
12717 : : }
12718 : : };
12719 : :
12720 : : /* *** configure tx_metadata for specific port *** */
12721 : : struct cmd_config_tx_metadata_specific_result {
12722 : : cmdline_fixed_string_t port;
12723 : : cmdline_fixed_string_t keyword;
12724 : : uint16_t port_id;
12725 : : cmdline_fixed_string_t item;
12726 : : uint32_t value;
12727 : : };
12728 : :
12729 : : static void
12730 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12731 : : __rte_unused struct cmdline *cl,
12732 : : __rte_unused void *data)
12733 : : {
12734 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12735 : :
12736 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12737 : : return;
12738 : 0 : ports[res->port_id].tx_metadata = res->value;
12739 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12740 : 0 : if (ports[res->port_id].tx_metadata)
12741 : 0 : add_tx_md_callback(res->port_id);
12742 : : else
12743 : 0 : remove_tx_md_callback(res->port_id);
12744 : 0 : rte_flow_dynf_metadata_register();
12745 : : }
12746 : :
12747 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12748 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12749 : : port, "port");
12750 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12751 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12752 : : keyword, "config");
12753 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12754 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12755 : : port_id, RTE_UINT16);
12756 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12757 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12758 : : item, "tx_metadata");
12759 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12760 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12761 : : value, RTE_UINT32);
12762 : :
12763 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12764 : : .f = cmd_config_tx_metadata_specific_parsed,
12765 : : .data = NULL,
12766 : : .help_str = "port config <port_id> tx_metadata <value>",
12767 : : .tokens = {
12768 : : (void *)&cmd_config_tx_metadata_specific_port,
12769 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12770 : : (void *)&cmd_config_tx_metadata_specific_id,
12771 : : (void *)&cmd_config_tx_metadata_specific_item,
12772 : : (void *)&cmd_config_tx_metadata_specific_value,
12773 : : NULL,
12774 : : },
12775 : : };
12776 : :
12777 : : /* *** set dynf *** */
12778 : : struct cmd_config_tx_dynf_specific_result {
12779 : : cmdline_fixed_string_t port;
12780 : : cmdline_fixed_string_t keyword;
12781 : : uint16_t port_id;
12782 : : cmdline_fixed_string_t item;
12783 : : cmdline_fixed_string_t name;
12784 : : cmdline_fixed_string_t value;
12785 : : };
12786 : :
12787 : : static void
12788 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12789 : : __rte_unused struct cmdline *cl,
12790 : : __rte_unused void *data)
12791 : : {
12792 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12793 : : struct rte_mbuf_dynflag desc_flag;
12794 : : int flag;
12795 : : uint64_t old_port_flags;
12796 : :
12797 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12798 : 0 : return;
12799 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12800 : 0 : if (flag <= 0) {
12801 : 0 : if (strlcpy(desc_flag.name, res->name,
12802 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12803 : 0 : fprintf(stderr, "Flag name too long\n");
12804 : 0 : return;
12805 : : }
12806 : 0 : desc_flag.flags = 0;
12807 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12808 : 0 : if (flag < 0) {
12809 : 0 : fprintf(stderr, "Can't register flag\n");
12810 : 0 : return;
12811 : : }
12812 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12813 : : }
12814 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12815 : 0 : if (!strcmp(res->value, "set")) {
12816 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
12817 : 0 : if (old_port_flags == 0)
12818 : 0 : add_tx_dynf_callback(res->port_id);
12819 : : } else {
12820 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
12821 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12822 : 0 : remove_tx_dynf_callback(res->port_id);
12823 : : }
12824 : : }
12825 : :
12826 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12827 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12828 : : keyword, "port");
12829 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12830 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12831 : : keyword, "config");
12832 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12833 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12834 : : port_id, RTE_UINT16);
12835 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12836 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12837 : : item, "dynf");
12838 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12839 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12840 : : name, NULL);
12841 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12842 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12843 : : value, "set#clear");
12844 : :
12845 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12846 : : .f = cmd_config_dynf_specific_parsed,
12847 : : .data = NULL,
12848 : : .help_str = "port config <port id> dynf <name> set|clear",
12849 : : .tokens = {
12850 : : (void *)&cmd_config_tx_dynf_specific_port,
12851 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12852 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12853 : : (void *)&cmd_config_tx_dynf_specific_item,
12854 : : (void *)&cmd_config_tx_dynf_specific_name,
12855 : : (void *)&cmd_config_tx_dynf_specific_value,
12856 : : NULL,
12857 : : },
12858 : : };
12859 : :
12860 : : /* *** display tx_metadata per port configuration *** */
12861 : : struct cmd_show_tx_metadata_result {
12862 : : cmdline_fixed_string_t cmd_show;
12863 : : cmdline_fixed_string_t cmd_port;
12864 : : cmdline_fixed_string_t cmd_keyword;
12865 : : portid_t cmd_pid;
12866 : : };
12867 : :
12868 : : static void
12869 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12870 : : __rte_unused struct cmdline *cl,
12871 : : __rte_unused void *data)
12872 : : {
12873 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12874 : :
12875 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12876 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12877 : 0 : return;
12878 : : }
12879 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12880 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12881 : 0 : ports[res->cmd_pid].tx_metadata);
12882 : : }
12883 : : }
12884 : :
12885 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12886 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12887 : : cmd_show, "show");
12888 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12889 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12890 : : cmd_port, "port");
12891 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12892 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12893 : : cmd_pid, RTE_UINT16);
12894 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12895 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12896 : : cmd_keyword, "tx_metadata");
12897 : :
12898 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12899 : : .f = cmd_show_tx_metadata_parsed,
12900 : : .data = NULL,
12901 : : .help_str = "show port <port_id> tx_metadata",
12902 : : .tokens = {
12903 : : (void *)&cmd_show_tx_metadata_show,
12904 : : (void *)&cmd_show_tx_metadata_port,
12905 : : (void *)&cmd_show_tx_metadata_pid,
12906 : : (void *)&cmd_show_tx_metadata_keyword,
12907 : : NULL,
12908 : : },
12909 : : };
12910 : :
12911 : : /* *** show fec capability per port configuration *** */
12912 : : struct cmd_show_fec_capability_result {
12913 : : cmdline_fixed_string_t cmd_show;
12914 : : cmdline_fixed_string_t cmd_port;
12915 : : cmdline_fixed_string_t cmd_fec;
12916 : : cmdline_fixed_string_t cmd_keyword;
12917 : : portid_t cmd_pid;
12918 : : };
12919 : :
12920 : : static void
12921 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12922 : : __rte_unused struct cmdline *cl,
12923 : : __rte_unused void *data)
12924 : : {
12925 : : struct cmd_show_fec_capability_result *res = parsed_result;
12926 : : struct rte_eth_fec_capa *speed_fec_capa;
12927 : : unsigned int num;
12928 : : int ret;
12929 : :
12930 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12931 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12932 : 0 : return;
12933 : : }
12934 : :
12935 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12936 : 0 : if (ret == -ENOTSUP) {
12937 : 0 : fprintf(stderr, "Function not implemented\n");
12938 : 0 : return;
12939 : 0 : } else if (ret < 0) {
12940 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12941 : 0 : return;
12942 : : }
12943 : :
12944 : 0 : num = (unsigned int)ret;
12945 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12946 : 0 : if (speed_fec_capa == NULL) {
12947 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12948 : 0 : return;
12949 : : }
12950 : :
12951 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12952 : 0 : if (ret < 0) {
12953 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12954 : 0 : goto out;
12955 : : }
12956 : :
12957 : 0 : show_fec_capability(num, speed_fec_capa);
12958 : 0 : out:
12959 : 0 : free(speed_fec_capa);
12960 : : }
12961 : :
12962 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12963 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12964 : : cmd_show, "show");
12965 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12966 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12967 : : cmd_port, "port");
12968 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12969 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12970 : : cmd_pid, RTE_UINT16);
12971 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12972 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12973 : : cmd_fec, "fec");
12974 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12975 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12976 : : cmd_keyword, "capabilities");
12977 : :
12978 : : static cmdline_parse_inst_t cmd_show_capability = {
12979 : : .f = cmd_show_fec_capability_parsed,
12980 : : .data = NULL,
12981 : : .help_str = "show port <port_id> fec capabilities",
12982 : : .tokens = {
12983 : : (void *)&cmd_show_fec_capability_show,
12984 : : (void *)&cmd_show_fec_capability_port,
12985 : : (void *)&cmd_show_fec_capability_pid,
12986 : : (void *)&cmd_show_fec_capability_fec,
12987 : : (void *)&cmd_show_fec_capability_keyword,
12988 : : NULL,
12989 : : },
12990 : : };
12991 : :
12992 : : /* *** show fec mode per port configuration *** */
12993 : : struct cmd_show_fec_metadata_result {
12994 : : cmdline_fixed_string_t cmd_show;
12995 : : cmdline_fixed_string_t cmd_port;
12996 : : cmdline_fixed_string_t cmd_keyword;
12997 : : portid_t cmd_pid;
12998 : : };
12999 : :
13000 : : static void
13001 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13002 : : __rte_unused struct cmdline *cl,
13003 : : __rte_unused void *data)
13004 : : {
13005 : : #define FEC_NAME_SIZE 16
13006 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13007 : : uint32_t mode;
13008 : : char buf[FEC_NAME_SIZE];
13009 : : int ret;
13010 : :
13011 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13012 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13013 : 0 : return;
13014 : : }
13015 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13016 : 0 : if (ret == -ENOTSUP) {
13017 : 0 : fprintf(stderr, "Function not implemented\n");
13018 : 0 : return;
13019 : 0 : } else if (ret < 0) {
13020 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13021 : 0 : return;
13022 : : }
13023 : :
13024 : 0 : switch (mode) {
13025 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13026 : : strlcpy(buf, "off", sizeof(buf));
13027 : : break;
13028 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13029 : : strlcpy(buf, "auto", sizeof(buf));
13030 : : break;
13031 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13032 : : strlcpy(buf, "baser", sizeof(buf));
13033 : : break;
13034 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13035 : : strlcpy(buf, "rs", sizeof(buf));
13036 : : break;
13037 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13038 : : strlcpy(buf, "llrs", sizeof(buf));
13039 : : break;
13040 : : default:
13041 : : return;
13042 : : }
13043 : :
13044 : : printf("%s\n", buf);
13045 : : }
13046 : :
13047 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13048 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13049 : : cmd_show, "show");
13050 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13051 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13052 : : cmd_port, "port");
13053 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13054 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13055 : : cmd_pid, RTE_UINT16);
13056 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13057 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13058 : : cmd_keyword, "fec_mode");
13059 : :
13060 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13061 : : .f = cmd_show_fec_mode_parsed,
13062 : : .data = NULL,
13063 : : .help_str = "show port <port_id> fec_mode",
13064 : : .tokens = {
13065 : : (void *)&cmd_show_fec_mode_show,
13066 : : (void *)&cmd_show_fec_mode_port,
13067 : : (void *)&cmd_show_fec_mode_pid,
13068 : : (void *)&cmd_show_fec_mode_keyword,
13069 : : NULL,
13070 : : },
13071 : : };
13072 : :
13073 : : /* *** set fec mode per port configuration *** */
13074 : : struct cmd_set_port_fec_mode {
13075 : : cmdline_fixed_string_t set;
13076 : : cmdline_fixed_string_t port;
13077 : : portid_t port_id;
13078 : : cmdline_fixed_string_t fec_mode;
13079 : : cmdline_fixed_string_t fec_value;
13080 : : };
13081 : :
13082 : : /* Common CLI fields for set fec mode */
13083 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13084 : : TOKEN_STRING_INITIALIZER
13085 : : (struct cmd_set_port_fec_mode,
13086 : : set, "set");
13087 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13088 : : TOKEN_STRING_INITIALIZER
13089 : : (struct cmd_set_port_fec_mode,
13090 : : port, "port");
13091 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13092 : : TOKEN_NUM_INITIALIZER
13093 : : (struct cmd_set_port_fec_mode,
13094 : : port_id, RTE_UINT16);
13095 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13096 : : TOKEN_STRING_INITIALIZER
13097 : : (struct cmd_set_port_fec_mode,
13098 : : fec_mode, "fec_mode");
13099 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13100 : : TOKEN_STRING_INITIALIZER
13101 : : (struct cmd_set_port_fec_mode,
13102 : : fec_value, NULL);
13103 : :
13104 : : static void
13105 : 0 : cmd_set_port_fec_mode_parsed(
13106 : : void *parsed_result,
13107 : : __rte_unused struct cmdline *cl,
13108 : : __rte_unused void *data)
13109 : : {
13110 : : struct cmd_set_port_fec_mode *res = parsed_result;
13111 : 0 : uint16_t port_id = res->port_id;
13112 : : uint32_t fec_capa;
13113 : : int ret;
13114 : :
13115 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13116 : 0 : if (ret < 0) {
13117 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13118 : : res->fec_value, port_id);
13119 : 0 : return;
13120 : : }
13121 : :
13122 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13123 : 0 : if (ret == -ENOTSUP) {
13124 : 0 : fprintf(stderr, "Function not implemented\n");
13125 : 0 : return;
13126 : 0 : } else if (ret < 0) {
13127 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13128 : 0 : return;
13129 : : }
13130 : : }
13131 : :
13132 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13133 : : .f = cmd_set_port_fec_mode_parsed,
13134 : : .data = NULL,
13135 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13136 : : .tokens = {
13137 : : (void *)&cmd_set_port_fec_mode_set,
13138 : : (void *)&cmd_set_port_fec_mode_port,
13139 : : (void *)&cmd_set_port_fec_mode_port_id,
13140 : : (void *)&cmd_set_port_fec_mode_str,
13141 : : (void *)&cmd_set_port_fec_mode_value,
13142 : : NULL,
13143 : : },
13144 : : };
13145 : :
13146 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13147 : : struct cmd_set_rxq_avail_thresh_result {
13148 : : cmdline_fixed_string_t set;
13149 : : cmdline_fixed_string_t port;
13150 : : uint16_t port_num;
13151 : : cmdline_fixed_string_t rxq;
13152 : : uint16_t rxq_num;
13153 : : cmdline_fixed_string_t avail_thresh;
13154 : : uint8_t avail_thresh_num;
13155 : : };
13156 : :
13157 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13158 : : __rte_unused struct cmdline *cl,
13159 : : __rte_unused void *data)
13160 : : {
13161 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13162 : : int ret = 0;
13163 : :
13164 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13165 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13166 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13167 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13168 : 0 : res->avail_thresh_num);
13169 : 0 : if (ret < 0)
13170 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13171 : :
13172 : 0 : }
13173 : :
13174 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13175 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13176 : : set, "set");
13177 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13178 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13179 : : port, "port");
13180 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13181 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13182 : : port_num, RTE_UINT16);
13183 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13185 : : rxq, "rxq");
13186 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13187 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13188 : : rxq_num, RTE_UINT16);
13189 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13191 : : avail_thresh, "avail_thresh");
13192 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13193 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13194 : : avail_thresh_num, RTE_UINT8);
13195 : :
13196 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13197 : : .f = cmd_set_rxq_avail_thresh_parsed,
13198 : : .data = (void *)0,
13199 : : .help_str =
13200 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13201 : : "Set available descriptors threshold for Rx queue",
13202 : : .tokens = {
13203 : : (void *)&cmd_set_rxq_avail_thresh_set,
13204 : : (void *)&cmd_set_rxq_avail_thresh_port,
13205 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13206 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13207 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13208 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13209 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13210 : : NULL,
13211 : : },
13212 : : };
13213 : :
13214 : : /* show port supported ptypes */
13215 : :
13216 : : /* Common result structure for show port ptypes */
13217 : : struct cmd_show_port_supported_ptypes_result {
13218 : : cmdline_fixed_string_t show;
13219 : : cmdline_fixed_string_t port;
13220 : : portid_t port_id;
13221 : : cmdline_fixed_string_t ptypes;
13222 : : };
13223 : :
13224 : : /* Common CLI fields for show port ptypes */
13225 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13226 : : TOKEN_STRING_INITIALIZER
13227 : : (struct cmd_show_port_supported_ptypes_result,
13228 : : show, "show");
13229 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13230 : : TOKEN_STRING_INITIALIZER
13231 : : (struct cmd_show_port_supported_ptypes_result,
13232 : : port, "port");
13233 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13234 : : TOKEN_NUM_INITIALIZER
13235 : : (struct cmd_show_port_supported_ptypes_result,
13236 : : port_id, RTE_UINT16);
13237 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13238 : : TOKEN_STRING_INITIALIZER
13239 : : (struct cmd_show_port_supported_ptypes_result,
13240 : : ptypes, "ptypes");
13241 : :
13242 : : static void
13243 : 0 : cmd_show_port_supported_ptypes_parsed(
13244 : : void *parsed_result,
13245 : : __rte_unused struct cmdline *cl,
13246 : : __rte_unused void *data)
13247 : : {
13248 : : #define RSVD_PTYPE_MASK 0xf0000000
13249 : : #define MAX_PTYPES_PER_LAYER 16
13250 : : #define LTYPE_NAMESIZE 32
13251 : : #define PTYPE_NAMESIZE 256
13252 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13253 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13254 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13255 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13256 : 0 : uint16_t port_id = res->port_id;
13257 : : int ret, i;
13258 : :
13259 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13260 : 0 : if (ret < 0)
13261 : 0 : return;
13262 : :
13263 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13264 : :
13265 : 0 : switch (ptype_mask) {
13266 : : case RTE_PTYPE_L2_MASK:
13267 : : strlcpy(ltype, "L2", sizeof(ltype));
13268 : : break;
13269 : : case RTE_PTYPE_L3_MASK:
13270 : : strlcpy(ltype, "L3", sizeof(ltype));
13271 : : break;
13272 : : case RTE_PTYPE_L4_MASK:
13273 : : strlcpy(ltype, "L4", sizeof(ltype));
13274 : : break;
13275 : : case RTE_PTYPE_TUNNEL_MASK:
13276 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13277 : : break;
13278 : : case RTE_PTYPE_INNER_L2_MASK:
13279 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13280 : : break;
13281 : : case RTE_PTYPE_INNER_L3_MASK:
13282 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13283 : : break;
13284 : : case RTE_PTYPE_INNER_L4_MASK:
13285 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13286 : : break;
13287 : : default:
13288 : : return;
13289 : : }
13290 : :
13291 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13292 : : ptype_mask, ptypes,
13293 : : MAX_PTYPES_PER_LAYER);
13294 : :
13295 : 0 : if (ret > 0)
13296 : : printf("Supported %s ptypes:\n", ltype);
13297 : : else
13298 : : printf("%s ptypes unsupported\n", ltype);
13299 : :
13300 : 0 : for (i = 0; i < ret; ++i) {
13301 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13302 : : printf("%s\n", buf);
13303 : : }
13304 : :
13305 : 0 : ptype_mask <<= 4;
13306 : : }
13307 : : }
13308 : :
13309 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13310 : : .f = cmd_show_port_supported_ptypes_parsed,
13311 : : .data = NULL,
13312 : : .help_str = "show port <port_id> ptypes",
13313 : : .tokens = {
13314 : : (void *)&cmd_show_port_supported_ptypes_show,
13315 : : (void *)&cmd_show_port_supported_ptypes_port,
13316 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13317 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13318 : : NULL,
13319 : : },
13320 : : };
13321 : :
13322 : : /* *** display rx/tx descriptor status *** */
13323 : : struct cmd_show_rx_tx_desc_status_result {
13324 : : cmdline_fixed_string_t cmd_show;
13325 : : cmdline_fixed_string_t cmd_port;
13326 : : cmdline_fixed_string_t cmd_keyword;
13327 : : cmdline_fixed_string_t cmd_desc;
13328 : : cmdline_fixed_string_t cmd_status;
13329 : : portid_t cmd_pid;
13330 : : portid_t cmd_qid;
13331 : : portid_t cmd_did;
13332 : : };
13333 : :
13334 : : static void
13335 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13336 : : __rte_unused struct cmdline *cl,
13337 : : __rte_unused void *data)
13338 : : {
13339 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13340 : : int rc;
13341 : :
13342 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13343 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13344 : 0 : fprintf(stderr,
13345 : : "Invalid input: port id = %d, queue id = %d\n",
13346 : 0 : res->cmd_pid, res->cmd_qid);
13347 : 0 : return;
13348 : : }
13349 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13350 : 0 : res->cmd_did);
13351 : 0 : if (rc < 0) {
13352 : 0 : fprintf(stderr,
13353 : : "Invalid input: queue id = %d, desc id = %d\n",
13354 : 0 : res->cmd_qid, res->cmd_did);
13355 : 0 : return;
13356 : : }
13357 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13358 : : printf("Desc status = AVAILABLE\n");
13359 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13360 : : printf("Desc status = DONE\n");
13361 : : else
13362 : : printf("Desc status = UNAVAILABLE\n");
13363 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13364 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13365 : 0 : fprintf(stderr,
13366 : : "Invalid input: port id = %d, queue id = %d\n",
13367 : 0 : res->cmd_pid, res->cmd_qid);
13368 : 0 : return;
13369 : : }
13370 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13371 : 0 : res->cmd_did);
13372 : 0 : if (rc < 0) {
13373 : 0 : fprintf(stderr,
13374 : : "Invalid input: queue id = %d, desc id = %d\n",
13375 : 0 : res->cmd_qid, res->cmd_did);
13376 : 0 : return;
13377 : : }
13378 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13379 : : printf("Desc status = FULL\n");
13380 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13381 : : printf("Desc status = DONE\n");
13382 : : else
13383 : : printf("Desc status = UNAVAILABLE\n");
13384 : : }
13385 : : }
13386 : :
13387 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13388 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13389 : : cmd_show, "show");
13390 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13391 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13392 : : cmd_port, "port");
13393 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13394 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13395 : : cmd_pid, RTE_UINT16);
13396 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13397 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13398 : : cmd_keyword, "rxq#txq");
13399 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13400 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13401 : : cmd_qid, RTE_UINT16);
13402 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13403 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13404 : : cmd_desc, "desc");
13405 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13406 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13407 : : cmd_did, RTE_UINT16);
13408 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13409 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13410 : : cmd_status, "status");
13411 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13412 : : .f = cmd_show_rx_tx_desc_status_parsed,
13413 : : .data = NULL,
13414 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13415 : : "status",
13416 : : .tokens = {
13417 : : (void *)&cmd_show_rx_tx_desc_status_show,
13418 : : (void *)&cmd_show_rx_tx_desc_status_port,
13419 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13420 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13421 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13422 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13423 : : (void *)&cmd_show_rx_tx_desc_status_did,
13424 : : (void *)&cmd_show_rx_tx_desc_status_status,
13425 : : NULL,
13426 : : },
13427 : : };
13428 : :
13429 : : /* *** display rx/tx queue descriptor used count *** */
13430 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13431 : : cmdline_fixed_string_t cmd_show;
13432 : : cmdline_fixed_string_t cmd_port;
13433 : : cmdline_fixed_string_t cmd_dir;
13434 : : cmdline_fixed_string_t cmd_desc;
13435 : : cmdline_fixed_string_t cmd_used;
13436 : : cmdline_fixed_string_t cmd_count;
13437 : : portid_t cmd_pid;
13438 : : portid_t cmd_qid;
13439 : : };
13440 : :
13441 : : static void
13442 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13443 : : __rte_unused void *data)
13444 : : {
13445 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13446 : : int rc;
13447 : :
13448 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13449 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13450 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13451 : 0 : res->cmd_pid, res->cmd_qid);
13452 : 0 : return;
13453 : : }
13454 : :
13455 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13456 : 0 : if (rc < 0) {
13457 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13458 : 0 : res->cmd_qid);
13459 : 0 : return;
13460 : : }
13461 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13462 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13463 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13464 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13465 : 0 : res->cmd_pid, res->cmd_qid);
13466 : 0 : return;
13467 : : }
13468 : :
13469 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13470 : 0 : if (rc < 0) {
13471 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13472 : 0 : res->cmd_qid);
13473 : 0 : return;
13474 : : }
13475 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13476 : : }
13477 : : }
13478 : :
13479 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13480 : : TOKEN_STRING_INITIALIZER
13481 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13482 : : cmd_show, "show");
13483 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13484 : : TOKEN_STRING_INITIALIZER
13485 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13486 : : cmd_port, "port");
13487 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13488 : : TOKEN_NUM_INITIALIZER
13489 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13490 : : cmd_pid, RTE_UINT16);
13491 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13492 : : TOKEN_STRING_INITIALIZER
13493 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13494 : : cmd_dir, "rxq#txq");
13495 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13496 : : TOKEN_NUM_INITIALIZER
13497 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13498 : : cmd_qid, RTE_UINT16);
13499 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13500 : : TOKEN_STRING_INITIALIZER
13501 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13502 : : cmd_desc, "desc");
13503 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13504 : : TOKEN_STRING_INITIALIZER
13505 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13506 : : cmd_count, "used");
13507 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13508 : : TOKEN_STRING_INITIALIZER
13509 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13510 : : cmd_count, "count");
13511 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13512 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13513 : : .data = NULL,
13514 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13515 : : .tokens = {
13516 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13517 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13518 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13519 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13520 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13521 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13522 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13523 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13524 : : NULL,
13525 : : },
13526 : : };
13527 : :
13528 : : /* Common result structure for set port ptypes */
13529 : : struct cmd_set_port_ptypes_result {
13530 : : cmdline_fixed_string_t set;
13531 : : cmdline_fixed_string_t port;
13532 : : portid_t port_id;
13533 : : cmdline_fixed_string_t ptype_mask;
13534 : : uint32_t mask;
13535 : : };
13536 : :
13537 : : /* Common CLI fields for set port ptypes */
13538 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13539 : : TOKEN_STRING_INITIALIZER
13540 : : (struct cmd_set_port_ptypes_result,
13541 : : set, "set");
13542 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13543 : : TOKEN_STRING_INITIALIZER
13544 : : (struct cmd_set_port_ptypes_result,
13545 : : port, "port");
13546 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13547 : : TOKEN_NUM_INITIALIZER
13548 : : (struct cmd_set_port_ptypes_result,
13549 : : port_id, RTE_UINT16);
13550 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13551 : : TOKEN_STRING_INITIALIZER
13552 : : (struct cmd_set_port_ptypes_result,
13553 : : ptype_mask, "ptype_mask");
13554 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13555 : : TOKEN_NUM_INITIALIZER
13556 : : (struct cmd_set_port_ptypes_result,
13557 : : mask, RTE_UINT32);
13558 : :
13559 : : static void
13560 : 0 : cmd_set_port_ptypes_parsed(
13561 : : void *parsed_result,
13562 : : __rte_unused struct cmdline *cl,
13563 : : __rte_unused void *data)
13564 : : {
13565 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13566 : : #define PTYPE_NAMESIZE 256
13567 : : char ptype_name[PTYPE_NAMESIZE];
13568 : 0 : uint16_t port_id = res->port_id;
13569 : 0 : uint32_t ptype_mask = res->mask;
13570 : : int ret, i;
13571 : :
13572 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13573 : : NULL, 0);
13574 : 0 : if (ret <= 0) {
13575 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13576 : : port_id);
13577 : 0 : return;
13578 : : }
13579 : :
13580 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13581 : :
13582 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13583 : 0 : if (ret < 0) {
13584 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13585 : : port_id);
13586 : 0 : return;
13587 : : }
13588 : :
13589 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13590 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13591 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13592 : : printf("%s\n", ptype_name);
13593 : : }
13594 : :
13595 : 0 : clear_ptypes = false;
13596 : : }
13597 : :
13598 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13599 : : .f = cmd_set_port_ptypes_parsed,
13600 : : .data = NULL,
13601 : : .help_str = "set port <port_id> ptype_mask <mask>",
13602 : : .tokens = {
13603 : : (void *)&cmd_set_port_ptypes_set,
13604 : : (void *)&cmd_set_port_ptypes_port,
13605 : : (void *)&cmd_set_port_ptypes_port_id,
13606 : : (void *)&cmd_set_port_ptypes_mask_str,
13607 : : (void *)&cmd_set_port_ptypes_mask_u32,
13608 : : NULL,
13609 : : },
13610 : : };
13611 : :
13612 : : /* *** display mac addresses added to a port *** */
13613 : : struct cmd_showport_macs_result {
13614 : : cmdline_fixed_string_t cmd_show;
13615 : : cmdline_fixed_string_t cmd_port;
13616 : : cmdline_fixed_string_t cmd_keyword;
13617 : : portid_t cmd_pid;
13618 : : };
13619 : :
13620 : : static void
13621 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13622 : : __rte_unused struct cmdline *cl,
13623 : : __rte_unused void *data)
13624 : : {
13625 : : struct cmd_showport_macs_result *res = parsed_result;
13626 : :
13627 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13628 : : return;
13629 : :
13630 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13631 : 0 : show_macs(res->cmd_pid);
13632 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13633 : 0 : show_mcast_macs(res->cmd_pid);
13634 : : }
13635 : :
13636 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13637 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13638 : : cmd_show, "show");
13639 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13640 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13641 : : cmd_port, "port");
13642 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13643 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13644 : : cmd_pid, RTE_UINT16);
13645 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13646 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13647 : : cmd_keyword, "macs#mcast_macs");
13648 : :
13649 : : static cmdline_parse_inst_t cmd_showport_macs = {
13650 : : .f = cmd_showport_macs_parsed,
13651 : : .data = NULL,
13652 : : .help_str = "show port <port_id> macs|mcast_macs",
13653 : : .tokens = {
13654 : : (void *)&cmd_showport_macs_show,
13655 : : (void *)&cmd_showport_macs_port,
13656 : : (void *)&cmd_showport_macs_pid,
13657 : : (void *)&cmd_showport_macs_keyword,
13658 : : NULL,
13659 : : },
13660 : : };
13661 : :
13662 : : /* *** show flow transfer proxy port ID for the given port *** */
13663 : : struct cmd_show_port_flow_transfer_proxy_result {
13664 : : cmdline_fixed_string_t show;
13665 : : cmdline_fixed_string_t port;
13666 : : portid_t port_id;
13667 : : cmdline_fixed_string_t flow;
13668 : : cmdline_fixed_string_t transfer;
13669 : : cmdline_fixed_string_t proxy;
13670 : : };
13671 : :
13672 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13673 : : TOKEN_STRING_INITIALIZER
13674 : : (struct cmd_show_port_flow_transfer_proxy_result,
13675 : : show, "show");
13676 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13677 : : TOKEN_STRING_INITIALIZER
13678 : : (struct cmd_show_port_flow_transfer_proxy_result,
13679 : : port, "port");
13680 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13681 : : TOKEN_NUM_INITIALIZER
13682 : : (struct cmd_show_port_flow_transfer_proxy_result,
13683 : : port_id, RTE_UINT16);
13684 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13685 : : TOKEN_STRING_INITIALIZER
13686 : : (struct cmd_show_port_flow_transfer_proxy_result,
13687 : : flow, "flow");
13688 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13689 : : TOKEN_STRING_INITIALIZER
13690 : : (struct cmd_show_port_flow_transfer_proxy_result,
13691 : : transfer, "transfer");
13692 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13693 : : TOKEN_STRING_INITIALIZER
13694 : : (struct cmd_show_port_flow_transfer_proxy_result,
13695 : : proxy, "proxy");
13696 : :
13697 : : static void
13698 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13699 : : __rte_unused struct cmdline *cl,
13700 : : __rte_unused void *data)
13701 : : {
13702 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13703 : : portid_t proxy_port_id;
13704 : : int ret;
13705 : :
13706 : : printf("\n");
13707 : :
13708 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13709 : 0 : if (ret != 0) {
13710 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13711 : : rte_strerror(-ret));
13712 : 0 : return;
13713 : : }
13714 : :
13715 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13716 : : }
13717 : :
13718 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13719 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13720 : : .data = NULL,
13721 : : .help_str = "show port <port_id> flow transfer proxy",
13722 : : .tokens = {
13723 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13724 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13725 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13726 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13727 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13728 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13729 : : NULL,
13730 : : }
13731 : : };
13732 : :
13733 : : /* *** configure port txq affinity value *** */
13734 : : struct cmd_config_tx_affinity_map {
13735 : : cmdline_fixed_string_t port;
13736 : : cmdline_fixed_string_t config;
13737 : : portid_t portid;
13738 : : cmdline_fixed_string_t txq;
13739 : : uint16_t qid;
13740 : : cmdline_fixed_string_t affinity;
13741 : : uint8_t value;
13742 : : };
13743 : :
13744 : : static void
13745 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13746 : : __rte_unused struct cmdline *cl,
13747 : : __rte_unused void *data)
13748 : : {
13749 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13750 : : int ret;
13751 : :
13752 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13753 : : return;
13754 : :
13755 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13756 : : printf("Invalid port id\n");
13757 : 0 : return;
13758 : : }
13759 : :
13760 : 0 : if (strcmp(res->txq, "txq")) {
13761 : : printf("Unknown parameter\n");
13762 : 0 : return;
13763 : : }
13764 : 0 : if (tx_queue_id_is_invalid(res->qid))
13765 : : return;
13766 : :
13767 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13768 : 0 : if (ret < 0) {
13769 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13770 : : strerror(-ret));
13771 : 0 : return;
13772 : : }
13773 : :
13774 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13775 : 0 : if (ret != 0) {
13776 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13777 : : rte_strerror(-ret));
13778 : 0 : return;
13779 : : }
13780 : : }
13781 : :
13782 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13783 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13784 : : port, "port");
13785 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13786 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13787 : : config, "config");
13788 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13789 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13790 : : portid, RTE_UINT16);
13791 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13792 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13793 : : txq, "txq");
13794 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13795 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13796 : : qid, RTE_UINT16);
13797 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13798 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13799 : : affinity, "affinity");
13800 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13801 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13802 : : value, RTE_UINT8);
13803 : :
13804 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13805 : : .f = cmd_config_tx_affinity_map_parsed,
13806 : : .data = (void *)0,
13807 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13808 : : .tokens = {
13809 : : (void *)&cmd_config_tx_affinity_map_port,
13810 : : (void *)&cmd_config_tx_affinity_map_config,
13811 : : (void *)&cmd_config_tx_affinity_map_portid,
13812 : : (void *)&cmd_config_tx_affinity_map_txq,
13813 : : (void *)&cmd_config_tx_affinity_map_qid,
13814 : : (void *)&cmd_config_tx_affinity_map_affinity,
13815 : : (void *)&cmd_config_tx_affinity_map_value,
13816 : : NULL,
13817 : : },
13818 : : };
13819 : :
13820 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
13821 : : struct cmd_dev_led_result {
13822 : : cmdline_fixed_string_t set;
13823 : : cmdline_fixed_string_t port;
13824 : : portid_t port_id;
13825 : : cmdline_fixed_string_t led;
13826 : : cmdline_fixed_string_t state;
13827 : : };
13828 : :
13829 : : static void
13830 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
13831 : : __rte_unused struct cmdline *cl,
13832 : : __rte_unused void *data)
13833 : : {
13834 : : struct cmd_dev_led_result *res = parsed_result;
13835 : :
13836 : 0 : if (strcmp(res->state, "on") == 0)
13837 : 0 : set_dev_led(res->port_id, true);
13838 : : else
13839 : 0 : set_dev_led(res->port_id, false);
13840 : 0 : }
13841 : :
13842 : : static cmdline_parse_token_string_t cmd_dev_led_set =
13843 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
13844 : : static cmdline_parse_token_string_t cmd_dev_led_port =
13845 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
13846 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
13847 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
13848 : : static cmdline_parse_token_string_t cmd_dev_led =
13849 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
13850 : : static cmdline_parse_token_string_t cmd_dev_state =
13851 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
13852 : :
13853 : : static cmdline_parse_inst_t cmd_set_dev_led = {
13854 : : .f = cmd_set_dev_led_parsed,
13855 : : .data = NULL,
13856 : : .help_str = "set port <port_id> led <on/off>",
13857 : : .tokens = {
13858 : : (void *)&cmd_dev_led_set,
13859 : : (void *)&cmd_dev_led_port,
13860 : : (void *)&cmd_dev_led_port_id,
13861 : : (void *)&cmd_dev_led,
13862 : : (void *)&cmd_dev_state,
13863 : : NULL,
13864 : : },
13865 : : };
13866 : :
13867 : : /* ******************************************************************************** */
13868 : :
13869 : : /* list of instructions */
13870 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13871 : : &cmd_help_brief,
13872 : : &cmd_help_long,
13873 : : &cmd_quit,
13874 : : &cmd_load_from_file,
13875 : : &cmd_showport,
13876 : : &cmd_showqueue,
13877 : : &cmd_showeeprom,
13878 : : &cmd_seteeprom,
13879 : : &cmd_showportall,
13880 : : &cmd_representor_info,
13881 : : &cmd_showdevice,
13882 : : &cmd_showcfg,
13883 : : &cmd_showfwdall,
13884 : : &cmd_start,
13885 : : &cmd_start_tx_first,
13886 : : &cmd_start_tx_first_n,
13887 : : &cmd_set_link_up,
13888 : : &cmd_set_link_down,
13889 : : &cmd_reset,
13890 : : &cmd_set_numbers,
13891 : : &cmd_set_log,
13892 : : &cmd_set_rxoffs,
13893 : : &cmd_set_rxpkts,
13894 : : &cmd_set_rxhdrs,
13895 : : &cmd_set_txpkts,
13896 : : &cmd_set_txsplit,
13897 : : &cmd_set_txtimes,
13898 : : &cmd_set_fwd_list,
13899 : : &cmd_set_fwd_mask,
13900 : : &cmd_set_fwd_mode,
13901 : : &cmd_set_fwd_retry_mode,
13902 : : &cmd_set_burst_tx_retry,
13903 : : &cmd_set_promisc_mode_one,
13904 : : &cmd_set_promisc_mode_all,
13905 : : &cmd_set_allmulti_mode_one,
13906 : : &cmd_set_allmulti_mode_all,
13907 : : &cmd_set_flush_rx,
13908 : : &cmd_set_link_check,
13909 : : &cmd_vlan_offload,
13910 : : &cmd_vlan_tpid,
13911 : : &cmd_rx_vlan_filter_all,
13912 : : &cmd_rx_vlan_filter,
13913 : : &cmd_tx_vlan_set,
13914 : : &cmd_tx_vlan_set_qinq,
13915 : : &cmd_tx_vlan_reset,
13916 : : &cmd_tx_vlan_set_pvid,
13917 : : &cmd_csum_set,
13918 : : &cmd_csum_show,
13919 : : &cmd_csum_tunnel,
13920 : : &cmd_csum_mac_swap,
13921 : : &cmd_tso_set,
13922 : : &cmd_tso_show,
13923 : : &cmd_tunnel_tso_set,
13924 : : &cmd_tunnel_tso_show,
13925 : : #ifdef RTE_LIB_GRO
13926 : : &cmd_gro_enable,
13927 : : &cmd_gro_flush,
13928 : : &cmd_gro_show,
13929 : : #endif
13930 : : #ifdef RTE_LIB_GSO
13931 : : &cmd_gso_enable,
13932 : : &cmd_gso_size,
13933 : : &cmd_gso_show,
13934 : : #endif
13935 : : &cmd_link_flow_control_set,
13936 : : &cmd_link_flow_control_set_rx,
13937 : : &cmd_link_flow_control_set_tx,
13938 : : &cmd_link_flow_control_set_hw,
13939 : : &cmd_link_flow_control_set_lw,
13940 : : &cmd_link_flow_control_set_pt,
13941 : : &cmd_link_flow_control_set_xon,
13942 : : &cmd_link_flow_control_set_macfwd,
13943 : : &cmd_link_flow_control_set_autoneg,
13944 : : &cmd_link_flow_control_show,
13945 : : &cmd_priority_flow_control_set,
13946 : : &cmd_queue_priority_flow_control_set,
13947 : : &cmd_config_dcb,
13948 : : &cmd_read_rxd_txd,
13949 : : &cmd_stop,
13950 : : &cmd_mac_addr,
13951 : : &cmd_set_fwd_eth_peer,
13952 : : &cmd_set_qmap,
13953 : : &cmd_set_xstats_hide_zero,
13954 : : &cmd_set_xstats_show_state,
13955 : : &cmd_set_xstats_hide_disabled,
13956 : : &cmd_operate_set_counter,
13957 : : &cmd_set_record_core_cycles,
13958 : : &cmd_set_record_burst_stats,
13959 : : &cmd_operate_port,
13960 : : &cmd_operate_specific_port,
13961 : : &cmd_operate_attach_port,
13962 : : &cmd_operate_detach_port,
13963 : : &cmd_operate_detach_device,
13964 : : &cmd_set_port_setup_on,
13965 : : &cmd_config_speed_all,
13966 : : &cmd_config_speed_specific,
13967 : : &cmd_config_speed_lanes_all,
13968 : : &cmd_config_speed_lanes_specific,
13969 : : &cmd_show_speed_lanes,
13970 : : &cmd_config_loopback_all,
13971 : : &cmd_config_loopback_specific,
13972 : : &cmd_config_rx_tx,
13973 : : &cmd_config_mtu,
13974 : : &cmd_config_max_pkt_len,
13975 : : &cmd_config_max_lro_pkt_size,
13976 : : &cmd_config_rx_mode_flag,
13977 : : &cmd_config_rss,
13978 : : &cmd_config_rxtx_ring_size,
13979 : : &cmd_config_rxtx_queue,
13980 : : &cmd_config_deferred_start_rxtx_queue,
13981 : : &cmd_setup_rxtx_queue,
13982 : : &cmd_config_rss_reta,
13983 : : &cmd_showport_reta,
13984 : : &cmd_showport_macs,
13985 : : &cmd_show_port_flow_transfer_proxy,
13986 : : &cmd_config_burst,
13987 : : &cmd_config_thresh,
13988 : : &cmd_config_threshold,
13989 : : &cmd_set_uc_hash_filter,
13990 : : &cmd_set_uc_all_hash_filter,
13991 : : &cmd_vf_mac_addr_filter,
13992 : : &cmd_queue_rate_limit,
13993 : : &cmd_tunnel_udp_config,
13994 : : &cmd_showport_rss_hash,
13995 : : &cmd_showport_rss_hash_key,
13996 : : &cmd_showport_rss_hash_algo,
13997 : : &cmd_config_rss_hash_key,
13998 : : &cmd_config_rss_hash_algo,
13999 : : &cmd_cleanup_txq_mbufs,
14000 : : &cmd_dump,
14001 : : &cmd_dump_one,
14002 : : &cmd_flow,
14003 : : &cmd_show_port_meter_cap,
14004 : : &cmd_add_port_meter_profile_srtcm,
14005 : : &cmd_add_port_meter_profile_trtcm,
14006 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14007 : : &cmd_del_port_meter_profile,
14008 : : &cmd_create_port_meter,
14009 : : &cmd_enable_port_meter,
14010 : : &cmd_disable_port_meter,
14011 : : &cmd_del_port_meter,
14012 : : &cmd_del_port_meter_policy,
14013 : : &cmd_set_port_meter_profile,
14014 : : &cmd_set_port_meter_dscp_table,
14015 : : &cmd_set_port_meter_vlan_table,
14016 : : &cmd_set_port_meter_in_proto,
14017 : : &cmd_get_port_meter_in_proto,
14018 : : &cmd_get_port_meter_in_proto_prio,
14019 : : &cmd_set_port_meter_stats_mask,
14020 : : &cmd_show_port_meter_stats,
14021 : : &cmd_mcast_addr,
14022 : : &cmd_mcast_addr_flush,
14023 : : &cmd_set_vf_vlan_anti_spoof,
14024 : : &cmd_set_vf_mac_anti_spoof,
14025 : : &cmd_set_vf_vlan_stripq,
14026 : : &cmd_set_vf_vlan_insert,
14027 : : &cmd_set_tx_loopback,
14028 : : &cmd_set_all_queues_drop_en,
14029 : : &cmd_set_vf_traffic,
14030 : : &cmd_set_vf_rxmode,
14031 : : &cmd_vf_rate_limit,
14032 : : &cmd_vf_rxvlan_filter,
14033 : : &cmd_set_vf_mac_addr,
14034 : : &cmd_set_vxlan,
14035 : : &cmd_set_vxlan_tos_ttl,
14036 : : &cmd_set_vxlan_with_vlan,
14037 : : &cmd_set_nvgre,
14038 : : &cmd_set_nvgre_with_vlan,
14039 : : &cmd_set_l2_encap,
14040 : : &cmd_set_l2_encap_with_vlan,
14041 : : &cmd_set_l2_decap,
14042 : : &cmd_set_l2_decap_with_vlan,
14043 : : &cmd_set_mplsogre_encap,
14044 : : &cmd_set_mplsogre_encap_with_vlan,
14045 : : &cmd_set_mplsogre_decap,
14046 : : &cmd_set_mplsogre_decap_with_vlan,
14047 : : &cmd_set_mplsoudp_encap,
14048 : : &cmd_set_mplsoudp_encap_with_vlan,
14049 : : &cmd_set_mplsoudp_decap,
14050 : : &cmd_set_mplsoudp_decap_with_vlan,
14051 : : &cmd_set_conntrack_common,
14052 : : &cmd_set_conntrack_dir,
14053 : : &cmd_show_vf_stats,
14054 : : &cmd_clear_vf_stats,
14055 : : &cmd_show_port_supported_ptypes,
14056 : : &cmd_set_port_ptypes,
14057 : : &cmd_show_port_tm_cap,
14058 : : &cmd_show_port_tm_level_cap,
14059 : : &cmd_show_port_tm_node,
14060 : : &cmd_show_port_tm_node_cap,
14061 : : &cmd_show_port_tm_node_type,
14062 : : &cmd_show_port_tm_node_stats,
14063 : : &cmd_add_port_tm_node_shaper_profile,
14064 : : &cmd_del_port_tm_node_shaper_profile,
14065 : : &cmd_add_port_tm_node_shared_shaper,
14066 : : &cmd_del_port_tm_node_shared_shaper,
14067 : : &cmd_add_port_tm_node_wred_profile,
14068 : : &cmd_del_port_tm_node_wred_profile,
14069 : : &cmd_set_port_tm_node_shaper_profile,
14070 : : &cmd_add_port_tm_nonleaf_node,
14071 : : &cmd_add_port_tm_nonleaf_node_pmode,
14072 : : &cmd_add_port_tm_leaf_node,
14073 : : &cmd_del_port_tm_node,
14074 : : &cmd_set_port_tm_node_parent,
14075 : : &cmd_suspend_port_tm_node,
14076 : : &cmd_resume_port_tm_node,
14077 : : &cmd_port_tm_hierarchy_commit,
14078 : : &cmd_port_tm_mark_ip_ecn,
14079 : : &cmd_port_tm_mark_ip_dscp,
14080 : : &cmd_port_tm_mark_vlan_dei,
14081 : : &cmd_cfg_tunnel_udp_port,
14082 : : &cmd_rx_offload_get_capa,
14083 : : &cmd_rx_offload_get_configuration,
14084 : : &cmd_config_per_port_rx_offload,
14085 : : &cmd_config_all_port_rx_offload,
14086 : : &cmd_config_per_queue_rx_offload,
14087 : : &cmd_tx_offload_get_capa,
14088 : : &cmd_tx_offload_get_configuration,
14089 : : &cmd_config_per_port_tx_offload,
14090 : : &cmd_config_all_port_tx_offload,
14091 : : &cmd_config_per_queue_tx_offload,
14092 : : #ifdef RTE_LIB_BPF
14093 : : &cmd_operate_bpf_ld_parse,
14094 : : &cmd_operate_bpf_unld_parse,
14095 : : #endif
14096 : : &cmd_config_tx_metadata_specific,
14097 : : &cmd_show_tx_metadata,
14098 : : &cmd_show_rx_tx_desc_status,
14099 : : &cmd_show_rx_tx_queue_desc_used_count,
14100 : : &cmd_set_raw,
14101 : : &cmd_show_set_raw,
14102 : : &cmd_show_set_raw_all,
14103 : : &cmd_config_tx_dynf_specific,
14104 : : &cmd_show_fec_mode,
14105 : : &cmd_set_fec_mode,
14106 : : &cmd_set_rxq_avail_thresh,
14107 : : &cmd_show_capability,
14108 : : &cmd_set_flex_is_pattern,
14109 : : &cmd_set_flex_spec_pattern,
14110 : : &cmd_show_port_cman_capa,
14111 : : &cmd_show_port_cman_config,
14112 : : &cmd_set_port_cman_config,
14113 : : &cmd_config_tx_affinity_map,
14114 : : &cmd_set_dev_led,
14115 : : NULL,
14116 : : };
14117 : :
14118 : : void
14119 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14120 : : {
14121 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14122 : 0 : }
14123 : :
14124 : : int
14125 : 0 : init_cmdline(void)
14126 : : {
14127 : : struct testpmd_driver_commands *c;
14128 : : unsigned int count;
14129 : : unsigned int i;
14130 : :
14131 : : /* initialize non-constant commands */
14132 : 0 : cmd_set_fwd_mode_init();
14133 : 0 : cmd_set_fwd_retry_mode_init();
14134 : : cmd_dump_init();
14135 : :
14136 : : count = 0;
14137 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14138 : 0 : count++;
14139 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14140 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14141 : 0 : count++;
14142 : : }
14143 : :
14144 : : /* cmdline expects a NULL terminated array */
14145 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14146 : 0 : if (main_ctx == NULL)
14147 : : return -1;
14148 : :
14149 : : count = 0;
14150 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14151 : 0 : main_ctx[count] = builtin_ctx[i];
14152 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14153 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14154 : 0 : main_ctx[count] = c->commands[i].ctx;
14155 : : }
14156 : :
14157 : : return 0;
14158 : : }
14159 : :
14160 : : /* read cmdline commands from file */
14161 : : void
14162 : 0 : cmdline_read_from_file(const char *filename)
14163 : : {
14164 : : struct cmdline *cl;
14165 : : int fd = -1;
14166 : :
14167 : : /* cmdline_file_new does not produce any output
14168 : : * so when echoing is requested we open filename directly
14169 : : * and then pass that to cmdline_new with stdout as the output path.
14170 : : */
14171 : 0 : if (!echo_cmdline_file) {
14172 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14173 : : } else {
14174 : : fd = open(filename, O_RDONLY);
14175 : 0 : if (fd < 0) {
14176 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14177 : 0 : filename, strerror(errno));
14178 : 0 : return;
14179 : : }
14180 : :
14181 : 0 : cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO);
14182 : : }
14183 : 0 : if (cl == NULL) {
14184 : 0 : fprintf(stderr,
14185 : : "Failed to create file based cmdline context: %s\n",
14186 : : filename);
14187 : 0 : goto end;
14188 : : }
14189 : :
14190 : 0 : cmdline_interact(cl);
14191 : 0 : cmdline_quit(cl);
14192 : :
14193 : 0 : cmdline_free(cl);
14194 : :
14195 : : printf("Read CLI commands from %s\n", filename);
14196 : :
14197 : 0 : end:
14198 : 0 : if (fd >= 0)
14199 : 0 : close(fd);
14200 : : }
14201 : :
14202 : : void
14203 : 0 : prompt_exit(void)
14204 : : {
14205 : 0 : cmdline_quit(testpmd_cl);
14206 : 0 : }
14207 : :
14208 : : /* prompt function, called from main on MAIN lcore */
14209 : : void
14210 : 0 : prompt(void)
14211 : : {
14212 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14213 : 0 : if (testpmd_cl == NULL) {
14214 : 0 : fprintf(stderr,
14215 : : "Failed to create stdin based cmdline context\n");
14216 : 0 : return;
14217 : : }
14218 : :
14219 : 0 : cmdline_interact(testpmd_cl);
14220 : 0 : cmdline_stdin_exit(testpmd_cl);
14221 : : }
14222 : :
14223 : : void
14224 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14225 : : {
14226 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14227 : : portid_t pid;
14228 : :
14229 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14230 : : /* check if need_reconfig has been set to 1 */
14231 : 0 : if (ports[pid].need_reconfig == 0)
14232 : 0 : ports[pid].need_reconfig = dev;
14233 : : /* check if need_reconfig_queues has been set to 1 */
14234 : 0 : if (ports[pid].need_reconfig_queues == 0)
14235 : 0 : ports[pid].need_reconfig_queues = queue;
14236 : : }
14237 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14238 : : /* check if need_reconfig has been set to 1 */
14239 : 0 : if (ports[id].need_reconfig == 0)
14240 : 0 : ports[id].need_reconfig = dev;
14241 : : /* check if need_reconfig_queues has been set to 1 */
14242 : 0 : if (ports[id].need_reconfig_queues == 0)
14243 : 0 : ports[id].need_reconfig_queues = queue;
14244 : : }
14245 : 0 : }
|