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 #if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
72 pci_dev = dev_info.pci_dev;
74 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
78 { /* bonded interface has no pci info */
79 vlib_pci_addr_t pci_addr;
81 pci_addr.domain = pci_dev->addr.domain;
82 pci_addr.bus = pci_dev->addr.bus;
83 pci_addr.slot = pci_dev->addr.devid;
84 pci_addr.function = pci_dev->addr.function;
87 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
91 (*devconf) = pool_elt_at_index (dm->conf->dev_confs, p[0]);
93 (*devconf) = &dm->conf->default_devconf;
99 static inline clib_error_t *
100 pcap_trace_command_internal (vlib_main_t * vm,
101 unformat_input_t * input,
102 vlib_cli_command_t * cmd, int rx_tx)
104 #define PCAP_DEF_PKT_TO_CAPTURE (100)
106 unformat_input_t _line_input, *line_input = &_line_input;
107 dpdk_main_t *dm = &dpdk_main;
109 u8 *chroot_filename = 0;
113 clib_error_t *error = 0;
115 /* Get a line of input. */
116 if (!unformat_user (input, unformat_line_input, line_input))
119 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
121 if (unformat (line_input, "on"))
123 if (dm->pcap[rx_tx].pcap_enable == 0)
129 vlib_cli_output (vm, "pcap tx capture already on...");
134 else if (unformat (line_input, "off"))
136 if (dm->pcap[rx_tx].pcap_enable)
139 (vm, "captured %d pkts...",
140 dm->pcap[rx_tx].pcap_main.n_packets_captured);
141 if (dm->pcap[rx_tx].pcap_main.n_packets_captured)
143 dm->pcap[rx_tx].pcap_main.n_packets_to_capture =
144 dm->pcap[rx_tx].pcap_main.n_packets_captured;
145 error = pcap_write (&dm->pcap[rx_tx].pcap_main);
147 clib_error_report (error);
149 vlib_cli_output (vm, "saved to %s...",
150 dm->pcap[rx_tx].pcap_main.file_name);
153 dm->pcap[rx_tx].pcap_enable = 0;
157 vlib_cli_output (vm, "pcap tx capture already off...");
162 else if (unformat (line_input, "max %d", &max))
164 if (dm->pcap[rx_tx].pcap_enable)
168 "can't change max value while pcap tx capture active...");
172 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
174 else if (unformat (line_input, "intfc %U",
175 unformat_vnet_sw_interface, dm->vnet_main,
176 &dm->pcap[rx_tx].pcap_sw_if_index))
179 else if (unformat (line_input, "intfc any"))
181 dm->pcap[rx_tx].pcap_sw_if_index = 0;
183 else if (unformat (line_input, "file %s", &filename))
185 if (dm->pcap[rx_tx].pcap_enable)
188 (vm, "can't change file while pcap tx capture active...");
193 /* Brain-police user path input */
194 if (strstr ((char *) filename, "..")
195 || index ((char *) filename, '/'))
197 vlib_cli_output (vm, "illegal characters in filename '%s'",
199 vlib_cli_output (vm, "Hint: .. and / are not allowed.");
205 chroot_filename = format (0, "/tmp/%s%c", filename, 0);
208 else if (unformat (line_input, "status"))
210 if (dm->pcap[rx_tx].pcap_sw_if_index == 0)
213 (vm, "max is %d for any interface to file %s",
214 dm->pcap[rx_tx].pcap_main.n_packets_to_capture ?
215 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
216 : PCAP_DEF_PKT_TO_CAPTURE,
217 dm->pcap[rx_tx].pcap_main.file_name ?
218 (u8 *) dm->pcap[rx_tx].pcap_main.file_name :
219 (u8 *) "/tmp/vpe.pcap");
223 vlib_cli_output (vm, "max is %d for interface %U to file %s",
224 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
226 pcap_main.n_packets_to_capture :
227 PCAP_DEF_PKT_TO_CAPTURE,
228 format_vnet_sw_if_index_name, dm->vnet_main,
229 dm->pcap_sw_if_index,
231 pcap_main.file_name ? (u8 *) dm->pcap[rx_tx].
232 pcap_main.file_name : (u8 *) "/tmp/vpe.pcap");
235 if (dm->pcap[rx_tx].pcap_enable == 0)
237 vlib_cli_output (vm, "pcap %s capture is off...",
238 (rx_tx == VLIB_RX) ? "rx" : "tx");
242 vlib_cli_output (vm, "pcap %s capture is on: %d of %d pkts...",
243 (rx_tx == VLIB_RX) ? "rx" : "tx",
244 dm->pcap[rx_tx].pcap_main.n_packets_captured,
246 pcap_main.n_packets_to_capture);
253 error = clib_error_return (0, "unknown input `%U'",
254 format_unformat_error, line_input);
259 unformat_free (line_input);
264 /* Since no error, save configured values. */
267 if (dm->pcap[rx_tx].pcap_main.file_name)
268 vec_free (dm->pcap[rx_tx].pcap_main.file_name);
269 vec_add1 (chroot_filename, 0);
270 dm->pcap[rx_tx].pcap_main.file_name = (char *) chroot_filename;
274 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
278 if (dm->pcap[rx_tx].pcap_main.file_name == 0)
279 dm->pcap[rx_tx].pcap_main.file_name
280 = (char *) format (0, "/tmp/vpe.pcap%c", 0);
282 dm->pcap[rx_tx].pcap_main.n_packets_captured = 0;
283 dm->pcap[rx_tx].pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
284 if (dm->pcap[rx_tx].pcap_main.lock == 0)
285 clib_spinlock_init (&(dm->pcap[rx_tx].pcap_main.lock));
286 dm->pcap[rx_tx].pcap_enable = 1;
287 vlib_cli_output (vm, "pcap %s capture on...",
288 rx_tx == VLIB_RX ? "rx" : "tx");
291 else if (chroot_filename)
292 vec_free (chroot_filename);
297 static clib_error_t *
298 pcap_rx_trace_command_fn (vlib_main_t * vm,
299 unformat_input_t * input, vlib_cli_command_t * cmd)
301 return pcap_trace_command_internal (vm, input, cmd, VLIB_RX);
304 static clib_error_t *
305 pcap_tx_trace_command_fn (vlib_main_t * vm,
306 unformat_input_t * input, vlib_cli_command_t * cmd)
308 return pcap_trace_command_internal (vm, input, cmd, VLIB_TX);
313 * This command is used to start or stop a packet capture, or show
314 * the status of packet capture. Note that both "pcap rx trace" and
315 * "pcap tx trace" are implemented. The command syntax is identical,
316 * simply substitute rx for tx as needed.
318 * This command has the following optional parameters:
320 * - <b>on|off</b> - Used to start or stop a packet capture.
322 * - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
323 * of packets have been received, buffer is flushed to file. Once another
324 * '<em>nn</em>' number of packets have been received, buffer is flushed
325 * to file, overwriting previous write. If not entered, value defaults
326 * to 100. Can only be updated if packet capture is off.
328 * - <b>intfc <interface>|any</b> - Used to specify a given interface,
329 * or use '<em>any</em>' to run packet capture on all interfaces.
330 * '<em>any</em>' is the default if not provided. Settings from a previous
331 * packet capture are preserved, so '<em>any</em>' can be used to reset
332 * the interface setting.
334 * - <b>file <name></b> - Used to specify the output filename. The file will
335 * be placed in the '<em>/tmp</em>' directory, so only the filename is
336 * supported. Directory should not be entered. If file already exists, file
337 * will be overwritten. If no filename is provided, '<em>/tmp/vpe.pcap</em>'
338 * will be used. Can only be updated if packet capture is off.
340 * - <b>status</b> - Displays the current status and configured attributes
341 * associated with a packet capture. If packet capture is in progress,
342 * '<em>status</em>' also will return the number of packets currently in
343 * the local buffer. All additional attributes entered on command line
344 * with '<em>status</em>' will be ingnored and not applied.
347 * Example of how to display the status of a tx packet capture when off:
348 * @cliexstart{pcap tx trace status}
349 * max is 100, for any interface to file /tmp/vpe.pcap
350 * pcap tx capture is off...
352 * Example of how to start a tx packet capture:
353 * @cliexstart{pcap tx trace on max 35 intfc GigabitEthernet0/8/0 file vppTest.pcap}
354 * pcap tx capture on...
356 * Example of how to display the status of a tx packet capture in progress:
357 * @cliexstart{pcap tx trace status}
358 * max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
359 * pcap tx capture is on: 20 of 35 pkts...
361 * Example of how to stop a tx packet capture:
362 * @cliexstart{vppctl pcap tx trace off}
363 * captured 21 pkts...
364 * saved to /tmp/vppTest.pcap...
369 VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = {
370 .path = "pcap tx trace",
372 "pcap tx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
373 .function = pcap_tx_trace_command_fn,
375 VLIB_CLI_COMMAND (pcap_rx_trace_command, static) = {
376 .path = "pcap rx trace",
378 "pcap rx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
379 .function = pcap_rx_trace_command_fn,
384 static clib_error_t *
385 show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
386 vlib_cli_command_t * cmd)
388 struct rte_mempool *rmp;
391 for (i = 0; i < vec_len (dpdk_main.pktmbuf_pools); i++)
393 rmp = dpdk_main.pktmbuf_pools[i];
396 unsigned count = rte_mempool_avail_count (rmp);
397 unsigned free_count = rte_mempool_in_use_count (rmp);
400 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
401 rmp->name, (u32) count, (u32) free_count,
402 (u32) (count + free_count));
406 vlib_cli_output (vm, "rte_mempool is NULL (!)\n");
413 * This command displays statistics of each DPDK mempool.
416 * Example of how to display DPDK buffer data:
417 * @cliexstart{show dpdk buffer}
418 * name="mbuf_pool_socket0" available = 15104 allocated = 1280 total = 16384
422 VLIB_CLI_COMMAND (cmd_show_dpdk_buffer,static) = {
423 .path = "show dpdk buffer",
424 .short_help = "show dpdk buffer",
425 .function = show_dpdk_buffer,
430 static clib_error_t *
431 show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
432 vlib_cli_command_t * cmd)
434 clib_error_t *err = 0;
441 err = clib_sysfs_read ("/proc/sys/fs/pipe-max-size", "%u", &pipe_max_size);
446 if (pipe (fds) == -1)
447 return clib_error_return_unix (0, "pipe");
450 #define F_SETPIPE_SZ (1024 + 7)
453 if (fcntl (fds[1], F_SETPIPE_SZ, pipe_max_size) == -1)
455 err = clib_error_return_unix (0, "fcntl(F_SETPIPE_SZ)");
459 if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1)
461 err = clib_error_return_unix (0, "fcntl(F_SETFL)");
465 if ((f = fdopen (fds[1], "a")) == 0)
467 err = clib_error_return_unix (0, "fdopen");
471 rte_dump_physmem_layout (f);
477 uword len = vec_len (s);
478 vec_resize (s, len + n_try);
480 n = read (fds[0], s + len, n_try);
481 if (n < 0 && errno != EAGAIN)
483 err = clib_error_return_unix (0, "read");
486 _vec_len (s) = len + (n < 0 ? 0 : n);
489 vlib_cli_output (vm, "%v", s);
499 * This command displays DPDK physmem layout
502 * Example of how to display DPDK physmem layout:
503 * @cliexstart{show dpdk physmem}
507 VLIB_CLI_COMMAND (cmd_show_dpdk_physmem,static) = {
508 .path = "show dpdk physmem",
509 .short_help = "show dpdk physmem",
510 .function = show_dpdk_physmem,
515 static clib_error_t *
516 test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
517 vlib_cli_command_t * cmd)
519 static u32 *allocated_buffers;
522 u32 first, actual_alloc;
524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
526 if (unformat (input, "allocate %d", &n_alloc))
528 else if (unformat (input, "free %d", &n_free))
536 if (vec_len (allocated_buffers) < n_free)
537 return clib_error_return (0, "Can't free %d, only %d allocated",
538 n_free, vec_len (allocated_buffers));
540 first = vec_len (allocated_buffers) - n_free;
541 vlib_buffer_free (vm, allocated_buffers + first, n_free);
542 _vec_len (allocated_buffers) = first;
546 first = vec_len (allocated_buffers);
547 vec_validate (allocated_buffers,
548 vec_len (allocated_buffers) + n_alloc - 1);
550 actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
552 _vec_len (allocated_buffers) = first + actual_alloc;
554 if (actual_alloc < n_alloc)
555 vlib_cli_output (vm, "WARNING: only allocated %d buffers",
559 vlib_cli_output (vm, "Currently %d buffers allocated",
560 vec_len (allocated_buffers));
562 if (allocated_buffers && vec_len (allocated_buffers) == 0)
563 vec_free (allocated_buffers);
569 * This command tests the allocation and freeing of DPDK buffers.
570 * If both '<em>allocate</em>' and '<em>free</em>' are entered on the
571 * same command, the '<em>free</em>' is executed first. If no
572 * parameters are provided, this command display how many DPDK buffers
573 * the test command has allocated.
578 * Example of how to display how many DPDK buffer test command has allcoated:
579 * @cliexstart{test dpdk buffer}
580 * Currently 0 buffers allocated
583 * Example of how to allocate DPDK buffers using the test command:
584 * @cliexstart{test dpdk buffer allocate 10}
585 * Currently 10 buffers allocated
588 * Example of how to free DPDK buffers allocated by the test command:
589 * @cliexstart{test dpdk buffer free 10}
590 * Currently 0 buffers allocated
595 VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = {
596 .path = "test dpdk buffer",
597 .short_help = "test dpdk buffer [allocate <nn>] [free <nn>]",
598 .function = test_dpdk_buffer,
603 static clib_error_t *
604 set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
605 vlib_cli_command_t * cmd)
607 unformat_input_t _line_input, *line_input = &_line_input;
608 dpdk_main_t *dm = &dpdk_main;
609 vnet_hw_interface_t *hw;
611 u32 hw_if_index = (u32) ~ 0;
612 u32 nb_rx_desc = (u32) ~ 0;
613 u32 nb_tx_desc = (u32) ~ 0;
614 clib_error_t *error = NULL;
616 if (!unformat_user (input, unformat_line_input, line_input))
619 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
622 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
625 else if (unformat (line_input, "tx %d", &nb_tx_desc))
627 else if (unformat (line_input, "rx %d", &nb_rx_desc))
631 error = clib_error_return (0, "parse error: '%U'",
632 format_unformat_error, line_input);
637 if (hw_if_index == (u32) ~ 0)
639 error = clib_error_return (0, "please specify valid interface name");
643 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
644 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
646 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
649 clib_error_return (0,
650 "number of descriptors can be set only for "
655 if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
656 (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
658 error = clib_error_return (0, "nothing changed");
662 if (nb_rx_desc != (u32) ~ 0)
663 xd->nb_rx_desc = nb_rx_desc;
665 if (nb_tx_desc != (u32) ~ 0)
666 xd->nb_tx_desc = nb_tx_desc;
668 dpdk_device_setup (xd);
670 if (vec_len (xd->errors))
671 return clib_error_return (0, "%U", format_dpdk_device_errors, xd);
674 unformat_free (line_input);
680 * This command sets the number of DPDK '<em>rx</em>' and
681 * '<em>tx</em>' descriptors for the given physical interface. Use
682 * the command '<em>show hardware-interface</em>' to display the
683 * current descriptor allocation.
686 * Example of how to set the DPDK interface descriptors:
687 * @cliexcmd{set dpdk interface descriptors GigabitEthernet0/8/0 rx 512 tx 512}
690 VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = {
691 .path = "set dpdk interface descriptors",
692 .short_help = "set dpdk interface descriptors <interface> [rx <nn>] [tx <nn>]",
693 .function = set_dpdk_if_desc,
698 dpdk_device_queue_sort (void *a1, void *a2)
700 dpdk_device_and_queue_t *dq1 = a1;
701 dpdk_device_and_queue_t *dq2 = a2;
703 if (dq1->device > dq2->device)
705 else if (dq1->device < dq2->device)
707 else if (dq1->queue_id > dq2->queue_id)
709 else if (dq1->queue_id < dq2->queue_id)
716 static clib_error_t *
717 show_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
718 vlib_cli_command_t * cmd)
720 vlib_thread_main_t *tm = vlib_get_thread_main ();
721 dpdk_main_t *dm = &dpdk_main;
722 dpdk_device_and_queue_t *dq;
725 if (tm->n_vlib_mains == 1)
726 vlib_cli_output (vm, "All interfaces are handled by main thread");
728 for (cpu = 0; cpu < vec_len (dm->devices_by_hqos_cpu); cpu++)
730 if (cpu >= dm->hqos_cpu_first_index &&
731 cpu < (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
732 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
733 vlib_worker_threads[cpu].name,
734 vlib_worker_threads[cpu].lcore_id);
736 vec_foreach (dq, dm->devices_by_hqos_cpu[cpu])
738 u32 hw_if_index = dm->devices[dq->device].hw_if_index;
739 vnet_hw_interface_t *hi =
740 vnet_get_hw_interface (dm->vnet_main, hw_if_index);
741 vlib_cli_output (vm, " %v queue %u", hi->name, dq->queue_id);
748 * This command is used to display the thread and core each
749 * DPDK output interface and HQoS queue is assigned too.
752 * Example of how to display the DPDK output interface and HQoS queue placement:
753 * @cliexstart{show dpdk interface hqos placement}
754 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
755 * GigabitEthernet0/8/0 queue 0
756 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
757 * GigabitEthernet0/9/0 queue 0
761 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos_placement, static) = {
762 .path = "show dpdk interface hqos placement",
763 .short_help = "show dpdk interface hqos placement",
764 .function = show_dpdk_if_hqos_placement,
768 static clib_error_t *
769 set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
770 vlib_cli_command_t * cmd)
772 unformat_input_t _line_input, *line_input = &_line_input;
773 dpdk_main_t *dm = &dpdk_main;
774 dpdk_device_and_queue_t *dq;
775 vnet_hw_interface_t *hw;
777 u32 hw_if_index = (u32) ~ 0;
780 clib_error_t *error = NULL;
782 if (!unformat_user (input, unformat_line_input, line_input))
785 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
788 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
791 else if (unformat (line_input, "thread %d", &cpu))
795 error = clib_error_return (0, "parse error: '%U'",
796 format_unformat_error, line_input);
801 if (hw_if_index == (u32) ~ 0)
802 return clib_error_return (0, "please specify valid interface name");
804 if (cpu < dm->hqos_cpu_first_index ||
805 cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
807 error = clib_error_return (0, "please specify valid thread id");
811 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
812 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
814 for (i = 0; i < vec_len (dm->devices_by_hqos_cpu); i++)
816 vec_foreach (dq, dm->devices_by_hqos_cpu[i])
818 if (hw_if_index == dm->devices[dq->device].hw_if_index)
820 if (cpu == i) /* nothing to do */
823 vec_del1 (dm->devices_by_hqos_cpu[i],
824 dq - dm->devices_by_hqos_cpu[i]);
825 vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
827 dq->device = xd->device_index;
829 vec_sort_with_function (dm->devices_by_hqos_cpu[i],
830 dpdk_device_queue_sort);
832 vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
833 dpdk_device_queue_sort);
840 error = clib_error_return (0, "not found");
843 unformat_free (line_input);
849 * This command is used to assign a given DPDK output interface and
850 * HQoS queue to a different thread. This will not create a thread,
851 * so the thread must already exist. Use '<em>/etc/vpp/startup.conf</em>'
852 * for the initial thread creation. See @ref qos_doc for more details.
855 * Example of how to display the DPDK output interface and HQoS queue placement:
856 * @cliexstart{show dpdk interface hqos placement}
857 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
858 * GigabitEthernet0/8/0 queue 0
859 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
860 * GigabitEthernet0/9/0 queue 0
862 * Example of how to assign a DPDK output interface and HQoS queue to a thread:
863 * @cliexcmd{set dpdk interface hqos placement GigabitEthernet0/8/0 thread 2}
866 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_placement, static) = {
867 .path = "set dpdk interface hqos placement",
868 .short_help = "set dpdk interface hqos placement <interface> thread <n>",
869 .function = set_dpdk_if_hqos_placement,
873 static clib_error_t *
874 set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
875 vlib_cli_command_t * cmd)
877 unformat_input_t _line_input, *line_input = &_line_input;
878 dpdk_main_t *dm = &dpdk_main;
879 vnet_hw_interface_t *hw;
881 u32 hw_if_index = (u32) ~ 0;
882 u32 subport_id = (u32) ~ 0;
883 u32 pipe_id = (u32) ~ 0;
884 u32 profile_id = (u32) ~ 0;
886 clib_error_t *error = NULL;
888 if (!unformat_user (input, unformat_line_input, line_input))
891 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
894 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
897 else if (unformat (line_input, "subport %d", &subport_id))
899 else if (unformat (line_input, "pipe %d", &pipe_id))
901 else if (unformat (line_input, "profile %d", &profile_id))
905 error = clib_error_return (0, "parse error: '%U'",
906 format_unformat_error, line_input);
911 if (hw_if_index == (u32) ~ 0)
913 error = clib_error_return (0, "please specify valid interface name");
917 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
918 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
921 rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
925 error = clib_error_return (0, "pipe configuration failed");
930 unformat_free (line_input);
936 * This command is used to change the profile associate with a HQoS pipe. The
937 * '<em><profile_id></em>' is zero based. Use the command
938 * '<em>show dpdk interface hqos</em>' to display the content of each profile.
939 * See @ref qos_doc for more details.
942 * Currently there is not an API to create a new HQoS pipe profile. One is
943 * created by default in the code (search for '<em>hqos_pipe_params_default</em>'').
944 * Additional profiles can be created in code and code recompiled. Then use this
945 * command to assign it.
948 * Example of how to assign a new profile to a HQoS pipe:
949 * @cliexcmd{set dpdk interface hqos pipe GigabitEthernet0/8/0 subport 0 pipe 2 profile 1}
952 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pipe, static) =
954 .path = "set dpdk interface hqos pipe",
955 .short_help = "set dpdk interface hqos pipe <interface> subport <subport_id> pipe <pipe_id> "
956 "profile <profile_id>",
957 .function = set_dpdk_if_hqos_pipe,
961 static clib_error_t *
962 set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
963 vlib_cli_command_t * cmd)
965 unformat_input_t _line_input, *line_input = &_line_input;
966 dpdk_main_t *dm = &dpdk_main;
967 dpdk_device_t *xd = NULL;
968 u32 hw_if_index = (u32) ~ 0;
969 u32 subport_id = (u32) ~ 0;
970 struct rte_sched_subport_params p;
972 clib_error_t *error = NULL;
973 u32 tb_rate = (u32) ~ 0;
974 u32 tb_size = (u32) ~ 0;
975 u32 tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] =
976 { (u32) ~ 0, (u32) ~ 0, (u32) ~ 0, (u32) ~ 0 };
977 u32 tc_period = (u32) ~ 0;
978 dpdk_device_config_t *devconf = NULL;
980 if (!unformat_user (input, unformat_line_input, line_input))
983 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
986 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
989 else if (unformat (line_input, "subport %d", &subport_id))
991 else if (unformat (line_input, "rate %d", &tb_rate))
993 else if (unformat (line_input, "bktsize %d", &tb_size))
995 else if (unformat (line_input, "tc0 %d", &tc_rate[0]))
997 else if (unformat (line_input, "tc1 %d", &tc_rate[1]))
999 else if (unformat (line_input, "tc2 %d", &tc_rate[2]))
1001 else if (unformat (line_input, "tc3 %d", &tc_rate[3]))
1003 else if (unformat (line_input, "period %d", &tc_period))
1007 error = clib_error_return (0, "parse error: '%U'",
1008 format_unformat_error, line_input);
1013 error = get_hqos (hw_if_index, subport_id, &xd, &devconf);
1017 /* Copy the current values over to local structure. */
1018 memcpy (&p, &devconf->hqos.subport[subport_id], sizeof (p));
1020 /* Update local structure with input values. */
1021 if (tb_rate != (u32) ~ 0)
1023 p.tb_rate = tb_rate;
1024 p.tc_rate[0] = tb_rate;
1025 p.tc_rate[1] = tb_rate;
1026 p.tc_rate[2] = tb_rate;
1027 p.tc_rate[3] = tb_rate;
1029 if (tb_size != (u32) ~ 0)
1031 p.tb_size = tb_size;
1033 if (tc_rate[0] != (u32) ~ 0)
1035 p.tc_rate[0] = tc_rate[0];
1037 if (tc_rate[1] != (u32) ~ 0)
1039 p.tc_rate[1] = tc_rate[1];
1041 if (tc_rate[2] != (u32) ~ 0)
1043 p.tc_rate[2] = tc_rate[2];
1045 if (tc_rate[3] != (u32) ~ 0)
1047 p.tc_rate[3] = tc_rate[3];
1049 if (tc_period != (u32) ~ 0)
1051 p.tc_period = tc_period;
1054 /* Apply changes. */
1055 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
1058 error = clib_error_return (0, "subport configuration failed");
1063 /* Successfully applied, so save of the input values. */
1064 memcpy (&devconf->hqos.subport[subport_id], &p, sizeof (p));
1069 unformat_free (line_input);
1075 * This command is used to set the subport level parameters such as token
1076 * bucket rate (bytes per seconds), token bucket size (bytes), traffic class
1077 * rates (bytes per seconds) and token update period (Milliseconds).
1079 * By default, the '<em>rate</em>' is set to 1250000000 bytes/second (10GbE
1080 * rate) and each of the four traffic classes is set to 100% of the port rate.
1081 * If the '<em>rate</em>' is updated by this command, all four traffic classes
1082 * are assigned the same value. Each of the four traffic classes can be updated
1086 * Example of how modify the subport attributes for a 1GbE link:
1087 * @cliexcmd{set dpdk interface hqos subport GigabitEthernet0/8/0 subport 0 rate 125000000}
1090 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_subport, static) = {
1091 .path = "set dpdk interface hqos subport",
1092 .short_help = "set dpdk interface hqos subport <interface> subport <subport_id> "
1093 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] "
1095 .function = set_dpdk_if_hqos_subport,
1099 static clib_error_t *
1100 set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
1101 vlib_cli_command_t * cmd)
1103 unformat_input_t _line_input, *line_input = &_line_input;
1104 vlib_thread_main_t *tm = vlib_get_thread_main ();
1105 dpdk_main_t *dm = &dpdk_main;
1106 vnet_hw_interface_t *hw;
1108 u32 hw_if_index = (u32) ~ 0;
1110 u32 queue = (u32) ~ 0;
1111 u32 entry = (u32) ~ 0;
1113 clib_error_t *error = NULL;
1115 if (!unformat_user (input, unformat_line_input, line_input))
1118 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1121 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1124 else if (unformat (line_input, "entry %d", &entry))
1126 else if (unformat (line_input, "tc %d", &tc))
1128 else if (unformat (line_input, "queue %d", &queue))
1132 error = clib_error_return (0, "parse error: '%U'",
1133 format_unformat_error, line_input);
1138 if (hw_if_index == (u32) ~ 0)
1140 error = clib_error_return (0, "please specify valid interface name");
1145 error = clib_error_return (0, "invalid entry");
1148 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1150 error = clib_error_return (0, "invalid traffic class");
1153 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1155 error = clib_error_return (0, "invalid traffic class queue");
1159 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1160 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1162 /* Detect the set of worker threads */
1163 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1164 /* Should never happen, shut up Coverity warning */
1167 error = clib_error_return (0, "no worker registrations?");
1171 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1172 int worker_thread_first = tr->first_index;
1173 int worker_thread_count = tr->count;
1175 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1176 for (i = 0; i < worker_thread_count; i++)
1177 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
1180 unformat_free (line_input);
1186 * This command is used to set the traffic class translation table. The
1187 * traffic class translation table is used to map 64 values (0-63) to one of
1188 * four traffic class and one of four HQoS input queue. Use the '<em>show
1189 * dpdk interface hqos</em>' command to display the traffic class translation
1190 * table. See @ref qos_doc for more details.
1192 * This command has the following parameters:
1194 * - <b><interface></b> - Used to specify the output interface.
1196 * - <b>entry <map_val></b> - Mapped value (0-63) to assign traffic class and queue to.
1198 * - <b>tc <tc_id></b> - Traffic class (0-3) to be used by the provided mapped value.
1200 * - <b>queue <queue_id></b> - HQoS input queue (0-3) to be used by the provided mapped value.
1203 * Example of how modify the traffic class translation table:
1204 * @cliexcmd{set dpdk interface hqos tctbl GigabitEthernet0/8/0 entry 16 tc 2 queue 2}
1207 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_tctbl, static) = {
1208 .path = "set dpdk interface hqos tctbl",
1209 .short_help = "set dpdk interface hqos tctbl <interface> entry <map_val> tc <tc_id> queue <queue_id>",
1210 .function = set_dpdk_if_hqos_tctbl,
1214 static clib_error_t *
1215 set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
1216 vlib_cli_command_t * cmd)
1218 unformat_input_t _line_input, *line_input = &_line_input;
1219 vlib_thread_main_t *tm = vlib_get_thread_main ();
1220 dpdk_main_t *dm = &dpdk_main;
1221 clib_error_t *error = NULL;
1223 /* Device specific data */
1224 struct rte_eth_dev_info dev_info;
1225 struct rte_pci_device *pci_dev;
1226 dpdk_device_config_t *devconf = 0;
1227 vnet_hw_interface_t *hw;
1229 u32 hw_if_index = (u32) ~ 0;
1231 /* Detect the set of worker threads */
1232 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1233 /* Should never happen, shut up Coverity warning */
1235 return clib_error_return (0, "no worker registrations?");
1237 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1238 int worker_thread_first = tr->first_index;
1239 int worker_thread_count = tr->count;
1241 /* Packet field configuration */
1242 u64 mask = (u64) ~ 0;
1244 u32 offset = (u32) ~ 0;
1247 u32 n_subports_per_port, n_pipes_per_subport, tctbl_size;
1251 /* Parse input arguments */
1252 if (!unformat_user (input, unformat_line_input, line_input))
1255 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1258 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1261 else if (unformat (line_input, "id subport"))
1263 else if (unformat (line_input, "id pipe"))
1265 else if (unformat (line_input, "id tc"))
1267 else if (unformat (line_input, "id %d", &id))
1269 else if (unformat (line_input, "offset %d", &offset))
1271 else if (unformat (line_input, "mask %llx", &mask))
1275 error = clib_error_return (0, "parse error: '%U'",
1276 format_unformat_error, line_input);
1282 if (hw_if_index == (u32) ~ 0)
1284 error = clib_error_return (0, "please specify valid interface name");
1288 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1289 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1291 rte_eth_dev_info_get (xd->port_id, &dev_info);
1293 #if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
1294 pci_dev = dev_info.pci_dev;
1296 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
1300 { /* bonded interface has no pci info */
1301 vlib_pci_addr_t pci_addr;
1303 pci_addr.domain = pci_dev->addr.domain;
1304 pci_addr.bus = pci_dev->addr.bus;
1305 pci_addr.slot = pci_dev->addr.devid;
1306 pci_addr.function = pci_dev->addr.function;
1309 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1313 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1315 devconf = &dm->conf->default_devconf;
1317 if (devconf->hqos_enabled == 0)
1319 vlib_cli_output (vm, "HQoS disabled for this interface");
1323 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
1324 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
1325 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
1327 /* Validate packet field configuration: id, offset and mask */
1330 error = clib_error_return (0, "invalid packet field id");
1337 if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
1339 error = clib_error_return (0, "invalid subport ID mask "
1340 "(n_subports_per_port = %u)",
1341 n_subports_per_port);
1346 if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
1348 error = clib_error_return (0, "invalid pipe ID mask "
1349 "(n_pipes_per_subport = %u)",
1350 n_pipes_per_subport);
1356 if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
1358 error = clib_error_return (0, "invalid TC table index mask "
1359 "(TC table size = %u)", tctbl_size);
1364 /* Propagate packet field configuration to all workers */
1365 for (i = 0; i < worker_thread_count; i++)
1369 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabpos = offset;
1370 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabmask = mask;
1371 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabshr =
1372 count_trailing_zeros (mask);
1375 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabpos = offset;
1376 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabmask = mask;
1377 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabshr =
1378 count_trailing_zeros (mask);
1382 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabpos = offset;
1383 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabmask = mask;
1384 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabshr =
1385 count_trailing_zeros (mask);
1389 unformat_free (line_input);
1395 * This command is used to set the packet fields required for classifiying the
1396 * incoming packet. As a result of classification process, packet field
1397 * information will be mapped to 5 tuples (subport, pipe, traffic class, pipe,
1398 * color) and stored in packet mbuf.
1400 * This command has the following parameters:
1402 * - <b><interface></b> - Used to specify the output interface.
1404 * - <b>id subport|pipe|tc</b> - Classification occurs across three fields.
1405 * This parameter indicates which of the three masks are being configured. Legacy
1406 * code used 0-2 to represent these three fields, so 0-2 is still accepted.
1407 * - <b>subport|0</b> - Currently only one subport is supported, so only
1408 * an empty mask is supported for the subport classification.
1409 * - <b>pipe|1</b> - Currently, 4096 pipes per subport are supported, so a
1410 * 12-bit mask should be configure to map to the 0-4095 pipes.
1411 * - <b>tc|2</b> - The translation table (see '<em>set dpdk interface hqos
1412 * tctbl</em>' command) maps each value (0-63) into one of the 4 traffic classes
1413 * per pipe. A 6-bit mask should be configure to map this field to a traffic class.
1415 * - <b>offset <n></b> - Offset in the packet to apply the 64-bit mask for classification.
1416 * The offset should be on an 8-byte boundary (0,8,16,24..).
1418 * - <b>mask <hex-mask></b> - 64-bit mask to apply to packet at the given '<em>offset</em>'.
1419 * Bits must be contiguous and should not include '<em>0x</em>'.
1421 * The default values for the '<em>pktfield</em>' assumes Ethernet/IPv4/UDP packets with
1422 * no VLAN. Adjust based on expected packet format and desired classification field.
1423 * - '<em>subport</em>' is always empty (offset 0 mask 0000000000000000)
1424 * - By default, '<em>pipe</em>' maps to the UDP payload bits 12 .. 23 (offset 40
1425 * mask 0000000fff000000)
1426 * - By default, '<em>tc</em>' maps to the DSCP field in IP header (offset 48 mask
1430 * Example of how modify the '<em>pipe</em>' classification filter to match VLAN:
1431 * @cliexcmd{set dpdk interface hqos pktfield GigabitEthernet0/8/0 id pipe offset 8 mask 0000000000000FFF}
1434 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pktfield, static) = {
1435 .path = "set dpdk interface hqos pktfield",
1436 .short_help = "set dpdk interface hqos pktfield <interface> id subport|pipe|tc offset <n> "
1438 .function = set_dpdk_if_hqos_pktfield,
1442 static clib_error_t *
1443 show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
1444 vlib_cli_command_t * cmd)
1446 unformat_input_t _line_input, *line_input = &_line_input;
1447 vlib_thread_main_t *tm = vlib_get_thread_main ();
1448 dpdk_main_t *dm = &dpdk_main;
1449 vnet_hw_interface_t *hw;
1451 dpdk_device_config_hqos_t *cfg;
1452 dpdk_device_hqos_per_hqos_thread_t *ht;
1453 dpdk_device_hqos_per_worker_thread_t *wk;
1455 u32 hw_if_index = (u32) ~ 0;
1456 u32 profile_id, subport_id, i;
1457 struct rte_eth_dev_info dev_info;
1458 struct rte_pci_device *pci_dev;
1459 dpdk_device_config_t *devconf = 0;
1460 vlib_thread_registration_t *tr;
1462 clib_error_t *error = NULL;
1464 if (!unformat_user (input, unformat_line_input, line_input))
1467 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1470 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1475 error = clib_error_return (0, "parse error: '%U'",
1476 format_unformat_error, line_input);
1481 if (hw_if_index == (u32) ~ 0)
1483 error = clib_error_return (0, "please specify interface name!!");
1487 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1488 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1490 rte_eth_dev_info_get (xd->port_id, &dev_info);
1492 #if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0)
1493 pci_dev = dev_info.pci_dev;
1495 pci_dev = RTE_DEV_TO_PCI (dev_info.device);
1499 { /* bonded interface has no pci info */
1500 vlib_pci_addr_t pci_addr;
1502 pci_addr.domain = pci_dev->addr.domain;
1503 pci_addr.bus = pci_dev->addr.bus;
1504 pci_addr.slot = pci_dev->addr.devid;
1505 pci_addr.function = pci_dev->addr.function;
1508 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1512 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1514 devconf = &dm->conf->default_devconf;
1516 if (devconf->hqos_enabled == 0)
1518 vlib_cli_output (vm, "HQoS disabled for this interface");
1522 /* Detect the set of worker threads */
1523 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1525 /* Should never happen, shut up Coverity warning */
1528 error = clib_error_return (0, "no worker registrations?");
1532 tr = (vlib_thread_registration_t *) p[0];
1534 cfg = &devconf->hqos;
1536 wk = &xd->hqos_wt[tr->first_index];
1537 tctbl = wk->hqos_tc_table;
1539 vlib_cli_output (vm, " Thread:");
1540 vlib_cli_output (vm, " Input SWQ size = %u packets", cfg->swq_size);
1541 vlib_cli_output (vm, " Enqueue burst size = %u packets",
1542 ht->hqos_burst_enq);
1543 vlib_cli_output (vm, " Dequeue burst size = %u packets",
1544 ht->hqos_burst_deq);
1546 vlib_cli_output (vm,
1547 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx (subport)",
1548 wk->hqos_field0_slabpos, wk->hqos_field0_slabmask);
1549 vlib_cli_output (vm,
1550 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx (pipe)",
1551 wk->hqos_field1_slabpos, wk->hqos_field1_slabmask);
1552 vlib_cli_output (vm,
1553 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx (tc)",
1554 wk->hqos_field2_slabpos, wk->hqos_field2_slabmask);
1555 vlib_cli_output (vm,
1556 " Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)");
1557 vlib_cli_output (vm,
1559 "%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",
1560 tctbl[0] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1561 tctbl[0] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1562 tctbl[1] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1563 tctbl[1] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1564 tctbl[2] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1565 tctbl[2] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1566 tctbl[3] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1567 tctbl[3] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1568 tctbl[4] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1569 tctbl[4] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1570 tctbl[5] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1571 tctbl[5] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1572 tctbl[6] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1573 tctbl[6] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1574 tctbl[7] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1575 tctbl[7] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1576 tctbl[8] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1577 tctbl[8] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1578 tctbl[9] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1579 tctbl[9] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1580 tctbl[10] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1581 tctbl[10] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1582 tctbl[11] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1583 tctbl[11] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1584 tctbl[12] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1585 tctbl[12] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1586 tctbl[13] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1587 tctbl[13] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1588 tctbl[14] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1589 tctbl[14] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1590 tctbl[15] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1591 tctbl[15] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1592 vlib_cli_output (vm,
1594 "%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",
1595 tctbl[16] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1596 tctbl[16] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1597 tctbl[17] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1598 tctbl[17] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1599 tctbl[18] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1600 tctbl[18] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1601 tctbl[19] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1602 tctbl[19] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1603 tctbl[20] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1604 tctbl[20] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1605 tctbl[21] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1606 tctbl[21] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1607 tctbl[22] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1608 tctbl[22] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1609 tctbl[23] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1610 tctbl[23] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1611 tctbl[24] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1612 tctbl[24] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1613 tctbl[25] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1614 tctbl[25] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1615 tctbl[26] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1616 tctbl[26] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1617 tctbl[27] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1618 tctbl[27] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1619 tctbl[28] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1620 tctbl[28] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1621 tctbl[29] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1622 tctbl[29] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1623 tctbl[30] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1624 tctbl[30] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1625 tctbl[31] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1626 tctbl[31] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1627 vlib_cli_output (vm,
1629 "%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",
1630 tctbl[32] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1631 tctbl[32] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1632 tctbl[33] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1633 tctbl[33] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1634 tctbl[34] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1635 tctbl[34] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1636 tctbl[35] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1637 tctbl[35] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1638 tctbl[36] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1639 tctbl[36] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1640 tctbl[37] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1641 tctbl[37] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1642 tctbl[38] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1643 tctbl[38] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1644 tctbl[39] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1645 tctbl[39] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1646 tctbl[40] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1647 tctbl[40] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1648 tctbl[41] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1649 tctbl[41] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1650 tctbl[42] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1651 tctbl[42] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1652 tctbl[43] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1653 tctbl[43] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1654 tctbl[44] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1655 tctbl[44] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1656 tctbl[45] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1657 tctbl[45] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1658 tctbl[46] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1659 tctbl[46] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1660 tctbl[47] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1661 tctbl[47] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1662 vlib_cli_output (vm,
1664 "%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",
1665 tctbl[48] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1666 tctbl[48] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1667 tctbl[49] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1668 tctbl[49] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1669 tctbl[50] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1670 tctbl[50] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1671 tctbl[51] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1672 tctbl[51] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1673 tctbl[52] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1674 tctbl[52] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1675 tctbl[53] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1676 tctbl[53] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1677 tctbl[54] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1678 tctbl[54] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1679 tctbl[55] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1680 tctbl[55] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1681 tctbl[56] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1682 tctbl[56] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1683 tctbl[57] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1684 tctbl[57] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1685 tctbl[58] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1686 tctbl[58] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1687 tctbl[59] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1688 tctbl[59] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1689 tctbl[60] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1690 tctbl[60] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1691 tctbl[61] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1692 tctbl[61] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1693 tctbl[62] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1694 tctbl[62] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1695 tctbl[63] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1696 tctbl[63] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1697 vlib_cli_output (vm, " Port:");
1698 vlib_cli_output (vm, " Rate = %u bytes/second", cfg->port.rate);
1699 vlib_cli_output (vm, " MTU = %u bytes", cfg->port.mtu);
1700 vlib_cli_output (vm, " Frame overhead = %u bytes",
1701 cfg->port.frame_overhead);
1702 vlib_cli_output (vm, " Number of subports = %u",
1703 cfg->port.n_subports_per_port);
1704 vlib_cli_output (vm, " Number of pipes per subport = %u",
1705 cfg->port.n_pipes_per_subport);
1706 vlib_cli_output (vm,
1707 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1708 cfg->port.qsize[0], cfg->port.qsize[1], cfg->port.qsize[2],
1709 cfg->port.qsize[3]);
1710 vlib_cli_output (vm, " Number of pipe profiles = %u",
1711 cfg->port.n_pipe_profiles);
1713 for (subport_id = 0; subport_id < vec_len (cfg->subport); subport_id++)
1715 vlib_cli_output (vm, " Subport %u:", subport_id);
1716 vlib_cli_output (vm, " Rate = %u bytes/second",
1717 cfg->subport[subport_id].tb_rate);
1718 vlib_cli_output (vm, " Token bucket size = %u bytes",
1719 cfg->subport[subport_id].tb_size);
1720 vlib_cli_output (vm,
1721 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1722 cfg->subport[subport_id].tc_rate[0],
1723 cfg->subport[subport_id].tc_rate[1],
1724 cfg->subport[subport_id].tc_rate[2],
1725 cfg->subport[subport_id].tc_rate[3]);
1726 vlib_cli_output (vm, " TC period = %u milliseconds",
1727 cfg->subport[subport_id].tc_period);
1730 for (profile_id = 0; profile_id < vec_len (cfg->pipe); profile_id++)
1732 vlib_cli_output (vm, " Pipe profile %u:", profile_id);
1733 vlib_cli_output (vm, " Rate = %u bytes/second",
1734 cfg->pipe[profile_id].tb_rate);
1735 vlib_cli_output (vm, " Token bucket size = %u bytes",
1736 cfg->pipe[profile_id].tb_size);
1737 vlib_cli_output (vm,
1738 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1739 cfg->pipe[profile_id].tc_rate[0],
1740 cfg->pipe[profile_id].tc_rate[1],
1741 cfg->pipe[profile_id].tc_rate[2],
1742 cfg->pipe[profile_id].tc_rate[3]);
1743 vlib_cli_output (vm, " TC period = %u milliseconds",
1744 cfg->pipe[profile_id].tc_period);
1745 #ifdef RTE_SCHED_SUBPORT_TC_OV
1746 vlib_cli_output (vm, " TC3 oversubscription_weight = %u",
1747 cfg->pipe[profile_id].tc_ov_weight);
1750 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1752 vlib_cli_output (vm,
1753 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1754 i, cfg->pipe[profile_id].wrr_weights[i * 4],
1755 cfg->pipe[profile_id].wrr_weights[i * 4 + 1],
1756 cfg->pipe[profile_id].wrr_weights[i * 4 + 2],
1757 cfg->pipe[profile_id].wrr_weights[i * 4 + 3]);
1761 #ifdef RTE_SCHED_RED
1762 vlib_cli_output (vm, " Weighted Random Early Detection (WRED):");
1763 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1765 vlib_cli_output (vm, " TC%u min: G = %u, Y = %u, R = %u", i,
1766 cfg->port.red_params[i][e_RTE_METER_GREEN].min_th,
1767 cfg->port.red_params[i][e_RTE_METER_YELLOW].min_th,
1768 cfg->port.red_params[i][e_RTE_METER_RED].min_th);
1770 vlib_cli_output (vm, " TC%u max: G = %u, Y = %u, R = %u", i,
1771 cfg->port.red_params[i][e_RTE_METER_GREEN].max_th,
1772 cfg->port.red_params[i][e_RTE_METER_YELLOW].max_th,
1773 cfg->port.red_params[i][e_RTE_METER_RED].max_th);
1775 vlib_cli_output (vm,
1776 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1777 i, cfg->port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1778 cfg->port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1779 cfg->port.red_params[i][e_RTE_METER_RED].maxp_inv);
1781 vlib_cli_output (vm, " TC%u weight: R = %u, Y = %u, R = %u", i,
1782 cfg->port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1783 cfg->port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1784 cfg->port.red_params[i][e_RTE_METER_RED].wq_log2);
1789 unformat_free (line_input);
1795 * This command is used to display details of an output interface's HQoS
1799 * Example of how to display HQoS settings for an interfaces:
1800 * @cliexstart{show dpdk interface hqos GigabitEthernet0/8/0}
1802 * Input SWQ size = 4096 packets
1803 * Enqueue burst size = 256 packets
1804 * Dequeue burst size = 220 packets
1805 * Packet field 0: slab position = 0, slab bitmask = 0x0000000000000000 (subport)
1806 * Packet field 1: slab position = 40, slab bitmask = 0x0000000fff000000 (pipe)
1807 * Packet field 2: slab position = 8, slab bitmask = 0x00000000000000fc (tc)
1808 * Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)
1809 * [ 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
1810 * [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
1811 * [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
1812 * [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
1814 * Rate = 1250000000 bytes/second
1816 * Frame overhead = 24 bytes
1817 * Number of subports = 1
1818 * Number of pipes per subport = 4096
1819 * Packet queue size: TC0 = 64, TC1 = 64, TC2 = 64, TC3 = 64 packets
1820 * Number of pipe profiles = 2
1822 * Rate = 1250000000 bytes/second
1823 * Token bucket size = 1000000 bytes
1824 * Traffic class rate: TC0 = 1250000000, TC1 = 1250000000, TC2 = 1250000000, TC3 = 1250000000 bytes/second
1825 * TC period = 10 milliseconds
1827 * Rate = 305175 bytes/second
1828 * Token bucket size = 1000000 bytes
1829 * Traffic class rate: TC0 = 305175, TC1 = 305175, TC2 = 305175, TC3 = 305175 bytes/second
1830 * TC period = 40 milliseconds
1831 * TC0 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1832 * TC1 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1833 * TC2 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1834 * TC3 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1838 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos, static) = {
1839 .path = "show dpdk interface hqos",
1840 .short_help = "show dpdk interface hqos <interface>",
1841 .function = show_dpdk_if_hqos,
1846 static clib_error_t *
1847 show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
1848 vlib_cli_command_t * cmd)
1850 unformat_input_t _line_input, *line_input = &_line_input;
1851 clib_error_t *error = NULL;
1852 #ifdef RTE_SCHED_COLLECT_STATS
1853 dpdk_main_t *dm = &dpdk_main;
1854 u32 hw_if_index = (u32) ~ 0;
1855 u32 subport = (u32) ~ 0;
1856 u32 pipe = (u32) ~ 0;
1858 u32 tc_q = (u32) ~ 0;
1859 vnet_hw_interface_t *hw;
1862 struct rte_eth_dev_info dev_info;
1863 dpdk_device_config_t *devconf = 0;
1865 struct rte_sched_queue_stats stats;
1868 if (!unformat_user (input, unformat_line_input, line_input))
1871 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1874 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1878 else if (unformat (line_input, "subport %d", &subport))
1881 else if (unformat (line_input, "pipe %d", &pipe))
1884 else if (unformat (line_input, "tc %d", &tc))
1887 else if (unformat (line_input, "tc_q %d", &tc_q))
1892 error = clib_error_return (0, "parse error: '%U'",
1893 format_unformat_error, line_input);
1898 if (hw_if_index == (u32) ~ 0)
1900 error = clib_error_return (0, "please specify interface name!!");
1904 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1905 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1907 rte_eth_dev_info_get (xd->port_id, &dev_info);
1908 if (dev_info.pci_dev)
1909 { /* bonded interface has no pci info */
1910 vlib_pci_addr_t pci_addr;
1912 pci_addr.domain = dev_info.pci_dev->addr.domain;
1913 pci_addr.bus = dev_info.pci_dev->addr.bus;
1914 pci_addr.slot = dev_info.pci_dev->addr.devid;
1915 pci_addr.function = dev_info.pci_dev->addr.function;
1918 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1922 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1924 devconf = &dm->conf->default_devconf;
1926 if (devconf->hqos_enabled == 0)
1928 vlib_cli_output (vm, "HQoS disabled for this interface");
1933 * Figure out which queue to query. cf rte_sched_port_qindex. (Not sure why
1934 * that method isn't made public by DPDK - how _should_ we get the queue ID?)
1936 qindex = subport * devconf->hqos.port.n_pipes_per_subport + pipe;
1937 qindex = qindex * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE + tc;
1938 qindex = qindex * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + tc_q;
1940 if (rte_sched_queue_read_stats (xd->hqos_ht->hqos, qindex, &stats, &qlen) !=
1943 error = clib_error_return (0, "failed to read stats");
1947 vlib_cli_output (vm, "%=24s%=16s", "Stats Parameter", "Value");
1948 vlib_cli_output (vm, "%=24s%=16d", "Packets", stats.n_pkts);
1949 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped", stats.n_pkts_dropped);
1950 #ifdef RTE_SCHED_RED
1951 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped (RED)",
1952 stats.n_pkts_red_dropped);
1954 vlib_cli_output (vm, "%=24s%=16d", "Bytes", stats.n_bytes);
1955 vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped);
1959 /* Get a line of input */
1960 if (!unformat_user (input, unformat_line_input, line_input))
1963 vlib_cli_output (vm, "RTE_SCHED_COLLECT_STATS disabled in DPDK");
1969 unformat_free (line_input);
1975 * This command is used to display statistics associated with a HQoS traffic class
1979 * Statistic collection by the scheduler is disabled by default in DPDK. In order to
1980 * turn it on, add the following line to '<em>../vpp/dpdk/Makefile</em>':
1981 * - <b>$(call set,RTE_SCHED_COLLECT_STATS,y)</b>
1984 * Example of how to display statistics of HQoS a HQoS traffic class queue:
1985 * @cliexstart{show dpdk hqos queue GigabitEthernet0/9/0 subport 0 pipe 3181 tc 0 tc_q 0}
1986 * Stats Parameter Value
1994 VLIB_CLI_COMMAND (cmd_show_dpdk_hqos_queue_stats, static) = {
1995 .path = "show dpdk hqos queue",
1996 .short_help = "show dpdk hqos queue <interface> subport <subport_id> pipe <pipe_id> tc <tc_id> tc_q <queue_id>",
1997 .function = show_dpdk_hqos_queue_stats,
2001 static clib_error_t *
2002 show_dpdk_version_command_fn (vlib_main_t * vm,
2003 unformat_input_t * input,
2004 vlib_cli_command_t * cmd)
2006 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
2007 _("DPDK Version", "%s", rte_version ());
2008 _("DPDK EAL init args", "%s", dpdk_config_main.eal_init_args_str);
2014 * This command is used to display the current DPDK version and
2015 * the list of arguments passed to DPDK when started.
2018 * Example of how to display how many DPDK buffer test command has allcoated:
2019 * @cliexstart{show dpdk version}
2020 * DPDK Version: DPDK 16.11.0
2021 * 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
2025 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
2026 .path = "show dpdk version",
2027 .short_help = "show dpdk version",
2028 .function = show_dpdk_version_command_fn,
2034 static clib_error_t *
2035 dpdk_validate_buffers_fn (vlib_main_t * vm, unformat_input_t * input,
2036 vlib_cli_command_t * cmd_arg)
2038 u32 n_invalid_bufs = 0, uninitialized = 0;
2039 u32 is_poison = 0, is_test = 0;
2040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2042 if (unformat (input, "poison"))
2044 else if (unformat (input, "trajectory"))
2047 return clib_error_return (0, "unknown input `%U'",
2048 format_unformat_error, input);
2051 if (VLIB_BUFFER_TRACE_TRAJECTORY == 0)
2053 vlib_cli_output (vm, "Trajectory not enabled. Recompile with "
2054 "VLIB_BUFFER_TRACE_TRAJECTORY 1");
2059 dpdk_buffer_poison_trajectory_all ();
2063 n_invalid_bufs = dpdk_buffer_validate_trajectory_all (&uninitialized);
2064 if (!n_invalid_bufs)
2065 vlib_cli_output (vm, "All buffers are valid %d uninitialized",
2068 vlib_cli_output (vm, "Found %d invalid buffers and %d uninitialized",
2069 n_invalid_bufs, uninitialized);
2075 VLIB_CLI_COMMAND (test_dpdk_buffers_command, static) =
2077 .path = "test dpdk buffers",
2078 .short_help = "test dpdk buffers [poison] [trajectory]",
2079 .function = dpdk_validate_buffers_fn,
2086 dpdk_cli_init (vlib_main_t * vm)
2091 VLIB_INIT_FUNCTION (dpdk_cli_init);
2094 * fd.io coding-style-patch-verification: ON
2097 * eval: (c-set-style "gnu")