89 else if (
unformat (input,
"max %d", &max))
95 else if (
unformat (input,
"intfc %U",
99 else if (
unformat (input,
"intfc any"))
104 else if (
unformat (input,
"file %s", &filename))
108 if (strstr ((
char *) filename,
"..")
109 || index ((
char *) filename,
'/'))
116 chroot_filename =
format (0,
"/tmp/%s%c", filename, 0);
125 else if (
unformat (input,
"status"))
152 .path =
"pcap tx trace",
154 "pcap tx trace on off max <nn> intfc <intfc> file <name> status",
164 struct rte_mempool *rmp;
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",
178 (
u32) (count + free_count));
190 .path =
"show dpdk buffer",
191 .short_help =
"show dpdk buffer state",
201 static u32 *allocated_buffers;
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)
220 n_free,
vec_len (allocated_buffers));
222 first =
vec_len (allocated_buffers) - n_free;
224 _vec_len (allocated_buffers) =
first;
228 first =
vec_len (allocated_buffers);
230 vec_len (allocated_buffers) + n_alloc - 1);
234 _vec_len (allocated_buffers) = first + actual_alloc;
236 if (actual_alloc < n_alloc)
244 if (allocated_buffers &&
vec_len (allocated_buffers) == 0)
252 .path =
"test dpdk buffer",
253 .short_help =
"test dpdk buffer [allocate <nn>][free <nn>]",
267 u32 hw_if_index = (
u32) ~ 0;
268 u32 nb_rx_desc = (
u32) ~ 0;
269 u32 nb_tx_desc = (
u32) ~ 0;
281 else if (
unformat (line_input,
"tx %d", &nb_tx_desc))
283 else if (
unformat (line_input,
"rx %d", &nb_rx_desc))
292 if (hw_if_index == (
u32) ~ 0)
302 if ((nb_rx_desc == (
u32) ~ 0 || nb_rx_desc == xd->
nb_rx_desc) &&
306 if (nb_rx_desc != (
u32) ~ 0)
309 if (nb_tx_desc != (
u32) ~ 0)
319 .path =
"set dpdk interface descriptors",
320 .short_help =
"set dpdk interface descriptors <if-name> [rx <n>] [tx <n>]",
358 .path =
"show dpdk interface placement",
359 .short_help =
"show dpdk interface placement",
391 u32 hw_if_index = (
u32) ~ 0;
405 else if (
unformat (line_input,
"queue %d", &queue))
407 else if (
unformat (line_input,
"thread %d", &cpu))
416 if (hw_if_index == (
u32) ~ 0)
419 if (cpu < dm->input_cpu_first_index ||
452 VLIB_NODE_STATE_DISABLED);
456 VLIB_NODE_STATE_POLLING);
469 .path =
"set dpdk interface placement",
470 .short_help =
"set dpdk interface placement <if-name> [queue <n>] thread <n>",
507 .path =
"show dpdk interface hqos placement",
508 .short_help =
"show dpdk interface hqos placement",
522 u32 hw_if_index = (
u32) ~ 0;
535 else if (
unformat (line_input,
"thread %d", &cpu))
544 if (hw_if_index == (
u32) ~ 0)
547 if (cpu < dm->hqos_cpu_first_index ||
585 .path =
"set dpdk interface hqos placement",
586 .short_help =
"set dpdk interface hqos placement <if-name> thread <n>",
599 u32 hw_if_index = (
u32) ~ 0;
600 u32 subport_id = (
u32) ~ 0;
602 u32 profile_id = (
u32) ~ 0;
614 else if (
unformat (line_input,
"subport %d", &subport_id))
616 else if (
unformat (line_input,
"pipe %d", &pipe_id))
618 else if (
unformat (line_input,
"profile %d", &profile_id))
627 if (hw_if_index == (
u32) ~ 0)
634 rte_sched_pipe_config (xd->
hqos_ht->
hqos, subport_id, pipe_id,
645 .path =
"set dpdk interface hqos pipe",
646 .short_help =
"set dpdk interface hqos pipe <if-name> subport <n> pipe <n> " 660 u32 hw_if_index = (
u32) ~ 0;
661 u32 subport_id = (
u32) ~ 0;
662 struct rte_sched_subport_params p = {
663 .tb_rate = 1250000000,
665 .tc_rate = {1250000000, 1250000000, 1250000000, 1250000000},
679 else if (
unformat (line_input,
"subport %d", &subport_id))
681 else if (
unformat (line_input,
"rate %d", &p.tb_rate))
683 p.tc_rate[0] = p.tb_rate;
684 p.tc_rate[1] = p.tb_rate;
685 p.tc_rate[2] = p.tb_rate;
686 p.tc_rate[3] = p.tb_rate;
688 else if (
unformat (line_input,
"bktsize %d", &p.tb_size))
690 else if (
unformat (line_input,
"tc0 %d", &p.tc_rate[0]))
692 else if (
unformat (line_input,
"tc1 %d", &p.tc_rate[1]))
694 else if (
unformat (line_input,
"tc2 %d", &p.tc_rate[2]))
696 else if (
unformat (line_input,
"tc3 %d", &p.tc_rate[3]))
698 else if (
unformat (line_input,
"period %d", &p.tc_period))
707 if (hw_if_index == (
u32) ~ 0)
713 rv = rte_sched_subport_config (xd->
hqos_ht->
hqos, subport_id, &p);
722 .path =
"set dpdk interface hqos subport",
723 .short_help =
"set dpdk interface hqos subport <if-name> subport <n> " 724 "[rate <n>] [bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] " 739 u32 hw_if_index = (
u32) ~ 0;
754 else if (
unformat (line_input,
"entry %d", &entry))
756 else if (
unformat (line_input,
"tc %d", &tc))
758 else if (
unformat (line_input,
"queue %d", &queue))
767 if (hw_if_index == (
u32) ~ 0)
771 if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
773 if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
787 int worker_thread_count = tr->
count;
789 val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
790 for (i = 0; i < worker_thread_count; i++)
798 .path =
"set dpdk interface hqos tctbl",
799 .short_help =
"set dpdk interface hqos tctbl <if-name> entry <n> tc <n> queue <n>",
813 struct rte_eth_dev_info dev_info;
817 u32 hw_if_index = (
u32) ~ 0;
827 int worker_thread_count = tr->
count;
835 u32 n_subports_per_port, n_pipes_per_subport, tctbl_size;
849 else if (
unformat (line_input,
"id %d", &
id))
851 else if (
unformat (line_input,
"offset %d", &offset))
853 else if (
unformat (line_input,
"mask %llx", &mask))
863 if (hw_if_index == (
u32) ~ 0)
870 if (dev_info.pci_dev)
872 vlib_pci_addr_t pci_addr;
874 pci_addr.domain = dev_info.pci_dev->addr.domain;
875 pci_addr.bus = dev_info.pci_dev->addr.bus;
876 pci_addr.slot = dev_info.pci_dev->addr.devid;
877 pci_addr.function = dev_info.pci_dev->addr.function;
888 if (devconf->hqos_enabled == 0)
894 n_subports_per_port = devconf->hqos.port.n_subports_per_port;
895 n_pipes_per_subport = devconf->hqos.port.n_pipes_per_subport;
896 tctbl_size = RTE_DIM (devconf->hqos.tc_table);
907 "(n_subports_per_port = %u)",
908 n_subports_per_port);
913 "(n_pipes_per_subport = %u)",
914 n_pipes_per_subport);
920 "(TC table size = %u)", tctbl_size);
924 for (i = 0; i < worker_thread_count; i++)
931 __builtin_ctzll (mask);
937 __builtin_ctzll (mask);
944 __builtin_ctzll (mask);
952 .path =
"set dpdk interface hqos pktfield",
953 .short_help =
"set dpdk interface hqos pktfield <if-name> id <n> offset <n> " 972 u32 hw_if_index = (
u32) ~ 0;
974 struct rte_eth_dev_info dev_info;
995 if (hw_if_index == (
u32) ~ 0)
1002 if (dev_info.pci_dev)
1004 vlib_pci_addr_t pci_addr;
1006 pci_addr.domain = dev_info.pci_dev->addr.domain;
1007 pci_addr.bus = dev_info.pci_dev->addr.bus;
1008 pci_addr.slot = dev_info.pci_dev->addr.devid;
1009 pci_addr.function = dev_info.pci_dev->addr.function;
1020 if (devconf->hqos_enabled == 0)
1035 cfg = &devconf->hqos;
1048 " Packet field 0: slab position = %4u, slab bitmask = 0x%016llx",
1051 " Packet field 1: slab position = %4u, slab bitmask = 0x%016llx",
1054 " Packet field 2: slab position = %4u, slab bitmask = 0x%016llx",
1058 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1059 tctbl[0], tctbl[1], tctbl[2], tctbl[3],
1060 tctbl[4], tctbl[5], tctbl[6], tctbl[7],
1061 tctbl[8], tctbl[9], tctbl[10], tctbl[11],
1062 tctbl[12], tctbl[13], tctbl[14], tctbl[15]);
1064 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1065 tctbl[16], tctbl[17], tctbl[18], tctbl[19],
1066 tctbl[20], tctbl[21], tctbl[22], tctbl[23],
1067 tctbl[24], tctbl[25], tctbl[26], tctbl[27],
1068 tctbl[28], tctbl[29], tctbl[30], tctbl[31]);
1070 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1071 tctbl[32], tctbl[33], tctbl[34], tctbl[35],
1072 tctbl[36], tctbl[37], tctbl[38], tctbl[39],
1073 tctbl[40], tctbl[41], tctbl[42], tctbl[43],
1074 tctbl[44], tctbl[45], tctbl[46], tctbl[47]);
1076 "%2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u %2u",
1077 tctbl[48], tctbl[49], tctbl[50], tctbl[51],
1078 tctbl[52], tctbl[53], tctbl[54], tctbl[55],
1079 tctbl[56], tctbl[57], tctbl[58], tctbl[59],
1080 tctbl[60], tctbl[61], tctbl[62], tctbl[63]);
1086 cfg->
port.frame_overhead);
1088 cfg->
port.n_subports_per_port);
1090 cfg->
port.n_pipes_per_subport);
1092 " Packet queue size: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u packets",
1093 cfg->
port.qsize[0], cfg->
port.qsize[1], cfg->
port.qsize[2],
1094 cfg->
port.qsize[3]);
1096 cfg->
port.n_pipe_profiles);
1098 for (profile_id = 0; profile_id <
vec_len (cfg->
pipe); profile_id++)
1102 cfg->
pipe[profile_id].tb_rate);
1104 cfg->
pipe[profile_id].tb_size);
1106 " Traffic class rate: TC0 = %u, TC1 = %u, TC2 = %u, TC3 = %u bytes/second",
1107 cfg->
pipe[profile_id].tc_rate[0],
1108 cfg->
pipe[profile_id].tc_rate[1],
1109 cfg->
pipe[profile_id].tc_rate[2],
1110 cfg->
pipe[profile_id].tc_rate[3]);
1112 cfg->
pipe[profile_id].tc_period);
1113 #ifdef RTE_SCHED_SUBPORT_TC_OV 1115 cfg->
pipe[profile_id].tc_ov_weight);
1118 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1121 " TC%u WRR weights: Q0 = %u, Q1 = %u, Q2 = %u, Q3 = %u",
1122 i, cfg->
pipe[profile_id].wrr_weights[i * 4],
1123 cfg->
pipe[profile_id].wrr_weights[i * 4 + 1],
1124 cfg->
pipe[profile_id].wrr_weights[i * 4 + 2],
1125 cfg->
pipe[profile_id].wrr_weights[i * 4 + 3]);
1129 #ifdef RTE_SCHED_RED 1131 for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++)
1134 cfg->
port.red_params[i][e_RTE_METER_GREEN].min_th,
1135 cfg->
port.red_params[i][e_RTE_METER_YELLOW].min_th,
1136 cfg->
port.red_params[i][e_RTE_METER_RED].min_th);
1139 cfg->
port.red_params[i][e_RTE_METER_GREEN].max_th,
1140 cfg->
port.red_params[i][e_RTE_METER_YELLOW].max_th,
1141 cfg->
port.red_params[i][e_RTE_METER_RED].max_th);
1144 " TC%u inverted probability: G = %u, Y = %u, R = %u",
1145 i, cfg->
port.red_params[i][e_RTE_METER_GREEN].maxp_inv,
1146 cfg->
port.red_params[i][e_RTE_METER_YELLOW].maxp_inv,
1147 cfg->
port.red_params[i][e_RTE_METER_RED].maxp_inv);
1150 cfg->
port.red_params[i][e_RTE_METER_GREEN].wq_log2,
1151 cfg->
port.red_params[i][e_RTE_METER_YELLOW].wq_log2,
1152 cfg->
port.red_params[i][e_RTE_METER_RED].wq_log2);
1161 .path =
"show dpdk interface hqos",
1162 .short_help =
"show dpdk interface hqos <if-name>",
1174 u32 hw_if_index = (
u32) ~ 0;
1182 struct rte_eth_dev_info dev_info;
1185 struct rte_sched_queue_stats stats;
1198 else if (
unformat (line_input,
"subport %d", &subport))
1201 else if (
unformat (line_input,
"pipe %d", &pipe))
1204 else if (
unformat (line_input,
"tc %d", &tc))
1207 else if (
unformat (line_input,
"tc_q %d", &tc_q))
1217 if (hw_if_index == (
u32) ~ 0)
1224 if (dev_info.pci_dev)
1226 vlib_pci_addr_t pci_addr;
1228 pci_addr.domain = dev_info.pci_dev->addr.domain;
1229 pci_addr.bus = dev_info.pci_dev->addr.bus;
1230 pci_addr.slot = dev_info.pci_dev->addr.devid;
1231 pci_addr.function = dev_info.pci_dev->addr.function;
1242 if (devconf->hqos_enabled == 0)
1252 qindex = subport * devconf->hqos.port.n_pipes_per_subport + pipe;
1253 qindex = qindex * RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE + tc;
1254 qindex = qindex * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + tc_q;
1256 if (rte_sched_queue_read_stats (xd->
hqos_ht->
hqos, qindex, &stats, &qlen) !=
1262 vlib_cli_output (vm,
"%=24s%=16d",
"Packets dropped", stats.n_pkts_dropped);
1263 #ifdef RTE_SCHED_RED 1265 stats.n_pkts_red_dropped);
1268 vlib_cli_output (vm,
"%=24s%=16d",
"Bytes dropped", stats.n_bytes_dropped);
1276 .path =
"show dpdk hqos queue",
1277 .short_help =
"show dpdk hqos queue <if-name> subport <subport> pipe <pipe> tc <tc> tc_q <tc_q>",
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) ...
char * file_name
File name of pcap output.
sll srl srl sll sra u16x4 i
static clib_error_t * show_dpdk_hqos_queue_stats(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 n_packets_to_capture
Number of packets to capture.
static clib_error_t * show_dpdk_if_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int dpdk_hqos_validate_mask(u64 mask, u32 n)
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 * set_dpdk_if_hqos_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
dpdk_device_and_queue_t ** devices_by_hqos_cpu
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
struct rte_sched_port_params port
vlib_buffer_main_t * buffer_main
struct rte_sched_port * hqos
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 DPDK_DEVICE_FLAG_PMD
clib_error_t * dpdk_port_setup(dpdk_main_t *dm, dpdk_device_t *xd)
struct rte_sched_pipe_params * pipe
#define VLIB_INIT_FUNCTION(x)
vlib_node_registration_t dpdk_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_input_node)
dpdk_device_config_t default_devconf
int input_cpu_first_index
static clib_error_t * set_dpdk_if_hqos_subport(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static clib_error_t * show_dpdk_if_hqos(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
dpdk_device_hqos_per_worker_thread_t * hqos_wt
static heap_elt_t * first(heap_header_t *h)
static clib_error_t * pcap_trace_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_worker_thread_t * vlib_worker_threads
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
dpdk_device_and_queue_t ** devices_by_cpu
static clib_error_t * set_dpdk_if_hqos_pipe(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_del1(v, i)
Delete the element at index I.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * set_dpdk_if_hqos_pktfield(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
struct rte_mempool ** pktmbuf_pools
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)
dpdk_device_config_t * dev_confs
static vlib_thread_main_t * vlib_get_thread_main()
static int dpdk_device_queue_sort(void *a1, void *a2)
clib_error_t * pcap_write(pcap_main_t *pm)
Write PCAP file.
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,...)
static clib_error_t * show_dpdk_if_hqos_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static clib_error_t * set_dpdk_if_hqos_tctbl(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
dpdk_device_hqos_per_hqos_thread_t * hqos_ht
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
uword * thread_registrations_by_name
u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
template key/value backing page structure
pcap_packet_type_t packet_type
Packet type.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
vlib_main_t ** vlib_mains
#define hash_get_mem(h, key)
struct clib_bihash_value offset
template key/value backing page structure
#define vec_foreach(var, vec)
Vector iterator.
#define clib_error_return(e, args...)
uword * device_config_index_by_pci_addr
u32 n_packets_captured
Number of packets currently captured.
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
clib_error_t * dpdk_cli_init(vlib_main_t *vm)
dpdk_config_main_t * conf