2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #include <vnet/vnet.h>
20 #include <vppinfra/vec.h>
21 #include <vppinfra/error.h>
22 #include <vppinfra/format.h>
23 #include <vppinfra/xxhash.h>
24 #include <vppinfra/linux/sysfs.c>
26 #include <vnet/ethernet/ethernet.h>
27 #include <dpdk/device/dpdk.h>
28 #include <vnet/classify/vnet_classify.h>
29 #include <vnet/mpls/packet.h>
31 #include <dpdk/device/dpdk_priv.h>
35 * @brief CLI for DPDK Abstraction Layer and pcap Tx Trace.
37 * This file contains the source code for CLI for DPDK
38 * Abstraction Layer and pcap Tx Trace.
43 get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd,
44 dpdk_device_config_t ** devconf)
46 dpdk_main_t *dm = &dpdk_main;
47 vnet_hw_interface_t *hw;
48 struct rte_eth_dev_info dev_info;
49 struct rte_pci_device *pci_dev;
51 clib_error_t *error = NULL;
54 if (hw_if_index == (u32) ~ 0)
56 error = clib_error_return (0, "please specify valid interface name");
62 error = clib_error_return (0, "Invalid subport");
66 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
67 *xd = vec_elt_at_index (dm->devices, hw->dev_instance);
69 rte_eth_dev_info_get ((*xd)->port_id, &dev_info);
71 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
74 { /* bonded interface has no pci info */
75 vlib_pci_addr_t pci_addr;
77 pci_addr.domain = pci_dev->addr.domain;
78 pci_addr.bus = pci_dev->addr.bus;
79 pci_addr.slot = pci_dev->addr.devid;
80 pci_addr.function = pci_dev->addr.function;
83 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
87 (*devconf) = pool_elt_at_index (dm->conf->dev_confs, p[0]);
89 (*devconf) = &dm->conf->default_devconf;
95 static inline clib_error_t *
96 pcap_trace_command_internal (vlib_main_t * vm,
97 unformat_input_t * input,
98 vlib_cli_command_t * cmd, int rx_tx)
100 #define PCAP_DEF_PKT_TO_CAPTURE (100)
102 unformat_input_t _line_input, *line_input = &_line_input;
103 dpdk_main_t *dm = &dpdk_main;
105 u8 *chroot_filename = 0;
109 clib_error_t *error = 0;
111 /* Get a line of input. */
112 if (!unformat_user (input, unformat_line_input, line_input))
115 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
117 if (unformat (line_input, "on"))
119 if (dm->pcap[rx_tx].pcap_enable == 0)
125 vlib_cli_output (vm, "pcap tx capture already on...");
130 else if (unformat (line_input, "off"))
132 if (dm->pcap[rx_tx].pcap_enable)
135 (vm, "captured %d pkts...",
136 dm->pcap[rx_tx].pcap_main.n_packets_captured);
137 if (dm->pcap[rx_tx].pcap_main.n_packets_captured)
139 dm->pcap[rx_tx].pcap_main.n_packets_to_capture =
140 dm->pcap[rx_tx].pcap_main.n_packets_captured;
141 error = pcap_write (&dm->pcap[rx_tx].pcap_main);
143 clib_error_report (error);
145 vlib_cli_output (vm, "saved to %s...",
146 dm->pcap[rx_tx].pcap_main.file_name);
149 dm->pcap[rx_tx].pcap_enable = 0;
153 vlib_cli_output (vm, "pcap tx capture already off...");
158 else if (unformat (line_input, "max %d", &max))
160 if (dm->pcap[rx_tx].pcap_enable)
164 "can't change max value while pcap tx capture active...");
168 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
170 else if (unformat (line_input, "intfc %U",
171 unformat_vnet_sw_interface, dm->vnet_main,
172 &dm->pcap[rx_tx].pcap_sw_if_index))
175 else if (unformat (line_input, "intfc any"))
177 dm->pcap[rx_tx].pcap_sw_if_index = 0;
179 else if (unformat (line_input, "file %s", &filename))
181 if (dm->pcap[rx_tx].pcap_enable)
184 (vm, "can't change file while pcap tx capture active...");
189 /* Brain-police user path input */
190 if (strstr ((char *) filename, "..")
191 || index ((char *) filename, '/'))
193 vlib_cli_output (vm, "illegal characters in filename '%s'",
195 vlib_cli_output (vm, "Hint: .. and / are not allowed.");
201 chroot_filename = format (0, "/tmp/%s%c", filename, 0);
204 else if (unformat (line_input, "status"))
206 if (dm->pcap[rx_tx].pcap_sw_if_index == 0)
209 (vm, "max is %d for any interface to file %s",
210 dm->pcap[rx_tx].pcap_main.n_packets_to_capture ?
211 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
212 : PCAP_DEF_PKT_TO_CAPTURE,
213 dm->pcap[rx_tx].pcap_main.file_name ?
214 (u8 *) dm->pcap[rx_tx].pcap_main.file_name :
215 (u8 *) "/tmp/vpe.pcap");
219 vlib_cli_output (vm, "max is %d for interface %U to file %s",
220 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
222 pcap_main.n_packets_to_capture :
223 PCAP_DEF_PKT_TO_CAPTURE,
224 format_vnet_sw_if_index_name, dm->vnet_main,
225 dm->pcap_sw_if_index,
227 pcap_main.file_name ? (u8 *) dm->pcap[rx_tx].
228 pcap_main.file_name : (u8 *) "/tmp/vpe.pcap");
231 if (dm->pcap[rx_tx].pcap_enable == 0)
233 vlib_cli_output (vm, "pcap %s capture is off...",
234 (rx_tx == VLIB_RX) ? "rx" : "tx");
238 vlib_cli_output (vm, "pcap %s capture is on: %d of %d pkts...",
239 (rx_tx == VLIB_RX) ? "rx" : "tx",
240 dm->pcap[rx_tx].pcap_main.n_packets_captured,
242 pcap_main.n_packets_to_capture);
249 error = clib_error_return (0, "unknown input `%U'",
250 format_unformat_error, line_input);
255 unformat_free (line_input);
260 /* Since no error, save configured values. */
263 if (dm->pcap[rx_tx].pcap_main.file_name)
264 vec_free (dm->pcap[rx_tx].pcap_main.file_name);
265 vec_add1 (chroot_filename, 0);
266 dm->pcap[rx_tx].pcap_main.file_name = (char *) chroot_filename;
270 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
274 if (dm->pcap[rx_tx].pcap_main.file_name == 0)
275 dm->pcap[rx_tx].pcap_main.file_name
276 = (char *) format (0, "/tmp/vpe.pcap%c", 0);
278 dm->pcap[rx_tx].pcap_main.n_packets_captured = 0;
279 dm->pcap[rx_tx].pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
280 if (dm->pcap[rx_tx].pcap_main.lock == 0)
281 clib_spinlock_init (&(dm->pcap[rx_tx].pcap_main.lock));
282 dm->pcap[rx_tx].pcap_enable = 1;
283 vlib_cli_output (vm, "pcap %s capture on...",
284 rx_tx == VLIB_RX ? "rx" : "tx");
287 else if (chroot_filename)
288 vec_free (chroot_filename);
293 static clib_error_t *
294 pcap_rx_trace_command_fn (vlib_main_t * vm,
295 unformat_input_t * input, vlib_cli_command_t * cmd)
297 return pcap_trace_command_internal (vm, input, cmd, VLIB_RX);
300 static clib_error_t *
301 pcap_tx_trace_command_fn (vlib_main_t * vm,
302 unformat_input_t * input, vlib_cli_command_t * cmd)
304 return pcap_trace_command_internal (vm, input, cmd, VLIB_TX);
309 * This command is used to start or stop a packet capture, or show
310 * the status of packet capture. Note that both "pcap rx trace" and
311 * "pcap tx trace" are implemented. The command syntax is identical,
312 * simply substitute rx for tx as needed.
314 * This command has the following optional parameters:
316 * - <b>on|off</b> - Used to start or stop a packet capture.
318 * - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
319 * of packets have been received, buffer is flushed to file. Once another
320 * '<em>nn</em>' number of packets have been received, buffer is flushed
321 * to file, overwriting previous write. If not entered, value defaults
322 * to 100. Can only be updated if packet capture is off.
324 * - <b>intfc <interface>|any</b> - Used to specify a given interface,
325 * or use '<em>any</em>' to run packet capture on all interfaces.
326 * '<em>any</em>' is the default if not provided. Settings from a previous
327 * packet capture are preserved, so '<em>any</em>' can be used to reset
328 * the interface setting.
330 * - <b>file <name></b> - Used to specify the output filename. The file will
331 * be placed in the '<em>/tmp</em>' directory, so only the filename is
332 * supported. Directory should not be entered. If file already exists, file
333 * will be overwritten. If no filename is provided, '<em>/tmp/vpe.pcap</em>'
334 * will be used. Can only be updated if packet capture is off.
336 * - <b>status</b> - Displays the current status and configured attributes
337 * associated with a packet capture. If packet capture is in progress,
338 * '<em>status</em>' also will return the number of packets currently in
339 * the local buffer. All additional attributes entered on command line
340 * with '<em>status</em>' will be ingnored and not applied.
343 * Example of how to display the status of a tx packet capture when off:
344 * @cliexstart{pcap tx trace status}
345 * max is 100, for any interface to file /tmp/vpe.pcap
346 * pcap tx capture is off...
348 * Example of how to start a tx packet capture:
349 * @cliexstart{pcap tx trace on max 35 intfc GigabitEthernet0/8/0 file vppTest.pcap}
350 * pcap tx capture on...
352 * Example of how to display the status of a tx packet capture in progress:
353 * @cliexstart{pcap tx trace status}
354 * max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
355 * pcap tx capture is on: 20 of 35 pkts...
357 * Example of how to stop a tx packet capture:
358 * @cliexstart{vppctl pcap tx trace off}
359 * captured 21 pkts...
360 * saved to /tmp/vppTest.pcap...
365 VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = {
366 .path = "pcap tx trace",
368 "pcap tx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
369 .function = pcap_tx_trace_command_fn,
371 VLIB_CLI_COMMAND (pcap_rx_trace_command, static) = {
372 .path = "pcap rx trace",
374 "pcap rx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
375 .function = pcap_rx_trace_command_fn,
380 static clib_error_t *
381 show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
382 vlib_cli_command_t * cmd)
384 struct rte_mempool *rmp;
387 for (i = 0; i < vec_len (dpdk_main.pktmbuf_pools); i++)
389 rmp = dpdk_main.pktmbuf_pools[i];
392 unsigned count = rte_mempool_avail_count (rmp);
393 unsigned free_count = rte_mempool_in_use_count (rmp);
396 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
397 rmp->name, (u32) count, (u32) free_count,
398 (u32) (count + free_count));
402 vlib_cli_output (vm, "rte_mempool is NULL (!)\n");
409 * This command displays statistics of each DPDK mempool.
412 * Example of how to display DPDK buffer data:
413 * @cliexstart{show dpdk buffer}
414 * name="mbuf_pool_socket0" available = 15104 allocated = 1280 total = 16384
418 VLIB_CLI_COMMAND (cmd_show_dpdk_buffer,static) = {
419 .path = "show dpdk buffer",
420 .short_help = "show dpdk buffer",
421 .function = show_dpdk_buffer,
426 static clib_error_t *
427 show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
428 vlib_cli_command_t * cmd)
430 clib_error_t *err = 0;
437 err = clib_sysfs_read ("/proc/sys/fs/pipe-max-size", "%u", &pipe_max_size);
442 if (pipe (fds) == -1)
443 return clib_error_return_unix (0, "pipe");
446 #define F_SETPIPE_SZ (1024 + 7)
449 if (fcntl (fds[1], F_SETPIPE_SZ, pipe_max_size) == -1)
451 err = clib_error_return_unix (0, "fcntl(F_SETPIPE_SZ)");
455 if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1)
457 err = clib_error_return_unix (0, "fcntl(F_SETFL)");
461 if ((f = fdopen (fds[1], "a")) == 0)
463 err = clib_error_return_unix (0, "fdopen");
467 rte_dump_physmem_layout (f);
473 uword len = vec_len (s);
474 vec_resize (s, len + n_try);
476 n = read (fds[0], s + len, n_try);
477 if (n < 0 && errno != EAGAIN)
479 err = clib_error_return_unix (0, "read");
482 _vec_len (s) = len + (n < 0 ? 0 : n);
485 vlib_cli_output (vm, "%v", s);
495 * This command displays DPDK physmem layout
498 * Example of how to display DPDK physmem layout:
499 * @cliexstart{show dpdk physmem}
503 VLIB_CLI_COMMAND (cmd_show_dpdk_physmem,static) = {
504 .path = "show dpdk physmem",
505 .short_help = "show dpdk physmem",
506 .function = show_dpdk_physmem,
511 static clib_error_t *
512 test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
513 vlib_cli_command_t * cmd)
515 static u32 *allocated_buffers;
518 u32 first, actual_alloc;
520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
522 if (unformat (input, "allocate %d", &n_alloc))
524 else if (unformat (input, "free %d", &n_free))
532 if (vec_len (allocated_buffers) < n_free)
533 return clib_error_return (0, "Can't free %d, only %d allocated",
534 n_free, vec_len (allocated_buffers));
536 first = vec_len (allocated_buffers) - n_free;
537 vlib_buffer_free (vm, allocated_buffers + first, n_free);
538 _vec_len (allocated_buffers) = first;
542 first = vec_len (allocated_buffers);
543 vec_validate (allocated_buffers,
544 vec_len (allocated_buffers) + n_alloc - 1);
546 actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
548 _vec_len (allocated_buffers) = first + actual_alloc;
550 if (actual_alloc < n_alloc)
551 vlib_cli_output (vm, "WARNING: only allocated %d buffers",
555 vlib_cli_output (vm, "Currently %d buffers allocated",
556 vec_len (allocated_buffers));
558 if (allocated_buffers && vec_len (allocated_buffers) == 0)
559 vec_free (allocated_buffers);
565 * This command tests the allocation and freeing of DPDK buffers.
566 * If both '<em>allocate</em>' and '<em>free</em>' are entered on the
567 * same command, the '<em>free</em>' is executed first. If no
568 * parameters are provided, this command display how many DPDK buffers
569 * the test command has allocated.
574 * Example of how to display how many DPDK buffer test command has allcoated:
575 * @cliexstart{test dpdk buffer}
576 * Currently 0 buffers allocated
579 * Example of how to allocate DPDK buffers using the test command:
580 * @cliexstart{test dpdk buffer allocate 10}
581 * Currently 10 buffers allocated
584 * Example of how to free DPDK buffers allocated by the test command:
585 * @cliexstart{test dpdk buffer free 10}
586 * Currently 0 buffers allocated
591 VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = {
592 .path = "test dpdk buffer",
593 .short_help = "test dpdk buffer [allocate <nn>] [free <nn>]",
594 .function = test_dpdk_buffer,
599 static clib_error_t *
600 set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
601 vlib_cli_command_t * cmd)
603 unformat_input_t _line_input, *line_input = &_line_input;
604 dpdk_main_t *dm = &dpdk_main;
605 vnet_hw_interface_t *hw;
607 u32 hw_if_index = (u32) ~ 0;
608 u32 nb_rx_desc = (u32) ~ 0;
609 u32 nb_tx_desc = (u32) ~ 0;
610 clib_error_t *error = NULL;
612 if (!unformat_user (input, unformat_line_input, line_input))
615 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
618 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
621 else if (unformat (line_input, "tx %d", &nb_tx_desc))
623 else if (unformat (line_input, "rx %d", &nb_rx_desc))
627 error = clib_error_return (0, "parse error: '%U'",
628 format_unformat_error, line_input);
633 if (hw_if_index == (u32) ~ 0)
635 error = clib_error_return (0, "please specify valid interface name");
639 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
640 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
642 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
645 clib_error_return (0,
646 "number of descriptors can be set only for "
651 if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
652 (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
654 error = clib_error_return (0, "nothing changed");
658 if (nb_rx_desc != (u32) ~ 0)
659 xd->nb_rx_desc = nb_rx_desc;
661 if (nb_tx_desc != (u32) ~ 0)
662 xd->nb_tx_desc = nb_tx_desc;
664 dpdk_device_setup (xd);
666 if (vec_len (xd->errors))
667 return clib_error_return (0, "%U", format_dpdk_device_errors, xd);
670 unformat_free (line_input);
676 * This command sets the number of DPDK '<em>rx</em>' and
677 * '<em>tx</em>' descriptors for the given physical interface. Use
678 * the command '<em>show hardware-interface</em>' to display the
679 * current descriptor allocation.
682 * Example of how to set the DPDK interface descriptors:
683 * @cliexcmd{set dpdk interface descriptors GigabitEthernet0/8/0 rx 512 tx 512}
686 VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = {
687 .path = "set dpdk interface descriptors",
688 .short_help = "set dpdk interface descriptors <interface> [rx <nn>] [tx <nn>]",
689 .function = set_dpdk_if_desc,
694 dpdk_device_queue_sort (void *a1, void *a2)
696 dpdk_device_and_queue_t *dq1 = a1;
697 dpdk_device_and_queue_t *dq2 = a2;
699 if (dq1->device > dq2->device)
701 else if (dq1->device < dq2->device)
703 else if (dq1->queue_id > dq2->queue_id)
705 else if (dq1->queue_id < dq2->queue_id)
712 static clib_error_t *
713 show_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
714 vlib_cli_command_t * cmd)
716 vlib_thread_main_t *tm = vlib_get_thread_main ();
717 dpdk_main_t *dm = &dpdk_main;
718 dpdk_device_and_queue_t *dq;
721 if (tm->n_vlib_mains == 1)
722 vlib_cli_output (vm, "All interfaces are handled by main thread");
724 for (cpu = 0; cpu < vec_len (dm->devices_by_hqos_cpu); cpu++)
726 if (cpu >= dm->hqos_cpu_first_index &&
727 cpu < (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
728 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
729 vlib_worker_threads[cpu].name,
730 vlib_worker_threads[cpu].lcore_id);
732 vec_foreach (dq, dm->devices_by_hqos_cpu[cpu])
734 u32 hw_if_index = dm->devices[dq->device].hw_if_index;
735 vnet_hw_interface_t *hi =
736 vnet_get_hw_interface (dm->vnet_main, hw_if_index);
737 vlib_cli_output (vm, " %v queue %u", hi->name, dq->queue_id);
744 * This command is used to display the thread and core each
745 * DPDK output interface and HQoS queue is assigned too.
748 * Example of how to display the DPDK output interface and HQoS queue placement:
749 * @cliexstart{show dpdk interface hqos placement}
750 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
751 * GigabitEthernet0/8/0 queue 0
752 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
753 * GigabitEthernet0/9/0 queue 0
757 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos_placement, static) = {
758 .path = "show dpdk interface hqos placement",
759 .short_help = "show dpdk interface hqos placement",
760 .function = show_dpdk_if_hqos_placement,
764 static clib_error_t *
765 set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
766 vlib_cli_command_t * cmd)
768 unformat_input_t _line_input, *line_input = &_line_input;
769 dpdk_main_t *dm = &dpdk_main;
770 dpdk_device_and_queue_t *dq;
771 vnet_hw_interface_t *hw;
773 u32 hw_if_index = (u32) ~ 0;
776 clib_error_t *error = NULL;
778 if (!unformat_user (input, unformat_line_input, line_input))
781 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
784 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
787 else if (unformat (line_input, "thread %d", &cpu))
791 error = clib_error_return (0, "parse error: '%U'",
792 format_unformat_error, line_input);
797 if (hw_if_index == (u32) ~ 0)
798 return clib_error_return (0, "please specify valid interface name");
800 if (cpu < dm->hqos_cpu_first_index ||
801 cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
803 error = clib_error_return (0, "please specify valid thread id");
807 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
808 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
810 for (i = 0; i < vec_len (dm->devices_by_hqos_cpu); i++)
812 vec_foreach (dq, dm->devices_by_hqos_cpu[i])
814 if (hw_if_index == dm->devices[dq->device].hw_if_index)
816 if (cpu == i) /* nothing to do */
819 vec_del1 (dm->devices_by_hqos_cpu[i],
820 dq - dm->devices_by_hqos_cpu[i]);
821 vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
823 dq->device = xd->device_index;
825 vec_sort_with_function (dm->devices_by_hqos_cpu[i],
826 dpdk_device_queue_sort);
828 vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
829 dpdk_device_queue_sort);
836 error = clib_error_return (0, "not found");
839 unformat_free (line_input);
845 * This command is used to assign a given DPDK output interface and
846 * HQoS queue to a different thread. This will not create a thread,
847 * so the thread must already exist. Use '<em>/etc/vpp/startup.conf</em>'
848 * for the initial thread creation. See @ref qos_doc for more details.
851 * Example of how to display the DPDK output interface and HQoS queue placement:
852 * @cliexstart{show dpdk interface hqos placement}
853 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
854 * GigabitEthernet0/8/0 queue 0
855 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
856 * GigabitEthernet0/9/0 queue 0
858 * Example of how to assign a DPDK output interface and HQoS queue to a thread:
859 * @cliexcmd{set dpdk interface hqos placement GigabitEthernet0/8/0 thread 2}
862 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_placement, static) = {
863 .path = "set dpdk interface hqos placement",
864 .short_help = "set dpdk interface hqos placement <interface> thread <n>",
865 .function = set_dpdk_if_hqos_placement,
869 static clib_error_t *
870 set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
871 vlib_cli_command_t * cmd)
873 unformat_input_t _line_input, *line_input = &_line_input;
874 dpdk_main_t *dm = &dpdk_main;
875 vnet_hw_interface_t *hw;
877 u32 hw_if_index = (u32) ~ 0;
878 u32 subport_id = (u32) ~ 0;
879 u32 pipe_id = (u32) ~ 0;
880 u32 profile_id = (u32) ~ 0;
882 clib_error_t *error = NULL;
884 if (!unformat_user (input, unformat_line_input, line_input))
887 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
890 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
893 else if (unformat (line_input, "subport %d", &subport_id))
895 else if (unformat (line_input, "pipe %d", &pipe_id))
897 else if (unformat (line_input, "profile %d", &profile_id))
901 error = clib_error_return (0, "parse error: '%U'",
902 format_unformat_error, line_input);
907 if (hw_if_index == (u32) ~ 0)
909 error = clib_error_return (0, "please specify valid interface name");
913 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
914 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
917 rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
921 error = clib_error_return (0, "pipe configuration failed");
926 unformat_free (line_input);
932 * This command is used to change the profile associate with a HQoS pipe. The
933 * '<em><profile_id></em>' is zero based. Use the command
934 * '<em>show dpdk interface hqos</em>' to display the content of each profile.
935 * See @ref qos_doc for more details.
938 * Currently there is not an API to create a new HQoS pipe profile. One is
939 * created by default in the code (search for '<em>hqos_pipe_params_default</em>'').
940 * Additional profiles can be created in code and code recompiled. Then use this
941 * command to assign it.
944 * Example of how to assign a new profile to a HQoS pipe:
945 * @cliexcmd{set dpdk interface hqos pipe GigabitEthernet0/8/0 subport 0 pipe 2 profile 1}
948 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pipe, static) =
950 .path = "set dpdk interface hqos pipe",
951 .short_help = "set dpdk interface hqos pipe <interface> subport <subport_id> pipe <pipe_id> "
952 "profile <profile_id>",
953 .function = set_dpdk_if_hqos_pipe,
957 static clib_error_t *
958 set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
959 vlib_cli_command_t * cmd)
961 unformat_input_t _line_input, *line_input = &_line_input;
962 dpdk_main_t *dm = &dpdk_main;
963 dpdk_device_t *xd = NULL;
964 u32 hw_if_index = (u32) ~ 0;
965 u32 subport_id = (u32) ~ 0;
966 struct rte_sched_subport_params p;
968 clib_error_t *error = NULL;
969 u32 tb_rate = (u32) ~ 0;
970 u32 tb_size = (u32) ~ 0;
971 u32 tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] =
972 { (u32) ~ 0, (u32) ~ 0, (u32) ~ 0, (u32) ~ 0 };
973 u32 tc_period = (u32) ~ 0;
974 dpdk_device_config_t *devconf = NULL;
976 if (!unformat_user (input, unformat_line_input, line_input))
979 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
982 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
985 else if (unformat (line_input, "subport %d", &subport_id))
987 else if (unformat (line_input, "rate %d", &tb_rate))
989 else if (unformat (line_input, "bktsize %d", &tb_size))
991 else if (unformat (line_input, "tc0 %d", &tc_rate[0]))
993 else if (unformat (line_input, "tc1 %d", &tc_rate[1]))
995 else if (unformat (line_input, "tc2 %d", &tc_rate[2]))
997 else if (unformat (line_input, "tc3 %d", &tc_rate[3]))
999 else if (unformat (line_input, "period %d", &tc_period))
1003 error = clib_error_return (0, "parse error: '%U'",
1004 format_unformat_error, line_input);
1009 error = get_hqos (hw_if_index, subport_id, &xd, &devconf);
1013 /* Copy the current values over to local structure. */
1014 memcpy (&p, &devconf->hqos.subport[subport_id], sizeof (p));
1016 /* Update local structure with input values. */
1017 if (tb_rate != (u32) ~ 0)
1019 p.tb_rate = tb_rate;
1020 p.tc_rate[0] = tb_rate;
1021 p.tc_rate[1] = tb_rate;
1022 p.tc_rate[2] = tb_rate;
1023 p.tc_rate[3] = tb_rate;
1025 if (tb_size != (u32) ~ 0)
1027 p.tb_size = tb_size;
1029 if (tc_rate[0] != (u32) ~ 0)
1031 p.tc_rate[0] = tc_rate[0];
1033 if (tc_rate[1] != (u32) ~ 0)
1035 p.tc_rate[1] = tc_rate[1];
1037 if (tc_rate[2] != (u32) ~ 0)
1039 p.tc_rate[2] = tc_rate[2];
1041 if (tc_rate[3] != (u32) ~ 0)
1043 p.tc_rate[3] = tc_rate[3];
1045 if (tc_period != (u32) ~ 0)
1047 p.tc_period = tc_period;
1050 /* Apply changes. */
1051 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
1054 error = clib_error_return (0, "subport configuration failed");
1059 /* Successfully applied, so save of the input values. */
1060 memcpy (&devconf->hqos.subport[subport_id], &p, sizeof (p));
1065 unformat_free (line_input);
1071 * This command is used to set the subport level parameters such as token
1072 * bucket rate (bytes per seconds), token bucket size (bytes), traffic class
1073 * rates (bytes per seconds) and token update period (Milliseconds).
1075 * By default, the '<em>rate</em>' is set to 1250000000 bytes/second (10GbE
1076 * rate) and each of the four traffic classes is set to 100% of the port rate.
1077 * If the '<em>rate</em>' is updated by this command, all four traffic classes
1078 * are assigned the same value. Each of the four traffic classes can be updated
1082 * Example of how modify the subport attributes for a 1GbE link:
1083 * @cliexcmd{set dpdk interface hqos subport GigabitEthernet0/8/0 subport 0 rate 125000000}
1086 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_subport, static) = {
1087 .path = "set dpdk interface hqos subport",
1088 .short_help = "set dpdk interface hqos subport <interface> subport <subport_id> "
1089 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] "
1091 .function = set_dpdk_if_hqos_subport,
1095 static clib_error_t *
1096 set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
1097 vlib_cli_command_t * cmd)
1099 unformat_input_t _line_input, *line_input = &_line_input;
1100 vlib_thread_main_t *tm = vlib_get_thread_main ();
1101 dpdk_main_t *dm = &dpdk_main;
1102 vnet_hw_interface_t *hw;
1104 u32 hw_if_index = (u32) ~ 0;
1106 u32 queue = (u32) ~ 0;
1107 u32 entry = (u32) ~ 0;
1109 clib_error_t *error = NULL;
1111 if (!unformat_user (input, unformat_line_input, line_input))
1114 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1117 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1120 else if (unformat (line_input, "entry %d", &entry))
1122 else if (unformat (line_input, "tc %d", &tc))
1124 else if (unformat (line_input, "queue %d", &queue))
1128 error = clib_error_return (0, "parse error: '%U'",
1129 format_unformat_error, line_input);
1134 if (hw_if_index == (u32) ~ 0)
1136 error = clib_error_return (0, "please specify valid interface name");
1141 error = clib_error_return (0, "invalid entry");
1144 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1146 error = clib_error_return (0, "invalid traffic class");
1149 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1151 error = clib_error_return (0, "invalid traffic class queue");
1155 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1156 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1158 /* Detect the set of worker threads */
1159 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1160 /* Should never happen, shut up Coverity warning */
1163 error = clib_error_return (0, "no worker registrations?");
1167 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1168 int worker_thread_first = tr->first_index;
1169 int worker_thread_count = tr->count;
1171 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1172 for (i = 0; i < worker_thread_count; i++)
1173 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
1176 unformat_free (line_input);
1182 * This command is used to set the traffic class translation table. The
1183 * traffic class translation table is used to map 64 values (0-63) to one of
1184 * four traffic class and one of four HQoS input queue. Use the '<em>show
1185 * dpdk interface hqos</em>' command to display the traffic class translation
1186 * table. See @ref qos_doc for more details.
1188 * This command has the following parameters:
1190 * - <b><interface></b> - Used to specify the output interface.
1192 * - <b>entry <map_val></b> - Mapped value (0-63) to assign traffic class and queue to.
1194 * - <b>tc <tc_id></b> - Traffic class (0-3) to be used by the provided mapped value.
1196 * - <b>queue <queue_id></b> - HQoS input queue (0-3) to be used by the provided mapped value.
1199 * Example of how modify the traffic class translation table:
1200 * @cliexcmd{set dpdk interface hqos tctbl GigabitEthernet0/8/0 entry 16 tc 2 queue 2}
1203 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_tctbl, static) = {
1204 .path = "set dpdk interface hqos tctbl",
1205 .short_help = "set dpdk interface hqos tctbl <interface> entry <map_val> tc <tc_id> queue <queue_id>",
1206 .function = set_dpdk_if_hqos_tctbl,
1210 static clib_error_t *
1211 set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
1212 vlib_cli_command_t * cmd)
1214 unformat_input_t _line_input, *line_input = &_line_input;
1215 vlib_thread_main_t *tm = vlib_get_thread_main ();
1216 dpdk_main_t *dm = &dpdk_main;
1217 clib_error_t *error = NULL;
1219 /* Device specific data */
1220 struct rte_eth_dev_info dev_info;
1221 struct rte_pci_device *pci_dev;
1222 dpdk_device_config_t *devconf = 0;
1223 vnet_hw_interface_t *hw;
1225 u32 hw_if_index = (u32) ~ 0;
1227 /* Detect the set of worker threads */
1228 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1229 /* Should never happen, shut up Coverity warning */
1231 return clib_error_return (0, "no worker registrations?");
1233 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1234 int worker_thread_first = tr->first_index;
1235 int worker_thread_count = tr->count;
1237 /* Packet field configuration */
1238 u64 mask = (u64) ~ 0;
1240 u32 offset = (u32) ~ 0;
1243 u32 n_subports_per_port, n_pipes_per_subport, tctbl_size;
1247 /* Parse input arguments */
1248 if (!unformat_user (input, unformat_line_input, line_input))
1251 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1254 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1257 else if (unformat (line_input, "id subport"))
1259 else if (unformat (line_input, "id pipe"))
1261 else if (unformat (line_input, "id tc"))
1263 else if (unformat (line_input, "id %d", &id))
1265 else if (unformat (line_input, "offset %d", &offset))
1267 else if (unformat (line_input, "mask %llx", &mask))
1271 error = clib_error_return (0, "parse error: '%U'",
1272 format_unformat_error, line_input);
1278 if (hw_if_index == (u32) ~ 0)
1280 error = clib_error_return (0, "please specify valid interface name");
1284 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1285 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1287 rte_eth_dev_info_get (xd->port_id, &dev_info);
1289 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
1292 { /* bonded interface has no pci info */
1293 vlib_pci_addr_t pci_addr;
1295 pci_addr.domain = pci_dev->addr.domain;
1296 pci_addr.bus = pci_dev->addr.bus;
1297 pci_addr.slot = pci_dev->addr.devid;
1298 pci_addr.function = pci_dev->addr.function;
1301 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1305 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1307 devconf = &dm->conf->default_devconf;
1309 if (devconf->hqos_enabled == 0)
1311 vlib_cli_output (vm, "HQoS disabled for this interface");
1315 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
1316 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
1317 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
1319 /* Validate packet field configuration: id, offset and mask */
1322 error = clib_error_return (0, "invalid packet field id");
1329 if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
1331 error = clib_error_return (0, "invalid subport ID mask "
1332 "(n_subports_per_port = %u)",
1333 n_subports_per_port);
1338 if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
1340 error = clib_error_return (0, "invalid pipe ID mask "
1341 "(n_pipes_per_subport = %u)",
1342 n_pipes_per_subport);
1348 if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
1350 error = clib_error_return (0, "invalid TC table index mask "
1351 "(TC table size = %u)", tctbl_size);
1356 /* Propagate packet field configuration to all workers */
1357 for (i = 0; i < worker_thread_count; i++)
1361 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabpos = offset;
1362 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabmask = mask;
1363 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabshr =
1364 count_trailing_zeros (mask);
1367 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabpos = offset;
1368 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabmask = mask;
1369 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabshr =
1370 count_trailing_zeros (mask);
1374 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabpos = offset;
1375 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabmask = mask;
1376 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabshr =
1377 count_trailing_zeros (mask);
1381 unformat_free (line_input);
1387 * This command is used to set the packet fields required for classifiying the
1388 * incoming packet. As a result of classification process, packet field
1389 * information will be mapped to 5 tuples (subport, pipe, traffic class, pipe,
1390 * color) and stored in packet mbuf.
1392 * This command has the following parameters:
1394 * - <b><interface></b> - Used to specify the output interface.
1396 * - <b>id subport|pipe|tc</b> - Classification occurs across three fields.
1397 * This parameter indicates which of the three masks are being configured. Legacy
1398 * code used 0-2 to represent these three fields, so 0-2 is still accepted.
1399 * - <b>subport|0</b> - Currently only one subport is supported, so only
1400 * an empty mask is supported for the subport classification.
1401 * - <b>pipe|1</b> - Currently, 4096 pipes per subport are supported, so a
1402 * 12-bit mask should be configure to map to the 0-4095 pipes.
1403 * - <b>tc|2</b> - The translation table (see '<em>set dpdk interface hqos
1404 * tctbl</em>' command) maps each value (0-63) into one of the 4 traffic classes
1405 * per pipe. A 6-bit mask should be configure to map this field to a traffic class.
1407 * - <b>offset <n></b> - Offset in the packet to apply the 64-bit mask for classification.
1408 * The offset should be on an 8-byte boundary (0,8,16,24..).
1410 * - <b>mask <hex-mask></b> - 64-bit mask to apply to packet at the given '<em>offset</em>'.
1411 * Bits must be contiguous and should not include '<em>0x</em>'.
1413 * The default values for the '<em>pktfield</em>' assumes Ethernet/IPv4/UDP packets with
1414 * no VLAN. Adjust based on expected packet format and desired classification field.
1415 * - '<em>subport</em>' is always empty (offset 0 mask 0000000000000000)
1416 * - By default, '<em>pipe</em>' maps to the UDP payload bits 12 .. 23 (offset 40
1417 * mask 0000000fff000000)
1418 * - By default, '<em>tc</em>' maps to the DSCP field in IP header (offset 48 mask
1422 * Example of how modify the '<em>pipe</em>' classification filter to match VLAN:
1423 * @cliexcmd{set dpdk interface hqos pktfield GigabitEthernet0/8/0 id pipe offset 8 mask 0000000000000FFF}
1426 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pktfield, static) = {
1427 .path = "set dpdk interface hqos pktfield",
1428 .short_help = "set dpdk interface hqos pktfield <interface> id subport|pipe|tc offset <n> "
1430 .function = set_dpdk_if_hqos_pktfield,
1434 static clib_error_t *
1435 show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
1436 vlib_cli_command_t * cmd)
1438 unformat_input_t _line_input, *line_input = &_line_input;
1439 vlib_thread_main_t *tm = vlib_get_thread_main ();
1440 dpdk_main_t *dm = &dpdk_main;
1441 vnet_hw_interface_t *hw;
1443 dpdk_device_config_hqos_t *cfg;
1444 dpdk_device_hqos_per_hqos_thread_t *ht;
1445 dpdk_device_hqos_per_worker_thread_t *wk;
1447 u32 hw_if_index = (u32) ~ 0;
1448 u32 profile_id, subport_id, i;
1449 struct rte_eth_dev_info dev_info;
1450 struct rte_pci_device *pci_dev;
1451 dpdk_device_config_t *devconf = 0;
1452 vlib_thread_registration_t *tr;
1454 clib_error_t *error = NULL;
1456 if (!unformat_user (input, unformat_line_input, line_input))
1459 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1462 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1467 error = clib_error_return (0, "parse error: '%U'",
1468 format_unformat_error, line_input);
1473 if (hw_if_index == (u32) ~ 0)
1475 error = clib_error_return (0, "please specify interface name!!");
1479 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1480 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1482 rte_eth_dev_info_get (xd->port_id, &dev_info);
1484 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
1487 { /* bonded interface has no pci info */
1488 vlib_pci_addr_t pci_addr;
1490 pci_addr.domain = pci_dev->addr.domain;
1491 pci_addr.bus = pci_dev->addr.bus;
1492 pci_addr.slot = pci_dev->addr.devid;
1493 pci_addr.function = pci_dev->addr.function;
1496 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1500 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1502 devconf = &dm->conf->default_devconf;
1504 if (devconf->hqos_enabled == 0)
1506 vlib_cli_output (vm, "HQoS disabled for this interface");
1510 /* Detect the set of worker threads */
1511 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1513 /* Should never happen, shut up Coverity warning */
1516 error = clib_error_return (0, "no worker registrations?");
1520 tr = (vlib_thread_registration_t *) p[0];
1522 cfg = &devconf->hqos;
1524 wk = &xd->hqos_wt[tr->first_index];
1525 tctbl = wk->hqos_tc_table;
1527 vlib_cli_output (vm, " Thread:");
1528 vlib_cli_output (vm, " Input SWQ size = %u packets", cfg->swq_size);
1529 vlib_cli_output (vm, " Enqueue burst size = %u packets",
1530 ht->hqos_burst_enq);
1531 vlib_cli_output (vm, " Dequeue burst size = %u packets",
1532 ht->hqos_burst_deq);
1534 vlib_cli_output (vm,
1535 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx (subport)",
1536 wk->hqos_field0_slabpos, wk->hqos_field0_slabmask);
1537 vlib_cli_output (vm,
1538 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx (pipe)",
1539 wk->hqos_field1_slabpos, wk->hqos_field1_slabmask);
1540 vlib_cli_output (vm,
1541 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx (tc)",
1542 wk->hqos_field2_slabpos, wk->hqos_field2_slabmask);
1543 vlib_cli_output (vm,
1544 " Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)");
1545 vlib_cli_output (vm,
1547 "%u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u",
1548 tctbl[0] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1549 tctbl[0] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1550 tctbl[1] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1551 tctbl[1] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1552 tctbl[2] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1553 tctbl[2] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1554 tctbl[3] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1555 tctbl[3] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1556 tctbl[4] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1557 tctbl[4] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1558 tctbl[5] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1559 tctbl[5] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1560 tctbl[6] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1561 tctbl[6] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1562 tctbl[7] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1563 tctbl[7] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1564 tctbl[8] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1565 tctbl[8] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1566 tctbl[9] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1567 tctbl[9] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1568 tctbl[10] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1569 tctbl[10] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1570 tctbl[11] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1571 tctbl[11] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1572 tctbl[12] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1573 tctbl[12] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1574 tctbl[13] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1575 tctbl[13] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1576 tctbl[14] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1577 tctbl[14] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1578 tctbl[15] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1579 tctbl[15] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1580 vlib_cli_output (vm,
1582 "%u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u",
1583 tctbl[16] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1584 tctbl[16] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1585 tctbl[17] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1586 tctbl[17] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1587 tctbl[18] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1588 tctbl[18] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1589 tctbl[19] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1590 tctbl[19] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1591 tctbl[20] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1592 tctbl[20] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1593 tctbl[21] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1594 tctbl[21] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1595 tctbl[22] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1596 tctbl[22] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1597 tctbl[23] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1598 tctbl[23] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1599 tctbl[24] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1600 tctbl[24] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1601 tctbl[25] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1602 tctbl[25] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1603 tctbl[26] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1604 tctbl[26] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1605 tctbl[27] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1606 tctbl[27] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1607 tctbl[28] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1608 tctbl[28] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1609 tctbl[29] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1610 tctbl[29] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1611 tctbl[30] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1612 tctbl[30] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1613 tctbl[31] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1614 tctbl[31] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1615 vlib_cli_output (vm,
1617 "%u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u",
1618 tctbl[32] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1619 tctbl[32] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1620 tctbl[33] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1621 tctbl[33] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1622 tctbl[34] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1623 tctbl[34] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1624 tctbl[35] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1625 tctbl[35] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1626 tctbl[36] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1627 tctbl[36] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1628 tctbl[37] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1629 tctbl[37] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1630 tctbl[38] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1631 tctbl[38] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1632 tctbl[39] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1633 tctbl[39] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1634 tctbl[40] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1635 tctbl[40] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1636 tctbl[41] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1637 tctbl[41] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1638 tctbl[42] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1639 tctbl[42] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1640 tctbl[43] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1641 tctbl[43] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1642 tctbl[44] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1643 tctbl[44] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1644 tctbl[45] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1645 tctbl[45] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1646 tctbl[46] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1647 tctbl[46] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1648 tctbl[47] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1649 tctbl[47] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1650 vlib_cli_output (vm,
1652 "%u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u %u/%u",
1653 tctbl[48] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1654 tctbl[48] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1655 tctbl[49] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1656 tctbl[49] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1657 tctbl[50] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1658 tctbl[50] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1659 tctbl[51] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1660 tctbl[51] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1661 tctbl[52] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1662 tctbl[52] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1663 tctbl[53] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1664 tctbl[53] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1665 tctbl[54] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1666 tctbl[54] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1667 tctbl[55] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1668 tctbl[55] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1669 tctbl[56] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1670 tctbl[56] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1671 tctbl[57] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1672 tctbl[57] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1673 tctbl[58] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1674 tctbl[58] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1675 tctbl[59] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1676 tctbl[59] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1677 tctbl[60] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1678 tctbl[60] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1679 tctbl[61] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1680 tctbl[61] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1681 tctbl[62] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1682 tctbl[62] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1683 tctbl[63] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1684 tctbl[63] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1685 vlib_cli_output (vm, " Port:");
1686 vlib_cli_output (vm, " Rate = %u bytes/second", cfg->port.rate);
1687 vlib_cli_output (vm, " MTU = %u bytes", cfg->port.mtu);
1688 vlib_cli_output (vm, " Frame overhead = %u bytes",
1689 cfg->port.frame_overhead);
1690 vlib_cli_output (vm, " Number of subports = %u",
1691 cfg->port.n_subports_per_port);
1692 vlib_cli_output (vm, " Number of pipes per subport = %u",
1693 cfg->port.n_pipes_per_subport);
1694 vlib_cli_output (vm,
1695 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1696 cfg->port.qsize[0], cfg->port.qsize[1], cfg->port.qsize[2],
1697 cfg->port.qsize[3]);
1698 vlib_cli_output (vm, " Number of pipe profiles = %u",
1699 cfg->port.n_pipe_profiles);
1701 for (subport_id = 0; subport_id < vec_len (cfg->subport); subport_id++)
1703 vlib_cli_output (vm, " Subport %u:", subport_id);
1704 vlib_cli_output (vm, " Rate = %u bytes/second",
1705 cfg->subport[subport_id].tb_rate);
1706 vlib_cli_output (vm, " Token bucket size = %u bytes",
1707 cfg->subport[subport_id].tb_size);
1708 vlib_cli_output (vm,
1709 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1710 cfg->subport[subport_id].tc_rate[0],
1711 cfg->subport[subport_id].tc_rate[1],
1712 cfg->subport[subport_id].tc_rate[2],
1713 cfg->subport[subport_id].tc_rate[3]);
1714 vlib_cli_output (vm, " TC period = %u milliseconds",
1715 cfg->subport[subport_id].tc_period);
1718 for (profile_id = 0; profile_id < vec_len (cfg->pipe); profile_id++)
1720 vlib_cli_output (vm, " Pipe profile %u:", profile_id);
1721 vlib_cli_output (vm, " Rate = %u bytes/second",
1722 cfg->pipe[profile_id].tb_rate);
1723 vlib_cli_output (vm, " Token bucket size = %u bytes",
1724 cfg->pipe[profile_id].tb_size);
1725 vlib_cli_output (vm,
1726 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1727 cfg->pipe[profile_id].tc_rate[0],
1728 cfg->pipe[profile_id].tc_rate[1],
1729 cfg->pipe[profile_id].tc_rate[2],
1730 cfg->pipe[profile_id].tc_rate[3]);
1731 vlib_cli_output (vm, " TC period = %u milliseconds",
1732 cfg->pipe[profile_id].tc_period);
1733 #ifdef RTE_SCHED_SUBPORT_TC_OV
1734 vlib_cli_output (vm, " TC3 oversubscription_weight = %u",
1735 cfg->pipe[profile_id].tc_ov_weight);
1738 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1740 vlib_cli_output (vm,
1741 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1742 i, cfg->pipe[profile_id].wrr_weights[i * 4],
1743 cfg->pipe[profile_id].wrr_weights[i * 4 + 1],
1744 cfg->pipe[profile_id].wrr_weights[i * 4 + 2],
1745 cfg->pipe[profile_id].wrr_weights[i * 4 + 3]);
1749 #ifdef RTE_SCHED_RED
1750 vlib_cli_output (vm, " Weighted Random Early Detection (WRED):");
1751 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1753 vlib_cli_output (vm, " TC%u min: G = %u, Y = %u, R = %u", i,
1754 cfg->port.red_params[i][e_RTE_METER_GREEN].min_th,
1755 cfg->port.red_params[i][e_RTE_METER_YELLOW].min_th,
1756 cfg->port.red_params[i][e_RTE_METER_RED].min_th);
1758 vlib_cli_output (vm, " TC%u max: G = %u, Y = %u, R = %u", i,
1759 cfg->port.red_params[i][e_RTE_METER_GREEN].max_th,
1760 cfg->port.red_params[i][e_RTE_METER_YELLOW].max_th,
1761 cfg->port.red_params[i][e_RTE_METER_RED].max_th);
1763 vlib_cli_output (vm,
1764 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1765 i, cfg->port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1766 cfg->port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1767 cfg->port.red_params[i][e_RTE_METER_RED].maxp_inv);
1769 vlib_cli_output (vm, " TC%u weight: R = %u, Y = %u, R = %u", i,
1770 cfg->port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1771 cfg->port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1772 cfg->port.red_params[i][e_RTE_METER_RED].wq_log2);
1777 unformat_free (line_input);
1783 * This command is used to display details of an output interface's HQoS
1787 * Example of how to display HQoS settings for an interfaces:
1788 * @cliexstart{show dpdk interface hqos GigabitEthernet0/8/0}
1790 * Input SWQ size = 4096 packets
1791 * Enqueue burst size = 256 packets
1792 * Dequeue burst size = 220 packets
1793 * Packet field 0: slab position = 0, slab bitmask = 0x0000000000000000 (subport)
1794 * Packet field 1: slab position = 40, slab bitmask = 0x0000000fff000000 (pipe)
1795 * Packet field 2: slab position = 8, slab bitmask = 0x00000000000000fc (tc)
1796 * Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)
1797 * [ 0 .. 15]: 0/0 0/1 0/2 0/3 1/0 1/1 1/2 1/3 2/0 2/1 2/2 2/3 3/0 3/1 3/2 3/3
1798 * [16 .. 31]: 0/0 0/1 0/2 0/3 1/0 1/1 1/2 1/3 2/0 2/1 2/2 2/3 3/0 3/1 3/2 3/3
1799 * [32 .. 47]: 0/0 0/1 0/2 0/3 1/0 1/1 1/2 1/3 2/0 2/1 2/2 2/3 3/0 3/1 3/2 3/3
1800 * [48 .. 63]: 0/0 0/1 0/2 0/3 1/0 1/1 1/2 1/3 2/0 2/1 2/2 2/3 3/0 3/1 3/2 3/3
1802 * Rate = 1250000000 bytes/second
1804 * Frame overhead = 24 bytes
1805 * Number of subports = 1
1806 * Number of pipes per subport = 4096
1807 * Packet queue size: TC0 = 64, TC1 = 64, TC2 = 64, TC3 = 64 packets
1808 * Number of pipe profiles = 2
1810 * Rate = 1250000000 bytes/second
1811 * Token bucket size = 1000000 bytes
1812 * Traffic class rate: TC0 = 1250000000, TC1 = 1250000000, TC2 = 1250000000, TC3 = 1250000000 bytes/second
1813 * TC period = 10 milliseconds
1815 * Rate = 305175 bytes/second
1816 * Token bucket size = 1000000 bytes
1817 * Traffic class rate: TC0 = 305175, TC1 = 305175, TC2 = 305175, TC3 = 305175 bytes/second
1818 * TC period = 40 milliseconds
1819 * TC0 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1820 * TC1 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1821 * TC2 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1822 * TC3 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1826 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos, static) = {
1827 .path = "show dpdk interface hqos",
1828 .short_help = "show dpdk interface hqos <interface>",
1829 .function = show_dpdk_if_hqos,
1834 static clib_error_t *
1835 show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
1836 vlib_cli_command_t * cmd)
1838 unformat_input_t _line_input, *line_input = &_line_input;
1839 clib_error_t *error = NULL;
1840 #ifdef RTE_SCHED_COLLECT_STATS
1841 dpdk_main_t *dm = &dpdk_main;
1842 u32 hw_if_index = (u32) ~ 0;
1843 u32 subport = (u32) ~ 0;
1844 u32 pipe = (u32) ~ 0;
1846 u32 tc_q = (u32) ~ 0;
1847 vnet_hw_interface_t *hw;
1850 struct rte_eth_dev_info dev_info;
1851 dpdk_device_config_t *devconf = 0;
1853 struct rte_sched_queue_stats stats;
1856 if (!unformat_user (input, unformat_line_input, line_input))
1859 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1862 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1866 else if (unformat (line_input, "subport %d", &subport))
1869 else if (unformat (line_input, "pipe %d", &pipe))
1872 else if (unformat (line_input, "tc %d", &tc))
1875 else if (unformat (line_input, "tc_q %d", &tc_q))
1880 error = clib_error_return (0, "parse error: '%U'",
1881 format_unformat_error, line_input);
1886 if (hw_if_index == (u32) ~ 0)
1888 error = clib_error_return (0, "please specify interface name!!");
1892 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1893 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1895 rte_eth_dev_info_get (xd->port_id, &dev_info);
1896 if (dev_info.pci_dev)
1897 { /* bonded interface has no pci info */
1898 vlib_pci_addr_t pci_addr;
1900 pci_addr.domain = dev_info.pci_dev->addr.domain;
1901 pci_addr.bus = dev_info.pci_dev->addr.bus;
1902 pci_addr.slot = dev_info.pci_dev->addr.devid;
1903 pci_addr.function = dev_info.pci_dev->addr.function;
1906 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1910 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1912 devconf = &dm->conf->default_devconf;
1914 if (devconf->hqos_enabled == 0)
1916 vlib_cli_output (vm, "HQoS disabled for this interface");
1921 * Figure out which queue to query. cf rte_sched_port_qindex. (Not sure why
1922 * that method isn't made public by DPDK - how _should_ we get the queue ID?)
1924 qindex = subport * devconf->hqos.port.n_pipes_per_subport + pipe;
1925 qindex = qindex * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE + tc;
1926 qindex = qindex * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + tc_q;
1928 if (rte_sched_queue_read_stats (xd->hqos_ht->hqos, qindex, &stats, &qlen) !=
1931 error = clib_error_return (0, "failed to read stats");
1935 vlib_cli_output (vm, "%=24s%=16s", "Stats Parameter", "Value");
1936 vlib_cli_output (vm, "%=24s%=16d", "Packets", stats.n_pkts);
1937 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped", stats.n_pkts_dropped);
1938 #ifdef RTE_SCHED_RED
1939 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped (RED)",
1940 stats.n_pkts_red_dropped);
1942 vlib_cli_output (vm, "%=24s%=16d", "Bytes", stats.n_bytes);
1943 vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped);
1947 /* Get a line of input */
1948 if (!unformat_user (input, unformat_line_input, line_input))
1951 vlib_cli_output (vm, "RTE_SCHED_COLLECT_STATS disabled in DPDK");
1957 unformat_free (line_input);
1963 * This command is used to display statistics associated with a HQoS traffic class
1967 * Statistic collection by the scheduler is disabled by default in DPDK. In order to
1968 * turn it on, add the following line to '<em>../vpp/dpdk/Makefile</em>':
1969 * - <b>$(call set,RTE_SCHED_COLLECT_STATS,y)</b>
1972 * Example of how to display statistics of HQoS a HQoS traffic class queue:
1973 * @cliexstart{show dpdk hqos queue GigabitEthernet0/9/0 subport 0 pipe 3181 tc 0 tc_q 0}
1974 * Stats Parameter Value
1982 VLIB_CLI_COMMAND (cmd_show_dpdk_hqos_queue_stats, static) = {
1983 .path = "show dpdk hqos queue",
1984 .short_help = "show dpdk hqos queue <interface> subport <subport_id> pipe <pipe_id> tc <tc_id> tc_q <queue_id>",
1985 .function = show_dpdk_hqos_queue_stats,
1989 static clib_error_t *
1990 show_dpdk_version_command_fn (vlib_main_t * vm,
1991 unformat_input_t * input,
1992 vlib_cli_command_t * cmd)
1994 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
1995 _("DPDK Version", "%s", rte_version ());
1996 _("DPDK EAL init args", "%s", dpdk_config_main.eal_init_args_str);
2002 * This command is used to display the current DPDK version and
2003 * the list of arguments passed to DPDK when started.
2006 * Example of how to display how many DPDK buffer test command has allcoated:
2007 * @cliexstart{show dpdk version}
2008 * DPDK Version: DPDK 16.11.0
2009 * DPDK EAL init args: -c 1 -n 4 --huge-dir /run/vpp/hugepages --file-prefix vpp -w 0000:00:08.0 -w 0000:00:09.0 --master-lcore 0 --socket-mem 256
2013 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
2014 .path = "show dpdk version",
2015 .short_help = "show dpdk version",
2016 .function = show_dpdk_version_command_fn,
2022 static clib_error_t *
2023 dpdk_validate_buffers_fn (vlib_main_t * vm, unformat_input_t * input,
2024 vlib_cli_command_t * cmd_arg)
2026 u32 n_invalid_bufs = 0, uninitialized = 0;
2027 u32 is_poison = 0, is_test = 0;
2028 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2030 if (unformat (input, "poison"))
2032 else if (unformat (input, "trajectory"))
2035 return clib_error_return (0, "unknown input `%U'",
2036 format_unformat_error, input);
2039 if (VLIB_BUFFER_TRACE_TRAJECTORY == 0)
2041 vlib_cli_output (vm, "Trajectory not enabled. Recompile with "
2042 "VLIB_BUFFER_TRACE_TRAJECTORY 1");
2047 dpdk_buffer_poison_trajectory_all ();
2051 n_invalid_bufs = dpdk_buffer_validate_trajectory_all (&uninitialized);
2052 if (!n_invalid_bufs)
2053 vlib_cli_output (vm, "All buffers are valid %d uninitialized",
2056 vlib_cli_output (vm, "Found %d invalid buffers and %d uninitialized",
2057 n_invalid_bufs, uninitialized);
2063 VLIB_CLI_COMMAND (test_dpdk_buffers_command, static) =
2065 .path = "test dpdk buffers",
2066 .short_help = "test dpdk buffers [poison] [trajectory]",
2067 .function = dpdk_validate_buffers_fn,
2074 dpdk_cli_init (vlib_main_t * vm)
2079 VLIB_INIT_FUNCTION (dpdk_cli_init);
2082 * fd.io coding-style-patch-verification: ON
2085 * eval: (c-set-style "gnu")