90 else if (
unformat (input,
"max %d", &max))
96 else if (
unformat (input,
"intfc %U",
100 else if (
unformat (input,
"intfc any"))
105 else if (
unformat (input,
"file %s", &filename))
107 u8 * chroot_filename;
109 if (strstr((
char *)filename,
"..") || index((
char *)filename,
'/'))
116 chroot_filename =
format (0,
"/tmp/%s%c", filename, 0);
125 else if (
unformat (input,
"status"))
151 .path =
"pcap tx trace",
153 "pcap tx trace on off max <nn> intfc <intfc> file <name> status",
162 struct rte_mempool * rmp;
170 unsigned count = rte_mempool_count(rmp);
171 unsigned free_count = rte_mempool_free_count(rmp);
173 vlib_cli_output(vm,
"name=\"%s\" available = %7d allocated = %7d total = %7d\n",
175 (
u32)(count+free_count));
186 .path =
"show dpdk buffer",
187 .short_help =
"show dpdk buffer state",
196 static u32 * allocated_buffers;
203 if (
unformat (input,
"allocate %d", &n_alloc))
205 else if (
unformat (input,
"free %d", &n_free))
213 if (
vec_len (allocated_buffers) < n_free)
215 n_free,
vec_len (allocated_buffers));
217 first =
vec_len(allocated_buffers) - n_free;
219 _vec_len (allocated_buffers) =
first;
223 first =
vec_len (allocated_buffers);
225 vec_len (allocated_buffers) + n_alloc - 1);
229 _vec_len (allocated_buffers) = first + actual_alloc;
231 if (actual_alloc < n_alloc)
239 if (allocated_buffers &&
vec_len(allocated_buffers) == 0)
246 .path =
"test dpdk buffer",
247 .short_help =
"test dpdk buffer [allocate <nn>][free <nn>]",
257 " last_burst_sz %d\n" 259 " full_frames_cnt %u\n" 260 " consec_full_frames_cnt %u\n" 261 " congestion_cnt %d\n" 262 " last_poll_time %llu\n" 263 " max_poll_delay %llu\n" 265 " total_packet_cnt %u\n",
280 " device_queue_sz %u\n",
301 }
else if (
unformat(input,
"off")) {
318 for (fqix=0; fqix<num_fq; fqix++) {
324 memset(fqh, 0,
sizeof(*fqh));
331 .path =
"trace frame-queue",
332 .short_help =
"trace frame-queue (on|off)",
351 return (((two_counters[0] + two_counters[1]) * 100) + (total-1)) / total;
378 "16-17 18-19 20-21 22-23 24-25 26-27 28-29 30-31\n");
381 for (fqix=0; fqix<num_fq; fqix++) {
399 total += fqh->
count[nelt];
410 "%3d%% %3d%% %3d%% %3d%% %3d%% %3d%% %3d%% %3d%% " 411 "%3d%% %3d%% %3d%% %3d%% %3d%% %3d%% %3d%% %3d%%\n",
435 vlib_cli_output(vm,
" %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",
443 vlib_cli_output(vm,
" %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d\n",
470 .path =
"show frame-queue",
471 .short_help =
"show frame-queue trace",
476 .path =
"show frame-queue histogram",
477 .short_help =
"show frame-queue histogram",
495 if ((nelts != 4) && (nelts != 8) && (nelts != 16) && (nelts != 32)) {
506 for (fqix=0; fqix<num_fq; fqix++) {
514 .path =
"test frame-queue nelts",
515 .short_help =
"test frame-queue nelts (4,8,16,32)",
532 if (
unformat(input,
"%d", &threshold)) {
548 for (fqix=0; fqix<num_fq; fqix++) {
556 .path =
"test frame-queue threshold",
557 .short_help =
"test frame-queue threshold N (0=no limit)",
568 "dpdk: (0x%04x) enabled:%d monitor:%d drop_all:%d\n" 569 " dpdk_queue_hi_thresh %d\n" 570 " consec_full_frames_hi_thresh %d\n" 572 "worker: (0x%04x) enabled:%d monitor:%d\n" 573 " worker_queue_hi_thresh %d\n",
586 "ip_prec_bitmap 0x%02x\n" 587 "mpls_exp_bitmap 0x%02x\n" 588 "vlan_cos_bitmap 0x%02x\n",
602 }
else if (
unformat(input,
"dpdk")) {
607 unformat(input,
"device %d", &device_id);
609 if ((xd->
device_index == device_id) || (device_id == ~0)) {
613 }
else if (
unformat(input,
"worker")) {
619 u32 first_worker_index = 0;
627 num_workers = tr->
count;
633 "first_worker_index %d\n" 634 "vlib_frame_queues[%d]:\n",
639 for (thread_id = 0; thread_id < tm->
n_vlib_mains; thread_id++) {
643 "%2d: frames_queued %u\n" 644 " frames_queued_hint %u\n" 645 " enqueue_full_events %u\n" 646 " enqueue_efd_discards %u\n",
654 }
else if (
unformat(input,
"help")) {
656 "dpdk [device <id>] | worker\n");
666 .short_help =
"Show efd [device <id>] | [config]",
693 for (thread_id = 0; thread_id < tm->
n_vlib_mains; thread_id++) {
706 .short_help =
"Clear early-fast-discard counters",
713 char *prec_type,
u8 *prec_bitmap)
723 }
else if (
unformat(input,
"help")) {
725 "enter operation [ge | lt] and precedence <0-7>)");
732 if (
unformat (input,
"%u", &prec)) {
745 "EFD will be set for %s precedence %s%u%s.",
766 }
else if (
unformat(input,
"worker")) {
768 }
else if (
unformat(input,
"monitor")) {
771 }
else if (
unformat(input,
"drop_all")) {
773 }
else if (
unformat(input,
"default")) {
780 "worker | monitor | drop_all | default]");
782 }
else if (
unformat(input,
"disable")) {
785 }
else if (
unformat(input,
"worker")) {
787 }
else if (
unformat(input,
"monitor")) {
790 }
else if (
unformat(input,
"drop_all")) {
792 }
else if (
unformat(input,
"all")) {
797 "worker | monitor | drop_all | all]");
799 }
else if (
unformat(input,
"worker_queue_hi_thresh")) {
801 if (
unformat (input,
"%u", &mark)) {
807 }
else if (
unformat(input,
"dpdk_device_hi_thresh")) {
809 if (
unformat (input,
"%u", &thresh)) {
815 }
else if (
unformat(input,
"consec_full_frames_hi_thresh")) {
817 if (
unformat (input,
"%u", &thresh)) {
823 }
else if (
unformat(input,
"ip-prec")) {
826 }
else if (
unformat(input,
"mpls-exp")) {
829 }
else if (
unformat(input,
"vlan-cos")) {
832 }
else if (
unformat(input,
"help")) {
835 " set efd enable <dpdk | worker | monitor | drop_all | default> |\n" 836 " set efd disable <dpdk | worker | monitor | drop_all | all> |\n" 837 " set efd <ip-prec | mpls-exp | vlan-cos> <ge | lt> <0-7>\n" 838 " set efd worker_queue_hi_thresh <0-32> |\n" 839 " set efd dpdk_device_hi_thresh <0-%d> |\n" 840 " set efd consec_full_frames_hi_thresh <count> |\n",
852 .short_help =
"set early-fast-discard commands",
864 u32 hw_if_index = (
u32) ~0;
865 u32 nb_rx_desc = (
u32) ~0;
866 u32 nb_tx_desc = (
u32) ~0;
876 else if (
unformat (line_input,
"tx %d", &nb_tx_desc))
878 else if (
unformat (line_input,
"rx %d", &nb_rx_desc))
887 if (hw_if_index == (
u32) ~0)
897 if ((nb_rx_desc == (
u32) ~0 || nb_rx_desc == xd->
nb_rx_desc) &&
901 if (nb_rx_desc != (
u32) ~0)
904 if (nb_tx_desc != (
u32) ~0)
909 return rv < 0 ? rv : 0;
913 .path =
"set dpdk interface descriptors",
914 .short_help =
"set dpdk interface descriptors <if-name> [rx <n>] [tx <n>]",
948 .path =
"show dpdk interface placement",
949 .short_help =
"show dpdk interface placement",
980 u32 hw_if_index = (
u32) ~0;
992 else if (
unformat (line_input,
"queue %d", &queue))
994 else if (
unformat (line_input,
"thread %d", &cpu))
1003 if (hw_if_index == (
u32) ~0)
1006 if (cpu < dm->input_cpu_first_index ||
1038 VLIB_NODE_STATE_DISABLED);
1042 VLIB_NODE_STATE_POLLING);
1053 .path =
"set dpdk interface placement",
1054 .short_help =
"set dpdk interface placement <if-name> [queue <n>] thread <n>",
unformat_function_t unformat_vnet_hw_interface
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
always_inline vlib_thread_main_t * vlib_get_thread_main()
sll srl srl sll sra u16x4 i
static void show_dpdk_device_stats(vlib_main_t *vm, dpdk_device_t *xd)
static clib_error_t * test_frame_queue_nelts(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_dpdk_if_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_dpdk_if_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * show_frame_queue_trace(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static clib_error_t * parse_op_and_prec(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, char *prec_type, u8 *prec_bitmap)
vlib_buffer_main_t * buffer_main
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * show_dpdk_buffer(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_error_report(e)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static clib_error_t * trace_frame_queue(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * dpdk_port_setup(dpdk_main_t *dm, dpdk_device_t *xd)
static clib_error_t * test_frame_queue_threshold(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
int input_cpu_first_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
always_inline void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
static clib_error_t * show_frame_queue_histogram(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u32 compute_percent(u64 *two_counters, u64 total)
always_inline heap_elt_t * first(heap_header_t *h)
u16 consec_full_frames_hi_thresh
static clib_error_t * pcap_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_EFD_DISCARD_ENABLED
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
dpdk_device_and_queue_t ** devices_by_cpu
static clib_error_t * clear_efd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 consec_full_frames_cnt
#define DPDK_EFD_DISCARD_ENABLED
#define DPDK_EFD_MONITOR_ENABLED
#define vec_del1(v, i)
Delete the element at index I.
vlib_frame_queue_t ** vlib_frame_queues
frame_queue_nelt_counter_t * frame_queue_histogram
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u16 * cpu_socket_id_by_queue
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * test_dpdk_buffer(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int dpdk_device_queue_sort(void *a1, void *a2)
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
clib_error_t * pcap_write(pcap_main_t *pm)
static clib_error_t * set_dpdk_if_desc(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
#define EFD_OPERATION_GREATER_OR_EQUAL
vlib_worker_thread_t * vlib_worker_threads
u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
uword * thread_registrations_by_name
#define VLIB_EFD_MONITOR_ENABLED
#define DPDK_NB_RX_DESC_10GE
frame_queue_trace_t * frame_queue_traces
static clib_error_t * show_efd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
pcap_packet_type_t packet_type
static clib_error_t * set_efd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
dpdk_device_type_t dev_type
dpdk_efd_agent_t efd_agent
#define DPDK_EFD_DROPALL_ENABLED
void set_efd_bitmap(u8 *bitmap, u32 value, u32 op)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
#define hash_get_mem(h, key)
static clib_error_t * show_frame_queue_internal(vlib_main_t *vm, u32 histogram)
#define vec_foreach(var, vec)
Vector iterator.
#define EFD_OPERATION_LESS_THAN
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES
static void show_efd_config(vlib_main_t *vm)
vlib_main_t ** vlib_mains
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
clib_error_t * dpdk_cli_init(vlib_main_t *vm)