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 #if RTE_VERSION >= RTE_VERSION_NUM(16, 7, 0, 0)
173 unsigned count = rte_mempool_avail_count (rmp);
174 unsigned free_count = rte_mempool_in_use_count (rmp);
176 unsigned count = rte_mempool_count (rmp);
177 unsigned free_count = rte_mempool_free_count (rmp);
181 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
182 rmp->name, (u32) count, (u32) free_count,
183 (u32) (count + free_count));
187 vlib_cli_output (vm, "rte_mempool is NULL (!)\n");
194 VLIB_CLI_COMMAND (cmd_show_dpdk_bufferr,static) = {
195 .path = "show dpdk buffer",
196 .short_help = "show dpdk buffer state",
197 .function = show_dpdk_buffer,
202 static clib_error_t *
203 test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
204 vlib_cli_command_t * cmd)
206 static u32 *allocated_buffers;
209 u32 first, actual_alloc;
211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
213 if (unformat (input, "allocate %d", &n_alloc))
215 else if (unformat (input, "free %d", &n_free))
223 if (vec_len (allocated_buffers) < n_free)
224 return clib_error_return (0, "Can't free %d, only %d allocated",
225 n_free, vec_len (allocated_buffers));
227 first = vec_len (allocated_buffers) - n_free;
228 vlib_buffer_free (vm, allocated_buffers + first, n_free);
229 _vec_len (allocated_buffers) = first;
233 first = vec_len (allocated_buffers);
234 vec_validate (allocated_buffers,
235 vec_len (allocated_buffers) + n_alloc - 1);
237 actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
239 _vec_len (allocated_buffers) = first + actual_alloc;
241 if (actual_alloc < n_alloc)
242 vlib_cli_output (vm, "WARNING: only allocated %d buffers",
246 vlib_cli_output (vm, "Currently %d buffers allocated",
247 vec_len (allocated_buffers));
249 if (allocated_buffers && vec_len (allocated_buffers) == 0)
250 vec_free (allocated_buffers);
256 VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = {
257 .path = "test dpdk buffer",
258 .short_help = "test dpdk buffer [allocate <nn>][free <nn>]",
259 .function = test_dpdk_buffer,
265 show_dpdk_device_stats (vlib_main_t * vm, dpdk_device_t * xd)
269 " last_burst_sz %d\n"
271 " full_frames_cnt %u\n"
272 " consec_full_frames_cnt %u\n"
273 " congestion_cnt %d\n"
274 " last_poll_time %llu\n"
275 " max_poll_delay %llu\n"
277 " total_packet_cnt %u\n",
279 xd->efd_agent.last_burst_sz,
280 xd->efd_agent.max_burst_sz,
281 xd->efd_agent.full_frames_cnt,
282 xd->efd_agent.consec_full_frames_cnt,
283 xd->efd_agent.congestion_cnt,
284 xd->efd_agent.last_poll_time,
285 xd->efd_agent.max_poll_delay,
286 xd->efd_agent.discard_cnt, xd->efd_agent.total_packet_cnt);
288 u32 device_queue_sz = rte_eth_rx_queue_count (xd->device_index,
290 vlib_cli_output (vm, " device_queue_sz %u\n", device_queue_sz);
294 show_efd_config (vlib_main_t * vm)
296 vlib_thread_main_t *tm = vlib_get_thread_main ();
297 dpdk_main_t *dm = &dpdk_main;
300 "dpdk: (0x%04x) enabled:%d monitor:%d drop_all:%d\n"
301 " dpdk_queue_hi_thresh %d\n"
302 " consec_full_frames_hi_thresh %d\n"
304 "worker: (0x%04x) enabled:%d monitor:%d\n"
305 " worker_queue_hi_thresh %d\n",
307 ((dm->efd.enabled & DPDK_EFD_DISCARD_ENABLED) ? 1 : 0),
308 ((dm->efd.enabled & DPDK_EFD_MONITOR_ENABLED) ? 1 : 0),
309 ((dm->efd.enabled & DPDK_EFD_DROPALL_ENABLED) ? 1 : 0),
310 dm->efd.queue_hi_thresh,
311 dm->efd.consec_full_frames_hi_thresh,
313 ((tm->efd.enabled & VLIB_EFD_DISCARD_ENABLED) ? 1 : 0),
314 ((dm->efd.enabled & VLIB_EFD_MONITOR_ENABLED) ? 1 : 0),
315 tm->efd.queue_hi_thresh);
318 "ip_prec_bitmap 0x%02x\n"
319 "mpls_exp_bitmap 0x%02x\n"
320 "vlan_cos_bitmap 0x%02x\n",
321 tm->efd.ip_prec_bitmap,
322 tm->efd.mpls_exp_bitmap, tm->efd.vlan_cos_bitmap);
325 static clib_error_t *
326 show_efd (vlib_main_t * vm,
327 unformat_input_t * input, vlib_cli_command_t * cmd)
330 if (unformat (input, "config"))
332 show_efd_config (vm);
334 else if (unformat (input, "dpdk"))
336 dpdk_main_t *dm = &dpdk_main;
340 (void) unformat (input, "device %d", &device_id);
342 vec_foreach (xd, dm->devices)
344 if ((xd->device_index == device_id) || (device_id == ~0))
346 show_dpdk_device_stats(vm, xd);
351 else if (unformat (input, "worker"))
353 vlib_thread_main_t *tm = vlib_get_thread_main ();
354 vlib_frame_queue_t *fq;
355 vlib_thread_registration_t *tr;
358 u32 first_worker_index = 0;
361 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
363 tr = (vlib_thread_registration_t *) p[0];
366 num_workers = tr->count;
367 first_worker_index = tr->first_index;
372 "first_worker_index %d\n"
373 "vlib_frame_queues[%d]:\n",
374 num_workers, first_worker_index, tm->n_vlib_mains);
376 for (thread_id = 0; thread_id < tm->n_vlib_mains; thread_id++)
378 fq = vlib_frame_queues[thread_id];
382 "%2d: frames_queued %u\n"
383 " frames_queued_hint %u\n"
384 " enqueue_full_events %u\n"
385 " enqueue_efd_discards %u\n",
387 (fq->tail - fq->head),
388 (fq->tail - fq->head_hint),
389 fq->enqueue_full_events,
390 fq->enqueue_efd_discards);
394 else if (unformat (input, "help"))
396 vlib_cli_output (vm, "Usage: show efd config | "
397 "dpdk [device <id>] | worker\n");
401 show_efd_config (vm);
408 VLIB_CLI_COMMAND (show_efd_command, static) = {
410 .short_help = "Show efd [device <id>] | [config]",
411 .function = show_efd,
415 static clib_error_t *
416 clear_efd (vlib_main_t * vm,
417 unformat_input_t * input, vlib_cli_command_t * cmd)
419 dpdk_main_t *dm = &dpdk_main;
421 vlib_thread_main_t *tm = vlib_get_thread_main ();
422 vlib_frame_queue_t *fq;
426 vec_foreach (xd, dm->devices)
428 xd->efd_agent.last_burst_sz = 0;
429 xd->efd_agent.max_burst_sz = 0;
430 xd->efd_agent.full_frames_cnt = 0;
431 xd->efd_agent.consec_full_frames_cnt = 0;
432 xd->efd_agent.congestion_cnt = 0;
433 xd->efd_agent.last_poll_time = 0;
434 xd->efd_agent.max_poll_delay = 0;
435 xd->efd_agent.discard_cnt = 0;
436 xd->efd_agent.total_packet_cnt = 0;
440 for (thread_id = 0; thread_id < tm->n_vlib_mains; thread_id++)
442 fq = vlib_frame_queues[thread_id];
445 fq->enqueue_full_events = 0;
446 fq->enqueue_efd_discards = 0;
454 VLIB_CLI_COMMAND (clear_efd_command,static) = {
456 .short_help = "Clear early-fast-discard counters",
457 .function = clear_efd,
461 static clib_error_t *
462 parse_op_and_prec (vlib_main_t * vm, unformat_input_t * input,
463 vlib_cli_command_t * cmd,
464 char *prec_type, u8 * prec_bitmap)
466 clib_error_t *error = NULL;
470 if (unformat (input, "ge"))
472 op = EFD_OPERATION_GREATER_OR_EQUAL;
474 else if (unformat (input, "lt"))
476 op = EFD_OPERATION_LESS_THAN;
478 else if (unformat (input, "help"))
480 vlib_cli_output (vm, "enter operation [ge | lt] and precedence <0-7>)");
485 return clib_error_return (0, "unknown input `%U'",
486 format_unformat_error, input);
489 if (unformat (input, "%u", &prec))
493 return clib_error_return (0, "precedence %d is out of range <0-7>",
499 return clib_error_return (0, "unknown input `%U'",
500 format_unformat_error, input);
503 set_efd_bitmap (prec_bitmap, prec, op);
506 "EFD will be set for %s precedence %s%u%s.",
508 (op == EFD_OPERATION_LESS_THAN) ? "less than " : "",
511 EFD_OPERATION_GREATER_OR_EQUAL) ? " and greater" : "");
517 static clib_error_t *
518 set_efd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
520 dpdk_main_t *dm = &dpdk_main;
521 vlib_thread_main_t *tm = vlib_get_thread_main ();
522 clib_error_t *error = NULL;
523 vlib_node_runtime_t *rt = vlib_node_get_runtime (vm, dpdk_input_node.index);
525 if (unformat (input, "enable"))
527 if (unformat (input, "dpdk"))
529 dm->efd.enabled |= DPDK_EFD_DISCARD_ENABLED;
531 else if (unformat (input, "worker"))
533 tm->efd.enabled |= VLIB_EFD_DISCARD_ENABLED;
535 else if (unformat (input, "monitor"))
537 dm->efd.enabled |= DPDK_EFD_MONITOR_ENABLED;
538 tm->efd.enabled |= VLIB_EFD_MONITOR_ENABLED;
540 else if (unformat (input, "drop_all"))
542 dm->efd.enabled |= DPDK_EFD_DROPALL_ENABLED;
544 else if (unformat (input, "default"))
546 dm->efd.enabled = (DPDK_EFD_DISCARD_ENABLED |
547 DPDK_EFD_MONITOR_ENABLED);
548 tm->efd.enabled = (VLIB_EFD_DISCARD_ENABLED |
549 VLIB_EFD_MONITOR_ENABLED);
553 return clib_error_return (0, "Usage: set efd enable [dpdk | "
554 "worker | monitor | drop_all | default]");
557 else if (unformat (input, "disable"))
559 if (unformat (input, "dpdk"))
561 dm->efd.enabled &= ~DPDK_EFD_DISCARD_ENABLED;
563 else if (unformat (input, "worker"))
565 tm->efd.enabled &= ~VLIB_EFD_DISCARD_ENABLED;
567 else if (unformat (input, "monitor"))
569 dm->efd.enabled &= ~DPDK_EFD_MONITOR_ENABLED;
570 tm->efd.enabled &= ~VLIB_EFD_MONITOR_ENABLED;
572 else if (unformat (input, "drop_all"))
574 dm->efd.enabled &= ~DPDK_EFD_DROPALL_ENABLED;
576 else if (unformat (input, "all"))
583 return clib_error_return (0, "Usage: set efd disable [dpdk | "
584 "worker | monitor | drop_all | all]");
587 else if (unformat (input, "worker_queue_hi_thresh"))
590 if (unformat (input, "%u", &mark))
592 tm->efd.queue_hi_thresh = mark;
596 return clib_error_return (0, "unknown input `%U'",
597 format_unformat_error, input);
600 else if (unformat (input, "dpdk_device_hi_thresh"))
603 if (unformat (input, "%u", &thresh))
605 dm->efd.queue_hi_thresh = thresh;
609 return clib_error_return (0, "unknown input `%U'",
610 format_unformat_error, input);
613 else if (unformat (input, "consec_full_frames_hi_thresh"))
616 if (unformat (input, "%u", &thresh))
618 dm->efd.consec_full_frames_hi_thresh = thresh;
622 return clib_error_return (0, "unknown input `%U'",
623 format_unformat_error, input);
626 else if (unformat (input, "ip-prec"))
628 return (parse_op_and_prec (vm, input, cmd,
629 "ip", &tm->efd.ip_prec_bitmap));
631 else if (unformat (input, "mpls-exp"))
633 return (parse_op_and_prec (vm, input, cmd,
634 "mpls", &tm->efd.mpls_exp_bitmap));
636 else if (unformat (input, "vlan-cos"))
638 return (parse_op_and_prec (vm, input, cmd,
639 "vlan", &tm->efd.vlan_cos_bitmap));
641 else if (unformat (input, "help"))
645 " set efd enable <dpdk | worker | monitor | drop_all | default> |\n"
646 " set efd disable <dpdk | worker | monitor | drop_all | all> |\n"
647 " set efd <ip-prec | mpls-exp | vlan-cos> <ge | lt> <0-7>\n"
648 " set efd worker_queue_hi_thresh <0-32> |\n"
649 " set efd dpdk_device_hi_thresh <0-%d> |\n"
650 " set efd consec_full_frames_hi_thresh <count> |\n",
651 DPDK_NB_RX_DESC_10GE);
655 return clib_error_return (0, "unknown input `%U'",
656 format_unformat_error, input);
660 rt->function = dpdk_input_efd_multiarch_select ();
661 else if (dm->use_rss)
662 rt->function = dpdk_input_rss_multiarch_select ();
664 rt->function = dpdk_input_multiarch_select ();
670 VLIB_CLI_COMMAND (cmd_set_efd,static) = {
672 .short_help = "set early-fast-discard commands",
677 static clib_error_t *
678 set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input,
679 vlib_cli_command_t * cmd)
681 unformat_input_t _line_input, *line_input = &_line_input;
682 dpdk_main_t *dm = &dpdk_main;
683 vnet_hw_interface_t *hw;
685 u32 hw_if_index = (u32) ~ 0;
686 u32 nb_rx_desc = (u32) ~ 0;
687 u32 nb_tx_desc = (u32) ~ 0;
690 if (!unformat_user (input, unformat_line_input, line_input))
693 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
696 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
699 else if (unformat (line_input, "tx %d", &nb_tx_desc))
701 else if (unformat (line_input, "rx %d", &nb_rx_desc))
704 return clib_error_return (0, "parse error: '%U'",
705 format_unformat_error, line_input);
708 unformat_free (line_input);
710 if (hw_if_index == (u32) ~ 0)
711 return clib_error_return (0, "please specify valid interface name");
713 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
714 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
716 if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
717 return clib_error_return (0, "number of descriptors can be set only for "
720 if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) &&
721 (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc))
722 return clib_error_return (0, "nothing changed");
724 if (nb_rx_desc != (u32) ~ 0)
725 xd->nb_rx_desc = nb_rx_desc;
727 if (nb_tx_desc != (u32) ~ 0)
728 xd->nb_rx_desc = nb_rx_desc;
730 rv = dpdk_port_setup (dm, xd);
736 VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = {
737 .path = "set dpdk interface descriptors",
738 .short_help = "set dpdk interface descriptors <if-name> [rx <n>] [tx <n>]",
739 .function = set_dpdk_if_desc,
743 static clib_error_t *
744 show_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
745 vlib_cli_command_t * cmd)
747 vlib_thread_main_t *tm = vlib_get_thread_main ();
748 dpdk_main_t *dm = &dpdk_main;
749 dpdk_device_and_queue_t *dq;
752 if (tm->n_vlib_mains == 1)
753 vlib_cli_output (vm, "All interfaces are handled by main thread");
755 for (cpu = 0; cpu < vec_len (dm->devices_by_cpu); cpu++)
757 if (vec_len (dm->devices_by_cpu[cpu]))
758 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
759 vlib_worker_threads[cpu].name,
760 vlib_worker_threads[cpu].lcore_id);
763 vec_foreach(dq, dm->devices_by_cpu[cpu])
765 u32 hw_if_index = dm->devices[dq->device].vlib_hw_if_index;
766 vnet_hw_interface_t * hi = vnet_get_hw_interface(dm->vnet_main, hw_if_index);
767 vlib_cli_output(vm, " %v queue %u", hi->name, dq->queue_id);
775 VLIB_CLI_COMMAND (cmd_show_dpdk_if_placement,static) = {
776 .path = "show dpdk interface placement",
777 .short_help = "show dpdk interface placement",
778 .function = show_dpdk_if_placement,
783 dpdk_device_queue_sort (void *a1, void *a2)
785 dpdk_device_and_queue_t *dq1 = a1;
786 dpdk_device_and_queue_t *dq2 = a2;
788 if (dq1->device > dq2->device)
790 else if (dq1->device < dq2->device)
792 else if (dq1->queue_id > dq2->queue_id)
794 else if (dq1->queue_id < dq2->queue_id)
800 static clib_error_t *
801 set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
802 vlib_cli_command_t * cmd)
804 unformat_input_t _line_input, *line_input = &_line_input;
805 dpdk_main_t *dm = &dpdk_main;
806 dpdk_device_and_queue_t *dq;
807 vnet_hw_interface_t *hw;
809 u32 hw_if_index = (u32) ~ 0;
814 if (!unformat_user (input, unformat_line_input, line_input))
817 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
820 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
823 else if (unformat (line_input, "queue %d", &queue))
825 else if (unformat (line_input, "thread %d", &cpu))
828 return clib_error_return (0, "parse error: '%U'",
829 format_unformat_error, line_input);
832 unformat_free (line_input);
834 if (hw_if_index == (u32) ~ 0)
835 return clib_error_return (0, "please specify valid interface name");
837 if (cpu < dm->input_cpu_first_index ||
838 cpu >= (dm->input_cpu_first_index + dm->input_cpu_count))
839 return clib_error_return (0, "please specify valid thread id");
841 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
842 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
844 for (i = 0; i < vec_len (dm->devices_by_cpu); i++)
847 vec_foreach(dq, dm->devices_by_cpu[i])
849 if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index &&
850 queue == dq->queue_id)
852 if (cpu == i) /* nothing to do */
855 vec_del1(dm->devices_by_cpu[i], dq - dm->devices_by_cpu[i]);
856 vec_add2(dm->devices_by_cpu[cpu], dq, 1);
857 dq->queue_id = queue;
858 dq->device = xd->device_index;
859 xd->cpu_socket_id_by_queue[queue] =
860 rte_lcore_to_socket_id(vlib_worker_threads[cpu].lcore_id);
862 vec_sort_with_function(dm->devices_by_cpu[i],
863 dpdk_device_queue_sort);
865 vec_sort_with_function(dm->devices_by_cpu[cpu],
866 dpdk_device_queue_sort);
868 if (vec_len(dm->devices_by_cpu[i]) == 0)
869 vlib_node_set_state (vlib_mains[i], dpdk_input_node.index,
870 VLIB_NODE_STATE_DISABLED);
872 if (vec_len(dm->devices_by_cpu[cpu]) == 1)
873 vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
874 VLIB_NODE_STATE_POLLING);
882 return clib_error_return (0, "not found");
886 VLIB_CLI_COMMAND (cmd_set_dpdk_if_placement,static) = {
887 .path = "set dpdk interface placement",
888 .short_help = "set dpdk interface placement <if-name> [queue <n>] thread <n>",
889 .function = set_dpdk_if_placement,
893 static clib_error_t *
894 show_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
895 vlib_cli_command_t * cmd)
897 vlib_thread_main_t *tm = vlib_get_thread_main ();
898 dpdk_main_t *dm = &dpdk_main;
899 dpdk_device_and_queue_t *dq;
902 if (tm->n_vlib_mains == 1)
903 vlib_cli_output (vm, "All interfaces are handled by main thread");
905 for (cpu = 0; cpu < vec_len (dm->devices_by_hqos_cpu); cpu++)
907 if (vec_len (dm->devices_by_hqos_cpu[cpu]))
908 vlib_cli_output (vm, "Thread %u (%s at lcore %u):", cpu,
909 vlib_worker_threads[cpu].name,
910 vlib_worker_threads[cpu].lcore_id);
912 vec_foreach (dq, dm->devices_by_hqos_cpu[cpu])
914 u32 hw_if_index = dm->devices[dq->device].vlib_hw_if_index;
915 vnet_hw_interface_t *hi =
916 vnet_get_hw_interface (dm->vnet_main, hw_if_index);
917 vlib_cli_output (vm, " %v queue %u", hi->name, dq->queue_id);
924 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos_placement, static) = {
925 .path = "show dpdk interface hqos placement",
926 .short_help = "show dpdk interface hqos placement",
927 .function = show_dpdk_if_hqos_placement,
931 static clib_error_t *
932 set_dpdk_if_hqos_placement (vlib_main_t * vm, unformat_input_t * input,
933 vlib_cli_command_t * cmd)
935 unformat_input_t _line_input, *line_input = &_line_input;
936 dpdk_main_t *dm = &dpdk_main;
937 dpdk_device_and_queue_t *dq;
938 vnet_hw_interface_t *hw;
940 u32 hw_if_index = (u32) ~ 0;
944 if (!unformat_user (input, unformat_line_input, line_input))
947 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
950 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
953 else if (unformat (line_input, "thread %d", &cpu))
956 return clib_error_return (0, "parse error: '%U'",
957 format_unformat_error, line_input);
960 unformat_free (line_input);
962 if (hw_if_index == (u32) ~ 0)
963 return clib_error_return (0, "please specify valid interface name");
965 if (cpu < dm->hqos_cpu_first_index ||
966 cpu >= (dm->hqos_cpu_first_index + dm->hqos_cpu_count))
967 return clib_error_return (0, "please specify valid thread id");
969 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
970 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
972 for (i = 0; i < vec_len (dm->devices_by_hqos_cpu); i++)
974 vec_foreach (dq, dm->devices_by_hqos_cpu[i])
976 if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index)
978 if (cpu == i) /* nothing to do */
981 vec_del1 (dm->devices_by_hqos_cpu[i],
982 dq - dm->devices_by_hqos_cpu[i]);
983 vec_add2 (dm->devices_by_hqos_cpu[cpu], dq, 1);
985 dq->device = xd->device_index;
987 vec_sort_with_function (dm->devices_by_hqos_cpu[i],
988 dpdk_device_queue_sort);
990 vec_sort_with_function (dm->devices_by_hqos_cpu[cpu],
991 dpdk_device_queue_sort);
998 return clib_error_return (0, "not found");
1002 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_placement, static) = {
1003 .path = "set dpdk interface hqos placement",
1004 .short_help = "set dpdk interface hqos placement <if-name> thread <n>",
1005 .function = set_dpdk_if_hqos_placement,
1009 static clib_error_t *
1010 set_dpdk_if_hqos_pipe (vlib_main_t * vm, unformat_input_t * input,
1011 vlib_cli_command_t * cmd)
1013 unformat_input_t _line_input, *line_input = &_line_input;
1014 dpdk_main_t *dm = &dpdk_main;
1015 vnet_hw_interface_t *hw;
1017 u32 hw_if_index = (u32) ~ 0;
1018 u32 subport_id = (u32) ~ 0;
1019 u32 pipe_id = (u32) ~ 0;
1020 u32 profile_id = (u32) ~ 0;
1023 if (!unformat_user (input, unformat_line_input, line_input))
1026 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1029 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1032 else if (unformat (line_input, "subport %d", &subport_id))
1034 else if (unformat (line_input, "pipe %d", &pipe_id))
1036 else if (unformat (line_input, "profile %d", &profile_id))
1039 return clib_error_return (0, "parse error: '%U'",
1040 format_unformat_error, line_input);
1043 unformat_free (line_input);
1045 if (hw_if_index == (u32) ~ 0)
1046 return clib_error_return (0, "please specify valid interface name");
1048 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1049 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1052 rte_sched_pipe_config (xd->hqos_ht->hqos, subport_id, pipe_id,
1055 return clib_error_return (0, "pipe configuration failed");
1061 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pipe, static) =
1063 .path = "set dpdk interface hqos pipe",
1064 .short_help = "set dpdk interface hqos pipe <if-name> subport <n> pipe <n> "
1066 .function = set_dpdk_if_hqos_pipe,
1070 static clib_error_t *
1071 set_dpdk_if_hqos_subport (vlib_main_t * vm, unformat_input_t * input,
1072 vlib_cli_command_t * cmd)
1074 unformat_input_t _line_input, *line_input = &_line_input;
1075 dpdk_main_t *dm = &dpdk_main;
1076 vnet_hw_interface_t *hw;
1078 u32 hw_if_index = (u32) ~ 0;
1079 u32 subport_id = (u32) ~ 0;
1080 struct rte_sched_subport_params p = {
1081 .tb_rate = 1250000000, /* 10GbE */
1083 .tc_rate = {1250000000, 1250000000, 1250000000, 1250000000},
1088 if (!unformat_user (input, unformat_line_input, line_input))
1091 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1094 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1097 else if (unformat (line_input, "subport %d", &subport_id))
1099 else if (unformat (line_input, "rate %d", &p.tb_rate))
1101 p.tc_rate[0] = p.tb_rate;
1102 p.tc_rate[1] = p.tb_rate;
1103 p.tc_rate[2] = p.tb_rate;
1104 p.tc_rate[3] = p.tb_rate;
1106 else if (unformat (line_input, "bktsize %d", &p.tb_size))
1108 else if (unformat (line_input, "tc0 %d", &p.tc_rate[0]))
1110 else if (unformat (line_input, "tc1 %d", &p.tc_rate[1]))
1112 else if (unformat (line_input, "tc2 %d", &p.tc_rate[2]))
1114 else if (unformat (line_input, "tc3 %d", &p.tc_rate[3]))
1116 else if (unformat (line_input, "period %d", &p.tc_period))
1119 return clib_error_return (0, "parse error: '%U'",
1120 format_unformat_error, line_input);
1123 unformat_free (line_input);
1125 if (hw_if_index == (u32) ~ 0)
1126 return clib_error_return (0, "please specify valid interface name");
1128 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1129 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1131 rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport_id, &p);
1133 return clib_error_return (0, "subport configuration failed");
1139 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_subport, static) = {
1140 .path = "set dpdk interface hqos subport",
1141 .short_help = "set dpdk interface hqos subport <if-name> subport <n> "
1142 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] "
1144 .function = set_dpdk_if_hqos_subport,
1148 static clib_error_t *
1149 set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
1150 vlib_cli_command_t * cmd)
1152 unformat_input_t _line_input, *line_input = &_line_input;
1153 vlib_thread_main_t *tm = vlib_get_thread_main ();
1154 dpdk_main_t *dm = &dpdk_main;
1155 vnet_hw_interface_t *hw;
1157 u32 hw_if_index = (u32) ~ 0;
1158 u32 entry, tc, queue, val, i;
1160 if (!unformat_user (input, unformat_line_input, line_input))
1163 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1166 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1169 else if (unformat (line_input, "entry %d", &entry))
1171 else if (unformat (line_input, "tc %d", &tc))
1173 else if (unformat (line_input, "queue %d", &queue))
1176 return clib_error_return (0, "parse error: '%U'",
1177 format_unformat_error, line_input);
1180 unformat_free (line_input);
1182 if (hw_if_index == (u32) ~ 0)
1183 return clib_error_return (0, "please specify valid interface name");
1185 return clib_error_return (0, "invalid entry");
1186 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
1187 return clib_error_return (0, "invalid traffic class");
1188 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
1189 return clib_error_return (0, "invalid traffic class");
1191 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1192 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1194 /* Detect the set of worker threads */
1195 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1196 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1197 int worker_thread_first = tr->first_index;
1198 int worker_thread_count = tr->count;
1200 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
1201 for (i = 0; i < worker_thread_count; i++)
1202 xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
1208 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_tctbl, static) = {
1209 .path = "set dpdk interface hqos tctbl",
1210 .short_help = "set dpdk interface hqos tctbl <if-name> entry <n> tc <n> queue <n>",
1211 .function = set_dpdk_if_hqos_tctbl,
1215 static clib_error_t *
1216 set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
1217 vlib_cli_command_t * cmd)
1219 unformat_input_t _line_input, *line_input = &_line_input;
1220 vlib_thread_main_t *tm = vlib_get_thread_main ();
1221 dpdk_main_t *dm = &dpdk_main;
1223 /* Device specific data */
1224 struct rte_eth_dev_info dev_info;
1225 dpdk_device_config_t *devconf = 0;
1226 vnet_hw_interface_t *hw;
1228 u32 hw_if_index = (u32) ~ 0;
1230 /* Detect the set of worker threads */
1231 uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1232 vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
1233 int worker_thread_first = tr->first_index;
1234 int worker_thread_count = tr->count;
1236 /* Packet field configuration */
1241 u32 n_subports_per_port, n_pipes_per_subport, tctbl_size;
1245 /* Parse input arguments */
1246 if (!unformat_user (input, unformat_line_input, line_input))
1249 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1252 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1255 else if (unformat (line_input, "id %d", &id))
1257 else if (unformat (line_input, "offset %d", &offset))
1259 else if (unformat (line_input, "mask %llx", &mask))
1262 return clib_error_return (0, "parse error: '%U'",
1263 format_unformat_error, line_input);
1266 unformat_free (line_input);
1269 if (hw_if_index == (u32) ~ 0)
1270 return clib_error_return (0, "please specify valid interface name");
1272 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1273 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1275 rte_eth_dev_info_get (xd->device_index, &dev_info);
1276 if (dev_info.pci_dev)
1277 { /* bonded interface has no pci info */
1278 vlib_pci_addr_t pci_addr;
1280 pci_addr.domain = dev_info.pci_dev->addr.domain;
1281 pci_addr.bus = dev_info.pci_dev->addr.bus;
1282 pci_addr.slot = dev_info.pci_dev->addr.devid;
1283 pci_addr.function = dev_info.pci_dev->addr.function;
1286 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1290 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1292 devconf = &dm->conf->default_devconf;
1294 if (devconf->hqos_enabled == 0)
1296 vlib_cli_output (vm, "HQoS disabled for this interface");
1300 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
1301 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
1302 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
1304 /* Validate packet field configuration: id, offset and mask */
1306 return clib_error_return (0, "invalid packet field id");
1311 if (dpdk_hqos_validate_mask (mask, n_subports_per_port) != 0)
1312 return clib_error_return (0, "invalid subport ID mask "
1313 "(n_subports_per_port = %u)",
1314 n_subports_per_port);
1317 if (dpdk_hqos_validate_mask (mask, n_pipes_per_subport) != 0)
1318 return clib_error_return (0, "invalid pipe ID mask "
1319 "(n_pipes_per_subport = %u)",
1320 n_pipes_per_subport);
1324 if (dpdk_hqos_validate_mask (mask, tctbl_size) != 0)
1325 return clib_error_return (0, "invalid TC table index mask "
1326 "(TC table size = %u)", tctbl_size);
1329 /* Propagate packet field configuration to all workers */
1330 for (i = 0; i < worker_thread_count; i++)
1334 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabpos = offset;
1335 xd->hqos_wt[worker_thread_first + i].hqos_field0_slabmask = mask;
1338 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabpos = offset;
1339 xd->hqos_wt[worker_thread_first + i].hqos_field1_slabmask = mask;
1343 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabpos = offset;
1344 xd->hqos_wt[worker_thread_first + i].hqos_field2_slabmask = mask;
1351 VLIB_CLI_COMMAND (cmd_set_dpdk_if_hqos_pktfield, static) = {
1352 .path = "set dpdk interface hqos pktfield",
1353 .short_help = "set dpdk interface hqos pktfield <if-name> id <n> offset <n> "
1355 .function = set_dpdk_if_hqos_pktfield,
1359 static clib_error_t *
1360 show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
1361 vlib_cli_command_t * cmd)
1363 unformat_input_t _line_input, *line_input = &_line_input;
1364 vlib_thread_main_t *tm = vlib_get_thread_main ();
1365 dpdk_main_t *dm = &dpdk_main;
1366 vnet_hw_interface_t *hw;
1368 dpdk_device_config_hqos_t *cfg;
1369 dpdk_device_hqos_per_hqos_thread_t *ht;
1370 dpdk_device_hqos_per_worker_thread_t *wk;
1372 u32 hw_if_index = (u32) ~ 0;
1374 struct rte_eth_dev_info dev_info;
1375 dpdk_device_config_t *devconf = 0;
1376 vlib_thread_registration_t *tr;
1379 if (!unformat_user (input, unformat_line_input, line_input))
1382 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1385 (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main,
1389 return clib_error_return (0, "parse error: '%U'",
1390 format_unformat_error, line_input);
1393 unformat_free (line_input);
1395 if (hw_if_index == (u32) ~ 0)
1396 return clib_error_return (0, "please specify interface name!!");
1398 hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
1399 xd = vec_elt_at_index (dm->devices, hw->dev_instance);
1401 rte_eth_dev_info_get (xd->device_index, &dev_info);
1402 if (dev_info.pci_dev)
1403 { /* bonded interface has no pci info */
1404 vlib_pci_addr_t pci_addr;
1406 pci_addr.domain = dev_info.pci_dev->addr.domain;
1407 pci_addr.bus = dev_info.pci_dev->addr.bus;
1408 pci_addr.slot = dev_info.pci_dev->addr.devid;
1409 pci_addr.function = dev_info.pci_dev->addr.function;
1412 hash_get (dm->conf->device_config_index_by_pci_addr, pci_addr.as_u32);
1416 devconf = pool_elt_at_index (dm->conf->dev_confs, p[0]);
1418 devconf = &dm->conf->default_devconf;
1420 if (devconf->hqos_enabled == 0)
1422 vlib_cli_output (vm, "HQoS disabled for this interface");
1426 /* Detect the set of worker threads */
1427 p = hash_get_mem (tm->thread_registrations_by_name, "workers");
1428 tr = (vlib_thread_registration_t *) p[0];
1430 cfg = &devconf->hqos;
1432 wk = &xd->hqos_wt[tr->first_index];
1433 tctbl = wk->hqos_tc_table;
1435 vlib_cli_output (vm, " Thread:");
1436 vlib_cli_output (vm, " Input SWQ size = %u packets", cfg->swq_size);
1437 vlib_cli_output (vm, " Enqueue burst size = %u packets",
1438 ht->hqos_burst_enq);
1439 vlib_cli_output (vm, " Dequeue burst size = %u packets",
1440 ht->hqos_burst_deq);
1442 vlib_cli_output (vm,
1443 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx",
1444 wk->hqos_field0_slabpos, wk->hqos_field0_slabmask);
1445 vlib_cli_output (vm,
1446 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx",
1447 wk->hqos_field1_slabpos, wk->hqos_field1_slabmask);
1448 vlib_cli_output (vm,
1449 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx",
1450 wk->hqos_field2_slabpos, wk->hqos_field2_slabmask);
1451 vlib_cli_output (vm, " Packet field 2 translation table:");
1452 vlib_cli_output (vm, " [ 0 .. 15]: "
1453 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1454 tctbl[0], tctbl[1], tctbl[2], tctbl[3],
1455 tctbl[4], tctbl[5], tctbl[6], tctbl[7],
1456 tctbl[8], tctbl[9], tctbl[10], tctbl[11],
1457 tctbl[12], tctbl[13], tctbl[14], tctbl[15]);
1458 vlib_cli_output (vm, " [16 .. 31]: "
1459 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1460 tctbl[16], tctbl[17], tctbl[18], tctbl[19],
1461 tctbl[20], tctbl[21], tctbl[22], tctbl[23],
1462 tctbl[24], tctbl[25], tctbl[26], tctbl[27],
1463 tctbl[28], tctbl[29], tctbl[30], tctbl[31]);
1464 vlib_cli_output (vm, " [32 .. 47]: "
1465 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1466 tctbl[32], tctbl[33], tctbl[34], tctbl[35],
1467 tctbl[36], tctbl[37], tctbl[38], tctbl[39],
1468 tctbl[40], tctbl[41], tctbl[42], tctbl[43],
1469 tctbl[44], tctbl[45], tctbl[46], tctbl[47]);
1470 vlib_cli_output (vm, " [48 .. 63]: "
1471 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1472 tctbl[48], tctbl[49], tctbl[50], tctbl[51],
1473 tctbl[52], tctbl[53], tctbl[54], tctbl[55],
1474 tctbl[56], tctbl[57], tctbl[58], tctbl[59],
1475 tctbl[60], tctbl[61], tctbl[62], tctbl[63]);
1477 vlib_cli_output (vm, " Port:");
1478 vlib_cli_output (vm, " Rate = %u bytes/second", cfg->port.rate);
1479 vlib_cli_output (vm, " MTU = %u bytes", cfg->port.mtu);
1480 vlib_cli_output (vm, " Frame overhead = %u bytes",
1481 cfg->port.frame_overhead);
1482 vlib_cli_output (vm, " Number of subports = %u",
1483 cfg->port.n_subports_per_port);
1484 vlib_cli_output (vm, " Number of pipes per subport = %u",
1485 cfg->port.n_pipes_per_subport);
1486 vlib_cli_output (vm,
1487 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1488 cfg->port.qsize[0], cfg->port.qsize[1], cfg->port.qsize[2],
1489 cfg->port.qsize[3]);
1490 vlib_cli_output (vm, " Number of pipe profiles = %u",
1491 cfg->port.n_pipe_profiles);
1493 for (profile_id = 0; profile_id < vec_len (cfg->pipe); profile_id++)
1495 vlib_cli_output (vm, " Pipe profile %u:", profile_id);
1496 vlib_cli_output (vm, " Rate = %u bytes/second",
1497 cfg->pipe[profile_id].tb_rate);
1498 vlib_cli_output (vm, " Token bucket size = %u bytes",
1499 cfg->pipe[profile_id].tb_size);
1500 vlib_cli_output (vm,
1501 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1502 cfg->pipe[profile_id].tc_rate[0],
1503 cfg->pipe[profile_id].tc_rate[1],
1504 cfg->pipe[profile_id].tc_rate[2],
1505 cfg->pipe[profile_id].tc_rate[3]);
1506 vlib_cli_output (vm, " TC period = %u milliseconds",
1507 cfg->pipe[profile_id].tc_period);
1508 #ifdef RTE_SCHED_SUBPORT_TC_OV
1509 vlib_cli_output (vm, " TC3 oversubscription_weight = %u",
1510 cfg->pipe[profile_id].tc_ov_weight);
1513 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1515 vlib_cli_output (vm,
1516 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1517 i, cfg->pipe[profile_id].wrr_weights[i * 4],
1518 cfg->pipe[profile_id].wrr_weights[i * 4 + 1],
1519 cfg->pipe[profile_id].wrr_weights[i * 4 + 2],
1520 cfg->pipe[profile_id].wrr_weights[i * 4 + 3]);
1524 #ifdef RTE_SCHED_RED
1525 vlib_cli_output (vm, " Weighted Random Early Detection (WRED):");
1526 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1528 vlib_cli_output (vm, " TC%u min: G = %u, Y = %u, R = %u", i,
1529 cfg->port.red_params[i][e_RTE_METER_GREEN].min_th,
1530 cfg->port.red_params[i][e_RTE_METER_YELLOW].min_th,
1531 cfg->port.red_params[i][e_RTE_METER_RED].min_th);
1533 vlib_cli_output (vm, " TC%u max: G = %u, Y = %u, R = %u", i,
1534 cfg->port.red_params[i][e_RTE_METER_GREEN].max_th,
1535 cfg->port.red_params[i][e_RTE_METER_YELLOW].max_th,
1536 cfg->port.red_params[i][e_RTE_METER_RED].max_th);
1538 vlib_cli_output (vm,
1539 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1540 i, cfg->port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1541 cfg->port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1542 cfg->port.red_params[i][e_RTE_METER_RED].maxp_inv);
1544 vlib_cli_output (vm, " TC%u weight: R = %u, Y = %u, R = %u", i,
1545 cfg->port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1546 cfg->port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1547 cfg->port.red_params[i][e_RTE_METER_RED].wq_log2);
1555 VLIB_CLI_COMMAND (cmd_show_dpdk_if_hqos, static) = {
1556 .path = "show dpdk interface hqos",
1557 .short_help = "show dpdk interface hqos <if-name>",
1558 .function = show_dpdk_if_hqos,
1563 dpdk_cli_init (vlib_main_t * vm)
1568 VLIB_INIT_FUNCTION (dpdk_cli_init);
1571 * fd.io coding-style-patch-verification: ON
1574 * eval: (c-set-style "gnu")