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/buffer.h>
28 #include <dpdk/device/dpdk.h>
29 #include <vnet/classify/vnet_classify.h>
30 #include <vnet/mpls/packet.h>
32 #include <dpdk/device/dpdk_priv.h>
36 * @brief CLI for DPDK Abstraction Layer and pcap Tx Trace.
38 * This file contains the source code for CLI for DPDK
39 * Abstraction Layer and pcap Tx Trace.
44 get_hqos (u32 hw_if_index, u32 subport_id, dpdk_device_t ** xd,
45 dpdk_device_config_t ** devconf)
47 dpdk_main_t *dm = &dpdk_main;
48 vnet_hw_interface_t *hw;
49 struct rte_eth_dev_info dev_info;
50 struct rte_pci_device *pci_dev;
52 clib_error_t *error = NULL;
55 if (hw_if_index == (u32) ~ 0)
57 error = clib_error_return (0, "please specify valid interface name");
63 error = clib_error_return (0, "Invalid subport");
67 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
68 *xd = vec_elt_at_index (dm->devices, hw->dev_instance);
70 rte_eth_dev_info_get ((*xd)->port_id, &dev_info);
72 pci_dev = dpdk_get_pci_device (&dev_info);
76 vlib_pci_addr_t pci_addr;
78 pci_addr.domain = pci_dev->addr.domain;
79 pci_addr.bus = pci_dev->addr.bus;
80 pci_addr.slot = pci_dev->addr.devid;
81 pci_addr.function = pci_dev->addr.function;
84 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
88 (*devconf) = pool_elt_at_index (dm->conf->dev_confs, p[0]);
90 (*devconf) = &dm->conf->default_devconf;
96 static inline clib_error_t *
97 pcap_trace_command_internal (vlib_main_t * vm,
98 unformat_input_t * input,
99 vlib_cli_command_t * cmd, int rx_tx)
101 #define PCAP_DEF_PKT_TO_CAPTURE (100)
103 unformat_input_t _line_input, *line_input = &_line_input;
104 dpdk_main_t *dm = &dpdk_main;
106 u8 *chroot_filename = 0;
110 clib_error_t *error = 0;
112 /* Get a line of input. */
113 if (!unformat_user (input, unformat_line_input, line_input))
116 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
118 if (unformat (line_input, "on"))
120 if (dm->pcap[rx_tx].pcap_enable == 0)
126 vlib_cli_output (vm, "pcap tx capture already on...");
131 else if (unformat (line_input, "off"))
133 if (dm->pcap[rx_tx].pcap_enable)
136 (vm, "captured %d pkts...",
137 dm->pcap[rx_tx].pcap_main.n_packets_captured);
138 if (dm->pcap[rx_tx].pcap_main.n_packets_captured)
140 dm->pcap[rx_tx].pcap_main.n_packets_to_capture =
141 dm->pcap[rx_tx].pcap_main.n_packets_captured;
142 error = pcap_write (&dm->pcap[rx_tx].pcap_main);
144 clib_error_report (error);
146 vlib_cli_output (vm, "saved to %s...",
147 dm->pcap[rx_tx].pcap_main.file_name);
150 dm->pcap[rx_tx].pcap_enable = 0;
154 vlib_cli_output (vm, "pcap tx capture already off...");
159 else if (unformat (line_input, "max %d", &max))
161 if (dm->pcap[rx_tx].pcap_enable)
165 "can't change max value while pcap tx capture active...");
169 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
171 else if (unformat (line_input, "intfc %U",
172 unformat_vnet_sw_interface, dm->vnet_main,
173 &dm->pcap[rx_tx].pcap_sw_if_index))
176 else if (unformat (line_input, "intfc any"))
178 dm->pcap[rx_tx].pcap_sw_if_index = 0;
180 else if (unformat (line_input, "file %s", &filename))
182 if (dm->pcap[rx_tx].pcap_enable)
185 (vm, "can't change file while pcap tx capture active...");
190 /* Brain-police user path input */
191 if (strstr ((char *) filename, "..")
192 || index ((char *) filename, '/'))
194 vlib_cli_output (vm, "illegal characters in filename '%s'",
196 vlib_cli_output (vm, "Hint: .. and / are not allowed.");
202 chroot_filename = format (0, "/tmp/%s%c", filename, 0);
205 else if (unformat (line_input, "status"))
207 if (dm->pcap[rx_tx].pcap_sw_if_index == 0)
210 (vm, "max is %d for any interface to file %s",
211 dm->pcap[rx_tx].pcap_main.n_packets_to_capture ?
212 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
213 : PCAP_DEF_PKT_TO_CAPTURE,
214 dm->pcap[rx_tx].pcap_main.file_name ?
215 (u8 *) dm->pcap[rx_tx].pcap_main.file_name :
216 (u8 *) "/tmp/vpe.pcap");
220 vlib_cli_output (vm, "max is %d for interface %U to file %s",
221 dm->pcap[rx_tx].pcap_main.n_packets_to_capture
223 pcap_main.n_packets_to_capture :
224 PCAP_DEF_PKT_TO_CAPTURE,
225 format_vnet_sw_if_index_name, dm->vnet_main,
226 dm->pcap_sw_if_index,
228 pcap_main.file_name ? (u8 *) dm->pcap[rx_tx].
229 pcap_main.file_name : (u8 *) "/tmp/vpe.pcap");
232 if (dm->pcap[rx_tx].pcap_enable == 0)
234 vlib_cli_output (vm, "pcap %s capture is off...",
235 (rx_tx == VLIB_RX) ? "rx" : "tx");
239 vlib_cli_output (vm, "pcap %s capture is on: %d of %d pkts...",
240 (rx_tx == VLIB_RX) ? "rx" : "tx",
241 dm->pcap[rx_tx].pcap_main.n_packets_captured,
243 pcap_main.n_packets_to_capture);
250 error = clib_error_return (0, "unknown input `%U'",
251 format_unformat_error, line_input);
256 unformat_free (line_input);
261 /* Since no error, save configured values. */
264 if (dm->pcap[rx_tx].pcap_main.file_name)
265 vec_free (dm->pcap[rx_tx].pcap_main.file_name);
266 vec_add1 (chroot_filename, 0);
267 dm->pcap[rx_tx].pcap_main.file_name = (char *) chroot_filename;
271 dm->pcap[rx_tx].pcap_main.n_packets_to_capture = max;
275 if (dm->pcap[rx_tx].pcap_main.file_name == 0)
276 dm->pcap[rx_tx].pcap_main.file_name
277 = (char *) format (0, "/tmp/vpe.pcap%c", 0);
279 dm->pcap[rx_tx].pcap_main.n_packets_captured = 0;
280 dm->pcap[rx_tx].pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
281 if (dm->pcap[rx_tx].pcap_main.lock == 0)
282 clib_spinlock_init (&(dm->pcap[rx_tx].pcap_main.lock));
283 dm->pcap[rx_tx].pcap_enable = 1;
284 vlib_cli_output (vm, "pcap %s capture on...",
285 rx_tx == VLIB_RX ? "rx" : "tx");
288 else if (chroot_filename)
289 vec_free (chroot_filename);
294 static clib_error_t *
295 pcap_rx_trace_command_fn (vlib_main_t * vm,
296 unformat_input_t * input, vlib_cli_command_t * cmd)
298 return pcap_trace_command_internal (vm, input, cmd, VLIB_RX);
301 static clib_error_t *
302 pcap_tx_trace_command_fn (vlib_main_t * vm,
303 unformat_input_t * input, vlib_cli_command_t * cmd)
305 return pcap_trace_command_internal (vm, input, cmd, VLIB_TX);
310 * This command is used to start or stop a packet capture, or show
311 * the status of packet capture. Note that both "pcap rx trace" and
312 * "pcap tx trace" are implemented. The command syntax is identical,
313 * simply substitute rx for tx as needed.
315 * This command has the following optional parameters:
317 * - <b>on|off</b> - Used to start or stop a packet capture.
319 * - <b>max <nn></b> - Depth of local buffer. Once '<em>nn</em>' number
320 * of packets have been received, buffer is flushed to file. Once another
321 * '<em>nn</em>' number of packets have been received, buffer is flushed
322 * to file, overwriting previous write. If not entered, value defaults
323 * to 100. Can only be updated if packet capture is off.
325 * - <b>intfc <interface>|any</b> - Used to specify a given interface,
326 * or use '<em>any</em>' to run packet capture on all interfaces.
327 * '<em>any</em>' is the default if not provided. Settings from a previous
328 * packet capture are preserved, so '<em>any</em>' can be used to reset
329 * the interface setting.
331 * - <b>file <name></b> - Used to specify the output filename. The file will
332 * be placed in the '<em>/tmp</em>' directory, so only the filename is
333 * supported. Directory should not be entered. If file already exists, file
334 * will be overwritten. If no filename is provided, '<em>/tmp/vpe.pcap</em>'
335 * will be used. Can only be updated if packet capture is off.
337 * - <b>status</b> - Displays the current status and configured attributes
338 * associated with a packet capture. If packet capture is in progress,
339 * '<em>status</em>' also will return the number of packets currently in
340 * the local buffer. All additional attributes entered on command line
341 * with '<em>status</em>' will be ignored and not applied.
344 * Example of how to display the status of a tx packet capture when off:
345 * @cliexstart{pcap tx trace status}
346 * max is 100, for any interface to file /tmp/vpe.pcap
347 * pcap tx capture is off...
349 * Example of how to start a tx packet capture:
350 * @cliexstart{pcap tx trace on max 35 intfc GigabitEthernet0/8/0 file vppTest.pcap}
351 * pcap tx capture on...
353 * Example of how to display the status of a tx packet capture in progress:
354 * @cliexstart{pcap tx trace status}
355 * max is 35, for interface GigabitEthernet0/8/0 to file /tmp/vppTest.pcap
356 * pcap tx capture is on: 20 of 35 pkts...
358 * Example of how to stop a tx packet capture:
359 * @cliexstart{vppctl pcap tx trace off}
360 * captured 21 pkts...
361 * saved to /tmp/vppTest.pcap...
366 VLIB_CLI_COMMAND (pcap_tx_trace_command, static) = {
367 .path = "pcap tx trace",
369 "pcap tx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
370 .function = pcap_tx_trace_command_fn,
372 VLIB_CLI_COMMAND (pcap_rx_trace_command, static) = {
373 .path = "pcap rx trace",
375 "pcap rx trace [on|off] [max <nn>] [intfc <interface>|any] [file <name>] [status]",
376 .function = pcap_rx_trace_command_fn,
381 static clib_error_t *
382 show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
383 vlib_cli_command_t * cmd)
385 struct rte_mempool *rmp;
388 for (i = 0; i < vec_len (dpdk_main.pktmbuf_pools); i++)
390 rmp = dpdk_main.pktmbuf_pools[i];
393 unsigned count = rte_mempool_avail_count (rmp);
394 unsigned free_count = rte_mempool_in_use_count (rmp);
397 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
398 rmp->name, (u32) count, (u32) free_count,
399 (u32) (count + free_count));
403 vlib_cli_output (vm, "rte_mempool is NULL (!)\n");
410 * This command displays statistics of each DPDK mempool.
413 * Example of how to display DPDK buffer data:
414 * @cliexstart{show dpdk buffer}
415 * name="mbuf_pool_socket0" available = 15104 allocated = 1280 total = 16384
419 VLIB_CLI_COMMAND (cmd_show_dpdk_buffer,static) = {
420 .path = "show dpdk buffer",
421 .short_help = "show dpdk buffer",
422 .function = show_dpdk_buffer,
427 static clib_error_t *
428 show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
429 vlib_cli_command_t * cmd)
431 clib_error_t *err = 0;
438 err = clib_sysfs_read ("/proc/sys/fs/pipe-max-size", "%u", &pipe_max_size);
443 if (pipe (fds) == -1)
444 return clib_error_return_unix (0, "pipe");
447 #define F_SETPIPE_SZ (1024 + 7)
450 if (fcntl (fds[1], F_SETPIPE_SZ, pipe_max_size) == -1)
452 err = clib_error_return_unix (0, "fcntl(F_SETPIPE_SZ)");
456 if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1)
458 err = clib_error_return_unix (0, "fcntl(F_SETFL)");
462 if ((f = fdopen (fds[1], "a")) == 0)
464 err = clib_error_return_unix (0, "fdopen");
468 rte_dump_physmem_layout (f);
474 uword len = vec_len (s);
475 vec_resize (s, len + n_try);
477 n = read (fds[0], s + len, n_try);
478 if (n < 0 && errno != EAGAIN)
480 err = clib_error_return_unix (0, "read");
483 _vec_len (s) = len + (n < 0 ? 0 : n);
486 vlib_cli_output (vm, "%v", s);
496 * This command displays DPDK physmem layout
499 * Example of how to display DPDK physmem layout:
500 * @cliexstart{show dpdk physmem}
504 VLIB_CLI_COMMAND (cmd_show_dpdk_physmem,static) = {
505 .path = "show dpdk physmem",
506 .short_help = "show dpdk physmem",
507 .function = show_dpdk_physmem,
512 static clib_error_t *
513 test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
514 vlib_cli_command_t * cmd)
516 static u32 *allocated_buffers;
519 u32 first, actual_alloc;
521 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
523 if (unformat (input, "allocate %d", &n_alloc))
525 else if (unformat (input, "free %d", &n_free))
533 if (vec_len (allocated_buffers) < n_free)
534 return clib_error_return (0, "Can't free %d, only %d allocated",
535 n_free, vec_len (allocated_buffers));
537 first = vec_len (allocated_buffers) - n_free;
538 vlib_buffer_free (vm, allocated_buffers + first, n_free);
539 _vec_len (allocated_buffers) = first;
543 first = vec_len (allocated_buffers);
544 vec_validate (allocated_buffers,
545 vec_len (allocated_buffers) + n_alloc - 1);
547 actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
549 _vec_len (allocated_buffers) = first + actual_alloc;
551 if (actual_alloc < n_alloc)
552 vlib_cli_output (vm, "WARNING: only allocated %d buffers",
556 vlib_cli_output (vm, "Currently %d buffers allocated",
557 vec_len (allocated_buffers));
559 if (allocated_buffers && vec_len (allocated_buffers) == 0)
560 vec_free (allocated_buffers);
566 * This command tests the allocation and freeing of DPDK buffers.
567 * If both '<em>allocate</em>' and '<em>free</em>' are entered on the
568 * same command, the '<em>free</em>' is executed first. If no
569 * parameters are provided, this command display how many DPDK buffers
570 * the test command has allocated.
575 * Example of how to display how many DPDK buffer test command has allocated:
576 * @cliexstart{test dpdk buffer}
577 * Currently 0 buffers allocated
580 * Example of how to allocate DPDK buffers using the test command:
581 * @cliexstart{test dpdk buffer allocate 10}
582 * Currently 10 buffers allocated
585 * Example of how to free DPDK buffers allocated by the test command:
586 * @cliexstart{test dpdk buffer free 10}
587 * Currently 0 buffers allocated
592 VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = {
593 .path = "test dpdk buffer",
594 .short_help = "test dpdk buffer [allocate <nn>] [free <nn>]",
595 .function = test_dpdk_buffer,
600 static clib_error_t *
601 set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
602 vlib_cli_command_t * cmd)
604 unformat_input_t _line_input, *line_input = &_line_input;
605 dpdk_main_t *dm = &dpdk_main;
606 vnet_hw_interface_t *hw;
608 u32 hw_if_index = (u32) ~ 0;
609 u32 nb_rx_desc = (u32) ~ 0;
610 u32 nb_tx_desc = (u32) ~ 0;
611 clib_error_t *error = NULL;
613 if (!unformat_user (input, unformat_line_input, line_input))
616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
619 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
622 else if (unformat (line_input, "tx %d", &nb_tx_desc))
624 else if (unformat (line_input, "rx %d", &nb_rx_desc))
628 error = clib_error_return (0, "parse error: '%U'",
629 format_unformat_error, line_input);
634 if (hw_if_index == (u32) ~ 0)
636 error = clib_error_return (0, "please specify valid interface name");
640 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
641 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
643 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
646 clib_error_return (0,
647 "number of descriptors can be set only for "
652 if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
653 (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
655 error = clib_error_return (0, "nothing changed");
659 if (nb_rx_desc != (u32) ~ 0)
660 xd->nb_rx_desc = nb_rx_desc;
662 if (nb_tx_desc != (u32) ~ 0)
663 xd->nb_tx_desc = nb_tx_desc;
665 dpdk_device_setup (xd);
667 if (vec_len (xd->errors))
668 return clib_error_return (0, "%U", format_dpdk_device_errors, xd);
671 unformat_free (line_input);
677 * This command sets the number of DPDK '<em>rx</em>' and
678 * '<em>tx</em>' descriptors for the given physical interface. Use
679 * the command '<em>show hardware-interface</em>' to display the
680 * current descriptor allocation.
683 * Example of how to set the DPDK interface descriptors:
684 * @cliexcmd{set dpdk interface descriptors GigabitEthernet0/8/0 rx 512 tx 512}
687 VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = {
688 .path = "set dpdk interface descriptors",
689 .short_help = "set dpdk interface descriptors <interface> [rx <nn>] [tx <nn>]",
690 .function = set_dpdk_if_desc,
695 dpdk_device_queue_sort (void *a1, void *a2)
697 dpdk_device_and_queue_t *dq1 = a1;
698 dpdk_device_and_queue_t *dq2 = a2;
700 if (dq1->device > dq2->device)
702 else if (dq1->device < dq2->device)
704 else if (dq1->queue_id > dq2->queue_id)
706 else if (dq1->queue_id < dq2->queue_id)
713 static clib_error_t *
714 show_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
715 vlib_cli_command_t * cmd)
717 vlib_thread_main_t *tm = vlib_get_thread_main ();
718 dpdk_main_t *dm = &dpdk_main;
719 dpdk_device_and_queue_t *dq;
722 if (tm->n_vlib_mains == 1)
723 vlib_cli_output (vm, "All interfaces are handled by main thread");
725 for (cpu = 0; cpu < vec_len (dm->devices_by_hqos_cpu); cpu++)
727 if (cpu >= dm->hqos_cpu_first_index &&
728 cpu < (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
729 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
730 vlib_worker_threads[cpu].name,
731 vlib_worker_threads[cpu].cpu_id);
733 vec_foreach (dq, dm->devices_by_hqos_cpu[cpu])
735 u32 hw_if_index = dm->devices[dq->device].hw_if_index;
736 vnet_hw_interface_t *hi =
737 vnet_get_hw_interface (dm->vnet_main, hw_if_index);
738 vlib_cli_output (vm, " %v queue %u", hi->name, dq->queue_id);
745 * This command is used to display the thread and core each
746 * DPDK output interface and HQoS queue is assigned too.
749 * Example of how to display the DPDK output interface and HQoS queue placement:
750 * @cliexstart{show dpdk interface hqos placement}
751 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
752 * GigabitEthernet0/8/0 queue 0
753 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
754 * GigabitEthernet0/9/0 queue 0
758 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos_placement, static) = {
759 .path = "show dpdk interface hqos placement",
760 .short_help = "show dpdk interface hqos placement",
761 .function = show_dpdk_if_hqos_placement,
765 static clib_error_t *
766 set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
767 vlib_cli_command_t * cmd)
769 unformat_input_t _line_input, *line_input = &_line_input;
770 dpdk_main_t *dm = &dpdk_main;
771 dpdk_device_and_queue_t *dq;
772 vnet_hw_interface_t *hw;
774 u32 hw_if_index = (u32) ~ 0;
777 clib_error_t *error = NULL;
779 if (!unformat_user (input, unformat_line_input, line_input))
782 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
785 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
788 else if (unformat (line_input, "thread %d", &cpu))
792 error = clib_error_return (0, "parse error: '%U'",
793 format_unformat_error, line_input);
798 if (hw_if_index == (u32) ~ 0)
799 return clib_error_return (0, "please specify valid interface name");
801 if (cpu < dm->hqos_cpu_first_index ||
802 cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
804 error = clib_error_return (0, "please specify valid thread id");
808 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
809 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
811 for (i = 0; i < vec_len (dm->devices_by_hqos_cpu); i++)
813 vec_foreach (dq, dm->devices_by_hqos_cpu[i])
815 if (hw_if_index == dm->devices[dq->device].hw_if_index)
817 if (cpu == i) /* nothing to do */
820 vec_del1 (dm->devices_by_hqos_cpu[i],
821 dq - dm->devices_by_hqos_cpu[i]);
822 vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
824 dq->device = xd->device_index;
826 vec_sort_with_function (dm->devices_by_hqos_cpu[i],
827 dpdk_device_queue_sort);
829 vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
830 dpdk_device_queue_sort);
837 error = clib_error_return (0, "not found");
840 unformat_free (line_input);
846 * This command is used to assign a given DPDK output interface and
847 * HQoS queue to a different thread. This will not create a thread,
848 * so the thread must already exist. Use '<em>/etc/vpp/startup.conf</em>'
849 * for the initial thread creation. See @ref qos_doc for more details.
852 * Example of how to display the DPDK output interface and HQoS queue placement:
853 * @cliexstart{show dpdk interface hqos placement}
854 * Thread 1 (vpp_hqos-threads_0 at lcore 3):
855 * GigabitEthernet0/8/0 queue 0
856 * Thread 2 (vpp_hqos-threads_1 at lcore 4):
857 * GigabitEthernet0/9/0 queue 0
859 * Example of how to assign a DPDK output interface and HQoS queue to a thread:
860 * @cliexcmd{set dpdk interface hqos placement GigabitEthernet0/8/0 thread 2}
863 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_placement, static) = {
864 .path = "set dpdk interface hqos placement",
865 .short_help = "set dpdk interface hqos placement <interface> thread <n>",
866 .function = set_dpdk_if_hqos_placement,
870 static clib_error_t *
871 set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
872 vlib_cli_command_t * cmd)
874 unformat_input_t _line_input, *line_input = &_line_input;
875 dpdk_main_t *dm = &dpdk_main;
876 vnet_hw_interface_t *hw;
878 u32 hw_if_index = (u32) ~ 0;
879 u32 subport_id = (u32) ~ 0;
880 u32 pipe_id = (u32) ~ 0;
881 u32 profile_id = (u32) ~ 0;
883 clib_error_t *error = NULL;
885 if (!unformat_user (input, unformat_line_input, line_input))
888 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
891 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
894 else if (unformat (line_input, "subport %d", &subport_id))
896 else if (unformat (line_input, "pipe %d", &pipe_id))
898 else if (unformat (line_input, "profile %d", &profile_id))
902 error = clib_error_return (0, "parse error: '%U'",
903 format_unformat_error, line_input);
908 if (hw_if_index == (u32) ~ 0)
910 error = clib_error_return (0, "please specify valid interface name");
914 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
915 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
918 rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
922 error = clib_error_return (0, "pipe configuration failed");
927 unformat_free (line_input);
933 * This command is used to change the profile associate with a HQoS pipe. The
934 * '<em><profile_id></em>' is zero based. Use the command
935 * '<em>show dpdk interface hqos</em>' to display the content of each profile.
936 * See @ref qos_doc for more details.
939 * Currently there is not an API to create a new HQoS pipe profile. One is
940 * created by default in the code (search for '<em>hqos_pipe_params_default</em>'').
941 * Additional profiles can be created in code and code recompiled. Then use this
942 * command to assign it.
945 * Example of how to assign a new profile to a HQoS pipe:
946 * @cliexcmd{set dpdk interface hqos pipe GigabitEthernet0/8/0 subport 0 pipe 2 profile 1}
949 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pipe, static) =
951 .path = "set dpdk interface hqos pipe",
952 .short_help = "set dpdk interface hqos pipe <interface> subport <subport_id> pipe <pipe_id> "
953 "profile <profile_id>",
954 .function = set_dpdk_if_hqos_pipe,
958 static clib_error_t *
959 set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
960 vlib_cli_command_t * cmd)
962 unformat_input_t _line_input, *line_input = &_line_input;
963 dpdk_main_t *dm = &dpdk_main;
964 dpdk_device_t *xd = NULL;
965 u32 hw_if_index = (u32) ~ 0;
966 u32 subport_id = (u32) ~ 0;
967 struct rte_sched_subport_params p;
969 clib_error_t *error = NULL;
970 u32 tb_rate = (u32) ~ 0;
971 u32 tb_size = (u32) ~ 0;
972 u32 tc_rate[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE] =
973 { (u32) ~ 0, (u32) ~ 0, (u32) ~ 0, (u32) ~ 0 };
974 u32 tc_period = (u32) ~ 0;
975 dpdk_device_config_t *devconf = NULL;
977 if (!unformat_user (input, unformat_line_input, line_input))
980 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
983 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
986 else if (unformat (line_input, "subport %d", &subport_id))
988 else if (unformat (line_input, "rate %d", &tb_rate))
990 else if (unformat (line_input, "bktsize %d", &tb_size))
992 else if (unformat (line_input, "tc0 %d", &tc_rate[0]))
994 else if (unformat (line_input, "tc1 %d", &tc_rate[1]))
996 else if (unformat (line_input, "tc2 %d", &tc_rate[2]))
998 else if (unformat (line_input, "tc3 %d", &tc_rate[3]))
1000 else if (unformat (line_input, "period %d", &tc_period))
1004 error = clib_error_return (0, "parse error: '%U'",
1005 format_unformat_error, line_input);
1010 error = get_hqos (hw_if_index, subport_id, &xd, &devconf);
1014 /* Copy the current values over to local structure. */
1015 memcpy (&p, &devconf->hqos.subport[subport_id], sizeof (p));
1017 /* Update local structure with input values. */
1018 if (tb_rate != (u32) ~ 0)
1020 p.tb_rate = tb_rate;
1021 p.tc_rate[0] = tb_rate;
1022 p.tc_rate[1] = tb_rate;
1023 p.tc_rate[2] = tb_rate;
1024 p.tc_rate[3] = tb_rate;
1026 if (tb_size != (u32) ~ 0)
1028 p.tb_size = tb_size;
1030 if (tc_rate[0] != (u32) ~ 0)
1032 p.tc_rate[0] = tc_rate[0];
1034 if (tc_rate[1] != (u32) ~ 0)
1036 p.tc_rate[1] = tc_rate[1];
1038 if (tc_rate[2] != (u32) ~ 0)
1040 p.tc_rate[2] = tc_rate[2];
1042 if (tc_rate[3] != (u32) ~ 0)
1044 p.tc_rate[3] = tc_rate[3];
1046 if (tc_period != (u32) ~ 0)
1048 p.tc_period = tc_period;
1051 /* Apply changes. */
1052 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
1055 error = clib_error_return (0, "subport configuration failed");
1060 /* Successfully applied, so save of the input values. */
1061 memcpy (&devconf->hqos.subport[subport_id], &p, sizeof (p));
1066 unformat_free (line_input);
1072 * This command is used to set the subport level parameters such as token
1073 * bucket rate (bytes per seconds), token bucket size (bytes), traffic class
1074 * rates (bytes per seconds) and token update period (Milliseconds).
1076 * By default, the '<em>rate</em>' is set to 1250000000 bytes/second (10GbE
1077 * rate) and each of the four traffic classes is set to 100% of the port rate.
1078 * If the '<em>rate</em>' is updated by this command, all four traffic classes
1079 * are assigned the same value. Each of the four traffic classes can be updated
1083 * Example of how modify the subport attributes for a 1GbE link:
1084 * @cliexcmd{set dpdk interface hqos subport GigabitEthernet0/8/0 subport 0 rate 125000000}
1087 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_subport, static) = {
1088 .path = "set dpdk interface hqos subport",
1089 .short_help = "set dpdk interface hqos subport <interface> subport <subport_id> "
1090 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] "
1092 .function = set_dpdk_if_hqos_subport,
1096 static clib_error_t *
1097 set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
1098 vlib_cli_command_t * cmd)
1100 unformat_input_t _line_input, *line_input = &_line_input;
1101 vlib_thread_main_t *tm = vlib_get_thread_main ();
1102 dpdk_main_t *dm = &dpdk_main;
1103 vnet_hw_interface_t *hw;
1105 u32 hw_if_index = (u32) ~ 0;
1107 u32 queue = (u32) ~ 0;
1108 u32 entry = (u32) ~ 0;
1110 clib_error_t *error = NULL;
1112 if (!unformat_user (input, unformat_line_input, line_input))
1115 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1118 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1121 else if (unformat (line_input, "entry %d", &entry))
1123 else if (unformat (line_input, "tc %d", &tc))
1125 else if (unformat (line_input, "queue %d", &queue))
1129 error = clib_error_return (0, "parse error: '%U'",
1130 format_unformat_error, line_input);
1135 if (hw_if_index == (u32) ~ 0)
1137 error = clib_error_return (0, "please specify valid interface name");
1142 error = clib_error_return (0, "invalid entry");
1145 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1147 error = clib_error_return (0, "invalid traffic class");
1150 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1152 error = clib_error_return (0, "invalid traffic class queue");
1156 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1157 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1159 /* Detect the set of worker threads */
1160 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1161 /* Should never happen, shut up Coverity warning */
1164 error = clib_error_return (0, "no worker registrations?");
1168 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1169 int worker_thread_first = tr->first_index;
1170 int worker_thread_count = tr->count;
1172 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1173 for (i = 0; i < worker_thread_count; i++)
1174 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
1177 unformat_free (line_input);
1183 * This command is used to set the traffic class translation table. The
1184 * traffic class translation table is used to map 64 values (0-63) to one of
1185 * four traffic class and one of four HQoS input queue. Use the '<em>show
1186 * dpdk interface hqos</em>' command to display the traffic class translation
1187 * table. See @ref qos_doc for more details.
1189 * This command has the following parameters:
1191 * - <b><interface></b> - Used to specify the output interface.
1193 * - <b>entry <map_val></b> - Mapped value (0-63) to assign traffic class and queue to.
1195 * - <b>tc <tc_id></b> - Traffic class (0-3) to be used by the provided mapped value.
1197 * - <b>queue <queue_id></b> - HQoS input queue (0-3) to be used by the provided mapped value.
1200 * Example of how modify the traffic class translation table:
1201 * @cliexcmd{set dpdk interface hqos tctbl GigabitEthernet0/8/0 entry 16 tc 2 queue 2}
1204 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_tctbl, static) = {
1205 .path = "set dpdk interface hqos tctbl",
1206 .short_help = "set dpdk interface hqos tctbl <interface> entry <map_val> tc <tc_id> queue <queue_id>",
1207 .function = set_dpdk_if_hqos_tctbl,
1211 static clib_error_t *
1212 set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
1213 vlib_cli_command_t * cmd)
1215 unformat_input_t _line_input, *line_input = &_line_input;
1216 vlib_thread_main_t *tm = vlib_get_thread_main ();
1217 dpdk_main_t *dm = &dpdk_main;
1218 clib_error_t *error = NULL;
1220 /* Device specific data */
1221 struct rte_eth_dev_info dev_info;
1222 struct rte_pci_device *pci_dev;
1223 dpdk_device_config_t *devconf = 0;
1224 vnet_hw_interface_t *hw;
1226 u32 hw_if_index = (u32) ~ 0;
1228 /* Detect the set of worker threads */
1229 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1230 /* Should never happen, shut up Coverity warning */
1232 return clib_error_return (0, "no worker registrations?");
1234 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1235 int worker_thread_first = tr->first_index;
1236 int worker_thread_count = tr->count;
1238 /* Packet field configuration */
1239 u64 mask = (u64) ~ 0;
1241 u32 offset = (u32) ~ 0;
1244 u32 n_subports_per_port, n_pipes_per_subport, tctbl_size;
1248 /* Parse input arguments */
1249 if (!unformat_user (input, unformat_line_input, line_input))
1252 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1255 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1258 else if (unformat (line_input, "id subport"))
1260 else if (unformat (line_input, "id pipe"))
1262 else if (unformat (line_input, "id tc"))
1264 else if (unformat (line_input, "id %d", &id))
1266 else if (unformat (line_input, "offset %d", &offset))
1268 else if (unformat (line_input, "mask %llx", &mask))
1272 error = clib_error_return (0, "parse error: '%U'",
1273 format_unformat_error, line_input);
1279 if (hw_if_index == (u32) ~ 0)
1281 error = clib_error_return (0, "please specify valid interface name");
1285 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1286 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1288 rte_eth_dev_info_get (xd->port_id, &dev_info);
1290 pci_dev = dpdk_get_pci_device (&dev_info);
1293 { /* bonded interface has no pci info */
1294 vlib_pci_addr_t pci_addr;
1296 pci_addr.domain = pci_dev->addr.domain;
1297 pci_addr.bus = pci_dev->addr.bus;
1298 pci_addr.slot = pci_dev->addr.devid;
1299 pci_addr.function = pci_dev->addr.function;
1302 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1306 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1308 devconf = &dm->conf->default_devconf;
1310 if (devconf->hqos_enabled == 0)
1312 vlib_cli_output (vm, "HQoS disabled for this interface");
1316 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
1317 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
1318 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
1320 /* Validate packet field configuration: id, offset and mask */
1323 error = clib_error_return (0, "invalid packet field id");
1330 if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
1332 error = clib_error_return (0, "invalid subport ID mask "
1333 "(n_subports_per_port = %u)",
1334 n_subports_per_port);
1339 if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
1341 error = clib_error_return (0, "invalid pipe ID mask "
1342 "(n_pipes_per_subport = %u)",
1343 n_pipes_per_subport);
1349 if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
1351 error = clib_error_return (0, "invalid TC table index mask "
1352 "(TC table size = %u)", tctbl_size);
1357 /* Propagate packet field configuration to all workers */
1358 for (i = 0; i < worker_thread_count; i++)
1362 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabpos = offset;
1363 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabmask = mask;
1364 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabshr =
1365 count_trailing_zeros (mask);
1368 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabpos = offset;
1369 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabmask = mask;
1370 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabshr =
1371 count_trailing_zeros (mask);
1375 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabpos = offset;
1376 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabmask = mask;
1377 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabshr =
1378 count_trailing_zeros (mask);
1382 unformat_free (line_input);
1388 * This command is used to set the packet fields required for classifying the
1389 * incoming packet. As a result of classification process, packet field
1390 * information will be mapped to 5 tuples (subport, pipe, traffic class, pipe,
1391 * color) and stored in packet mbuf.
1393 * This command has the following parameters:
1395 * - <b><interface></b> - Used to specify the output interface.
1397 * - <b>id subport|pipe|tc</b> - Classification occurs across three fields.
1398 * This parameter indicates which of the three masks are being configured. Legacy
1399 * code used 0-2 to represent these three fields, so 0-2 is still accepted.
1400 * - <b>subport|0</b> - Currently only one subport is supported, so only
1401 * an empty mask is supported for the subport classification.
1402 * - <b>pipe|1</b> - Currently, 4096 pipes per subport are supported, so a
1403 * 12-bit mask should be configure to map to the 0-4095 pipes.
1404 * - <b>tc|2</b> - The translation table (see '<em>set dpdk interface hqos
1405 * tctbl</em>' command) maps each value (0-63) into one of the 4 traffic classes
1406 * per pipe. A 6-bit mask should be configure to map this field to a traffic class.
1408 * - <b>offset <n></b> - Offset in the packet to apply the 64-bit mask for classification.
1409 * The offset should be on an 8-byte boundary (0,8,16,24..).
1411 * - <b>mask <hex-mask></b> - 64-bit mask to apply to packet at the given '<em>offset</em>'.
1412 * Bits must be contiguous and should not include '<em>0x</em>'.
1414 * The default values for the '<em>pktfield</em>' assumes Ethernet/IPv4/UDP packets with
1415 * no VLAN. Adjust based on expected packet format and desired classification field.
1416 * - '<em>subport</em>' is always empty (offset 0 mask 0000000000000000)
1417 * - By default, '<em>pipe</em>' maps to the UDP payload bits 12 .. 23 (offset 40
1418 * mask 0000000fff000000)
1419 * - By default, '<em>tc</em>' maps to the DSCP field in IP header (offset 48 mask
1423 * Example of how modify the '<em>pipe</em>' classification filter to match VLAN:
1424 * @cliexcmd{set dpdk interface hqos pktfield GigabitEthernet0/8/0 id pipe offset 8 mask 0000000000000FFF}
1427 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pktfield, static) = {
1428 .path = "set dpdk interface hqos pktfield",
1429 .short_help = "set dpdk interface hqos pktfield <interface> id subport|pipe|tc offset <n> "
1431 .function = set_dpdk_if_hqos_pktfield,
1435 static clib_error_t *
1436 show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
1437 vlib_cli_command_t * cmd)
1439 unformat_input_t _line_input, *line_input = &_line_input;
1440 vlib_thread_main_t *tm = vlib_get_thread_main ();
1441 dpdk_main_t *dm = &dpdk_main;
1442 vnet_hw_interface_t *hw;
1444 dpdk_device_config_hqos_t *cfg;
1445 dpdk_device_hqos_per_hqos_thread_t *ht;
1446 dpdk_device_hqos_per_worker_thread_t *wk;
1448 u32 hw_if_index = (u32) ~ 0;
1449 u32 profile_id, subport_id, i;
1450 struct rte_eth_dev_info dev_info;
1451 struct rte_pci_device *pci_dev;
1452 dpdk_device_config_t *devconf = 0;
1453 vlib_thread_registration_t *tr;
1455 clib_error_t *error = NULL;
1457 if (!unformat_user (input, unformat_line_input, line_input))
1460 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1463 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1468 error = clib_error_return (0, "parse error: '%U'",
1469 format_unformat_error, line_input);
1474 if (hw_if_index == (u32) ~ 0)
1476 error = clib_error_return (0, "please specify interface name!!");
1480 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1481 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1483 rte_eth_dev_info_get (xd->port_id, &dev_info);
1485 pci_dev = dpdk_get_pci_device (&dev_info);
1488 { /* bonded interface has no pci info */
1489 vlib_pci_addr_t pci_addr;
1491 pci_addr.domain = pci_dev->addr.domain;
1492 pci_addr.bus = pci_dev->addr.bus;
1493 pci_addr.slot = pci_dev->addr.devid;
1494 pci_addr.function = pci_dev->addr.function;
1497 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1501 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1503 devconf = &dm->conf->default_devconf;
1505 if (devconf->hqos_enabled == 0)
1507 vlib_cli_output (vm, "HQoS disabled for this interface");
1511 /* Detect the set of worker threads */
1512 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1514 /* Should never happen, shut up Coverity warning */
1517 error = clib_error_return (0, "no worker registrations?");
1521 tr = (vlib_thread_registration_t *) p[0];
1523 cfg = &devconf->hqos;
1525 wk = &xd->hqos_wt[tr->first_index];
1526 tctbl = wk->hqos_tc_table;
1528 vlib_cli_output (vm, " Thread:");
1529 vlib_cli_output (vm, " Input SWQ size = %u packets", cfg->swq_size);
1530 vlib_cli_output (vm, " Enqueue burst size = %u packets",
1531 ht->hqos_burst_enq);
1532 vlib_cli_output (vm, " Dequeue burst size = %u packets",
1533 ht->hqos_burst_deq);
1535 vlib_cli_output (vm,
1536 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx (subport)",
1537 wk->hqos_field0_slabpos, wk->hqos_field0_slabmask);
1538 vlib_cli_output (vm,
1539 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx (pipe)",
1540 wk->hqos_field1_slabpos, wk->hqos_field1_slabmask);
1541 vlib_cli_output (vm,
1542 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx (tc)",
1543 wk->hqos_field2_slabpos, wk->hqos_field2_slabmask);
1544 vlib_cli_output (vm,
1545 " Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)");
1546 vlib_cli_output (vm,
1548 "%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",
1549 tctbl[0] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1550 tctbl[0] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1551 tctbl[1] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1552 tctbl[1] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1553 tctbl[2] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1554 tctbl[2] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1555 tctbl[3] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1556 tctbl[3] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1557 tctbl[4] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1558 tctbl[4] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1559 tctbl[5] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1560 tctbl[5] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1561 tctbl[6] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1562 tctbl[6] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1563 tctbl[7] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1564 tctbl[7] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1565 tctbl[8] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1566 tctbl[8] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1567 tctbl[9] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1568 tctbl[9] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1569 tctbl[10] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1570 tctbl[10] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1571 tctbl[11] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1572 tctbl[11] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1573 tctbl[12] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1574 tctbl[12] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1575 tctbl[13] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1576 tctbl[13] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1577 tctbl[14] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1578 tctbl[14] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1579 tctbl[15] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1580 tctbl[15] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1581 vlib_cli_output (vm,
1583 "%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",
1584 tctbl[16] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1585 tctbl[16] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1586 tctbl[17] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1587 tctbl[17] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1588 tctbl[18] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1589 tctbl[18] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1590 tctbl[19] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1591 tctbl[19] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1592 tctbl[20] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1593 tctbl[20] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1594 tctbl[21] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1595 tctbl[21] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1596 tctbl[22] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1597 tctbl[22] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1598 tctbl[23] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1599 tctbl[23] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1600 tctbl[24] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1601 tctbl[24] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1602 tctbl[25] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1603 tctbl[25] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1604 tctbl[26] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1605 tctbl[26] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1606 tctbl[27] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1607 tctbl[27] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1608 tctbl[28] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1609 tctbl[28] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1610 tctbl[29] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1611 tctbl[29] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1612 tctbl[30] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1613 tctbl[30] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1614 tctbl[31] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1615 tctbl[31] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1616 vlib_cli_output (vm,
1618 "%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",
1619 tctbl[32] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1620 tctbl[32] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1621 tctbl[33] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1622 tctbl[33] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1623 tctbl[34] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1624 tctbl[34] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1625 tctbl[35] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1626 tctbl[35] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1627 tctbl[36] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1628 tctbl[36] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1629 tctbl[37] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1630 tctbl[37] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1631 tctbl[38] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1632 tctbl[38] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1633 tctbl[39] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1634 tctbl[39] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1635 tctbl[40] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1636 tctbl[40] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1637 tctbl[41] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1638 tctbl[41] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1639 tctbl[42] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1640 tctbl[42] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1641 tctbl[43] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1642 tctbl[43] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1643 tctbl[44] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1644 tctbl[44] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1645 tctbl[45] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1646 tctbl[45] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1647 tctbl[46] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1648 tctbl[46] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1649 tctbl[47] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1650 tctbl[47] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1651 vlib_cli_output (vm,
1653 "%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",
1654 tctbl[48] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1655 tctbl[48] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1656 tctbl[49] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1657 tctbl[49] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1658 tctbl[50] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1659 tctbl[50] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1660 tctbl[51] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1661 tctbl[51] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1662 tctbl[52] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1663 tctbl[52] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1664 tctbl[53] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1665 tctbl[53] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1666 tctbl[54] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1667 tctbl[54] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1668 tctbl[55] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1669 tctbl[55] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1670 tctbl[56] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1671 tctbl[56] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1672 tctbl[57] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1673 tctbl[57] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1674 tctbl[58] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1675 tctbl[58] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1676 tctbl[59] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1677 tctbl[59] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1678 tctbl[60] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1679 tctbl[60] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1680 tctbl[61] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1681 tctbl[61] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1682 tctbl[62] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1683 tctbl[62] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1684 tctbl[63] / RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS,
1685 tctbl[63] % RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS);
1686 vlib_cli_output (vm, " Port:");
1687 vlib_cli_output (vm, " Rate = %u bytes/second", cfg->port.rate);
1688 vlib_cli_output (vm, " MTU = %u bytes", cfg->port.mtu);
1689 vlib_cli_output (vm, " Frame overhead = %u bytes",
1690 cfg->port.frame_overhead);
1691 vlib_cli_output (vm, " Number of subports = %u",
1692 cfg->port.n_subports_per_port);
1693 vlib_cli_output (vm, " Number of pipes per subport = %u",
1694 cfg->port.n_pipes_per_subport);
1695 vlib_cli_output (vm,
1696 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1697 cfg->port.qsize[0], cfg->port.qsize[1], cfg->port.qsize[2],
1698 cfg->port.qsize[3]);
1699 vlib_cli_output (vm, " Number of pipe profiles = %u",
1700 cfg->port.n_pipe_profiles);
1702 for (subport_id = 0; subport_id < vec_len (cfg->subport); subport_id++)
1704 vlib_cli_output (vm, " Subport %u:", subport_id);
1705 vlib_cli_output (vm, " Rate = %u bytes/second",
1706 cfg->subport[subport_id].tb_rate);
1707 vlib_cli_output (vm, " Token bucket size = %u bytes",
1708 cfg->subport[subport_id].tb_size);
1709 vlib_cli_output (vm,
1710 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1711 cfg->subport[subport_id].tc_rate[0],
1712 cfg->subport[subport_id].tc_rate[1],
1713 cfg->subport[subport_id].tc_rate[2],
1714 cfg->subport[subport_id].tc_rate[3]);
1715 vlib_cli_output (vm, " TC period = %u milliseconds",
1716 cfg->subport[subport_id].tc_period);
1719 for (profile_id = 0; profile_id < vec_len (cfg->pipe); profile_id++)
1721 vlib_cli_output (vm, " Pipe profile %u:", profile_id);
1722 vlib_cli_output (vm, " Rate = %u bytes/second",
1723 cfg->pipe[profile_id].tb_rate);
1724 vlib_cli_output (vm, " Token bucket size = %u bytes",
1725 cfg->pipe[profile_id].tb_size);
1726 vlib_cli_output (vm,
1727 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1728 cfg->pipe[profile_id].tc_rate[0],
1729 cfg->pipe[profile_id].tc_rate[1],
1730 cfg->pipe[profile_id].tc_rate[2],
1731 cfg->pipe[profile_id].tc_rate[3]);
1732 vlib_cli_output (vm, " TC period = %u milliseconds",
1733 cfg->pipe[profile_id].tc_period);
1734 #ifdef RTE_SCHED_SUBPORT_TC_OV
1735 vlib_cli_output (vm, " TC3 oversubscription_weight = %u",
1736 cfg->pipe[profile_id].tc_ov_weight);
1739 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1741 vlib_cli_output (vm,
1742 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1743 i, cfg->pipe[profile_id].wrr_weights[i * 4],
1744 cfg->pipe[profile_id].wrr_weights[i * 4 + 1],
1745 cfg->pipe[profile_id].wrr_weights[i * 4 + 2],
1746 cfg->pipe[profile_id].wrr_weights[i * 4 + 3]);
1750 #ifdef RTE_SCHED_RED
1751 vlib_cli_output (vm, " Weighted Random Early Detection (WRED):");
1752 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1754 vlib_cli_output (vm, " TC%u min: G = %u, Y = %u, R = %u", i,
1755 cfg->port.red_params[i][e_RTE_METER_GREEN].min_th,
1756 cfg->port.red_params[i][e_RTE_METER_YELLOW].min_th,
1757 cfg->port.red_params[i][e_RTE_METER_RED].min_th);
1759 vlib_cli_output (vm, " TC%u max: G = %u, Y = %u, R = %u", i,
1760 cfg->port.red_params[i][e_RTE_METER_GREEN].max_th,
1761 cfg->port.red_params[i][e_RTE_METER_YELLOW].max_th,
1762 cfg->port.red_params[i][e_RTE_METER_RED].max_th);
1764 vlib_cli_output (vm,
1765 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1766 i, cfg->port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1767 cfg->port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1768 cfg->port.red_params[i][e_RTE_METER_RED].maxp_inv);
1770 vlib_cli_output (vm, " TC%u weight: R = %u, Y = %u, R = %u", i,
1771 cfg->port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1772 cfg->port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1773 cfg->port.red_params[i][e_RTE_METER_RED].wq_log2);
1778 unformat_free (line_input);
1784 * This command is used to display details of an output interface's HQoS
1788 * Example of how to display HQoS settings for an interfaces:
1789 * @cliexstart{show dpdk interface hqos GigabitEthernet0/8/0}
1791 * Input SWQ size = 4096 packets
1792 * Enqueue burst size = 256 packets
1793 * Dequeue burst size = 220 packets
1794 * Packet field 0: slab position = 0, slab bitmask = 0x0000000000000000 (subport)
1795 * Packet field 1: slab position = 40, slab bitmask = 0x0000000fff000000 (pipe)
1796 * Packet field 2: slab position = 8, slab bitmask = 0x00000000000000fc (tc)
1797 * Packet field 2 tc translation table: ([Mapped Value Range]: tc/queue tc/queue ...)
1798 * [ 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
1799 * [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
1800 * [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
1801 * [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
1803 * Rate = 1250000000 bytes/second
1805 * Frame overhead = 24 bytes
1806 * Number of subports = 1
1807 * Number of pipes per subport = 4096
1808 * Packet queue size: TC0 = 64, TC1 = 64, TC2 = 64, TC3 = 64 packets
1809 * Number of pipe profiles = 2
1811 * Rate = 1250000000 bytes/second
1812 * Token bucket size = 1000000 bytes
1813 * Traffic class rate: TC0 = 1250000000, TC1 = 1250000000, TC2 = 1250000000, TC3 = 1250000000 bytes/second
1814 * TC period = 10 milliseconds
1816 * Rate = 305175 bytes/second
1817 * Token bucket size = 1000000 bytes
1818 * Traffic class rate: TC0 = 305175, TC1 = 305175, TC2 = 305175, TC3 = 305175 bytes/second
1819 * TC period = 40 milliseconds
1820 * TC0 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1821 * TC1 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1822 * TC2 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1823 * TC3 WRR weights: Q0 = 1, Q1 = 1, Q2 = 1, Q3 = 1
1827 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos, static) = {
1828 .path = "show dpdk interface hqos",
1829 .short_help = "show dpdk interface hqos <interface>",
1830 .function = show_dpdk_if_hqos,
1835 static clib_error_t *
1836 show_dpdk_hqos_queue_stats (vlib_main_t * vm, unformat_input_t * input,
1837 vlib_cli_command_t * cmd)
1839 unformat_input_t _line_input, *line_input = &_line_input;
1840 clib_error_t *error = NULL;
1841 #ifdef RTE_SCHED_COLLECT_STATS
1842 dpdk_main_t *dm = &dpdk_main;
1843 u32 hw_if_index = (u32) ~ 0;
1844 u32 subport = (u32) ~ 0;
1845 u32 pipe = (u32) ~ 0;
1847 u32 tc_q = (u32) ~ 0;
1848 vnet_hw_interface_t *hw;
1851 struct rte_eth_dev_info dev_info;
1852 dpdk_device_config_t *devconf = 0;
1854 struct rte_sched_queue_stats stats;
1857 if (!unformat_user (input, unformat_line_input, line_input))
1860 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1863 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1867 else if (unformat (line_input, "subport %d", &subport))
1870 else if (unformat (line_input, "pipe %d", &pipe))
1873 else if (unformat (line_input, "tc %d", &tc))
1876 else if (unformat (line_input, "tc_q %d", &tc_q))
1881 error = clib_error_return (0, "parse error: '%U'",
1882 format_unformat_error, line_input);
1887 if (hw_if_index == (u32) ~ 0)
1889 error = clib_error_return (0, "please specify interface name!!");
1893 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1894 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1896 rte_eth_dev_info_get (xd->port_id, &dev_info);
1897 if (dev_info.pci_dev)
1898 { /* bonded interface has no pci info */
1899 vlib_pci_addr_t pci_addr;
1901 pci_addr.domain = dev_info.pci_dev->addr.domain;
1902 pci_addr.bus = dev_info.pci_dev->addr.bus;
1903 pci_addr.slot = dev_info.pci_dev->addr.devid;
1904 pci_addr.function = dev_info.pci_dev->addr.function;
1907 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1911 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1913 devconf = &dm->conf->default_devconf;
1915 if (devconf->hqos_enabled == 0)
1917 vlib_cli_output (vm, "HQoS disabled for this interface");
1922 * Figure out which queue to query. cf rte_sched_port_qindex. (Not sure why
1923 * that method isn't made public by DPDK - how _should_ we get the queue ID?)
1925 qindex = subport * devconf->hqos.port.n_pipes_per_subport + pipe;
1926 qindex = qindex * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE + tc;
1927 qindex = qindex * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + tc_q;
1929 if (rte_sched_queue_read_stats (xd->hqos_ht->hqos, qindex, &stats, &qlen) !=
1932 error = clib_error_return (0, "failed to read stats");
1936 vlib_cli_output (vm, "%=24s%=16s", "Stats Parameter", "Value");
1937 vlib_cli_output (vm, "%=24s%=16d", "Packets", stats.n_pkts);
1938 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped", stats.n_pkts_dropped);
1939 #ifdef RTE_SCHED_RED
1940 vlib_cli_output (vm, "%=24s%=16d", "Packets dropped (RED)",
1941 stats.n_pkts_red_dropped);
1943 vlib_cli_output (vm, "%=24s%=16d", "Bytes", stats.n_bytes);
1944 vlib_cli_output (vm, "%=24s%=16d", "Bytes dropped", stats.n_bytes_dropped);
1948 /* Get a line of input */
1949 if (!unformat_user (input, unformat_line_input, line_input))
1952 vlib_cli_output (vm, "RTE_SCHED_COLLECT_STATS disabled in DPDK");
1958 unformat_free (line_input);
1964 * This command is used to display statistics associated with a HQoS traffic class
1968 * Statistic collection by the scheduler is disabled by default in DPDK. In order to
1969 * turn it on, add the following line to '<em>../vpp/dpdk/Makefile</em>':
1970 * - <b>$(call set,RTE_SCHED_COLLECT_STATS,y)</b>
1973 * Example of how to display statistics of HQoS a HQoS traffic class queue:
1974 * @cliexstart{show dpdk hqos queue GigabitEthernet0/9/0 subport 0 pipe 3181 tc 0 tc_q 0}
1975 * Stats Parameter Value
1983 VLIB_CLI_COMMAND (cmd_show_dpdk_hqos_queue_stats, static) = {
1984 .path = "show dpdk hqos queue",
1985 .short_help = "show dpdk hqos queue <interface> subport <subport_id> pipe <pipe_id> tc <tc_id> tc_q <queue_id>",
1986 .function = show_dpdk_hqos_queue_stats,
1990 static clib_error_t *
1991 show_dpdk_version_command_fn (vlib_main_t * vm,
1992 unformat_input_t * input,
1993 vlib_cli_command_t * cmd)
1995 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c);
1996 _("DPDK Version", "%s", rte_version ());
1997 _("DPDK EAL init args", "%s", dpdk_config_main.eal_init_args_str);
2003 * This command is used to display the current DPDK version and
2004 * the list of arguments passed to DPDK when started.
2007 * Example of how to display how many DPDK buffer test command has allocated:
2008 * @cliexstart{show dpdk version}
2009 * DPDK Version: DPDK 16.11.0
2010 * 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
2014 VLIB_CLI_COMMAND (show_vpe_version_command, static) = {
2015 .path = "show dpdk version",
2016 .short_help = "show dpdk version",
2017 .function = show_dpdk_version_command_fn,
2023 static clib_error_t *
2024 dpdk_validate_buffers_fn (vlib_main_t * vm, unformat_input_t * input,
2025 vlib_cli_command_t * cmd_arg)
2027 u32 n_invalid_bufs = 0, uninitialized = 0;
2028 u32 is_poison = 0, is_test = 0;
2029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
2031 if (unformat (input, "poison"))
2033 else if (unformat (input, "trajectory"))
2036 return clib_error_return (0, "unknown input `%U'",
2037 format_unformat_error, input);
2040 if (VLIB_BUFFER_TRACE_TRAJECTORY == 0)
2042 vlib_cli_output (vm, "Trajectory not enabled. Recompile with "
2043 "VLIB_BUFFER_TRACE_TRAJECTORY 1");
2048 dpdk_buffer_poison_trajectory_all ();
2052 n_invalid_bufs = dpdk_buffer_validate_trajectory_all (&uninitialized);
2053 if (!n_invalid_bufs)
2054 vlib_cli_output (vm, "All buffers are valid %d uninitialized",
2057 vlib_cli_output (vm, "Found %d invalid buffers and %d uninitialized",
2058 n_invalid_bufs, uninitialized);
2064 VLIB_CLI_COMMAND (test_dpdk_buffers_command, static) =
2066 .path = "test dpdk buffers",
2067 .short_help = "test dpdk buffers [poison] [trajectory]",
2068 .function = dpdk_validate_buffers_fn,
2075 dpdk_cli_init (vlib_main_t * vm)
2080 VLIB_INIT_FUNCTION (dpdk_cli_init);
2083 * fd.io coding-style-patch-verification: ON
2086 * eval: (c-set-style "gnu")