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.
15 #include <vnet/vnet.h>
16 #include <vppinfra/vec.h>
17 #include <vppinfra/error.h>
18 #include <vppinfra/format.h>
19 #include <vppinfra/xxhash.h>
21 #include <vnet/ethernet/ethernet.h>
22 #include <vnet/devices/dpdk/dpdk.h>
23 #include <vnet/classify/vnet_classify.h>
24 #include <vnet/mpls/packet.h>
26 #include "dpdk_priv.h"
29 pcap_trace_command_fn (vlib_main_t * vm,
30 unformat_input_t * input, vlib_cli_command_t * cmd)
32 dpdk_main_t *dm = &dpdk_main;
36 clib_error_t *error = 0;
38 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
40 if (unformat (input, "on"))
42 if (dm->tx_pcap_enable == 0)
44 if (dm->pcap_filename == 0)
45 dm->pcap_filename = format (0, "/tmp/vpe.pcap%c", 0);
47 memset (&dm->pcap_main, 0, sizeof (dm->pcap_main));
48 dm->pcap_main.file_name = (char *) dm->pcap_filename;
49 dm->pcap_main.n_packets_to_capture = 100;
50 if (dm->pcap_pkts_to_capture)
51 dm->pcap_main.n_packets_to_capture = dm->pcap_pkts_to_capture;
53 dm->pcap_main.packet_type = PCAP_PACKET_TYPE_ethernet;
54 dm->tx_pcap_enable = 1;
56 vlib_cli_output (vm, "pcap tx capture on...");
60 vlib_cli_output (vm, "pcap tx capture already on...");
64 else if (unformat (input, "off"))
66 if (dm->tx_pcap_enable)
68 vlib_cli_output (vm, "captured %d pkts...",
69 dm->pcap_main.n_packets_captured + 1);
70 if (dm->pcap_main.n_packets_captured)
72 dm->pcap_main.n_packets_to_capture =
73 dm->pcap_main.n_packets_captured;
74 error = pcap_write (&dm->pcap_main);
76 clib_error_report (error);
78 vlib_cli_output (vm, "saved to %s...", dm->pcap_filename);
83 vlib_cli_output (vm, "pcap tx capture already off...");
86 dm->tx_pcap_enable = 0;
89 else if (unformat (input, "max %d", &max))
91 dm->pcap_pkts_to_capture = max;
95 else if (unformat (input, "intfc %U",
96 unformat_vnet_sw_interface, dm->vnet_main,
97 &dm->pcap_sw_if_index))
99 else if (unformat (input, "intfc any"))
101 dm->pcap_sw_if_index = 0;
104 else if (unformat (input, "file %s", &filename))
107 /* Brain-police user path input */
108 if (strstr ((char *) filename, "..")
109 || index ((char *) filename, '/'))
111 vlib_cli_output (vm, "illegal characters in filename '%s'",
116 chroot_filename = format (0, "/tmp/%s%c", filename, 0);
119 if (dm->pcap_filename)
120 vec_free (dm->pcap_filename);
121 vec_add1 (filename, 0);
122 dm->pcap_filename = chroot_filename;
125 else if (unformat (input, "status"))
127 if (dm->tx_pcap_enable == 0)
129 vlib_cli_output (vm, "pcap tx capture is off...");
133 vlib_cli_output (vm, "pcap tx capture: %d of %d pkts...",
134 dm->pcap_main.n_packets_captured,
135 dm->pcap_main.n_packets_to_capture);
144 return clib_error_return (0, "unknown input `%U'",
145 format_unformat_error, input);
151 VLIB_CLI_COMMAND (pcap_trace_command, static) = {
152 .path = "pcap tx trace",
154 "pcap tx trace on off max <nn> intfc <intfc> file <name> status",
155 .function = pcap_trace_command_fn,
160 static clib_error_t *
161 show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
162 vlib_cli_command_t * cmd)
164 struct rte_mempool *rmp;
167 for (i = 0; i < vec_len (vm->buffer_main->pktmbuf_pools); i++)
169 rmp = vm->buffer_main->pktmbuf_pools[i];
172 unsigned count = rte_mempool_avail_count (rmp);
173 unsigned free_count = rte_mempool_in_use_count (rmp);
176 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
177 rmp->name, (u32) count, (u32) free_count,
178 (u32) (count + free_count));
182 vlib_cli_output (vm, "rte_mempool is NULL (!)\n");
189 VLIB_CLI_COMMAND (cmd_show_dpdk_bufferr,static) = {
190 .path = "show dpdk buffer",
191 .short_help = "show dpdk buffer state",
192 .function = show_dpdk_buffer,
197 static clib_error_t *
198 test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
199 vlib_cli_command_t * cmd)
201 static u32 *allocated_buffers;
204 u32 first, actual_alloc;
206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
208 if (unformat (input, "allocate %d", &n_alloc))
210 else if (unformat (input, "free %d", &n_free))
218 if (vec_len (allocated_buffers) < n_free)
219 return clib_error_return (0, "Can't free %d, only %d allocated",
220 n_free, vec_len (allocated_buffers));
222 first = vec_len (allocated_buffers) - n_free;
223 vlib_buffer_free (vm, allocated_buffers + first, n_free);
224 _vec_len (allocated_buffers) = first;
228 first = vec_len (allocated_buffers);
229 vec_validate (allocated_buffers,
230 vec_len (allocated_buffers) + n_alloc - 1);
232 actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
234 _vec_len (allocated_buffers) = first + actual_alloc;
236 if (actual_alloc < n_alloc)
237 vlib_cli_output (vm, "WARNING: only allocated %d buffers",
241 vlib_cli_output (vm, "Currently %d buffers allocated",
242 vec_len (allocated_buffers));
244 if (allocated_buffers && vec_len (allocated_buffers) == 0)
245 vec_free (allocated_buffers);
251 VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = {
252 .path = "test dpdk buffer",
253 .short_help = "test dpdk buffer [allocate <nn>][free <nn>]",
254 .function = test_dpdk_buffer,
260 show_dpdk_device_stats (vlib_main_t * vm, dpdk_device_t * xd)
264 " last_burst_sz %d\n"
266 " full_frames_cnt %u\n"
267 " consec_full_frames_cnt %u\n"
268 " congestion_cnt %d\n"
269 " last_poll_time %llu\n"
270 " max_poll_delay %llu\n"
272 " total_packet_cnt %u\n",
274 xd->efd_agent.last_burst_sz,
275 xd->efd_agent.max_burst_sz,
276 xd->efd_agent.full_frames_cnt,
277 xd->efd_agent.consec_full_frames_cnt,
278 xd->efd_agent.congestion_cnt,
279 xd->efd_agent.last_poll_time,
280 xd->efd_agent.max_poll_delay,
281 xd->efd_agent.discard_cnt, xd->efd_agent.total_packet_cnt);
283 u32 device_queue_sz = rte_eth_rx_queue_count (xd->device_index,
285 vlib_cli_output (vm, " device_queue_sz %u\n", device_queue_sz);
289 show_efd_config (vlib_main_t * vm)
291 vlib_thread_main_t *tm = vlib_get_thread_main ();
292 dpdk_main_t *dm = &dpdk_main;
295 "dpdk: (0x%04x) enabled:%d monitor:%d drop_all:%d\n"
296 " dpdk_queue_hi_thresh %d\n"
297 " consec_full_frames_hi_thresh %d\n"
299 "worker: (0x%04x) enabled:%d monitor:%d\n"
300 " worker_queue_hi_thresh %d\n",
302 ((dm->efd.enabled & DPDK_EFD_DISCARD_ENABLED) ? 1 : 0),
303 ((dm->efd.enabled & DPDK_EFD_MONITOR_ENABLED) ? 1 : 0),
304 ((dm->efd.enabled & DPDK_EFD_DROPALL_ENABLED) ? 1 : 0),
305 dm->efd.queue_hi_thresh,
306 dm->efd.consec_full_frames_hi_thresh,
308 ((tm->efd.enabled & VLIB_EFD_DISCARD_ENABLED) ? 1 : 0),
309 ((dm->efd.enabled & VLIB_EFD_MONITOR_ENABLED) ? 1 : 0),
310 tm->efd.queue_hi_thresh);
313 "ip_prec_bitmap 0x%02x\n"
314 "mpls_exp_bitmap 0x%02x\n"
315 "vlan_cos_bitmap 0x%02x\n",
316 tm->efd.ip_prec_bitmap,
317 tm->efd.mpls_exp_bitmap, tm->efd.vlan_cos_bitmap);
320 static clib_error_t *
321 show_efd (vlib_main_t * vm,
322 unformat_input_t * input, vlib_cli_command_t * cmd)
325 if (unformat (input, "config"))
327 show_efd_config (vm);
329 else if (unformat (input, "dpdk"))
331 dpdk_main_t *dm = &dpdk_main;
335 (void) unformat (input, "device %d", &device_id);
337 vec_foreach (xd, dm->devices)
339 if ((xd->device_index == device_id) || (device_id == ~0))
341 show_dpdk_device_stats(vm, xd);
346 else if (unformat (input, "worker"))
348 vlib_thread_main_t *tm = vlib_get_thread_main ();
349 vlib_frame_queue_t *fq;
350 vlib_thread_registration_t *tr;
353 u32 first_worker_index = 0;
356 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
358 tr = (vlib_thread_registration_t *) p[0];
361 num_workers = tr->count;
362 first_worker_index = tr->first_index;
367 "first_worker_index %d\n"
368 "vlib_frame_queues[%d]:\n",
369 num_workers, first_worker_index, tm->n_vlib_mains);
371 for (thread_id = 0; thread_id < tm->n_vlib_mains; thread_id++)
373 fq = vlib_frame_queues[thread_id];
377 "%2d: frames_queued %u\n"
378 " frames_queued_hint %u\n"
379 " enqueue_full_events %u\n"
380 " enqueue_efd_discards %u\n",
382 (fq->tail - fq->head),
383 (fq->tail - fq->head_hint),
384 fq->enqueue_full_events,
385 fq->enqueue_efd_discards);
389 else if (unformat (input, "help"))
391 vlib_cli_output (vm, "Usage: show efd config | "
392 "dpdk [device <id>] | worker\n");
396 show_efd_config (vm);
403 VLIB_CLI_COMMAND (show_efd_command, static) = {
405 .short_help = "Show efd [device <id>] | [config]",
406 .function = show_efd,
410 static clib_error_t *
411 clear_efd (vlib_main_t * vm,
412 unformat_input_t * input, vlib_cli_command_t * cmd)
414 dpdk_main_t *dm = &dpdk_main;
416 vlib_thread_main_t *tm = vlib_get_thread_main ();
417 vlib_frame_queue_t *fq;
421 vec_foreach (xd, dm->devices)
423 xd->efd_agent.last_burst_sz = 0;
424 xd->efd_agent.max_burst_sz = 0;
425 xd->efd_agent.full_frames_cnt = 0;
426 xd->efd_agent.consec_full_frames_cnt = 0;
427 xd->efd_agent.congestion_cnt = 0;
428 xd->efd_agent.last_poll_time = 0;
429 xd->efd_agent.max_poll_delay = 0;
430 xd->efd_agent.discard_cnt = 0;
431 xd->efd_agent.total_packet_cnt = 0;
435 for (thread_id = 0; thread_id < tm->n_vlib_mains; thread_id++)
437 fq = vlib_frame_queues[thread_id];
440 fq->enqueue_full_events = 0;
441 fq->enqueue_efd_discards = 0;
449 VLIB_CLI_COMMAND (clear_efd_command,static) = {
451 .short_help = "Clear early-fast-discard counters",
452 .function = clear_efd,
456 static clib_error_t *
457 parse_op_and_prec (vlib_main_t * vm, unformat_input_t * input,
458 vlib_cli_command_t * cmd,
459 char *prec_type, u8 * prec_bitmap)
461 clib_error_t *error = NULL;
465 if (unformat (input, "ge"))
467 op = EFD_OPERATION_GREATER_OR_EQUAL;
469 else if (unformat (input, "lt"))
471 op = EFD_OPERATION_LESS_THAN;
473 else if (unformat (input, "help"))
475 vlib_cli_output (vm, "enter operation [ge | lt] and precedence <0-7>)");
480 return clib_error_return (0, "unknown input `%U'",
481 format_unformat_error, input);
484 if (unformat (input, "%u", &prec))
488 return clib_error_return (0, "precedence %d is out of range <0-7>",
494 return clib_error_return (0, "unknown input `%U'",
495 format_unformat_error, input);
498 set_efd_bitmap (prec_bitmap, prec, op);
501 "EFD will be set for %s precedence %s%u%s.",
503 (op == EFD_OPERATION_LESS_THAN) ? "less than " : "",
506 EFD_OPERATION_GREATER_OR_EQUAL) ? " and greater" : "");
512 static clib_error_t *
513 set_efd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
515 dpdk_main_t *dm = &dpdk_main;
516 vlib_thread_main_t *tm = vlib_get_thread_main ();
517 clib_error_t *error = NULL;
518 vlib_node_runtime_t *rt = vlib_node_get_runtime (vm, dpdk_input_node.index);
520 if (unformat (input, "enable"))
522 if (unformat (input, "dpdk"))
524 dm->efd.enabled |= DPDK_EFD_DISCARD_ENABLED;
526 else if (unformat (input, "worker"))
528 tm->efd.enabled |= VLIB_EFD_DISCARD_ENABLED;
530 else if (unformat (input, "monitor"))
532 dm->efd.enabled |= DPDK_EFD_MONITOR_ENABLED;
533 tm->efd.enabled |= VLIB_EFD_MONITOR_ENABLED;
535 else if (unformat (input, "drop_all"))
537 dm->efd.enabled |= DPDK_EFD_DROPALL_ENABLED;
539 else if (unformat (input, "default"))
541 dm->efd.enabled = (DPDK_EFD_DISCARD_ENABLED |
542 DPDK_EFD_MONITOR_ENABLED);
543 tm->efd.enabled = (VLIB_EFD_DISCARD_ENABLED |
544 VLIB_EFD_MONITOR_ENABLED);
548 return clib_error_return (0, "Usage: set efd enable [dpdk | "
549 "worker | monitor | drop_all | default]");
552 else if (unformat (input, "disable"))
554 if (unformat (input, "dpdk"))
556 dm->efd.enabled &= ~DPDK_EFD_DISCARD_ENABLED;
558 else if (unformat (input, "worker"))
560 tm->efd.enabled &= ~VLIB_EFD_DISCARD_ENABLED;
562 else if (unformat (input, "monitor"))
564 dm->efd.enabled &= ~DPDK_EFD_MONITOR_ENABLED;
565 tm->efd.enabled &= ~VLIB_EFD_MONITOR_ENABLED;
567 else if (unformat (input, "drop_all"))
569 dm->efd.enabled &= ~DPDK_EFD_DROPALL_ENABLED;
571 else if (unformat (input, "all"))
578 return clib_error_return (0, "Usage: set efd disable [dpdk | "
579 "worker | monitor | drop_all | all]");
582 else if (unformat (input, "worker_queue_hi_thresh"))
585 if (unformat (input, "%u", &mark))
587 tm->efd.queue_hi_thresh = mark;
591 return clib_error_return (0, "unknown input `%U'",
592 format_unformat_error, input);
595 else if (unformat (input, "dpdk_device_hi_thresh"))
598 if (unformat (input, "%u", &thresh))
600 dm->efd.queue_hi_thresh = thresh;
604 return clib_error_return (0, "unknown input `%U'",
605 format_unformat_error, input);
608 else if (unformat (input, "consec_full_frames_hi_thresh"))
611 if (unformat (input, "%u", &thresh))
613 dm->efd.consec_full_frames_hi_thresh = thresh;
617 return clib_error_return (0, "unknown input `%U'",
618 format_unformat_error, input);
621 else if (unformat (input, "ip-prec"))
623 return (parse_op_and_prec (vm, input, cmd,
624 "ip", &tm->efd.ip_prec_bitmap));
626 else if (unformat (input, "mpls-exp"))
628 return (parse_op_and_prec (vm, input, cmd,
629 "mpls", &tm->efd.mpls_exp_bitmap));
631 else if (unformat (input, "vlan-cos"))
633 return (parse_op_and_prec (vm, input, cmd,
634 "vlan", &tm->efd.vlan_cos_bitmap));
636 else if (unformat (input, "help"))
640 " set efd enable <dpdk | worker | monitor | drop_all | default> |\n"
641 " set efd disable <dpdk | worker | monitor | drop_all | all> |\n"
642 " set efd <ip-prec | mpls-exp | vlan-cos> <ge | lt> <0-7>\n"
643 " set efd worker_queue_hi_thresh <0-32> |\n"
644 " set efd dpdk_device_hi_thresh <0-%d> |\n"
645 " set efd consec_full_frames_hi_thresh <count> |\n",
646 DPDK_NB_RX_DESC_10GE);
650 return clib_error_return (0, "unknown input `%U'",
651 format_unformat_error, input);
655 rt->function = dpdk_input_efd_multiarch_select ();
656 else if (dm->use_rss)
657 rt->function = dpdk_input_rss_multiarch_select ();
659 rt->function = dpdk_input_multiarch_select ();
665 VLIB_CLI_COMMAND (cmd_set_efd,static) = {
667 .short_help = "set early-fast-discard commands",
672 static clib_error_t *
673 set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
674 vlib_cli_command_t * cmd)
676 unformat_input_t _line_input, *line_input = &_line_input;
677 dpdk_main_t *dm = &dpdk_main;
678 vnet_hw_interface_t *hw;
680 u32 hw_if_index = (u32) ~ 0;
681 u32 nb_rx_desc = (u32) ~ 0;
682 u32 nb_tx_desc = (u32) ~ 0;
685 if (!unformat_user (input, unformat_line_input, line_input))
688 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
691 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
694 else if (unformat (line_input, "tx %d", &nb_tx_desc))
696 else if (unformat (line_input, "rx %d", &nb_rx_desc))
699 return clib_error_return (0, "parse error: '%U'",
700 format_unformat_error, line_input);
703 unformat_free (line_input);
705 if (hw_if_index == (u32) ~ 0)
706 return clib_error_return (0, "please specify valid interface name");
708 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
709 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
711 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
712 return clib_error_return (0, "number of descriptors can be set only for "
715 if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
716 (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
717 return clib_error_return (0, "nothing changed");
719 if (nb_rx_desc != (u32) ~ 0)
720 xd->nb_rx_desc = nb_rx_desc;
722 if (nb_tx_desc != (u32) ~ 0)
723 xd->nb_rx_desc = nb_rx_desc;
725 rv = dpdk_port_setup (dm, xd);
731 VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = {
732 .path = "set dpdk interface descriptors",
733 .short_help = "set dpdk interface descriptors <if-name> [rx <n>] [tx <n>]",
734 .function = set_dpdk_if_desc,
738 static clib_error_t *
739 show_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
740 vlib_cli_command_t * cmd)
742 vlib_thread_main_t *tm = vlib_get_thread_main ();
743 dpdk_main_t *dm = &dpdk_main;
744 dpdk_device_and_queue_t *dq;
747 if (tm->n_vlib_mains == 1)
748 vlib_cli_output (vm, "All interfaces are handled by main thread");
750 for (cpu = 0; cpu < vec_len (dm->devices_by_cpu); cpu++)
752 if (vec_len (dm->devices_by_cpu[cpu]))
753 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
754 vlib_worker_threads[cpu].name,
755 vlib_worker_threads[cpu].lcore_id);
758 vec_foreach(dq, dm->devices_by_cpu[cpu])
760 u32 hw_if_index = dm->devices[dq->device].vlib_hw_if_index;
761 vnet_hw_interface_t * hi = vnet_get_hw_interface(dm->vnet_main, hw_if_index);
762 vlib_cli_output(vm, " %v queue %u", hi->name, dq->queue_id);
770 VLIB_CLI_COMMAND (cmd_show_dpdk_if_placement,static) = {
771 .path = "show dpdk interface placement",
772 .short_help = "show dpdk interface placement",
773 .function = show_dpdk_if_placement,
778 dpdk_device_queue_sort (void *a1, void *a2)
780 dpdk_device_and_queue_t *dq1 = a1;
781 dpdk_device_and_queue_t *dq2 = a2;
783 if (dq1->device > dq2->device)
785 else if (dq1->device < dq2->device)
787 else if (dq1->queue_id > dq2->queue_id)
789 else if (dq1->queue_id < dq2->queue_id)
795 static clib_error_t *
796 set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
797 vlib_cli_command_t * cmd)
799 unformat_input_t _line_input, *line_input = &_line_input;
800 dpdk_main_t *dm = &dpdk_main;
801 dpdk_device_and_queue_t *dq;
802 vnet_hw_interface_t *hw;
804 u32 hw_if_index = (u32) ~ 0;
809 if (!unformat_user (input, unformat_line_input, line_input))
812 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
815 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
818 else if (unformat (line_input, "queue %d", &queue))
820 else if (unformat (line_input, "thread %d", &cpu))
823 return clib_error_return (0, "parse error: '%U'",
824 format_unformat_error, line_input);
827 unformat_free (line_input);
829 if (hw_if_index == (u32) ~ 0)
830 return clib_error_return (0, "please specify valid interface name");
832 if (cpu < dm->input_cpu_first_index ||
833 cpu >= (dm->input_cpu_first_index + dm->input_cpu_count))
834 return clib_error_return (0, "please specify valid thread id");
836 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
837 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
839 for (i = 0; i < vec_len (dm->devices_by_cpu); i++)
842 vec_foreach(dq, dm->devices_by_cpu[i])
844 if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index &&
845 queue == dq->queue_id)
847 if (cpu == i) /* nothing to do */
850 vec_del1(dm->devices_by_cpu[i], dq - dm->devices_by_cpu[i]);
851 vec_add2(dm->devices_by_cpu[cpu], dq, 1);
852 dq->queue_id = queue;
853 dq->device = xd->device_index;
854 xd->cpu_socket_id_by_queue[queue] =
855 rte_lcore_to_socket_id(vlib_worker_threads[cpu].lcore_id);
857 vec_sort_with_function(dm->devices_by_cpu[i],
858 dpdk_device_queue_sort);
860 vec_sort_with_function(dm->devices_by_cpu[cpu],
861 dpdk_device_queue_sort);
863 if (vec_len(dm->devices_by_cpu[i]) == 0)
864 vlib_node_set_state (vlib_mains[i], dpdk_input_node.index,
865 VLIB_NODE_STATE_DISABLED);
867 if (vec_len(dm->devices_by_cpu[cpu]) == 1)
868 vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
869 VLIB_NODE_STATE_POLLING);
877 return clib_error_return (0, "not found");
881 VLIB_CLI_COMMAND (cmd_set_dpdk_if_placement,static) = {
882 .path = "set dpdk interface placement",
883 .short_help = "set dpdk interface placement <if-name> [queue <n>] thread <n>",
884 .function = set_dpdk_if_placement,
888 static clib_error_t *
889 show_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
890 vlib_cli_command_t * cmd)
892 vlib_thread_main_t *tm = vlib_get_thread_main ();
893 dpdk_main_t *dm = &dpdk_main;
894 dpdk_device_and_queue_t *dq;
897 if (tm->n_vlib_mains == 1)
898 vlib_cli_output (vm, "All interfaces are handled by main thread");
900 for (cpu = 0; cpu < vec_len (dm->devices_by_hqos_cpu); cpu++)
902 if (vec_len (dm->devices_by_hqos_cpu[cpu]))
903 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
904 vlib_worker_threads[cpu].name,
905 vlib_worker_threads[cpu].lcore_id);
907 vec_foreach (dq, dm->devices_by_hqos_cpu[cpu])
909 u32 hw_if_index = dm->devices[dq->device].vlib_hw_if_index;
910 vnet_hw_interface_t *hi =
911 vnet_get_hw_interface (dm->vnet_main, hw_if_index);
912 vlib_cli_output (vm, " %v queue %u", hi->name, dq->queue_id);
919 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos_placement, static) = {
920 .path = "show dpdk interface hqos placement",
921 .short_help = "show dpdk interface hqos placement",
922 .function = show_dpdk_if_hqos_placement,
926 static clib_error_t *
927 set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
928 vlib_cli_command_t * cmd)
930 unformat_input_t _line_input, *line_input = &_line_input;
931 dpdk_main_t *dm = &dpdk_main;
932 dpdk_device_and_queue_t *dq;
933 vnet_hw_interface_t *hw;
935 u32 hw_if_index = (u32) ~ 0;
939 if (!unformat_user (input, unformat_line_input, line_input))
942 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
945 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
948 else if (unformat (line_input, "thread %d", &cpu))
951 return clib_error_return (0, "parse error: '%U'",
952 format_unformat_error, line_input);
955 unformat_free (line_input);
957 if (hw_if_index == (u32) ~ 0)
958 return clib_error_return (0, "please specify valid interface name");
960 if (cpu < dm->hqos_cpu_first_index ||
961 cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
962 return clib_error_return (0, "please specify valid thread id");
964 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
965 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
967 for (i = 0; i < vec_len (dm->devices_by_hqos_cpu); i++)
969 vec_foreach (dq, dm->devices_by_hqos_cpu[i])
971 if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index)
973 if (cpu == i) /* nothing to do */
976 vec_del1 (dm->devices_by_hqos_cpu[i],
977 dq - dm->devices_by_hqos_cpu[i]);
978 vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
980 dq->device = xd->device_index;
982 vec_sort_with_function (dm->devices_by_hqos_cpu[i],
983 dpdk_device_queue_sort);
985 vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
986 dpdk_device_queue_sort);
993 return clib_error_return (0, "not found");
997 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_placement, static) = {
998 .path = "set dpdk interface hqos placement",
999 .short_help = "set dpdk interface hqos placement <if-name> thread <n>",
1000 .function = set_dpdk_if_hqos_placement,
1004 static clib_error_t *
1005 set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
1006 vlib_cli_command_t * cmd)
1008 unformat_input_t _line_input, *line_input = &_line_input;
1009 dpdk_main_t *dm = &dpdk_main;
1010 vnet_hw_interface_t *hw;
1012 u32 hw_if_index = (u32) ~ 0;
1013 u32 subport_id = (u32) ~ 0;
1014 u32 pipe_id = (u32) ~ 0;
1015 u32 profile_id = (u32) ~ 0;
1018 if (!unformat_user (input, unformat_line_input, line_input))
1021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1024 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1027 else if (unformat (line_input, "subport %d", &subport_id))
1029 else if (unformat (line_input, "pipe %d", &pipe_id))
1031 else if (unformat (line_input, "profile %d", &profile_id))
1034 return clib_error_return (0, "parse error: '%U'",
1035 format_unformat_error, line_input);
1038 unformat_free (line_input);
1040 if (hw_if_index == (u32) ~ 0)
1041 return clib_error_return (0, "please specify valid interface name");
1043 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1044 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1047 rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
1050 return clib_error_return (0, "pipe configuration failed");
1056 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pipe, static) =
1058 .path = "set dpdk interface hqos pipe",
1059 .short_help = "set dpdk interface hqos pipe <if-name> subport <n> pipe <n> "
1061 .function = set_dpdk_if_hqos_pipe,
1065 static clib_error_t *
1066 set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
1067 vlib_cli_command_t * cmd)
1069 unformat_input_t _line_input, *line_input = &_line_input;
1070 dpdk_main_t *dm = &dpdk_main;
1071 vnet_hw_interface_t *hw;
1073 u32 hw_if_index = (u32) ~ 0;
1074 u32 subport_id = (u32) ~ 0;
1075 struct rte_sched_subport_params p = {
1076 .tb_rate = 1250000000, /* 10GbE */
1078 .tc_rate = {1250000000, 1250000000, 1250000000, 1250000000},
1083 if (!unformat_user (input, unformat_line_input, line_input))
1086 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1089 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1092 else if (unformat (line_input, "subport %d", &subport_id))
1094 else if (unformat (line_input, "rate %d", &p.tb_rate))
1096 p.tc_rate[0] = p.tb_rate;
1097 p.tc_rate[1] = p.tb_rate;
1098 p.tc_rate[2] = p.tb_rate;
1099 p.tc_rate[3] = p.tb_rate;
1101 else if (unformat (line_input, "bktsize %d", &p.tb_size))
1103 else if (unformat (line_input, "tc0 %d", &p.tc_rate[0]))
1105 else if (unformat (line_input, "tc1 %d", &p.tc_rate[1]))
1107 else if (unformat (line_input, "tc2 %d", &p.tc_rate[2]))
1109 else if (unformat (line_input, "tc3 %d", &p.tc_rate[3]))
1111 else if (unformat (line_input, "period %d", &p.tc_period))
1114 return clib_error_return (0, "parse error: '%U'",
1115 format_unformat_error, line_input);
1118 unformat_free (line_input);
1120 if (hw_if_index == (u32) ~ 0)
1121 return clib_error_return (0, "please specify valid interface name");
1123 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1124 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1126 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
1128 return clib_error_return (0, "subport configuration failed");
1134 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_subport, static) = {
1135 .path = "set dpdk interface hqos subport",
1136 .short_help = "set dpdk interface hqos subport <if-name> subport <n> "
1137 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] "
1139 .function = set_dpdk_if_hqos_subport,
1143 static clib_error_t *
1144 set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
1145 vlib_cli_command_t * cmd)
1147 unformat_input_t _line_input, *line_input = &_line_input;
1148 vlib_thread_main_t *tm = vlib_get_thread_main ();
1149 dpdk_main_t *dm = &dpdk_main;
1150 vnet_hw_interface_t *hw;
1152 u32 hw_if_index = (u32) ~ 0;
1153 u32 entry, tc, queue, val, i;
1155 if (!unformat_user (input, unformat_line_input, line_input))
1158 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1161 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1164 else if (unformat (line_input, "entry %d", &entry))
1166 else if (unformat (line_input, "tc %d", &tc))
1168 else if (unformat (line_input, "queue %d", &queue))
1171 return clib_error_return (0, "parse error: '%U'",
1172 format_unformat_error, line_input);
1175 unformat_free (line_input);
1177 if (hw_if_index == (u32) ~ 0)
1178 return clib_error_return (0, "please specify valid interface name");
1180 return clib_error_return (0, "invalid entry");
1181 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1182 return clib_error_return (0, "invalid traffic class");
1183 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1184 return clib_error_return (0, "invalid traffic class");
1186 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1187 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1189 /* Detect the set of worker threads */
1190 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1191 /* Should never happen, shut up Coverity warning */
1193 return clib_error_return (0, "no worker registrations?");
1195 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1196 int worker_thread_first = tr->first_index;
1197 int worker_thread_count = tr->count;
1199 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1200 for (i = 0; i < worker_thread_count; i++)
1201 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
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 <if-name> entry <n> tc <n> queue <n>",
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;
1222 /* Device specific data */
1223 struct rte_eth_dev_info dev_info;
1224 dpdk_device_config_t *devconf = 0;
1225 vnet_hw_interface_t *hw;
1227 u32 hw_if_index = (u32) ~ 0;
1229 /* Detect the set of worker threads */
1230 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1231 /* Should never happen, shut up Coverity warning */
1233 return clib_error_return (0, "no worker registrations?");
1235 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1236 int worker_thread_first = tr->first_index;
1237 int worker_thread_count = tr->count;
1239 /* Packet field configuration */
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 %d", &id))
1260 else if (unformat (line_input, "offset %d", &offset))
1262 else if (unformat (line_input, "mask %llx", &mask))
1265 return clib_error_return (0, "parse error: '%U'",
1266 format_unformat_error, line_input);
1269 unformat_free (line_input);
1272 if (hw_if_index == (u32) ~ 0)
1273 return clib_error_return (0, "please specify valid interface name");
1275 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1276 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1278 rte_eth_dev_info_get (xd->device_index, &dev_info);
1279 if (dev_info.pci_dev)
1280 { /* bonded interface has no pci info */
1281 vlib_pci_addr_t pci_addr;
1283 pci_addr.domain = dev_info.pci_dev->addr.domain;
1284 pci_addr.bus = dev_info.pci_dev->addr.bus;
1285 pci_addr.slot = dev_info.pci_dev->addr.devid;
1286 pci_addr.function = dev_info.pci_dev->addr.function;
1289 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1293 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1295 devconf = &dm->conf->default_devconf;
1297 if (devconf->hqos_enabled == 0)
1299 vlib_cli_output (vm, "HQoS disabled for this interface");
1303 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
1304 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
1305 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
1307 /* Validate packet field configuration: id, offset and mask */
1309 return clib_error_return (0, "invalid packet field id");
1314 if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
1315 return clib_error_return (0, "invalid subport ID mask "
1316 "(n_subports_per_port = %u)",
1317 n_subports_per_port);
1320 if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
1321 return clib_error_return (0, "invalid pipe ID mask "
1322 "(n_pipes_per_subport = %u)",
1323 n_pipes_per_subport);
1327 if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
1328 return clib_error_return (0, "invalid TC table index mask "
1329 "(TC table size = %u)", tctbl_size);
1332 /* Propagate packet field configuration to all workers */
1333 for (i = 0; i < worker_thread_count; i++)
1337 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabpos = offset;
1338 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabmask = mask;
1339 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabshr =
1340 __builtin_ctzll (mask);
1343 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabpos = offset;
1344 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabmask = mask;
1345 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabshr =
1346 __builtin_ctzll (mask);
1350 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabpos = offset;
1351 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabmask = mask;
1352 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabshr =
1353 __builtin_ctzll (mask);
1360 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pktfield, static) = {
1361 .path = "set dpdk interface hqos pktfield",
1362 .short_help = "set dpdk interface hqos pktfield <if-name> id <n> offset <n> "
1364 .function = set_dpdk_if_hqos_pktfield,
1368 static clib_error_t *
1369 show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
1370 vlib_cli_command_t * cmd)
1372 unformat_input_t _line_input, *line_input = &_line_input;
1373 vlib_thread_main_t *tm = vlib_get_thread_main ();
1374 dpdk_main_t *dm = &dpdk_main;
1375 vnet_hw_interface_t *hw;
1377 dpdk_device_config_hqos_t *cfg;
1378 dpdk_device_hqos_per_hqos_thread_t *ht;
1379 dpdk_device_hqos_per_worker_thread_t *wk;
1381 u32 hw_if_index = (u32) ~ 0;
1383 struct rte_eth_dev_info dev_info;
1384 dpdk_device_config_t *devconf = 0;
1385 vlib_thread_registration_t *tr;
1388 if (!unformat_user (input, unformat_line_input, line_input))
1391 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1394 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1398 return clib_error_return (0, "parse error: '%U'",
1399 format_unformat_error, line_input);
1402 unformat_free (line_input);
1404 if (hw_if_index == (u32) ~ 0)
1405 return clib_error_return (0, "please specify interface name!!");
1407 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1408 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1410 rte_eth_dev_info_get (xd->device_index, &dev_info);
1411 if (dev_info.pci_dev)
1412 { /* bonded interface has no pci info */
1413 vlib_pci_addr_t pci_addr;
1415 pci_addr.domain = dev_info.pci_dev->addr.domain;
1416 pci_addr.bus = dev_info.pci_dev->addr.bus;
1417 pci_addr.slot = dev_info.pci_dev->addr.devid;
1418 pci_addr.function = dev_info.pci_dev->addr.function;
1421 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1425 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1427 devconf = &dm->conf->default_devconf;
1429 if (devconf->hqos_enabled == 0)
1431 vlib_cli_output (vm, "HQoS disabled for this interface");
1435 /* Detect the set of worker threads */
1436 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1438 /* Should never happen, shut up Coverity warning */
1440 return clib_error_return (0, "no worker registrations?");
1442 tr = (vlib_thread_registration_t *) p[0];
1444 cfg = &devconf->hqos;
1446 wk = &xd->hqos_wt[tr->first_index];
1447 tctbl = wk->hqos_tc_table;
1449 vlib_cli_output (vm, " Thread:");
1450 vlib_cli_output (vm, " Input SWQ size = %u packets", cfg->swq_size);
1451 vlib_cli_output (vm, " Enqueue burst size = %u packets",
1452 ht->hqos_burst_enq);
1453 vlib_cli_output (vm, " Dequeue burst size = %u packets",
1454 ht->hqos_burst_deq);
1456 vlib_cli_output (vm,
1457 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx",
1458 wk->hqos_field0_slabpos, wk->hqos_field0_slabmask);
1459 vlib_cli_output (vm,
1460 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx",
1461 wk->hqos_field1_slabpos, wk->hqos_field1_slabmask);
1462 vlib_cli_output (vm,
1463 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx",
1464 wk->hqos_field2_slabpos, wk->hqos_field2_slabmask);
1465 vlib_cli_output (vm, " Packet field 2 translation table:");
1466 vlib_cli_output (vm, " [ 0 .. 15]: "
1467 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1468 tctbl[0], tctbl[1], tctbl[2], tctbl[3],
1469 tctbl[4], tctbl[5], tctbl[6], tctbl[7],
1470 tctbl[8], tctbl[9], tctbl[10], tctbl[11],
1471 tctbl[12], tctbl[13], tctbl[14], tctbl[15]);
1472 vlib_cli_output (vm, " [16 .. 31]: "
1473 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1474 tctbl[16], tctbl[17], tctbl[18], tctbl[19],
1475 tctbl[20], tctbl[21], tctbl[22], tctbl[23],
1476 tctbl[24], tctbl[25], tctbl[26], tctbl[27],
1477 tctbl[28], tctbl[29], tctbl[30], tctbl[31]);
1478 vlib_cli_output (vm, " [32 .. 47]: "
1479 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1480 tctbl[32], tctbl[33], tctbl[34], tctbl[35],
1481 tctbl[36], tctbl[37], tctbl[38], tctbl[39],
1482 tctbl[40], tctbl[41], tctbl[42], tctbl[43],
1483 tctbl[44], tctbl[45], tctbl[46], tctbl[47]);
1484 vlib_cli_output (vm, " [48 .. 63]: "
1485 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1486 tctbl[48], tctbl[49], tctbl[50], tctbl[51],
1487 tctbl[52], tctbl[53], tctbl[54], tctbl[55],
1488 tctbl[56], tctbl[57], tctbl[58], tctbl[59],
1489 tctbl[60], tctbl[61], tctbl[62], tctbl[63]);
1491 vlib_cli_output (vm, " Port:");
1492 vlib_cli_output (vm, " Rate = %u bytes/second", cfg->port.rate);
1493 vlib_cli_output (vm, " MTU = %u bytes", cfg->port.mtu);
1494 vlib_cli_output (vm, " Frame overhead = %u bytes",
1495 cfg->port.frame_overhead);
1496 vlib_cli_output (vm, " Number of subports = %u",
1497 cfg->port.n_subports_per_port);
1498 vlib_cli_output (vm, " Number of pipes per subport = %u",
1499 cfg->port.n_pipes_per_subport);
1500 vlib_cli_output (vm,
1501 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1502 cfg->port.qsize[0], cfg->port.qsize[1], cfg->port.qsize[2],
1503 cfg->port.qsize[3]);
1504 vlib_cli_output (vm, " Number of pipe profiles = %u",
1505 cfg->port.n_pipe_profiles);
1507 for (profile_id = 0; profile_id < vec_len (cfg->pipe); profile_id++)
1509 vlib_cli_output (vm, " Pipe profile %u:", profile_id);
1510 vlib_cli_output (vm, " Rate = %u bytes/second",
1511 cfg->pipe[profile_id].tb_rate);
1512 vlib_cli_output (vm, " Token bucket size = %u bytes",
1513 cfg->pipe[profile_id].tb_size);
1514 vlib_cli_output (vm,
1515 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1516 cfg->pipe[profile_id].tc_rate[0],
1517 cfg->pipe[profile_id].tc_rate[1],
1518 cfg->pipe[profile_id].tc_rate[2],
1519 cfg->pipe[profile_id].tc_rate[3]);
1520 vlib_cli_output (vm, " TC period = %u milliseconds",
1521 cfg->pipe[profile_id].tc_period);
1522 #ifdef RTE_SCHED_SUBPORT_TC_OV
1523 vlib_cli_output (vm, " TC3 oversubscription_weight = %u",
1524 cfg->pipe[profile_id].tc_ov_weight);
1527 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1529 vlib_cli_output (vm,
1530 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1531 i, cfg->pipe[profile_id].wrr_weights[i * 4],
1532 cfg->pipe[profile_id].wrr_weights[i * 4 + 1],
1533 cfg->pipe[profile_id].wrr_weights[i * 4 + 2],
1534 cfg->pipe[profile_id].wrr_weights[i * 4 + 3]);
1538 #ifdef RTE_SCHED_RED
1539 vlib_cli_output (vm, " Weighted Random Early Detection (WRED):");
1540 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1542 vlib_cli_output (vm, " TC%u min: G = %u, Y = %u, R = %u", i,
1543 cfg->port.red_params[i][e_RTE_METER_GREEN].min_th,
1544 cfg->port.red_params[i][e_RTE_METER_YELLOW].min_th,
1545 cfg->port.red_params[i][e_RTE_METER_RED].min_th);
1547 vlib_cli_output (vm, " TC%u max: G = %u, Y = %u, R = %u", i,
1548 cfg->port.red_params[i][e_RTE_METER_GREEN].max_th,
1549 cfg->port.red_params[i][e_RTE_METER_YELLOW].max_th,
1550 cfg->port.red_params[i][e_RTE_METER_RED].max_th);
1552 vlib_cli_output (vm,
1553 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1554 i, cfg->port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1555 cfg->port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1556 cfg->port.red_params[i][e_RTE_METER_RED].maxp_inv);
1558 vlib_cli_output (vm, " TC%u weight: R = %u, Y = %u, R = %u", i,
1559 cfg->port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1560 cfg->port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1561 cfg->port.red_params[i][e_RTE_METER_RED].wq_log2);
1569 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos, static) = {
1570 .path = "show dpdk interface hqos",
1571 .short_help = "show dpdk interface hqos <if-name>",
1572 .function = show_dpdk_if_hqos,
1577 dpdk_cli_init (vlib_main_t * vm)
1582 VLIB_INIT_FUNCTION (dpdk_cli_init);
1585 * fd.io coding-style-patch-verification: ON
1588 * eval: (c-set-style "gnu")