Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <stdio.h>
10 : : #include <stdint.h>
11 : : #include <stdlib.h>
12 : : #include <string.h>
13 : : #include <unistd.h>
14 : : #include <inttypes.h>
15 : : #include <sys/queue.h>
16 : :
17 : : #include <rte_common.h>
18 : : #include <rte_byteorder.h>
19 : : #include <rte_log.h>
20 : : #include <rte_debug.h>
21 : : #include <rte_cycles.h>
22 : : #include <rte_memory.h>
23 : : #include <rte_memzone.h>
24 : : #include <rte_malloc.h>
25 : : #include <rte_launch.h>
26 : : #include <rte_eal.h>
27 : : #include <rte_per_lcore.h>
28 : : #include <rte_lcore.h>
29 : : #include <rte_branch_prediction.h>
30 : : #include <rte_ring.h>
31 : : #include <rte_mempool.h>
32 : : #include <rte_interrupts.h>
33 : : #include <rte_ether.h>
34 : : #include <rte_ethdev.h>
35 : : #include <rte_string_fns.h>
36 : : #include <rte_devargs.h>
37 : : #include <rte_flow.h>
38 : : #ifdef RTE_LIB_GRO
39 : : #include <rte_gro.h>
40 : : #endif
41 : : #include <rte_mbuf_dyn.h>
42 : : #include <rte_trace.h>
43 : :
44 : : #include <cmdline_rdline.h>
45 : : #include <cmdline_parse.h>
46 : : #include <cmdline_parse_num.h>
47 : : #include <cmdline_parse_string.h>
48 : : #include <cmdline_parse_ipaddr.h>
49 : : #include <cmdline_parse_etheraddr.h>
50 : : #include <cmdline_socket.h>
51 : : #include <cmdline.h>
52 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
53 : : #include <rte_pmd_dpaa.h>
54 : : #endif
55 : : #ifdef RTE_NET_IXGBE
56 : : #include <rte_pmd_ixgbe.h>
57 : : #endif
58 : : #ifdef RTE_NET_I40E
59 : : #include <rte_pmd_i40e.h>
60 : : #endif
61 : : #ifdef RTE_NET_BNXT
62 : : #include <rte_pmd_bnxt.h>
63 : : #endif
64 : : #include "testpmd.h"
65 : : #include "cmdline_cman.h"
66 : : #include "cmdline_mtr.h"
67 : : #include "cmdline_tm.h"
68 : : #include "bpf_cmd.h"
69 : :
70 : : static struct cmdline *testpmd_cl;
71 : : static cmdline_parse_ctx_t *main_ctx;
72 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
73 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
74 : :
75 : : /* *** Help command with introduction. *** */
76 : : struct cmd_help_brief_result {
77 : : cmdline_fixed_string_t help;
78 : : };
79 : :
80 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 : : struct cmdline *cl,
82 : : __rte_unused void *data)
83 : : {
84 : 0 : cmdline_printf(
85 : : cl,
86 : : "\n"
87 : : "Help is available for the following sections:\n\n"
88 : : " help control : Start and stop forwarding.\n"
89 : : " help display : Displaying port, stats and config "
90 : : "information.\n"
91 : : " help config : Configuration information.\n"
92 : : " help ports : Configuring ports.\n"
93 : : " help filters : Filters configuration help.\n"
94 : : " help traffic_management : Traffic Management commands.\n"
95 : : " help devices : Device related commands.\n"
96 : : " help drivers : Driver specific commands.\n"
97 : : " help all : All of the above sections.\n\n"
98 : : );
99 : :
100 : 0 : }
101 : :
102 : : static cmdline_parse_token_string_t cmd_help_brief_help =
103 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 : :
105 : : static cmdline_parse_inst_t cmd_help_brief = {
106 : : .f = cmd_help_brief_parsed,
107 : : .data = NULL,
108 : : .help_str = "help: Show help",
109 : : .tokens = {
110 : : (void *)&cmd_help_brief_help,
111 : : NULL,
112 : : },
113 : : };
114 : :
115 : : /* *** Help command with help sections. *** */
116 : : struct cmd_help_long_result {
117 : : cmdline_fixed_string_t help;
118 : : cmdline_fixed_string_t section;
119 : : };
120 : :
121 : 0 : static void cmd_help_long_parsed(void *parsed_result,
122 : : struct cmdline *cl,
123 : : __rte_unused void *data)
124 : : {
125 : : int show_all = 0;
126 : : struct cmd_help_long_result *res = parsed_result;
127 : :
128 : 0 : if (!strcmp(res->section, "all"))
129 : : show_all = 1;
130 : :
131 : 0 : if (show_all || !strcmp(res->section, "control")) {
132 : :
133 : 0 : cmdline_printf(
134 : : cl,
135 : : "\n"
136 : : "Control forwarding:\n"
137 : : "-------------------\n\n"
138 : :
139 : : "start\n"
140 : : " Start packet forwarding with current configuration.\n\n"
141 : :
142 : : "start tx_first\n"
143 : : " Start packet forwarding with current config"
144 : : " after sending one burst of packets.\n\n"
145 : :
146 : : "stop\n"
147 : : " Stop packet forwarding, and display accumulated"
148 : : " statistics.\n\n"
149 : :
150 : : "quit\n"
151 : : " Quit to prompt.\n\n"
152 : : );
153 : : }
154 : :
155 : 0 : if (show_all || !strcmp(res->section, "display")) {
156 : :
157 : 0 : cmdline_printf(
158 : : cl,
159 : : "\n"
160 : : "Display:\n"
161 : : "--------\n\n"
162 : :
163 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 : : " Display information for port_id, or all.\n\n"
165 : :
166 : : "show port info (port_id) representor\n"
167 : : " Show supported representors for a specific port\n\n"
168 : :
169 : : "show port port_id (module_eeprom|eeprom)\n"
170 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
171 : :
172 : : "show port X rss reta (size) (mask0,mask1,...)\n"
173 : : " Display the rss redirection table entry indicated"
174 : : " by masks on port X. size is used to indicate the"
175 : : " hardware supported reta size\n\n"
176 : :
177 : : "show port (port_id) rss-hash [key | algorithm]\n"
178 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
179 : :
180 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 : : " Clear information for port_id, or all.\n\n"
182 : :
183 : : "show (rxq|txq) info (port_id) (queue_id)\n"
184 : : " Display information for configured RX/TX queue.\n\n"
185 : :
186 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
187 : : " Display the given configuration.\n\n"
188 : :
189 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
190 : : " Display an RX descriptor of a port RX queue.\n\n"
191 : :
192 : : "read txd (port_id) (queue_id) (txd_id)\n"
193 : : " Display a TX descriptor of a port TX queue.\n\n"
194 : :
195 : : "show vf stats (port_id) (vf_id)\n"
196 : : " Display a VF's statistics.\n\n"
197 : :
198 : : "clear vf stats (port_id) (vf_id)\n"
199 : : " Reset a VF's statistics.\n\n"
200 : :
201 : : "show port meter stats (port_id) (meter_id) (clear)\n"
202 : : " Get meter stats on a port\n\n"
203 : :
204 : : "show fwd stats all\n"
205 : : " Display statistics for all fwd engines.\n\n"
206 : :
207 : : "clear fwd stats all\n"
208 : : " Clear statistics for all fwd engines.\n\n"
209 : :
210 : : "show port (port_id) rx_offload capabilities\n"
211 : : " List all per queue and per port Rx offloading"
212 : : " capabilities of a port\n\n"
213 : :
214 : : "show port (port_id) rx_offload configuration\n"
215 : : " List port level and all queue level"
216 : : " Rx offloading configuration\n\n"
217 : :
218 : : "show port (port_id) tx_offload capabilities\n"
219 : : " List all per queue and per port"
220 : : " Tx offloading capabilities of a port\n\n"
221 : :
222 : : "show port (port_id) tx_offload configuration\n"
223 : : " List port level and all queue level"
224 : : " Tx offloading configuration\n\n"
225 : :
226 : : "show port (port_id) tx_metadata\n"
227 : : " Show Tx metadata value set"
228 : : " for a specific port\n\n"
229 : :
230 : : "show port (port_id) ptypes\n"
231 : : " Show port supported ptypes"
232 : : " for a specific port\n\n"
233 : :
234 : : "show device info (<identifier>|all)"
235 : : " Show general information about devices probed.\n\n"
236 : :
237 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
238 : : " Show status of rx|tx descriptor.\n\n"
239 : :
240 : : "show port (port_id) rxq (queue_id) desc used count\n"
241 : : " Show current number of filled receive"
242 : : " packet descriptors.\n\n"
243 : :
244 : : "show port (port_id) macs|mcast_macs"
245 : : " Display list of mac addresses added to port.\n\n"
246 : :
247 : : "show port (port_id) flow transfer proxy\n"
248 : : " Display proxy port to manage transfer flows\n\n"
249 : :
250 : : "show port (port_id) fec capabilities"
251 : : " Show fec capabilities of a port.\n\n"
252 : :
253 : : "show port (port_id) fec_mode"
254 : : " Show fec mode of a port.\n\n"
255 : :
256 : : "show port (port_id) flow_ctrl"
257 : : " Show flow control info of a port.\n\n"
258 : :
259 : : "dump_physmem\n"
260 : : " Dumps all physical memory segment layouts\n\n"
261 : :
262 : : "dump_socket_mem\n"
263 : : " Dumps the memory usage of all sockets\n\n"
264 : :
265 : : "dump_memzone\n"
266 : : " Dumps the layout of all memory zones\n\n"
267 : :
268 : : "dump_struct_sizes\n"
269 : : " Dumps the size of all memory structures\n\n"
270 : :
271 : : "dump_ring\n"
272 : : " Dumps the status of all or specific element in DPDK rings\n\n"
273 : :
274 : : "dump_mempool\n"
275 : : " Dumps the statistics of all or specific memory pool\n\n"
276 : :
277 : : "dump_devargs\n"
278 : : " Dumps the user device list\n\n"
279 : :
280 : : "dump_lcores\n"
281 : : " Dumps the logical cores list\n\n"
282 : :
283 : : "dump_trace\n"
284 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
285 : :
286 : : "dump_log_types\n"
287 : : " Dumps the log level for all the dpdk modules\n\n"
288 : : );
289 : : }
290 : :
291 : 0 : if (show_all || !strcmp(res->section, "config")) {
292 : 0 : cmdline_printf(
293 : : cl,
294 : : "\n"
295 : : "Configuration:\n"
296 : : "--------------\n"
297 : : "Configuration changes only become active when"
298 : : " forwarding is started/restarted.\n\n"
299 : :
300 : : "set default\n"
301 : : " Reset forwarding to the default configuration.\n\n"
302 : :
303 : : "set verbose (level)\n"
304 : : " Set the debug verbosity level X.\n\n"
305 : :
306 : : "set log global|(type) (level)\n"
307 : : " Set the log level.\n\n"
308 : :
309 : : "set nbport (num)\n"
310 : : " Set number of ports.\n\n"
311 : :
312 : : "set nbcore (num)\n"
313 : : " Set number of cores.\n\n"
314 : :
315 : : "set coremask (mask)\n"
316 : : " Set the forwarding cores hexadecimal mask.\n\n"
317 : :
318 : : "set portmask (mask)\n"
319 : : " Set the forwarding ports hexadecimal mask.\n\n"
320 : :
321 : : "set burst (num)\n"
322 : : " Set number of packets per burst.\n\n"
323 : :
324 : : "set burst tx delay (microseconds) retry (num)\n"
325 : : " Set the transmit delay time and number of retries,"
326 : : " effective when retry is enabled.\n\n"
327 : :
328 : : "set rxoffs (x[,y]*)\n"
329 : : " Set the offset of each packet segment on"
330 : : " receiving if split feature is engaged."
331 : : " Affects only the queues configured with split"
332 : : " offloads.\n\n"
333 : :
334 : : "set rxpkts (x[,y]*)\n"
335 : : " Set the length of each segment to scatter"
336 : : " packets on receiving if split feature is engaged."
337 : : " Affects only the queues configured with split"
338 : : " offloads.\n\n"
339 : :
340 : : "set rxhdrs (eth[,ipv4])*\n"
341 : : " Set the protocol hdr of each segment to scatter"
342 : : " packets on receiving if split feature is engaged."
343 : : " Affects only the queues configured with split"
344 : : " offloads.\n"
345 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
346 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
347 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
348 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
349 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
350 : :
351 : : "set txpkts (x[,y]*)\n"
352 : : " Set the length of each segment of TXONLY"
353 : : " and optionally CSUM packets.\n\n"
354 : :
355 : : "set txsplit (off|on|rand)\n"
356 : : " Set the split policy for the TX packets."
357 : : " Right now only applicable for CSUM and TXONLY"
358 : : " modes\n\n"
359 : :
360 : : "set txtimes (x, y)\n"
361 : : " Set the scheduling on timestamps"
362 : : " timings for the TXONLY mode\n\n"
363 : :
364 : : "set corelist (x[,y]*)\n"
365 : : " Set the list of forwarding cores.\n\n"
366 : :
367 : : "set portlist (x[,y]*)\n"
368 : : " Set the list of forwarding ports.\n\n"
369 : :
370 : : "set port setup on (iterator|event)\n"
371 : : " Select how attached port is retrieved for setup.\n\n"
372 : :
373 : : "set tx loopback (port_id) (on|off)\n"
374 : : " Enable or disable tx loopback.\n\n"
375 : :
376 : : "set all queues drop (port_id) (on|off)\n"
377 : : " Set drop enable bit for all queues.\n\n"
378 : :
379 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
380 : : " Set MAC antispoof for a VF from the PF.\n\n"
381 : :
382 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
383 : : " Set the VLAN strip for a queue on a port.\n\n"
384 : :
385 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
386 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
387 : :
388 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
389 : : " Set VLAN insert for a VF from the PF.\n\n"
390 : :
391 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
392 : : " Set VLAN antispoof for a VF from the PF.\n\n"
393 : :
394 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
395 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
396 : :
397 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
398 : : " Set the VLAN TPID for Packet Filtering on"
399 : : " a port\n\n"
400 : :
401 : : "rx_vlan add (vlan_id|all) (port_id)\n"
402 : : " Add a vlan_id, or all identifiers, to the set"
403 : : " of VLAN identifiers filtered by port_id.\n\n"
404 : :
405 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
406 : : " Remove a vlan_id, or all identifiers, from the set"
407 : : " of VLAN identifiers filtered by port_id.\n\n"
408 : :
409 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
410 : : " Add a vlan_id, to the set of VLAN identifiers"
411 : : "filtered for VF(s) from port_id.\n\n"
412 : :
413 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
414 : : " Remove a vlan_id, to the set of VLAN identifiers"
415 : : "filtered for VF(s) from port_id.\n\n"
416 : :
417 : : "rx_vxlan_port add (udp_port) (port_id)\n"
418 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
419 : :
420 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
421 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
422 : :
423 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
424 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
425 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
426 : :
427 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
428 : : " Set port based TX VLAN insertion.\n\n"
429 : :
430 : : "tx_vlan reset (port_id)\n"
431 : : " Disable hardware insertion of a VLAN header in"
432 : : " packets sent on a port.\n\n"
433 : :
434 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
435 : : " Select hardware or software calculation of the"
436 : : " checksum when transmitting a packet using the"
437 : : " csum forward engine.\n"
438 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
439 : : " outer-ip concerns the outer IP layer in"
440 : : " outer-udp concerns the outer UDP layer in"
441 : : " case the packet is recognized as a tunnel packet by"
442 : : " the forward engine (vxlan, gre and ipip are supported)\n"
443 : : " Please check the NIC datasheet for HW limits.\n\n"
444 : :
445 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
446 : : " If disabled, treat tunnel packets as non-tunneled"
447 : : " packets (treat inner headers as payload). The port\n"
448 : : " argument is the port used for TX in csum forward"
449 : : " engine.\n\n"
450 : :
451 : : "csum show (port_id)\n"
452 : : " Display tx checksum offload configuration\n\n"
453 : :
454 : : "tso set (segsize) (portid)\n"
455 : : " Enable TCP Segmentation Offload in csum forward"
456 : : " engine.\n"
457 : : " Please check the NIC datasheet for HW limits.\n\n"
458 : :
459 : : "tso show (portid)"
460 : : " Display the status of TCP Segmentation Offload.\n\n"
461 : :
462 : : #ifdef RTE_LIB_GRO
463 : : "set port (port_id) gro on|off\n"
464 : : " Enable or disable Generic Receive Offload in"
465 : : " csum forwarding engine.\n\n"
466 : :
467 : : "show port (port_id) gro\n"
468 : : " Display GRO configuration.\n\n"
469 : :
470 : : "set gro flush (cycles)\n"
471 : : " Set the cycle to flush GROed packets from"
472 : : " reassembly tables.\n\n"
473 : : #endif
474 : :
475 : : #ifdef RTE_LIB_GSO
476 : : "set port (port_id) gso (on|off)"
477 : : " Enable or disable Generic Segmentation Offload in"
478 : : " csum forwarding engine.\n\n"
479 : :
480 : : "set gso segsz (length)\n"
481 : : " Set max packet length for output GSO segments,"
482 : : " including packet header and payload.\n\n"
483 : :
484 : : "show port (port_id) gso\n"
485 : : " Show GSO configuration.\n\n"
486 : : #endif
487 : :
488 : : "set fwd (%s)\n"
489 : : " Set packet forwarding mode.\n\n"
490 : :
491 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
492 : : " Add a MAC address on port_id.\n\n"
493 : :
494 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
495 : : " Remove a MAC address from port_id.\n\n"
496 : :
497 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
498 : : " Set the default MAC address for port_id.\n\n"
499 : :
500 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
501 : : " Add a MAC address for a VF on the port.\n\n"
502 : :
503 : : "mcast_addr add (port_id) (mcast_addr)\n"
504 : : " Add a multicast MAC addresses on port_id.\n\n"
505 : :
506 : : "mcast_addr remove (port_id) (mcast_addr)\n"
507 : : " Remove a multicast MAC address from port_id.\n\n"
508 : :
509 : : "mcast_addr flush (port_id)\n"
510 : : " Flush all multicast MAC addresses on port_id.\n\n"
511 : :
512 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
513 : : " Set the MAC address for a VF from the PF.\n\n"
514 : :
515 : : "set eth-peer (port_id) (peer_addr)\n"
516 : : " set the peer address for certain port.\n\n"
517 : :
518 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
519 : : " Add/Remove a or all unicast hash filter(s)"
520 : : "from port X.\n\n"
521 : :
522 : : "set promisc (port_id|all) (on|off)\n"
523 : : " Set the promiscuous mode on port_id, or all.\n\n"
524 : :
525 : : "set allmulti (port_id|all) (on|off)\n"
526 : : " Set the allmulti mode on port_id, or all.\n\n"
527 : :
528 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
529 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
530 : : " (on|off) autoneg (on|off) (port_id)\n"
531 : : "set flow_ctrl rx (on|off) (portid)\n"
532 : : "set flow_ctrl tx (on|off) (portid)\n"
533 : : "set flow_ctrl high_water (high_water) (portid)\n"
534 : : "set flow_ctrl low_water (low_water) (portid)\n"
535 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
536 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
537 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
538 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
539 : : " Set the link flow control parameter on a port.\n\n"
540 : :
541 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
542 : : " (low_water) (pause_time) (priority) (port_id)\n"
543 : : " Set the priority flow control parameter on a"
544 : : " port.\n\n"
545 : :
546 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
547 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
548 : : " Set the queue priority flow control parameter on a"
549 : : " given Rx and Tx queues of a port.\n\n"
550 : :
551 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
552 : : " set available descriptors threshold for Rx queue\n\n"
553 : :
554 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
555 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
556 : : " queue on port.\n"
557 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
558 : : " on port 0 to mapping 5.\n\n"
559 : :
560 : : "set xstats-hide-zero on|off\n"
561 : : " Set the option to hide the zero values"
562 : : " for xstats display.\n"
563 : :
564 : : "set record-core-cycles on|off\n"
565 : : " Set the option to enable measurement of CPU cycles.\n"
566 : :
567 : : "set record-burst-stats on|off\n"
568 : : " Set the option to enable display of RX and TX bursts.\n"
569 : :
570 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
571 : : " Enable/Disable a VF receive/transmit from a port\n\n"
572 : :
573 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
574 : : "|MPE) (on|off)\n"
575 : : " AUPE:accepts untagged VLAN;"
576 : : "ROPE:accept unicast hash\n\n"
577 : : " BAM:accepts broadcast packets;"
578 : : "MPE:accepts all multicast packets\n\n"
579 : : " Enable/Disable a VF receive mode of a port\n\n"
580 : :
581 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
582 : : " Set rate limit for a queue of a port\n\n"
583 : :
584 : : "set port (port_id) vf (vf_id) rate (rate_num) "
585 : : "queue_mask (queue_mask_value)\n"
586 : : " Set rate limit for queues in VF of a port\n\n"
587 : :
588 : : "set flush_rx (on|off)\n"
589 : : " Flush (default) or don't flush RX streams before"
590 : : " forwarding. Mainly used with PCAP drivers.\n\n"
591 : :
592 : : "set link-up port (port_id)\n"
593 : : " Set link up for a port.\n\n"
594 : :
595 : : "set link-down port (port_id)\n"
596 : : " Set link down for a port.\n\n"
597 : :
598 : : "set port (port_id) ptype_mask (ptype_mask)\n"
599 : : " set packet types classification for a specific port\n\n"
600 : :
601 : : "show port meter cap (port_id)\n"
602 : : " Show port meter capability information\n\n"
603 : :
604 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
605 : : " meter profile add - srtcm rfc 2697\n\n"
606 : :
607 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
608 : : " meter profile add - trtcm rfc 2698\n\n"
609 : :
610 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
611 : : " meter profile add - trtcm rfc 4115\n\n"
612 : :
613 : : "del port meter profile (port_id) (profile_id)\n"
614 : : " meter profile delete\n\n"
615 : :
616 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
617 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
618 : : "(dscp_tbl_entry63)]\n"
619 : : " meter create\n\n"
620 : :
621 : : "enable port meter (port_id) (mtr_id)\n"
622 : : " meter enable\n\n"
623 : :
624 : : "disable port meter (port_id) (mtr_id)\n"
625 : : " meter disable\n\n"
626 : :
627 : : "del port meter (port_id) (mtr_id)\n"
628 : : " meter delete\n\n"
629 : :
630 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
631 : : "y_actions (actions) r_actions (actions)\n"
632 : : " meter policy add\n\n"
633 : :
634 : : "del port meter policy (port_id) (policy_id)\n"
635 : : " meter policy delete\n\n"
636 : :
637 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
638 : : " meter update meter profile\n\n"
639 : :
640 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
641 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
642 : : " update meter dscp table entries\n\n"
643 : :
644 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
645 : : "(action0) [(action1) (action2)]\n"
646 : : " meter update policer action\n\n"
647 : :
648 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
649 : : " meter update stats\n\n"
650 : :
651 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
652 : : " set fec mode for a specific port\n\n"
653 : :
654 : : "show port cman capa (port_id)\n"
655 : : " Show congestion management capabilities\n\n"
656 : :
657 : : "show port cman config (port_id)\n"
658 : : " Show congestion management configuration\n\n"
659 : :
660 : : "set port cman config (port_id) (queue_id) default | "
661 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
662 : : "(max_thresh) (prob_inv)]\n"
663 : : " Set congestion management configuration\n\n"
664 : :
665 : : , list_pkt_forwarding_modes()
666 : : );
667 : : }
668 : :
669 : 0 : if (show_all || !strcmp(res->section, "ports")) {
670 : :
671 : 0 : cmdline_printf(
672 : : cl,
673 : : "\n"
674 : : "Port Operations:\n"
675 : : "----------------\n\n"
676 : :
677 : : "port start (port_id|all)\n"
678 : : " Start all ports or port_id.\n\n"
679 : :
680 : : "port stop (port_id|all)\n"
681 : : " Stop all ports or port_id.\n\n"
682 : :
683 : : "port close (port_id|all)\n"
684 : : " Close all ports or port_id.\n\n"
685 : :
686 : : "port reset (port_id|all)\n"
687 : : " Reset all ports or port_id.\n\n"
688 : :
689 : : "port attach (ident)\n"
690 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
691 : :
692 : : "port detach (port_id)\n"
693 : : " Detach physical or virtual dev by port_id\n\n"
694 : :
695 : : "port config (port_id|all)"
696 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
697 : : " duplex (half|full|auto)\n"
698 : : " Set speed and duplex for all ports or port_id\n\n"
699 : :
700 : : "port config (port_id|all) loopback (mode)\n"
701 : : " Set loopback mode for all ports or port_id\n\n"
702 : :
703 : : "port config all (rxq|txq|rxd|txd) (value)\n"
704 : : " Set number for rxq/txq/rxd/txd.\n\n"
705 : :
706 : : "port config all max-pkt-len (value)\n"
707 : : " Set the max packet length.\n\n"
708 : :
709 : : "port config all max-lro-pkt-size (value)\n"
710 : : " Set the max LRO aggregated packet size.\n\n"
711 : :
712 : : "port config all drop-en (on|off)\n"
713 : : " Enable or disable packet drop on all RX queues of all ports when no "
714 : : "receive buffers available.\n\n"
715 : :
716 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
717 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
718 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
719 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
720 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
721 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
722 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
723 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
724 : : " Set the RSS mode.\n\n"
725 : :
726 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
727 : : " Set the RSS redirection table.\n\n"
728 : :
729 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
730 : : " pfc (on|off)\n"
731 : : " Set the DCB mode.\n\n"
732 : :
733 : : "port config all burst (value)\n"
734 : : " Set the number of packets per burst.\n\n"
735 : :
736 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
737 : : " (value)\n"
738 : : " Set the ring prefetch/host/writeback threshold"
739 : : " for tx/rx queue.\n\n"
740 : :
741 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
742 : : " Set free threshold for rx/tx, or set"
743 : : " tx rs bit threshold.\n\n"
744 : : "port config mtu X value\n"
745 : : " Set the MTU of port X to a given value\n\n"
746 : :
747 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
748 : : " Set a rx/tx queue's ring size configuration, the new"
749 : : " value will take effect after command that (re-)start the port"
750 : : " or command that setup the specific queue\n\n"
751 : :
752 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
753 : : " Start/stop a rx/tx queue of port X. Only take effect"
754 : : " when port X is started\n\n"
755 : :
756 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
757 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
758 : : " take effect when port X is stopped.\n\n"
759 : :
760 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
761 : : " Setup a rx/tx queue of port X.\n\n"
762 : :
763 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
764 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
765 : :
766 : : "port config (port_id|all) rx_offload all|vlan_strip|"
767 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
768 : : "outer_ipv4_cksum|macsec_strip|"
769 : : "vlan_filter|vlan_extend|scatter|"
770 : : "buffer_split|timestamp|security|keep_crc on|off\n"
771 : : " Enable or disable a per port Rx offloading"
772 : : " on all Rx queues of a port\n\n"
773 : :
774 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
775 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
776 : : "outer_ipv4_cksum|macsec_strip|"
777 : : "vlan_filter|vlan_extend|scatter|"
778 : : "buffer_split|timestamp|security|keep_crc on|off\n"
779 : : " Enable or disable a per queue Rx offloading"
780 : : " only on a specific Rx queue\n\n"
781 : :
782 : : "port config (port_id|all) tx_offload all|vlan_insert|"
783 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
784 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
785 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
786 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
787 : : "security on|off\n"
788 : : " Enable or disable a per port Tx offloading"
789 : : " on all Tx queues of a port\n\n"
790 : :
791 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
792 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
793 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
794 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
795 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
796 : : " on|off\n"
797 : : " Enable or disable a per queue Tx offloading"
798 : : " only on a specific Tx queue\n\n"
799 : :
800 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
801 : : " Load an eBPF program as a callback"
802 : : " for particular RX/TX queue\n\n"
803 : :
804 : : "bpf-unload rx|tx (port) (queue)\n"
805 : : " Unload previously loaded eBPF program"
806 : : " for particular RX/TX queue\n\n"
807 : :
808 : : "port config (port_id) tx_metadata (value)\n"
809 : : " Set Tx metadata value per port. Testpmd will add this value"
810 : : " to any Tx packet sent from this port\n\n"
811 : :
812 : : "port config (port_id) dynf (name) set|clear\n"
813 : : " Register a dynf and Set/clear this flag on Tx. "
814 : : "Testpmd will set this value to any Tx packet "
815 : : "sent from this port\n\n"
816 : :
817 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
818 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
819 : :
820 : : "port config (port_id) txq (queue_id) affinity (value)\n"
821 : : " Map a Tx queue with an aggregated port "
822 : : "of the DPDK port\n\n"
823 : : );
824 : : }
825 : :
826 : 0 : if (show_all || !strcmp(res->section, "filters")) {
827 : :
828 : 0 : cmdline_printf(
829 : : cl,
830 : : "\n"
831 : : "filters:\n"
832 : : "--------\n\n"
833 : :
834 : : "flow validate {port_id}"
835 : : " [group {group_id}] [priority {level}]"
836 : : " [ingress] [egress]"
837 : : " pattern {item} [/ {item} [...]] / end"
838 : : " actions {action} [/ {action} [...]] / end\n"
839 : : " Check whether a flow rule can be created.\n\n"
840 : :
841 : : "flow create {port_id}"
842 : : " [group {group_id}] [priority {level}]"
843 : : " [ingress] [egress]"
844 : : " pattern {item} [/ {item} [...]] / end"
845 : : " actions {action} [/ {action} [...]] / end\n"
846 : : " Create a flow rule.\n\n"
847 : :
848 : : "flow destroy {port_id} rule {rule_id} [...]\n"
849 : : " Destroy specific flow rules.\n\n"
850 : :
851 : : "flow flush {port_id}\n"
852 : : " Destroy all flow rules.\n\n"
853 : :
854 : : "flow query {port_id} {rule_id} {action}\n"
855 : : " Query an existing flow rule.\n\n"
856 : :
857 : : "flow list {port_id} [group {group_id}] [...]\n"
858 : : " List existing flow rules sorted by priority,"
859 : : " filtered by group identifiers.\n\n"
860 : :
861 : : "flow isolate {port_id} {boolean}\n"
862 : : " Restrict ingress traffic to the defined"
863 : : " flow rules\n\n"
864 : :
865 : : "flow aged {port_id} [destroy]\n"
866 : : " List and destroy aged flows"
867 : : " flow rules\n\n"
868 : :
869 : : "flow indirect_action {port_id} create"
870 : : " [action_id {indirect_action_id}]"
871 : : " [ingress] [egress]"
872 : : " action {action} / end\n"
873 : : " Create indirect action.\n\n"
874 : :
875 : : "flow indirect_action {port_id} update"
876 : : " {indirect_action_id} action {action} / end\n"
877 : : " Update indirect action.\n\n"
878 : :
879 : : "flow indirect_action {port_id} destroy"
880 : : " action_id {indirect_action_id} [...]\n"
881 : : " Destroy specific indirect actions.\n\n"
882 : :
883 : : "flow indirect_action {port_id} query"
884 : : " {indirect_action_id}\n"
885 : : " Query an existing indirect action.\n\n"
886 : :
887 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
888 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
889 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
890 : : " Configure the VXLAN encapsulation for flows.\n\n"
891 : :
892 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
893 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
894 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
895 : : " eth-dst (eth-dst)\n"
896 : : " Configure the VXLAN encapsulation for flows.\n\n"
897 : :
898 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
899 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
900 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
901 : : " eth-dst (eth-dst)\n"
902 : : " Configure the VXLAN encapsulation for flows.\n\n"
903 : :
904 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
905 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
906 : : " (eth-dst)\n"
907 : : " Configure the NVGRE encapsulation for flows.\n\n"
908 : :
909 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
910 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
911 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
912 : : " Configure the NVGRE encapsulation for flows.\n\n"
913 : :
914 : : "set raw_encap {flow items}\n"
915 : : " Configure the encapsulation with raw data.\n\n"
916 : :
917 : : "set raw_decap {flow items}\n"
918 : : " Configure the decapsulation with raw data.\n\n"
919 : :
920 : : );
921 : : }
922 : :
923 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
924 : 0 : cmdline_printf(
925 : : cl,
926 : : "\n"
927 : : "Traffic Management:\n"
928 : : "--------------\n"
929 : : "show port tm cap (port_id)\n"
930 : : " Display the port TM capability.\n\n"
931 : :
932 : : "show port tm level cap (port_id) (level_id)\n"
933 : : " Display the port TM hierarchical level capability.\n\n"
934 : :
935 : : "show port tm node cap (port_id) (node_id)\n"
936 : : " Display the port TM node capability.\n\n"
937 : :
938 : : "show port tm node type (port_id) (node_id)\n"
939 : : " Display the port TM node type.\n\n"
940 : :
941 : : "show port tm node stats (port_id) (node_id) (clear)\n"
942 : : " Display the port TM node stats.\n\n"
943 : :
944 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
945 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
946 : : " (packet_length_adjust) (packet_mode)\n"
947 : : " Add port tm node private shaper profile.\n\n"
948 : :
949 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
950 : : " Delete port tm node private shaper profile.\n\n"
951 : :
952 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
953 : : " (shaper_profile_id)\n"
954 : : " Add/update port tm node shared shaper.\n\n"
955 : :
956 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
957 : : " Delete port tm node shared shaper.\n\n"
958 : :
959 : : "set port tm node shaper profile (port_id) (node_id)"
960 : : " (shaper_profile_id)\n"
961 : : " Set port tm node shaper profile.\n\n"
962 : :
963 : : "add port tm node wred profile (port_id) (wred_profile_id)"
964 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
965 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
966 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
967 : : " Add port tm node wred profile.\n\n"
968 : :
969 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
970 : : " Delete port tm node wred profile.\n\n"
971 : :
972 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
973 : : " (priority) (weight) (level_id) (shaper_profile_id)"
974 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
975 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
976 : : " Add port tm nonleaf node.\n\n"
977 : :
978 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
979 : : " (priority) (weight) (level_id) (shaper_profile_id)"
980 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
981 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
982 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
983 : :
984 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
985 : : " (priority) (weight) (level_id) (shaper_profile_id)"
986 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
987 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
988 : : " Add port tm leaf node.\n\n"
989 : :
990 : : "del port tm node (port_id) (node_id)\n"
991 : : " Delete port tm node.\n\n"
992 : :
993 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
994 : : " (priority) (weight)\n"
995 : : " Set port tm node parent.\n\n"
996 : :
997 : : "suspend port tm node (port_id) (node_id)"
998 : : " Suspend tm node.\n\n"
999 : :
1000 : : "resume port tm node (port_id) (node_id)"
1001 : : " Resume tm node.\n\n"
1002 : :
1003 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1004 : : " Commit tm hierarchy.\n\n"
1005 : :
1006 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1007 : : " (red)\n"
1008 : : " Enables/Disables the traffic management marking"
1009 : : " for IP ECN (Explicit Congestion Notification)"
1010 : : " packets on a given port\n\n"
1011 : :
1012 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1013 : : " (red)\n"
1014 : : " Enables/Disables the traffic management marking"
1015 : : " on the port for IP dscp packets\n\n"
1016 : :
1017 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1018 : : " (red)\n"
1019 : : " Enables/Disables the traffic management marking"
1020 : : " on the port for VLAN packets with DEI enabled\n\n"
1021 : : );
1022 : : }
1023 : :
1024 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1025 : 0 : cmdline_printf(
1026 : : cl,
1027 : : "\n"
1028 : : "Device Operations:\n"
1029 : : "--------------\n"
1030 : : "device detach (identifier)\n"
1031 : : " Detach device by identifier.\n\n"
1032 : : );
1033 : : }
1034 : :
1035 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1036 : : struct testpmd_driver_commands *c;
1037 : : unsigned int i;
1038 : :
1039 : 0 : cmdline_printf(
1040 : : cl,
1041 : : "\n"
1042 : : "Driver specific:\n"
1043 : : "----------------\n"
1044 : : );
1045 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1046 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1047 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1048 : : }
1049 : : }
1050 : 0 : }
1051 : :
1052 : : static cmdline_parse_token_string_t cmd_help_long_help =
1053 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1054 : :
1055 : : static cmdline_parse_token_string_t cmd_help_long_section =
1056 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1057 : : "all#control#display#config#ports#"
1058 : : "filters#traffic_management#devices#drivers");
1059 : :
1060 : : static cmdline_parse_inst_t cmd_help_long = {
1061 : : .f = cmd_help_long_parsed,
1062 : : .data = NULL,
1063 : : .help_str = "help all|control|display|config|ports|"
1064 : : "filters|traffic_management|devices|drivers: "
1065 : : "Show help",
1066 : : .tokens = {
1067 : : (void *)&cmd_help_long_help,
1068 : : (void *)&cmd_help_long_section,
1069 : : NULL,
1070 : : },
1071 : : };
1072 : :
1073 : :
1074 : : /* *** start/stop/close all ports *** */
1075 : : struct cmd_operate_port_result {
1076 : : cmdline_fixed_string_t keyword;
1077 : : cmdline_fixed_string_t name;
1078 : : cmdline_fixed_string_t value;
1079 : : };
1080 : :
1081 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1082 : : __rte_unused struct cmdline *cl,
1083 : : __rte_unused void *data)
1084 : : {
1085 : : struct cmd_operate_port_result *res = parsed_result;
1086 : :
1087 : 0 : if (!strcmp(res->name, "start"))
1088 : 0 : start_port(RTE_PORT_ALL);
1089 : 0 : else if (!strcmp(res->name, "stop"))
1090 : 0 : stop_port(RTE_PORT_ALL);
1091 : 0 : else if (!strcmp(res->name, "close"))
1092 : 0 : close_port(RTE_PORT_ALL);
1093 : 0 : else if (!strcmp(res->name, "reset"))
1094 : 0 : reset_port(RTE_PORT_ALL);
1095 : : else
1096 : 0 : fprintf(stderr, "Unknown parameter\n");
1097 : 0 : }
1098 : :
1099 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1100 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1101 : : "port");
1102 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1103 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1104 : : "start#stop#close#reset");
1105 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1106 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1107 : :
1108 : : static cmdline_parse_inst_t cmd_operate_port = {
1109 : : .f = cmd_operate_port_parsed,
1110 : : .data = NULL,
1111 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1112 : : .tokens = {
1113 : : (void *)&cmd_operate_port_all_cmd,
1114 : : (void *)&cmd_operate_port_all_port,
1115 : : (void *)&cmd_operate_port_all_all,
1116 : : NULL,
1117 : : },
1118 : : };
1119 : :
1120 : : /* *** start/stop/close specific port *** */
1121 : : struct cmd_operate_specific_port_result {
1122 : : cmdline_fixed_string_t keyword;
1123 : : cmdline_fixed_string_t name;
1124 : : uint8_t value;
1125 : : };
1126 : :
1127 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1128 : : __rte_unused struct cmdline *cl,
1129 : : __rte_unused void *data)
1130 : : {
1131 : : struct cmd_operate_specific_port_result *res = parsed_result;
1132 : :
1133 : 0 : if (!strcmp(res->name, "start"))
1134 : 0 : start_port(res->value);
1135 : 0 : else if (!strcmp(res->name, "stop"))
1136 : 0 : stop_port(res->value);
1137 : 0 : else if (!strcmp(res->name, "close"))
1138 : 0 : close_port(res->value);
1139 : 0 : else if (!strcmp(res->name, "reset"))
1140 : 0 : reset_port(res->value);
1141 : : else
1142 : 0 : fprintf(stderr, "Unknown parameter\n");
1143 : 0 : }
1144 : :
1145 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1147 : : keyword, "port");
1148 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1150 : : name, "start#stop#close#reset");
1151 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1152 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1153 : : value, RTE_UINT8);
1154 : :
1155 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1156 : : .f = cmd_operate_specific_port_parsed,
1157 : : .data = NULL,
1158 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1159 : : .tokens = {
1160 : : (void *)&cmd_operate_specific_port_cmd,
1161 : : (void *)&cmd_operate_specific_port_port,
1162 : : (void *)&cmd_operate_specific_port_id,
1163 : : NULL,
1164 : : },
1165 : : };
1166 : :
1167 : : /* *** enable port setup (after attach) via iterator or event *** */
1168 : : struct cmd_set_port_setup_on_result {
1169 : : cmdline_fixed_string_t set;
1170 : : cmdline_fixed_string_t port;
1171 : : cmdline_fixed_string_t setup;
1172 : : cmdline_fixed_string_t on;
1173 : : cmdline_fixed_string_t mode;
1174 : : };
1175 : :
1176 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1177 : : __rte_unused struct cmdline *cl,
1178 : : __rte_unused void *data)
1179 : : {
1180 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1181 : :
1182 : 0 : if (strcmp(res->mode, "event") == 0)
1183 : 0 : setup_on_probe_event = true;
1184 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1185 : 0 : setup_on_probe_event = false;
1186 : : else
1187 : 0 : fprintf(stderr, "Unknown mode\n");
1188 : 0 : }
1189 : :
1190 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1191 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1192 : : set, "set");
1193 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1194 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1195 : : port, "port");
1196 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1197 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1198 : : setup, "setup");
1199 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1200 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1201 : : on, "on");
1202 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1203 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1204 : : mode, "iterator#event");
1205 : :
1206 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1207 : : .f = cmd_set_port_setup_on_parsed,
1208 : : .data = NULL,
1209 : : .help_str = "set port setup on iterator|event",
1210 : : .tokens = {
1211 : : (void *)&cmd_set_port_setup_on_set,
1212 : : (void *)&cmd_set_port_setup_on_port,
1213 : : (void *)&cmd_set_port_setup_on_setup,
1214 : : (void *)&cmd_set_port_setup_on_on,
1215 : : (void *)&cmd_set_port_setup_on_mode,
1216 : : NULL,
1217 : : },
1218 : : };
1219 : :
1220 : : /* *** attach a specified port *** */
1221 : : struct cmd_operate_attach_port_result {
1222 : : cmdline_fixed_string_t port;
1223 : : cmdline_fixed_string_t keyword;
1224 : : cmdline_multi_string_t identifier;
1225 : : };
1226 : :
1227 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1228 : : __rte_unused struct cmdline *cl,
1229 : : __rte_unused void *data)
1230 : : {
1231 : : struct cmd_operate_attach_port_result *res = parsed_result;
1232 : :
1233 : 0 : if (!strcmp(res->keyword, "attach"))
1234 : 0 : attach_port(res->identifier);
1235 : : else
1236 : 0 : fprintf(stderr, "Unknown parameter\n");
1237 : 0 : }
1238 : :
1239 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1241 : : port, "port");
1242 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 : : keyword, "attach");
1245 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 : : identifier, TOKEN_STRING_MULTI);
1248 : :
1249 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1250 : : .f = cmd_operate_attach_port_parsed,
1251 : : .data = NULL,
1252 : : .help_str = "port attach <identifier>: "
1253 : : "(identifier: pci address or virtual dev name)",
1254 : : .tokens = {
1255 : : (void *)&cmd_operate_attach_port_port,
1256 : : (void *)&cmd_operate_attach_port_keyword,
1257 : : (void *)&cmd_operate_attach_port_identifier,
1258 : : NULL,
1259 : : },
1260 : : };
1261 : :
1262 : : /* *** detach a specified port *** */
1263 : : struct cmd_operate_detach_port_result {
1264 : : cmdline_fixed_string_t port;
1265 : : cmdline_fixed_string_t keyword;
1266 : : portid_t port_id;
1267 : : };
1268 : :
1269 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1270 : : __rte_unused struct cmdline *cl,
1271 : : __rte_unused void *data)
1272 : : {
1273 : : struct cmd_operate_detach_port_result *res = parsed_result;
1274 : :
1275 : 0 : if (!strcmp(res->keyword, "detach")) {
1276 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1277 : 0 : detach_port_device(res->port_id);
1278 : : } else {
1279 : 0 : fprintf(stderr, "Unknown parameter\n");
1280 : : }
1281 : : }
1282 : :
1283 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1284 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1285 : : port, "port");
1286 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1287 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1288 : : keyword, "detach");
1289 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1290 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1291 : : port_id, RTE_UINT16);
1292 : :
1293 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1294 : : .f = cmd_operate_detach_port_parsed,
1295 : : .data = NULL,
1296 : : .help_str = "port detach <port_id>",
1297 : : .tokens = {
1298 : : (void *)&cmd_operate_detach_port_port,
1299 : : (void *)&cmd_operate_detach_port_keyword,
1300 : : (void *)&cmd_operate_detach_port_port_id,
1301 : : NULL,
1302 : : },
1303 : : };
1304 : :
1305 : : /* *** detach device by identifier *** */
1306 : : struct cmd_operate_detach_device_result {
1307 : : cmdline_fixed_string_t device;
1308 : : cmdline_fixed_string_t keyword;
1309 : : cmdline_fixed_string_t identifier;
1310 : : };
1311 : :
1312 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1313 : : __rte_unused struct cmdline *cl,
1314 : : __rte_unused void *data)
1315 : : {
1316 : : struct cmd_operate_detach_device_result *res = parsed_result;
1317 : :
1318 : 0 : if (!strcmp(res->keyword, "detach"))
1319 : 0 : detach_devargs(res->identifier);
1320 : : else
1321 : 0 : fprintf(stderr, "Unknown parameter\n");
1322 : 0 : }
1323 : :
1324 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1325 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1326 : : device, "device");
1327 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1328 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1329 : : keyword, "detach");
1330 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1331 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1332 : : identifier, NULL);
1333 : :
1334 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1335 : : .f = cmd_operate_detach_device_parsed,
1336 : : .data = NULL,
1337 : : .help_str = "device detach <identifier>:"
1338 : : "(identifier: pci address or virtual dev name)",
1339 : : .tokens = {
1340 : : (void *)&cmd_operate_detach_device_device,
1341 : : (void *)&cmd_operate_detach_device_keyword,
1342 : : (void *)&cmd_operate_detach_device_identifier,
1343 : : NULL,
1344 : : },
1345 : : };
1346 : : /* *** configure speed for all ports *** */
1347 : : struct cmd_config_speed_all {
1348 : : cmdline_fixed_string_t port;
1349 : : cmdline_fixed_string_t keyword;
1350 : : cmdline_fixed_string_t all;
1351 : : cmdline_fixed_string_t item1;
1352 : : cmdline_fixed_string_t item2;
1353 : : cmdline_fixed_string_t value1;
1354 : : cmdline_fixed_string_t value2;
1355 : : };
1356 : :
1357 : : static int
1358 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1359 : : {
1360 : :
1361 : : int duplex;
1362 : :
1363 : 0 : if (!strcmp(duplexstr, "half")) {
1364 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1365 : 0 : } else if (!strcmp(duplexstr, "full")) {
1366 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1367 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1368 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1369 : : } else {
1370 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1371 : 0 : return -1;
1372 : : }
1373 : :
1374 : 0 : if (!strcmp(speedstr, "10")) {
1375 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1376 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1377 : 0 : } else if (!strcmp(speedstr, "100")) {
1378 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1379 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1380 : : } else {
1381 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1382 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1383 : 0 : return -1;
1384 : : }
1385 : 0 : if (!strcmp(speedstr, "1000")) {
1386 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1387 : 0 : } else if (!strcmp(speedstr, "2500")) {
1388 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1389 : 0 : } else if (!strcmp(speedstr, "5000")) {
1390 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1391 : 0 : } else if (!strcmp(speedstr, "10000")) {
1392 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1393 : 0 : } else if (!strcmp(speedstr, "25000")) {
1394 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1395 : 0 : } else if (!strcmp(speedstr, "40000")) {
1396 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1397 : 0 : } else if (!strcmp(speedstr, "50000")) {
1398 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1399 : 0 : } else if (!strcmp(speedstr, "100000")) {
1400 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1401 : 0 : } else if (!strcmp(speedstr, "200000")) {
1402 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1403 : 0 : } else if (!strcmp(speedstr, "400000")) {
1404 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1405 : 0 : } else if (!strcmp(speedstr, "auto")) {
1406 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1407 : : } else {
1408 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1409 : 0 : return -1;
1410 : : }
1411 : : }
1412 : :
1413 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1414 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1415 : :
1416 : : return 0;
1417 : : }
1418 : :
1419 : : static void
1420 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1421 : : __rte_unused struct cmdline *cl,
1422 : : __rte_unused void *data)
1423 : : {
1424 : : struct cmd_config_speed_all *res = parsed_result;
1425 : : uint32_t link_speed;
1426 : : portid_t pid;
1427 : :
1428 : 0 : if (!all_ports_stopped()) {
1429 : 0 : fprintf(stderr, "Please stop all ports first\n");
1430 : 0 : return;
1431 : : }
1432 : :
1433 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1434 : : &link_speed) < 0)
1435 : : return;
1436 : :
1437 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1438 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1439 : : }
1440 : :
1441 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1442 : : }
1443 : :
1444 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1445 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1446 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1447 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1448 : : "config");
1449 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1450 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1451 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1452 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1453 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1454 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1455 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1456 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1457 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1458 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1459 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1460 : : "half#full#auto");
1461 : :
1462 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1463 : : .f = cmd_config_speed_all_parsed,
1464 : : .data = NULL,
1465 : : .help_str = "port config all speed "
1466 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1467 : : "half|full|auto",
1468 : : .tokens = {
1469 : : (void *)&cmd_config_speed_all_port,
1470 : : (void *)&cmd_config_speed_all_keyword,
1471 : : (void *)&cmd_config_speed_all_all,
1472 : : (void *)&cmd_config_speed_all_item1,
1473 : : (void *)&cmd_config_speed_all_value1,
1474 : : (void *)&cmd_config_speed_all_item2,
1475 : : (void *)&cmd_config_speed_all_value2,
1476 : : NULL,
1477 : : },
1478 : : };
1479 : :
1480 : : /* *** configure speed for specific port *** */
1481 : : struct cmd_config_speed_specific {
1482 : : cmdline_fixed_string_t port;
1483 : : cmdline_fixed_string_t keyword;
1484 : : portid_t id;
1485 : : cmdline_fixed_string_t item1;
1486 : : cmdline_fixed_string_t item2;
1487 : : cmdline_fixed_string_t value1;
1488 : : cmdline_fixed_string_t value2;
1489 : : };
1490 : :
1491 : : static void
1492 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1493 : : __rte_unused struct cmdline *cl,
1494 : : __rte_unused void *data)
1495 : : {
1496 : : struct cmd_config_speed_specific *res = parsed_result;
1497 : : uint32_t link_speed;
1498 : :
1499 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1500 : 0 : return;
1501 : :
1502 : 0 : if (!port_is_stopped(res->id)) {
1503 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1504 : 0 : return;
1505 : : }
1506 : :
1507 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1508 : : &link_speed) < 0)
1509 : : return;
1510 : :
1511 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1512 : :
1513 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1514 : : }
1515 : :
1516 : :
1517 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1518 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1519 : : "port");
1520 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1521 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1522 : : "config");
1523 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1524 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1525 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1526 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1527 : : "speed");
1528 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1529 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1530 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1531 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1532 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1533 : : "duplex");
1534 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1535 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1536 : : "half#full#auto");
1537 : :
1538 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1539 : : .f = cmd_config_speed_specific_parsed,
1540 : : .data = NULL,
1541 : : .help_str = "port config <port_id> speed "
1542 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1543 : : "half|full|auto",
1544 : : .tokens = {
1545 : : (void *)&cmd_config_speed_specific_port,
1546 : : (void *)&cmd_config_speed_specific_keyword,
1547 : : (void *)&cmd_config_speed_specific_id,
1548 : : (void *)&cmd_config_speed_specific_item1,
1549 : : (void *)&cmd_config_speed_specific_value1,
1550 : : (void *)&cmd_config_speed_specific_item2,
1551 : : (void *)&cmd_config_speed_specific_value2,
1552 : : NULL,
1553 : : },
1554 : : };
1555 : :
1556 : : /* *** configure loopback for all ports *** */
1557 : : struct cmd_config_loopback_all {
1558 : : cmdline_fixed_string_t port;
1559 : : cmdline_fixed_string_t keyword;
1560 : : cmdline_fixed_string_t all;
1561 : : cmdline_fixed_string_t item;
1562 : : uint32_t mode;
1563 : : };
1564 : :
1565 : : static void
1566 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1567 : : __rte_unused struct cmdline *cl,
1568 : : __rte_unused void *data)
1569 : : {
1570 : : struct cmd_config_loopback_all *res = parsed_result;
1571 : : portid_t pid;
1572 : :
1573 : 0 : if (!all_ports_stopped()) {
1574 : 0 : fprintf(stderr, "Please stop all ports first\n");
1575 : 0 : return;
1576 : : }
1577 : :
1578 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1579 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1580 : : }
1581 : :
1582 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1583 : : }
1584 : :
1585 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1586 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1587 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1588 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1589 : : "config");
1590 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1591 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1592 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1593 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1594 : : "loopback");
1595 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1596 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1597 : :
1598 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1599 : : .f = cmd_config_loopback_all_parsed,
1600 : : .data = NULL,
1601 : : .help_str = "port config all loopback <mode>",
1602 : : .tokens = {
1603 : : (void *)&cmd_config_loopback_all_port,
1604 : : (void *)&cmd_config_loopback_all_keyword,
1605 : : (void *)&cmd_config_loopback_all_all,
1606 : : (void *)&cmd_config_loopback_all_item,
1607 : : (void *)&cmd_config_loopback_all_mode,
1608 : : NULL,
1609 : : },
1610 : : };
1611 : :
1612 : : /* *** configure loopback for specific port *** */
1613 : : struct cmd_config_loopback_specific {
1614 : : cmdline_fixed_string_t port;
1615 : : cmdline_fixed_string_t keyword;
1616 : : uint16_t port_id;
1617 : : cmdline_fixed_string_t item;
1618 : : uint32_t mode;
1619 : : };
1620 : :
1621 : : static void
1622 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1623 : : __rte_unused struct cmdline *cl,
1624 : : __rte_unused void *data)
1625 : : {
1626 : : struct cmd_config_loopback_specific *res = parsed_result;
1627 : :
1628 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1629 : : return;
1630 : :
1631 : 0 : if (!port_is_stopped(res->port_id)) {
1632 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1633 : 0 : return;
1634 : : }
1635 : :
1636 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1637 : :
1638 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1639 : : }
1640 : :
1641 : :
1642 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1643 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1644 : : "port");
1645 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1646 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1647 : : "config");
1648 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1649 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1650 : : RTE_UINT16);
1651 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1652 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1653 : : "loopback");
1654 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1655 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1656 : : RTE_UINT32);
1657 : :
1658 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1659 : : .f = cmd_config_loopback_specific_parsed,
1660 : : .data = NULL,
1661 : : .help_str = "port config <port_id> loopback <mode>",
1662 : : .tokens = {
1663 : : (void *)&cmd_config_loopback_specific_port,
1664 : : (void *)&cmd_config_loopback_specific_keyword,
1665 : : (void *)&cmd_config_loopback_specific_id,
1666 : : (void *)&cmd_config_loopback_specific_item,
1667 : : (void *)&cmd_config_loopback_specific_mode,
1668 : : NULL,
1669 : : },
1670 : : };
1671 : :
1672 : : /* *** configure txq/rxq, txd/rxd *** */
1673 : : struct cmd_config_rx_tx {
1674 : : cmdline_fixed_string_t port;
1675 : : cmdline_fixed_string_t keyword;
1676 : : cmdline_fixed_string_t all;
1677 : : cmdline_fixed_string_t name;
1678 : : uint16_t value;
1679 : : };
1680 : :
1681 : : static void
1682 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1683 : : __rte_unused struct cmdline *cl,
1684 : : __rte_unused void *data)
1685 : : {
1686 : : struct cmd_config_rx_tx *res = parsed_result;
1687 : :
1688 : 0 : if (!all_ports_stopped()) {
1689 : 0 : fprintf(stderr, "Please stop all ports first\n");
1690 : 0 : return;
1691 : : }
1692 : 0 : if (!strcmp(res->name, "rxq")) {
1693 : 0 : if (!res->value && !nb_txq) {
1694 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1695 : 0 : return;
1696 : : }
1697 : 0 : if (check_nb_rxq(res->value) != 0)
1698 : : return;
1699 : 0 : nb_rxq = res->value;
1700 : : }
1701 : 0 : else if (!strcmp(res->name, "txq")) {
1702 : 0 : if (!res->value && !nb_rxq) {
1703 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1704 : 0 : return;
1705 : : }
1706 : 0 : if (check_nb_txq(res->value) != 0)
1707 : : return;
1708 : 0 : nb_txq = res->value;
1709 : : }
1710 : 0 : else if (!strcmp(res->name, "rxd")) {
1711 : 0 : if (check_nb_rxd(res->value) != 0)
1712 : : return;
1713 : 0 : nb_rxd = res->value;
1714 : 0 : } else if (!strcmp(res->name, "txd")) {
1715 : 0 : if (check_nb_txd(res->value) != 0)
1716 : : return;
1717 : :
1718 : 0 : nb_txd = res->value;
1719 : : } else {
1720 : 0 : fprintf(stderr, "Unknown parameter\n");
1721 : 0 : return;
1722 : : }
1723 : :
1724 : 0 : fwd_config_setup();
1725 : :
1726 : 0 : init_port_config();
1727 : :
1728 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1729 : : }
1730 : :
1731 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1732 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1733 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1734 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1735 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1736 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1737 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1738 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1739 : : "rxq#txq#rxd#txd");
1740 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1741 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1742 : :
1743 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
1744 : : .f = cmd_config_rx_tx_parsed,
1745 : : .data = NULL,
1746 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
1747 : : .tokens = {
1748 : : (void *)&cmd_config_rx_tx_port,
1749 : : (void *)&cmd_config_rx_tx_keyword,
1750 : : (void *)&cmd_config_rx_tx_all,
1751 : : (void *)&cmd_config_rx_tx_name,
1752 : : (void *)&cmd_config_rx_tx_value,
1753 : : NULL,
1754 : : },
1755 : : };
1756 : :
1757 : : /* *** config max packet length *** */
1758 : : struct cmd_config_max_pkt_len_result {
1759 : : cmdline_fixed_string_t port;
1760 : : cmdline_fixed_string_t keyword;
1761 : : cmdline_fixed_string_t all;
1762 : : cmdline_fixed_string_t name;
1763 : : uint32_t value;
1764 : : };
1765 : :
1766 : : static void
1767 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
1768 : : __rte_unused struct cmdline *cl,
1769 : : __rte_unused void *data)
1770 : : {
1771 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
1772 : : portid_t port_id;
1773 : : int ret;
1774 : :
1775 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
1776 : : printf("Unknown parameter\n");
1777 : 0 : return;
1778 : : }
1779 : :
1780 : 0 : if (!all_ports_stopped()) {
1781 : 0 : fprintf(stderr, "Please stop all ports first\n");
1782 : 0 : return;
1783 : : }
1784 : :
1785 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
1786 : 0 : struct rte_port *port = &ports[port_id];
1787 : :
1788 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
1789 : 0 : fprintf(stderr,
1790 : : "max-pkt-len can not be less than %d\n",
1791 : : RTE_ETHER_MIN_LEN);
1792 : 0 : return;
1793 : : }
1794 : :
1795 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1796 : 0 : if (ret != 0) {
1797 : 0 : fprintf(stderr,
1798 : : "rte_eth_dev_info_get() failed for port %u\n",
1799 : : port_id);
1800 : 0 : return;
1801 : : }
1802 : :
1803 : 0 : update_mtu_from_frame_size(port_id, res->value);
1804 : : }
1805 : :
1806 : 0 : init_port_config();
1807 : :
1808 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1809 : : }
1810 : :
1811 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1812 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1813 : : "port");
1814 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1815 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1816 : : "config");
1817 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1818 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1819 : : "all");
1820 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1821 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1822 : : "max-pkt-len");
1823 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1824 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1825 : : RTE_UINT32);
1826 : :
1827 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1828 : : .f = cmd_config_max_pkt_len_parsed,
1829 : : .data = NULL,
1830 : : .help_str = "port config all max-pkt-len <value>",
1831 : : .tokens = {
1832 : : (void *)&cmd_config_max_pkt_len_port,
1833 : : (void *)&cmd_config_max_pkt_len_keyword,
1834 : : (void *)&cmd_config_max_pkt_len_all,
1835 : : (void *)&cmd_config_max_pkt_len_name,
1836 : : (void *)&cmd_config_max_pkt_len_value,
1837 : : NULL,
1838 : : },
1839 : : };
1840 : :
1841 : : /* *** config max LRO aggregated packet size *** */
1842 : : struct cmd_config_max_lro_pkt_size_result {
1843 : : cmdline_fixed_string_t port;
1844 : : cmdline_fixed_string_t keyword;
1845 : : cmdline_fixed_string_t all;
1846 : : cmdline_fixed_string_t name;
1847 : : uint32_t value;
1848 : : };
1849 : :
1850 : : static void
1851 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1852 : : __rte_unused struct cmdline *cl,
1853 : : __rte_unused void *data)
1854 : : {
1855 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1856 : : portid_t pid;
1857 : :
1858 : 0 : if (!all_ports_stopped()) {
1859 : 0 : fprintf(stderr, "Please stop all ports first\n");
1860 : 0 : return;
1861 : : }
1862 : :
1863 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1864 : 0 : struct rte_port *port = &ports[pid];
1865 : :
1866 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
1867 : 0 : if (res->value ==
1868 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
1869 : : return;
1870 : :
1871 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1872 : : } else {
1873 : 0 : fprintf(stderr, "Unknown parameter\n");
1874 : 0 : return;
1875 : : }
1876 : : }
1877 : :
1878 : 0 : init_port_config();
1879 : :
1880 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1881 : : }
1882 : :
1883 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1884 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1885 : : port, "port");
1886 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1888 : : keyword, "config");
1889 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1890 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1891 : : all, "all");
1892 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1893 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1894 : : name, "max-lro-pkt-size");
1895 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1896 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1897 : : value, RTE_UINT32);
1898 : :
1899 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
1900 : : .f = cmd_config_max_lro_pkt_size_parsed,
1901 : : .data = NULL,
1902 : : .help_str = "port config all max-lro-pkt-size <value>",
1903 : : .tokens = {
1904 : : (void *)&cmd_config_max_lro_pkt_size_port,
1905 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
1906 : : (void *)&cmd_config_max_lro_pkt_size_all,
1907 : : (void *)&cmd_config_max_lro_pkt_size_name,
1908 : : (void *)&cmd_config_max_lro_pkt_size_value,
1909 : : NULL,
1910 : : },
1911 : : };
1912 : :
1913 : : /* *** configure port MTU *** */
1914 : : struct cmd_config_mtu_result {
1915 : : cmdline_fixed_string_t port;
1916 : : cmdline_fixed_string_t keyword;
1917 : : cmdline_fixed_string_t mtu;
1918 : : portid_t port_id;
1919 : : uint16_t value;
1920 : : };
1921 : :
1922 : : static void
1923 : 0 : cmd_config_mtu_parsed(void *parsed_result,
1924 : : __rte_unused struct cmdline *cl,
1925 : : __rte_unused void *data)
1926 : : {
1927 : : struct cmd_config_mtu_result *res = parsed_result;
1928 : :
1929 : 0 : port_mtu_set(res->port_id, res->value);
1930 : 0 : }
1931 : :
1932 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
1933 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1934 : : "port");
1935 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
1936 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1937 : : "config");
1938 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
1939 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1940 : : "mtu");
1941 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
1942 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
1943 : : RTE_UINT16);
1944 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
1945 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
1946 : : RTE_UINT16);
1947 : :
1948 : : static cmdline_parse_inst_t cmd_config_mtu = {
1949 : : .f = cmd_config_mtu_parsed,
1950 : : .data = NULL,
1951 : : .help_str = "port config mtu <port_id> <value>",
1952 : : .tokens = {
1953 : : (void *)&cmd_config_mtu_port,
1954 : : (void *)&cmd_config_mtu_keyword,
1955 : : (void *)&cmd_config_mtu_mtu,
1956 : : (void *)&cmd_config_mtu_port_id,
1957 : : (void *)&cmd_config_mtu_value,
1958 : : NULL,
1959 : : },
1960 : : };
1961 : :
1962 : : /* *** configure rx mode *** */
1963 : : struct cmd_config_rx_mode_flag {
1964 : : cmdline_fixed_string_t port;
1965 : : cmdline_fixed_string_t keyword;
1966 : : cmdline_fixed_string_t all;
1967 : : cmdline_fixed_string_t name;
1968 : : cmdline_fixed_string_t value;
1969 : : };
1970 : :
1971 : : static void
1972 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
1973 : : __rte_unused struct cmdline *cl,
1974 : : __rte_unused void *data)
1975 : : {
1976 : : struct cmd_config_rx_mode_flag *res = parsed_result;
1977 : :
1978 : 0 : if (!all_ports_stopped()) {
1979 : 0 : fprintf(stderr, "Please stop all ports first\n");
1980 : 0 : return;
1981 : : }
1982 : :
1983 : 0 : if (!strcmp(res->name, "drop-en")) {
1984 : 0 : if (!strcmp(res->value, "on"))
1985 : 0 : rx_drop_en = 1;
1986 : 0 : else if (!strcmp(res->value, "off"))
1987 : 0 : rx_drop_en = 0;
1988 : : else {
1989 : 0 : fprintf(stderr, "Unknown parameter\n");
1990 : 0 : return;
1991 : : }
1992 : : } else {
1993 : 0 : fprintf(stderr, "Unknown parameter\n");
1994 : 0 : return;
1995 : : }
1996 : :
1997 : 0 : init_port_config();
1998 : :
1999 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2000 : : }
2001 : :
2002 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2003 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2004 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2005 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2006 : : "config");
2007 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2008 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2009 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2011 : : "drop-en");
2012 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2013 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2014 : : "on#off");
2015 : :
2016 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2017 : : .f = cmd_config_rx_mode_flag_parsed,
2018 : : .data = NULL,
2019 : : .help_str = "port config all drop-en on|off",
2020 : : .tokens = {
2021 : : (void *)&cmd_config_rx_mode_flag_port,
2022 : : (void *)&cmd_config_rx_mode_flag_keyword,
2023 : : (void *)&cmd_config_rx_mode_flag_all,
2024 : : (void *)&cmd_config_rx_mode_flag_name,
2025 : : (void *)&cmd_config_rx_mode_flag_value,
2026 : : NULL,
2027 : : },
2028 : : };
2029 : :
2030 : : /* *** configure rss *** */
2031 : : struct cmd_config_rss {
2032 : : cmdline_fixed_string_t port;
2033 : : cmdline_fixed_string_t keyword;
2034 : : cmdline_fixed_string_t all;
2035 : : cmdline_fixed_string_t name;
2036 : : cmdline_fixed_string_t value;
2037 : : };
2038 : :
2039 : : static void
2040 : 0 : cmd_config_rss_parsed(void *parsed_result,
2041 : : __rte_unused struct cmdline *cl,
2042 : : __rte_unused void *data)
2043 : : {
2044 : : struct cmd_config_rss *res = parsed_result;
2045 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2046 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2047 : : int use_default = 0;
2048 : : int all_updated = 1;
2049 : : int diag;
2050 : : uint16_t i;
2051 : : int ret;
2052 : :
2053 : 0 : if (!strcmp(res->value, "level-default")) {
2054 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2055 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2056 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2057 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2058 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2059 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2060 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2061 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2062 : 0 : } else if (!strcmp(res->value, "default")) {
2063 : : use_default = 1;
2064 : 0 : } else if (isdigit(res->value[0])) {
2065 : : int value = atoi(res->value);
2066 : 0 : if (value > 0 && value < 64)
2067 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2068 : : else {
2069 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2070 : 0 : return;
2071 : : }
2072 : 0 : } else if (!strcmp(res->value, "none")) {
2073 : : rss_conf.rss_hf = 0;
2074 : : } else {
2075 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2076 : 0 : if (rss_conf.rss_hf == 0) {
2077 : 0 : fprintf(stderr, "Unknown parameter\n");
2078 : 0 : return;
2079 : : }
2080 : : }
2081 : : rss_conf.rss_key = NULL;
2082 : : /* Update global configuration for RSS types. */
2083 : 0 : RTE_ETH_FOREACH_DEV(i) {
2084 : : struct rte_eth_rss_conf local_rss_conf;
2085 : :
2086 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2087 : 0 : if (ret != 0)
2088 : 0 : return;
2089 : :
2090 : 0 : if (use_default)
2091 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2092 : :
2093 : 0 : local_rss_conf = rss_conf;
2094 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2095 : 0 : dev_info.flow_type_rss_offloads;
2096 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2097 : : printf("Port %u modified RSS hash function based on hardware support,"
2098 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2099 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2100 : : }
2101 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2102 : 0 : if (diag < 0) {
2103 : : all_updated = 0;
2104 : 0 : fprintf(stderr,
2105 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2106 : : i, -diag, strerror(-diag));
2107 : : }
2108 : : }
2109 : 0 : if (all_updated && !use_default) {
2110 : 0 : rss_hf = rss_conf.rss_hf;
2111 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2112 : : }
2113 : : }
2114 : :
2115 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2116 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2117 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2118 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2119 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2120 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2121 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2122 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2123 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2124 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2125 : :
2126 : : static cmdline_parse_inst_t cmd_config_rss = {
2127 : : .f = cmd_config_rss_parsed,
2128 : : .data = NULL,
2129 : : .help_str = "port config all rss "
2130 : : "all|default|level-default|level-outer|level-inner|"
2131 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2132 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2133 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2134 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2135 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2136 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2137 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2138 : : .tokens = {
2139 : : (void *)&cmd_config_rss_port,
2140 : : (void *)&cmd_config_rss_keyword,
2141 : : (void *)&cmd_config_rss_all,
2142 : : (void *)&cmd_config_rss_name,
2143 : : (void *)&cmd_config_rss_value,
2144 : : NULL,
2145 : : },
2146 : : };
2147 : :
2148 : : /* *** configure rss hash key *** */
2149 : : struct cmd_config_rss_hash_key {
2150 : : cmdline_fixed_string_t port;
2151 : : cmdline_fixed_string_t config;
2152 : : portid_t port_id;
2153 : : cmdline_fixed_string_t rss_hash_key;
2154 : : cmdline_fixed_string_t rss_type;
2155 : : cmdline_fixed_string_t key;
2156 : : };
2157 : :
2158 : : static uint8_t
2159 : : hexa_digit_to_value(char hexa_digit)
2160 : : {
2161 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2162 : : return (uint8_t) (hexa_digit - '0');
2163 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2164 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2165 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2166 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2167 : : /* Invalid hexa digit */
2168 : : return 0xFF;
2169 : : }
2170 : :
2171 : : static uint8_t
2172 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2173 : : {
2174 : : uint8_t hexa_v;
2175 : :
2176 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2177 : : if (hexa_v == 0xFF)
2178 : 0 : fprintf(stderr,
2179 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2180 : : key[idx], idx);
2181 : 0 : return hexa_v;
2182 : : }
2183 : :
2184 : : static void
2185 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2186 : : __rte_unused struct cmdline *cl,
2187 : : __rte_unused void *data)
2188 : : {
2189 : : struct cmd_config_rss_hash_key *res = parsed_result;
2190 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2191 : : uint8_t xdgt0;
2192 : : uint8_t xdgt1;
2193 : : int i;
2194 : : struct rte_eth_dev_info dev_info;
2195 : : uint8_t hash_key_size;
2196 : : uint32_t key_len;
2197 : : int ret;
2198 : :
2199 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2200 : 0 : if (ret != 0)
2201 : 0 : return;
2202 : :
2203 : 0 : if (dev_info.hash_key_size > 0 &&
2204 : : dev_info.hash_key_size <= sizeof(hash_key))
2205 : : hash_key_size = dev_info.hash_key_size;
2206 : : else {
2207 : 0 : fprintf(stderr,
2208 : : "dev_info did not provide a valid hash key size\n");
2209 : 0 : return;
2210 : : }
2211 : : /* Check the length of the RSS hash key */
2212 : 0 : key_len = strlen(res->key);
2213 : 0 : if (key_len != (hash_key_size * 2)) {
2214 : 0 : fprintf(stderr,
2215 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2216 : : (int)key_len, hash_key_size * 2);
2217 : 0 : return;
2218 : : }
2219 : : /* Translate RSS hash key into binary representation */
2220 : 0 : for (i = 0; i < hash_key_size; i++) {
2221 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2222 : 0 : if (xdgt0 == 0xFF)
2223 : : return;
2224 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2225 : 0 : if (xdgt1 == 0xFF)
2226 : : return;
2227 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2228 : : }
2229 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2230 : : hash_key_size);
2231 : : }
2232 : :
2233 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2234 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2235 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2236 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2237 : : "config");
2238 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2239 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2240 : : RTE_UINT16);
2241 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2242 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2243 : : rss_hash_key, "rss-hash-key");
2244 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2245 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2246 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2247 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2248 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2249 : : "ipv6-tcp-ex#ipv6-udp-ex#"
2250 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2251 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2252 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2253 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2254 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2255 : :
2256 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2257 : : .f = cmd_config_rss_hash_key_parsed,
2258 : : .data = NULL,
2259 : : .help_str = "port config <port_id> rss-hash-key "
2260 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2261 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2262 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2263 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2264 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2265 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2266 : : "<string of hex digits (variable length, NIC dependent)>",
2267 : : .tokens = {
2268 : : (void *)&cmd_config_rss_hash_key_port,
2269 : : (void *)&cmd_config_rss_hash_key_config,
2270 : : (void *)&cmd_config_rss_hash_key_port_id,
2271 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2272 : : (void *)&cmd_config_rss_hash_key_rss_type,
2273 : : (void *)&cmd_config_rss_hash_key_value,
2274 : : NULL,
2275 : : },
2276 : : };
2277 : :
2278 : : /* *** cleanup txq mbufs *** */
2279 : : struct cmd_cleanup_txq_mbufs_result {
2280 : : cmdline_fixed_string_t port;
2281 : : cmdline_fixed_string_t keyword;
2282 : : cmdline_fixed_string_t name;
2283 : : uint16_t port_id;
2284 : : uint16_t queue_id;
2285 : : uint32_t free_cnt;
2286 : : };
2287 : :
2288 : : static void
2289 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2290 : : __rte_unused struct cmdline *cl,
2291 : : __rte_unused void *data)
2292 : : {
2293 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2294 : 0 : uint16_t port_id = res->port_id;
2295 : 0 : uint16_t queue_id = res->queue_id;
2296 : 0 : uint32_t free_cnt = res->free_cnt;
2297 : : struct rte_eth_txq_info qinfo;
2298 : : int ret;
2299 : :
2300 : 0 : if (test_done == 0) {
2301 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2302 : 0 : return;
2303 : : }
2304 : :
2305 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2306 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2307 : : port_id, queue_id);
2308 : 0 : return;
2309 : : }
2310 : :
2311 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2312 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2313 : 0 : return;
2314 : : }
2315 : :
2316 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2317 : 0 : if (ret < 0) {
2318 : 0 : fprintf(stderr,
2319 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2320 : : port_id, queue_id, strerror(-ret), ret);
2321 : 0 : return;
2322 : : }
2323 : :
2324 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2325 : : port_id, queue_id, ret);
2326 : : }
2327 : :
2328 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2329 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2330 : : "port");
2331 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2332 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2333 : : "cleanup");
2334 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2335 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2336 : : RTE_UINT16);
2337 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2338 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2339 : : "txq");
2340 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2341 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2342 : : RTE_UINT16);
2343 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2344 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2345 : : RTE_UINT32);
2346 : :
2347 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2348 : : .f = cmd_cleanup_txq_mbufs_parsed,
2349 : : .data = NULL,
2350 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2351 : : .tokens = {
2352 : : (void *)&cmd_cleanup_txq_mbufs_port,
2353 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2354 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2355 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2356 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2357 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2358 : : NULL,
2359 : : },
2360 : : };
2361 : :
2362 : : /* *** configure port rxq/txq ring size *** */
2363 : : struct cmd_config_rxtx_ring_size {
2364 : : cmdline_fixed_string_t port;
2365 : : cmdline_fixed_string_t config;
2366 : : portid_t portid;
2367 : : cmdline_fixed_string_t rxtxq;
2368 : : uint16_t qid;
2369 : : cmdline_fixed_string_t rsize;
2370 : : uint16_t size;
2371 : : };
2372 : :
2373 : : static void
2374 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2375 : : __rte_unused struct cmdline *cl,
2376 : : __rte_unused void *data)
2377 : : {
2378 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2379 : : struct rte_port *port;
2380 : : uint8_t isrx;
2381 : :
2382 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2383 : : return;
2384 : :
2385 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2386 : 0 : fprintf(stderr, "Invalid port id\n");
2387 : 0 : return;
2388 : : }
2389 : :
2390 : 0 : port = &ports[res->portid];
2391 : :
2392 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2393 : : isrx = 1;
2394 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2395 : : isrx = 0;
2396 : : else {
2397 : 0 : fprintf(stderr, "Unknown parameter\n");
2398 : 0 : return;
2399 : : }
2400 : :
2401 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2402 : : return;
2403 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2404 : : return;
2405 : :
2406 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2407 : 0 : fprintf(stderr,
2408 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2409 : : rx_free_thresh);
2410 : 0 : return;
2411 : : }
2412 : :
2413 : 0 : if (isrx)
2414 : 0 : port->nb_rx_desc[res->qid] = res->size;
2415 : : else
2416 : 0 : port->nb_tx_desc[res->qid] = res->size;
2417 : :
2418 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2419 : : }
2420 : :
2421 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2422 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2423 : : port, "port");
2424 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2425 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2426 : : config, "config");
2427 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2428 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2429 : : portid, RTE_UINT16);
2430 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2431 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2432 : : rxtxq, "rxq#txq");
2433 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2434 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2435 : : qid, RTE_UINT16);
2436 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2437 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2438 : : rsize, "ring_size");
2439 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2440 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2441 : : size, RTE_UINT16);
2442 : :
2443 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2444 : : .f = cmd_config_rxtx_ring_size_parsed,
2445 : : .data = NULL,
2446 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2447 : : .tokens = {
2448 : : (void *)&cmd_config_rxtx_ring_size_port,
2449 : : (void *)&cmd_config_rxtx_ring_size_config,
2450 : : (void *)&cmd_config_rxtx_ring_size_portid,
2451 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2452 : : (void *)&cmd_config_rxtx_ring_size_qid,
2453 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2454 : : (void *)&cmd_config_rxtx_ring_size_size,
2455 : : NULL,
2456 : : },
2457 : : };
2458 : :
2459 : : /* *** configure port rxq/txq start/stop *** */
2460 : : struct cmd_config_rxtx_queue {
2461 : : cmdline_fixed_string_t port;
2462 : : portid_t portid;
2463 : : cmdline_fixed_string_t rxtxq;
2464 : : uint16_t qid;
2465 : : cmdline_fixed_string_t opname;
2466 : : };
2467 : :
2468 : : static void
2469 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2470 : : __rte_unused struct cmdline *cl,
2471 : : __rte_unused void *data)
2472 : : {
2473 : : struct cmd_config_rxtx_queue *res = parsed_result;
2474 : : struct rte_port *port;
2475 : : uint8_t isrx;
2476 : : uint8_t isstart;
2477 : : uint8_t *state;
2478 : : int ret = 0;
2479 : :
2480 : 0 : if (test_done == 0) {
2481 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2482 : 0 : return;
2483 : : }
2484 : :
2485 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2486 : : return;
2487 : :
2488 : 0 : if (port_is_started(res->portid) != 1) {
2489 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2490 : 0 : return;
2491 : : }
2492 : :
2493 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2494 : : isrx = 1;
2495 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2496 : : isrx = 0;
2497 : : else {
2498 : 0 : fprintf(stderr, "Unknown parameter\n");
2499 : 0 : return;
2500 : : }
2501 : :
2502 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2503 : : return;
2504 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2505 : : return;
2506 : :
2507 : 0 : if (!strcmp(res->opname, "start"))
2508 : : isstart = 1;
2509 : 0 : else if (!strcmp(res->opname, "stop"))
2510 : : isstart = 0;
2511 : : else {
2512 : 0 : fprintf(stderr, "Unknown parameter\n");
2513 : 0 : return;
2514 : : }
2515 : :
2516 : 0 : if (isstart && isrx)
2517 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2518 : 0 : else if (!isstart && isrx)
2519 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2520 : 0 : else if (isstart && !isrx)
2521 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2522 : : else
2523 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2524 : :
2525 : 0 : if (ret == -ENOTSUP) {
2526 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2527 : 0 : return;
2528 : : }
2529 : :
2530 : 0 : port = &ports[res->portid];
2531 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2532 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2533 : : RTE_ETH_QUEUE_STATE_STOPPED;
2534 : : }
2535 : :
2536 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2537 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2538 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2539 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2540 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2541 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2542 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2543 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2544 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2545 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2546 : : "start#stop");
2547 : :
2548 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2549 : : .f = cmd_config_rxtx_queue_parsed,
2550 : : .data = NULL,
2551 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2552 : : .tokens = {
2553 : : (void *)&cmd_config_rxtx_queue_port,
2554 : : (void *)&cmd_config_rxtx_queue_portid,
2555 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2556 : : (void *)&cmd_config_rxtx_queue_qid,
2557 : : (void *)&cmd_config_rxtx_queue_opname,
2558 : : NULL,
2559 : : },
2560 : : };
2561 : :
2562 : : /* *** configure port rxq/txq deferred start on/off *** */
2563 : : struct cmd_config_deferred_start_rxtx_queue {
2564 : : cmdline_fixed_string_t port;
2565 : : portid_t port_id;
2566 : : cmdline_fixed_string_t rxtxq;
2567 : : uint16_t qid;
2568 : : cmdline_fixed_string_t opname;
2569 : : cmdline_fixed_string_t state;
2570 : : };
2571 : :
2572 : : static void
2573 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2574 : : __rte_unused struct cmdline *cl,
2575 : : __rte_unused void *data)
2576 : : {
2577 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2578 : : struct rte_port *port;
2579 : : uint8_t isrx;
2580 : : uint8_t ison;
2581 : : uint8_t needreconfig = 0;
2582 : :
2583 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2584 : : return;
2585 : :
2586 : 0 : if (port_is_started(res->port_id) != 0) {
2587 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2588 : 0 : return;
2589 : : }
2590 : :
2591 : 0 : port = &ports[res->port_id];
2592 : :
2593 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2594 : :
2595 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2596 : : return;
2597 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2598 : : return;
2599 : :
2600 : 0 : ison = !strcmp(res->state, "on");
2601 : :
2602 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2603 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2604 : : needreconfig = 1;
2605 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2606 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2607 : : needreconfig = 1;
2608 : : }
2609 : :
2610 : : if (needreconfig)
2611 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2612 : : }
2613 : :
2614 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2615 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2616 : : port, "port");
2617 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2618 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2619 : : port_id, RTE_UINT16);
2620 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2621 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2622 : : rxtxq, "rxq#txq");
2623 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2624 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2625 : : qid, RTE_UINT16);
2626 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2627 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2628 : : opname, "deferred_start");
2629 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2630 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2631 : : state, "on#off");
2632 : :
2633 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2634 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2635 : : .data = NULL,
2636 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2637 : : .tokens = {
2638 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2639 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2640 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2641 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2642 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2643 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2644 : : NULL,
2645 : : },
2646 : : };
2647 : :
2648 : : /* *** configure port rxq/txq setup *** */
2649 : : struct cmd_setup_rxtx_queue {
2650 : : cmdline_fixed_string_t port;
2651 : : portid_t portid;
2652 : : cmdline_fixed_string_t rxtxq;
2653 : : uint16_t qid;
2654 : : cmdline_fixed_string_t setup;
2655 : : };
2656 : :
2657 : : /* Common CLI fields for queue setup */
2658 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2659 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2660 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2661 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2662 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2663 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2664 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2665 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2666 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2667 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2668 : :
2669 : : static void
2670 : 0 : cmd_setup_rxtx_queue_parsed(
2671 : : void *parsed_result,
2672 : : __rte_unused struct cmdline *cl,
2673 : : __rte_unused void *data)
2674 : : {
2675 : : struct cmd_setup_rxtx_queue *res = parsed_result;
2676 : : struct rte_port *port;
2677 : : struct rte_mempool *mp;
2678 : : unsigned int socket_id;
2679 : : uint8_t isrx = 0;
2680 : : int ret;
2681 : :
2682 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2683 : : return;
2684 : :
2685 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2686 : 0 : fprintf(stderr, "Invalid port id\n");
2687 : 0 : return;
2688 : : }
2689 : :
2690 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2691 : : isrx = 1;
2692 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2693 : : isrx = 0;
2694 : : else {
2695 : 0 : fprintf(stderr, "Unknown parameter\n");
2696 : 0 : return;
2697 : : }
2698 : :
2699 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
2700 : 0 : fprintf(stderr, "Invalid rx queue\n");
2701 : 0 : return;
2702 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2703 : 0 : fprintf(stderr, "Invalid tx queue\n");
2704 : 0 : return;
2705 : : }
2706 : :
2707 : 0 : port = &ports[res->portid];
2708 : 0 : if (isrx) {
2709 : 0 : socket_id = rxring_numa[res->portid];
2710 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2711 : 0 : socket_id = port->socket_id;
2712 : :
2713 : : mp = mbuf_pool_find(socket_id, 0);
2714 : 0 : if (mp == NULL) {
2715 : 0 : fprintf(stderr,
2716 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2717 : 0 : rxring_numa[res->portid]);
2718 : 0 : return;
2719 : : }
2720 : 0 : ret = rx_queue_setup(res->portid,
2721 : : res->qid,
2722 : 0 : port->nb_rx_desc[res->qid],
2723 : : socket_id,
2724 : 0 : &port->rxq[res->qid].conf,
2725 : : mp);
2726 : 0 : if (ret)
2727 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
2728 : : } else {
2729 : 0 : socket_id = txring_numa[res->portid];
2730 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2731 : 0 : socket_id = port->socket_id;
2732 : :
2733 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2734 : 0 : fprintf(stderr,
2735 : : "Failed to setup TX queue: not enough descriptors\n");
2736 : 0 : return;
2737 : : }
2738 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
2739 : : res->qid,
2740 : : port->nb_tx_desc[res->qid],
2741 : : socket_id,
2742 : 0 : &port->txq[res->qid].conf);
2743 : 0 : if (ret)
2744 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
2745 : : }
2746 : : }
2747 : :
2748 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2749 : : .f = cmd_setup_rxtx_queue_parsed,
2750 : : .data = NULL,
2751 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2752 : : .tokens = {
2753 : : (void *)&cmd_setup_rxtx_queue_port,
2754 : : (void *)&cmd_setup_rxtx_queue_portid,
2755 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
2756 : : (void *)&cmd_setup_rxtx_queue_qid,
2757 : : (void *)&cmd_setup_rxtx_queue_setup,
2758 : : NULL,
2759 : : },
2760 : : };
2761 : :
2762 : :
2763 : : /* *** Configure RSS RETA *** */
2764 : : struct cmd_config_rss_reta {
2765 : : cmdline_fixed_string_t port;
2766 : : cmdline_fixed_string_t keyword;
2767 : : portid_t port_id;
2768 : : cmdline_fixed_string_t name;
2769 : : cmdline_fixed_string_t list_name;
2770 : : cmdline_fixed_string_t list_of_items;
2771 : : };
2772 : :
2773 : : static int
2774 : 0 : parse_reta_config(const char *str,
2775 : : struct rte_eth_rss_reta_entry64 *reta_conf,
2776 : : uint16_t nb_entries)
2777 : : {
2778 : : int i;
2779 : : unsigned size;
2780 : : uint16_t hash_index, idx, shift;
2781 : : uint16_t nb_queue;
2782 : : char s[256];
2783 : : const char *p, *p0 = str;
2784 : : char *end;
2785 : : enum fieldnames {
2786 : : FLD_HASH_INDEX = 0,
2787 : : FLD_QUEUE,
2788 : : _NUM_FLD
2789 : : };
2790 : : unsigned long int_fld[_NUM_FLD];
2791 : : char *str_fld[_NUM_FLD];
2792 : :
2793 : 0 : while ((p = strchr(p0,'(')) != NULL) {
2794 : 0 : ++p;
2795 : 0 : if((p0 = strchr(p,')')) == NULL)
2796 : : return -1;
2797 : :
2798 : 0 : size = p0 - p;
2799 : 0 : if(size >= sizeof(s))
2800 : : return -1;
2801 : :
2802 : : snprintf(s, sizeof(s), "%.*s", size, p);
2803 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2804 : : return -1;
2805 : 0 : for (i = 0; i < _NUM_FLD; i++) {
2806 : 0 : errno = 0;
2807 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
2808 : 0 : if (errno != 0 || end == str_fld[i] ||
2809 : : int_fld[i] > 65535)
2810 : : return -1;
2811 : : }
2812 : :
2813 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2814 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2815 : :
2816 : 0 : if (hash_index >= nb_entries) {
2817 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
2818 : : hash_index);
2819 : 0 : return -1;
2820 : : }
2821 : :
2822 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2823 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2824 : 0 : reta_conf[idx].mask |= (1ULL << shift);
2825 : 0 : reta_conf[idx].reta[shift] = nb_queue;
2826 : : }
2827 : :
2828 : : return 0;
2829 : : }
2830 : :
2831 : : static void
2832 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
2833 : : __rte_unused struct cmdline *cl,
2834 : : __rte_unused void *data)
2835 : : {
2836 : : int ret;
2837 : : struct rte_eth_dev_info dev_info;
2838 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
2839 : : struct cmd_config_rss_reta *res = parsed_result;
2840 : :
2841 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2842 : 0 : if (ret != 0)
2843 : 0 : return;
2844 : :
2845 : 0 : if (dev_info.reta_size == 0) {
2846 : 0 : fprintf(stderr,
2847 : : "Redirection table size is 0 which is invalid for RSS\n");
2848 : 0 : return;
2849 : : } else
2850 : 0 : printf("The reta size of port %d is %u\n",
2851 : 0 : res->port_id, dev_info.reta_size);
2852 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
2853 : 0 : fprintf(stderr,
2854 : : "Currently do not support more than %u entries of redirection table\n",
2855 : : RTE_ETH_RSS_RETA_SIZE_512);
2856 : 0 : return;
2857 : : }
2858 : :
2859 : : memset(reta_conf, 0, sizeof(reta_conf));
2860 : 0 : if (!strcmp(res->list_name, "reta")) {
2861 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
2862 : : dev_info.reta_size)) {
2863 : 0 : fprintf(stderr,
2864 : : "Invalid RSS Redirection Table config entered\n");
2865 : 0 : return;
2866 : : }
2867 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
2868 : 0 : reta_conf, dev_info.reta_size);
2869 : 0 : if (ret != 0)
2870 : 0 : fprintf(stderr,
2871 : : "Bad redirection table parameter, return code = %d\n",
2872 : : ret);
2873 : : }
2874 : : }
2875 : :
2876 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
2877 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2878 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2880 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2881 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2882 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
2883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2884 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2885 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2886 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2888 : : NULL);
2889 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
2890 : : .f = cmd_set_rss_reta_parsed,
2891 : : .data = NULL,
2892 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2893 : : .tokens = {
2894 : : (void *)&cmd_config_rss_reta_port,
2895 : : (void *)&cmd_config_rss_reta_keyword,
2896 : : (void *)&cmd_config_rss_reta_port_id,
2897 : : (void *)&cmd_config_rss_reta_name,
2898 : : (void *)&cmd_config_rss_reta_list_name,
2899 : : (void *)&cmd_config_rss_reta_list_of_items,
2900 : : NULL,
2901 : : },
2902 : : };
2903 : :
2904 : : /* *** SHOW PORT RETA INFO *** */
2905 : : struct cmd_showport_reta {
2906 : : cmdline_fixed_string_t show;
2907 : : cmdline_fixed_string_t port;
2908 : : portid_t port_id;
2909 : : cmdline_fixed_string_t rss;
2910 : : cmdline_fixed_string_t reta;
2911 : : uint16_t size;
2912 : : cmdline_fixed_string_t list_of_items;
2913 : : };
2914 : :
2915 : : static int
2916 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2917 : : uint16_t nb_entries,
2918 : : char *str)
2919 : : {
2920 : : uint32_t size;
2921 : : const char *p, *p0 = str;
2922 : : char s[256];
2923 : : char *end;
2924 : : char *str_fld[8];
2925 : : uint16_t i;
2926 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
2927 : : RTE_ETH_RETA_GROUP_SIZE;
2928 : : int ret;
2929 : :
2930 : 0 : p = strchr(p0, '(');
2931 : 0 : if (p == NULL)
2932 : : return -1;
2933 : 0 : p++;
2934 : 0 : p0 = strchr(p, ')');
2935 : 0 : if (p0 == NULL)
2936 : : return -1;
2937 : 0 : size = p0 - p;
2938 : 0 : if (size >= sizeof(s)) {
2939 : 0 : fprintf(stderr,
2940 : : "The string size exceeds the internal buffer size\n");
2941 : 0 : return -1;
2942 : : }
2943 : : snprintf(s, sizeof(s), "%.*s", size, p);
2944 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2945 : 0 : if (ret <= 0 || ret != num) {
2946 : 0 : fprintf(stderr,
2947 : : "The bits of masks do not match the number of reta entries: %u\n",
2948 : : num);
2949 : 0 : return -1;
2950 : : }
2951 : 0 : for (i = 0; i < ret; i++)
2952 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
2953 : :
2954 : : return 0;
2955 : : }
2956 : :
2957 : : static void
2958 : 0 : cmd_showport_reta_parsed(void *parsed_result,
2959 : : __rte_unused struct cmdline *cl,
2960 : : __rte_unused void *data)
2961 : : {
2962 : : struct cmd_showport_reta *res = parsed_result;
2963 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
2964 : : struct rte_eth_dev_info dev_info;
2965 : : uint16_t max_reta_size;
2966 : : int ret;
2967 : :
2968 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2969 : 0 : if (ret != 0)
2970 : 0 : return;
2971 : :
2972 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
2973 : 0 : if (res->size == 0 || res->size > max_reta_size) {
2974 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
2975 : : res->size, max_reta_size);
2976 : 0 : return;
2977 : : }
2978 : :
2979 : : memset(reta_conf, 0, sizeof(reta_conf));
2980 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
2981 : 0 : res->list_of_items) < 0) {
2982 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
2983 : : res->list_of_items);
2984 : 0 : return;
2985 : : }
2986 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
2987 : : }
2988 : :
2989 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
2990 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2991 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
2992 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2993 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
2994 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
2995 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
2996 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2997 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
2998 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2999 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3000 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3001 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3002 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3003 : : list_of_items, NULL);
3004 : :
3005 : : static cmdline_parse_inst_t cmd_showport_reta = {
3006 : : .f = cmd_showport_reta_parsed,
3007 : : .data = NULL,
3008 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3009 : : .tokens = {
3010 : : (void *)&cmd_showport_reta_show,
3011 : : (void *)&cmd_showport_reta_port,
3012 : : (void *)&cmd_showport_reta_port_id,
3013 : : (void *)&cmd_showport_reta_rss,
3014 : : (void *)&cmd_showport_reta_reta,
3015 : : (void *)&cmd_showport_reta_size,
3016 : : (void *)&cmd_showport_reta_list_of_items,
3017 : : NULL,
3018 : : },
3019 : : };
3020 : :
3021 : : /* *** Show RSS hash configuration *** */
3022 : : struct cmd_showport_rss_hash {
3023 : : cmdline_fixed_string_t show;
3024 : : cmdline_fixed_string_t port;
3025 : : portid_t port_id;
3026 : : cmdline_fixed_string_t rss_hash;
3027 : : cmdline_fixed_string_t rss_type;
3028 : : cmdline_fixed_string_t key; /* optional argument */
3029 : : cmdline_fixed_string_t algorithm; /* optional argument */
3030 : : };
3031 : :
3032 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3033 : : __rte_unused struct cmdline *cl,
3034 : : __rte_unused void *data)
3035 : : {
3036 : : struct cmd_showport_rss_hash *res = parsed_result;
3037 : :
3038 : 0 : port_rss_hash_conf_show(res->port_id,
3039 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3040 : 0 : }
3041 : :
3042 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3043 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3044 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3045 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3046 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3047 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3048 : : RTE_UINT16);
3049 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3050 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3051 : : "rss-hash");
3052 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3053 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3054 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3055 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3056 : :
3057 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3058 : : .f = cmd_showport_rss_hash_parsed,
3059 : : .data = NULL,
3060 : : .help_str = "show port <port_id> rss-hash",
3061 : : .tokens = {
3062 : : (void *)&cmd_showport_rss_hash_show,
3063 : : (void *)&cmd_showport_rss_hash_port,
3064 : : (void *)&cmd_showport_rss_hash_port_id,
3065 : : (void *)&cmd_showport_rss_hash_rss_hash,
3066 : : NULL,
3067 : : },
3068 : : };
3069 : :
3070 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3071 : : .f = cmd_showport_rss_hash_parsed,
3072 : : .data = NULL,
3073 : : .help_str = "show port <port_id> rss-hash key",
3074 : : .tokens = {
3075 : : (void *)&cmd_showport_rss_hash_show,
3076 : : (void *)&cmd_showport_rss_hash_port,
3077 : : (void *)&cmd_showport_rss_hash_port_id,
3078 : : (void *)&cmd_showport_rss_hash_rss_hash,
3079 : : (void *)&cmd_showport_rss_hash_rss_key,
3080 : : NULL,
3081 : : },
3082 : : };
3083 : :
3084 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3085 : : .f = cmd_showport_rss_hash_parsed,
3086 : : .data = NULL,
3087 : : .help_str = "show port <port_id> rss-hash algorithm",
3088 : : .tokens = {
3089 : : (void *)&cmd_showport_rss_hash_show,
3090 : : (void *)&cmd_showport_rss_hash_port,
3091 : : (void *)&cmd_showport_rss_hash_port_id,
3092 : : (void *)&cmd_showport_rss_hash_rss_hash,
3093 : : (void *)&cmd_showport_rss_hash_rss_algo,
3094 : : NULL,
3095 : : },
3096 : : };
3097 : :
3098 : : /* *** Configure DCB *** */
3099 : : struct cmd_config_dcb {
3100 : : cmdline_fixed_string_t port;
3101 : : cmdline_fixed_string_t config;
3102 : : portid_t port_id;
3103 : : cmdline_fixed_string_t dcb;
3104 : : cmdline_fixed_string_t vt;
3105 : : cmdline_fixed_string_t vt_en;
3106 : : uint8_t num_tcs;
3107 : : cmdline_fixed_string_t pfc;
3108 : : cmdline_fixed_string_t pfc_en;
3109 : : };
3110 : :
3111 : : static void
3112 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3113 : : __rte_unused struct cmdline *cl,
3114 : : __rte_unused void *data)
3115 : : {
3116 : : struct cmd_config_dcb *res = parsed_result;
3117 : : struct rte_eth_dcb_info dcb_info;
3118 : 0 : portid_t port_id = res->port_id;
3119 : : struct rte_port *port;
3120 : : uint8_t pfc_en;
3121 : : int ret;
3122 : :
3123 : 0 : port = &ports[port_id];
3124 : : /** Check if the port is not started **/
3125 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3126 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3127 : 0 : return;
3128 : : }
3129 : :
3130 : 0 : if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3131 : 0 : fprintf(stderr,
3132 : : "The invalid number of traffic class, only 4 or 8 allowed.\n");
3133 : 0 : return;
3134 : : }
3135 : :
3136 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3137 : 0 : fprintf(stderr,
3138 : : "nb_cores shouldn't be less than number of TCs.\n");
3139 : 0 : return;
3140 : : }
3141 : :
3142 : : /* Check whether the port supports the report of DCB info. */
3143 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3144 : 0 : if (ret == -ENOTSUP) {
3145 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3146 : 0 : return;
3147 : : }
3148 : :
3149 : 0 : if (!strncmp(res->pfc_en, "on", 2))
3150 : : pfc_en = 1;
3151 : : else
3152 : : pfc_en = 0;
3153 : :
3154 : : /* DCB in VT mode */
3155 : 0 : if (!strncmp(res->vt_en, "on", 2))
3156 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3157 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3158 : : pfc_en);
3159 : : else
3160 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3161 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3162 : : pfc_en);
3163 : 0 : if (ret != 0) {
3164 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3165 : 0 : return;
3166 : : }
3167 : :
3168 : 0 : fwd_config_setup();
3169 : :
3170 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3171 : : }
3172 : :
3173 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3174 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3175 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3177 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3178 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3179 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3180 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3181 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3183 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3184 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3185 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3186 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3187 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3188 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3189 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3190 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3191 : :
3192 : : static cmdline_parse_inst_t cmd_config_dcb = {
3193 : : .f = cmd_config_dcb_parsed,
3194 : : .data = NULL,
3195 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3196 : : .tokens = {
3197 : : (void *)&cmd_config_dcb_port,
3198 : : (void *)&cmd_config_dcb_config,
3199 : : (void *)&cmd_config_dcb_port_id,
3200 : : (void *)&cmd_config_dcb_dcb,
3201 : : (void *)&cmd_config_dcb_vt,
3202 : : (void *)&cmd_config_dcb_vt_en,
3203 : : (void *)&cmd_config_dcb_num_tcs,
3204 : : (void *)&cmd_config_dcb_pfc,
3205 : : (void *)&cmd_config_dcb_pfc_en,
3206 : : NULL,
3207 : : },
3208 : : };
3209 : :
3210 : : /* *** configure number of packets per burst *** */
3211 : : struct cmd_config_burst {
3212 : : cmdline_fixed_string_t port;
3213 : : cmdline_fixed_string_t keyword;
3214 : : cmdline_fixed_string_t all;
3215 : : cmdline_fixed_string_t name;
3216 : : uint16_t value;
3217 : : };
3218 : :
3219 : : static void
3220 : 0 : cmd_config_burst_parsed(void *parsed_result,
3221 : : __rte_unused struct cmdline *cl,
3222 : : __rte_unused void *data)
3223 : : {
3224 : : struct cmd_config_burst *res = parsed_result;
3225 : : struct rte_eth_dev_info dev_info;
3226 : : uint16_t rec_nb_pkts;
3227 : : int ret;
3228 : :
3229 : 0 : if (!all_ports_stopped()) {
3230 : 0 : fprintf(stderr, "Please stop all ports first\n");
3231 : 0 : return;
3232 : : }
3233 : :
3234 : 0 : if (!strcmp(res->name, "burst")) {
3235 : 0 : if (res->value == 0) {
3236 : : /* If user gives a value of zero, query the PMD for
3237 : : * its recommended Rx burst size. Testpmd uses a single
3238 : : * size for all ports, so assume all ports are the same
3239 : : * NIC model and use the values from Port 0.
3240 : : */
3241 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3242 : 0 : if (ret != 0)
3243 : : return;
3244 : :
3245 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3246 : :
3247 : 0 : if (rec_nb_pkts == 0) {
3248 : : printf("PMD does not recommend a burst size.\n"
3249 : : "User provided value must be between"
3250 : : " 1 and %d\n", MAX_PKT_BURST);
3251 : 0 : return;
3252 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3253 : 0 : printf("PMD recommended burst size of %d"
3254 : : " exceeds maximum value of %d\n",
3255 : : rec_nb_pkts, MAX_PKT_BURST);
3256 : 0 : return;
3257 : : }
3258 : 0 : printf("Using PMD-provided burst value of %d\n",
3259 : : rec_nb_pkts);
3260 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3261 : 0 : } else if (res->value > MAX_PKT_BURST) {
3262 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3263 : : MAX_PKT_BURST);
3264 : 0 : return;
3265 : : } else
3266 : 0 : nb_pkt_per_burst = res->value;
3267 : : } else {
3268 : 0 : fprintf(stderr, "Unknown parameter\n");
3269 : 0 : return;
3270 : : }
3271 : :
3272 : 0 : init_port_config();
3273 : :
3274 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3275 : : }
3276 : :
3277 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3278 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3279 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3280 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3281 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3282 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3283 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3284 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3285 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3286 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3287 : :
3288 : : static cmdline_parse_inst_t cmd_config_burst = {
3289 : : .f = cmd_config_burst_parsed,
3290 : : .data = NULL,
3291 : : .help_str = "port config all burst <value>",
3292 : : .tokens = {
3293 : : (void *)&cmd_config_burst_port,
3294 : : (void *)&cmd_config_burst_keyword,
3295 : : (void *)&cmd_config_burst_all,
3296 : : (void *)&cmd_config_burst_name,
3297 : : (void *)&cmd_config_burst_value,
3298 : : NULL,
3299 : : },
3300 : : };
3301 : :
3302 : : /* *** configure rx/tx queues *** */
3303 : : struct cmd_config_thresh {
3304 : : cmdline_fixed_string_t port;
3305 : : cmdline_fixed_string_t keyword;
3306 : : cmdline_fixed_string_t all;
3307 : : cmdline_fixed_string_t name;
3308 : : uint8_t value;
3309 : : };
3310 : :
3311 : : static void
3312 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3313 : : __rte_unused struct cmdline *cl,
3314 : : __rte_unused void *data)
3315 : : {
3316 : : struct cmd_config_thresh *res = parsed_result;
3317 : :
3318 : 0 : if (!all_ports_stopped()) {
3319 : 0 : fprintf(stderr, "Please stop all ports first\n");
3320 : 0 : return;
3321 : : }
3322 : :
3323 : 0 : if (!strcmp(res->name, "txpt"))
3324 : 0 : tx_pthresh = res->value;
3325 : 0 : else if(!strcmp(res->name, "txht"))
3326 : 0 : tx_hthresh = res->value;
3327 : 0 : else if(!strcmp(res->name, "txwt"))
3328 : 0 : tx_wthresh = res->value;
3329 : 0 : else if(!strcmp(res->name, "rxpt"))
3330 : 0 : rx_pthresh = res->value;
3331 : 0 : else if(!strcmp(res->name, "rxht"))
3332 : 0 : rx_hthresh = res->value;
3333 : 0 : else if(!strcmp(res->name, "rxwt"))
3334 : 0 : rx_wthresh = res->value;
3335 : : else {
3336 : 0 : fprintf(stderr, "Unknown parameter\n");
3337 : 0 : return;
3338 : : }
3339 : :
3340 : 0 : init_port_config();
3341 : :
3342 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3343 : : }
3344 : :
3345 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3346 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3347 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3348 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3349 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3350 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3351 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3352 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3353 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3354 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3355 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3356 : :
3357 : : static cmdline_parse_inst_t cmd_config_thresh = {
3358 : : .f = cmd_config_thresh_parsed,
3359 : : .data = NULL,
3360 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3361 : : .tokens = {
3362 : : (void *)&cmd_config_thresh_port,
3363 : : (void *)&cmd_config_thresh_keyword,
3364 : : (void *)&cmd_config_thresh_all,
3365 : : (void *)&cmd_config_thresh_name,
3366 : : (void *)&cmd_config_thresh_value,
3367 : : NULL,
3368 : : },
3369 : : };
3370 : :
3371 : : /* *** configure free/rs threshold *** */
3372 : : struct cmd_config_threshold {
3373 : : cmdline_fixed_string_t port;
3374 : : cmdline_fixed_string_t keyword;
3375 : : cmdline_fixed_string_t all;
3376 : : cmdline_fixed_string_t name;
3377 : : uint16_t value;
3378 : : };
3379 : :
3380 : : static void
3381 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3382 : : __rte_unused struct cmdline *cl,
3383 : : __rte_unused void *data)
3384 : : {
3385 : : struct cmd_config_threshold *res = parsed_result;
3386 : :
3387 : 0 : if (!all_ports_stopped()) {
3388 : 0 : fprintf(stderr, "Please stop all ports first\n");
3389 : 0 : return;
3390 : : }
3391 : :
3392 : 0 : if (!strcmp(res->name, "txfreet"))
3393 : 0 : tx_free_thresh = res->value;
3394 : 0 : else if (!strcmp(res->name, "txrst"))
3395 : 0 : tx_rs_thresh = res->value;
3396 : 0 : else if (!strcmp(res->name, "rxfreet"))
3397 : 0 : rx_free_thresh = res->value;
3398 : : else {
3399 : 0 : fprintf(stderr, "Unknown parameter\n");
3400 : 0 : return;
3401 : : }
3402 : :
3403 : 0 : init_port_config();
3404 : :
3405 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3406 : : }
3407 : :
3408 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3409 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3410 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3411 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3412 : : "config");
3413 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3414 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3415 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3416 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3417 : : "txfreet#txrst#rxfreet");
3418 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3419 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3420 : :
3421 : : static cmdline_parse_inst_t cmd_config_threshold = {
3422 : : .f = cmd_config_threshold_parsed,
3423 : : .data = NULL,
3424 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3425 : : .tokens = {
3426 : : (void *)&cmd_config_threshold_port,
3427 : : (void *)&cmd_config_threshold_keyword,
3428 : : (void *)&cmd_config_threshold_all,
3429 : : (void *)&cmd_config_threshold_name,
3430 : : (void *)&cmd_config_threshold_value,
3431 : : NULL,
3432 : : },
3433 : : };
3434 : :
3435 : : /* *** stop *** */
3436 : : struct cmd_stop_result {
3437 : : cmdline_fixed_string_t stop;
3438 : : };
3439 : :
3440 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3441 : : __rte_unused struct cmdline *cl,
3442 : : __rte_unused void *data)
3443 : : {
3444 : 0 : stop_packet_forwarding();
3445 : 0 : }
3446 : :
3447 : : static cmdline_parse_token_string_t cmd_stop_stop =
3448 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3449 : :
3450 : : static cmdline_parse_inst_t cmd_stop = {
3451 : : .f = cmd_stop_parsed,
3452 : : .data = NULL,
3453 : : .help_str = "stop: Stop packet forwarding",
3454 : : .tokens = {
3455 : : (void *)&cmd_stop_stop,
3456 : : NULL,
3457 : : },
3458 : : };
3459 : :
3460 : : static unsigned int
3461 : 0 : get_ptype(char *value)
3462 : : {
3463 : : uint32_t protocol;
3464 : :
3465 : 0 : if (!strcmp(value, "eth"))
3466 : : protocol = RTE_PTYPE_L2_ETHER;
3467 : 0 : else if (!strcmp(value, "ipv4"))
3468 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3469 : 0 : else if (!strcmp(value, "ipv6"))
3470 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3471 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3472 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3473 : 0 : else if (!strcmp(value, "ipv4-udp"))
3474 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3475 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3476 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3477 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3478 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3479 : 0 : else if (!strcmp(value, "ipv6-udp"))
3480 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3481 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3482 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3483 : 0 : else if (!strcmp(value, "grenat"))
3484 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3485 : 0 : else if (!strcmp(value, "inner-eth"))
3486 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3487 : 0 : else if (!strcmp(value, "inner-ipv4"))
3488 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3489 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3490 : 0 : else if (!strcmp(value, "inner-ipv6"))
3491 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3492 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3493 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
3494 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3495 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3496 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
3497 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3498 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3499 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
3500 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3501 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3502 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
3503 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3504 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3505 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
3506 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3507 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3508 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
3509 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3510 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3511 : : else {
3512 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
3513 : : protocol = RTE_PTYPE_UNKNOWN;
3514 : : }
3515 : :
3516 : 0 : return protocol;
3517 : : }
3518 : :
3519 : : /* *** SET RXHDRSLIST *** */
3520 : :
3521 : : unsigned int
3522 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
3523 : : unsigned int *parsed_items)
3524 : : {
3525 : : unsigned int nb_item;
3526 : : char *cur;
3527 : : char *tmp;
3528 : :
3529 : : nb_item = 0;
3530 : 0 : char *str2 = strdup(str);
3531 : 0 : cur = strtok_r(str2, ",", &tmp);
3532 : 0 : while (cur != NULL) {
3533 : 0 : parsed_items[nb_item] = get_ptype(cur);
3534 : 0 : cur = strtok_r(NULL, ",", &tmp);
3535 : 0 : nb_item++;
3536 : : }
3537 : 0 : if (nb_item > max_items)
3538 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3539 : : item_name, nb_item + 1, max_items);
3540 : 0 : free(str2);
3541 : 0 : return nb_item;
3542 : : }
3543 : :
3544 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3545 : :
3546 : : unsigned int
3547 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3548 : : unsigned int *parsed_items, int check_unique_values)
3549 : : {
3550 : : unsigned int nb_item;
3551 : : unsigned int value;
3552 : : unsigned int i;
3553 : : unsigned int j;
3554 : : int value_ok;
3555 : : char c;
3556 : :
3557 : : /*
3558 : : * First parse all items in the list and store their value.
3559 : : */
3560 : : value = 0;
3561 : : nb_item = 0;
3562 : : value_ok = 0;
3563 : 0 : for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3564 : 0 : c = str[i];
3565 : 0 : if ((c >= '0') && (c <= '9')) {
3566 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
3567 : : value_ok = 1;
3568 : 0 : continue;
3569 : : }
3570 : 0 : if (c != ',') {
3571 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
3572 : 0 : return 0;
3573 : : }
3574 : 0 : if (! value_ok) {
3575 : 0 : fprintf(stderr, "No valid value before comma\n");
3576 : 0 : return 0;
3577 : : }
3578 : 0 : if (nb_item < max_items) {
3579 : 0 : parsed_items[nb_item] = value;
3580 : : value_ok = 0;
3581 : : value = 0;
3582 : : }
3583 : 0 : nb_item++;
3584 : : }
3585 : 0 : if (nb_item >= max_items) {
3586 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3587 : : item_name, nb_item + 1, max_items);
3588 : 0 : return 0;
3589 : : }
3590 : 0 : parsed_items[nb_item++] = value;
3591 : 0 : if (! check_unique_values)
3592 : : return nb_item;
3593 : :
3594 : : /*
3595 : : * Then, check that all values in the list are different.
3596 : : * No optimization here...
3597 : : */
3598 : 0 : for (i = 0; i < nb_item; i++) {
3599 : 0 : for (j = i + 1; j < nb_item; j++) {
3600 : 0 : if (parsed_items[j] == parsed_items[i]) {
3601 : 0 : fprintf(stderr,
3602 : : "duplicated %s %u at index %u and %u\n",
3603 : : item_name, parsed_items[i], i, j);
3604 : 0 : return 0;
3605 : : }
3606 : : }
3607 : : }
3608 : : return nb_item;
3609 : : }
3610 : :
3611 : : struct cmd_set_list_result {
3612 : : cmdline_fixed_string_t cmd_keyword;
3613 : : cmdline_fixed_string_t list_name;
3614 : : cmdline_fixed_string_t list_of_items;
3615 : : };
3616 : :
3617 : 0 : static void cmd_set_list_parsed(void *parsed_result,
3618 : : __rte_unused struct cmdline *cl,
3619 : : __rte_unused void *data)
3620 : : {
3621 : : struct cmd_set_list_result *res;
3622 : : union {
3623 : : unsigned int lcorelist[RTE_MAX_LCORE];
3624 : : unsigned int portlist[RTE_MAX_ETHPORTS];
3625 : : } parsed_items;
3626 : : unsigned int nb_item;
3627 : :
3628 : 0 : if (test_done == 0) {
3629 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3630 : 0 : return;
3631 : : }
3632 : :
3633 : : res = parsed_result;
3634 : 0 : if (!strcmp(res->list_name, "corelist")) {
3635 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
3636 : : RTE_MAX_LCORE,
3637 : : parsed_items.lcorelist, 1);
3638 : 0 : if (nb_item > 0) {
3639 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3640 : 0 : fwd_config_setup();
3641 : : }
3642 : 0 : return;
3643 : : }
3644 : 0 : if (!strcmp(res->list_name, "portlist")) {
3645 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
3646 : : RTE_MAX_ETHPORTS,
3647 : : parsed_items.portlist, 1);
3648 : 0 : if (nb_item > 0) {
3649 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
3650 : 0 : fwd_config_setup();
3651 : : }
3652 : : }
3653 : : }
3654 : :
3655 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
3656 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3657 : : "set");
3658 : : static cmdline_parse_token_string_t cmd_set_list_name =
3659 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3660 : : "corelist#portlist");
3661 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
3662 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3663 : : NULL);
3664 : :
3665 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
3666 : : .f = cmd_set_list_parsed,
3667 : : .data = NULL,
3668 : : .help_str = "set corelist|portlist <list0[,list1]*>",
3669 : : .tokens = {
3670 : : (void *)&cmd_set_list_keyword,
3671 : : (void *)&cmd_set_list_name,
3672 : : (void *)&cmd_set_list_of_items,
3673 : : NULL,
3674 : : },
3675 : : };
3676 : :
3677 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3678 : :
3679 : : struct cmd_setmask_result {
3680 : : cmdline_fixed_string_t set;
3681 : : cmdline_fixed_string_t mask;
3682 : : uint64_t hexavalue;
3683 : : };
3684 : :
3685 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
3686 : : __rte_unused struct cmdline *cl,
3687 : : __rte_unused void *data)
3688 : : {
3689 : : struct cmd_setmask_result *res = parsed_result;
3690 : :
3691 : 0 : if (test_done == 0) {
3692 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3693 : 0 : return;
3694 : : }
3695 : 0 : if (!strcmp(res->mask, "coremask")) {
3696 : 0 : set_fwd_lcores_mask(res->hexavalue);
3697 : 0 : fwd_config_setup();
3698 : 0 : } else if (!strcmp(res->mask, "portmask")) {
3699 : 0 : set_fwd_ports_mask(res->hexavalue);
3700 : 0 : fwd_config_setup();
3701 : : }
3702 : : }
3703 : :
3704 : : static cmdline_parse_token_string_t cmd_setmask_set =
3705 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3706 : : static cmdline_parse_token_string_t cmd_setmask_mask =
3707 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3708 : : "coremask#portmask");
3709 : : static cmdline_parse_token_num_t cmd_setmask_value =
3710 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3711 : :
3712 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
3713 : : .f = cmd_set_mask_parsed,
3714 : : .data = NULL,
3715 : : .help_str = "set coremask|portmask <hexadecimal value>",
3716 : : .tokens = {
3717 : : (void *)&cmd_setmask_set,
3718 : : (void *)&cmd_setmask_mask,
3719 : : (void *)&cmd_setmask_value,
3720 : : NULL,
3721 : : },
3722 : : };
3723 : :
3724 : : /*
3725 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3726 : : */
3727 : : struct cmd_set_result {
3728 : : cmdline_fixed_string_t set;
3729 : : cmdline_fixed_string_t what;
3730 : : uint16_t value;
3731 : : };
3732 : :
3733 : 0 : static void cmd_set_parsed(void *parsed_result,
3734 : : __rte_unused struct cmdline *cl,
3735 : : __rte_unused void *data)
3736 : : {
3737 : : struct cmd_set_result *res = parsed_result;
3738 : 0 : if (!strcmp(res->what, "nbport")) {
3739 : 0 : set_fwd_ports_number(res->value);
3740 : 0 : fwd_config_setup();
3741 : 0 : } else if (!strcmp(res->what, "nbcore")) {
3742 : 0 : set_fwd_lcores_number(res->value);
3743 : 0 : fwd_config_setup();
3744 : 0 : } else if (!strcmp(res->what, "burst"))
3745 : 0 : set_nb_pkt_per_burst(res->value);
3746 : 0 : else if (!strcmp(res->what, "verbose"))
3747 : 0 : set_verbose_level(res->value);
3748 : 0 : }
3749 : :
3750 : : static cmdline_parse_token_string_t cmd_set_set =
3751 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3752 : : static cmdline_parse_token_string_t cmd_set_what =
3753 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3754 : : "nbport#nbcore#burst#verbose");
3755 : : static cmdline_parse_token_num_t cmd_set_value =
3756 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3757 : :
3758 : : static cmdline_parse_inst_t cmd_set_numbers = {
3759 : : .f = cmd_set_parsed,
3760 : : .data = NULL,
3761 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
3762 : : .tokens = {
3763 : : (void *)&cmd_set_set,
3764 : : (void *)&cmd_set_what,
3765 : : (void *)&cmd_set_value,
3766 : : NULL,
3767 : : },
3768 : : };
3769 : :
3770 : : /* *** SET LOG LEVEL CONFIGURATION *** */
3771 : :
3772 : : struct cmd_set_log_result {
3773 : : cmdline_fixed_string_t set;
3774 : : cmdline_fixed_string_t log;
3775 : : cmdline_fixed_string_t type;
3776 : : uint32_t level;
3777 : : };
3778 : :
3779 : : static void
3780 : 0 : cmd_set_log_parsed(void *parsed_result,
3781 : : __rte_unused struct cmdline *cl,
3782 : : __rte_unused void *data)
3783 : : {
3784 : : struct cmd_set_log_result *res;
3785 : : int ret;
3786 : :
3787 : : res = parsed_result;
3788 : 0 : if (!strcmp(res->type, "global"))
3789 : 0 : rte_log_set_global_level(res->level);
3790 : : else {
3791 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
3792 : 0 : if (ret < 0)
3793 : 0 : fprintf(stderr, "Unable to set log level\n");
3794 : : }
3795 : 0 : }
3796 : :
3797 : : static cmdline_parse_token_string_t cmd_set_log_set =
3798 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3799 : : static cmdline_parse_token_string_t cmd_set_log_log =
3800 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3801 : : static cmdline_parse_token_string_t cmd_set_log_type =
3802 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3803 : : static cmdline_parse_token_num_t cmd_set_log_level =
3804 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3805 : :
3806 : : static cmdline_parse_inst_t cmd_set_log = {
3807 : : .f = cmd_set_log_parsed,
3808 : : .data = NULL,
3809 : : .help_str = "set log global|<type> <level>",
3810 : : .tokens = {
3811 : : (void *)&cmd_set_log_set,
3812 : : (void *)&cmd_set_log_log,
3813 : : (void *)&cmd_set_log_type,
3814 : : (void *)&cmd_set_log_level,
3815 : : NULL,
3816 : : },
3817 : : };
3818 : :
3819 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3820 : :
3821 : : struct cmd_set_rxoffs_result {
3822 : : cmdline_fixed_string_t cmd_keyword;
3823 : : cmdline_fixed_string_t rxoffs;
3824 : : cmdline_fixed_string_t seg_offsets;
3825 : : };
3826 : :
3827 : : static void
3828 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
3829 : : __rte_unused struct cmdline *cl,
3830 : : __rte_unused void *data)
3831 : : {
3832 : : struct cmd_set_rxoffs_result *res;
3833 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3834 : : unsigned int nb_segs;
3835 : :
3836 : : res = parsed_result;
3837 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3838 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3839 : 0 : if (nb_segs > 0)
3840 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
3841 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3842 : 0 : }
3843 : :
3844 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3845 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3846 : : cmd_keyword, "set");
3847 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3848 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3849 : : rxoffs, "rxoffs");
3850 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3851 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3852 : : seg_offsets, NULL);
3853 : :
3854 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
3855 : : .f = cmd_set_rxoffs_parsed,
3856 : : .data = NULL,
3857 : : .help_str = "set rxoffs <len0[,len1]*>",
3858 : : .tokens = {
3859 : : (void *)&cmd_set_rxoffs_keyword,
3860 : : (void *)&cmd_set_rxoffs_name,
3861 : : (void *)&cmd_set_rxoffs_offsets,
3862 : : NULL,
3863 : : },
3864 : : };
3865 : :
3866 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3867 : :
3868 : : struct cmd_set_rxpkts_result {
3869 : : cmdline_fixed_string_t cmd_keyword;
3870 : : cmdline_fixed_string_t rxpkts;
3871 : : cmdline_fixed_string_t seg_lengths;
3872 : : };
3873 : :
3874 : : static void
3875 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
3876 : : __rte_unused struct cmdline *cl,
3877 : : __rte_unused void *data)
3878 : : {
3879 : : struct cmd_set_rxpkts_result *res;
3880 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3881 : : unsigned int nb_segs;
3882 : :
3883 : : res = parsed_result;
3884 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3885 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3886 : 0 : if (nb_segs > 0)
3887 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
3888 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3889 : 0 : }
3890 : :
3891 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3892 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3893 : : cmd_keyword, "set");
3894 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3895 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3896 : : rxpkts, "rxpkts");
3897 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3898 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3899 : : seg_lengths, NULL);
3900 : :
3901 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
3902 : : .f = cmd_set_rxpkts_parsed,
3903 : : .data = NULL,
3904 : : .help_str = "set rxpkts <len0[,len1]*>",
3905 : : .tokens = {
3906 : : (void *)&cmd_set_rxpkts_keyword,
3907 : : (void *)&cmd_set_rxpkts_name,
3908 : : (void *)&cmd_set_rxpkts_lengths,
3909 : : NULL,
3910 : : },
3911 : : };
3912 : :
3913 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
3914 : : struct cmd_set_rxhdrs_result {
3915 : : cmdline_fixed_string_t set;
3916 : : cmdline_fixed_string_t rxhdrs;
3917 : : cmdline_fixed_string_t values;
3918 : : };
3919 : :
3920 : : static void
3921 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
3922 : : __rte_unused struct cmdline *cl,
3923 : : __rte_unused void *data)
3924 : : {
3925 : : struct cmd_set_rxhdrs_result *res;
3926 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
3927 : : unsigned int nb_segs;
3928 : :
3929 : : res = parsed_result;
3930 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
3931 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
3932 : 0 : if (nb_segs > 0)
3933 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
3934 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3935 : 0 : }
3936 : :
3937 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
3938 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3939 : : set, "set");
3940 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
3941 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3942 : : rxhdrs, "rxhdrs");
3943 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
3944 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
3945 : : values, NULL);
3946 : :
3947 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
3948 : : .f = cmd_set_rxhdrs_parsed,
3949 : : .data = NULL,
3950 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
3951 : : .tokens = {
3952 : : (void *)&cmd_set_rxhdrs_set,
3953 : : (void *)&cmd_set_rxhdrs_rxhdrs,
3954 : : (void *)&cmd_set_rxhdrs_values,
3955 : : NULL,
3956 : : },
3957 : : };
3958 : :
3959 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3960 : :
3961 : : struct cmd_set_txpkts_result {
3962 : : cmdline_fixed_string_t cmd_keyword;
3963 : : cmdline_fixed_string_t txpkts;
3964 : : cmdline_fixed_string_t seg_lengths;
3965 : : };
3966 : :
3967 : : static void
3968 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
3969 : : __rte_unused struct cmdline *cl,
3970 : : __rte_unused void *data)
3971 : : {
3972 : : struct cmd_set_txpkts_result *res;
3973 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3974 : : unsigned int nb_segs;
3975 : :
3976 : : res = parsed_result;
3977 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3978 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3979 : 0 : if (nb_segs > 0)
3980 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
3981 : 0 : }
3982 : :
3983 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3984 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3985 : : cmd_keyword, "set");
3986 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
3987 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3988 : : txpkts, "txpkts");
3989 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3990 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3991 : : seg_lengths, NULL);
3992 : :
3993 : : static cmdline_parse_inst_t cmd_set_txpkts = {
3994 : : .f = cmd_set_txpkts_parsed,
3995 : : .data = NULL,
3996 : : .help_str = "set txpkts <len0[,len1]*>",
3997 : : .tokens = {
3998 : : (void *)&cmd_set_txpkts_keyword,
3999 : : (void *)&cmd_set_txpkts_name,
4000 : : (void *)&cmd_set_txpkts_lengths,
4001 : : NULL,
4002 : : },
4003 : : };
4004 : :
4005 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4006 : :
4007 : : struct cmd_set_txsplit_result {
4008 : : cmdline_fixed_string_t cmd_keyword;
4009 : : cmdline_fixed_string_t txsplit;
4010 : : cmdline_fixed_string_t mode;
4011 : : };
4012 : :
4013 : : static void
4014 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4015 : : __rte_unused struct cmdline *cl,
4016 : : __rte_unused void *data)
4017 : : {
4018 : : struct cmd_set_txsplit_result *res;
4019 : :
4020 : : res = parsed_result;
4021 : 0 : set_tx_pkt_split(res->mode);
4022 : 0 : }
4023 : :
4024 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4025 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4026 : : cmd_keyword, "set");
4027 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4028 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4029 : : txsplit, "txsplit");
4030 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4031 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4032 : : mode, NULL);
4033 : :
4034 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4035 : : .f = cmd_set_txsplit_parsed,
4036 : : .data = NULL,
4037 : : .help_str = "set txsplit on|off|rand",
4038 : : .tokens = {
4039 : : (void *)&cmd_set_txsplit_keyword,
4040 : : (void *)&cmd_set_txsplit_name,
4041 : : (void *)&cmd_set_txsplit_mode,
4042 : : NULL,
4043 : : },
4044 : : };
4045 : :
4046 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4047 : :
4048 : : struct cmd_set_txtimes_result {
4049 : : cmdline_fixed_string_t cmd_keyword;
4050 : : cmdline_fixed_string_t txtimes;
4051 : : cmdline_fixed_string_t tx_times;
4052 : : };
4053 : :
4054 : : static void
4055 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4056 : : __rte_unused struct cmdline *cl,
4057 : : __rte_unused void *data)
4058 : : {
4059 : : struct cmd_set_txtimes_result *res;
4060 : 0 : unsigned int tx_times[2] = {0, 0};
4061 : : unsigned int n_times;
4062 : :
4063 : : res = parsed_result;
4064 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4065 : : 2, tx_times, 0);
4066 : 0 : if (n_times == 2)
4067 : 0 : set_tx_pkt_times(tx_times);
4068 : 0 : }
4069 : :
4070 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4071 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4072 : : cmd_keyword, "set");
4073 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4074 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4075 : : txtimes, "txtimes");
4076 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4077 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4078 : : tx_times, NULL);
4079 : :
4080 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4081 : : .f = cmd_set_txtimes_parsed,
4082 : : .data = NULL,
4083 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4084 : : .tokens = {
4085 : : (void *)&cmd_set_txtimes_keyword,
4086 : : (void *)&cmd_set_txtimes_name,
4087 : : (void *)&cmd_set_txtimes_value,
4088 : : NULL,
4089 : : },
4090 : : };
4091 : :
4092 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4093 : : struct cmd_rx_vlan_filter_all_result {
4094 : : cmdline_fixed_string_t rx_vlan;
4095 : : cmdline_fixed_string_t what;
4096 : : cmdline_fixed_string_t all;
4097 : : portid_t port_id;
4098 : : };
4099 : :
4100 : : static void
4101 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4102 : : __rte_unused struct cmdline *cl,
4103 : : __rte_unused void *data)
4104 : : {
4105 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4106 : :
4107 : 0 : if (!strcmp(res->what, "add"))
4108 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4109 : : else
4110 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4111 : 0 : }
4112 : :
4113 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4114 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4115 : : rx_vlan, "rx_vlan");
4116 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4117 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4118 : : what, "add#rm");
4119 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4120 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4121 : : all, "all");
4122 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4123 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4124 : : port_id, RTE_UINT16);
4125 : :
4126 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4127 : : .f = cmd_rx_vlan_filter_all_parsed,
4128 : : .data = NULL,
4129 : : .help_str = "rx_vlan add|rm all <port_id>: "
4130 : : "Add/Remove all identifiers to/from the set of VLAN "
4131 : : "identifiers filtered by a port",
4132 : : .tokens = {
4133 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4134 : : (void *)&cmd_rx_vlan_filter_all_what,
4135 : : (void *)&cmd_rx_vlan_filter_all_all,
4136 : : (void *)&cmd_rx_vlan_filter_all_portid,
4137 : : NULL,
4138 : : },
4139 : : };
4140 : :
4141 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4142 : : struct cmd_vlan_offload_result {
4143 : : cmdline_fixed_string_t vlan;
4144 : : cmdline_fixed_string_t set;
4145 : : cmdline_fixed_string_t vlan_type;
4146 : : cmdline_fixed_string_t what;
4147 : : cmdline_fixed_string_t on;
4148 : : cmdline_fixed_string_t port_id;
4149 : : };
4150 : :
4151 : : static void
4152 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4153 : : __rte_unused struct cmdline *cl,
4154 : : __rte_unused void *data)
4155 : : {
4156 : : int on;
4157 : : struct cmd_vlan_offload_result *res = parsed_result;
4158 : : char *str;
4159 : : int i, len = 0;
4160 : : portid_t port_id = 0;
4161 : : unsigned int tmp;
4162 : :
4163 : 0 : str = res->port_id;
4164 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4165 : : i = 0;
4166 : : /* Get port_id first */
4167 : 0 : while(i < len){
4168 : 0 : if(str[i] == ',')
4169 : : break;
4170 : :
4171 : 0 : i++;
4172 : : }
4173 : 0 : str[i]='\0';
4174 : 0 : tmp = strtoul(str, NULL, 0);
4175 : : /* If port_id greater that what portid_t can represent, return */
4176 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4177 : : return;
4178 : 0 : port_id = (portid_t)tmp;
4179 : :
4180 : 0 : if (!strcmp(res->on, "on"))
4181 : : on = 1;
4182 : : else
4183 : : on = 0;
4184 : :
4185 : 0 : if (!strcmp(res->what, "strip"))
4186 : 0 : rx_vlan_strip_set(port_id, on);
4187 : 0 : else if(!strcmp(res->what, "stripq")){
4188 : : uint16_t queue_id = 0;
4189 : :
4190 : : /* No queue_id, return */
4191 : 0 : if(i + 1 >= len) {
4192 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4193 : 0 : return;
4194 : : }
4195 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4196 : : /* If queue_id greater that what 16-bits can represent, return */
4197 : 0 : if(tmp > 0xffff)
4198 : : return;
4199 : :
4200 : 0 : queue_id = (uint16_t)tmp;
4201 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4202 : : }
4203 : 0 : else if (!strcmp(res->what, "filter"))
4204 : 0 : rx_vlan_filter_set(port_id, on);
4205 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4206 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4207 : : else
4208 : 0 : vlan_extend_set(port_id, on);
4209 : :
4210 : : return;
4211 : : }
4212 : :
4213 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4214 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4215 : : vlan, "vlan");
4216 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4217 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4218 : : set, "set");
4219 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4220 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4221 : : what, "strip#filter#qinq_strip#extend#stripq");
4222 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4223 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4224 : : on, "on#off");
4225 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4226 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4227 : : port_id, NULL);
4228 : :
4229 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4230 : : .f = cmd_vlan_offload_parsed,
4231 : : .data = NULL,
4232 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4233 : : "<port_id[,queue_id]>: "
4234 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4235 : : .tokens = {
4236 : : (void *)&cmd_vlan_offload_vlan,
4237 : : (void *)&cmd_vlan_offload_set,
4238 : : (void *)&cmd_vlan_offload_what,
4239 : : (void *)&cmd_vlan_offload_on,
4240 : : (void *)&cmd_vlan_offload_portid,
4241 : : NULL,
4242 : : },
4243 : : };
4244 : :
4245 : : /* *** VLAN TPID SET ON A PORT *** */
4246 : : struct cmd_vlan_tpid_result {
4247 : : cmdline_fixed_string_t vlan;
4248 : : cmdline_fixed_string_t set;
4249 : : cmdline_fixed_string_t vlan_type;
4250 : : cmdline_fixed_string_t what;
4251 : : uint16_t tp_id;
4252 : : portid_t port_id;
4253 : : };
4254 : :
4255 : : static void
4256 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4257 : : __rte_unused struct cmdline *cl,
4258 : : __rte_unused void *data)
4259 : : {
4260 : : struct cmd_vlan_tpid_result *res = parsed_result;
4261 : : enum rte_vlan_type vlan_type;
4262 : :
4263 : 0 : if (!strcmp(res->vlan_type, "inner"))
4264 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4265 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4266 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4267 : : else {
4268 : 0 : fprintf(stderr, "Unknown vlan type\n");
4269 : 0 : return;
4270 : : }
4271 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4272 : : }
4273 : :
4274 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4275 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4276 : : vlan, "vlan");
4277 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4278 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4279 : : set, "set");
4280 : : static cmdline_parse_token_string_t cmd_vlan_type =
4281 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4282 : : vlan_type, "inner#outer");
4283 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4284 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4285 : : what, "tpid");
4286 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4287 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4288 : : tp_id, RTE_UINT16);
4289 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4290 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4291 : : port_id, RTE_UINT16);
4292 : :
4293 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4294 : : .f = cmd_vlan_tpid_parsed,
4295 : : .data = NULL,
4296 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4297 : : "Set the VLAN Ether type",
4298 : : .tokens = {
4299 : : (void *)&cmd_vlan_tpid_vlan,
4300 : : (void *)&cmd_vlan_tpid_set,
4301 : : (void *)&cmd_vlan_type,
4302 : : (void *)&cmd_vlan_tpid_what,
4303 : : (void *)&cmd_vlan_tpid_tpid,
4304 : : (void *)&cmd_vlan_tpid_portid,
4305 : : NULL,
4306 : : },
4307 : : };
4308 : :
4309 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4310 : : struct cmd_rx_vlan_filter_result {
4311 : : cmdline_fixed_string_t rx_vlan;
4312 : : cmdline_fixed_string_t what;
4313 : : uint16_t vlan_id;
4314 : : portid_t port_id;
4315 : : };
4316 : :
4317 : : static void
4318 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4319 : : __rte_unused struct cmdline *cl,
4320 : : __rte_unused void *data)
4321 : : {
4322 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4323 : :
4324 : 0 : if (!strcmp(res->what, "add"))
4325 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4326 : : else
4327 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4328 : 0 : }
4329 : :
4330 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4331 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4332 : : rx_vlan, "rx_vlan");
4333 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4334 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4335 : : what, "add#rm");
4336 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4337 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4338 : : vlan_id, RTE_UINT16);
4339 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4340 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4341 : : port_id, RTE_UINT16);
4342 : :
4343 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4344 : : .f = cmd_rx_vlan_filter_parsed,
4345 : : .data = NULL,
4346 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4347 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4348 : : "identifiers filtered by a port",
4349 : : .tokens = {
4350 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4351 : : (void *)&cmd_rx_vlan_filter_what,
4352 : : (void *)&cmd_rx_vlan_filter_vlanid,
4353 : : (void *)&cmd_rx_vlan_filter_portid,
4354 : : NULL,
4355 : : },
4356 : : };
4357 : :
4358 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4359 : : struct cmd_tx_vlan_set_result {
4360 : : cmdline_fixed_string_t tx_vlan;
4361 : : cmdline_fixed_string_t set;
4362 : : portid_t port_id;
4363 : : uint16_t vlan_id;
4364 : : };
4365 : :
4366 : : static void
4367 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4368 : : __rte_unused struct cmdline *cl,
4369 : : __rte_unused void *data)
4370 : : {
4371 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4372 : :
4373 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4374 : : return;
4375 : :
4376 : 0 : if (!port_is_stopped(res->port_id)) {
4377 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4378 : 0 : return;
4379 : : }
4380 : :
4381 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4382 : :
4383 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4384 : : }
4385 : :
4386 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4387 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4388 : : tx_vlan, "tx_vlan");
4389 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4390 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4391 : : set, "set");
4392 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4393 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4394 : : port_id, RTE_UINT16);
4395 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4396 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4397 : : vlan_id, RTE_UINT16);
4398 : :
4399 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4400 : : .f = cmd_tx_vlan_set_parsed,
4401 : : .data = NULL,
4402 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4403 : : "Enable hardware insertion of a single VLAN header "
4404 : : "with a given TAG Identifier in packets sent on a port",
4405 : : .tokens = {
4406 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4407 : : (void *)&cmd_tx_vlan_set_set,
4408 : : (void *)&cmd_tx_vlan_set_portid,
4409 : : (void *)&cmd_tx_vlan_set_vlanid,
4410 : : NULL,
4411 : : },
4412 : : };
4413 : :
4414 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4415 : : struct cmd_tx_vlan_set_qinq_result {
4416 : : cmdline_fixed_string_t tx_vlan;
4417 : : cmdline_fixed_string_t set;
4418 : : portid_t port_id;
4419 : : uint16_t vlan_id;
4420 : : uint16_t vlan_id_outer;
4421 : : };
4422 : :
4423 : : static void
4424 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4425 : : __rte_unused struct cmdline *cl,
4426 : : __rte_unused void *data)
4427 : : {
4428 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4429 : :
4430 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4431 : : return;
4432 : :
4433 : 0 : if (!port_is_stopped(res->port_id)) {
4434 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4435 : 0 : return;
4436 : : }
4437 : :
4438 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4439 : :
4440 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4441 : : }
4442 : :
4443 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4444 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4445 : : tx_vlan, "tx_vlan");
4446 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4447 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4448 : : set, "set");
4449 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4450 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4451 : : port_id, RTE_UINT16);
4452 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4453 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4454 : : vlan_id, RTE_UINT16);
4455 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4456 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4457 : : vlan_id_outer, RTE_UINT16);
4458 : :
4459 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4460 : : .f = cmd_tx_vlan_set_qinq_parsed,
4461 : : .data = NULL,
4462 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4463 : : "Enable hardware insertion of double VLAN header "
4464 : : "with given TAG Identifiers in packets sent on a port",
4465 : : .tokens = {
4466 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4467 : : (void *)&cmd_tx_vlan_set_qinq_set,
4468 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4469 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4470 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4471 : : NULL,
4472 : : },
4473 : : };
4474 : :
4475 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4476 : : struct cmd_tx_vlan_set_pvid_result {
4477 : : cmdline_fixed_string_t tx_vlan;
4478 : : cmdline_fixed_string_t set;
4479 : : cmdline_fixed_string_t pvid;
4480 : : portid_t port_id;
4481 : : uint16_t vlan_id;
4482 : : cmdline_fixed_string_t mode;
4483 : : };
4484 : :
4485 : : static void
4486 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4487 : : __rte_unused struct cmdline *cl,
4488 : : __rte_unused void *data)
4489 : : {
4490 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4491 : :
4492 : 0 : if (strcmp(res->mode, "on") == 0)
4493 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4494 : : else
4495 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4496 : 0 : }
4497 : :
4498 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4499 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4500 : : tx_vlan, "tx_vlan");
4501 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4502 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4503 : : set, "set");
4504 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4505 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4506 : : pvid, "pvid");
4507 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4508 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4509 : : port_id, RTE_UINT16);
4510 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4511 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4512 : : vlan_id, RTE_UINT16);
4513 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4514 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4515 : : mode, "on#off");
4516 : :
4517 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4518 : : .f = cmd_tx_vlan_set_pvid_parsed,
4519 : : .data = NULL,
4520 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4521 : : .tokens = {
4522 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4523 : : (void *)&cmd_tx_vlan_set_pvid_set,
4524 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
4525 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
4526 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4527 : : (void *)&cmd_tx_vlan_set_pvid_mode,
4528 : : NULL,
4529 : : },
4530 : : };
4531 : :
4532 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4533 : : struct cmd_tx_vlan_reset_result {
4534 : : cmdline_fixed_string_t tx_vlan;
4535 : : cmdline_fixed_string_t reset;
4536 : : portid_t port_id;
4537 : : };
4538 : :
4539 : : static void
4540 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
4541 : : __rte_unused struct cmdline *cl,
4542 : : __rte_unused void *data)
4543 : : {
4544 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
4545 : :
4546 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4547 : : return;
4548 : :
4549 : 0 : if (!port_is_stopped(res->port_id)) {
4550 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4551 : 0 : return;
4552 : : }
4553 : :
4554 : 0 : tx_vlan_reset(res->port_id);
4555 : :
4556 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4557 : : }
4558 : :
4559 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4560 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4561 : : tx_vlan, "tx_vlan");
4562 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4563 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4564 : : reset, "reset");
4565 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4566 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4567 : : port_id, RTE_UINT16);
4568 : :
4569 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4570 : : .f = cmd_tx_vlan_reset_parsed,
4571 : : .data = NULL,
4572 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4573 : : "VLAN header in packets sent on a port",
4574 : : .tokens = {
4575 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
4576 : : (void *)&cmd_tx_vlan_reset_reset,
4577 : : (void *)&cmd_tx_vlan_reset_portid,
4578 : : NULL,
4579 : : },
4580 : : };
4581 : :
4582 : :
4583 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4584 : : struct cmd_csum_result {
4585 : : cmdline_fixed_string_t csum;
4586 : : cmdline_fixed_string_t mode;
4587 : : cmdline_fixed_string_t proto;
4588 : : cmdline_fixed_string_t hwsw;
4589 : : portid_t port_id;
4590 : : };
4591 : :
4592 : : static void
4593 : 0 : csum_show(int port_id)
4594 : : {
4595 : : struct rte_eth_dev_info dev_info;
4596 : : uint64_t tx_offloads;
4597 : : int ret;
4598 : :
4599 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4600 : 0 : printf("Parse tunnel is %s\n",
4601 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
4602 : 0 : printf("IP checksum offload is %s\n",
4603 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4604 : 0 : printf("UDP checksum offload is %s\n",
4605 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4606 : 0 : printf("TCP checksum offload is %s\n",
4607 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4608 : 0 : printf("SCTP checksum offload is %s\n",
4609 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4610 : 0 : printf("Outer-Ip checksum offload is %s\n",
4611 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4612 : 0 : printf("Outer-Udp checksum offload is %s\n",
4613 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4614 : :
4615 : : /* display warnings if configuration is not supported by the NIC */
4616 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
4617 : 0 : if (ret != 0)
4618 : 0 : return;
4619 : :
4620 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4621 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4622 : 0 : fprintf(stderr,
4623 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
4624 : : port_id);
4625 : : }
4626 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4627 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4628 : 0 : fprintf(stderr,
4629 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4630 : : port_id);
4631 : : }
4632 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4633 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4634 : 0 : fprintf(stderr,
4635 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4636 : : port_id);
4637 : : }
4638 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4639 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4640 : 0 : fprintf(stderr,
4641 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4642 : : port_id);
4643 : : }
4644 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4645 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4646 : 0 : fprintf(stderr,
4647 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4648 : : port_id);
4649 : : }
4650 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4651 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4652 : : == 0) {
4653 : 0 : fprintf(stderr,
4654 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4655 : : port_id);
4656 : : }
4657 : : }
4658 : :
4659 : : static void
4660 : : cmd_config_queue_tx_offloads(struct rte_port *port)
4661 : : {
4662 : : int k;
4663 : :
4664 : : /* Apply queue tx offloads configuration */
4665 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
4666 : 0 : port->txq[k].conf.offloads =
4667 : 0 : port->dev_conf.txmode.offloads;
4668 : : }
4669 : :
4670 : : static void
4671 : 0 : cmd_csum_parsed(void *parsed_result,
4672 : : __rte_unused struct cmdline *cl,
4673 : : __rte_unused void *data)
4674 : : {
4675 : : struct cmd_csum_result *res = parsed_result;
4676 : : int hw = 0;
4677 : : uint64_t csum_offloads = 0;
4678 : : struct rte_eth_dev_info dev_info;
4679 : : int ret;
4680 : :
4681 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4682 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
4683 : 0 : return;
4684 : : }
4685 : 0 : if (!port_is_stopped(res->port_id)) {
4686 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4687 : 0 : return;
4688 : : }
4689 : :
4690 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4691 : 0 : if (ret != 0)
4692 : : return;
4693 : :
4694 : 0 : if (!strcmp(res->mode, "set")) {
4695 : :
4696 : 0 : if (!strcmp(res->hwsw, "hw"))
4697 : : hw = 1;
4698 : :
4699 : 0 : if (!strcmp(res->proto, "ip")) {
4700 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4701 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4702 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4703 : : } else {
4704 : 0 : fprintf(stderr,
4705 : : "IP checksum offload is not supported by port %u\n",
4706 : 0 : res->port_id);
4707 : : }
4708 : 0 : } else if (!strcmp(res->proto, "udp")) {
4709 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4710 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4711 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4712 : : } else {
4713 : 0 : fprintf(stderr,
4714 : : "UDP checksum offload is not supported by port %u\n",
4715 : 0 : res->port_id);
4716 : : }
4717 : 0 : } else if (!strcmp(res->proto, "tcp")) {
4718 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4719 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4720 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4721 : : } else {
4722 : 0 : fprintf(stderr,
4723 : : "TCP checksum offload is not supported by port %u\n",
4724 : 0 : res->port_id);
4725 : : }
4726 : 0 : } else if (!strcmp(res->proto, "sctp")) {
4727 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4728 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4729 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4730 : : } else {
4731 : 0 : fprintf(stderr,
4732 : : "SCTP checksum offload is not supported by port %u\n",
4733 : 0 : res->port_id);
4734 : : }
4735 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
4736 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4737 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4738 : : csum_offloads |=
4739 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4740 : : } else {
4741 : 0 : fprintf(stderr,
4742 : : "Outer IP checksum offload is not supported by port %u\n",
4743 : 0 : res->port_id);
4744 : : }
4745 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
4746 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4747 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4748 : : csum_offloads |=
4749 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4750 : : } else {
4751 : 0 : fprintf(stderr,
4752 : : "Outer UDP checksum offload is not supported by port %u\n",
4753 : 0 : res->port_id);
4754 : : }
4755 : : }
4756 : :
4757 : 0 : if (hw) {
4758 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
4759 : : csum_offloads;
4760 : : } else {
4761 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
4762 : 0 : (~csum_offloads);
4763 : : }
4764 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
4765 : : }
4766 : 0 : csum_show(res->port_id);
4767 : :
4768 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4769 : : }
4770 : :
4771 : : static cmdline_parse_token_string_t cmd_csum_csum =
4772 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4773 : : csum, "csum");
4774 : : static cmdline_parse_token_string_t cmd_csum_mode =
4775 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4776 : : mode, "set");
4777 : : static cmdline_parse_token_string_t cmd_csum_proto =
4778 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4779 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4780 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
4781 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4782 : : hwsw, "hw#sw");
4783 : : static cmdline_parse_token_num_t cmd_csum_portid =
4784 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4785 : : port_id, RTE_UINT16);
4786 : :
4787 : : static cmdline_parse_inst_t cmd_csum_set = {
4788 : : .f = cmd_csum_parsed,
4789 : : .data = NULL,
4790 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4791 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
4792 : : "using csum forward engine",
4793 : : .tokens = {
4794 : : (void *)&cmd_csum_csum,
4795 : : (void *)&cmd_csum_mode,
4796 : : (void *)&cmd_csum_proto,
4797 : : (void *)&cmd_csum_hwsw,
4798 : : (void *)&cmd_csum_portid,
4799 : : NULL,
4800 : : },
4801 : : };
4802 : :
4803 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
4804 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4805 : : mode, "show");
4806 : :
4807 : : static cmdline_parse_inst_t cmd_csum_show = {
4808 : : .f = cmd_csum_parsed,
4809 : : .data = NULL,
4810 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
4811 : : .tokens = {
4812 : : (void *)&cmd_csum_csum,
4813 : : (void *)&cmd_csum_mode_show,
4814 : : (void *)&cmd_csum_portid,
4815 : : NULL,
4816 : : },
4817 : : };
4818 : :
4819 : : /* Enable/disable tunnel parsing */
4820 : : struct cmd_csum_tunnel_result {
4821 : : cmdline_fixed_string_t csum;
4822 : : cmdline_fixed_string_t parse;
4823 : : cmdline_fixed_string_t onoff;
4824 : : portid_t port_id;
4825 : : };
4826 : :
4827 : : static void
4828 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
4829 : : __rte_unused struct cmdline *cl,
4830 : : __rte_unused void *data)
4831 : : {
4832 : : struct cmd_csum_tunnel_result *res = parsed_result;
4833 : :
4834 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4835 : : return;
4836 : :
4837 : 0 : if (!strcmp(res->onoff, "on"))
4838 : 0 : ports[res->port_id].parse_tunnel = 1;
4839 : : else
4840 : 0 : ports[res->port_id].parse_tunnel = 0;
4841 : :
4842 : 0 : csum_show(res->port_id);
4843 : : }
4844 : :
4845 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4846 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4847 : : csum, "csum");
4848 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4849 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4850 : : parse, "parse-tunnel");
4851 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4852 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4853 : : onoff, "on#off");
4854 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4855 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4856 : : port_id, RTE_UINT16);
4857 : :
4858 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
4859 : : .f = cmd_csum_tunnel_parsed,
4860 : : .data = NULL,
4861 : : .help_str = "csum parse-tunnel on|off <port_id>: "
4862 : : "Enable/Disable parsing of tunnels for csum engine",
4863 : : .tokens = {
4864 : : (void *)&cmd_csum_tunnel_csum,
4865 : : (void *)&cmd_csum_tunnel_parse,
4866 : : (void *)&cmd_csum_tunnel_onoff,
4867 : : (void *)&cmd_csum_tunnel_portid,
4868 : : NULL,
4869 : : },
4870 : : };
4871 : :
4872 : : struct cmd_csum_mac_swap_result {
4873 : : cmdline_fixed_string_t csum;
4874 : : cmdline_fixed_string_t parse;
4875 : : cmdline_fixed_string_t onoff;
4876 : : portid_t port_id;
4877 : : };
4878 : :
4879 : : static void
4880 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
4881 : : __rte_unused struct cmdline *cl,
4882 : : __rte_unused void *data)
4883 : : {
4884 : : struct cmd_csum_mac_swap_result *res = parsed_result;
4885 : :
4886 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4887 : : return;
4888 : 0 : if (strcmp(res->onoff, "on") == 0)
4889 : 0 : ports[res->port_id].fwd_mac_swap = 1;
4890 : : else
4891 : 0 : ports[res->port_id].fwd_mac_swap = 0;
4892 : : }
4893 : :
4894 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
4895 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4896 : : csum, "csum");
4897 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
4898 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4899 : : parse, "mac-swap");
4900 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
4901 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4902 : : onoff, "on#off");
4903 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
4904 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
4905 : : port_id, RTE_UINT16);
4906 : :
4907 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
4908 : : .f = cmd_csum_mac_swap_parsed,
4909 : : .data = NULL,
4910 : : .help_str = "csum mac-swap on|off <port_id>: "
4911 : : "Enable/Disable forward mac address swap",
4912 : : .tokens = {
4913 : : (void *)&cmd_csum_mac_swap_csum,
4914 : : (void *)&cmd_csum_mac_swap_parse,
4915 : : (void *)&cmd_csum_mac_swap_onoff,
4916 : : (void *)&cmd_csum_mac_swap_portid,
4917 : : NULL,
4918 : : },
4919 : : };
4920 : :
4921 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4922 : : struct cmd_tso_set_result {
4923 : : cmdline_fixed_string_t tso;
4924 : : cmdline_fixed_string_t mode;
4925 : : uint16_t tso_segsz;
4926 : : portid_t port_id;
4927 : : };
4928 : :
4929 : : static void
4930 : 0 : cmd_tso_set_parsed(void *parsed_result,
4931 : : __rte_unused struct cmdline *cl,
4932 : : __rte_unused void *data)
4933 : : {
4934 : : struct cmd_tso_set_result *res = parsed_result;
4935 : : struct rte_eth_dev_info dev_info;
4936 : : uint64_t offloads;
4937 : : int ret;
4938 : :
4939 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4940 : 0 : return;
4941 : 0 : if (!port_is_stopped(res->port_id)) {
4942 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4943 : 0 : return;
4944 : : }
4945 : :
4946 : 0 : if (!strcmp(res->mode, "set"))
4947 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
4948 : :
4949 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4950 : 0 : if (ret != 0)
4951 : : return;
4952 : :
4953 : 0 : if (ports[res->port_id].tso_segsz != 0) {
4954 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
4955 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
4956 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
4957 : : res->port_id);
4958 : 0 : return;
4959 : : }
4960 : : /* display warnings if configuration is not supported by the NIC */
4961 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
4962 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
4963 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
4964 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
4965 : : }
4966 : :
4967 : 0 : if (ports[res->port_id].tso_segsz == 0) {
4968 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
4969 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
4970 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
4971 : : } else {
4972 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
4973 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
4974 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
4975 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
4976 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
4977 : 0 : printf("segment size for non-tunneled packets is %d\n",
4978 : : ports[res->port_id].tso_segsz);
4979 : : }
4980 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
4981 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4982 : : }
4983 : :
4984 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
4985 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4986 : : tso, "tso");
4987 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
4988 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4989 : : mode, "set");
4990 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4991 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4992 : : tso_segsz, RTE_UINT16);
4993 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
4994 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4995 : : port_id, RTE_UINT16);
4996 : :
4997 : : static cmdline_parse_inst_t cmd_tso_set = {
4998 : : .f = cmd_tso_set_parsed,
4999 : : .data = NULL,
5000 : : .help_str = "tso set <tso_segsz> <port_id>: "
5001 : : "Set TSO segment size of non-tunneled packets for csum engine "
5002 : : "(0 to disable)",
5003 : : .tokens = {
5004 : : (void *)&cmd_tso_set_tso,
5005 : : (void *)&cmd_tso_set_mode,
5006 : : (void *)&cmd_tso_set_tso_segsz,
5007 : : (void *)&cmd_tso_set_portid,
5008 : : NULL,
5009 : : },
5010 : : };
5011 : :
5012 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5013 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5014 : : mode, "show");
5015 : :
5016 : :
5017 : : static cmdline_parse_inst_t cmd_tso_show = {
5018 : : .f = cmd_tso_set_parsed,
5019 : : .data = NULL,
5020 : : .help_str = "tso show <port_id>: "
5021 : : "Show TSO segment size of non-tunneled packets for csum engine",
5022 : : .tokens = {
5023 : : (void *)&cmd_tso_set_tso,
5024 : : (void *)&cmd_tso_show_mode,
5025 : : (void *)&cmd_tso_set_portid,
5026 : : NULL,
5027 : : },
5028 : : };
5029 : :
5030 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5031 : : struct cmd_tunnel_tso_set_result {
5032 : : cmdline_fixed_string_t tso;
5033 : : cmdline_fixed_string_t mode;
5034 : : uint16_t tso_segsz;
5035 : : portid_t port_id;
5036 : : };
5037 : :
5038 : : static void
5039 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5040 : : {
5041 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5042 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5043 : : port_id);
5044 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5045 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5046 : : port_id);
5047 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5048 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5049 : : port_id);
5050 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5051 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5052 : : port_id);
5053 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5054 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5055 : : port_id);
5056 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5057 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5058 : : port_id);
5059 : 0 : }
5060 : :
5061 : : static void
5062 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5063 : : __rte_unused struct cmdline *cl,
5064 : : __rte_unused void *data)
5065 : : {
5066 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5067 : : struct rte_eth_dev_info dev_info;
5068 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5069 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5070 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5071 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5072 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5073 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5074 : : int ret;
5075 : :
5076 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5077 : 0 : return;
5078 : 0 : if (!port_is_stopped(res->port_id)) {
5079 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5080 : 0 : return;
5081 : : }
5082 : :
5083 : 0 : if (!strcmp(res->mode, "set"))
5084 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5085 : :
5086 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5087 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5088 : : printf("TSO for tunneled packets is disabled\n");
5089 : : } else {
5090 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5091 : 0 : if (ret != 0)
5092 : : return;
5093 : :
5094 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5095 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5096 : 0 : res->port_id);
5097 : 0 : return;
5098 : : }
5099 : :
5100 : : /* Below conditions are needed to make it work:
5101 : : * (1) tunnel TSO is supported by the NIC;
5102 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5103 : : * are recognized;
5104 : : * (3) for tunneled pkts with outer L3 of IPv4,
5105 : : * "csum set outer-ip" must be set to hw, because after tso,
5106 : : * total_len of outer IP header is changed, and the checksum
5107 : : * of outer IP header calculated by sw should be wrong; that
5108 : : * is not necessary for IPv6 tunneled pkts because there's no
5109 : : * checksum in IP header anymore.
5110 : : */
5111 : 0 : if (!ports[res->port_id].parse_tunnel) {
5112 : 0 : fprintf(stderr,
5113 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5114 : 0 : return;
5115 : : }
5116 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5117 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5118 : 0 : fprintf(stderr,
5119 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5120 : 0 : return;
5121 : : }
5122 : :
5123 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5124 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5125 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5126 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5127 : 0 : ports[res->port_id].tunnel_tso_segsz);
5128 : : }
5129 : :
5130 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5131 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5132 : : }
5133 : :
5134 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5135 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5136 : : tso, "tunnel_tso");
5137 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5138 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5139 : : mode, "set");
5140 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5141 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5142 : : tso_segsz, RTE_UINT16);
5143 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5144 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5145 : : port_id, RTE_UINT16);
5146 : :
5147 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5148 : : .f = cmd_tunnel_tso_set_parsed,
5149 : : .data = NULL,
5150 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5151 : : "Set TSO segment size of tunneled packets for csum engine "
5152 : : "(0 to disable)",
5153 : : .tokens = {
5154 : : (void *)&cmd_tunnel_tso_set_tso,
5155 : : (void *)&cmd_tunnel_tso_set_mode,
5156 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5157 : : (void *)&cmd_tunnel_tso_set_portid,
5158 : : NULL,
5159 : : },
5160 : : };
5161 : :
5162 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5163 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5164 : : mode, "show");
5165 : :
5166 : :
5167 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5168 : : .f = cmd_tunnel_tso_set_parsed,
5169 : : .data = NULL,
5170 : : .help_str = "tunnel_tso show <port_id> "
5171 : : "Show TSO segment size of tunneled packets for csum engine",
5172 : : .tokens = {
5173 : : (void *)&cmd_tunnel_tso_set_tso,
5174 : : (void *)&cmd_tunnel_tso_show_mode,
5175 : : (void *)&cmd_tunnel_tso_set_portid,
5176 : : NULL,
5177 : : },
5178 : : };
5179 : :
5180 : : #ifdef RTE_LIB_GRO
5181 : : /* *** SET GRO FOR A PORT *** */
5182 : : struct cmd_gro_enable_result {
5183 : : cmdline_fixed_string_t cmd_set;
5184 : : cmdline_fixed_string_t cmd_port;
5185 : : cmdline_fixed_string_t cmd_keyword;
5186 : : cmdline_fixed_string_t cmd_onoff;
5187 : : portid_t cmd_pid;
5188 : : };
5189 : :
5190 : : static void
5191 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5192 : : __rte_unused struct cmdline *cl,
5193 : : __rte_unused void *data)
5194 : : {
5195 : : struct cmd_gro_enable_result *res;
5196 : :
5197 : : res = parsed_result;
5198 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5199 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5200 : 0 : }
5201 : :
5202 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5203 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 : : cmd_set, "set");
5205 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5206 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5207 : : cmd_keyword, "port");
5208 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5209 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5210 : : cmd_pid, RTE_UINT16);
5211 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5212 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5213 : : cmd_keyword, "gro");
5214 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5215 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5216 : : cmd_onoff, "on#off");
5217 : :
5218 : : static cmdline_parse_inst_t cmd_gro_enable = {
5219 : : .f = cmd_gro_enable_parsed,
5220 : : .data = NULL,
5221 : : .help_str = "set port <port_id> gro on|off",
5222 : : .tokens = {
5223 : : (void *)&cmd_gro_enable_set,
5224 : : (void *)&cmd_gro_enable_port,
5225 : : (void *)&cmd_gro_enable_pid,
5226 : : (void *)&cmd_gro_enable_keyword,
5227 : : (void *)&cmd_gro_enable_onoff,
5228 : : NULL,
5229 : : },
5230 : : };
5231 : :
5232 : : /* *** DISPLAY GRO CONFIGURATION *** */
5233 : : struct cmd_gro_show_result {
5234 : : cmdline_fixed_string_t cmd_show;
5235 : : cmdline_fixed_string_t cmd_port;
5236 : : cmdline_fixed_string_t cmd_keyword;
5237 : : portid_t cmd_pid;
5238 : : };
5239 : :
5240 : : static void
5241 : 0 : cmd_gro_show_parsed(void *parsed_result,
5242 : : __rte_unused struct cmdline *cl,
5243 : : __rte_unused void *data)
5244 : : {
5245 : : struct cmd_gro_show_result *res;
5246 : :
5247 : : res = parsed_result;
5248 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5249 : 0 : show_gro(res->cmd_pid);
5250 : 0 : }
5251 : :
5252 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5253 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5254 : : cmd_show, "show");
5255 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5256 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5257 : : cmd_port, "port");
5258 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5259 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5260 : : cmd_pid, RTE_UINT16);
5261 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5262 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5263 : : cmd_keyword, "gro");
5264 : :
5265 : : static cmdline_parse_inst_t cmd_gro_show = {
5266 : : .f = cmd_gro_show_parsed,
5267 : : .data = NULL,
5268 : : .help_str = "show port <port_id> gro",
5269 : : .tokens = {
5270 : : (void *)&cmd_gro_show_show,
5271 : : (void *)&cmd_gro_show_port,
5272 : : (void *)&cmd_gro_show_pid,
5273 : : (void *)&cmd_gro_show_keyword,
5274 : : NULL,
5275 : : },
5276 : : };
5277 : :
5278 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5279 : : struct cmd_gro_flush_result {
5280 : : cmdline_fixed_string_t cmd_set;
5281 : : cmdline_fixed_string_t cmd_keyword;
5282 : : cmdline_fixed_string_t cmd_flush;
5283 : : uint8_t cmd_cycles;
5284 : : };
5285 : :
5286 : : static void
5287 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5288 : : __rte_unused struct cmdline *cl,
5289 : : __rte_unused void *data)
5290 : : {
5291 : : struct cmd_gro_flush_result *res;
5292 : :
5293 : : res = parsed_result;
5294 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5295 : 0 : (!strcmp(res->cmd_flush, "flush")))
5296 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5297 : 0 : }
5298 : :
5299 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5300 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5301 : : cmd_set, "set");
5302 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5303 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5304 : : cmd_keyword, "gro");
5305 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5306 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5307 : : cmd_flush, "flush");
5308 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5309 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5310 : : cmd_cycles, RTE_UINT8);
5311 : :
5312 : : static cmdline_parse_inst_t cmd_gro_flush = {
5313 : : .f = cmd_gro_flush_parsed,
5314 : : .data = NULL,
5315 : : .help_str = "set gro flush <cycles>",
5316 : : .tokens = {
5317 : : (void *)&cmd_gro_flush_set,
5318 : : (void *)&cmd_gro_flush_keyword,
5319 : : (void *)&cmd_gro_flush_flush,
5320 : : (void *)&cmd_gro_flush_cycles,
5321 : : NULL,
5322 : : },
5323 : : };
5324 : : #endif /* RTE_LIB_GRO */
5325 : :
5326 : : #ifdef RTE_LIB_GSO
5327 : : /* *** ENABLE/DISABLE GSO *** */
5328 : : struct cmd_gso_enable_result {
5329 : : cmdline_fixed_string_t cmd_set;
5330 : : cmdline_fixed_string_t cmd_port;
5331 : : cmdline_fixed_string_t cmd_keyword;
5332 : : cmdline_fixed_string_t cmd_mode;
5333 : : portid_t cmd_pid;
5334 : : };
5335 : :
5336 : : static void
5337 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5338 : : __rte_unused struct cmdline *cl,
5339 : : __rte_unused void *data)
5340 : : {
5341 : : struct cmd_gso_enable_result *res;
5342 : :
5343 : : res = parsed_result;
5344 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5345 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5346 : 0 : }
5347 : :
5348 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5349 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5350 : : cmd_set, "set");
5351 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5352 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5353 : : cmd_port, "port");
5354 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5355 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5356 : : cmd_keyword, "gso");
5357 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5358 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5359 : : cmd_mode, "on#off");
5360 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5361 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5362 : : cmd_pid, RTE_UINT16);
5363 : :
5364 : : static cmdline_parse_inst_t cmd_gso_enable = {
5365 : : .f = cmd_gso_enable_parsed,
5366 : : .data = NULL,
5367 : : .help_str = "set port <port_id> gso on|off",
5368 : : .tokens = {
5369 : : (void *)&cmd_gso_enable_set,
5370 : : (void *)&cmd_gso_enable_port,
5371 : : (void *)&cmd_gso_enable_pid,
5372 : : (void *)&cmd_gso_enable_keyword,
5373 : : (void *)&cmd_gso_enable_mode,
5374 : : NULL,
5375 : : },
5376 : : };
5377 : :
5378 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5379 : : struct cmd_gso_size_result {
5380 : : cmdline_fixed_string_t cmd_set;
5381 : : cmdline_fixed_string_t cmd_keyword;
5382 : : cmdline_fixed_string_t cmd_segsz;
5383 : : uint16_t cmd_size;
5384 : : };
5385 : :
5386 : : static void
5387 : 0 : cmd_gso_size_parsed(void *parsed_result,
5388 : : __rte_unused struct cmdline *cl,
5389 : : __rte_unused void *data)
5390 : : {
5391 : : struct cmd_gso_size_result *res = parsed_result;
5392 : :
5393 : 0 : if (test_done == 0) {
5394 : 0 : fprintf(stderr,
5395 : : "Before setting GSO segsz, please first stop forwarding\n");
5396 : 0 : return;
5397 : : }
5398 : :
5399 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5400 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5401 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5402 : 0 : fprintf(stderr,
5403 : : "gso_size should be larger than %zu. Please input a legal value\n",
5404 : : RTE_GSO_SEG_SIZE_MIN);
5405 : : else
5406 : 0 : gso_max_segment_size = res->cmd_size;
5407 : : }
5408 : : }
5409 : :
5410 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5411 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5412 : : cmd_set, "set");
5413 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5414 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5415 : : cmd_keyword, "gso");
5416 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5417 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5418 : : cmd_segsz, "segsz");
5419 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5420 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5421 : : cmd_size, RTE_UINT16);
5422 : :
5423 : : static cmdline_parse_inst_t cmd_gso_size = {
5424 : : .f = cmd_gso_size_parsed,
5425 : : .data = NULL,
5426 : : .help_str = "set gso segsz <length>",
5427 : : .tokens = {
5428 : : (void *)&cmd_gso_size_set,
5429 : : (void *)&cmd_gso_size_keyword,
5430 : : (void *)&cmd_gso_size_segsz,
5431 : : (void *)&cmd_gso_size_size,
5432 : : NULL,
5433 : : },
5434 : : };
5435 : :
5436 : : /* *** SHOW GSO CONFIGURATION *** */
5437 : : struct cmd_gso_show_result {
5438 : : cmdline_fixed_string_t cmd_show;
5439 : : cmdline_fixed_string_t cmd_port;
5440 : : cmdline_fixed_string_t cmd_keyword;
5441 : : portid_t cmd_pid;
5442 : : };
5443 : :
5444 : : static void
5445 : 0 : cmd_gso_show_parsed(void *parsed_result,
5446 : : __rte_unused struct cmdline *cl,
5447 : : __rte_unused void *data)
5448 : : {
5449 : : struct cmd_gso_show_result *res = parsed_result;
5450 : :
5451 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5452 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5453 : 0 : return;
5454 : : }
5455 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5456 : 0 : if (gso_ports[res->cmd_pid].enable) {
5457 : 0 : printf("Max GSO'd packet size: %uB\n"
5458 : : "Supported GSO types: TCP/IPv4, "
5459 : : "UDP/IPv4, VxLAN with inner "
5460 : : "TCP/IPv4 packet, GRE with inner "
5461 : : "TCP/IPv4 packet\n",
5462 : : gso_max_segment_size);
5463 : : } else
5464 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5465 : : }
5466 : : }
5467 : :
5468 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5469 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5470 : : cmd_show, "show");
5471 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5472 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5473 : : cmd_port, "port");
5474 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5475 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5476 : : cmd_keyword, "gso");
5477 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5478 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5479 : : cmd_pid, RTE_UINT16);
5480 : :
5481 : : static cmdline_parse_inst_t cmd_gso_show = {
5482 : : .f = cmd_gso_show_parsed,
5483 : : .data = NULL,
5484 : : .help_str = "show port <port_id> gso",
5485 : : .tokens = {
5486 : : (void *)&cmd_gso_show_show,
5487 : : (void *)&cmd_gso_show_port,
5488 : : (void *)&cmd_gso_show_pid,
5489 : : (void *)&cmd_gso_show_keyword,
5490 : : NULL,
5491 : : },
5492 : : };
5493 : : #endif /* RTE_LIB_GSO */
5494 : :
5495 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5496 : : struct cmd_set_flush_rx {
5497 : : cmdline_fixed_string_t set;
5498 : : cmdline_fixed_string_t flush_rx;
5499 : : cmdline_fixed_string_t mode;
5500 : : };
5501 : :
5502 : : static void
5503 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
5504 : : __rte_unused struct cmdline *cl,
5505 : : __rte_unused void *data)
5506 : : {
5507 : : struct cmd_set_flush_rx *res = parsed_result;
5508 : :
5509 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5510 : : printf("multi-process doesn't support to flush Rx queues.\n");
5511 : 0 : return;
5512 : : }
5513 : :
5514 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5515 : : }
5516 : :
5517 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
5518 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5519 : : set, "set");
5520 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5521 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5522 : : flush_rx, "flush_rx");
5523 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
5524 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5525 : : mode, "on#off");
5526 : :
5527 : :
5528 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
5529 : : .f = cmd_set_flush_rx_parsed,
5530 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5531 : : .data = NULL,
5532 : : .tokens = {
5533 : : (void *)&cmd_setflushrx_set,
5534 : : (void *)&cmd_setflushrx_flush_rx,
5535 : : (void *)&cmd_setflushrx_mode,
5536 : : NULL,
5537 : : },
5538 : : };
5539 : :
5540 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5541 : : struct cmd_set_link_check {
5542 : : cmdline_fixed_string_t set;
5543 : : cmdline_fixed_string_t link_check;
5544 : : cmdline_fixed_string_t mode;
5545 : : };
5546 : :
5547 : : static void
5548 : 0 : cmd_set_link_check_parsed(void *parsed_result,
5549 : : __rte_unused struct cmdline *cl,
5550 : : __rte_unused void *data)
5551 : : {
5552 : : struct cmd_set_link_check *res = parsed_result;
5553 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5554 : 0 : }
5555 : :
5556 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5557 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5558 : : set, "set");
5559 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5560 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5561 : : link_check, "link_check");
5562 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5563 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5564 : : mode, "on#off");
5565 : :
5566 : :
5567 : : static cmdline_parse_inst_t cmd_set_link_check = {
5568 : : .f = cmd_set_link_check_parsed,
5569 : : .help_str = "set link_check on|off: Enable/Disable link status check "
5570 : : "when starting/stopping a port",
5571 : : .data = NULL,
5572 : : .tokens = {
5573 : : (void *)&cmd_setlinkcheck_set,
5574 : : (void *)&cmd_setlinkcheck_link_check,
5575 : : (void *)&cmd_setlinkcheck_mode,
5576 : : NULL,
5577 : : },
5578 : : };
5579 : :
5580 : : /* *** SET FORWARDING MODE *** */
5581 : : struct cmd_set_fwd_mode_result {
5582 : : cmdline_fixed_string_t set;
5583 : : cmdline_fixed_string_t fwd;
5584 : : cmdline_fixed_string_t mode;
5585 : : };
5586 : :
5587 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
5588 : : __rte_unused struct cmdline *cl,
5589 : : __rte_unused void *data)
5590 : : {
5591 : : struct cmd_set_fwd_mode_result *res = parsed_result;
5592 : :
5593 : 0 : retry_enabled = 0;
5594 : 0 : set_pkt_forwarding_mode(res->mode);
5595 : 0 : }
5596 : :
5597 : : static cmdline_parse_token_string_t cmd_setfwd_set =
5598 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5599 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
5600 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5601 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
5602 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5603 : : "" /* defined at init */);
5604 : :
5605 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
5606 : : .f = cmd_set_fwd_mode_parsed,
5607 : : .data = NULL,
5608 : : .help_str = NULL, /* defined at init */
5609 : : .tokens = {
5610 : : (void *)&cmd_setfwd_set,
5611 : : (void *)&cmd_setfwd_fwd,
5612 : : (void *)&cmd_setfwd_mode,
5613 : : NULL,
5614 : : },
5615 : : };
5616 : :
5617 : 0 : static void cmd_set_fwd_mode_init(void)
5618 : : {
5619 : : char *modes, *c;
5620 : : static char token[128];
5621 : : static char help[256];
5622 : : cmdline_parse_token_string_t *token_struct;
5623 : :
5624 : 0 : modes = list_pkt_forwarding_modes();
5625 : : snprintf(help, sizeof(help), "set fwd %s: "
5626 : : "Set packet forwarding mode", modes);
5627 : 0 : cmd_set_fwd_mode.help_str = help;
5628 : :
5629 : : /* string token separator is # */
5630 : 0 : for (c = token; *modes != '\0'; modes++)
5631 : 0 : if (*modes == '|')
5632 : 0 : *c++ = '#';
5633 : : else
5634 : 0 : *c++ = *modes;
5635 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5636 : 0 : token_struct->string_data.str = token;
5637 : 0 : }
5638 : :
5639 : : /* *** SET RETRY FORWARDING MODE *** */
5640 : : struct cmd_set_fwd_retry_mode_result {
5641 : : cmdline_fixed_string_t set;
5642 : : cmdline_fixed_string_t fwd;
5643 : : cmdline_fixed_string_t mode;
5644 : : cmdline_fixed_string_t retry;
5645 : : };
5646 : :
5647 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5648 : : __rte_unused struct cmdline *cl,
5649 : : __rte_unused void *data)
5650 : : {
5651 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5652 : :
5653 : 0 : retry_enabled = 1;
5654 : 0 : set_pkt_forwarding_mode(res->mode);
5655 : 0 : }
5656 : :
5657 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
5658 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5659 : : set, "set");
5660 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5661 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5662 : : fwd, "fwd");
5663 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5664 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5665 : : mode,
5666 : : "" /* defined at init */);
5667 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5668 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5669 : : retry, "retry");
5670 : :
5671 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5672 : : .f = cmd_set_fwd_retry_mode_parsed,
5673 : : .data = NULL,
5674 : : .help_str = NULL, /* defined at init */
5675 : : .tokens = {
5676 : : (void *)&cmd_setfwd_retry_set,
5677 : : (void *)&cmd_setfwd_retry_fwd,
5678 : : (void *)&cmd_setfwd_retry_mode,
5679 : : (void *)&cmd_setfwd_retry_retry,
5680 : : NULL,
5681 : : },
5682 : : };
5683 : :
5684 : 0 : static void cmd_set_fwd_retry_mode_init(void)
5685 : : {
5686 : : char *modes, *c;
5687 : : static char token[128];
5688 : : static char help[256];
5689 : : cmdline_parse_token_string_t *token_struct;
5690 : :
5691 : 0 : modes = list_pkt_forwarding_retry_modes();
5692 : : snprintf(help, sizeof(help), "set fwd %s retry: "
5693 : : "Set packet forwarding mode with retry", modes);
5694 : 0 : cmd_set_fwd_retry_mode.help_str = help;
5695 : :
5696 : : /* string token separator is # */
5697 : 0 : for (c = token; *modes != '\0'; modes++)
5698 : 0 : if (*modes == '|')
5699 : 0 : *c++ = '#';
5700 : : else
5701 : 0 : *c++ = *modes;
5702 : 0 : token_struct = (cmdline_parse_token_string_t *)
5703 : : cmd_set_fwd_retry_mode.tokens[2];
5704 : 0 : token_struct->string_data.str = token;
5705 : 0 : }
5706 : :
5707 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5708 : : struct cmd_set_burst_tx_retry_result {
5709 : : cmdline_fixed_string_t set;
5710 : : cmdline_fixed_string_t burst;
5711 : : cmdline_fixed_string_t tx;
5712 : : cmdline_fixed_string_t delay;
5713 : : uint32_t time;
5714 : : cmdline_fixed_string_t retry;
5715 : : uint32_t retry_num;
5716 : : };
5717 : :
5718 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5719 : : __rte_unused struct cmdline *cl,
5720 : : __rte_unused void *data)
5721 : : {
5722 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
5723 : :
5724 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5725 : 0 : && !strcmp(res->tx, "tx")) {
5726 : 0 : if (!strcmp(res->delay, "delay"))
5727 : 0 : burst_tx_delay_time = res->time;
5728 : 0 : if (!strcmp(res->retry, "retry"))
5729 : 0 : burst_tx_retry_num = res->retry_num;
5730 : : }
5731 : :
5732 : 0 : }
5733 : :
5734 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5735 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5736 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5738 : : "burst");
5739 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5740 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5741 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5742 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5743 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5744 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
5745 : : RTE_UINT32);
5746 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5747 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5748 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5749 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
5750 : : RTE_UINT32);
5751 : :
5752 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5753 : : .f = cmd_set_burst_tx_retry_parsed,
5754 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5755 : : .tokens = {
5756 : : (void *)&cmd_set_burst_tx_retry_set,
5757 : : (void *)&cmd_set_burst_tx_retry_burst,
5758 : : (void *)&cmd_set_burst_tx_retry_tx,
5759 : : (void *)&cmd_set_burst_tx_retry_delay,
5760 : : (void *)&cmd_set_burst_tx_retry_time,
5761 : : (void *)&cmd_set_burst_tx_retry_retry,
5762 : : (void *)&cmd_set_burst_tx_retry_retry_num,
5763 : : NULL,
5764 : : },
5765 : : };
5766 : :
5767 : : /* *** SET PROMISC MODE *** */
5768 : : struct cmd_set_promisc_mode_result {
5769 : : cmdline_fixed_string_t set;
5770 : : cmdline_fixed_string_t promisc;
5771 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5772 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5773 : : cmdline_fixed_string_t mode;
5774 : : };
5775 : :
5776 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
5777 : : __rte_unused struct cmdline *cl,
5778 : : void *allports)
5779 : : {
5780 : : struct cmd_set_promisc_mode_result *res = parsed_result;
5781 : : int enable;
5782 : : portid_t i;
5783 : :
5784 : 0 : if (!strcmp(res->mode, "on"))
5785 : : enable = 1;
5786 : : else
5787 : : enable = 0;
5788 : :
5789 : : /* all ports */
5790 : 0 : if (allports) {
5791 : 0 : RTE_ETH_FOREACH_DEV(i)
5792 : 0 : eth_set_promisc_mode(i, enable);
5793 : : } else {
5794 : 0 : eth_set_promisc_mode(res->port_num, enable);
5795 : : }
5796 : 0 : }
5797 : :
5798 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
5799 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5800 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
5801 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5802 : : "promisc");
5803 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
5804 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5805 : : "all");
5806 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
5807 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5808 : : RTE_UINT16);
5809 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
5810 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5811 : : "on#off");
5812 : :
5813 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5814 : : .f = cmd_set_promisc_mode_parsed,
5815 : : .data = (void *)1,
5816 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
5817 : : .tokens = {
5818 : : (void *)&cmd_setpromisc_set,
5819 : : (void *)&cmd_setpromisc_promisc,
5820 : : (void *)&cmd_setpromisc_portall,
5821 : : (void *)&cmd_setpromisc_mode,
5822 : : NULL,
5823 : : },
5824 : : };
5825 : :
5826 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5827 : : .f = cmd_set_promisc_mode_parsed,
5828 : : .data = (void *)0,
5829 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5830 : : .tokens = {
5831 : : (void *)&cmd_setpromisc_set,
5832 : : (void *)&cmd_setpromisc_promisc,
5833 : : (void *)&cmd_setpromisc_portnum,
5834 : : (void *)&cmd_setpromisc_mode,
5835 : : NULL,
5836 : : },
5837 : : };
5838 : :
5839 : : /* *** SET ALLMULTI MODE *** */
5840 : : struct cmd_set_allmulti_mode_result {
5841 : : cmdline_fixed_string_t set;
5842 : : cmdline_fixed_string_t allmulti;
5843 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5844 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5845 : : cmdline_fixed_string_t mode;
5846 : : };
5847 : :
5848 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5849 : : __rte_unused struct cmdline *cl,
5850 : : void *allports)
5851 : : {
5852 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
5853 : : int enable;
5854 : : portid_t i;
5855 : :
5856 : 0 : if (!strcmp(res->mode, "on"))
5857 : : enable = 1;
5858 : : else
5859 : : enable = 0;
5860 : :
5861 : : /* all ports */
5862 : 0 : if (allports) {
5863 : 0 : RTE_ETH_FOREACH_DEV(i) {
5864 : 0 : eth_set_allmulticast_mode(i, enable);
5865 : : }
5866 : : }
5867 : : else {
5868 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
5869 : : }
5870 : 0 : }
5871 : :
5872 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
5873 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5874 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5876 : : "allmulti");
5877 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
5878 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5879 : : "all");
5880 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
5881 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5882 : : RTE_UINT16);
5883 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
5884 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5885 : : "on#off");
5886 : :
5887 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5888 : : .f = cmd_set_allmulti_mode_parsed,
5889 : : .data = (void *)1,
5890 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5891 : : .tokens = {
5892 : : (void *)&cmd_setallmulti_set,
5893 : : (void *)&cmd_setallmulti_allmulti,
5894 : : (void *)&cmd_setallmulti_portall,
5895 : : (void *)&cmd_setallmulti_mode,
5896 : : NULL,
5897 : : },
5898 : : };
5899 : :
5900 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5901 : : .f = cmd_set_allmulti_mode_parsed,
5902 : : .data = (void *)0,
5903 : : .help_str = "set allmulti <port_id> on|off: "
5904 : : "Set allmulti mode on port_id",
5905 : : .tokens = {
5906 : : (void *)&cmd_setallmulti_set,
5907 : : (void *)&cmd_setallmulti_allmulti,
5908 : : (void *)&cmd_setallmulti_portnum,
5909 : : (void *)&cmd_setallmulti_mode,
5910 : : NULL,
5911 : : },
5912 : : };
5913 : :
5914 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
5915 : : struct cmd_link_flow_ctrl_show {
5916 : : cmdline_fixed_string_t show;
5917 : : cmdline_fixed_string_t port;
5918 : : portid_t port_id;
5919 : : cmdline_fixed_string_t flow_ctrl;
5920 : : };
5921 : :
5922 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
5923 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5924 : : show, "show");
5925 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
5926 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5927 : : port, "port");
5928 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
5929 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
5930 : : port_id, RTE_UINT16);
5931 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
5932 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
5933 : : flow_ctrl, "flow_ctrl");
5934 : :
5935 : : static void
5936 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
5937 : : __rte_unused struct cmdline *cl,
5938 : : __rte_unused void *data)
5939 : : {
5940 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
5941 : : static const char *info_border = "*********************";
5942 : : struct rte_eth_fc_conf fc_conf;
5943 : : bool rx_fc_en = false;
5944 : : bool tx_fc_en = false;
5945 : : int ret;
5946 : :
5947 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
5948 : 0 : if (ret != 0) {
5949 : 0 : fprintf(stderr,
5950 : : "Failed to get current flow ctrl information: err = %d\n",
5951 : : ret);
5952 : 0 : return;
5953 : : }
5954 : :
5955 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
5956 : : rx_fc_en = true;
5957 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
5958 : : tx_fc_en = true;
5959 : :
5960 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
5961 : 0 : info_border, res->port_id, info_border);
5962 : : printf("FC mode:\n");
5963 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
5964 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
5965 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
5966 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
5967 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
5968 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
5969 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
5970 : 0 : printf("Forward MAC control frames: %s\n",
5971 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
5972 : 0 : printf("\n%s************** End ***********%s\n",
5973 : : info_border, info_border);
5974 : : }
5975 : :
5976 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
5977 : : .f = cmd_link_flow_ctrl_show_parsed,
5978 : : .data = NULL,
5979 : : .help_str = "show port <port_id> flow_ctrl",
5980 : : .tokens = {
5981 : : (void *)&cmd_lfc_show_show,
5982 : : (void *)&cmd_lfc_show_port,
5983 : : (void *)&cmd_lfc_show_portid,
5984 : : (void *)&cmd_lfc_show_flow_ctrl,
5985 : : NULL,
5986 : : },
5987 : : };
5988 : :
5989 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
5990 : : struct cmd_link_flow_ctrl_set_result {
5991 : : cmdline_fixed_string_t set;
5992 : : cmdline_fixed_string_t flow_ctrl;
5993 : : cmdline_fixed_string_t rx;
5994 : : cmdline_fixed_string_t rx_lfc_mode;
5995 : : cmdline_fixed_string_t tx;
5996 : : cmdline_fixed_string_t tx_lfc_mode;
5997 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
5998 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
5999 : : cmdline_fixed_string_t autoneg_str;
6000 : : cmdline_fixed_string_t autoneg;
6001 : : cmdline_fixed_string_t hw_str;
6002 : : uint32_t high_water;
6003 : : cmdline_fixed_string_t lw_str;
6004 : : uint32_t low_water;
6005 : : cmdline_fixed_string_t pt_str;
6006 : : uint16_t pause_time;
6007 : : cmdline_fixed_string_t xon_str;
6008 : : uint16_t send_xon;
6009 : : portid_t port_id;
6010 : : };
6011 : :
6012 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6013 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6014 : : set, "set");
6015 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6016 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6017 : : flow_ctrl, "flow_ctrl");
6018 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6019 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6020 : : rx, "rx");
6021 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6022 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6023 : : rx_lfc_mode, "on#off");
6024 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6025 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6026 : : tx, "tx");
6027 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6028 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6029 : : tx_lfc_mode, "on#off");
6030 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6031 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6032 : : hw_str, "high_water");
6033 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6034 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6035 : : high_water, RTE_UINT32);
6036 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6037 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6038 : : lw_str, "low_water");
6039 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6040 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6041 : : low_water, RTE_UINT32);
6042 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6043 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6044 : : pt_str, "pause_time");
6045 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6046 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6047 : : pause_time, RTE_UINT16);
6048 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6049 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6050 : : xon_str, "send_xon");
6051 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6052 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6053 : : send_xon, RTE_UINT16);
6054 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6055 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6056 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6057 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6058 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6059 : : mac_ctrl_frame_fwd_mode, "on#off");
6060 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6061 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6062 : : autoneg_str, "autoneg");
6063 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6064 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6065 : : autoneg, "on#off");
6066 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6067 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6068 : : port_id, RTE_UINT16);
6069 : :
6070 : : /* forward declaration */
6071 : : static void
6072 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6073 : : void *data);
6074 : :
6075 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6076 : : .f = cmd_link_flow_ctrl_set_parsed,
6077 : : .data = NULL,
6078 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6079 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6080 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6081 : : .tokens = {
6082 : : (void *)&cmd_lfc_set_set,
6083 : : (void *)&cmd_lfc_set_flow_ctrl,
6084 : : (void *)&cmd_lfc_set_rx,
6085 : : (void *)&cmd_lfc_set_rx_mode,
6086 : : (void *)&cmd_lfc_set_tx,
6087 : : (void *)&cmd_lfc_set_tx_mode,
6088 : : (void *)&cmd_lfc_set_high_water,
6089 : : (void *)&cmd_lfc_set_low_water,
6090 : : (void *)&cmd_lfc_set_pause_time,
6091 : : (void *)&cmd_lfc_set_send_xon,
6092 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6093 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6094 : : (void *)&cmd_lfc_set_autoneg_str,
6095 : : (void *)&cmd_lfc_set_autoneg,
6096 : : (void *)&cmd_lfc_set_portid,
6097 : : NULL,
6098 : : },
6099 : : };
6100 : :
6101 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6102 : : .f = cmd_link_flow_ctrl_set_parsed,
6103 : : .data = (void *)&cmd_link_flow_control_set_rx,
6104 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6105 : : "Change rx flow control parameter",
6106 : : .tokens = {
6107 : : (void *)&cmd_lfc_set_set,
6108 : : (void *)&cmd_lfc_set_flow_ctrl,
6109 : : (void *)&cmd_lfc_set_rx,
6110 : : (void *)&cmd_lfc_set_rx_mode,
6111 : : (void *)&cmd_lfc_set_portid,
6112 : : NULL,
6113 : : },
6114 : : };
6115 : :
6116 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6117 : : .f = cmd_link_flow_ctrl_set_parsed,
6118 : : .data = (void *)&cmd_link_flow_control_set_tx,
6119 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6120 : : "Change tx flow control parameter",
6121 : : .tokens = {
6122 : : (void *)&cmd_lfc_set_set,
6123 : : (void *)&cmd_lfc_set_flow_ctrl,
6124 : : (void *)&cmd_lfc_set_tx,
6125 : : (void *)&cmd_lfc_set_tx_mode,
6126 : : (void *)&cmd_lfc_set_portid,
6127 : : NULL,
6128 : : },
6129 : : };
6130 : :
6131 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6132 : : .f = cmd_link_flow_ctrl_set_parsed,
6133 : : .data = (void *)&cmd_link_flow_control_set_hw,
6134 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6135 : : "Change high water flow control parameter",
6136 : : .tokens = {
6137 : : (void *)&cmd_lfc_set_set,
6138 : : (void *)&cmd_lfc_set_flow_ctrl,
6139 : : (void *)&cmd_lfc_set_high_water_str,
6140 : : (void *)&cmd_lfc_set_high_water,
6141 : : (void *)&cmd_lfc_set_portid,
6142 : : NULL,
6143 : : },
6144 : : };
6145 : :
6146 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6147 : : .f = cmd_link_flow_ctrl_set_parsed,
6148 : : .data = (void *)&cmd_link_flow_control_set_lw,
6149 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6150 : : "Change low water flow control parameter",
6151 : : .tokens = {
6152 : : (void *)&cmd_lfc_set_set,
6153 : : (void *)&cmd_lfc_set_flow_ctrl,
6154 : : (void *)&cmd_lfc_set_low_water_str,
6155 : : (void *)&cmd_lfc_set_low_water,
6156 : : (void *)&cmd_lfc_set_portid,
6157 : : NULL,
6158 : : },
6159 : : };
6160 : :
6161 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6162 : : .f = cmd_link_flow_ctrl_set_parsed,
6163 : : .data = (void *)&cmd_link_flow_control_set_pt,
6164 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6165 : : "Change pause time flow control parameter",
6166 : : .tokens = {
6167 : : (void *)&cmd_lfc_set_set,
6168 : : (void *)&cmd_lfc_set_flow_ctrl,
6169 : : (void *)&cmd_lfc_set_pause_time_str,
6170 : : (void *)&cmd_lfc_set_pause_time,
6171 : : (void *)&cmd_lfc_set_portid,
6172 : : NULL,
6173 : : },
6174 : : };
6175 : :
6176 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6177 : : .f = cmd_link_flow_ctrl_set_parsed,
6178 : : .data = (void *)&cmd_link_flow_control_set_xon,
6179 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6180 : : "Change send_xon flow control parameter",
6181 : : .tokens = {
6182 : : (void *)&cmd_lfc_set_set,
6183 : : (void *)&cmd_lfc_set_flow_ctrl,
6184 : : (void *)&cmd_lfc_set_send_xon_str,
6185 : : (void *)&cmd_lfc_set_send_xon,
6186 : : (void *)&cmd_lfc_set_portid,
6187 : : NULL,
6188 : : },
6189 : : };
6190 : :
6191 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6192 : : .f = cmd_link_flow_ctrl_set_parsed,
6193 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6194 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6195 : : "Change mac ctrl fwd flow control parameter",
6196 : : .tokens = {
6197 : : (void *)&cmd_lfc_set_set,
6198 : : (void *)&cmd_lfc_set_flow_ctrl,
6199 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6200 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6201 : : (void *)&cmd_lfc_set_portid,
6202 : : NULL,
6203 : : },
6204 : : };
6205 : :
6206 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6207 : : .f = cmd_link_flow_ctrl_set_parsed,
6208 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6209 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6210 : : "Change autoneg flow control parameter",
6211 : : .tokens = {
6212 : : (void *)&cmd_lfc_set_set,
6213 : : (void *)&cmd_lfc_set_flow_ctrl,
6214 : : (void *)&cmd_lfc_set_autoneg_str,
6215 : : (void *)&cmd_lfc_set_autoneg,
6216 : : (void *)&cmd_lfc_set_portid,
6217 : : NULL,
6218 : : },
6219 : : };
6220 : :
6221 : : static void
6222 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6223 : : __rte_unused struct cmdline *cl,
6224 : : void *data)
6225 : : {
6226 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6227 : : cmdline_parse_inst_t *cmd = data;
6228 : : struct rte_eth_fc_conf fc_conf;
6229 : : int rx_fc_en = 0;
6230 : : int tx_fc_en = 0;
6231 : : int ret;
6232 : :
6233 : : /*
6234 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6235 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6236 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6237 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6238 : : */
6239 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6240 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6241 : : };
6242 : :
6243 : : /* Partial command line, retrieve current configuration */
6244 : 0 : if (cmd) {
6245 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6246 : 0 : if (ret != 0) {
6247 : 0 : fprintf(stderr,
6248 : : "cannot get current flow ctrl parameters, return code = %d\n",
6249 : : ret);
6250 : 0 : return;
6251 : : }
6252 : :
6253 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6254 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6255 : : rx_fc_en = 1;
6256 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6257 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6258 : : tx_fc_en = 1;
6259 : : }
6260 : :
6261 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6262 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6263 : :
6264 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6265 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6266 : :
6267 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6268 : :
6269 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6270 : 0 : fc_conf.high_water = res->high_water;
6271 : :
6272 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6273 : 0 : fc_conf.low_water = res->low_water;
6274 : :
6275 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6276 : 0 : fc_conf.pause_time = res->pause_time;
6277 : :
6278 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6279 : 0 : fc_conf.send_xon = res->send_xon;
6280 : :
6281 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6282 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6283 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6284 : : else
6285 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6286 : : }
6287 : :
6288 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6289 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6290 : :
6291 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6292 : 0 : if (ret != 0)
6293 : 0 : fprintf(stderr,
6294 : : "bad flow control parameter, return code = %d\n",
6295 : : ret);
6296 : : }
6297 : :
6298 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6299 : : struct cmd_priority_flow_ctrl_set_result {
6300 : : cmdline_fixed_string_t set;
6301 : : cmdline_fixed_string_t pfc_ctrl;
6302 : : cmdline_fixed_string_t rx;
6303 : : cmdline_fixed_string_t rx_pfc_mode;
6304 : : cmdline_fixed_string_t tx;
6305 : : cmdline_fixed_string_t tx_pfc_mode;
6306 : : uint32_t high_water;
6307 : : uint32_t low_water;
6308 : : uint16_t pause_time;
6309 : : uint8_t priority;
6310 : : portid_t port_id;
6311 : : };
6312 : :
6313 : : static void
6314 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6315 : : __rte_unused struct cmdline *cl,
6316 : : __rte_unused void *data)
6317 : : {
6318 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6319 : : struct rte_eth_pfc_conf pfc_conf;
6320 : : int rx_fc_enable, tx_fc_enable;
6321 : : int ret;
6322 : :
6323 : : /*
6324 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6325 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6326 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6327 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6328 : : */
6329 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6330 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6331 : : };
6332 : :
6333 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6334 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6335 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6336 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6337 : 0 : pfc_conf.fc.high_water = res->high_water;
6338 : 0 : pfc_conf.fc.low_water = res->low_water;
6339 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6340 : 0 : pfc_conf.priority = res->priority;
6341 : :
6342 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6343 : 0 : if (ret != 0)
6344 : 0 : fprintf(stderr,
6345 : : "bad priority flow control parameter, return code = %d\n",
6346 : : ret);
6347 : 0 : }
6348 : :
6349 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6350 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6351 : : set, "set");
6352 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6353 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6354 : : pfc_ctrl, "pfc_ctrl");
6355 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6356 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6357 : : rx, "rx");
6358 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6359 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6360 : : rx_pfc_mode, "on#off");
6361 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6362 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6363 : : tx, "tx");
6364 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6365 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6366 : : tx_pfc_mode, "on#off");
6367 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6368 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6369 : : high_water, RTE_UINT32);
6370 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6371 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6372 : : low_water, RTE_UINT32);
6373 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6374 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6375 : : pause_time, RTE_UINT16);
6376 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6377 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6378 : : priority, RTE_UINT8);
6379 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6380 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6381 : : port_id, RTE_UINT16);
6382 : :
6383 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6384 : : .f = cmd_priority_flow_ctrl_set_parsed,
6385 : : .data = NULL,
6386 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6387 : : "<pause_time> <priority> <port_id>: "
6388 : : "Configure the Ethernet priority flow control",
6389 : : .tokens = {
6390 : : (void *)&cmd_pfc_set_set,
6391 : : (void *)&cmd_pfc_set_flow_ctrl,
6392 : : (void *)&cmd_pfc_set_rx,
6393 : : (void *)&cmd_pfc_set_rx_mode,
6394 : : (void *)&cmd_pfc_set_tx,
6395 : : (void *)&cmd_pfc_set_tx_mode,
6396 : : (void *)&cmd_pfc_set_high_water,
6397 : : (void *)&cmd_pfc_set_low_water,
6398 : : (void *)&cmd_pfc_set_pause_time,
6399 : : (void *)&cmd_pfc_set_priority,
6400 : : (void *)&cmd_pfc_set_portid,
6401 : : NULL,
6402 : : },
6403 : : };
6404 : :
6405 : : struct cmd_queue_priority_flow_ctrl_set_result {
6406 : : cmdline_fixed_string_t set;
6407 : : cmdline_fixed_string_t pfc_queue_ctrl;
6408 : : portid_t port_id;
6409 : : cmdline_fixed_string_t rx;
6410 : : cmdline_fixed_string_t rx_pfc_mode;
6411 : : uint16_t tx_qid;
6412 : : uint8_t tx_tc;
6413 : : cmdline_fixed_string_t tx;
6414 : : cmdline_fixed_string_t tx_pfc_mode;
6415 : : uint16_t rx_qid;
6416 : : uint8_t rx_tc;
6417 : : uint16_t pause_time;
6418 : : };
6419 : :
6420 : : static void
6421 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6422 : : __rte_unused struct cmdline *cl,
6423 : : __rte_unused void *data)
6424 : : {
6425 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6426 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6427 : : int rx_fc_enable, tx_fc_enable;
6428 : : int ret;
6429 : :
6430 : : /*
6431 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6432 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6433 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6434 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6435 : : * the Tx side.
6436 : : */
6437 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6438 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6439 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6440 : : };
6441 : :
6442 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6443 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6444 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6445 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6446 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6447 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6448 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6449 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6450 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6451 : :
6452 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6453 : : &pfc_queue_conf);
6454 : 0 : if (ret != 0) {
6455 : 0 : fprintf(stderr,
6456 : : "bad queue priority flow control parameter, rc = %d\n",
6457 : : ret);
6458 : : }
6459 : 0 : }
6460 : :
6461 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6462 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6463 : : set, "set");
6464 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6465 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6466 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6467 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6468 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6469 : : port_id, RTE_UINT16);
6470 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6471 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6472 : : rx, "rx");
6473 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6474 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6475 : : rx_pfc_mode, "on#off");
6476 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6477 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6478 : : tx_qid, RTE_UINT16);
6479 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6480 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6481 : : tx_tc, RTE_UINT8);
6482 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6483 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6484 : : tx, "tx");
6485 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6486 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6487 : : tx_pfc_mode, "on#off");
6488 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6489 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6490 : : rx_qid, RTE_UINT16);
6491 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6492 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6493 : : rx_tc, RTE_UINT8);
6494 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
6495 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6496 : : pause_time, RTE_UINT16);
6497 : :
6498 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
6499 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
6500 : : .data = NULL,
6501 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
6502 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
6503 : : "Configure the Ethernet queue priority flow control",
6504 : : .tokens = {
6505 : : (void *)&cmd_q_pfc_set_set,
6506 : : (void *)&cmd_q_pfc_set_flow_ctrl,
6507 : : (void *)&cmd_q_pfc_set_portid,
6508 : : (void *)&cmd_q_pfc_set_rx,
6509 : : (void *)&cmd_q_pfc_set_rx_mode,
6510 : : (void *)&cmd_q_pfc_set_tx_qid,
6511 : : (void *)&cmd_q_pfc_set_tx_tc,
6512 : : (void *)&cmd_q_pfc_set_tx,
6513 : : (void *)&cmd_q_pfc_set_tx_mode,
6514 : : (void *)&cmd_q_pfc_set_rx_qid,
6515 : : (void *)&cmd_q_pfc_set_rx_tc,
6516 : : (void *)&cmd_q_pfc_set_pause_time,
6517 : : NULL,
6518 : : },
6519 : : };
6520 : :
6521 : : /* *** RESET CONFIGURATION *** */
6522 : : struct cmd_reset_result {
6523 : : cmdline_fixed_string_t reset;
6524 : : cmdline_fixed_string_t def;
6525 : : };
6526 : :
6527 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
6528 : : struct cmdline *cl,
6529 : : __rte_unused void *data)
6530 : : {
6531 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6532 : 0 : set_def_fwd_config();
6533 : 0 : }
6534 : :
6535 : : static cmdline_parse_token_string_t cmd_reset_set =
6536 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6537 : : static cmdline_parse_token_string_t cmd_reset_def =
6538 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6539 : : "default");
6540 : :
6541 : : static cmdline_parse_inst_t cmd_reset = {
6542 : : .f = cmd_reset_parsed,
6543 : : .data = NULL,
6544 : : .help_str = "set default: Reset default forwarding configuration",
6545 : : .tokens = {
6546 : : (void *)&cmd_reset_set,
6547 : : (void *)&cmd_reset_def,
6548 : : NULL,
6549 : : },
6550 : : };
6551 : :
6552 : : /* *** START FORWARDING *** */
6553 : : struct cmd_start_result {
6554 : : cmdline_fixed_string_t start;
6555 : : };
6556 : :
6557 : : static cmdline_parse_token_string_t cmd_start_start =
6558 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6559 : :
6560 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
6561 : : __rte_unused struct cmdline *cl,
6562 : : __rte_unused void *data)
6563 : : {
6564 : 0 : start_packet_forwarding(0);
6565 : 0 : }
6566 : :
6567 : : static cmdline_parse_inst_t cmd_start = {
6568 : : .f = cmd_start_parsed,
6569 : : .data = NULL,
6570 : : .help_str = "start: Start packet forwarding",
6571 : : .tokens = {
6572 : : (void *)&cmd_start_start,
6573 : : NULL,
6574 : : },
6575 : : };
6576 : :
6577 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6578 : : struct cmd_start_tx_first_result {
6579 : : cmdline_fixed_string_t start;
6580 : : cmdline_fixed_string_t tx_first;
6581 : : };
6582 : :
6583 : : static void
6584 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
6585 : : __rte_unused struct cmdline *cl,
6586 : : __rte_unused void *data)
6587 : : {
6588 : 0 : start_packet_forwarding(1);
6589 : 0 : }
6590 : :
6591 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
6592 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6593 : : "start");
6594 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6595 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6596 : : tx_first, "tx_first");
6597 : :
6598 : : static cmdline_parse_inst_t cmd_start_tx_first = {
6599 : : .f = cmd_start_tx_first_parsed,
6600 : : .data = NULL,
6601 : : .help_str = "start tx_first: Start packet forwarding, "
6602 : : "after sending 1 burst of packets",
6603 : : .tokens = {
6604 : : (void *)&cmd_start_tx_first_start,
6605 : : (void *)&cmd_start_tx_first_tx_first,
6606 : : NULL,
6607 : : },
6608 : : };
6609 : :
6610 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
6611 : : struct cmd_start_tx_first_n_result {
6612 : : cmdline_fixed_string_t start;
6613 : : cmdline_fixed_string_t tx_first;
6614 : : uint32_t tx_num;
6615 : : };
6616 : :
6617 : : static void
6618 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
6619 : : __rte_unused struct cmdline *cl,
6620 : : __rte_unused void *data)
6621 : : {
6622 : : struct cmd_start_tx_first_n_result *res = parsed_result;
6623 : :
6624 : 0 : start_packet_forwarding(res->tx_num);
6625 : 0 : }
6626 : :
6627 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6628 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6629 : : start, "start");
6630 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6631 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6632 : : tx_first, "tx_first");
6633 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6634 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6635 : : tx_num, RTE_UINT32);
6636 : :
6637 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
6638 : : .f = cmd_start_tx_first_n_parsed,
6639 : : .data = NULL,
6640 : : .help_str = "start tx_first <num>: "
6641 : : "packet forwarding, after sending <num> bursts of packets",
6642 : : .tokens = {
6643 : : (void *)&cmd_start_tx_first_n_start,
6644 : : (void *)&cmd_start_tx_first_n_tx_first,
6645 : : (void *)&cmd_start_tx_first_n_tx_num,
6646 : : NULL,
6647 : : },
6648 : : };
6649 : :
6650 : : /* *** SET LINK UP *** */
6651 : : struct cmd_set_link_up_result {
6652 : : cmdline_fixed_string_t set;
6653 : : cmdline_fixed_string_t link_up;
6654 : : cmdline_fixed_string_t port;
6655 : : portid_t port_id;
6656 : : };
6657 : :
6658 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
6659 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6660 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
6661 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6662 : : "link-up");
6663 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
6664 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6665 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
6666 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
6667 : : RTE_UINT16);
6668 : :
6669 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
6670 : : __rte_unused struct cmdline *cl,
6671 : : __rte_unused void *data)
6672 : : {
6673 : : struct cmd_set_link_up_result *res = parsed_result;
6674 : 0 : dev_set_link_up(res->port_id);
6675 : 0 : }
6676 : :
6677 : : static cmdline_parse_inst_t cmd_set_link_up = {
6678 : : .f = cmd_set_link_up_parsed,
6679 : : .data = NULL,
6680 : : .help_str = "set link-up port <port id>",
6681 : : .tokens = {
6682 : : (void *)&cmd_set_link_up_set,
6683 : : (void *)&cmd_set_link_up_link_up,
6684 : : (void *)&cmd_set_link_up_port,
6685 : : (void *)&cmd_set_link_up_port_id,
6686 : : NULL,
6687 : : },
6688 : : };
6689 : :
6690 : : /* *** SET LINK DOWN *** */
6691 : : struct cmd_set_link_down_result {
6692 : : cmdline_fixed_string_t set;
6693 : : cmdline_fixed_string_t link_down;
6694 : : cmdline_fixed_string_t port;
6695 : : portid_t port_id;
6696 : : };
6697 : :
6698 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
6699 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6700 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
6701 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6702 : : "link-down");
6703 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
6704 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6705 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
6706 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
6707 : : RTE_UINT16);
6708 : :
6709 : 0 : static void cmd_set_link_down_parsed(
6710 : : __rte_unused void *parsed_result,
6711 : : __rte_unused struct cmdline *cl,
6712 : : __rte_unused void *data)
6713 : : {
6714 : : struct cmd_set_link_down_result *res = parsed_result;
6715 : 0 : dev_set_link_down(res->port_id);
6716 : 0 : }
6717 : :
6718 : : static cmdline_parse_inst_t cmd_set_link_down = {
6719 : : .f = cmd_set_link_down_parsed,
6720 : : .data = NULL,
6721 : : .help_str = "set link-down port <port id>",
6722 : : .tokens = {
6723 : : (void *)&cmd_set_link_down_set,
6724 : : (void *)&cmd_set_link_down_link_down,
6725 : : (void *)&cmd_set_link_down_port,
6726 : : (void *)&cmd_set_link_down_port_id,
6727 : : NULL,
6728 : : },
6729 : : };
6730 : :
6731 : : /* *** SHOW CFG *** */
6732 : : struct cmd_showcfg_result {
6733 : : cmdline_fixed_string_t show;
6734 : : cmdline_fixed_string_t cfg;
6735 : : cmdline_fixed_string_t what;
6736 : : };
6737 : :
6738 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
6739 : : __rte_unused struct cmdline *cl,
6740 : : __rte_unused void *data)
6741 : : {
6742 : : struct cmd_showcfg_result *res = parsed_result;
6743 : 0 : if (!strcmp(res->what, "rxtx"))
6744 : 0 : rxtx_config_display();
6745 : 0 : else if (!strcmp(res->what, "cores"))
6746 : 0 : fwd_lcores_config_display();
6747 : 0 : else if (!strcmp(res->what, "fwd"))
6748 : 0 : pkt_fwd_config_display(&cur_fwd_config);
6749 : 0 : else if (!strcmp(res->what, "rxoffs"))
6750 : 0 : show_rx_pkt_offsets();
6751 : 0 : else if (!strcmp(res->what, "rxpkts"))
6752 : 0 : show_rx_pkt_segments();
6753 : 0 : else if (!strcmp(res->what, "rxhdrs"))
6754 : 0 : show_rx_pkt_hdrs();
6755 : 0 : else if (!strcmp(res->what, "txpkts"))
6756 : 0 : show_tx_pkt_segments();
6757 : 0 : else if (!strcmp(res->what, "txtimes"))
6758 : 0 : show_tx_pkt_times();
6759 : 0 : }
6760 : :
6761 : : static cmdline_parse_token_string_t cmd_showcfg_show =
6762 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6763 : : static cmdline_parse_token_string_t cmd_showcfg_port =
6764 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6765 : : static cmdline_parse_token_string_t cmd_showcfg_what =
6766 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6767 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
6768 : :
6769 : : static cmdline_parse_inst_t cmd_showcfg = {
6770 : : .f = cmd_showcfg_parsed,
6771 : : .data = NULL,
6772 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
6773 : : .tokens = {
6774 : : (void *)&cmd_showcfg_show,
6775 : : (void *)&cmd_showcfg_port,
6776 : : (void *)&cmd_showcfg_what,
6777 : : NULL,
6778 : : },
6779 : : };
6780 : :
6781 : : /* *** SHOW ALL PORT INFO *** */
6782 : : struct cmd_showportall_result {
6783 : : cmdline_fixed_string_t show;
6784 : : cmdline_fixed_string_t port;
6785 : : cmdline_fixed_string_t what;
6786 : : cmdline_fixed_string_t all;
6787 : : };
6788 : :
6789 : 0 : static void cmd_showportall_parsed(void *parsed_result,
6790 : : __rte_unused struct cmdline *cl,
6791 : : __rte_unused void *data)
6792 : : {
6793 : : portid_t i;
6794 : :
6795 : : struct cmd_showportall_result *res = parsed_result;
6796 : 0 : if (!strcmp(res->show, "clear")) {
6797 : 0 : if (!strcmp(res->what, "stats"))
6798 : 0 : RTE_ETH_FOREACH_DEV(i)
6799 : 0 : nic_stats_clear(i);
6800 : 0 : else if (!strcmp(res->what, "xstats"))
6801 : 0 : RTE_ETH_FOREACH_DEV(i)
6802 : 0 : nic_xstats_clear(i);
6803 : 0 : } else if (!strcmp(res->what, "info"))
6804 : 0 : RTE_ETH_FOREACH_DEV(i)
6805 : 0 : port_infos_display(i);
6806 : 0 : else if (!strcmp(res->what, "summary")) {
6807 : 0 : port_summary_header_display();
6808 : 0 : RTE_ETH_FOREACH_DEV(i)
6809 : 0 : port_summary_display(i);
6810 : : }
6811 : 0 : else if (!strcmp(res->what, "stats"))
6812 : 0 : RTE_ETH_FOREACH_DEV(i)
6813 : 0 : nic_stats_display(i);
6814 : 0 : else if (!strcmp(res->what, "xstats"))
6815 : 0 : RTE_ETH_FOREACH_DEV(i)
6816 : 0 : nic_xstats_display(i);
6817 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6818 : 0 : else if (!strcmp(res->what, "fdir"))
6819 : 0 : RTE_ETH_FOREACH_DEV(i)
6820 : 0 : fdir_get_infos(i);
6821 : : #endif
6822 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6823 : 0 : RTE_ETH_FOREACH_DEV(i)
6824 : 0 : port_dcb_info_display(i);
6825 : 0 : }
6826 : :
6827 : : static cmdline_parse_token_string_t cmd_showportall_show =
6828 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6829 : : "show#clear");
6830 : : static cmdline_parse_token_string_t cmd_showportall_port =
6831 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6832 : : static cmdline_parse_token_string_t cmd_showportall_what =
6833 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6834 : : "info#summary#stats#xstats#fdir#dcb_tc");
6835 : : static cmdline_parse_token_string_t cmd_showportall_all =
6836 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6837 : : static cmdline_parse_inst_t cmd_showportall = {
6838 : : .f = cmd_showportall_parsed,
6839 : : .data = NULL,
6840 : : .help_str = "show|clear port "
6841 : : "info|summary|stats|xstats|fdir|dcb_tc all",
6842 : : .tokens = {
6843 : : (void *)&cmd_showportall_show,
6844 : : (void *)&cmd_showportall_port,
6845 : : (void *)&cmd_showportall_what,
6846 : : (void *)&cmd_showportall_all,
6847 : : NULL,
6848 : : },
6849 : : };
6850 : :
6851 : : /* *** SHOW PORT INFO *** */
6852 : : struct cmd_showport_result {
6853 : : cmdline_fixed_string_t show;
6854 : : cmdline_fixed_string_t port;
6855 : : cmdline_fixed_string_t what;
6856 : : uint16_t portnum;
6857 : : };
6858 : :
6859 : 0 : static void cmd_showport_parsed(void *parsed_result,
6860 : : __rte_unused struct cmdline *cl,
6861 : : __rte_unused void *data)
6862 : : {
6863 : : struct cmd_showport_result *res = parsed_result;
6864 : 0 : if (!strcmp(res->show, "clear")) {
6865 : 0 : if (!strcmp(res->what, "stats"))
6866 : 0 : nic_stats_clear(res->portnum);
6867 : 0 : else if (!strcmp(res->what, "xstats"))
6868 : 0 : nic_xstats_clear(res->portnum);
6869 : 0 : } else if (!strcmp(res->what, "info"))
6870 : 0 : port_infos_display(res->portnum);
6871 : 0 : else if (!strcmp(res->what, "summary")) {
6872 : 0 : port_summary_header_display();
6873 : 0 : port_summary_display(res->portnum);
6874 : : }
6875 : 0 : else if (!strcmp(res->what, "stats"))
6876 : 0 : nic_stats_display(res->portnum);
6877 : 0 : else if (!strcmp(res->what, "xstats"))
6878 : 0 : nic_xstats_display(res->portnum);
6879 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6880 : 0 : else if (!strcmp(res->what, "fdir"))
6881 : 0 : fdir_get_infos(res->portnum);
6882 : : #endif
6883 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6884 : 0 : port_dcb_info_display(res->portnum);
6885 : 0 : }
6886 : :
6887 : : static cmdline_parse_token_string_t cmd_showport_show =
6888 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6889 : : "show#clear");
6890 : : static cmdline_parse_token_string_t cmd_showport_port =
6891 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6892 : : static cmdline_parse_token_string_t cmd_showport_what =
6893 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6894 : : "info#summary#stats#xstats#fdir#dcb_tc");
6895 : : static cmdline_parse_token_num_t cmd_showport_portnum =
6896 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
6897 : :
6898 : : static cmdline_parse_inst_t cmd_showport = {
6899 : : .f = cmd_showport_parsed,
6900 : : .data = NULL,
6901 : : .help_str = "show|clear port "
6902 : : "info|summary|stats|xstats|fdir|dcb_tc "
6903 : : "<port_id>",
6904 : : .tokens = {
6905 : : (void *)&cmd_showport_show,
6906 : : (void *)&cmd_showport_port,
6907 : : (void *)&cmd_showport_what,
6908 : : (void *)&cmd_showport_portnum,
6909 : : NULL,
6910 : : },
6911 : : };
6912 : :
6913 : : /* *** show port representors information *** */
6914 : : struct cmd_representor_info_result {
6915 : : cmdline_fixed_string_t cmd_show;
6916 : : cmdline_fixed_string_t cmd_port;
6917 : : cmdline_fixed_string_t cmd_info;
6918 : : cmdline_fixed_string_t cmd_keyword;
6919 : : portid_t cmd_pid;
6920 : : };
6921 : :
6922 : : static void
6923 : 0 : cmd_representor_info_parsed(void *parsed_result,
6924 : : __rte_unused struct cmdline *cl,
6925 : : __rte_unused void *data)
6926 : : {
6927 : : struct cmd_representor_info_result *res = parsed_result;
6928 : : struct rte_eth_representor_info *info;
6929 : : struct rte_eth_representor_range *range;
6930 : : uint32_t range_diff;
6931 : : uint32_t i;
6932 : : int ret;
6933 : : int num;
6934 : :
6935 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6936 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
6937 : 0 : return;
6938 : : }
6939 : :
6940 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
6941 : 0 : if (ret < 0) {
6942 : 0 : fprintf(stderr,
6943 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
6944 : 0 : res->cmd_pid, rte_strerror(-ret));
6945 : 0 : return;
6946 : : }
6947 : : num = ret;
6948 : :
6949 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
6950 : 0 : if (info == NULL) {
6951 : 0 : fprintf(stderr,
6952 : : "Failed to allocate memory for representor info for port %hu\n",
6953 : 0 : res->cmd_pid);
6954 : 0 : return;
6955 : : }
6956 : 0 : info->nb_ranges_alloc = num;
6957 : :
6958 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
6959 : 0 : if (ret < 0) {
6960 : 0 : fprintf(stderr,
6961 : : "Failed to get the representor info for port %hu: %s\n",
6962 : 0 : res->cmd_pid, rte_strerror(-ret));
6963 : 0 : free(info);
6964 : 0 : return;
6965 : : }
6966 : :
6967 : 0 : printf("Port controller: %hu\n", info->controller);
6968 : 0 : printf("Port PF: %hu\n", info->pf);
6969 : :
6970 : 0 : printf("Ranges: %u\n", info->nb_ranges);
6971 : 0 : for (i = 0; i < info->nb_ranges; i++) {
6972 : : range = &info->ranges[i];
6973 : 0 : range_diff = range->id_end - range->id_base;
6974 : :
6975 : 0 : printf("%u. ", i + 1);
6976 : 0 : printf("'%s' ", range->name);
6977 : 0 : if (range_diff > 0)
6978 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
6979 : : else
6980 : 0 : printf("[%u]: ", range->id_base);
6981 : :
6982 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
6983 : :
6984 : 0 : switch (range->type) {
6985 : : case RTE_ETH_REPRESENTOR_NONE:
6986 : : printf(", NONE\n");
6987 : : break;
6988 : 0 : case RTE_ETH_REPRESENTOR_VF:
6989 : 0 : if (range_diff > 0)
6990 : 0 : printf(", VF %d..%d\n", range->vf,
6991 : 0 : range->vf + range_diff);
6992 : : else
6993 : 0 : printf(", VF %d\n", range->vf);
6994 : : break;
6995 : 0 : case RTE_ETH_REPRESENTOR_SF:
6996 : 0 : printf(", SF %d\n", range->sf);
6997 : : break;
6998 : 0 : case RTE_ETH_REPRESENTOR_PF:
6999 : 0 : if (range_diff > 0)
7000 : 0 : printf("..%d\n", range->pf + range_diff);
7001 : : else
7002 : : printf("\n");
7003 : : break;
7004 : 0 : default:
7005 : : printf(", UNKNOWN TYPE %d\n", range->type);
7006 : : break;
7007 : : }
7008 : : }
7009 : :
7010 : 0 : free(info);
7011 : : }
7012 : :
7013 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7014 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7015 : : cmd_show, "show");
7016 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7017 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7018 : : cmd_port, "port");
7019 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7020 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7021 : : cmd_info, "info");
7022 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7023 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7024 : : cmd_pid, RTE_UINT16);
7025 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7026 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7027 : : cmd_keyword, "representor");
7028 : :
7029 : : static cmdline_parse_inst_t cmd_representor_info = {
7030 : : .f = cmd_representor_info_parsed,
7031 : : .data = NULL,
7032 : : .help_str = "show port info <port_id> representor",
7033 : : .tokens = {
7034 : : (void *)&cmd_representor_info_show,
7035 : : (void *)&cmd_representor_info_port,
7036 : : (void *)&cmd_representor_info_info,
7037 : : (void *)&cmd_representor_info_pid,
7038 : : (void *)&cmd_representor_info_keyword,
7039 : : NULL,
7040 : : },
7041 : : };
7042 : :
7043 : :
7044 : : /* *** SHOW DEVICE INFO *** */
7045 : : struct cmd_showdevice_result {
7046 : : cmdline_fixed_string_t show;
7047 : : cmdline_fixed_string_t device;
7048 : : cmdline_fixed_string_t what;
7049 : : cmdline_fixed_string_t identifier;
7050 : : };
7051 : :
7052 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7053 : : __rte_unused struct cmdline *cl,
7054 : : __rte_unused void *data)
7055 : : {
7056 : : struct cmd_showdevice_result *res = parsed_result;
7057 : 0 : if (!strcmp(res->what, "info")) {
7058 : 0 : if (!strcmp(res->identifier, "all"))
7059 : 0 : device_infos_display(NULL);
7060 : : else
7061 : 0 : device_infos_display(res->identifier);
7062 : : }
7063 : 0 : }
7064 : :
7065 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7066 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7067 : : "show");
7068 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7069 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7070 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7071 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7072 : : "info");
7073 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7074 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7075 : : identifier, NULL);
7076 : :
7077 : : static cmdline_parse_inst_t cmd_showdevice = {
7078 : : .f = cmd_showdevice_parsed,
7079 : : .data = NULL,
7080 : : .help_str = "show device info <identifier>|all",
7081 : : .tokens = {
7082 : : (void *)&cmd_showdevice_show,
7083 : : (void *)&cmd_showdevice_device,
7084 : : (void *)&cmd_showdevice_what,
7085 : : (void *)&cmd_showdevice_identifier,
7086 : : NULL,
7087 : : },
7088 : : };
7089 : :
7090 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7091 : : struct cmd_showeeprom_result {
7092 : : cmdline_fixed_string_t show;
7093 : : cmdline_fixed_string_t port;
7094 : : uint16_t portnum;
7095 : : cmdline_fixed_string_t type;
7096 : : };
7097 : :
7098 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7099 : : __rte_unused struct cmdline *cl,
7100 : : __rte_unused void *data)
7101 : : {
7102 : : struct cmd_showeeprom_result *res = parsed_result;
7103 : :
7104 : 0 : if (!strcmp(res->type, "eeprom"))
7105 : 0 : port_eeprom_display(res->portnum);
7106 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7107 : 0 : port_module_eeprom_display(res->portnum);
7108 : : else
7109 : 0 : fprintf(stderr, "Unknown argument\n");
7110 : 0 : }
7111 : :
7112 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7113 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7114 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7115 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7116 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7117 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7118 : : RTE_UINT16);
7119 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7120 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7121 : :
7122 : : static cmdline_parse_inst_t cmd_showeeprom = {
7123 : : .f = cmd_showeeprom_parsed,
7124 : : .data = NULL,
7125 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7126 : : .tokens = {
7127 : : (void *)&cmd_showeeprom_show,
7128 : : (void *)&cmd_showeeprom_port,
7129 : : (void *)&cmd_showeeprom_portnum,
7130 : : (void *)&cmd_showeeprom_type,
7131 : : NULL,
7132 : : },
7133 : : };
7134 : :
7135 : : /* *** SHOW QUEUE INFO *** */
7136 : : struct cmd_showqueue_result {
7137 : : cmdline_fixed_string_t show;
7138 : : cmdline_fixed_string_t type;
7139 : : cmdline_fixed_string_t what;
7140 : : uint16_t portnum;
7141 : : uint16_t queuenum;
7142 : : };
7143 : :
7144 : : static void
7145 : 0 : cmd_showqueue_parsed(void *parsed_result,
7146 : : __rte_unused struct cmdline *cl,
7147 : : __rte_unused void *data)
7148 : : {
7149 : : struct cmd_showqueue_result *res = parsed_result;
7150 : :
7151 : 0 : if (!strcmp(res->type, "rxq"))
7152 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7153 : 0 : else if (!strcmp(res->type, "txq"))
7154 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7155 : 0 : }
7156 : :
7157 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7158 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7159 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7160 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7161 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7162 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7163 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7164 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7165 : : RTE_UINT16);
7166 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7167 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7168 : : RTE_UINT16);
7169 : :
7170 : : static cmdline_parse_inst_t cmd_showqueue = {
7171 : : .f = cmd_showqueue_parsed,
7172 : : .data = NULL,
7173 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7174 : : .tokens = {
7175 : : (void *)&cmd_showqueue_show,
7176 : : (void *)&cmd_showqueue_type,
7177 : : (void *)&cmd_showqueue_what,
7178 : : (void *)&cmd_showqueue_portnum,
7179 : : (void *)&cmd_showqueue_queuenum,
7180 : : NULL,
7181 : : },
7182 : : };
7183 : :
7184 : : /* show/clear fwd engine statistics */
7185 : : struct fwd_result {
7186 : : cmdline_fixed_string_t action;
7187 : : cmdline_fixed_string_t fwd;
7188 : : cmdline_fixed_string_t stats;
7189 : : cmdline_fixed_string_t all;
7190 : : };
7191 : :
7192 : : static cmdline_parse_token_string_t cmd_fwd_action =
7193 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7194 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7195 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7196 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7197 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7198 : : static cmdline_parse_token_string_t cmd_fwd_all =
7199 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7200 : :
7201 : : static void
7202 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7203 : : __rte_unused struct cmdline *cl,
7204 : : __rte_unused void *data)
7205 : : {
7206 : : struct fwd_result *res = parsed_result;
7207 : :
7208 : 0 : if (!strcmp(res->action, "show"))
7209 : 0 : fwd_stats_display();
7210 : : else
7211 : 0 : fwd_stats_reset();
7212 : 0 : }
7213 : :
7214 : : static cmdline_parse_inst_t cmd_showfwdall = {
7215 : : .f = cmd_showfwdall_parsed,
7216 : : .data = NULL,
7217 : : .help_str = "show|clear fwd stats all",
7218 : : .tokens = {
7219 : : (void *)&cmd_fwd_action,
7220 : : (void *)&cmd_fwd_fwd,
7221 : : (void *)&cmd_fwd_stats,
7222 : : (void *)&cmd_fwd_all,
7223 : : NULL,
7224 : : },
7225 : : };
7226 : :
7227 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7228 : : struct cmd_read_rxd_txd_result {
7229 : : cmdline_fixed_string_t read;
7230 : : cmdline_fixed_string_t rxd_txd;
7231 : : portid_t port_id;
7232 : : uint16_t queue_id;
7233 : : uint16_t desc_id;
7234 : : };
7235 : :
7236 : : static void
7237 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7238 : : __rte_unused struct cmdline *cl,
7239 : : __rte_unused void *data)
7240 : : {
7241 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7242 : :
7243 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7244 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7245 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7246 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7247 : 0 : }
7248 : :
7249 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7250 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7251 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7252 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7253 : : "rxd#txd");
7254 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7255 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7256 : : RTE_UINT16);
7257 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7258 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7259 : : RTE_UINT16);
7260 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7261 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7262 : : RTE_UINT16);
7263 : :
7264 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7265 : : .f = cmd_read_rxd_txd_parsed,
7266 : : .data = NULL,
7267 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7268 : : .tokens = {
7269 : : (void *)&cmd_read_rxd_txd_read,
7270 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7271 : : (void *)&cmd_read_rxd_txd_port_id,
7272 : : (void *)&cmd_read_rxd_txd_queue_id,
7273 : : (void *)&cmd_read_rxd_txd_desc_id,
7274 : : NULL,
7275 : : },
7276 : : };
7277 : :
7278 : : /* *** QUIT *** */
7279 : : struct cmd_quit_result {
7280 : : cmdline_fixed_string_t quit;
7281 : : };
7282 : :
7283 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7284 : : struct cmdline *cl,
7285 : : __rte_unused void *data)
7286 : : {
7287 : 0 : cmdline_quit(cl);
7288 : 0 : cl_quit = 1;
7289 : 0 : }
7290 : :
7291 : : static cmdline_parse_token_string_t cmd_quit_quit =
7292 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7293 : :
7294 : : static cmdline_parse_inst_t cmd_quit = {
7295 : : .f = cmd_quit_parsed,
7296 : : .data = NULL,
7297 : : .help_str = "quit: Exit application",
7298 : : .tokens = {
7299 : : (void *)&cmd_quit_quit,
7300 : : NULL,
7301 : : },
7302 : : };
7303 : :
7304 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7305 : : struct cmd_mac_addr_result {
7306 : : cmdline_fixed_string_t mac_addr_cmd;
7307 : : cmdline_fixed_string_t what;
7308 : : uint16_t port_num;
7309 : : struct rte_ether_addr address;
7310 : : };
7311 : :
7312 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7313 : : __rte_unused struct cmdline *cl,
7314 : : __rte_unused void *data)
7315 : : {
7316 : : struct cmd_mac_addr_result *res = parsed_result;
7317 : : int ret;
7318 : :
7319 : 0 : if (strcmp(res->what, "add") == 0)
7320 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7321 : 0 : else if (strcmp(res->what, "set") == 0)
7322 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7323 : : &res->address);
7324 : : else
7325 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7326 : :
7327 : : /* check the return value and print it if is < 0 */
7328 : 0 : if(ret < 0)
7329 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7330 : :
7331 : 0 : }
7332 : :
7333 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7334 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7335 : : "mac_addr");
7336 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7337 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7338 : : "add#remove#set");
7339 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7340 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7341 : : RTE_UINT16);
7342 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7343 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7344 : :
7345 : : static cmdline_parse_inst_t cmd_mac_addr = {
7346 : : .f = cmd_mac_addr_parsed,
7347 : : .data = (void *)0,
7348 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7349 : : "Add/Remove/Set MAC address on port_id",
7350 : : .tokens = {
7351 : : (void *)&cmd_mac_addr_cmd,
7352 : : (void *)&cmd_mac_addr_what,
7353 : : (void *)&cmd_mac_addr_portnum,
7354 : : (void *)&cmd_mac_addr_addr,
7355 : : NULL,
7356 : : },
7357 : : };
7358 : :
7359 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7360 : : struct cmd_eth_peer_result {
7361 : : cmdline_fixed_string_t set;
7362 : : cmdline_fixed_string_t eth_peer;
7363 : : portid_t port_id;
7364 : : cmdline_fixed_string_t peer_addr;
7365 : : };
7366 : :
7367 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7368 : : __rte_unused struct cmdline *cl,
7369 : : __rte_unused void *data)
7370 : : {
7371 : : struct cmd_eth_peer_result *res = parsed_result;
7372 : :
7373 : 0 : if (test_done == 0) {
7374 : 0 : fprintf(stderr, "Please stop forwarding first\n");
7375 : 0 : return;
7376 : : }
7377 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
7378 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
7379 : 0 : fwd_config_setup();
7380 : : }
7381 : : }
7382 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
7383 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7384 : : static cmdline_parse_token_string_t cmd_eth_peer =
7385 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7386 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
7387 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
7388 : : RTE_UINT16);
7389 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
7390 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7391 : :
7392 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7393 : : .f = cmd_set_eth_peer_parsed,
7394 : : .data = NULL,
7395 : : .help_str = "set eth-peer <port_id> <peer_mac>",
7396 : : .tokens = {
7397 : : (void *)&cmd_eth_peer_set,
7398 : : (void *)&cmd_eth_peer,
7399 : : (void *)&cmd_eth_peer_port_id,
7400 : : (void *)&cmd_eth_peer_addr,
7401 : : NULL,
7402 : : },
7403 : : };
7404 : :
7405 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7406 : : struct cmd_set_qmap_result {
7407 : : cmdline_fixed_string_t set;
7408 : : cmdline_fixed_string_t qmap;
7409 : : cmdline_fixed_string_t what;
7410 : : portid_t port_id;
7411 : : uint16_t queue_id;
7412 : : uint8_t map_value;
7413 : : };
7414 : :
7415 : : static void
7416 : 0 : cmd_set_qmap_parsed(void *parsed_result,
7417 : : __rte_unused struct cmdline *cl,
7418 : : __rte_unused void *data)
7419 : : {
7420 : : struct cmd_set_qmap_result *res = parsed_result;
7421 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7422 : :
7423 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7424 : 0 : }
7425 : :
7426 : : static cmdline_parse_token_string_t cmd_setqmap_set =
7427 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7428 : : set, "set");
7429 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
7430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7431 : : qmap, "stat_qmap");
7432 : : static cmdline_parse_token_string_t cmd_setqmap_what =
7433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7434 : : what, "tx#rx");
7435 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
7436 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7437 : : port_id, RTE_UINT16);
7438 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
7439 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7440 : : queue_id, RTE_UINT16);
7441 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7442 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7443 : : map_value, RTE_UINT8);
7444 : :
7445 : : static cmdline_parse_inst_t cmd_set_qmap = {
7446 : : .f = cmd_set_qmap_parsed,
7447 : : .data = NULL,
7448 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7449 : : "Set statistics mapping value on tx|rx queue_id of port_id",
7450 : : .tokens = {
7451 : : (void *)&cmd_setqmap_set,
7452 : : (void *)&cmd_setqmap_qmap,
7453 : : (void *)&cmd_setqmap_what,
7454 : : (void *)&cmd_setqmap_portid,
7455 : : (void *)&cmd_setqmap_queueid,
7456 : : (void *)&cmd_setqmap_mapvalue,
7457 : : NULL,
7458 : : },
7459 : : };
7460 : :
7461 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7462 : : struct cmd_set_xstats_hide_zero_result {
7463 : : cmdline_fixed_string_t keyword;
7464 : : cmdline_fixed_string_t name;
7465 : : cmdline_fixed_string_t on_off;
7466 : : };
7467 : :
7468 : : static void
7469 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7470 : : __rte_unused struct cmdline *cl,
7471 : : __rte_unused void *data)
7472 : : {
7473 : : struct cmd_set_xstats_hide_zero_result *res;
7474 : : uint16_t on_off = 0;
7475 : :
7476 : : res = parsed_result;
7477 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7478 : 0 : set_xstats_hide_zero(on_off);
7479 : 0 : }
7480 : :
7481 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7482 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7483 : : keyword, "set");
7484 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7486 : : name, "xstats-hide-zero");
7487 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7488 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7489 : : on_off, "on#off");
7490 : :
7491 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7492 : : .f = cmd_set_xstats_hide_zero_parsed,
7493 : : .data = NULL,
7494 : : .help_str = "set xstats-hide-zero on|off",
7495 : : .tokens = {
7496 : : (void *)&cmd_set_xstats_hide_zero_keyword,
7497 : : (void *)&cmd_set_xstats_hide_zero_name,
7498 : : (void *)&cmd_set_xstats_hide_zero_on_off,
7499 : : NULL,
7500 : : },
7501 : : };
7502 : :
7503 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
7504 : : struct cmd_set_record_core_cycles_result {
7505 : : cmdline_fixed_string_t keyword;
7506 : : cmdline_fixed_string_t name;
7507 : : cmdline_fixed_string_t on_off;
7508 : : };
7509 : :
7510 : : static void
7511 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
7512 : : __rte_unused struct cmdline *cl,
7513 : : __rte_unused void *data)
7514 : : {
7515 : : struct cmd_set_record_core_cycles_result *res;
7516 : : uint16_t on_off = 0;
7517 : :
7518 : : res = parsed_result;
7519 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7520 : 0 : set_record_core_cycles(on_off);
7521 : 0 : }
7522 : :
7523 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
7524 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7525 : : keyword, "set");
7526 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
7527 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7528 : : name, "record-core-cycles");
7529 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
7530 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7531 : : on_off, "on#off");
7532 : :
7533 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
7534 : : .f = cmd_set_record_core_cycles_parsed,
7535 : : .data = NULL,
7536 : : .help_str = "set record-core-cycles on|off",
7537 : : .tokens = {
7538 : : (void *)&cmd_set_record_core_cycles_keyword,
7539 : : (void *)&cmd_set_record_core_cycles_name,
7540 : : (void *)&cmd_set_record_core_cycles_on_off,
7541 : : NULL,
7542 : : },
7543 : : };
7544 : :
7545 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
7546 : : struct cmd_set_record_burst_stats_result {
7547 : : cmdline_fixed_string_t keyword;
7548 : : cmdline_fixed_string_t name;
7549 : : cmdline_fixed_string_t on_off;
7550 : : };
7551 : :
7552 : : static void
7553 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
7554 : : __rte_unused struct cmdline *cl,
7555 : : __rte_unused void *data)
7556 : : {
7557 : : struct cmd_set_record_burst_stats_result *res;
7558 : : uint16_t on_off = 0;
7559 : :
7560 : : res = parsed_result;
7561 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7562 : 0 : set_record_burst_stats(on_off);
7563 : 0 : }
7564 : :
7565 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
7566 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7567 : : keyword, "set");
7568 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
7569 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7570 : : name, "record-burst-stats");
7571 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
7572 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7573 : : on_off, "on#off");
7574 : :
7575 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
7576 : : .f = cmd_set_record_burst_stats_parsed,
7577 : : .data = NULL,
7578 : : .help_str = "set record-burst-stats on|off",
7579 : : .tokens = {
7580 : : (void *)&cmd_set_record_burst_stats_keyword,
7581 : : (void *)&cmd_set_record_burst_stats_name,
7582 : : (void *)&cmd_set_record_burst_stats_on_off,
7583 : : NULL,
7584 : : },
7585 : : };
7586 : :
7587 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
7588 : : struct cmd_set_uc_hash_table {
7589 : : cmdline_fixed_string_t set;
7590 : : cmdline_fixed_string_t port;
7591 : : portid_t port_id;
7592 : : cmdline_fixed_string_t what;
7593 : : struct rte_ether_addr address;
7594 : : cmdline_fixed_string_t mode;
7595 : : };
7596 : :
7597 : : static void
7598 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
7599 : : __rte_unused struct cmdline *cl,
7600 : : __rte_unused void *data)
7601 : : {
7602 : : int ret=0;
7603 : : struct cmd_set_uc_hash_table *res = parsed_result;
7604 : :
7605 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7606 : :
7607 : 0 : if (strcmp(res->what, "uta") == 0)
7608 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7609 : : &res->address,(uint8_t)is_on);
7610 : 0 : if (ret < 0)
7611 : 0 : fprintf(stderr,
7612 : : "bad unicast hash table parameter, return code = %d\n",
7613 : : ret);
7614 : :
7615 : 0 : }
7616 : :
7617 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
7618 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7619 : : set, "set");
7620 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
7621 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7622 : : port, "port");
7623 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7624 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7625 : : port_id, RTE_UINT16);
7626 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
7627 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7628 : : what, "uta");
7629 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7630 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7631 : : address);
7632 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7633 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7634 : : mode, "on#off");
7635 : :
7636 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7637 : : .f = cmd_set_uc_hash_parsed,
7638 : : .data = NULL,
7639 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
7640 : : .tokens = {
7641 : : (void *)&cmd_set_uc_hash_set,
7642 : : (void *)&cmd_set_uc_hash_port,
7643 : : (void *)&cmd_set_uc_hash_portid,
7644 : : (void *)&cmd_set_uc_hash_what,
7645 : : (void *)&cmd_set_uc_hash_mac,
7646 : : (void *)&cmd_set_uc_hash_mode,
7647 : : NULL,
7648 : : },
7649 : : };
7650 : :
7651 : : struct cmd_set_uc_all_hash_table {
7652 : : cmdline_fixed_string_t set;
7653 : : cmdline_fixed_string_t port;
7654 : : portid_t port_id;
7655 : : cmdline_fixed_string_t what;
7656 : : cmdline_fixed_string_t value;
7657 : : cmdline_fixed_string_t mode;
7658 : : };
7659 : :
7660 : : static void
7661 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
7662 : : __rte_unused struct cmdline *cl,
7663 : : __rte_unused void *data)
7664 : : {
7665 : : int ret=0;
7666 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
7667 : :
7668 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7669 : :
7670 : 0 : if ((strcmp(res->what, "uta") == 0) &&
7671 : 0 : (strcmp(res->value, "all") == 0))
7672 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7673 : 0 : if (ret < 0)
7674 : 0 : fprintf(stderr,
7675 : : "bad unicast hash table parameter, return code = %d\n",
7676 : : ret);
7677 : 0 : }
7678 : :
7679 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7680 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7681 : : set, "set");
7682 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7683 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7684 : : port, "port");
7685 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7686 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7687 : : port_id, RTE_UINT16);
7688 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7689 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7690 : : what, "uta");
7691 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7692 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7693 : : value,"all");
7694 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7695 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7696 : : mode, "on#off");
7697 : :
7698 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7699 : : .f = cmd_set_uc_all_hash_parsed,
7700 : : .data = NULL,
7701 : : .help_str = "set port <port_id> uta all on|off",
7702 : : .tokens = {
7703 : : (void *)&cmd_set_uc_all_hash_set,
7704 : : (void *)&cmd_set_uc_all_hash_port,
7705 : : (void *)&cmd_set_uc_all_hash_portid,
7706 : : (void *)&cmd_set_uc_all_hash_what,
7707 : : (void *)&cmd_set_uc_all_hash_value,
7708 : : (void *)&cmd_set_uc_all_hash_mode,
7709 : : NULL,
7710 : : },
7711 : : };
7712 : :
7713 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7714 : : struct cmd_set_vf_traffic {
7715 : : cmdline_fixed_string_t set;
7716 : : cmdline_fixed_string_t port;
7717 : : portid_t port_id;
7718 : : cmdline_fixed_string_t vf;
7719 : : uint8_t vf_id;
7720 : : cmdline_fixed_string_t what;
7721 : : cmdline_fixed_string_t mode;
7722 : : };
7723 : :
7724 : : static void
7725 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
7726 : : __rte_unused struct cmdline *cl,
7727 : : __rte_unused void *data)
7728 : : {
7729 : : struct cmd_set_vf_traffic *res = parsed_result;
7730 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7731 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7732 : :
7733 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7734 : 0 : }
7735 : :
7736 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
7737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7738 : : set, "set");
7739 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
7740 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7741 : : port, "port");
7742 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7743 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7744 : : port_id, RTE_UINT16);
7745 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7746 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7747 : : vf, "vf");
7748 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7749 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7750 : : vf_id, RTE_UINT8);
7751 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
7752 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7753 : : what, "tx#rx");
7754 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7755 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7756 : : mode, "on#off");
7757 : :
7758 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
7759 : : .f = cmd_set_vf_traffic_parsed,
7760 : : .data = NULL,
7761 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7762 : : .tokens = {
7763 : : (void *)&cmd_setvf_traffic_set,
7764 : : (void *)&cmd_setvf_traffic_port,
7765 : : (void *)&cmd_setvf_traffic_portid,
7766 : : (void *)&cmd_setvf_traffic_vf,
7767 : : (void *)&cmd_setvf_traffic_vfid,
7768 : : (void *)&cmd_setvf_traffic_what,
7769 : : (void *)&cmd_setvf_traffic_mode,
7770 : : NULL,
7771 : : },
7772 : : };
7773 : :
7774 : : /* *** CONFIGURE VF RECEIVE MODE *** */
7775 : : struct cmd_set_vf_rxmode {
7776 : : cmdline_fixed_string_t set;
7777 : : cmdline_fixed_string_t port;
7778 : : portid_t port_id;
7779 : : cmdline_fixed_string_t vf;
7780 : : uint8_t vf_id;
7781 : : cmdline_fixed_string_t what;
7782 : : cmdline_fixed_string_t mode;
7783 : : cmdline_fixed_string_t on;
7784 : : };
7785 : :
7786 : : static void
7787 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
7788 : : __rte_unused struct cmdline *cl,
7789 : : __rte_unused void *data)
7790 : : {
7791 : : int ret = -ENOTSUP;
7792 : : uint16_t vf_rxmode = 0;
7793 : : struct cmd_set_vf_rxmode *res = parsed_result;
7794 : :
7795 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7796 : 0 : if (!strcmp(res->what,"rxmode")) {
7797 : 0 : if (!strcmp(res->mode, "AUPE"))
7798 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
7799 : 0 : else if (!strcmp(res->mode, "ROPE"))
7800 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
7801 : 0 : else if (!strcmp(res->mode, "BAM"))
7802 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
7803 : 0 : else if (!strncmp(res->mode, "MPE",3))
7804 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
7805 : : }
7806 : :
7807 : : RTE_SET_USED(is_on);
7808 : : RTE_SET_USED(vf_rxmode);
7809 : :
7810 : : #ifdef RTE_NET_IXGBE
7811 : : if (ret == -ENOTSUP)
7812 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7813 : : vf_rxmode, (uint8_t)is_on);
7814 : : #endif
7815 : : #ifdef RTE_NET_BNXT
7816 : 0 : if (ret == -ENOTSUP)
7817 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7818 : : vf_rxmode, (uint8_t)is_on);
7819 : : #endif
7820 : 0 : if (ret < 0)
7821 : 0 : fprintf(stderr,
7822 : : "bad VF receive mode parameter, return code = %d\n",
7823 : : ret);
7824 : 0 : }
7825 : :
7826 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7827 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7828 : : set, "set");
7829 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7830 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7831 : : port, "port");
7832 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7833 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7834 : : port_id, RTE_UINT16);
7835 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7836 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7837 : : vf, "vf");
7838 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7839 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7840 : : vf_id, RTE_UINT8);
7841 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7842 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7843 : : what, "rxmode");
7844 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7845 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7846 : : mode, "AUPE#ROPE#BAM#MPE");
7847 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7848 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7849 : : on, "on#off");
7850 : :
7851 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
7852 : : .f = cmd_set_vf_rxmode_parsed,
7853 : : .data = NULL,
7854 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
7855 : : "AUPE|ROPE|BAM|MPE on|off",
7856 : : .tokens = {
7857 : : (void *)&cmd_set_vf_rxmode_set,
7858 : : (void *)&cmd_set_vf_rxmode_port,
7859 : : (void *)&cmd_set_vf_rxmode_portid,
7860 : : (void *)&cmd_set_vf_rxmode_vf,
7861 : : (void *)&cmd_set_vf_rxmode_vfid,
7862 : : (void *)&cmd_set_vf_rxmode_what,
7863 : : (void *)&cmd_set_vf_rxmode_mode,
7864 : : (void *)&cmd_set_vf_rxmode_on,
7865 : : NULL,
7866 : : },
7867 : : };
7868 : :
7869 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7870 : : struct cmd_vf_mac_addr_result {
7871 : : cmdline_fixed_string_t mac_addr_cmd;
7872 : : cmdline_fixed_string_t what;
7873 : : cmdline_fixed_string_t port;
7874 : : uint16_t port_num;
7875 : : cmdline_fixed_string_t vf;
7876 : : uint8_t vf_num;
7877 : : struct rte_ether_addr address;
7878 : : };
7879 : :
7880 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
7881 : : __rte_unused struct cmdline *cl,
7882 : : __rte_unused void *data)
7883 : : {
7884 : : struct cmd_vf_mac_addr_result *res = parsed_result;
7885 : : int ret = -ENOTSUP;
7886 : :
7887 : 0 : if (strcmp(res->what, "add") != 0)
7888 : : return;
7889 : :
7890 : : #ifdef RTE_NET_I40E
7891 : : if (ret == -ENOTSUP)
7892 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7893 : : &res->address);
7894 : : #endif
7895 : : #ifdef RTE_NET_BNXT
7896 : 0 : if (ret == -ENOTSUP)
7897 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7898 : 0 : res->vf_num);
7899 : : #endif
7900 : :
7901 : 0 : if(ret < 0)
7902 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7903 : :
7904 : : }
7905 : :
7906 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7907 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7908 : : mac_addr_cmd,"mac_addr");
7909 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7910 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7911 : : what,"add");
7912 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7913 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7914 : : port,"port");
7915 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7916 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7917 : : port_num, RTE_UINT16);
7918 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
7919 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7920 : : vf,"vf");
7921 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
7922 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7923 : : vf_num, RTE_UINT8);
7924 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
7925 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
7926 : : address);
7927 : :
7928 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
7929 : : .f = cmd_vf_mac_addr_parsed,
7930 : : .data = (void *)0,
7931 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
7932 : : "Add MAC address filtering for a VF on port_id",
7933 : : .tokens = {
7934 : : (void *)&cmd_vf_mac_addr_cmd,
7935 : : (void *)&cmd_vf_mac_addr_what,
7936 : : (void *)&cmd_vf_mac_addr_port,
7937 : : (void *)&cmd_vf_mac_addr_portnum,
7938 : : (void *)&cmd_vf_mac_addr_vf,
7939 : : (void *)&cmd_vf_mac_addr_vfnum,
7940 : : (void *)&cmd_vf_mac_addr_addr,
7941 : : NULL,
7942 : : },
7943 : : };
7944 : :
7945 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
7946 : : struct cmd_vf_rx_vlan_filter {
7947 : : cmdline_fixed_string_t rx_vlan;
7948 : : cmdline_fixed_string_t what;
7949 : : uint16_t vlan_id;
7950 : : cmdline_fixed_string_t port;
7951 : : portid_t port_id;
7952 : : cmdline_fixed_string_t vf;
7953 : : uint64_t vf_mask;
7954 : : };
7955 : :
7956 : : static void
7957 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
7958 : : __rte_unused struct cmdline *cl,
7959 : : __rte_unused void *data)
7960 : : {
7961 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
7962 : : int ret = -ENOTSUP;
7963 : :
7964 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
7965 : :
7966 : : #ifdef RTE_NET_IXGBE
7967 : : if (ret == -ENOTSUP)
7968 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
7969 : 0 : res->vlan_id, res->vf_mask, is_add);
7970 : : #endif
7971 : : #ifdef RTE_NET_I40E
7972 : 0 : if (ret == -ENOTSUP)
7973 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
7974 : 0 : res->vlan_id, res->vf_mask, is_add);
7975 : : #endif
7976 : : #ifdef RTE_NET_BNXT
7977 : 0 : if (ret == -ENOTSUP)
7978 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
7979 : 0 : res->vlan_id, res->vf_mask, is_add);
7980 : : #endif
7981 : :
7982 : 0 : switch (ret) {
7983 : : case 0:
7984 : : break;
7985 : 0 : case -EINVAL:
7986 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
7987 : 0 : res->vlan_id, res->vf_mask);
7988 : : break;
7989 : 0 : case -ENODEV:
7990 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
7991 : : break;
7992 : 0 : case -ENOTSUP:
7993 : 0 : fprintf(stderr, "function not implemented or supported\n");
7994 : : break;
7995 : 0 : default:
7996 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
7997 : : }
7998 : 0 : }
7999 : :
8000 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8001 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8002 : : rx_vlan, "rx_vlan");
8003 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8004 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8005 : : what, "add#rm");
8006 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8007 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8008 : : vlan_id, RTE_UINT16);
8009 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8010 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8011 : : port, "port");
8012 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8013 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8014 : : port_id, RTE_UINT16);
8015 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8016 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8017 : : vf, "vf");
8018 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8019 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8020 : : vf_mask, RTE_UINT64);
8021 : :
8022 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8023 : : .f = cmd_vf_rx_vlan_filter_parsed,
8024 : : .data = NULL,
8025 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8026 : : "(vf_mask = hexadecimal VF mask)",
8027 : : .tokens = {
8028 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8029 : : (void *)&cmd_vf_rx_vlan_filter_what,
8030 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8031 : : (void *)&cmd_vf_rx_vlan_filter_port,
8032 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8033 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8034 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8035 : : NULL,
8036 : : },
8037 : : };
8038 : :
8039 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8040 : : struct cmd_queue_rate_limit_result {
8041 : : cmdline_fixed_string_t set;
8042 : : cmdline_fixed_string_t port;
8043 : : uint16_t port_num;
8044 : : cmdline_fixed_string_t queue;
8045 : : uint8_t queue_num;
8046 : : cmdline_fixed_string_t rate;
8047 : : uint32_t rate_num;
8048 : : };
8049 : :
8050 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8051 : : __rte_unused struct cmdline *cl,
8052 : : __rte_unused void *data)
8053 : : {
8054 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8055 : : int ret = 0;
8056 : :
8057 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8058 : 0 : && (strcmp(res->queue, "queue") == 0)
8059 : 0 : && (strcmp(res->rate, "rate") == 0))
8060 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8061 : : res->rate_num);
8062 : 0 : if (ret < 0)
8063 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8064 : : strerror(-ret));
8065 : :
8066 : 0 : }
8067 : :
8068 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8069 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8070 : : set, "set");
8071 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8072 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8073 : : port, "port");
8074 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8075 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8076 : : port_num, RTE_UINT16);
8077 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8078 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8079 : : queue, "queue");
8080 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8081 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8082 : : queue_num, RTE_UINT8);
8083 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8084 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8085 : : rate, "rate");
8086 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8087 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8088 : : rate_num, RTE_UINT32);
8089 : :
8090 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8091 : : .f = cmd_queue_rate_limit_parsed,
8092 : : .data = (void *)0,
8093 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8094 : : "Set rate limit for a queue on port_id",
8095 : : .tokens = {
8096 : : (void *)&cmd_queue_rate_limit_set,
8097 : : (void *)&cmd_queue_rate_limit_port,
8098 : : (void *)&cmd_queue_rate_limit_portnum,
8099 : : (void *)&cmd_queue_rate_limit_queue,
8100 : : (void *)&cmd_queue_rate_limit_queuenum,
8101 : : (void *)&cmd_queue_rate_limit_rate,
8102 : : (void *)&cmd_queue_rate_limit_ratenum,
8103 : : NULL,
8104 : : },
8105 : : };
8106 : :
8107 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8108 : : struct cmd_vf_rate_limit_result {
8109 : : cmdline_fixed_string_t set;
8110 : : cmdline_fixed_string_t port;
8111 : : uint16_t port_num;
8112 : : cmdline_fixed_string_t vf;
8113 : : uint8_t vf_num;
8114 : : cmdline_fixed_string_t rate;
8115 : : uint32_t rate_num;
8116 : : cmdline_fixed_string_t q_msk;
8117 : : uint64_t q_msk_val;
8118 : : };
8119 : :
8120 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8121 : : __rte_unused struct cmdline *cl,
8122 : : __rte_unused void *data)
8123 : : {
8124 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8125 : : int ret = 0;
8126 : :
8127 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8128 : 0 : && (strcmp(res->vf, "vf") == 0)
8129 : 0 : && (strcmp(res->rate, "rate") == 0)
8130 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8131 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8132 : : res->rate_num, res->q_msk_val);
8133 : 0 : if (ret < 0)
8134 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8135 : : strerror(-ret));
8136 : :
8137 : 0 : }
8138 : :
8139 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8140 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8141 : : set, "set");
8142 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8143 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8144 : : port, "port");
8145 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8146 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8147 : : port_num, RTE_UINT16);
8148 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8149 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8150 : : vf, "vf");
8151 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8152 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8153 : : vf_num, RTE_UINT8);
8154 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8155 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8156 : : rate, "rate");
8157 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8158 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8159 : : rate_num, RTE_UINT32);
8160 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8161 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8162 : : q_msk, "queue_mask");
8163 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8164 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8165 : : q_msk_val, RTE_UINT64);
8166 : :
8167 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8168 : : .f = cmd_vf_rate_limit_parsed,
8169 : : .data = (void *)0,
8170 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8171 : : "queue_mask <queue_mask_value>: "
8172 : : "Set rate limit for queues of VF on port_id",
8173 : : .tokens = {
8174 : : (void *)&cmd_vf_rate_limit_set,
8175 : : (void *)&cmd_vf_rate_limit_port,
8176 : : (void *)&cmd_vf_rate_limit_portnum,
8177 : : (void *)&cmd_vf_rate_limit_vf,
8178 : : (void *)&cmd_vf_rate_limit_vfnum,
8179 : : (void *)&cmd_vf_rate_limit_rate,
8180 : : (void *)&cmd_vf_rate_limit_ratenum,
8181 : : (void *)&cmd_vf_rate_limit_q_msk,
8182 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8183 : : NULL,
8184 : : },
8185 : : };
8186 : :
8187 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8188 : : struct cmd_tunnel_udp_config {
8189 : : cmdline_fixed_string_t rx_vxlan_port;
8190 : : cmdline_fixed_string_t what;
8191 : : uint16_t udp_port;
8192 : : portid_t port_id;
8193 : : };
8194 : :
8195 : : static void
8196 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8197 : : __rte_unused struct cmdline *cl,
8198 : : __rte_unused void *data)
8199 : : {
8200 : : struct cmd_tunnel_udp_config *res = parsed_result;
8201 : : struct rte_eth_udp_tunnel tunnel_udp;
8202 : : int ret;
8203 : :
8204 : 0 : tunnel_udp.udp_port = res->udp_port;
8205 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8206 : :
8207 : 0 : if (!strcmp(res->what, "add"))
8208 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8209 : : &tunnel_udp);
8210 : : else
8211 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8212 : : &tunnel_udp);
8213 : :
8214 : 0 : if (ret < 0)
8215 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8216 : : strerror(-ret));
8217 : 0 : }
8218 : :
8219 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8220 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8221 : : rx_vxlan_port, "rx_vxlan_port");
8222 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8223 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8224 : : what, "add#rm");
8225 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8226 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8227 : : udp_port, RTE_UINT16);
8228 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8229 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8230 : : port_id, RTE_UINT16);
8231 : :
8232 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8233 : : .f = cmd_tunnel_udp_config_parsed,
8234 : : .data = (void *)0,
8235 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8236 : : "Add/Remove a tunneling UDP port filter",
8237 : : .tokens = {
8238 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8239 : : (void *)&cmd_tunnel_udp_config_what,
8240 : : (void *)&cmd_tunnel_udp_config_udp_port,
8241 : : (void *)&cmd_tunnel_udp_config_port_id,
8242 : : NULL,
8243 : : },
8244 : : };
8245 : :
8246 : : struct cmd_config_tunnel_udp_port {
8247 : : cmdline_fixed_string_t port;
8248 : : cmdline_fixed_string_t config;
8249 : : portid_t port_id;
8250 : : cmdline_fixed_string_t udp_tunnel_port;
8251 : : cmdline_fixed_string_t action;
8252 : : cmdline_fixed_string_t tunnel_type;
8253 : : uint16_t udp_port;
8254 : : };
8255 : :
8256 : : static void
8257 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8258 : : __rte_unused struct cmdline *cl,
8259 : : __rte_unused void *data)
8260 : : {
8261 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
8262 : : struct rte_eth_udp_tunnel tunnel_udp;
8263 : : int ret = 0;
8264 : :
8265 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8266 : 0 : return;
8267 : :
8268 : 0 : tunnel_udp.udp_port = res->udp_port;
8269 : :
8270 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
8271 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8272 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
8273 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8274 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8275 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8276 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
8277 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8278 : : } else {
8279 : 0 : fprintf(stderr, "Invalid tunnel type\n");
8280 : 0 : return;
8281 : : }
8282 : :
8283 : 0 : if (!strcmp(res->action, "add"))
8284 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8285 : : &tunnel_udp);
8286 : : else
8287 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8288 : : &tunnel_udp);
8289 : :
8290 : 0 : if (ret < 0)
8291 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
8292 : : strerror(-ret));
8293 : : }
8294 : :
8295 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8296 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8297 : : "port");
8298 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8299 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8300 : : "config");
8301 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8302 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8303 : : RTE_UINT16);
8304 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8305 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8306 : : udp_tunnel_port,
8307 : : "udp_tunnel_port");
8308 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8309 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8310 : : "add#rm");
8311 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8312 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8313 : : "vxlan#geneve#vxlan-gpe#ecpri");
8314 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8315 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8316 : : RTE_UINT16);
8317 : :
8318 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8319 : : .f = cmd_cfg_tunnel_udp_port_parsed,
8320 : : .data = NULL,
8321 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
8322 : : "geneve|vxlan-gpe|ecpri <udp_port>",
8323 : : .tokens = {
8324 : : (void *)&cmd_config_tunnel_udp_port_port,
8325 : : (void *)&cmd_config_tunnel_udp_port_config,
8326 : : (void *)&cmd_config_tunnel_udp_port_port_id,
8327 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8328 : : (void *)&cmd_config_tunnel_udp_port_action,
8329 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8330 : : (void *)&cmd_config_tunnel_udp_port_value,
8331 : : NULL,
8332 : : },
8333 : : };
8334 : :
8335 : : /* ******************************************************************************** */
8336 : :
8337 : : struct cmd_dump_result {
8338 : : cmdline_fixed_string_t dump;
8339 : : };
8340 : :
8341 : : static void
8342 : 0 : dump_struct_sizes(void)
8343 : : {
8344 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8345 : : DUMP_SIZE(struct rte_mbuf);
8346 : : DUMP_SIZE(struct rte_mempool);
8347 : : DUMP_SIZE(struct rte_ring);
8348 : : #undef DUMP_SIZE
8349 : 0 : }
8350 : :
8351 : :
8352 : : /* Dump the socket memory statistics on console */
8353 : : static void
8354 : 0 : dump_socket_mem(FILE *f)
8355 : : {
8356 : : struct rte_malloc_socket_stats socket_stats;
8357 : : unsigned int i;
8358 : : size_t total = 0;
8359 : : size_t alloc = 0;
8360 : : size_t free = 0;
8361 : : unsigned int n_alloc = 0;
8362 : : unsigned int n_free = 0;
8363 : : static size_t last_allocs;
8364 : : static size_t last_total;
8365 : :
8366 : :
8367 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
8368 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
8369 : 0 : !socket_stats.heap_totalsz_bytes)
8370 : 0 : continue;
8371 : 0 : total += socket_stats.heap_totalsz_bytes;
8372 : 0 : alloc += socket_stats.heap_allocsz_bytes;
8373 : 0 : free += socket_stats.heap_freesz_bytes;
8374 : 0 : n_alloc += socket_stats.alloc_count;
8375 : 0 : n_free += socket_stats.free_count;
8376 : 0 : fprintf(f,
8377 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8378 : : i,
8379 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
8380 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
8381 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
8382 : 0 : (double)socket_stats.heap_totalsz_bytes,
8383 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
8384 : : socket_stats.alloc_count,
8385 : : socket_stats.free_count);
8386 : : }
8387 : 0 : fprintf(f,
8388 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8389 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
8390 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
8391 : 0 : (double)free / (1024 * 1024),
8392 : : n_alloc, n_free);
8393 : 0 : if (last_allocs)
8394 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
8395 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
8396 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
8397 : 0 : last_allocs = alloc;
8398 : 0 : last_total = total;
8399 : 0 : }
8400 : :
8401 : 0 : static void cmd_dump_parsed(void *parsed_result,
8402 : : __rte_unused struct cmdline *cl,
8403 : : __rte_unused void *data)
8404 : : {
8405 : : struct cmd_dump_result *res = parsed_result;
8406 : :
8407 : 0 : if (!strcmp(res->dump, "dump_physmem"))
8408 : 0 : rte_dump_physmem_layout(stdout);
8409 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
8410 : 0 : dump_socket_mem(stdout);
8411 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
8412 : 0 : rte_memzone_dump(stdout);
8413 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
8414 : 0 : dump_struct_sizes();
8415 : 0 : else if (!strcmp(res->dump, "dump_ring"))
8416 : 0 : rte_ring_list_dump(stdout);
8417 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
8418 : 0 : rte_mempool_list_dump(stdout);
8419 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
8420 : 0 : rte_devargs_dump(stdout);
8421 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
8422 : 0 : rte_lcore_dump(stdout);
8423 : : #ifndef RTE_EXEC_ENV_WINDOWS
8424 : 0 : else if (!strcmp(res->dump, "dump_trace"))
8425 : 0 : rte_trace_save();
8426 : : #endif
8427 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
8428 : 0 : rte_log_dump(stdout);
8429 : 0 : }
8430 : :
8431 : : static cmdline_parse_token_string_t cmd_dump_dump =
8432 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8433 : : "dump_physmem#"
8434 : : "dump_memzone#"
8435 : : "dump_socket_mem#"
8436 : : "dump_struct_sizes#"
8437 : : "dump_ring#"
8438 : : "dump_mempool#"
8439 : : "dump_devargs#"
8440 : : "dump_lcores#"
8441 : : #ifndef RTE_EXEC_ENV_WINDOWS
8442 : : "dump_trace#"
8443 : : #endif
8444 : : "dump_log_types");
8445 : :
8446 : : static cmdline_parse_inst_t cmd_dump = {
8447 : : .f = cmd_dump_parsed, /* function to call */
8448 : : .data = NULL, /* 2nd arg of func */
8449 : : .help_str = "Dump status",
8450 : : .tokens = { /* token list, NULL terminated */
8451 : : (void *)&cmd_dump_dump,
8452 : : NULL,
8453 : : },
8454 : : };
8455 : :
8456 : : /* ******************************************************************************** */
8457 : :
8458 : : struct cmd_dump_one_result {
8459 : : cmdline_fixed_string_t dump;
8460 : : cmdline_fixed_string_t name;
8461 : : };
8462 : :
8463 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8464 : : __rte_unused void *data)
8465 : : {
8466 : : struct cmd_dump_one_result *res = parsed_result;
8467 : :
8468 : 0 : if (!strcmp(res->dump, "dump_ring")) {
8469 : : struct rte_ring *r;
8470 : 0 : r = rte_ring_lookup(res->name);
8471 : 0 : if (r == NULL) {
8472 : 0 : cmdline_printf(cl, "Cannot find ring\n");
8473 : 0 : return;
8474 : : }
8475 : 0 : rte_ring_dump(stdout, r);
8476 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
8477 : : struct rte_mempool *mp;
8478 : 0 : mp = rte_mempool_lookup(res->name);
8479 : 0 : if (mp == NULL) {
8480 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
8481 : 0 : return;
8482 : : }
8483 : 0 : rte_mempool_dump(stdout, mp);
8484 : : }
8485 : : }
8486 : :
8487 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
8488 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8489 : : "dump_ring#dump_mempool");
8490 : :
8491 : : static cmdline_parse_token_string_t cmd_dump_one_name =
8492 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8493 : :
8494 : : static cmdline_parse_inst_t cmd_dump_one = {
8495 : : .f = cmd_dump_one_parsed, /* function to call */
8496 : : .data = NULL, /* 2nd arg of func */
8497 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8498 : : .tokens = { /* token list, NULL terminated */
8499 : : (void *)&cmd_dump_one_dump,
8500 : : (void *)&cmd_dump_one_name,
8501 : : NULL,
8502 : : },
8503 : : };
8504 : :
8505 : : /* *** Filters Control *** */
8506 : :
8507 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8508 : : do { \
8509 : : if ((ip_addr).family == AF_INET) \
8510 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
8511 : : else { \
8512 : : fprintf(stderr, "invalid parameter.\n"); \
8513 : : return; \
8514 : : } \
8515 : : } while (0)
8516 : :
8517 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8518 : : do { \
8519 : : if ((ip_addr).family == AF_INET6) \
8520 : : rte_memcpy(&(ip), \
8521 : : &((ip_addr).addr.ipv6), \
8522 : : sizeof(struct in6_addr)); \
8523 : : else { \
8524 : : fprintf(stderr, "invalid parameter.\n"); \
8525 : : return; \
8526 : : } \
8527 : : } while (0)
8528 : :
8529 : : /* Generic flow interface command. */
8530 : : extern cmdline_parse_inst_t cmd_flow;
8531 : :
8532 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8533 : : struct cmd_mcast_addr_result {
8534 : : cmdline_fixed_string_t mcast_addr_cmd;
8535 : : cmdline_fixed_string_t what;
8536 : : uint16_t port_num;
8537 : : struct rte_ether_addr mc_addr;
8538 : : };
8539 : :
8540 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
8541 : : __rte_unused struct cmdline *cl,
8542 : : __rte_unused void *data)
8543 : : {
8544 : : struct cmd_mcast_addr_result *res = parsed_result;
8545 : :
8546 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
8547 : 0 : fprintf(stderr,
8548 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
8549 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
8550 : 0 : return;
8551 : : }
8552 : 0 : if (strcmp(res->what, "add") == 0)
8553 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
8554 : : else
8555 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
8556 : : }
8557 : :
8558 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8559 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8560 : : mcast_addr_cmd, "mcast_addr");
8561 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
8562 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8563 : : "add#remove");
8564 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8565 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8566 : : RTE_UINT16);
8567 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8568 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8569 : :
8570 : : static cmdline_parse_inst_t cmd_mcast_addr = {
8571 : : .f = cmd_mcast_addr_parsed,
8572 : : .data = (void *)0,
8573 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
8574 : : "Add/Remove multicast MAC address on port_id",
8575 : : .tokens = {
8576 : : (void *)&cmd_mcast_addr_cmd,
8577 : : (void *)&cmd_mcast_addr_what,
8578 : : (void *)&cmd_mcast_addr_portnum,
8579 : : (void *)&cmd_mcast_addr_addr,
8580 : : NULL,
8581 : : },
8582 : : };
8583 : :
8584 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
8585 : : struct cmd_mcast_addr_flush_result {
8586 : : cmdline_fixed_string_t mcast_addr_cmd;
8587 : : cmdline_fixed_string_t what;
8588 : : uint16_t port_num;
8589 : : };
8590 : :
8591 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
8592 : : __rte_unused struct cmdline *cl,
8593 : : __rte_unused void *data)
8594 : : {
8595 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
8596 : :
8597 : 0 : mcast_addr_flush(res->port_num);
8598 : 0 : }
8599 : :
8600 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
8601 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8602 : : mcast_addr_cmd, "mcast_addr");
8603 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
8604 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8605 : : "flush");
8606 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
8607 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8608 : : RTE_UINT16);
8609 : :
8610 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
8611 : : .f = cmd_mcast_addr_flush_parsed,
8612 : : .data = (void *)0,
8613 : : .help_str = "mcast_addr flush <port_id> : "
8614 : : "flush all multicast MAC addresses on port_id",
8615 : : .tokens = {
8616 : : (void *)&cmd_mcast_addr_flush_cmd,
8617 : : (void *)&cmd_mcast_addr_flush_what,
8618 : : (void *)&cmd_mcast_addr_flush_portnum,
8619 : : NULL,
8620 : : },
8621 : : };
8622 : :
8623 : : /* vf vlan anti spoof configuration */
8624 : :
8625 : : /* Common result structure for vf vlan anti spoof */
8626 : : struct cmd_vf_vlan_anti_spoof_result {
8627 : : cmdline_fixed_string_t set;
8628 : : cmdline_fixed_string_t vf;
8629 : : cmdline_fixed_string_t vlan;
8630 : : cmdline_fixed_string_t antispoof;
8631 : : portid_t port_id;
8632 : : uint32_t vf_id;
8633 : : cmdline_fixed_string_t on_off;
8634 : : };
8635 : :
8636 : : /* Common CLI fields for vf vlan anti spoof enable disable */
8637 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
8638 : : TOKEN_STRING_INITIALIZER
8639 : : (struct cmd_vf_vlan_anti_spoof_result,
8640 : : set, "set");
8641 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
8642 : : TOKEN_STRING_INITIALIZER
8643 : : (struct cmd_vf_vlan_anti_spoof_result,
8644 : : vf, "vf");
8645 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
8646 : : TOKEN_STRING_INITIALIZER
8647 : : (struct cmd_vf_vlan_anti_spoof_result,
8648 : : vlan, "vlan");
8649 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
8650 : : TOKEN_STRING_INITIALIZER
8651 : : (struct cmd_vf_vlan_anti_spoof_result,
8652 : : antispoof, "antispoof");
8653 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
8654 : : TOKEN_NUM_INITIALIZER
8655 : : (struct cmd_vf_vlan_anti_spoof_result,
8656 : : port_id, RTE_UINT16);
8657 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
8658 : : TOKEN_NUM_INITIALIZER
8659 : : (struct cmd_vf_vlan_anti_spoof_result,
8660 : : vf_id, RTE_UINT32);
8661 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
8662 : : TOKEN_STRING_INITIALIZER
8663 : : (struct cmd_vf_vlan_anti_spoof_result,
8664 : : on_off, "on#off");
8665 : :
8666 : : static void
8667 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
8668 : : void *parsed_result,
8669 : : __rte_unused struct cmdline *cl,
8670 : : __rte_unused void *data)
8671 : : {
8672 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
8673 : : int ret = -ENOTSUP;
8674 : :
8675 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8676 : :
8677 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8678 : : return;
8679 : :
8680 : : #ifdef RTE_NET_IXGBE
8681 : : if (ret == -ENOTSUP)
8682 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
8683 : 0 : res->vf_id, is_on);
8684 : : #endif
8685 : : #ifdef RTE_NET_I40E
8686 : 0 : if (ret == -ENOTSUP)
8687 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
8688 : 0 : res->vf_id, is_on);
8689 : : #endif
8690 : : #ifdef RTE_NET_BNXT
8691 : 0 : if (ret == -ENOTSUP)
8692 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
8693 : 0 : res->vf_id, is_on);
8694 : : #endif
8695 : :
8696 : 0 : switch (ret) {
8697 : : case 0:
8698 : : break;
8699 : 0 : case -EINVAL:
8700 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
8701 : : break;
8702 : 0 : case -ENODEV:
8703 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8704 : : break;
8705 : 0 : case -ENOTSUP:
8706 : 0 : fprintf(stderr, "function not implemented\n");
8707 : : break;
8708 : 0 : default:
8709 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8710 : : }
8711 : : }
8712 : :
8713 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
8714 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
8715 : : .data = NULL,
8716 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
8717 : : .tokens = {
8718 : : (void *)&cmd_vf_vlan_anti_spoof_set,
8719 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
8720 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
8721 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
8722 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
8723 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
8724 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
8725 : : NULL,
8726 : : },
8727 : : };
8728 : :
8729 : : /* vf mac anti spoof configuration */
8730 : :
8731 : : /* Common result structure for vf mac anti spoof */
8732 : : struct cmd_vf_mac_anti_spoof_result {
8733 : : cmdline_fixed_string_t set;
8734 : : cmdline_fixed_string_t vf;
8735 : : cmdline_fixed_string_t mac;
8736 : : cmdline_fixed_string_t antispoof;
8737 : : portid_t port_id;
8738 : : uint32_t vf_id;
8739 : : cmdline_fixed_string_t on_off;
8740 : : };
8741 : :
8742 : : /* Common CLI fields for vf mac anti spoof enable disable */
8743 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
8744 : : TOKEN_STRING_INITIALIZER
8745 : : (struct cmd_vf_mac_anti_spoof_result,
8746 : : set, "set");
8747 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
8748 : : TOKEN_STRING_INITIALIZER
8749 : : (struct cmd_vf_mac_anti_spoof_result,
8750 : : vf, "vf");
8751 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
8752 : : TOKEN_STRING_INITIALIZER
8753 : : (struct cmd_vf_mac_anti_spoof_result,
8754 : : mac, "mac");
8755 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
8756 : : TOKEN_STRING_INITIALIZER
8757 : : (struct cmd_vf_mac_anti_spoof_result,
8758 : : antispoof, "antispoof");
8759 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
8760 : : TOKEN_NUM_INITIALIZER
8761 : : (struct cmd_vf_mac_anti_spoof_result,
8762 : : port_id, RTE_UINT16);
8763 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
8764 : : TOKEN_NUM_INITIALIZER
8765 : : (struct cmd_vf_mac_anti_spoof_result,
8766 : : vf_id, RTE_UINT32);
8767 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
8768 : : TOKEN_STRING_INITIALIZER
8769 : : (struct cmd_vf_mac_anti_spoof_result,
8770 : : on_off, "on#off");
8771 : :
8772 : : static void
8773 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
8774 : : void *parsed_result,
8775 : : __rte_unused struct cmdline *cl,
8776 : : __rte_unused void *data)
8777 : : {
8778 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
8779 : : int ret = -ENOTSUP;
8780 : :
8781 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8782 : :
8783 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8784 : : return;
8785 : :
8786 : : #ifdef RTE_NET_IXGBE
8787 : : if (ret == -ENOTSUP)
8788 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
8789 : 0 : res->vf_id, is_on);
8790 : : #endif
8791 : : #ifdef RTE_NET_I40E
8792 : 0 : if (ret == -ENOTSUP)
8793 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
8794 : 0 : res->vf_id, is_on);
8795 : : #endif
8796 : : #ifdef RTE_NET_BNXT
8797 : 0 : if (ret == -ENOTSUP)
8798 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
8799 : 0 : res->vf_id, is_on);
8800 : : #endif
8801 : :
8802 : 0 : switch (ret) {
8803 : : case 0:
8804 : : break;
8805 : 0 : case -EINVAL:
8806 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8807 : : res->vf_id, is_on);
8808 : : break;
8809 : 0 : case -ENODEV:
8810 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8811 : : break;
8812 : 0 : case -ENOTSUP:
8813 : 0 : fprintf(stderr, "function not implemented\n");
8814 : : break;
8815 : 0 : default:
8816 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8817 : : }
8818 : : }
8819 : :
8820 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
8821 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
8822 : : .data = NULL,
8823 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
8824 : : .tokens = {
8825 : : (void *)&cmd_vf_mac_anti_spoof_set,
8826 : : (void *)&cmd_vf_mac_anti_spoof_vf,
8827 : : (void *)&cmd_vf_mac_anti_spoof_mac,
8828 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
8829 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
8830 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
8831 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
8832 : : NULL,
8833 : : },
8834 : : };
8835 : :
8836 : : /* vf vlan strip queue configuration */
8837 : :
8838 : : /* Common result structure for vf mac anti spoof */
8839 : : struct cmd_vf_vlan_stripq_result {
8840 : : cmdline_fixed_string_t set;
8841 : : cmdline_fixed_string_t vf;
8842 : : cmdline_fixed_string_t vlan;
8843 : : cmdline_fixed_string_t stripq;
8844 : : portid_t port_id;
8845 : : uint16_t vf_id;
8846 : : cmdline_fixed_string_t on_off;
8847 : : };
8848 : :
8849 : : /* Common CLI fields for vf vlan strip enable disable */
8850 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
8851 : : TOKEN_STRING_INITIALIZER
8852 : : (struct cmd_vf_vlan_stripq_result,
8853 : : set, "set");
8854 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
8855 : : TOKEN_STRING_INITIALIZER
8856 : : (struct cmd_vf_vlan_stripq_result,
8857 : : vf, "vf");
8858 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
8859 : : TOKEN_STRING_INITIALIZER
8860 : : (struct cmd_vf_vlan_stripq_result,
8861 : : vlan, "vlan");
8862 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
8863 : : TOKEN_STRING_INITIALIZER
8864 : : (struct cmd_vf_vlan_stripq_result,
8865 : : stripq, "stripq");
8866 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
8867 : : TOKEN_NUM_INITIALIZER
8868 : : (struct cmd_vf_vlan_stripq_result,
8869 : : port_id, RTE_UINT16);
8870 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
8871 : : TOKEN_NUM_INITIALIZER
8872 : : (struct cmd_vf_vlan_stripq_result,
8873 : : vf_id, RTE_UINT16);
8874 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
8875 : : TOKEN_STRING_INITIALIZER
8876 : : (struct cmd_vf_vlan_stripq_result,
8877 : : on_off, "on#off");
8878 : :
8879 : : static void
8880 : 0 : cmd_set_vf_vlan_stripq_parsed(
8881 : : void *parsed_result,
8882 : : __rte_unused struct cmdline *cl,
8883 : : __rte_unused void *data)
8884 : : {
8885 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
8886 : : int ret = -ENOTSUP;
8887 : :
8888 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8889 : :
8890 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8891 : : return;
8892 : :
8893 : : #ifdef RTE_NET_IXGBE
8894 : : if (ret == -ENOTSUP)
8895 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
8896 : 0 : res->vf_id, is_on);
8897 : : #endif
8898 : : #ifdef RTE_NET_I40E
8899 : 0 : if (ret == -ENOTSUP)
8900 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
8901 : 0 : res->vf_id, is_on);
8902 : : #endif
8903 : : #ifdef RTE_NET_BNXT
8904 : 0 : if (ret == -ENOTSUP)
8905 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
8906 : 0 : res->vf_id, is_on);
8907 : : #endif
8908 : :
8909 : 0 : switch (ret) {
8910 : : case 0:
8911 : : break;
8912 : 0 : case -EINVAL:
8913 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8914 : 0 : res->vf_id, is_on);
8915 : : break;
8916 : 0 : case -ENODEV:
8917 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8918 : : break;
8919 : 0 : case -ENOTSUP:
8920 : 0 : fprintf(stderr, "function not implemented\n");
8921 : : break;
8922 : 0 : default:
8923 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8924 : : }
8925 : : }
8926 : :
8927 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
8928 : : .f = cmd_set_vf_vlan_stripq_parsed,
8929 : : .data = NULL,
8930 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
8931 : : .tokens = {
8932 : : (void *)&cmd_vf_vlan_stripq_set,
8933 : : (void *)&cmd_vf_vlan_stripq_vf,
8934 : : (void *)&cmd_vf_vlan_stripq_vlan,
8935 : : (void *)&cmd_vf_vlan_stripq_stripq,
8936 : : (void *)&cmd_vf_vlan_stripq_port_id,
8937 : : (void *)&cmd_vf_vlan_stripq_vf_id,
8938 : : (void *)&cmd_vf_vlan_stripq_on_off,
8939 : : NULL,
8940 : : },
8941 : : };
8942 : :
8943 : : /* vf vlan insert configuration */
8944 : :
8945 : : /* Common result structure for vf vlan insert */
8946 : : struct cmd_vf_vlan_insert_result {
8947 : : cmdline_fixed_string_t set;
8948 : : cmdline_fixed_string_t vf;
8949 : : cmdline_fixed_string_t vlan;
8950 : : cmdline_fixed_string_t insert;
8951 : : portid_t port_id;
8952 : : uint16_t vf_id;
8953 : : uint16_t vlan_id;
8954 : : };
8955 : :
8956 : : /* Common CLI fields for vf vlan insert enable disable */
8957 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
8958 : : TOKEN_STRING_INITIALIZER
8959 : : (struct cmd_vf_vlan_insert_result,
8960 : : set, "set");
8961 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
8962 : : TOKEN_STRING_INITIALIZER
8963 : : (struct cmd_vf_vlan_insert_result,
8964 : : vf, "vf");
8965 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
8966 : : TOKEN_STRING_INITIALIZER
8967 : : (struct cmd_vf_vlan_insert_result,
8968 : : vlan, "vlan");
8969 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
8970 : : TOKEN_STRING_INITIALIZER
8971 : : (struct cmd_vf_vlan_insert_result,
8972 : : insert, "insert");
8973 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
8974 : : TOKEN_NUM_INITIALIZER
8975 : : (struct cmd_vf_vlan_insert_result,
8976 : : port_id, RTE_UINT16);
8977 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
8978 : : TOKEN_NUM_INITIALIZER
8979 : : (struct cmd_vf_vlan_insert_result,
8980 : : vf_id, RTE_UINT16);
8981 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
8982 : : TOKEN_NUM_INITIALIZER
8983 : : (struct cmd_vf_vlan_insert_result,
8984 : : vlan_id, RTE_UINT16);
8985 : :
8986 : : static void
8987 : 0 : cmd_set_vf_vlan_insert_parsed(
8988 : : void *parsed_result,
8989 : : __rte_unused struct cmdline *cl,
8990 : : __rte_unused void *data)
8991 : : {
8992 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
8993 : : int ret = -ENOTSUP;
8994 : :
8995 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8996 : : return;
8997 : :
8998 : : #ifdef RTE_NET_IXGBE
8999 : : if (ret == -ENOTSUP)
9000 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9001 : 0 : res->vlan_id);
9002 : : #endif
9003 : : #ifdef RTE_NET_I40E
9004 : 0 : if (ret == -ENOTSUP)
9005 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9006 : 0 : res->vlan_id);
9007 : : #endif
9008 : : #ifdef RTE_NET_BNXT
9009 : 0 : if (ret == -ENOTSUP)
9010 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9011 : 0 : res->vlan_id);
9012 : : #endif
9013 : :
9014 : 0 : switch (ret) {
9015 : : case 0:
9016 : : break;
9017 : 0 : case -EINVAL:
9018 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9019 : 0 : res->vf_id, res->vlan_id);
9020 : : break;
9021 : 0 : case -ENODEV:
9022 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9023 : : break;
9024 : 0 : case -ENOTSUP:
9025 : 0 : fprintf(stderr, "function not implemented\n");
9026 : : break;
9027 : 0 : default:
9028 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9029 : : }
9030 : : }
9031 : :
9032 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9033 : : .f = cmd_set_vf_vlan_insert_parsed,
9034 : : .data = NULL,
9035 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9036 : : .tokens = {
9037 : : (void *)&cmd_vf_vlan_insert_set,
9038 : : (void *)&cmd_vf_vlan_insert_vf,
9039 : : (void *)&cmd_vf_vlan_insert_vlan,
9040 : : (void *)&cmd_vf_vlan_insert_insert,
9041 : : (void *)&cmd_vf_vlan_insert_port_id,
9042 : : (void *)&cmd_vf_vlan_insert_vf_id,
9043 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9044 : : NULL,
9045 : : },
9046 : : };
9047 : :
9048 : : /* tx loopback configuration */
9049 : :
9050 : : /* Common result structure for tx loopback */
9051 : : struct cmd_tx_loopback_result {
9052 : : cmdline_fixed_string_t set;
9053 : : cmdline_fixed_string_t tx;
9054 : : cmdline_fixed_string_t loopback;
9055 : : portid_t port_id;
9056 : : cmdline_fixed_string_t on_off;
9057 : : };
9058 : :
9059 : : /* Common CLI fields for tx loopback enable disable */
9060 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9061 : : TOKEN_STRING_INITIALIZER
9062 : : (struct cmd_tx_loopback_result,
9063 : : set, "set");
9064 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9065 : : TOKEN_STRING_INITIALIZER
9066 : : (struct cmd_tx_loopback_result,
9067 : : tx, "tx");
9068 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9069 : : TOKEN_STRING_INITIALIZER
9070 : : (struct cmd_tx_loopback_result,
9071 : : loopback, "loopback");
9072 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9073 : : TOKEN_NUM_INITIALIZER
9074 : : (struct cmd_tx_loopback_result,
9075 : : port_id, RTE_UINT16);
9076 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9077 : : TOKEN_STRING_INITIALIZER
9078 : : (struct cmd_tx_loopback_result,
9079 : : on_off, "on#off");
9080 : :
9081 : : static void
9082 : 0 : cmd_set_tx_loopback_parsed(
9083 : : void *parsed_result,
9084 : : __rte_unused struct cmdline *cl,
9085 : : __rte_unused void *data)
9086 : : {
9087 : : struct cmd_tx_loopback_result *res = parsed_result;
9088 : : int ret = -ENOTSUP;
9089 : :
9090 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9091 : :
9092 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9093 : : return;
9094 : :
9095 : : #ifdef RTE_NET_IXGBE
9096 : : if (ret == -ENOTSUP)
9097 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9098 : : #endif
9099 : : #ifdef RTE_NET_I40E
9100 : 0 : if (ret == -ENOTSUP)
9101 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9102 : : #endif
9103 : : #ifdef RTE_NET_BNXT
9104 : 0 : if (ret == -ENOTSUP)
9105 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9106 : : #endif
9107 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9108 : 0 : if (ret == -ENOTSUP)
9109 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9110 : : #endif
9111 : :
9112 : 0 : switch (ret) {
9113 : : case 0:
9114 : : break;
9115 : 0 : case -EINVAL:
9116 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9117 : : break;
9118 : 0 : case -ENODEV:
9119 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9120 : : break;
9121 : 0 : case -ENOTSUP:
9122 : 0 : fprintf(stderr, "function not implemented\n");
9123 : : break;
9124 : 0 : default:
9125 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9126 : : }
9127 : : }
9128 : :
9129 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9130 : : .f = cmd_set_tx_loopback_parsed,
9131 : : .data = NULL,
9132 : : .help_str = "set tx loopback <port_id> on|off",
9133 : : .tokens = {
9134 : : (void *)&cmd_tx_loopback_set,
9135 : : (void *)&cmd_tx_loopback_tx,
9136 : : (void *)&cmd_tx_loopback_loopback,
9137 : : (void *)&cmd_tx_loopback_port_id,
9138 : : (void *)&cmd_tx_loopback_on_off,
9139 : : NULL,
9140 : : },
9141 : : };
9142 : :
9143 : : /* all queues drop enable configuration */
9144 : :
9145 : : /* Common result structure for all queues drop enable */
9146 : : struct cmd_all_queues_drop_en_result {
9147 : : cmdline_fixed_string_t set;
9148 : : cmdline_fixed_string_t all;
9149 : : cmdline_fixed_string_t queues;
9150 : : cmdline_fixed_string_t drop;
9151 : : portid_t port_id;
9152 : : cmdline_fixed_string_t on_off;
9153 : : };
9154 : :
9155 : : /* Common CLI fields for tx loopback enable disable */
9156 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9157 : : TOKEN_STRING_INITIALIZER
9158 : : (struct cmd_all_queues_drop_en_result,
9159 : : set, "set");
9160 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9161 : : TOKEN_STRING_INITIALIZER
9162 : : (struct cmd_all_queues_drop_en_result,
9163 : : all, "all");
9164 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9165 : : TOKEN_STRING_INITIALIZER
9166 : : (struct cmd_all_queues_drop_en_result,
9167 : : queues, "queues");
9168 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9169 : : TOKEN_STRING_INITIALIZER
9170 : : (struct cmd_all_queues_drop_en_result,
9171 : : drop, "drop");
9172 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9173 : : TOKEN_NUM_INITIALIZER
9174 : : (struct cmd_all_queues_drop_en_result,
9175 : : port_id, RTE_UINT16);
9176 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9177 : : TOKEN_STRING_INITIALIZER
9178 : : (struct cmd_all_queues_drop_en_result,
9179 : : on_off, "on#off");
9180 : :
9181 : : static void
9182 : 0 : cmd_set_all_queues_drop_en_parsed(
9183 : : void *parsed_result,
9184 : : __rte_unused struct cmdline *cl,
9185 : : __rte_unused void *data)
9186 : : {
9187 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9188 : : int ret = -ENOTSUP;
9189 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9190 : :
9191 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9192 : : return;
9193 : :
9194 : : #ifdef RTE_NET_IXGBE
9195 : : if (ret == -ENOTSUP)
9196 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9197 : : #endif
9198 : : #ifdef RTE_NET_BNXT
9199 : 0 : if (ret == -ENOTSUP)
9200 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9201 : : #endif
9202 : 0 : switch (ret) {
9203 : : case 0:
9204 : : break;
9205 : 0 : case -EINVAL:
9206 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9207 : : break;
9208 : 0 : case -ENODEV:
9209 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9210 : : break;
9211 : 0 : case -ENOTSUP:
9212 : 0 : fprintf(stderr, "function not implemented\n");
9213 : : break;
9214 : 0 : default:
9215 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9216 : : }
9217 : : }
9218 : :
9219 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9220 : : .f = cmd_set_all_queues_drop_en_parsed,
9221 : : .data = NULL,
9222 : : .help_str = "set all queues drop <port_id> on|off",
9223 : : .tokens = {
9224 : : (void *)&cmd_all_queues_drop_en_set,
9225 : : (void *)&cmd_all_queues_drop_en_all,
9226 : : (void *)&cmd_all_queues_drop_en_queues,
9227 : : (void *)&cmd_all_queues_drop_en_drop,
9228 : : (void *)&cmd_all_queues_drop_en_port_id,
9229 : : (void *)&cmd_all_queues_drop_en_on_off,
9230 : : NULL,
9231 : : },
9232 : : };
9233 : :
9234 : : /* vf mac address configuration */
9235 : :
9236 : : /* Common result structure for vf mac address */
9237 : : struct cmd_set_vf_mac_addr_result {
9238 : : cmdline_fixed_string_t set;
9239 : : cmdline_fixed_string_t vf;
9240 : : cmdline_fixed_string_t mac;
9241 : : cmdline_fixed_string_t addr;
9242 : : portid_t port_id;
9243 : : uint16_t vf_id;
9244 : : struct rte_ether_addr mac_addr;
9245 : :
9246 : : };
9247 : :
9248 : : /* Common CLI fields for vf split drop enable disable */
9249 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9250 : : TOKEN_STRING_INITIALIZER
9251 : : (struct cmd_set_vf_mac_addr_result,
9252 : : set, "set");
9253 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
9254 : : TOKEN_STRING_INITIALIZER
9255 : : (struct cmd_set_vf_mac_addr_result,
9256 : : vf, "vf");
9257 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
9258 : : TOKEN_STRING_INITIALIZER
9259 : : (struct cmd_set_vf_mac_addr_result,
9260 : : mac, "mac");
9261 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
9262 : : TOKEN_STRING_INITIALIZER
9263 : : (struct cmd_set_vf_mac_addr_result,
9264 : : addr, "addr");
9265 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
9266 : : TOKEN_NUM_INITIALIZER
9267 : : (struct cmd_set_vf_mac_addr_result,
9268 : : port_id, RTE_UINT16);
9269 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
9270 : : TOKEN_NUM_INITIALIZER
9271 : : (struct cmd_set_vf_mac_addr_result,
9272 : : vf_id, RTE_UINT16);
9273 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
9274 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
9275 : : mac_addr);
9276 : :
9277 : : static void
9278 : 0 : cmd_set_vf_mac_addr_parsed(
9279 : : void *parsed_result,
9280 : : __rte_unused struct cmdline *cl,
9281 : : __rte_unused void *data)
9282 : : {
9283 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
9284 : : int ret = -ENOTSUP;
9285 : :
9286 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9287 : : return;
9288 : :
9289 : : #ifdef RTE_NET_IXGBE
9290 : : if (ret == -ENOTSUP)
9291 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
9292 : : &res->mac_addr);
9293 : : #endif
9294 : : #ifdef RTE_NET_I40E
9295 : 0 : if (ret == -ENOTSUP)
9296 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
9297 : : &res->mac_addr);
9298 : : #endif
9299 : : #ifdef RTE_NET_BNXT
9300 : 0 : if (ret == -ENOTSUP)
9301 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
9302 : : &res->mac_addr);
9303 : : #endif
9304 : :
9305 : 0 : switch (ret) {
9306 : : case 0:
9307 : : break;
9308 : 0 : case -EINVAL:
9309 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
9310 : : break;
9311 : 0 : case -ENODEV:
9312 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9313 : : break;
9314 : 0 : case -ENOTSUP:
9315 : 0 : fprintf(stderr, "function not implemented\n");
9316 : : break;
9317 : 0 : default:
9318 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9319 : : }
9320 : : }
9321 : :
9322 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
9323 : : .f = cmd_set_vf_mac_addr_parsed,
9324 : : .data = NULL,
9325 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
9326 : : .tokens = {
9327 : : (void *)&cmd_set_vf_mac_addr_set,
9328 : : (void *)&cmd_set_vf_mac_addr_vf,
9329 : : (void *)&cmd_set_vf_mac_addr_mac,
9330 : : (void *)&cmd_set_vf_mac_addr_addr,
9331 : : (void *)&cmd_set_vf_mac_addr_port_id,
9332 : : (void *)&cmd_set_vf_mac_addr_vf_id,
9333 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
9334 : : NULL,
9335 : : },
9336 : : };
9337 : :
9338 : : /** Set VXLAN encapsulation details */
9339 : : struct cmd_set_vxlan_result {
9340 : : cmdline_fixed_string_t set;
9341 : : cmdline_fixed_string_t vxlan;
9342 : : cmdline_fixed_string_t pos_token;
9343 : : cmdline_fixed_string_t ip_version;
9344 : : uint32_t vlan_present:1;
9345 : : uint32_t vni;
9346 : : uint16_t udp_src;
9347 : : uint16_t udp_dst;
9348 : : cmdline_ipaddr_t ip_src;
9349 : : cmdline_ipaddr_t ip_dst;
9350 : : uint16_t tci;
9351 : : uint8_t tos;
9352 : : uint8_t ttl;
9353 : : struct rte_ether_addr eth_src;
9354 : : struct rte_ether_addr eth_dst;
9355 : : };
9356 : :
9357 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
9358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
9359 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
9360 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
9361 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
9362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9363 : : "vxlan-tos-ttl");
9364 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
9365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9366 : : "vxlan-with-vlan");
9367 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
9368 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9369 : : "ip-version");
9370 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
9371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
9372 : : "ipv4#ipv6");
9373 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
9374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9375 : : "vni");
9376 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
9377 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
9378 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
9379 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9380 : : "udp-src");
9381 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
9382 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
9383 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
9384 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9385 : : "udp-dst");
9386 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
9387 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
9388 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
9389 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9390 : : "ip-tos");
9391 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
9392 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
9393 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
9394 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9395 : : "ip-ttl");
9396 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
9397 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
9398 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
9399 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9400 : : "ip-src");
9401 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
9402 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
9403 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
9404 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9405 : : "ip-dst");
9406 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
9407 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
9408 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
9409 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9410 : : "vlan-tci");
9411 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
9412 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
9413 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
9414 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9415 : : "eth-src");
9416 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
9417 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
9418 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
9419 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9420 : : "eth-dst");
9421 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
9422 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
9423 : :
9424 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
9425 : : __rte_unused struct cmdline *cl,
9426 : : __rte_unused void *data)
9427 : : {
9428 : : struct cmd_set_vxlan_result *res = parsed_result;
9429 : : union {
9430 : : uint32_t vxlan_id;
9431 : : uint8_t vni[4];
9432 : 0 : } id = {
9433 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
9434 : : };
9435 : :
9436 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
9437 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
9438 : 0 : vxlan_encap_conf.select_vlan = 0;
9439 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
9440 : 0 : vxlan_encap_conf.select_vlan = 1;
9441 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
9442 : 0 : vxlan_encap_conf.select_vlan = 0;
9443 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
9444 : : }
9445 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9446 : 0 : vxlan_encap_conf.select_ipv4 = 1;
9447 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9448 : 0 : vxlan_encap_conf.select_ipv4 = 0;
9449 : : else
9450 : 0 : return;
9451 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
9452 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
9453 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
9454 : 0 : vxlan_encap_conf.ip_tos = res->tos;
9455 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
9456 : 0 : if (vxlan_encap_conf.select_ipv4) {
9457 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
9458 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
9459 : : } else {
9460 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
9461 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
9462 : : }
9463 : 0 : if (vxlan_encap_conf.select_vlan)
9464 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9465 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
9466 : : RTE_ETHER_ADDR_LEN);
9467 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9468 : : RTE_ETHER_ADDR_LEN);
9469 : : }
9470 : :
9471 : : static cmdline_parse_inst_t cmd_set_vxlan = {
9472 : : .f = cmd_set_vxlan_parsed,
9473 : : .data = NULL,
9474 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
9475 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
9476 : : " eth-src <eth-src> eth-dst <eth-dst>",
9477 : : .tokens = {
9478 : : (void *)&cmd_set_vxlan_set,
9479 : : (void *)&cmd_set_vxlan_vxlan,
9480 : : (void *)&cmd_set_vxlan_ip_version,
9481 : : (void *)&cmd_set_vxlan_ip_version_value,
9482 : : (void *)&cmd_set_vxlan_vni,
9483 : : (void *)&cmd_set_vxlan_vni_value,
9484 : : (void *)&cmd_set_vxlan_udp_src,
9485 : : (void *)&cmd_set_vxlan_udp_src_value,
9486 : : (void *)&cmd_set_vxlan_udp_dst,
9487 : : (void *)&cmd_set_vxlan_udp_dst_value,
9488 : : (void *)&cmd_set_vxlan_ip_src,
9489 : : (void *)&cmd_set_vxlan_ip_src_value,
9490 : : (void *)&cmd_set_vxlan_ip_dst,
9491 : : (void *)&cmd_set_vxlan_ip_dst_value,
9492 : : (void *)&cmd_set_vxlan_eth_src,
9493 : : (void *)&cmd_set_vxlan_eth_src_value,
9494 : : (void *)&cmd_set_vxlan_eth_dst,
9495 : : (void *)&cmd_set_vxlan_eth_dst_value,
9496 : : NULL,
9497 : : },
9498 : : };
9499 : :
9500 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
9501 : : .f = cmd_set_vxlan_parsed,
9502 : : .data = NULL,
9503 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
9504 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
9505 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9506 : : " eth-dst <eth-dst>",
9507 : : .tokens = {
9508 : : (void *)&cmd_set_vxlan_set,
9509 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
9510 : : (void *)&cmd_set_vxlan_ip_version,
9511 : : (void *)&cmd_set_vxlan_ip_version_value,
9512 : : (void *)&cmd_set_vxlan_vni,
9513 : : (void *)&cmd_set_vxlan_vni_value,
9514 : : (void *)&cmd_set_vxlan_udp_src,
9515 : : (void *)&cmd_set_vxlan_udp_src_value,
9516 : : (void *)&cmd_set_vxlan_udp_dst,
9517 : : (void *)&cmd_set_vxlan_udp_dst_value,
9518 : : (void *)&cmd_set_vxlan_ip_tos,
9519 : : (void *)&cmd_set_vxlan_ip_tos_value,
9520 : : (void *)&cmd_set_vxlan_ip_ttl,
9521 : : (void *)&cmd_set_vxlan_ip_ttl_value,
9522 : : (void *)&cmd_set_vxlan_ip_src,
9523 : : (void *)&cmd_set_vxlan_ip_src_value,
9524 : : (void *)&cmd_set_vxlan_ip_dst,
9525 : : (void *)&cmd_set_vxlan_ip_dst_value,
9526 : : (void *)&cmd_set_vxlan_eth_src,
9527 : : (void *)&cmd_set_vxlan_eth_src_value,
9528 : : (void *)&cmd_set_vxlan_eth_dst,
9529 : : (void *)&cmd_set_vxlan_eth_dst_value,
9530 : : NULL,
9531 : : },
9532 : : };
9533 : :
9534 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
9535 : : .f = cmd_set_vxlan_parsed,
9536 : : .data = NULL,
9537 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
9538 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
9539 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
9540 : : " <eth-dst>",
9541 : : .tokens = {
9542 : : (void *)&cmd_set_vxlan_set,
9543 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
9544 : : (void *)&cmd_set_vxlan_ip_version,
9545 : : (void *)&cmd_set_vxlan_ip_version_value,
9546 : : (void *)&cmd_set_vxlan_vni,
9547 : : (void *)&cmd_set_vxlan_vni_value,
9548 : : (void *)&cmd_set_vxlan_udp_src,
9549 : : (void *)&cmd_set_vxlan_udp_src_value,
9550 : : (void *)&cmd_set_vxlan_udp_dst,
9551 : : (void *)&cmd_set_vxlan_udp_dst_value,
9552 : : (void *)&cmd_set_vxlan_ip_src,
9553 : : (void *)&cmd_set_vxlan_ip_src_value,
9554 : : (void *)&cmd_set_vxlan_ip_dst,
9555 : : (void *)&cmd_set_vxlan_ip_dst_value,
9556 : : (void *)&cmd_set_vxlan_vlan,
9557 : : (void *)&cmd_set_vxlan_vlan_value,
9558 : : (void *)&cmd_set_vxlan_eth_src,
9559 : : (void *)&cmd_set_vxlan_eth_src_value,
9560 : : (void *)&cmd_set_vxlan_eth_dst,
9561 : : (void *)&cmd_set_vxlan_eth_dst_value,
9562 : : NULL,
9563 : : },
9564 : : };
9565 : :
9566 : : /** Set NVGRE encapsulation details */
9567 : : struct cmd_set_nvgre_result {
9568 : : cmdline_fixed_string_t set;
9569 : : cmdline_fixed_string_t nvgre;
9570 : : cmdline_fixed_string_t pos_token;
9571 : : cmdline_fixed_string_t ip_version;
9572 : : uint32_t tni;
9573 : : cmdline_ipaddr_t ip_src;
9574 : : cmdline_ipaddr_t ip_dst;
9575 : : uint16_t tci;
9576 : : struct rte_ether_addr eth_src;
9577 : : struct rte_ether_addr eth_dst;
9578 : : };
9579 : :
9580 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
9581 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
9582 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
9583 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
9584 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
9585 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
9586 : : "nvgre-with-vlan");
9587 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
9588 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9589 : : "ip-version");
9590 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
9591 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
9592 : : "ipv4#ipv6");
9593 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
9594 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9595 : : "tni");
9596 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
9597 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
9598 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
9599 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9600 : : "ip-src");
9601 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
9602 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
9603 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
9604 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9605 : : "ip-dst");
9606 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
9607 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
9608 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
9609 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9610 : : "vlan-tci");
9611 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
9612 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
9613 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
9614 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9615 : : "eth-src");
9616 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
9617 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
9618 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
9619 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9620 : : "eth-dst");
9621 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
9622 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
9623 : :
9624 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
9625 : : __rte_unused struct cmdline *cl,
9626 : : __rte_unused void *data)
9627 : : {
9628 : : struct cmd_set_nvgre_result *res = parsed_result;
9629 : : union {
9630 : : uint32_t nvgre_tni;
9631 : : uint8_t tni[4];
9632 : 0 : } id = {
9633 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
9634 : : };
9635 : :
9636 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
9637 : 0 : nvgre_encap_conf.select_vlan = 0;
9638 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
9639 : 0 : nvgre_encap_conf.select_vlan = 1;
9640 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9641 : 0 : nvgre_encap_conf.select_ipv4 = 1;
9642 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9643 : 0 : nvgre_encap_conf.select_ipv4 = 0;
9644 : : else
9645 : 0 : return;
9646 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
9647 : 0 : if (nvgre_encap_conf.select_ipv4) {
9648 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
9649 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
9650 : : } else {
9651 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
9652 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
9653 : : }
9654 : 0 : if (nvgre_encap_conf.select_vlan)
9655 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9656 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
9657 : : RTE_ETHER_ADDR_LEN);
9658 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9659 : : RTE_ETHER_ADDR_LEN);
9660 : : }
9661 : :
9662 : : static cmdline_parse_inst_t cmd_set_nvgre = {
9663 : : .f = cmd_set_nvgre_parsed,
9664 : : .data = NULL,
9665 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
9666 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9667 : : " eth-dst <eth-dst>",
9668 : : .tokens = {
9669 : : (void *)&cmd_set_nvgre_set,
9670 : : (void *)&cmd_set_nvgre_nvgre,
9671 : : (void *)&cmd_set_nvgre_ip_version,
9672 : : (void *)&cmd_set_nvgre_ip_version_value,
9673 : : (void *)&cmd_set_nvgre_tni,
9674 : : (void *)&cmd_set_nvgre_tni_value,
9675 : : (void *)&cmd_set_nvgre_ip_src,
9676 : : (void *)&cmd_set_nvgre_ip_src_value,
9677 : : (void *)&cmd_set_nvgre_ip_dst,
9678 : : (void *)&cmd_set_nvgre_ip_dst_value,
9679 : : (void *)&cmd_set_nvgre_eth_src,
9680 : : (void *)&cmd_set_nvgre_eth_src_value,
9681 : : (void *)&cmd_set_nvgre_eth_dst,
9682 : : (void *)&cmd_set_nvgre_eth_dst_value,
9683 : : NULL,
9684 : : },
9685 : : };
9686 : :
9687 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
9688 : : .f = cmd_set_nvgre_parsed,
9689 : : .data = NULL,
9690 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
9691 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
9692 : : " eth-src <eth-src> eth-dst <eth-dst>",
9693 : : .tokens = {
9694 : : (void *)&cmd_set_nvgre_set,
9695 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
9696 : : (void *)&cmd_set_nvgre_ip_version,
9697 : : (void *)&cmd_set_nvgre_ip_version_value,
9698 : : (void *)&cmd_set_nvgre_tni,
9699 : : (void *)&cmd_set_nvgre_tni_value,
9700 : : (void *)&cmd_set_nvgre_ip_src,
9701 : : (void *)&cmd_set_nvgre_ip_src_value,
9702 : : (void *)&cmd_set_nvgre_ip_dst,
9703 : : (void *)&cmd_set_nvgre_ip_dst_value,
9704 : : (void *)&cmd_set_nvgre_vlan,
9705 : : (void *)&cmd_set_nvgre_vlan_value,
9706 : : (void *)&cmd_set_nvgre_eth_src,
9707 : : (void *)&cmd_set_nvgre_eth_src_value,
9708 : : (void *)&cmd_set_nvgre_eth_dst,
9709 : : (void *)&cmd_set_nvgre_eth_dst_value,
9710 : : NULL,
9711 : : },
9712 : : };
9713 : :
9714 : : /** Set L2 encapsulation details */
9715 : : struct cmd_set_l2_encap_result {
9716 : : cmdline_fixed_string_t set;
9717 : : cmdline_fixed_string_t l2_encap;
9718 : : cmdline_fixed_string_t pos_token;
9719 : : cmdline_fixed_string_t ip_version;
9720 : : uint32_t vlan_present:1;
9721 : : uint16_t tci;
9722 : : struct rte_ether_addr eth_src;
9723 : : struct rte_ether_addr eth_dst;
9724 : : };
9725 : :
9726 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
9727 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
9728 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
9729 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
9730 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
9731 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
9732 : : "l2_encap-with-vlan");
9733 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
9734 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9735 : : "ip-version");
9736 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
9737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
9738 : : "ipv4#ipv6");
9739 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
9740 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9741 : : "vlan-tci");
9742 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
9743 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
9744 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
9745 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9746 : : "eth-src");
9747 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
9748 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
9749 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
9750 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9751 : : "eth-dst");
9752 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
9753 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
9754 : :
9755 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
9756 : : __rte_unused struct cmdline *cl,
9757 : : __rte_unused void *data)
9758 : : {
9759 : : struct cmd_set_l2_encap_result *res = parsed_result;
9760 : :
9761 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
9762 : 0 : l2_encap_conf.select_vlan = 0;
9763 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
9764 : 0 : l2_encap_conf.select_vlan = 1;
9765 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9766 : 0 : l2_encap_conf.select_ipv4 = 1;
9767 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9768 : 0 : l2_encap_conf.select_ipv4 = 0;
9769 : : else
9770 : : return;
9771 : 0 : if (l2_encap_conf.select_vlan)
9772 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9773 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
9774 : : RTE_ETHER_ADDR_LEN);
9775 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9776 : : RTE_ETHER_ADDR_LEN);
9777 : : }
9778 : :
9779 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
9780 : : .f = cmd_set_l2_encap_parsed,
9781 : : .data = NULL,
9782 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
9783 : : " eth-src <eth-src> eth-dst <eth-dst>",
9784 : : .tokens = {
9785 : : (void *)&cmd_set_l2_encap_set,
9786 : : (void *)&cmd_set_l2_encap_l2_encap,
9787 : : (void *)&cmd_set_l2_encap_ip_version,
9788 : : (void *)&cmd_set_l2_encap_ip_version_value,
9789 : : (void *)&cmd_set_l2_encap_eth_src,
9790 : : (void *)&cmd_set_l2_encap_eth_src_value,
9791 : : (void *)&cmd_set_l2_encap_eth_dst,
9792 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9793 : : NULL,
9794 : : },
9795 : : };
9796 : :
9797 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
9798 : : .f = cmd_set_l2_encap_parsed,
9799 : : .data = NULL,
9800 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
9801 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
9802 : : .tokens = {
9803 : : (void *)&cmd_set_l2_encap_set,
9804 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
9805 : : (void *)&cmd_set_l2_encap_ip_version,
9806 : : (void *)&cmd_set_l2_encap_ip_version_value,
9807 : : (void *)&cmd_set_l2_encap_vlan,
9808 : : (void *)&cmd_set_l2_encap_vlan_value,
9809 : : (void *)&cmd_set_l2_encap_eth_src,
9810 : : (void *)&cmd_set_l2_encap_eth_src_value,
9811 : : (void *)&cmd_set_l2_encap_eth_dst,
9812 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9813 : : NULL,
9814 : : },
9815 : : };
9816 : :
9817 : : /** Set L2 decapsulation details */
9818 : : struct cmd_set_l2_decap_result {
9819 : : cmdline_fixed_string_t set;
9820 : : cmdline_fixed_string_t l2_decap;
9821 : : cmdline_fixed_string_t pos_token;
9822 : : uint32_t vlan_present:1;
9823 : : };
9824 : :
9825 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
9826 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
9827 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
9828 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9829 : : "l2_decap");
9830 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
9831 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9832 : : "l2_decap-with-vlan");
9833 : :
9834 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
9835 : : __rte_unused struct cmdline *cl,
9836 : : __rte_unused void *data)
9837 : : {
9838 : : struct cmd_set_l2_decap_result *res = parsed_result;
9839 : :
9840 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
9841 : 0 : l2_decap_conf.select_vlan = 0;
9842 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
9843 : 0 : l2_decap_conf.select_vlan = 1;
9844 : 0 : }
9845 : :
9846 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
9847 : : .f = cmd_set_l2_decap_parsed,
9848 : : .data = NULL,
9849 : : .help_str = "set l2_decap",
9850 : : .tokens = {
9851 : : (void *)&cmd_set_l2_decap_set,
9852 : : (void *)&cmd_set_l2_decap_l2_decap,
9853 : : NULL,
9854 : : },
9855 : : };
9856 : :
9857 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
9858 : : .f = cmd_set_l2_decap_parsed,
9859 : : .data = NULL,
9860 : : .help_str = "set l2_decap-with-vlan",
9861 : : .tokens = {
9862 : : (void *)&cmd_set_l2_decap_set,
9863 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
9864 : : NULL,
9865 : : },
9866 : : };
9867 : :
9868 : : /** Set MPLSoGRE encapsulation details */
9869 : : struct cmd_set_mplsogre_encap_result {
9870 : : cmdline_fixed_string_t set;
9871 : : cmdline_fixed_string_t mplsogre;
9872 : : cmdline_fixed_string_t pos_token;
9873 : : cmdline_fixed_string_t ip_version;
9874 : : uint32_t vlan_present:1;
9875 : : uint32_t label;
9876 : : cmdline_ipaddr_t ip_src;
9877 : : cmdline_ipaddr_t ip_dst;
9878 : : uint16_t tci;
9879 : : struct rte_ether_addr eth_src;
9880 : : struct rte_ether_addr eth_dst;
9881 : : };
9882 : :
9883 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
9884 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
9885 : : "set");
9886 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
9887 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
9888 : : "mplsogre_encap");
9889 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
9890 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9891 : : mplsogre, "mplsogre_encap-with-vlan");
9892 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
9893 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9894 : : pos_token, "ip-version");
9895 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
9896 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9897 : : ip_version, "ipv4#ipv6");
9898 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
9899 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9900 : : pos_token, "label");
9901 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
9902 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
9903 : : RTE_UINT32);
9904 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
9905 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9906 : : pos_token, "ip-src");
9907 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
9908 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
9909 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
9910 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9911 : : pos_token, "ip-dst");
9912 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
9913 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
9914 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
9915 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9916 : : pos_token, "vlan-tci");
9917 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
9918 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
9919 : : RTE_UINT16);
9920 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
9921 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9922 : : pos_token, "eth-src");
9923 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
9924 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9925 : : eth_src);
9926 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
9927 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9928 : : pos_token, "eth-dst");
9929 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
9930 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9931 : : eth_dst);
9932 : :
9933 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
9934 : : __rte_unused struct cmdline *cl,
9935 : : __rte_unused void *data)
9936 : : {
9937 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
9938 : : union {
9939 : : uint32_t mplsogre_label;
9940 : : uint8_t label[4];
9941 : 0 : } id = {
9942 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
9943 : : };
9944 : :
9945 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
9946 : 0 : mplsogre_encap_conf.select_vlan = 0;
9947 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
9948 : 0 : mplsogre_encap_conf.select_vlan = 1;
9949 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9950 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
9951 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9952 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
9953 : : else
9954 : 0 : return;
9955 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
9956 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9957 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
9958 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
9959 : : } else {
9960 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
9961 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
9962 : : }
9963 : 0 : if (mplsogre_encap_conf.select_vlan)
9964 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9965 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
9966 : : RTE_ETHER_ADDR_LEN);
9967 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9968 : : RTE_ETHER_ADDR_LEN);
9969 : : }
9970 : :
9971 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
9972 : : .f = cmd_set_mplsogre_encap_parsed,
9973 : : .data = NULL,
9974 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
9975 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9976 : : " eth-dst <eth-dst>",
9977 : : .tokens = {
9978 : : (void *)&cmd_set_mplsogre_encap_set,
9979 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
9980 : : (void *)&cmd_set_mplsogre_encap_ip_version,
9981 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
9982 : : (void *)&cmd_set_mplsogre_encap_label,
9983 : : (void *)&cmd_set_mplsogre_encap_label_value,
9984 : : (void *)&cmd_set_mplsogre_encap_ip_src,
9985 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
9986 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
9987 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
9988 : : (void *)&cmd_set_mplsogre_encap_eth_src,
9989 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
9990 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
9991 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
9992 : : NULL,
9993 : : },
9994 : : };
9995 : :
9996 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
9997 : : .f = cmd_set_mplsogre_encap_parsed,
9998 : : .data = NULL,
9999 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10000 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10001 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10002 : : .tokens = {
10003 : : (void *)&cmd_set_mplsogre_encap_set,
10004 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10005 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10006 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10007 : : (void *)&cmd_set_mplsogre_encap_label,
10008 : : (void *)&cmd_set_mplsogre_encap_label_value,
10009 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10010 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10011 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10012 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10013 : : (void *)&cmd_set_mplsogre_encap_vlan,
10014 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10015 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10016 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10017 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10018 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10019 : : NULL,
10020 : : },
10021 : : };
10022 : :
10023 : : /** Set MPLSoGRE decapsulation details */
10024 : : struct cmd_set_mplsogre_decap_result {
10025 : : cmdline_fixed_string_t set;
10026 : : cmdline_fixed_string_t mplsogre;
10027 : : cmdline_fixed_string_t pos_token;
10028 : : cmdline_fixed_string_t ip_version;
10029 : : uint32_t vlan_present:1;
10030 : : };
10031 : :
10032 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10033 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10034 : : "set");
10035 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10036 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10037 : : "mplsogre_decap");
10038 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10039 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10040 : : mplsogre, "mplsogre_decap-with-vlan");
10041 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10042 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10043 : : pos_token, "ip-version");
10044 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10045 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10046 : : ip_version, "ipv4#ipv6");
10047 : :
10048 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10049 : : __rte_unused struct cmdline *cl,
10050 : : __rte_unused void *data)
10051 : : {
10052 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10053 : :
10054 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10055 : 0 : mplsogre_decap_conf.select_vlan = 0;
10056 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10057 : 0 : mplsogre_decap_conf.select_vlan = 1;
10058 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10059 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10060 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10061 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10062 : 0 : }
10063 : :
10064 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10065 : : .f = cmd_set_mplsogre_decap_parsed,
10066 : : .data = NULL,
10067 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10068 : : .tokens = {
10069 : : (void *)&cmd_set_mplsogre_decap_set,
10070 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10071 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10072 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10073 : : NULL,
10074 : : },
10075 : : };
10076 : :
10077 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10078 : : .f = cmd_set_mplsogre_decap_parsed,
10079 : : .data = NULL,
10080 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10081 : : .tokens = {
10082 : : (void *)&cmd_set_mplsogre_decap_set,
10083 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10084 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10085 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10086 : : NULL,
10087 : : },
10088 : : };
10089 : :
10090 : : /** Set MPLSoUDP encapsulation details */
10091 : : struct cmd_set_mplsoudp_encap_result {
10092 : : cmdline_fixed_string_t set;
10093 : : cmdline_fixed_string_t mplsoudp;
10094 : : cmdline_fixed_string_t pos_token;
10095 : : cmdline_fixed_string_t ip_version;
10096 : : uint32_t vlan_present:1;
10097 : : uint32_t label;
10098 : : uint16_t udp_src;
10099 : : uint16_t udp_dst;
10100 : : cmdline_ipaddr_t ip_src;
10101 : : cmdline_ipaddr_t ip_dst;
10102 : : uint16_t tci;
10103 : : struct rte_ether_addr eth_src;
10104 : : struct rte_ether_addr eth_dst;
10105 : : };
10106 : :
10107 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10108 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10109 : : "set");
10110 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10112 : : "mplsoudp_encap");
10113 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10115 : : mplsoudp, "mplsoudp_encap-with-vlan");
10116 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10117 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10118 : : pos_token, "ip-version");
10119 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10120 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10121 : : ip_version, "ipv4#ipv6");
10122 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10123 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10124 : : pos_token, "label");
10125 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10126 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10127 : : RTE_UINT32);
10128 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10129 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10130 : : pos_token, "udp-src");
10131 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10132 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10133 : : RTE_UINT16);
10134 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10135 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10136 : : pos_token, "udp-dst");
10137 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10138 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10139 : : RTE_UINT16);
10140 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10141 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10142 : : pos_token, "ip-src");
10143 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10144 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10145 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10146 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10147 : : pos_token, "ip-dst");
10148 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10149 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10150 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10151 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10152 : : pos_token, "vlan-tci");
10153 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10154 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10155 : : RTE_UINT16);
10156 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10157 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10158 : : pos_token, "eth-src");
10159 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10160 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10161 : : eth_src);
10162 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10163 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10164 : : pos_token, "eth-dst");
10165 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10166 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10167 : : eth_dst);
10168 : :
10169 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10170 : : __rte_unused struct cmdline *cl,
10171 : : __rte_unused void *data)
10172 : : {
10173 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10174 : : union {
10175 : : uint32_t mplsoudp_label;
10176 : : uint8_t label[4];
10177 : 0 : } id = {
10178 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10179 : : };
10180 : :
10181 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10182 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10183 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10184 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10185 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10186 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10187 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10188 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10189 : : else
10190 : 0 : return;
10191 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10192 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10193 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10194 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10195 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10196 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10197 : : } else {
10198 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10199 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10200 : : }
10201 : 0 : if (mplsoudp_encap_conf.select_vlan)
10202 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10203 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10204 : : RTE_ETHER_ADDR_LEN);
10205 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10206 : : RTE_ETHER_ADDR_LEN);
10207 : : }
10208 : :
10209 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10210 : : .f = cmd_set_mplsoudp_encap_parsed,
10211 : : .data = NULL,
10212 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10213 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10214 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10215 : : .tokens = {
10216 : : (void *)&cmd_set_mplsoudp_encap_set,
10217 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10218 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10219 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10220 : : (void *)&cmd_set_mplsoudp_encap_label,
10221 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10222 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10223 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10224 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10225 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10226 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10227 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10228 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10229 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10230 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10231 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10232 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10233 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10234 : : NULL,
10235 : : },
10236 : : };
10237 : :
10238 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10239 : : .f = cmd_set_mplsoudp_encap_parsed,
10240 : : .data = NULL,
10241 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10242 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10243 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10244 : : " eth-src <eth-src> eth-dst <eth-dst>",
10245 : : .tokens = {
10246 : : (void *)&cmd_set_mplsoudp_encap_set,
10247 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10248 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10249 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10250 : : (void *)&cmd_set_mplsoudp_encap_label,
10251 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10252 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10253 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10254 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10255 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10256 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10257 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10258 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10259 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10260 : : (void *)&cmd_set_mplsoudp_encap_vlan,
10261 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
10262 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10263 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10264 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10265 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10266 : : NULL,
10267 : : },
10268 : : };
10269 : :
10270 : : /** Set MPLSoUDP decapsulation details */
10271 : : struct cmd_set_mplsoudp_decap_result {
10272 : : cmdline_fixed_string_t set;
10273 : : cmdline_fixed_string_t mplsoudp;
10274 : : cmdline_fixed_string_t pos_token;
10275 : : cmdline_fixed_string_t ip_version;
10276 : : uint32_t vlan_present:1;
10277 : : };
10278 : :
10279 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
10280 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
10281 : : "set");
10282 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
10283 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
10284 : : "mplsoudp_decap");
10285 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
10286 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10287 : : mplsoudp, "mplsoudp_decap-with-vlan");
10288 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
10289 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10290 : : pos_token, "ip-version");
10291 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
10292 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10293 : : ip_version, "ipv4#ipv6");
10294 : :
10295 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
10296 : : __rte_unused struct cmdline *cl,
10297 : : __rte_unused void *data)
10298 : : {
10299 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
10300 : :
10301 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
10302 : 0 : mplsoudp_decap_conf.select_vlan = 0;
10303 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
10304 : 0 : mplsoudp_decap_conf.select_vlan = 1;
10305 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10306 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
10307 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10308 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
10309 : 0 : }
10310 : :
10311 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
10312 : : .f = cmd_set_mplsoudp_decap_parsed,
10313 : : .data = NULL,
10314 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
10315 : : .tokens = {
10316 : : (void *)&cmd_set_mplsoudp_decap_set,
10317 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
10318 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10319 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10320 : : NULL,
10321 : : },
10322 : : };
10323 : :
10324 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
10325 : : .f = cmd_set_mplsoudp_decap_parsed,
10326 : : .data = NULL,
10327 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
10328 : : .tokens = {
10329 : : (void *)&cmd_set_mplsoudp_decap_set,
10330 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
10331 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10332 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10333 : : NULL,
10334 : : },
10335 : : };
10336 : :
10337 : : /** Set connection tracking object common details */
10338 : : struct cmd_set_conntrack_common_result {
10339 : : cmdline_fixed_string_t set;
10340 : : cmdline_fixed_string_t conntrack;
10341 : : cmdline_fixed_string_t common;
10342 : : cmdline_fixed_string_t peer;
10343 : : cmdline_fixed_string_t is_orig;
10344 : : cmdline_fixed_string_t enable;
10345 : : cmdline_fixed_string_t live;
10346 : : cmdline_fixed_string_t sack;
10347 : : cmdline_fixed_string_t cack;
10348 : : cmdline_fixed_string_t last_dir;
10349 : : cmdline_fixed_string_t liberal;
10350 : : cmdline_fixed_string_t state;
10351 : : cmdline_fixed_string_t max_ack_win;
10352 : : cmdline_fixed_string_t retrans;
10353 : : cmdline_fixed_string_t last_win;
10354 : : cmdline_fixed_string_t last_seq;
10355 : : cmdline_fixed_string_t last_ack;
10356 : : cmdline_fixed_string_t last_end;
10357 : : cmdline_fixed_string_t last_index;
10358 : : uint8_t stat;
10359 : : uint8_t factor;
10360 : : uint16_t peer_port;
10361 : : uint32_t is_original;
10362 : : uint32_t en;
10363 : : uint32_t is_live;
10364 : : uint32_t s_ack;
10365 : : uint32_t c_ack;
10366 : : uint32_t ld;
10367 : : uint32_t lb;
10368 : : uint8_t re_num;
10369 : : uint8_t li;
10370 : : uint16_t lw;
10371 : : uint32_t ls;
10372 : : uint32_t la;
10373 : : uint32_t le;
10374 : : };
10375 : :
10376 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
10377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10378 : : set, "set");
10379 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
10380 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10381 : : conntrack, "conntrack");
10382 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
10383 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10384 : : common, "com");
10385 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
10386 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10387 : : peer, "peer");
10388 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
10389 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10390 : : peer_port, RTE_UINT16);
10391 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
10392 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10393 : : is_orig, "is_orig");
10394 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
10395 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10396 : : is_original, RTE_UINT32);
10397 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
10398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10399 : : enable, "enable");
10400 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
10401 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10402 : : en, RTE_UINT32);
10403 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
10404 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10405 : : live, "live");
10406 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
10407 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10408 : : is_live, RTE_UINT32);
10409 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
10410 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10411 : : sack, "sack");
10412 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
10413 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10414 : : s_ack, RTE_UINT32);
10415 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
10416 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10417 : : cack, "cack");
10418 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
10419 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10420 : : c_ack, RTE_UINT32);
10421 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
10422 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10423 : : last_dir, "last_dir");
10424 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
10425 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10426 : : ld, RTE_UINT32);
10427 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
10428 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10429 : : liberal, "liberal");
10430 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
10431 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10432 : : lb, RTE_UINT32);
10433 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
10434 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10435 : : state, "state");
10436 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
10437 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10438 : : stat, RTE_UINT8);
10439 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
10440 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10441 : : max_ack_win, "max_ack_win");
10442 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
10443 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10444 : : factor, RTE_UINT8);
10445 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
10446 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10447 : : retrans, "r_lim");
10448 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
10449 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10450 : : re_num, RTE_UINT8);
10451 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
10452 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10453 : : last_win, "last_win");
10454 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
10455 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10456 : : lw, RTE_UINT16);
10457 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
10458 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10459 : : last_seq, "last_seq");
10460 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
10461 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10462 : : ls, RTE_UINT32);
10463 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
10464 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10465 : : last_ack, "last_ack");
10466 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
10467 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10468 : : la, RTE_UINT32);
10469 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
10470 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10471 : : last_end, "last_end");
10472 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
10473 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10474 : : le, RTE_UINT32);
10475 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
10476 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10477 : : last_index, "last_index");
10478 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
10479 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10480 : : li, RTE_UINT8);
10481 : :
10482 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
10483 : : __rte_unused struct cmdline *cl,
10484 : : __rte_unused void *data)
10485 : : {
10486 : : struct cmd_set_conntrack_common_result *res = parsed_result;
10487 : :
10488 : : /* No need to swap to big endian. */
10489 : 0 : conntrack_context.peer_port = res->peer_port;
10490 : 0 : conntrack_context.is_original_dir = res->is_original;
10491 : 0 : conntrack_context.enable = res->en;
10492 : 0 : conntrack_context.live_connection = res->is_live;
10493 : 0 : conntrack_context.selective_ack = res->s_ack;
10494 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
10495 : 0 : conntrack_context.last_direction = res->ld;
10496 : 0 : conntrack_context.liberal_mode = res->lb;
10497 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
10498 : 0 : conntrack_context.max_ack_window = res->factor;
10499 : 0 : conntrack_context.retransmission_limit = res->re_num;
10500 : 0 : conntrack_context.last_window = res->lw;
10501 : 0 : conntrack_context.last_index =
10502 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
10503 : 0 : conntrack_context.last_seq = res->ls;
10504 : 0 : conntrack_context.last_ack = res->la;
10505 : 0 : conntrack_context.last_end = res->le;
10506 : 0 : }
10507 : :
10508 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
10509 : : .f = cmd_set_conntrack_common_parsed,
10510 : : .data = NULL,
10511 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
10512 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
10513 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
10514 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
10515 : : " last_index <flag>",
10516 : : .tokens = {
10517 : : (void *)&cmd_set_conntrack_set,
10518 : : (void *)&cmd_set_conntrack_conntrack,
10519 : : (void *)&cmd_set_conntrack_common_com,
10520 : : (void *)&cmd_set_conntrack_common_peer,
10521 : : (void *)&cmd_set_conntrack_common_peer_value,
10522 : : (void *)&cmd_set_conntrack_common_is_orig,
10523 : : (void *)&cmd_set_conntrack_common_is_orig_value,
10524 : : (void *)&cmd_set_conntrack_common_enable,
10525 : : (void *)&cmd_set_conntrack_common_enable_value,
10526 : : (void *)&cmd_set_conntrack_common_live,
10527 : : (void *)&cmd_set_conntrack_common_live_value,
10528 : : (void *)&cmd_set_conntrack_common_sack,
10529 : : (void *)&cmd_set_conntrack_common_sack_value,
10530 : : (void *)&cmd_set_conntrack_common_cack,
10531 : : (void *)&cmd_set_conntrack_common_cack_value,
10532 : : (void *)&cmd_set_conntrack_common_last_dir,
10533 : : (void *)&cmd_set_conntrack_common_last_dir_value,
10534 : : (void *)&cmd_set_conntrack_common_liberal,
10535 : : (void *)&cmd_set_conntrack_common_liberal_value,
10536 : : (void *)&cmd_set_conntrack_common_state,
10537 : : (void *)&cmd_set_conntrack_common_state_value,
10538 : : (void *)&cmd_set_conntrack_common_max_ackwin,
10539 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
10540 : : (void *)&cmd_set_conntrack_common_retrans,
10541 : : (void *)&cmd_set_conntrack_common_retrans_value,
10542 : : (void *)&cmd_set_conntrack_common_last_win,
10543 : : (void *)&cmd_set_conntrack_common_last_win_value,
10544 : : (void *)&cmd_set_conntrack_common_last_seq,
10545 : : (void *)&cmd_set_conntrack_common_last_seq_value,
10546 : : (void *)&cmd_set_conntrack_common_last_ack,
10547 : : (void *)&cmd_set_conntrack_common_last_ack_value,
10548 : : (void *)&cmd_set_conntrack_common_last_end,
10549 : : (void *)&cmd_set_conntrack_common_last_end_value,
10550 : : (void *)&cmd_set_conntrack_common_last_index,
10551 : : (void *)&cmd_set_conntrack_common_last_index_value,
10552 : : NULL,
10553 : : },
10554 : : };
10555 : :
10556 : : /** Set connection tracking object both directions' details */
10557 : : struct cmd_set_conntrack_dir_result {
10558 : : cmdline_fixed_string_t set;
10559 : : cmdline_fixed_string_t conntrack;
10560 : : cmdline_fixed_string_t dir;
10561 : : cmdline_fixed_string_t scale;
10562 : : cmdline_fixed_string_t fin;
10563 : : cmdline_fixed_string_t ack_seen;
10564 : : cmdline_fixed_string_t unack;
10565 : : cmdline_fixed_string_t sent_end;
10566 : : cmdline_fixed_string_t reply_end;
10567 : : cmdline_fixed_string_t max_win;
10568 : : cmdline_fixed_string_t max_ack;
10569 : : uint32_t factor;
10570 : : uint32_t f;
10571 : : uint32_t as;
10572 : : uint32_t un;
10573 : : uint32_t se;
10574 : : uint32_t re;
10575 : : uint32_t mw;
10576 : : uint32_t ma;
10577 : : };
10578 : :
10579 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
10580 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10581 : : dir, "orig#rply");
10582 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
10583 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10584 : : scale, "scale");
10585 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
10586 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10587 : : factor, RTE_UINT32);
10588 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
10589 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10590 : : fin, "fin");
10591 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
10592 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10593 : : f, RTE_UINT32);
10594 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
10595 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10596 : : ack_seen, "acked");
10597 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
10598 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10599 : : as, RTE_UINT32);
10600 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
10601 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10602 : : unack, "unack_data");
10603 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
10604 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10605 : : un, RTE_UINT32);
10606 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
10607 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10608 : : sent_end, "sent_end");
10609 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
10610 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10611 : : se, RTE_UINT32);
10612 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
10613 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10614 : : reply_end, "reply_end");
10615 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
10616 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10617 : : re, RTE_UINT32);
10618 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
10619 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10620 : : max_win, "max_win");
10621 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
10622 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10623 : : mw, RTE_UINT32);
10624 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
10625 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10626 : : max_ack, "max_ack");
10627 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
10628 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10629 : : ma, RTE_UINT32);
10630 : :
10631 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
10632 : : __rte_unused struct cmdline *cl,
10633 : : __rte_unused void *data)
10634 : : {
10635 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
10636 : : struct rte_flow_tcp_dir_param *dir = NULL;
10637 : :
10638 : 0 : if (strcmp(res->dir, "orig") == 0)
10639 : : dir = &conntrack_context.original_dir;
10640 : 0 : else if (strcmp(res->dir, "rply") == 0)
10641 : : dir = &conntrack_context.reply_dir;
10642 : : else
10643 : : return;
10644 : 0 : dir->scale = res->factor;
10645 : 0 : dir->close_initiated = res->f;
10646 : 0 : dir->last_ack_seen = res->as;
10647 : 0 : dir->data_unacked = res->un;
10648 : 0 : dir->sent_end = res->se;
10649 : 0 : dir->reply_end = res->re;
10650 : 0 : dir->max_ack = res->ma;
10651 : 0 : dir->max_win = res->mw;
10652 : : }
10653 : :
10654 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
10655 : : .f = cmd_set_conntrack_dir_parsed,
10656 : : .data = NULL,
10657 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
10658 : : " acked <seen> unack_data <unack> sent_end <sent>"
10659 : : " reply_end <reply> max_win <win> max_ack <ack>",
10660 : : .tokens = {
10661 : : (void *)&cmd_set_conntrack_set,
10662 : : (void *)&cmd_set_conntrack_conntrack,
10663 : : (void *)&cmd_set_conntrack_dir_dir,
10664 : : (void *)&cmd_set_conntrack_dir_scale,
10665 : : (void *)&cmd_set_conntrack_dir_scale_value,
10666 : : (void *)&cmd_set_conntrack_dir_fin,
10667 : : (void *)&cmd_set_conntrack_dir_fin_value,
10668 : : (void *)&cmd_set_conntrack_dir_ack,
10669 : : (void *)&cmd_set_conntrack_dir_ack_value,
10670 : : (void *)&cmd_set_conntrack_dir_unack_data,
10671 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
10672 : : (void *)&cmd_set_conntrack_dir_sent_end,
10673 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
10674 : : (void *)&cmd_set_conntrack_dir_reply_end,
10675 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
10676 : : (void *)&cmd_set_conntrack_dir_max_win,
10677 : : (void *)&cmd_set_conntrack_dir_max_win_value,
10678 : : (void *)&cmd_set_conntrack_dir_max_ack,
10679 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
10680 : : NULL,
10681 : : },
10682 : : };
10683 : :
10684 : : /* show vf stats */
10685 : :
10686 : : /* Common result structure for show vf stats */
10687 : : struct cmd_show_vf_stats_result {
10688 : : cmdline_fixed_string_t show;
10689 : : cmdline_fixed_string_t vf;
10690 : : cmdline_fixed_string_t stats;
10691 : : portid_t port_id;
10692 : : uint16_t vf_id;
10693 : : };
10694 : :
10695 : : /* Common CLI fields show vf stats*/
10696 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
10697 : : TOKEN_STRING_INITIALIZER
10698 : : (struct cmd_show_vf_stats_result,
10699 : : show, "show");
10700 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
10701 : : TOKEN_STRING_INITIALIZER
10702 : : (struct cmd_show_vf_stats_result,
10703 : : vf, "vf");
10704 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
10705 : : TOKEN_STRING_INITIALIZER
10706 : : (struct cmd_show_vf_stats_result,
10707 : : stats, "stats");
10708 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
10709 : : TOKEN_NUM_INITIALIZER
10710 : : (struct cmd_show_vf_stats_result,
10711 : : port_id, RTE_UINT16);
10712 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
10713 : : TOKEN_NUM_INITIALIZER
10714 : : (struct cmd_show_vf_stats_result,
10715 : : vf_id, RTE_UINT16);
10716 : :
10717 : : static void
10718 : 0 : cmd_show_vf_stats_parsed(
10719 : : void *parsed_result,
10720 : : __rte_unused struct cmdline *cl,
10721 : : __rte_unused void *data)
10722 : : {
10723 : : struct cmd_show_vf_stats_result *res = parsed_result;
10724 : : struct rte_eth_stats stats;
10725 : : int ret = -ENOTSUP;
10726 : : static const char *nic_stats_border = "########################";
10727 : :
10728 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10729 : 0 : return;
10730 : :
10731 : : memset(&stats, 0, sizeof(stats));
10732 : :
10733 : : #ifdef RTE_NET_I40E
10734 : : if (ret == -ENOTSUP)
10735 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
10736 : 0 : res->vf_id,
10737 : : &stats);
10738 : : #endif
10739 : : #ifdef RTE_NET_BNXT
10740 : 0 : if (ret == -ENOTSUP)
10741 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
10742 : 0 : res->vf_id,
10743 : : &stats);
10744 : : #endif
10745 : :
10746 : 0 : switch (ret) {
10747 : : case 0:
10748 : : break;
10749 : 0 : case -EINVAL:
10750 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10751 : : break;
10752 : 0 : case -ENODEV:
10753 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10754 : : break;
10755 : 0 : case -ENOTSUP:
10756 : 0 : fprintf(stderr, "function not implemented\n");
10757 : : break;
10758 : 0 : default:
10759 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10760 : : }
10761 : :
10762 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
10763 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
10764 : :
10765 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
10766 : : "%-"PRIu64"\n",
10767 : : stats.ipackets, stats.imissed, stats.ibytes);
10768 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
10769 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
10770 : : stats.rx_nombuf);
10771 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
10772 : : "%-"PRIu64"\n",
10773 : : stats.opackets, stats.oerrors, stats.obytes);
10774 : :
10775 : 0 : printf(" %s############################%s\n",
10776 : : nic_stats_border, nic_stats_border);
10777 : : }
10778 : :
10779 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
10780 : : .f = cmd_show_vf_stats_parsed,
10781 : : .data = NULL,
10782 : : .help_str = "show vf stats <port_id> <vf_id>",
10783 : : .tokens = {
10784 : : (void *)&cmd_show_vf_stats_show,
10785 : : (void *)&cmd_show_vf_stats_vf,
10786 : : (void *)&cmd_show_vf_stats_stats,
10787 : : (void *)&cmd_show_vf_stats_port_id,
10788 : : (void *)&cmd_show_vf_stats_vf_id,
10789 : : NULL,
10790 : : },
10791 : : };
10792 : :
10793 : : /* clear vf stats */
10794 : :
10795 : : /* Common result structure for clear vf stats */
10796 : : struct cmd_clear_vf_stats_result {
10797 : : cmdline_fixed_string_t clear;
10798 : : cmdline_fixed_string_t vf;
10799 : : cmdline_fixed_string_t stats;
10800 : : portid_t port_id;
10801 : : uint16_t vf_id;
10802 : : };
10803 : :
10804 : : /* Common CLI fields clear vf stats*/
10805 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
10806 : : TOKEN_STRING_INITIALIZER
10807 : : (struct cmd_clear_vf_stats_result,
10808 : : clear, "clear");
10809 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
10810 : : TOKEN_STRING_INITIALIZER
10811 : : (struct cmd_clear_vf_stats_result,
10812 : : vf, "vf");
10813 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
10814 : : TOKEN_STRING_INITIALIZER
10815 : : (struct cmd_clear_vf_stats_result,
10816 : : stats, "stats");
10817 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
10818 : : TOKEN_NUM_INITIALIZER
10819 : : (struct cmd_clear_vf_stats_result,
10820 : : port_id, RTE_UINT16);
10821 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
10822 : : TOKEN_NUM_INITIALIZER
10823 : : (struct cmd_clear_vf_stats_result,
10824 : : vf_id, RTE_UINT16);
10825 : :
10826 : : static void
10827 : 0 : cmd_clear_vf_stats_parsed(
10828 : : void *parsed_result,
10829 : : __rte_unused struct cmdline *cl,
10830 : : __rte_unused void *data)
10831 : : {
10832 : : struct cmd_clear_vf_stats_result *res = parsed_result;
10833 : : int ret = -ENOTSUP;
10834 : :
10835 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10836 : : return;
10837 : :
10838 : : #ifdef RTE_NET_I40E
10839 : : if (ret == -ENOTSUP)
10840 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
10841 : 0 : res->vf_id);
10842 : : #endif
10843 : : #ifdef RTE_NET_BNXT
10844 : 0 : if (ret == -ENOTSUP)
10845 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
10846 : 0 : res->vf_id);
10847 : : #endif
10848 : :
10849 : 0 : switch (ret) {
10850 : : case 0:
10851 : : break;
10852 : 0 : case -EINVAL:
10853 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10854 : : break;
10855 : 0 : case -ENODEV:
10856 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10857 : : break;
10858 : 0 : case -ENOTSUP:
10859 : 0 : fprintf(stderr, "function not implemented\n");
10860 : : break;
10861 : 0 : default:
10862 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10863 : : }
10864 : : }
10865 : :
10866 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
10867 : : .f = cmd_clear_vf_stats_parsed,
10868 : : .data = NULL,
10869 : : .help_str = "clear vf stats <port_id> <vf_id>",
10870 : : .tokens = {
10871 : : (void *)&cmd_clear_vf_stats_clear,
10872 : : (void *)&cmd_clear_vf_stats_vf,
10873 : : (void *)&cmd_clear_vf_stats_stats,
10874 : : (void *)&cmd_clear_vf_stats_port_id,
10875 : : (void *)&cmd_clear_vf_stats_vf_id,
10876 : : NULL,
10877 : : },
10878 : : };
10879 : :
10880 : : /* Common result structure for file commands */
10881 : : struct cmd_cmdfile_result {
10882 : : cmdline_fixed_string_t load;
10883 : : cmdline_fixed_string_t filename;
10884 : : };
10885 : :
10886 : : /* Common CLI fields for file commands */
10887 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
10888 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
10889 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
10890 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
10891 : :
10892 : : static void
10893 : 0 : cmd_load_from_file_parsed(
10894 : : void *parsed_result,
10895 : : __rte_unused struct cmdline *cl,
10896 : : __rte_unused void *data)
10897 : : {
10898 : : struct cmd_cmdfile_result *res = parsed_result;
10899 : :
10900 : 0 : cmdline_read_from_file(res->filename);
10901 : 0 : }
10902 : :
10903 : : static cmdline_parse_inst_t cmd_load_from_file = {
10904 : : .f = cmd_load_from_file_parsed,
10905 : : .data = NULL,
10906 : : .help_str = "load <filename>",
10907 : : .tokens = {
10908 : : (void *)&cmd_load_cmdfile,
10909 : : (void *)&cmd_load_cmdfile_filename,
10910 : : NULL,
10911 : : },
10912 : : };
10913 : :
10914 : : /* Get Rx offloads capabilities */
10915 : : struct cmd_rx_offload_get_capa_result {
10916 : : cmdline_fixed_string_t show;
10917 : : cmdline_fixed_string_t port;
10918 : : portid_t port_id;
10919 : : cmdline_fixed_string_t rx_offload;
10920 : : cmdline_fixed_string_t capabilities;
10921 : : };
10922 : :
10923 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
10924 : : TOKEN_STRING_INITIALIZER
10925 : : (struct cmd_rx_offload_get_capa_result,
10926 : : show, "show");
10927 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
10928 : : TOKEN_STRING_INITIALIZER
10929 : : (struct cmd_rx_offload_get_capa_result,
10930 : : port, "port");
10931 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
10932 : : TOKEN_NUM_INITIALIZER
10933 : : (struct cmd_rx_offload_get_capa_result,
10934 : : port_id, RTE_UINT16);
10935 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
10936 : : TOKEN_STRING_INITIALIZER
10937 : : (struct cmd_rx_offload_get_capa_result,
10938 : : rx_offload, "rx_offload");
10939 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
10940 : : TOKEN_STRING_INITIALIZER
10941 : : (struct cmd_rx_offload_get_capa_result,
10942 : : capabilities, "capabilities");
10943 : :
10944 : : static void
10945 : 0 : print_rx_offloads(uint64_t offloads)
10946 : : {
10947 : : uint64_t single_offload;
10948 : : int begin;
10949 : : int end;
10950 : : int bit;
10951 : :
10952 : 0 : if (offloads == 0)
10953 : : return;
10954 : :
10955 : : begin = rte_ctz64(offloads);
10956 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
10957 : :
10958 : 0 : single_offload = 1ULL << begin;
10959 : 0 : for (bit = begin; bit < end; bit++) {
10960 : 0 : if (offloads & single_offload)
10961 : 0 : printf(" %s",
10962 : : rte_eth_dev_rx_offload_name(single_offload));
10963 : 0 : single_offload <<= 1;
10964 : : }
10965 : : }
10966 : :
10967 : : static void
10968 : 0 : cmd_rx_offload_get_capa_parsed(
10969 : : void *parsed_result,
10970 : : __rte_unused struct cmdline *cl,
10971 : : __rte_unused void *data)
10972 : : {
10973 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
10974 : : struct rte_eth_dev_info dev_info;
10975 : 0 : portid_t port_id = res->port_id;
10976 : : uint64_t queue_offloads;
10977 : : uint64_t port_offloads;
10978 : : int ret;
10979 : :
10980 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
10981 : 0 : if (ret != 0)
10982 : 0 : return;
10983 : :
10984 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
10985 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
10986 : :
10987 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
10988 : : printf(" Per Queue :");
10989 : 0 : print_rx_offloads(queue_offloads);
10990 : :
10991 : : printf("\n");
10992 : : printf(" Per Port :");
10993 : 0 : print_rx_offloads(port_offloads);
10994 : : printf("\n\n");
10995 : : }
10996 : :
10997 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
10998 : : .f = cmd_rx_offload_get_capa_parsed,
10999 : : .data = NULL,
11000 : : .help_str = "show port <port_id> rx_offload capabilities",
11001 : : .tokens = {
11002 : : (void *)&cmd_rx_offload_get_capa_show,
11003 : : (void *)&cmd_rx_offload_get_capa_port,
11004 : : (void *)&cmd_rx_offload_get_capa_port_id,
11005 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11006 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11007 : : NULL,
11008 : : }
11009 : : };
11010 : :
11011 : : /* Get Rx offloads configuration */
11012 : : struct cmd_rx_offload_get_configuration_result {
11013 : : cmdline_fixed_string_t show;
11014 : : cmdline_fixed_string_t port;
11015 : : portid_t port_id;
11016 : : cmdline_fixed_string_t rx_offload;
11017 : : cmdline_fixed_string_t configuration;
11018 : : };
11019 : :
11020 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11021 : : TOKEN_STRING_INITIALIZER
11022 : : (struct cmd_rx_offload_get_configuration_result,
11023 : : show, "show");
11024 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11025 : : TOKEN_STRING_INITIALIZER
11026 : : (struct cmd_rx_offload_get_configuration_result,
11027 : : port, "port");
11028 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11029 : : TOKEN_NUM_INITIALIZER
11030 : : (struct cmd_rx_offload_get_configuration_result,
11031 : : port_id, RTE_UINT16);
11032 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11033 : : TOKEN_STRING_INITIALIZER
11034 : : (struct cmd_rx_offload_get_configuration_result,
11035 : : rx_offload, "rx_offload");
11036 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11037 : : TOKEN_STRING_INITIALIZER
11038 : : (struct cmd_rx_offload_get_configuration_result,
11039 : : configuration, "configuration");
11040 : :
11041 : : static void
11042 : 0 : cmd_rx_offload_get_configuration_parsed(
11043 : : void *parsed_result,
11044 : : __rte_unused struct cmdline *cl,
11045 : : __rte_unused void *data)
11046 : : {
11047 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11048 : : struct rte_eth_dev_info dev_info;
11049 : 0 : portid_t port_id = res->port_id;
11050 : 0 : struct rte_port *port = &ports[port_id];
11051 : : struct rte_eth_conf dev_conf;
11052 : : uint64_t port_offloads;
11053 : : uint64_t queue_offloads;
11054 : : uint16_t nb_rx_queues;
11055 : : int q;
11056 : : int ret;
11057 : :
11058 : 0 : printf("Rx Offloading Configuration of port %d :\n", port_id);
11059 : :
11060 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11061 : 0 : if (ret != 0)
11062 : 0 : return;
11063 : :
11064 : 0 : port_offloads = dev_conf.rxmode.offloads;
11065 : : printf(" Port :");
11066 : 0 : print_rx_offloads(port_offloads);
11067 : : printf("\n");
11068 : :
11069 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11070 : 0 : if (ret != 0)
11071 : : return;
11072 : :
11073 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11074 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11075 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11076 : : printf(" Queue[%2d] :", q);
11077 : 0 : print_rx_offloads(queue_offloads);
11078 : : printf("\n");
11079 : : }
11080 : : printf("\n");
11081 : : }
11082 : :
11083 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11084 : : .f = cmd_rx_offload_get_configuration_parsed,
11085 : : .data = NULL,
11086 : : .help_str = "show port <port_id> rx_offload configuration",
11087 : : .tokens = {
11088 : : (void *)&cmd_rx_offload_get_configuration_show,
11089 : : (void *)&cmd_rx_offload_get_configuration_port,
11090 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11091 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11092 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11093 : : NULL,
11094 : : }
11095 : : };
11096 : :
11097 : : /* Enable/Disable a per port offloading */
11098 : : struct cmd_config_per_port_rx_offload_result {
11099 : : cmdline_fixed_string_t port;
11100 : : cmdline_fixed_string_t config;
11101 : : portid_t port_id;
11102 : : cmdline_fixed_string_t rx_offload;
11103 : : cmdline_fixed_string_t offload;
11104 : : cmdline_fixed_string_t on_off;
11105 : : };
11106 : :
11107 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11108 : : TOKEN_STRING_INITIALIZER
11109 : : (struct cmd_config_per_port_rx_offload_result,
11110 : : port, "port");
11111 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11112 : : TOKEN_STRING_INITIALIZER
11113 : : (struct cmd_config_per_port_rx_offload_result,
11114 : : config, "config");
11115 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11116 : : TOKEN_NUM_INITIALIZER
11117 : : (struct cmd_config_per_port_rx_offload_result,
11118 : : port_id, RTE_UINT16);
11119 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11120 : : TOKEN_STRING_INITIALIZER
11121 : : (struct cmd_config_per_port_rx_offload_result,
11122 : : rx_offload, "rx_offload");
11123 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11124 : : TOKEN_STRING_INITIALIZER
11125 : : (struct cmd_config_per_port_rx_offload_result,
11126 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11127 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11128 : : "vlan_filter#vlan_extend#"
11129 : : "scatter#buffer_split#timestamp#security#"
11130 : : "keep_crc#rss_hash");
11131 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11132 : : TOKEN_STRING_INITIALIZER
11133 : : (struct cmd_config_per_port_rx_offload_result,
11134 : : on_off, "on#off");
11135 : :
11136 : : static uint64_t
11137 : 0 : search_rx_offload(const char *name)
11138 : : {
11139 : : uint64_t single_offload;
11140 : : const char *single_name;
11141 : : int found = 0;
11142 : : unsigned int bit;
11143 : :
11144 : : single_offload = 1;
11145 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11146 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11147 : 0 : if (!strcasecmp(single_name, name)) {
11148 : : found = 1;
11149 : : break;
11150 : : }
11151 : 0 : single_offload <<= 1;
11152 : : }
11153 : :
11154 : 0 : if (found)
11155 : 0 : return single_offload;
11156 : :
11157 : : return 0;
11158 : : }
11159 : :
11160 : : static void
11161 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11162 : : {
11163 : : struct rte_eth_dev_info dev_info;
11164 : 0 : struct rte_port *port = &ports[port_id];
11165 : : uint16_t nb_rx_queues;
11166 : : uint64_t offload;
11167 : : int q;
11168 : : int ret;
11169 : :
11170 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11171 : 0 : fprintf(stderr,
11172 : : "Error: Can't config offload when Port %d is not stopped\n",
11173 : : port_id);
11174 : 0 : return;
11175 : : }
11176 : :
11177 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11178 : 0 : if (ret != 0)
11179 : : return;
11180 : :
11181 : 0 : if (!strcmp(name, "all")) {
11182 : 0 : offload = dev_info.rx_offload_capa;
11183 : : } else {
11184 : 0 : offload = search_rx_offload(name);
11185 : 0 : if (offload == 0) {
11186 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11187 : 0 : return;
11188 : : }
11189 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11190 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11191 : : port_id, name);
11192 : 0 : return;
11193 : : }
11194 : : }
11195 : :
11196 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11197 : 0 : if (on) {
11198 : 0 : port->dev_conf.rxmode.offloads |= offload;
11199 : 0 : for (q = 0; q < nb_rx_queues; q++)
11200 : 0 : port->rxq[q].conf.offloads |= offload;
11201 : : } else {
11202 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11203 : 0 : for (q = 0; q < nb_rx_queues; q++)
11204 : 0 : port->rxq[q].conf.offloads &= ~offload;
11205 : : }
11206 : :
11207 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11208 : : }
11209 : :
11210 : : static void
11211 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11212 : : __rte_unused struct cmdline *cl,
11213 : : __rte_unused void *data)
11214 : : {
11215 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11216 : : bool on;
11217 : :
11218 : 0 : on = strcmp(res->on_off, "on") == 0;
11219 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11220 : 0 : }
11221 : :
11222 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11223 : : .f = cmd_config_per_port_rx_offload_parsed,
11224 : : .data = NULL,
11225 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11226 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11227 : : "macsec_strip|vlan_filter|vlan_extend|"
11228 : : "scatter|buffer_split|timestamp|security|"
11229 : : "keep_crc|rss_hash on|off",
11230 : : .tokens = {
11231 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11232 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11233 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11234 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11235 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11236 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11237 : : NULL,
11238 : : }
11239 : : };
11240 : :
11241 : : /* Enable/Disable all port Rx offloading */
11242 : : struct cmd_config_all_port_rx_offload_result {
11243 : : cmdline_fixed_string_t port;
11244 : : cmdline_fixed_string_t config;
11245 : : cmdline_fixed_string_t port_all;
11246 : : cmdline_fixed_string_t rx_offload;
11247 : : cmdline_fixed_string_t offload;
11248 : : cmdline_fixed_string_t on_off;
11249 : : };
11250 : :
11251 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
11252 : : TOKEN_STRING_INITIALIZER
11253 : : (struct cmd_config_all_port_rx_offload_result,
11254 : : port, "port");
11255 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
11256 : : TOKEN_STRING_INITIALIZER
11257 : : (struct cmd_config_all_port_rx_offload_result,
11258 : : config, "config");
11259 : :
11260 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
11261 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
11262 : : port_all, "all");
11263 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
11264 : : TOKEN_STRING_INITIALIZER
11265 : : (struct cmd_config_all_port_rx_offload_result,
11266 : : rx_offload, "rx_offload");
11267 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
11268 : : TOKEN_STRING_INITIALIZER
11269 : : (struct cmd_config_all_port_rx_offload_result,
11270 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11271 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11272 : : "vlan_filter#vlan_extend#"
11273 : : "scatter#buffer_split#timestamp#security#"
11274 : : "keep_crc#rss_hash");
11275 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
11276 : : TOKEN_STRING_INITIALIZER
11277 : : (struct cmd_config_all_port_rx_offload_result,
11278 : : on_off, "on#off");
11279 : :
11280 : : static void
11281 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
11282 : : __rte_unused struct cmdline *cl,
11283 : : __rte_unused void *data)
11284 : : {
11285 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
11286 : : bool on_off;
11287 : : portid_t i;
11288 : :
11289 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11290 : 0 : RTE_ETH_FOREACH_DEV(i)
11291 : 0 : config_port_rx_offload(i, res->offload, on_off);
11292 : :
11293 : 0 : }
11294 : :
11295 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
11296 : : .f = cmd_config_all_port_rx_offload_parsed,
11297 : : .data = NULL,
11298 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
11299 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11300 : : "macsec_strip|vlan_filter|vlan_extend|"
11301 : : "scatter|buffer_split|timestamp|security|"
11302 : : "keep_crc|rss_hash on|off",
11303 : : .tokens = {
11304 : : (void *)&cmd_config_all_port_rx_offload_result_port,
11305 : : (void *)&cmd_config_all_port_rx_offload_result_config,
11306 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
11307 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
11308 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
11309 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
11310 : : NULL,
11311 : : }
11312 : : };
11313 : :
11314 : : /* Enable/Disable a per queue offloading */
11315 : : struct cmd_config_per_queue_rx_offload_result {
11316 : : cmdline_fixed_string_t port;
11317 : : portid_t port_id;
11318 : : cmdline_fixed_string_t rxq;
11319 : : uint16_t queue_id;
11320 : : cmdline_fixed_string_t rx_offload;
11321 : : cmdline_fixed_string_t offload;
11322 : : cmdline_fixed_string_t on_off;
11323 : : };
11324 : :
11325 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
11326 : : TOKEN_STRING_INITIALIZER
11327 : : (struct cmd_config_per_queue_rx_offload_result,
11328 : : port, "port");
11329 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
11330 : : TOKEN_NUM_INITIALIZER
11331 : : (struct cmd_config_per_queue_rx_offload_result,
11332 : : port_id, RTE_UINT16);
11333 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
11334 : : TOKEN_STRING_INITIALIZER
11335 : : (struct cmd_config_per_queue_rx_offload_result,
11336 : : rxq, "rxq");
11337 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
11338 : : TOKEN_NUM_INITIALIZER
11339 : : (struct cmd_config_per_queue_rx_offload_result,
11340 : : queue_id, RTE_UINT16);
11341 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
11342 : : TOKEN_STRING_INITIALIZER
11343 : : (struct cmd_config_per_queue_rx_offload_result,
11344 : : rx_offload, "rx_offload");
11345 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
11346 : : TOKEN_STRING_INITIALIZER
11347 : : (struct cmd_config_per_queue_rx_offload_result,
11348 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11349 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11350 : : "vlan_filter#vlan_extend#"
11351 : : "scatter#buffer_split#timestamp#security#keep_crc");
11352 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
11353 : : TOKEN_STRING_INITIALIZER
11354 : : (struct cmd_config_per_queue_rx_offload_result,
11355 : : on_off, "on#off");
11356 : :
11357 : : static void
11358 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
11359 : : __rte_unused struct cmdline *cl,
11360 : : __rte_unused void *data)
11361 : : {
11362 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
11363 : : struct rte_eth_dev_info dev_info;
11364 : 0 : portid_t port_id = res->port_id;
11365 : 0 : uint16_t queue_id = res->queue_id;
11366 : 0 : struct rte_port *port = &ports[port_id];
11367 : : uint64_t offload;
11368 : : int ret;
11369 : :
11370 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11371 : 0 : fprintf(stderr,
11372 : : "Error: Can't config offload when Port %d is not stopped\n",
11373 : : port_id);
11374 : 0 : return;
11375 : : }
11376 : :
11377 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11378 : 0 : if (ret != 0)
11379 : : return;
11380 : :
11381 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
11382 : 0 : fprintf(stderr,
11383 : : "Error: input queue_id should be 0 ... %d\n",
11384 : 0 : dev_info.nb_rx_queues - 1);
11385 : 0 : return;
11386 : : }
11387 : :
11388 : 0 : if (!strcmp(res->offload, "all")) {
11389 : 0 : offload = dev_info.rx_queue_offload_capa;
11390 : : } else {
11391 : 0 : offload = search_rx_offload(res->offload);
11392 : 0 : if (offload == 0) {
11393 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11394 : 0 : return;
11395 : : }
11396 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
11397 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11398 : : port_id, res->offload);
11399 : 0 : return;
11400 : : }
11401 : : }
11402 : :
11403 : 0 : if (!strcmp(res->on_off, "on"))
11404 : 0 : port->rxq[queue_id].conf.offloads |= offload;
11405 : : else
11406 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
11407 : :
11408 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11409 : : }
11410 : :
11411 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
11412 : : .f = cmd_config_per_queue_rx_offload_parsed,
11413 : : .data = NULL,
11414 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
11415 : : "all|vlan_strip|ipv4_cksum|"
11416 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11417 : : "macsec_strip|vlan_filter|vlan_extend|"
11418 : : "scatter|buffer_split|timestamp|security|"
11419 : : "keep_crc on|off",
11420 : : .tokens = {
11421 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
11422 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
11423 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
11424 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
11425 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
11426 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
11427 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
11428 : : NULL,
11429 : : }
11430 : : };
11431 : :
11432 : : /* Get Tx offloads capabilities */
11433 : : struct cmd_tx_offload_get_capa_result {
11434 : : cmdline_fixed_string_t show;
11435 : : cmdline_fixed_string_t port;
11436 : : portid_t port_id;
11437 : : cmdline_fixed_string_t tx_offload;
11438 : : cmdline_fixed_string_t capabilities;
11439 : : };
11440 : :
11441 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
11442 : : TOKEN_STRING_INITIALIZER
11443 : : (struct cmd_tx_offload_get_capa_result,
11444 : : show, "show");
11445 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
11446 : : TOKEN_STRING_INITIALIZER
11447 : : (struct cmd_tx_offload_get_capa_result,
11448 : : port, "port");
11449 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
11450 : : TOKEN_NUM_INITIALIZER
11451 : : (struct cmd_tx_offload_get_capa_result,
11452 : : port_id, RTE_UINT16);
11453 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
11454 : : TOKEN_STRING_INITIALIZER
11455 : : (struct cmd_tx_offload_get_capa_result,
11456 : : tx_offload, "tx_offload");
11457 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
11458 : : TOKEN_STRING_INITIALIZER
11459 : : (struct cmd_tx_offload_get_capa_result,
11460 : : capabilities, "capabilities");
11461 : :
11462 : : static void
11463 : 0 : print_tx_offloads(uint64_t offloads)
11464 : : {
11465 : : uint64_t single_offload;
11466 : : int begin;
11467 : : int end;
11468 : : int bit;
11469 : :
11470 : 0 : if (offloads == 0)
11471 : : return;
11472 : :
11473 : : begin = rte_ctz64(offloads);
11474 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11475 : :
11476 : 0 : single_offload = 1ULL << begin;
11477 : 0 : for (bit = begin; bit < end; bit++) {
11478 : 0 : if (offloads & single_offload)
11479 : 0 : printf(" %s",
11480 : : rte_eth_dev_tx_offload_name(single_offload));
11481 : 0 : single_offload <<= 1;
11482 : : }
11483 : : }
11484 : :
11485 : : static void
11486 : 0 : cmd_tx_offload_get_capa_parsed(
11487 : : void *parsed_result,
11488 : : __rte_unused struct cmdline *cl,
11489 : : __rte_unused void *data)
11490 : : {
11491 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
11492 : : struct rte_eth_dev_info dev_info;
11493 : 0 : portid_t port_id = res->port_id;
11494 : : uint64_t queue_offloads;
11495 : : uint64_t port_offloads;
11496 : : int ret;
11497 : :
11498 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11499 : 0 : if (ret != 0)
11500 : 0 : return;
11501 : :
11502 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
11503 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
11504 : :
11505 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
11506 : : printf(" Per Queue :");
11507 : 0 : print_tx_offloads(queue_offloads);
11508 : :
11509 : : printf("\n");
11510 : : printf(" Per Port :");
11511 : 0 : print_tx_offloads(port_offloads);
11512 : : printf("\n\n");
11513 : : }
11514 : :
11515 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
11516 : : .f = cmd_tx_offload_get_capa_parsed,
11517 : : .data = NULL,
11518 : : .help_str = "show port <port_id> tx_offload capabilities",
11519 : : .tokens = {
11520 : : (void *)&cmd_tx_offload_get_capa_show,
11521 : : (void *)&cmd_tx_offload_get_capa_port,
11522 : : (void *)&cmd_tx_offload_get_capa_port_id,
11523 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
11524 : : (void *)&cmd_tx_offload_get_capa_capabilities,
11525 : : NULL,
11526 : : }
11527 : : };
11528 : :
11529 : : /* Get Tx offloads configuration */
11530 : : struct cmd_tx_offload_get_configuration_result {
11531 : : cmdline_fixed_string_t show;
11532 : : cmdline_fixed_string_t port;
11533 : : portid_t port_id;
11534 : : cmdline_fixed_string_t tx_offload;
11535 : : cmdline_fixed_string_t configuration;
11536 : : };
11537 : :
11538 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
11539 : : TOKEN_STRING_INITIALIZER
11540 : : (struct cmd_tx_offload_get_configuration_result,
11541 : : show, "show");
11542 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
11543 : : TOKEN_STRING_INITIALIZER
11544 : : (struct cmd_tx_offload_get_configuration_result,
11545 : : port, "port");
11546 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
11547 : : TOKEN_NUM_INITIALIZER
11548 : : (struct cmd_tx_offload_get_configuration_result,
11549 : : port_id, RTE_UINT16);
11550 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
11551 : : TOKEN_STRING_INITIALIZER
11552 : : (struct cmd_tx_offload_get_configuration_result,
11553 : : tx_offload, "tx_offload");
11554 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
11555 : : TOKEN_STRING_INITIALIZER
11556 : : (struct cmd_tx_offload_get_configuration_result,
11557 : : configuration, "configuration");
11558 : :
11559 : : static void
11560 : 0 : cmd_tx_offload_get_configuration_parsed(
11561 : : void *parsed_result,
11562 : : __rte_unused struct cmdline *cl,
11563 : : __rte_unused void *data)
11564 : : {
11565 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
11566 : : struct rte_eth_dev_info dev_info;
11567 : 0 : portid_t port_id = res->port_id;
11568 : 0 : struct rte_port *port = &ports[port_id];
11569 : : struct rte_eth_conf dev_conf;
11570 : : uint64_t port_offloads;
11571 : : uint64_t queue_offloads;
11572 : : uint16_t nb_tx_queues;
11573 : : int q;
11574 : : int ret;
11575 : :
11576 : 0 : printf("Tx Offloading Configuration of port %d :\n", port_id);
11577 : :
11578 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11579 : 0 : if (ret != 0)
11580 : 0 : return;
11581 : :
11582 : 0 : port_offloads = dev_conf.txmode.offloads;
11583 : : printf(" Port :");
11584 : 0 : print_tx_offloads(port_offloads);
11585 : : printf("\n");
11586 : :
11587 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11588 : 0 : if (ret != 0)
11589 : : return;
11590 : :
11591 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11592 : 0 : for (q = 0; q < nb_tx_queues; q++) {
11593 : 0 : queue_offloads = port->txq[q].conf.offloads;
11594 : : printf(" Queue[%2d] :", q);
11595 : 0 : print_tx_offloads(queue_offloads);
11596 : : printf("\n");
11597 : : }
11598 : : printf("\n");
11599 : : }
11600 : :
11601 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
11602 : : .f = cmd_tx_offload_get_configuration_parsed,
11603 : : .data = NULL,
11604 : : .help_str = "show port <port_id> tx_offload configuration",
11605 : : .tokens = {
11606 : : (void *)&cmd_tx_offload_get_configuration_show,
11607 : : (void *)&cmd_tx_offload_get_configuration_port,
11608 : : (void *)&cmd_tx_offload_get_configuration_port_id,
11609 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
11610 : : (void *)&cmd_tx_offload_get_configuration_configuration,
11611 : : NULL,
11612 : : }
11613 : : };
11614 : :
11615 : : /* Enable/Disable a per port offloading */
11616 : : struct cmd_config_per_port_tx_offload_result {
11617 : : cmdline_fixed_string_t port;
11618 : : cmdline_fixed_string_t config;
11619 : : portid_t port_id;
11620 : : cmdline_fixed_string_t tx_offload;
11621 : : cmdline_fixed_string_t offload;
11622 : : cmdline_fixed_string_t on_off;
11623 : : };
11624 : :
11625 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
11626 : : TOKEN_STRING_INITIALIZER
11627 : : (struct cmd_config_per_port_tx_offload_result,
11628 : : port, "port");
11629 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
11630 : : TOKEN_STRING_INITIALIZER
11631 : : (struct cmd_config_per_port_tx_offload_result,
11632 : : config, "config");
11633 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
11634 : : TOKEN_NUM_INITIALIZER
11635 : : (struct cmd_config_per_port_tx_offload_result,
11636 : : port_id, RTE_UINT16);
11637 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
11638 : : TOKEN_STRING_INITIALIZER
11639 : : (struct cmd_config_per_port_tx_offload_result,
11640 : : tx_offload, "tx_offload");
11641 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
11642 : : TOKEN_STRING_INITIALIZER
11643 : : (struct cmd_config_per_port_tx_offload_result,
11644 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11645 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11646 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11647 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11648 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11649 : : "send_on_timestamp");
11650 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
11651 : : TOKEN_STRING_INITIALIZER
11652 : : (struct cmd_config_per_port_tx_offload_result,
11653 : : on_off, "on#off");
11654 : :
11655 : : static uint64_t
11656 : 0 : search_tx_offload(const char *name)
11657 : : {
11658 : : uint64_t single_offload;
11659 : : const char *single_name;
11660 : : int found = 0;
11661 : : unsigned int bit;
11662 : :
11663 : : single_offload = 1;
11664 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11665 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
11666 : 0 : if (single_name == NULL)
11667 : : break;
11668 : 0 : if (!strcasecmp(single_name, name)) {
11669 : : found = 1;
11670 : : break;
11671 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
11672 : : break;
11673 : 0 : single_offload <<= 1;
11674 : : }
11675 : :
11676 : 0 : if (found)
11677 : 0 : return single_offload;
11678 : :
11679 : : return 0;
11680 : : }
11681 : :
11682 : : static void
11683 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
11684 : : {
11685 : : struct rte_eth_dev_info dev_info;
11686 : 0 : struct rte_port *port = &ports[port_id];
11687 : : uint16_t nb_tx_queues;
11688 : : uint64_t offload;
11689 : : int q;
11690 : : int ret;
11691 : :
11692 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11693 : 0 : fprintf(stderr,
11694 : : "Error: Can't config offload when Port %d is not stopped\n",
11695 : : port_id);
11696 : 0 : return;
11697 : : }
11698 : :
11699 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11700 : 0 : if (ret != 0)
11701 : : return;
11702 : :
11703 : 0 : if (!strcmp(name, "all")) {
11704 : 0 : offload = dev_info.tx_offload_capa;
11705 : : } else {
11706 : 0 : offload = search_tx_offload(name);
11707 : 0 : if (offload == 0) {
11708 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11709 : 0 : return;
11710 : : }
11711 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
11712 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11713 : : port_id, name);
11714 : 0 : return;
11715 : : }
11716 : : }
11717 : :
11718 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11719 : 0 : if (on) {
11720 : 0 : port->dev_conf.txmode.offloads |= offload;
11721 : 0 : for (q = 0; q < nb_tx_queues; q++)
11722 : 0 : port->txq[q].conf.offloads |= offload;
11723 : : } else {
11724 : 0 : port->dev_conf.txmode.offloads &= ~offload;
11725 : 0 : for (q = 0; q < nb_tx_queues; q++)
11726 : 0 : port->txq[q].conf.offloads &= ~offload;
11727 : : }
11728 : :
11729 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11730 : : }
11731 : :
11732 : : static void
11733 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
11734 : : __rte_unused struct cmdline *cl,
11735 : : __rte_unused void *data)
11736 : : {
11737 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
11738 : : bool on;
11739 : :
11740 : 0 : on = strcmp(res->on_off, "on") == 0;
11741 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
11742 : 0 : }
11743 : :
11744 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
11745 : : .f = cmd_config_per_port_tx_offload_parsed,
11746 : : .data = NULL,
11747 : : .help_str = "port config <port_id> tx_offload "
11748 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11749 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11750 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11751 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11752 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11753 : : "send_on_timestamp on|off",
11754 : : .tokens = {
11755 : : (void *)&cmd_config_per_port_tx_offload_result_port,
11756 : : (void *)&cmd_config_per_port_tx_offload_result_config,
11757 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
11758 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
11759 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
11760 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
11761 : : NULL,
11762 : : }
11763 : : };
11764 : :
11765 : : /* Enable/Disable all port Tx offloading */
11766 : : struct cmd_config_all_port_tx_offload_result {
11767 : : cmdline_fixed_string_t port;
11768 : : cmdline_fixed_string_t config;
11769 : : cmdline_fixed_string_t port_all;
11770 : : cmdline_fixed_string_t tx_offload;
11771 : : cmdline_fixed_string_t offload;
11772 : : cmdline_fixed_string_t on_off;
11773 : : };
11774 : :
11775 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
11776 : : TOKEN_STRING_INITIALIZER
11777 : : (struct cmd_config_all_port_tx_offload_result,
11778 : : port, "port");
11779 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
11780 : : TOKEN_STRING_INITIALIZER
11781 : : (struct cmd_config_all_port_tx_offload_result,
11782 : : config, "config");
11783 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
11784 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
11785 : : port_all, "all");
11786 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
11787 : : TOKEN_STRING_INITIALIZER
11788 : : (struct cmd_config_all_port_tx_offload_result,
11789 : : tx_offload, "tx_offload");
11790 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
11791 : : TOKEN_STRING_INITIALIZER
11792 : : (struct cmd_config_all_port_tx_offload_result,
11793 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11794 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11795 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11796 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11797 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11798 : : "send_on_timestamp");
11799 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
11800 : : TOKEN_STRING_INITIALIZER
11801 : : (struct cmd_config_all_port_tx_offload_result,
11802 : : on_off, "on#off");
11803 : :
11804 : : static void
11805 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
11806 : : __rte_unused struct cmdline *cl,
11807 : : __rte_unused void *data)
11808 : : {
11809 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
11810 : : portid_t i;
11811 : : bool on_off;
11812 : :
11813 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11814 : 0 : RTE_ETH_FOREACH_DEV(i)
11815 : 0 : config_port_tx_offload(i, res->offload, on_off);
11816 : 0 : }
11817 : :
11818 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
11819 : : .f = cmd_config_all_port_tx_offload_parsed,
11820 : : .data = NULL,
11821 : : .help_str = "port config all tx_offload "
11822 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11823 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11824 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11825 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11826 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11827 : : "send_on_timestamp on|off",
11828 : : .tokens = {
11829 : : (void *)&cmd_config_all_port_tx_offload_result_port,
11830 : : (void *)&cmd_config_all_port_tx_offload_result_config,
11831 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
11832 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
11833 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
11834 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
11835 : : NULL,
11836 : : }
11837 : : };
11838 : :
11839 : : /* Enable/Disable a per queue offloading */
11840 : : struct cmd_config_per_queue_tx_offload_result {
11841 : : cmdline_fixed_string_t port;
11842 : : portid_t port_id;
11843 : : cmdline_fixed_string_t txq;
11844 : : uint16_t queue_id;
11845 : : cmdline_fixed_string_t tx_offload;
11846 : : cmdline_fixed_string_t offload;
11847 : : cmdline_fixed_string_t on_off;
11848 : : };
11849 : :
11850 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
11851 : : TOKEN_STRING_INITIALIZER
11852 : : (struct cmd_config_per_queue_tx_offload_result,
11853 : : port, "port");
11854 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
11855 : : TOKEN_NUM_INITIALIZER
11856 : : (struct cmd_config_per_queue_tx_offload_result,
11857 : : port_id, RTE_UINT16);
11858 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
11859 : : TOKEN_STRING_INITIALIZER
11860 : : (struct cmd_config_per_queue_tx_offload_result,
11861 : : txq, "txq");
11862 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
11863 : : TOKEN_NUM_INITIALIZER
11864 : : (struct cmd_config_per_queue_tx_offload_result,
11865 : : queue_id, RTE_UINT16);
11866 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
11867 : : TOKEN_STRING_INITIALIZER
11868 : : (struct cmd_config_per_queue_tx_offload_result,
11869 : : tx_offload, "tx_offload");
11870 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
11871 : : TOKEN_STRING_INITIALIZER
11872 : : (struct cmd_config_per_queue_tx_offload_result,
11873 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11874 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11875 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11876 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11877 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
11878 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
11879 : : TOKEN_STRING_INITIALIZER
11880 : : (struct cmd_config_per_queue_tx_offload_result,
11881 : : on_off, "on#off");
11882 : :
11883 : : static void
11884 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
11885 : : __rte_unused struct cmdline *cl,
11886 : : __rte_unused void *data)
11887 : : {
11888 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
11889 : : struct rte_eth_dev_info dev_info;
11890 : 0 : portid_t port_id = res->port_id;
11891 : 0 : uint16_t queue_id = res->queue_id;
11892 : 0 : struct rte_port *port = &ports[port_id];
11893 : : uint64_t offload;
11894 : : int ret;
11895 : :
11896 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11897 : 0 : fprintf(stderr,
11898 : : "Error: Can't config offload when Port %d is not stopped\n",
11899 : : port_id);
11900 : 0 : return;
11901 : : }
11902 : :
11903 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11904 : 0 : if (ret != 0)
11905 : : return;
11906 : :
11907 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
11908 : 0 : fprintf(stderr,
11909 : : "Error: input queue_id should be 0 ... %d\n",
11910 : 0 : dev_info.nb_tx_queues - 1);
11911 : 0 : return;
11912 : : }
11913 : :
11914 : 0 : if (!strcmp(res->offload, "all")) {
11915 : 0 : offload = dev_info.tx_queue_offload_capa;
11916 : : } else {
11917 : 0 : offload = search_tx_offload(res->offload);
11918 : 0 : if (offload == 0) {
11919 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11920 : 0 : return;
11921 : : }
11922 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
11923 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11924 : : port_id, res->offload);
11925 : 0 : return;
11926 : : }
11927 : : }
11928 : :
11929 : 0 : if (!strcmp(res->on_off, "on"))
11930 : 0 : port->txq[queue_id].conf.offloads |= offload;
11931 : : else
11932 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
11933 : :
11934 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11935 : : }
11936 : :
11937 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
11938 : : .f = cmd_config_per_queue_tx_offload_parsed,
11939 : : .data = NULL,
11940 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
11941 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11942 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11943 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11944 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11945 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
11946 : : "on|off",
11947 : : .tokens = {
11948 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
11949 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
11950 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
11951 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
11952 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
11953 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
11954 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
11955 : : NULL,
11956 : : }
11957 : : };
11958 : :
11959 : : /* *** configure tx_metadata for specific port *** */
11960 : : struct cmd_config_tx_metadata_specific_result {
11961 : : cmdline_fixed_string_t port;
11962 : : cmdline_fixed_string_t keyword;
11963 : : uint16_t port_id;
11964 : : cmdline_fixed_string_t item;
11965 : : uint32_t value;
11966 : : };
11967 : :
11968 : : static void
11969 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
11970 : : __rte_unused struct cmdline *cl,
11971 : : __rte_unused void *data)
11972 : : {
11973 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
11974 : :
11975 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11976 : : return;
11977 : 0 : ports[res->port_id].tx_metadata = res->value;
11978 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
11979 : 0 : if (ports[res->port_id].tx_metadata)
11980 : 0 : add_tx_md_callback(res->port_id);
11981 : : else
11982 : 0 : remove_tx_md_callback(res->port_id);
11983 : 0 : rte_flow_dynf_metadata_register();
11984 : : }
11985 : :
11986 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
11987 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11988 : : port, "port");
11989 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
11990 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11991 : : keyword, "config");
11992 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
11993 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11994 : : port_id, RTE_UINT16);
11995 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
11996 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
11997 : : item, "tx_metadata");
11998 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
11999 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12000 : : value, RTE_UINT32);
12001 : :
12002 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12003 : : .f = cmd_config_tx_metadata_specific_parsed,
12004 : : .data = NULL,
12005 : : .help_str = "port config <port_id> tx_metadata <value>",
12006 : : .tokens = {
12007 : : (void *)&cmd_config_tx_metadata_specific_port,
12008 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12009 : : (void *)&cmd_config_tx_metadata_specific_id,
12010 : : (void *)&cmd_config_tx_metadata_specific_item,
12011 : : (void *)&cmd_config_tx_metadata_specific_value,
12012 : : NULL,
12013 : : },
12014 : : };
12015 : :
12016 : : /* *** set dynf *** */
12017 : : struct cmd_config_tx_dynf_specific_result {
12018 : : cmdline_fixed_string_t port;
12019 : : cmdline_fixed_string_t keyword;
12020 : : uint16_t port_id;
12021 : : cmdline_fixed_string_t item;
12022 : : cmdline_fixed_string_t name;
12023 : : cmdline_fixed_string_t value;
12024 : : };
12025 : :
12026 : : static void
12027 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12028 : : __rte_unused struct cmdline *cl,
12029 : : __rte_unused void *data)
12030 : : {
12031 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12032 : : struct rte_mbuf_dynflag desc_flag;
12033 : : int flag;
12034 : : uint64_t old_port_flags;
12035 : :
12036 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12037 : 0 : return;
12038 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12039 : 0 : if (flag <= 0) {
12040 : 0 : if (strlcpy(desc_flag.name, res->name,
12041 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12042 : 0 : fprintf(stderr, "Flag name too long\n");
12043 : 0 : return;
12044 : : }
12045 : 0 : desc_flag.flags = 0;
12046 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12047 : 0 : if (flag < 0) {
12048 : 0 : fprintf(stderr, "Can't register flag\n");
12049 : 0 : return;
12050 : : }
12051 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12052 : : }
12053 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12054 : 0 : if (!strcmp(res->value, "set")) {
12055 : 0 : ports[res->port_id].mbuf_dynf |= 1UL << flag;
12056 : 0 : if (old_port_flags == 0)
12057 : 0 : add_tx_dynf_callback(res->port_id);
12058 : : } else {
12059 : 0 : ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
12060 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12061 : 0 : remove_tx_dynf_callback(res->port_id);
12062 : : }
12063 : : }
12064 : :
12065 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12066 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12067 : : keyword, "port");
12068 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12069 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12070 : : keyword, "config");
12071 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12072 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12073 : : port_id, RTE_UINT16);
12074 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12075 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12076 : : item, "dynf");
12077 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12078 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12079 : : name, NULL);
12080 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12081 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12082 : : value, "set#clear");
12083 : :
12084 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12085 : : .f = cmd_config_dynf_specific_parsed,
12086 : : .data = NULL,
12087 : : .help_str = "port config <port id> dynf <name> set|clear",
12088 : : .tokens = {
12089 : : (void *)&cmd_config_tx_dynf_specific_port,
12090 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12091 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12092 : : (void *)&cmd_config_tx_dynf_specific_item,
12093 : : (void *)&cmd_config_tx_dynf_specific_name,
12094 : : (void *)&cmd_config_tx_dynf_specific_value,
12095 : : NULL,
12096 : : },
12097 : : };
12098 : :
12099 : : /* *** display tx_metadata per port configuration *** */
12100 : : struct cmd_show_tx_metadata_result {
12101 : : cmdline_fixed_string_t cmd_show;
12102 : : cmdline_fixed_string_t cmd_port;
12103 : : cmdline_fixed_string_t cmd_keyword;
12104 : : portid_t cmd_pid;
12105 : : };
12106 : :
12107 : : static void
12108 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12109 : : __rte_unused struct cmdline *cl,
12110 : : __rte_unused void *data)
12111 : : {
12112 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12113 : :
12114 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12115 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12116 : 0 : return;
12117 : : }
12118 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12119 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12120 : 0 : ports[res->cmd_pid].tx_metadata);
12121 : : }
12122 : : }
12123 : :
12124 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12125 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12126 : : cmd_show, "show");
12127 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12128 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12129 : : cmd_port, "port");
12130 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12131 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12132 : : cmd_pid, RTE_UINT16);
12133 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12134 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12135 : : cmd_keyword, "tx_metadata");
12136 : :
12137 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12138 : : .f = cmd_show_tx_metadata_parsed,
12139 : : .data = NULL,
12140 : : .help_str = "show port <port_id> tx_metadata",
12141 : : .tokens = {
12142 : : (void *)&cmd_show_tx_metadata_show,
12143 : : (void *)&cmd_show_tx_metadata_port,
12144 : : (void *)&cmd_show_tx_metadata_pid,
12145 : : (void *)&cmd_show_tx_metadata_keyword,
12146 : : NULL,
12147 : : },
12148 : : };
12149 : :
12150 : : /* *** show fec capability per port configuration *** */
12151 : : struct cmd_show_fec_capability_result {
12152 : : cmdline_fixed_string_t cmd_show;
12153 : : cmdline_fixed_string_t cmd_port;
12154 : : cmdline_fixed_string_t cmd_fec;
12155 : : cmdline_fixed_string_t cmd_keyword;
12156 : : portid_t cmd_pid;
12157 : : };
12158 : :
12159 : : static void
12160 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12161 : : __rte_unused struct cmdline *cl,
12162 : : __rte_unused void *data)
12163 : : {
12164 : : struct cmd_show_fec_capability_result *res = parsed_result;
12165 : : struct rte_eth_fec_capa *speed_fec_capa;
12166 : : unsigned int num;
12167 : : int ret;
12168 : :
12169 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12170 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12171 : 0 : return;
12172 : : }
12173 : :
12174 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12175 : 0 : if (ret == -ENOTSUP) {
12176 : 0 : fprintf(stderr, "Function not implemented\n");
12177 : 0 : return;
12178 : 0 : } else if (ret < 0) {
12179 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12180 : 0 : return;
12181 : : }
12182 : :
12183 : 0 : num = (unsigned int)ret;
12184 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12185 : 0 : if (speed_fec_capa == NULL) {
12186 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12187 : 0 : return;
12188 : : }
12189 : :
12190 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12191 : 0 : if (ret < 0) {
12192 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12193 : 0 : goto out;
12194 : : }
12195 : :
12196 : 0 : show_fec_capability(num, speed_fec_capa);
12197 : 0 : out:
12198 : 0 : free(speed_fec_capa);
12199 : : }
12200 : :
12201 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12202 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12203 : : cmd_show, "show");
12204 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12205 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12206 : : cmd_port, "port");
12207 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12208 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12209 : : cmd_pid, RTE_UINT16);
12210 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12211 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12212 : : cmd_fec, "fec");
12213 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12214 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12215 : : cmd_keyword, "capabilities");
12216 : :
12217 : : static cmdline_parse_inst_t cmd_show_capability = {
12218 : : .f = cmd_show_fec_capability_parsed,
12219 : : .data = NULL,
12220 : : .help_str = "show port <port_id> fec capabilities",
12221 : : .tokens = {
12222 : : (void *)&cmd_show_fec_capability_show,
12223 : : (void *)&cmd_show_fec_capability_port,
12224 : : (void *)&cmd_show_fec_capability_pid,
12225 : : (void *)&cmd_show_fec_capability_fec,
12226 : : (void *)&cmd_show_fec_capability_keyword,
12227 : : NULL,
12228 : : },
12229 : : };
12230 : :
12231 : : /* *** show fec mode per port configuration *** */
12232 : : struct cmd_show_fec_metadata_result {
12233 : : cmdline_fixed_string_t cmd_show;
12234 : : cmdline_fixed_string_t cmd_port;
12235 : : cmdline_fixed_string_t cmd_keyword;
12236 : : portid_t cmd_pid;
12237 : : };
12238 : :
12239 : : static void
12240 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
12241 : : __rte_unused struct cmdline *cl,
12242 : : __rte_unused void *data)
12243 : : {
12244 : : #define FEC_NAME_SIZE 16
12245 : : struct cmd_show_fec_metadata_result *res = parsed_result;
12246 : : uint32_t mode;
12247 : : char buf[FEC_NAME_SIZE];
12248 : : int ret;
12249 : :
12250 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12251 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12252 : 0 : return;
12253 : : }
12254 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
12255 : 0 : if (ret == -ENOTSUP) {
12256 : 0 : fprintf(stderr, "Function not implemented\n");
12257 : 0 : return;
12258 : 0 : } else if (ret < 0) {
12259 : 0 : fprintf(stderr, "Get FEC mode failed\n");
12260 : 0 : return;
12261 : : }
12262 : :
12263 : 0 : switch (mode) {
12264 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
12265 : : strlcpy(buf, "off", sizeof(buf));
12266 : : break;
12267 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
12268 : : strlcpy(buf, "auto", sizeof(buf));
12269 : : break;
12270 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
12271 : : strlcpy(buf, "baser", sizeof(buf));
12272 : : break;
12273 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
12274 : : strlcpy(buf, "rs", sizeof(buf));
12275 : : break;
12276 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
12277 : : strlcpy(buf, "llrs", sizeof(buf));
12278 : : break;
12279 : : default:
12280 : : return;
12281 : : }
12282 : :
12283 : : printf("%s\n", buf);
12284 : : }
12285 : :
12286 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
12287 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12288 : : cmd_show, "show");
12289 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
12290 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12291 : : cmd_port, "port");
12292 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
12293 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
12294 : : cmd_pid, RTE_UINT16);
12295 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
12296 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12297 : : cmd_keyword, "fec_mode");
12298 : :
12299 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
12300 : : .f = cmd_show_fec_mode_parsed,
12301 : : .data = NULL,
12302 : : .help_str = "show port <port_id> fec_mode",
12303 : : .tokens = {
12304 : : (void *)&cmd_show_fec_mode_show,
12305 : : (void *)&cmd_show_fec_mode_port,
12306 : : (void *)&cmd_show_fec_mode_pid,
12307 : : (void *)&cmd_show_fec_mode_keyword,
12308 : : NULL,
12309 : : },
12310 : : };
12311 : :
12312 : : /* *** set fec mode per port configuration *** */
12313 : : struct cmd_set_port_fec_mode {
12314 : : cmdline_fixed_string_t set;
12315 : : cmdline_fixed_string_t port;
12316 : : portid_t port_id;
12317 : : cmdline_fixed_string_t fec_mode;
12318 : : cmdline_fixed_string_t fec_value;
12319 : : };
12320 : :
12321 : : /* Common CLI fields for set fec mode */
12322 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
12323 : : TOKEN_STRING_INITIALIZER
12324 : : (struct cmd_set_port_fec_mode,
12325 : : set, "set");
12326 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
12327 : : TOKEN_STRING_INITIALIZER
12328 : : (struct cmd_set_port_fec_mode,
12329 : : port, "port");
12330 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
12331 : : TOKEN_NUM_INITIALIZER
12332 : : (struct cmd_set_port_fec_mode,
12333 : : port_id, RTE_UINT16);
12334 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
12335 : : TOKEN_STRING_INITIALIZER
12336 : : (struct cmd_set_port_fec_mode,
12337 : : fec_mode, "fec_mode");
12338 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
12339 : : TOKEN_STRING_INITIALIZER
12340 : : (struct cmd_set_port_fec_mode,
12341 : : fec_value, NULL);
12342 : :
12343 : : static void
12344 : 0 : cmd_set_port_fec_mode_parsed(
12345 : : void *parsed_result,
12346 : : __rte_unused struct cmdline *cl,
12347 : : __rte_unused void *data)
12348 : : {
12349 : : struct cmd_set_port_fec_mode *res = parsed_result;
12350 : 0 : uint16_t port_id = res->port_id;
12351 : : uint32_t fec_capa;
12352 : : int ret;
12353 : :
12354 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
12355 : 0 : if (ret < 0) {
12356 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
12357 : : res->fec_value, port_id);
12358 : 0 : return;
12359 : : }
12360 : :
12361 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
12362 : 0 : if (ret == -ENOTSUP) {
12363 : 0 : fprintf(stderr, "Function not implemented\n");
12364 : 0 : return;
12365 : 0 : } else if (ret < 0) {
12366 : 0 : fprintf(stderr, "Set FEC mode failed\n");
12367 : 0 : return;
12368 : : }
12369 : : }
12370 : :
12371 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
12372 : : .f = cmd_set_port_fec_mode_parsed,
12373 : : .data = NULL,
12374 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
12375 : : .tokens = {
12376 : : (void *)&cmd_set_port_fec_mode_set,
12377 : : (void *)&cmd_set_port_fec_mode_port,
12378 : : (void *)&cmd_set_port_fec_mode_port_id,
12379 : : (void *)&cmd_set_port_fec_mode_str,
12380 : : (void *)&cmd_set_port_fec_mode_value,
12381 : : NULL,
12382 : : },
12383 : : };
12384 : :
12385 : : /* *** set available descriptors threshold for an RxQ of a port *** */
12386 : : struct cmd_set_rxq_avail_thresh_result {
12387 : : cmdline_fixed_string_t set;
12388 : : cmdline_fixed_string_t port;
12389 : : uint16_t port_num;
12390 : : cmdline_fixed_string_t rxq;
12391 : : uint16_t rxq_num;
12392 : : cmdline_fixed_string_t avail_thresh;
12393 : : uint8_t avail_thresh_num;
12394 : : };
12395 : :
12396 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
12397 : : __rte_unused struct cmdline *cl,
12398 : : __rte_unused void *data)
12399 : : {
12400 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
12401 : : int ret = 0;
12402 : :
12403 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
12404 : 0 : && (strcmp(res->rxq, "rxq") == 0)
12405 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
12406 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
12407 : 0 : res->avail_thresh_num);
12408 : 0 : if (ret < 0)
12409 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
12410 : :
12411 : 0 : }
12412 : :
12413 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
12414 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12415 : : set, "set");
12416 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
12417 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12418 : : port, "port");
12419 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
12420 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12421 : : port_num, RTE_UINT16);
12422 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
12423 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12424 : : rxq, "rxq");
12425 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
12426 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12427 : : rxq_num, RTE_UINT16);
12428 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
12429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12430 : : avail_thresh, "avail_thresh");
12431 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
12432 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12433 : : avail_thresh_num, RTE_UINT8);
12434 : :
12435 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
12436 : : .f = cmd_set_rxq_avail_thresh_parsed,
12437 : : .data = (void *)0,
12438 : : .help_str =
12439 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
12440 : : "Set available descriptors threshold for Rx queue",
12441 : : .tokens = {
12442 : : (void *)&cmd_set_rxq_avail_thresh_set,
12443 : : (void *)&cmd_set_rxq_avail_thresh_port,
12444 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
12445 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
12446 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
12447 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
12448 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
12449 : : NULL,
12450 : : },
12451 : : };
12452 : :
12453 : : /* show port supported ptypes */
12454 : :
12455 : : /* Common result structure for show port ptypes */
12456 : : struct cmd_show_port_supported_ptypes_result {
12457 : : cmdline_fixed_string_t show;
12458 : : cmdline_fixed_string_t port;
12459 : : portid_t port_id;
12460 : : cmdline_fixed_string_t ptypes;
12461 : : };
12462 : :
12463 : : /* Common CLI fields for show port ptypes */
12464 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
12465 : : TOKEN_STRING_INITIALIZER
12466 : : (struct cmd_show_port_supported_ptypes_result,
12467 : : show, "show");
12468 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
12469 : : TOKEN_STRING_INITIALIZER
12470 : : (struct cmd_show_port_supported_ptypes_result,
12471 : : port, "port");
12472 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
12473 : : TOKEN_NUM_INITIALIZER
12474 : : (struct cmd_show_port_supported_ptypes_result,
12475 : : port_id, RTE_UINT16);
12476 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
12477 : : TOKEN_STRING_INITIALIZER
12478 : : (struct cmd_show_port_supported_ptypes_result,
12479 : : ptypes, "ptypes");
12480 : :
12481 : : static void
12482 : 0 : cmd_show_port_supported_ptypes_parsed(
12483 : : void *parsed_result,
12484 : : __rte_unused struct cmdline *cl,
12485 : : __rte_unused void *data)
12486 : : {
12487 : : #define RSVD_PTYPE_MASK 0xf0000000
12488 : : #define MAX_PTYPES_PER_LAYER 16
12489 : : #define LTYPE_NAMESIZE 32
12490 : : #define PTYPE_NAMESIZE 256
12491 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
12492 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
12493 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
12494 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
12495 : 0 : uint16_t port_id = res->port_id;
12496 : : int ret, i;
12497 : :
12498 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
12499 : 0 : if (ret < 0)
12500 : 0 : return;
12501 : :
12502 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
12503 : :
12504 : 0 : switch (ptype_mask) {
12505 : : case RTE_PTYPE_L2_MASK:
12506 : : strlcpy(ltype, "L2", sizeof(ltype));
12507 : : break;
12508 : : case RTE_PTYPE_L3_MASK:
12509 : : strlcpy(ltype, "L3", sizeof(ltype));
12510 : : break;
12511 : : case RTE_PTYPE_L4_MASK:
12512 : : strlcpy(ltype, "L4", sizeof(ltype));
12513 : : break;
12514 : : case RTE_PTYPE_TUNNEL_MASK:
12515 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
12516 : : break;
12517 : : case RTE_PTYPE_INNER_L2_MASK:
12518 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
12519 : : break;
12520 : : case RTE_PTYPE_INNER_L3_MASK:
12521 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
12522 : : break;
12523 : : case RTE_PTYPE_INNER_L4_MASK:
12524 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
12525 : : break;
12526 : : default:
12527 : : return;
12528 : : }
12529 : :
12530 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
12531 : : ptype_mask, ptypes,
12532 : : MAX_PTYPES_PER_LAYER);
12533 : :
12534 : 0 : if (ret > 0)
12535 : : printf("Supported %s ptypes:\n", ltype);
12536 : : else
12537 : : printf("%s ptypes unsupported\n", ltype);
12538 : :
12539 : 0 : for (i = 0; i < ret; ++i) {
12540 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
12541 : : printf("%s\n", buf);
12542 : : }
12543 : :
12544 : 0 : ptype_mask <<= 4;
12545 : : }
12546 : : }
12547 : :
12548 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
12549 : : .f = cmd_show_port_supported_ptypes_parsed,
12550 : : .data = NULL,
12551 : : .help_str = "show port <port_id> ptypes",
12552 : : .tokens = {
12553 : : (void *)&cmd_show_port_supported_ptypes_show,
12554 : : (void *)&cmd_show_port_supported_ptypes_port,
12555 : : (void *)&cmd_show_port_supported_ptypes_port_id,
12556 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
12557 : : NULL,
12558 : : },
12559 : : };
12560 : :
12561 : : /* *** display rx/tx descriptor status *** */
12562 : : struct cmd_show_rx_tx_desc_status_result {
12563 : : cmdline_fixed_string_t cmd_show;
12564 : : cmdline_fixed_string_t cmd_port;
12565 : : cmdline_fixed_string_t cmd_keyword;
12566 : : cmdline_fixed_string_t cmd_desc;
12567 : : cmdline_fixed_string_t cmd_status;
12568 : : portid_t cmd_pid;
12569 : : portid_t cmd_qid;
12570 : : portid_t cmd_did;
12571 : : };
12572 : :
12573 : : static void
12574 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
12575 : : __rte_unused struct cmdline *cl,
12576 : : __rte_unused void *data)
12577 : : {
12578 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
12579 : : int rc;
12580 : :
12581 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
12582 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12583 : 0 : fprintf(stderr,
12584 : : "Invalid input: port id = %d, queue id = %d\n",
12585 : 0 : res->cmd_pid, res->cmd_qid);
12586 : 0 : return;
12587 : : }
12588 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
12589 : 0 : res->cmd_did);
12590 : 0 : if (rc < 0) {
12591 : 0 : fprintf(stderr,
12592 : : "Invalid input: queue id = %d, desc id = %d\n",
12593 : 0 : res->cmd_qid, res->cmd_did);
12594 : 0 : return;
12595 : : }
12596 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
12597 : : printf("Desc status = AVAILABLE\n");
12598 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
12599 : : printf("Desc status = DONE\n");
12600 : : else
12601 : : printf("Desc status = UNAVAILABLE\n");
12602 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
12603 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12604 : 0 : fprintf(stderr,
12605 : : "Invalid input: port id = %d, queue id = %d\n",
12606 : 0 : res->cmd_pid, res->cmd_qid);
12607 : 0 : return;
12608 : : }
12609 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
12610 : 0 : res->cmd_did);
12611 : 0 : if (rc < 0) {
12612 : 0 : fprintf(stderr,
12613 : : "Invalid input: queue id = %d, desc id = %d\n",
12614 : 0 : res->cmd_qid, res->cmd_did);
12615 : 0 : return;
12616 : : }
12617 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
12618 : : printf("Desc status = FULL\n");
12619 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
12620 : : printf("Desc status = DONE\n");
12621 : : else
12622 : : printf("Desc status = UNAVAILABLE\n");
12623 : : }
12624 : : }
12625 : :
12626 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
12627 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12628 : : cmd_show, "show");
12629 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
12630 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12631 : : cmd_port, "port");
12632 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
12633 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12634 : : cmd_pid, RTE_UINT16);
12635 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
12636 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12637 : : cmd_keyword, "rxq#txq");
12638 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
12639 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12640 : : cmd_qid, RTE_UINT16);
12641 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
12642 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12643 : : cmd_desc, "desc");
12644 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
12645 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12646 : : cmd_did, RTE_UINT16);
12647 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
12648 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12649 : : cmd_status, "status");
12650 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
12651 : : .f = cmd_show_rx_tx_desc_status_parsed,
12652 : : .data = NULL,
12653 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
12654 : : "status",
12655 : : .tokens = {
12656 : : (void *)&cmd_show_rx_tx_desc_status_show,
12657 : : (void *)&cmd_show_rx_tx_desc_status_port,
12658 : : (void *)&cmd_show_rx_tx_desc_status_pid,
12659 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
12660 : : (void *)&cmd_show_rx_tx_desc_status_qid,
12661 : : (void *)&cmd_show_rx_tx_desc_status_desc,
12662 : : (void *)&cmd_show_rx_tx_desc_status_did,
12663 : : (void *)&cmd_show_rx_tx_desc_status_status,
12664 : : NULL,
12665 : : },
12666 : : };
12667 : :
12668 : : /* *** display rx queue desc used count *** */
12669 : : struct cmd_show_rx_queue_desc_used_count_result {
12670 : : cmdline_fixed_string_t cmd_show;
12671 : : cmdline_fixed_string_t cmd_port;
12672 : : cmdline_fixed_string_t cmd_rxq;
12673 : : cmdline_fixed_string_t cmd_desc;
12674 : : cmdline_fixed_string_t cmd_used;
12675 : : cmdline_fixed_string_t cmd_count;
12676 : : portid_t cmd_pid;
12677 : : portid_t cmd_qid;
12678 : : };
12679 : :
12680 : : static void
12681 : 0 : cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
12682 : : __rte_unused struct cmdline *cl,
12683 : : __rte_unused void *data)
12684 : : {
12685 : : struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
12686 : : int rc;
12687 : :
12688 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12689 : 0 : fprintf(stderr,
12690 : : "Invalid input: port id = %d, queue id = %d\n",
12691 : 0 : res->cmd_pid, res->cmd_qid);
12692 : 0 : return;
12693 : : }
12694 : :
12695 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
12696 : 0 : if (rc < 0) {
12697 : 0 : fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
12698 : 0 : return;
12699 : : }
12700 : : printf("Used desc count = %d\n", rc);
12701 : : }
12702 : :
12703 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
12704 : : TOKEN_STRING_INITIALIZER
12705 : : (struct cmd_show_rx_queue_desc_used_count_result,
12706 : : cmd_show, "show");
12707 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
12708 : : TOKEN_STRING_INITIALIZER
12709 : : (struct cmd_show_rx_queue_desc_used_count_result,
12710 : : cmd_port, "port");
12711 : : static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
12712 : : TOKEN_NUM_INITIALIZER
12713 : : (struct cmd_show_rx_queue_desc_used_count_result,
12714 : : cmd_pid, RTE_UINT16);
12715 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
12716 : : TOKEN_STRING_INITIALIZER
12717 : : (struct cmd_show_rx_queue_desc_used_count_result,
12718 : : cmd_rxq, "rxq");
12719 : : static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
12720 : : TOKEN_NUM_INITIALIZER
12721 : : (struct cmd_show_rx_queue_desc_used_count_result,
12722 : : cmd_qid, RTE_UINT16);
12723 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
12724 : : TOKEN_STRING_INITIALIZER
12725 : : (struct cmd_show_rx_queue_desc_used_count_result,
12726 : : cmd_count, "desc");
12727 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
12728 : : TOKEN_STRING_INITIALIZER
12729 : : (struct cmd_show_rx_queue_desc_used_count_result,
12730 : : cmd_count, "used");
12731 : : static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
12732 : : TOKEN_STRING_INITIALIZER
12733 : : (struct cmd_show_rx_queue_desc_used_count_result,
12734 : : cmd_count, "count");
12735 : : static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
12736 : : .f = cmd_show_rx_queue_desc_used_count_parsed,
12737 : : .data = NULL,
12738 : : .help_str = "show port <port_id> rxq <queue_id> desc used count",
12739 : : .tokens = {
12740 : : (void *)&cmd_show_rx_queue_desc_used_count_show,
12741 : : (void *)&cmd_show_rx_queue_desc_used_count_port,
12742 : : (void *)&cmd_show_rx_queue_desc_used_count_pid,
12743 : : (void *)&cmd_show_rx_queue_desc_used_count_rxq,
12744 : : (void *)&cmd_show_rx_queue_desc_used_count_qid,
12745 : : (void *)&cmd_show_rx_queue_desc_used_count_desc,
12746 : : (void *)&cmd_show_rx_queue_desc_used_count_used,
12747 : : (void *)&cmd_show_rx_queue_desc_used_count_count,
12748 : : NULL,
12749 : : },
12750 : : };
12751 : :
12752 : : /* Common result structure for set port ptypes */
12753 : : struct cmd_set_port_ptypes_result {
12754 : : cmdline_fixed_string_t set;
12755 : : cmdline_fixed_string_t port;
12756 : : portid_t port_id;
12757 : : cmdline_fixed_string_t ptype_mask;
12758 : : uint32_t mask;
12759 : : };
12760 : :
12761 : : /* Common CLI fields for set port ptypes */
12762 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
12763 : : TOKEN_STRING_INITIALIZER
12764 : : (struct cmd_set_port_ptypes_result,
12765 : : set, "set");
12766 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
12767 : : TOKEN_STRING_INITIALIZER
12768 : : (struct cmd_set_port_ptypes_result,
12769 : : port, "port");
12770 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
12771 : : TOKEN_NUM_INITIALIZER
12772 : : (struct cmd_set_port_ptypes_result,
12773 : : port_id, RTE_UINT16);
12774 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
12775 : : TOKEN_STRING_INITIALIZER
12776 : : (struct cmd_set_port_ptypes_result,
12777 : : ptype_mask, "ptype_mask");
12778 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
12779 : : TOKEN_NUM_INITIALIZER
12780 : : (struct cmd_set_port_ptypes_result,
12781 : : mask, RTE_UINT32);
12782 : :
12783 : : static void
12784 : 0 : cmd_set_port_ptypes_parsed(
12785 : : void *parsed_result,
12786 : : __rte_unused struct cmdline *cl,
12787 : : __rte_unused void *data)
12788 : 0 : {
12789 : : struct cmd_set_port_ptypes_result *res = parsed_result;
12790 : : #define PTYPE_NAMESIZE 256
12791 : : char ptype_name[PTYPE_NAMESIZE];
12792 : 0 : uint16_t port_id = res->port_id;
12793 : 0 : uint32_t ptype_mask = res->mask;
12794 : : int ret, i;
12795 : :
12796 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
12797 : : NULL, 0);
12798 : 0 : if (ret <= 0) {
12799 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
12800 : : port_id);
12801 : 0 : return;
12802 : : }
12803 : :
12804 : 0 : uint32_t ptypes[ret];
12805 : :
12806 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
12807 : 0 : if (ret < 0) {
12808 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
12809 : : port_id);
12810 : 0 : return;
12811 : : }
12812 : :
12813 : : printf("Successfully set following ptypes for Port %d\n", port_id);
12814 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
12815 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
12816 : : printf("%s\n", ptype_name);
12817 : : }
12818 : :
12819 : 0 : clear_ptypes = false;
12820 : : }
12821 : :
12822 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
12823 : : .f = cmd_set_port_ptypes_parsed,
12824 : : .data = NULL,
12825 : : .help_str = "set port <port_id> ptype_mask <mask>",
12826 : : .tokens = {
12827 : : (void *)&cmd_set_port_ptypes_set,
12828 : : (void *)&cmd_set_port_ptypes_port,
12829 : : (void *)&cmd_set_port_ptypes_port_id,
12830 : : (void *)&cmd_set_port_ptypes_mask_str,
12831 : : (void *)&cmd_set_port_ptypes_mask_u32,
12832 : : NULL,
12833 : : },
12834 : : };
12835 : :
12836 : : /* *** display mac addresses added to a port *** */
12837 : : struct cmd_showport_macs_result {
12838 : : cmdline_fixed_string_t cmd_show;
12839 : : cmdline_fixed_string_t cmd_port;
12840 : : cmdline_fixed_string_t cmd_keyword;
12841 : : portid_t cmd_pid;
12842 : : };
12843 : :
12844 : : static void
12845 : 0 : cmd_showport_macs_parsed(void *parsed_result,
12846 : : __rte_unused struct cmdline *cl,
12847 : : __rte_unused void *data)
12848 : : {
12849 : : struct cmd_showport_macs_result *res = parsed_result;
12850 : :
12851 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
12852 : : return;
12853 : :
12854 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
12855 : 0 : show_macs(res->cmd_pid);
12856 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
12857 : 0 : show_mcast_macs(res->cmd_pid);
12858 : : }
12859 : :
12860 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
12861 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12862 : : cmd_show, "show");
12863 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
12864 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12865 : : cmd_port, "port");
12866 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
12867 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
12868 : : cmd_pid, RTE_UINT16);
12869 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
12870 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12871 : : cmd_keyword, "macs#mcast_macs");
12872 : :
12873 : : static cmdline_parse_inst_t cmd_showport_macs = {
12874 : : .f = cmd_showport_macs_parsed,
12875 : : .data = NULL,
12876 : : .help_str = "show port <port_id> macs|mcast_macs",
12877 : : .tokens = {
12878 : : (void *)&cmd_showport_macs_show,
12879 : : (void *)&cmd_showport_macs_port,
12880 : : (void *)&cmd_showport_macs_pid,
12881 : : (void *)&cmd_showport_macs_keyword,
12882 : : NULL,
12883 : : },
12884 : : };
12885 : :
12886 : : /* *** show flow transfer proxy port ID for the given port *** */
12887 : : struct cmd_show_port_flow_transfer_proxy_result {
12888 : : cmdline_fixed_string_t show;
12889 : : cmdline_fixed_string_t port;
12890 : : portid_t port_id;
12891 : : cmdline_fixed_string_t flow;
12892 : : cmdline_fixed_string_t transfer;
12893 : : cmdline_fixed_string_t proxy;
12894 : : };
12895 : :
12896 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
12897 : : TOKEN_STRING_INITIALIZER
12898 : : (struct cmd_show_port_flow_transfer_proxy_result,
12899 : : show, "show");
12900 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
12901 : : TOKEN_STRING_INITIALIZER
12902 : : (struct cmd_show_port_flow_transfer_proxy_result,
12903 : : port, "port");
12904 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
12905 : : TOKEN_NUM_INITIALIZER
12906 : : (struct cmd_show_port_flow_transfer_proxy_result,
12907 : : port_id, RTE_UINT16);
12908 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
12909 : : TOKEN_STRING_INITIALIZER
12910 : : (struct cmd_show_port_flow_transfer_proxy_result,
12911 : : flow, "flow");
12912 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
12913 : : TOKEN_STRING_INITIALIZER
12914 : : (struct cmd_show_port_flow_transfer_proxy_result,
12915 : : transfer, "transfer");
12916 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
12917 : : TOKEN_STRING_INITIALIZER
12918 : : (struct cmd_show_port_flow_transfer_proxy_result,
12919 : : proxy, "proxy");
12920 : :
12921 : : static void
12922 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
12923 : : __rte_unused struct cmdline *cl,
12924 : : __rte_unused void *data)
12925 : : {
12926 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
12927 : : portid_t proxy_port_id;
12928 : : int ret;
12929 : :
12930 : : printf("\n");
12931 : :
12932 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
12933 : 0 : if (ret != 0) {
12934 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
12935 : : rte_strerror(-ret));
12936 : 0 : return;
12937 : : }
12938 : :
12939 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
12940 : : }
12941 : :
12942 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
12943 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
12944 : : .data = NULL,
12945 : : .help_str = "show port <port_id> flow transfer proxy",
12946 : : .tokens = {
12947 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
12948 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
12949 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
12950 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
12951 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
12952 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
12953 : : NULL,
12954 : : }
12955 : : };
12956 : :
12957 : : /* *** configure port txq affinity value *** */
12958 : : struct cmd_config_tx_affinity_map {
12959 : : cmdline_fixed_string_t port;
12960 : : cmdline_fixed_string_t config;
12961 : : portid_t portid;
12962 : : cmdline_fixed_string_t txq;
12963 : : uint16_t qid;
12964 : : cmdline_fixed_string_t affinity;
12965 : : uint8_t value;
12966 : : };
12967 : :
12968 : : static void
12969 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
12970 : : __rte_unused struct cmdline *cl,
12971 : : __rte_unused void *data)
12972 : : {
12973 : : struct cmd_config_tx_affinity_map *res = parsed_result;
12974 : : int ret;
12975 : :
12976 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
12977 : : return;
12978 : :
12979 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
12980 : : printf("Invalid port id\n");
12981 : 0 : return;
12982 : : }
12983 : :
12984 : 0 : if (strcmp(res->txq, "txq")) {
12985 : : printf("Unknown parameter\n");
12986 : 0 : return;
12987 : : }
12988 : 0 : if (tx_queue_id_is_invalid(res->qid))
12989 : : return;
12990 : :
12991 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
12992 : 0 : if (ret < 0) {
12993 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
12994 : : strerror(-ret));
12995 : 0 : return;
12996 : : }
12997 : :
12998 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
12999 : 0 : if (ret != 0) {
13000 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13001 : : rte_strerror(-ret));
13002 : 0 : return;
13003 : : }
13004 : : }
13005 : :
13006 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13007 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13008 : : port, "port");
13009 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13011 : : config, "config");
13012 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13013 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13014 : : portid, RTE_UINT16);
13015 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13016 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13017 : : txq, "txq");
13018 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13019 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13020 : : qid, RTE_UINT16);
13021 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13022 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13023 : : affinity, "affinity");
13024 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13025 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13026 : : value, RTE_UINT8);
13027 : :
13028 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13029 : : .f = cmd_config_tx_affinity_map_parsed,
13030 : : .data = (void *)0,
13031 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13032 : : .tokens = {
13033 : : (void *)&cmd_config_tx_affinity_map_port,
13034 : : (void *)&cmd_config_tx_affinity_map_config,
13035 : : (void *)&cmd_config_tx_affinity_map_portid,
13036 : : (void *)&cmd_config_tx_affinity_map_txq,
13037 : : (void *)&cmd_config_tx_affinity_map_qid,
13038 : : (void *)&cmd_config_tx_affinity_map_affinity,
13039 : : (void *)&cmd_config_tx_affinity_map_value,
13040 : : NULL,
13041 : : },
13042 : : };
13043 : :
13044 : : /* ******************************************************************************** */
13045 : :
13046 : : /* list of instructions */
13047 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13048 : : (cmdline_parse_inst_t *)&cmd_help_brief,
13049 : : (cmdline_parse_inst_t *)&cmd_help_long,
13050 : : (cmdline_parse_inst_t *)&cmd_quit,
13051 : : (cmdline_parse_inst_t *)&cmd_load_from_file,
13052 : : (cmdline_parse_inst_t *)&cmd_showport,
13053 : : (cmdline_parse_inst_t *)&cmd_showqueue,
13054 : : (cmdline_parse_inst_t *)&cmd_showeeprom,
13055 : : (cmdline_parse_inst_t *)&cmd_showportall,
13056 : : (cmdline_parse_inst_t *)&cmd_representor_info,
13057 : : (cmdline_parse_inst_t *)&cmd_showdevice,
13058 : : (cmdline_parse_inst_t *)&cmd_showcfg,
13059 : : (cmdline_parse_inst_t *)&cmd_showfwdall,
13060 : : (cmdline_parse_inst_t *)&cmd_start,
13061 : : (cmdline_parse_inst_t *)&cmd_start_tx_first,
13062 : : (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13063 : : (cmdline_parse_inst_t *)&cmd_set_link_up,
13064 : : (cmdline_parse_inst_t *)&cmd_set_link_down,
13065 : : (cmdline_parse_inst_t *)&cmd_reset,
13066 : : (cmdline_parse_inst_t *)&cmd_set_numbers,
13067 : : (cmdline_parse_inst_t *)&cmd_set_log,
13068 : : (cmdline_parse_inst_t *)&cmd_set_rxoffs,
13069 : : (cmdline_parse_inst_t *)&cmd_set_rxpkts,
13070 : : (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
13071 : : (cmdline_parse_inst_t *)&cmd_set_txpkts,
13072 : : (cmdline_parse_inst_t *)&cmd_set_txsplit,
13073 : : (cmdline_parse_inst_t *)&cmd_set_txtimes,
13074 : : (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13075 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13076 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13077 : : (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13078 : : (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13079 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13080 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13081 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13082 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13083 : : (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13084 : : (cmdline_parse_inst_t *)&cmd_set_link_check,
13085 : : (cmdline_parse_inst_t *)&cmd_vlan_offload,
13086 : : (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13087 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13088 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13089 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13090 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13091 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13092 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13093 : : (cmdline_parse_inst_t *)&cmd_csum_set,
13094 : : (cmdline_parse_inst_t *)&cmd_csum_show,
13095 : : (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13096 : : (cmdline_parse_inst_t *)&cmd_csum_mac_swap,
13097 : : (cmdline_parse_inst_t *)&cmd_tso_set,
13098 : : (cmdline_parse_inst_t *)&cmd_tso_show,
13099 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13100 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13101 : : #ifdef RTE_LIB_GRO
13102 : : (cmdline_parse_inst_t *)&cmd_gro_enable,
13103 : : (cmdline_parse_inst_t *)&cmd_gro_flush,
13104 : : (cmdline_parse_inst_t *)&cmd_gro_show,
13105 : : #endif
13106 : : #ifdef RTE_LIB_GSO
13107 : : (cmdline_parse_inst_t *)&cmd_gso_enable,
13108 : : (cmdline_parse_inst_t *)&cmd_gso_size,
13109 : : (cmdline_parse_inst_t *)&cmd_gso_show,
13110 : : #endif
13111 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13112 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13113 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13114 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13115 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13116 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13117 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13118 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13119 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13120 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
13121 : : (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13122 : : (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
13123 : : (cmdline_parse_inst_t *)&cmd_config_dcb,
13124 : : (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13125 : : (cmdline_parse_inst_t *)&cmd_stop,
13126 : : (cmdline_parse_inst_t *)&cmd_mac_addr,
13127 : : (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
13128 : : (cmdline_parse_inst_t *)&cmd_set_qmap,
13129 : : (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
13130 : : (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
13131 : : (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
13132 : : (cmdline_parse_inst_t *)&cmd_operate_port,
13133 : : (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13134 : : (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13135 : : (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13136 : : (cmdline_parse_inst_t *)&cmd_operate_detach_device,
13137 : : (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
13138 : : (cmdline_parse_inst_t *)&cmd_config_speed_all,
13139 : : (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13140 : : (cmdline_parse_inst_t *)&cmd_config_loopback_all,
13141 : : (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
13142 : : (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13143 : : (cmdline_parse_inst_t *)&cmd_config_mtu,
13144 : : (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13145 : : (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
13146 : : (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13147 : : (cmdline_parse_inst_t *)&cmd_config_rss,
13148 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
13149 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13150 : : (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
13151 : : (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
13152 : : (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13153 : : (cmdline_parse_inst_t *)&cmd_showport_reta,
13154 : : (cmdline_parse_inst_t *)&cmd_showport_macs,
13155 : : (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
13156 : : (cmdline_parse_inst_t *)&cmd_config_burst,
13157 : : (cmdline_parse_inst_t *)&cmd_config_thresh,
13158 : : (cmdline_parse_inst_t *)&cmd_config_threshold,
13159 : : (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13160 : : (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13161 : : (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13162 : : (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13163 : : (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13164 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13165 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13166 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
13167 : : (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13168 : : (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
13169 : : (cmdline_parse_inst_t *)&cmd_dump,
13170 : : (cmdline_parse_inst_t *)&cmd_dump_one,
13171 : : (cmdline_parse_inst_t *)&cmd_flow,
13172 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
13173 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
13174 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
13175 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
13176 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
13177 : : (cmdline_parse_inst_t *)&cmd_create_port_meter,
13178 : : (cmdline_parse_inst_t *)&cmd_enable_port_meter,
13179 : : (cmdline_parse_inst_t *)&cmd_disable_port_meter,
13180 : : (cmdline_parse_inst_t *)&cmd_del_port_meter,
13181 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
13182 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
13183 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
13184 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
13185 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
13186 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
13187 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
13188 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
13189 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
13190 : : (cmdline_parse_inst_t *)&cmd_mcast_addr,
13191 : : (cmdline_parse_inst_t *)&cmd_mcast_addr_flush,
13192 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13193 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13194 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13195 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13196 : : (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13197 : : (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13198 : : (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13199 : : (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13200 : : (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13201 : : (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13202 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13203 : : (cmdline_parse_inst_t *)&cmd_set_vxlan,
13204 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
13205 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
13206 : : (cmdline_parse_inst_t *)&cmd_set_nvgre,
13207 : : (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
13208 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap,
13209 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
13210 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap,
13211 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
13212 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
13213 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
13214 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
13215 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
13216 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
13217 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
13218 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
13219 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
13220 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
13221 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
13222 : : (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13223 : : (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13224 : : (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
13225 : : (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
13226 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
13227 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
13228 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
13229 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
13230 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
13231 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
13232 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
13233 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
13234 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
13235 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
13236 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
13237 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
13238 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
13239 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
13240 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
13241 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
13242 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
13243 : : (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
13244 : : (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
13245 : : (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
13246 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
13247 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
13248 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
13249 : : (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
13250 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
13251 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
13252 : : (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
13253 : : (cmdline_parse_inst_t *)&cmd_config_all_port_rx_offload,
13254 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
13255 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
13256 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
13257 : : (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
13258 : : (cmdline_parse_inst_t *)&cmd_config_all_port_tx_offload,
13259 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
13260 : : #ifdef RTE_LIB_BPF
13261 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
13262 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
13263 : : #endif
13264 : : (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
13265 : : (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
13266 : : (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
13267 : : (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
13268 : : (cmdline_parse_inst_t *)&cmd_set_raw,
13269 : : (cmdline_parse_inst_t *)&cmd_show_set_raw,
13270 : : (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
13271 : : (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
13272 : : (cmdline_parse_inst_t *)&cmd_show_fec_mode,
13273 : : (cmdline_parse_inst_t *)&cmd_set_fec_mode,
13274 : : (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
13275 : : (cmdline_parse_inst_t *)&cmd_show_capability,
13276 : : (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
13277 : : (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
13278 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_capa,
13279 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_config,
13280 : : (cmdline_parse_inst_t *)&cmd_set_port_cman_config,
13281 : : (cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
13282 : : NULL,
13283 : : };
13284 : :
13285 : : void
13286 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
13287 : : {
13288 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
13289 : 0 : }
13290 : :
13291 : : int
13292 : 0 : init_cmdline(void)
13293 : : {
13294 : : struct testpmd_driver_commands *c;
13295 : : unsigned int count;
13296 : : unsigned int i;
13297 : :
13298 : : /* initialize non-constant commands */
13299 : 0 : cmd_set_fwd_mode_init();
13300 : 0 : cmd_set_fwd_retry_mode_init();
13301 : :
13302 : : count = 0;
13303 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
13304 : 0 : count++;
13305 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13306 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
13307 : 0 : count++;
13308 : : }
13309 : :
13310 : : /* cmdline expects a NULL terminated array */
13311 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
13312 : 0 : if (main_ctx == NULL)
13313 : : return -1;
13314 : :
13315 : : count = 0;
13316 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
13317 : 0 : main_ctx[count] = builtin_ctx[i];
13318 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13319 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
13320 : 0 : main_ctx[count] = c->commands[i].ctx;
13321 : : }
13322 : :
13323 : : return 0;
13324 : : }
13325 : :
13326 : : /* read cmdline commands from file */
13327 : : void
13328 : 0 : cmdline_read_from_file(const char *filename)
13329 : : {
13330 : : struct cmdline *cl;
13331 : :
13332 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13333 : 0 : if (cl == NULL) {
13334 : 0 : fprintf(stderr,
13335 : : "Failed to create file based cmdline context: %s\n",
13336 : : filename);
13337 : 0 : return;
13338 : : }
13339 : :
13340 : 0 : cmdline_interact(cl);
13341 : 0 : cmdline_quit(cl);
13342 : :
13343 : 0 : cmdline_free(cl);
13344 : :
13345 : : printf("Read CLI commands from %s\n", filename);
13346 : : }
13347 : :
13348 : : void
13349 : 0 : prompt_exit(void)
13350 : : {
13351 : 0 : cmdline_quit(testpmd_cl);
13352 : 0 : }
13353 : :
13354 : : /* prompt function, called from main on MAIN lcore */
13355 : : void
13356 : 0 : prompt(void)
13357 : : {
13358 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13359 : 0 : if (testpmd_cl == NULL) {
13360 : 0 : fprintf(stderr,
13361 : : "Failed to create stdin based cmdline context\n");
13362 : 0 : return;
13363 : : }
13364 : :
13365 : 0 : cmdline_interact(testpmd_cl);
13366 : 0 : cmdline_stdin_exit(testpmd_cl);
13367 : : }
13368 : :
13369 : : void
13370 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13371 : : {
13372 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
13373 : : portid_t pid;
13374 : :
13375 : 0 : RTE_ETH_FOREACH_DEV(pid) {
13376 : : /* check if need_reconfig has been set to 1 */
13377 : 0 : if (ports[pid].need_reconfig == 0)
13378 : 0 : ports[pid].need_reconfig = dev;
13379 : : /* check if need_reconfig_queues has been set to 1 */
13380 : 0 : if (ports[pid].need_reconfig_queues == 0)
13381 : 0 : ports[pid].need_reconfig_queues = queue;
13382 : : }
13383 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13384 : : /* check if need_reconfig has been set to 1 */
13385 : 0 : if (ports[id].need_reconfig == 0)
13386 : 0 : ports[id].need_reconfig = dev;
13387 : : /* check if need_reconfig_queues has been set to 1 */
13388 : 0 : if (ports[id].need_reconfig_queues == 0)
13389 : 0 : ports[id].need_reconfig_queues = queue;
13390 : : }
13391 : 0 : }
|