55 unsigned count = rte_mempool_avail_count (rmp);
56 unsigned free_count = rte_mempool_in_use_count (rmp);
59 "name=\"%s\" available = %7d allocated = %7d total = %7d\n",
61 (
u32) (count + free_count));
82 .path =
"show dpdk buffer",
83 .short_help =
"show dpdk buffer",
100 err =
clib_sysfs_read (
"/proc/sys/fs/pipe-max-size",
"%u", &pipe_max_size);
105 if (pipe (fds) == -1)
109 #define F_SETPIPE_SZ (1024 + 7) 118 if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1)
124 if ((f = fdopen (fds[1],
"a")) == 0)
130 rte_dump_physmem_layout (f);
139 n = read (fds[0], s + len, n_try);
140 if (n < 0 && errno != EAGAIN)
145 _vec_len (s) = len + (n < 0 ? 0 : n);
167 .path =
"show dpdk physmem",
168 .short_help =
"show dpdk physmem",
178 static u32 *allocated_buffers;
185 if (
unformat (input,
"allocate %d", &n_alloc))
187 else if (
unformat (input,
"free %d", &n_free))
195 if (
vec_len (allocated_buffers) < n_free)
197 n_free,
vec_len (allocated_buffers));
199 first =
vec_len (allocated_buffers) - n_free;
201 _vec_len (allocated_buffers) =
first;
205 first =
vec_len (allocated_buffers);
207 vec_len (allocated_buffers) + n_alloc - 1);
211 _vec_len (allocated_buffers) = first + actual_alloc;
213 if (actual_alloc < n_alloc)
221 if (allocated_buffers &&
vec_len (allocated_buffers) == 0)
255 .path =
"test dpdk buffer",
256 .short_help =
"test dpdk buffer [allocate <nn>] [free <nn>]",
270 u32 hw_if_index = (
u32) ~ 0;
271 u32 nb_rx_desc = (
u32) ~ 0;
272 u32 nb_tx_desc = (
u32) ~ 0;
284 else if (
unformat (line_input,
"tx %d", &nb_tx_desc))
286 else if (
unformat (line_input,
"rx %d", &nb_rx_desc))
296 if (hw_if_index == (
u32) ~ 0)
305 if ((xd->
flags & DPDK_DEVICE_FLAG_PMD) == 0)
309 "number of descriptors can be set only for " 314 if ((nb_rx_desc == (
u32) ~ 0 || nb_rx_desc == xd->
nb_rx_desc) &&
321 if (nb_rx_desc != (
u32) ~ 0)
324 if (nb_tx_desc != (
u32) ~ 0)
350 .path =
"set dpdk interface descriptors",
351 .short_help =
"set dpdk interface descriptors <interface> [rx <nn>] [tx <nn>]",
361 #define _(a,b,c) vlib_cli_output (vm, "%-25s " b, a ":", c); 362 _(
"DPDK Version",
"%s", rte_version ());
381 .path =
"show dpdk version",
382 .short_help =
"show dpdk version",
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) ...
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vlib_buffer_main_t * buffer_main
void dpdk_cli_reference(void)
#define VLIB_INIT_FUNCTION(x)
dpdk_config_main_t dpdk_config_main
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
void dpdk_device_setup(dpdk_device_t *xd)
static heap_elt_t * first(heap_header_t *h)
static clib_error_t * show_dpdk_buffer(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_dpdk_if_desc(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_error_return_unix(e, args...)
vlib_buffer_pool_t * buffer_pools
clib_error_t * clib_sysfs_read(char *file_name, char *fmt,...)
static clib_error_t * show_dpdk_version_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector's memory (no header).
format_function_t format_dpdk_device_errors
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static clib_error_t * test_dpdk_buffer(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)
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * dpdk_cli_init(vlib_main_t *vm)
struct rte_mempool ** dpdk_mempool_by_buffer_pool_index
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
static clib_error_t * show_dpdk_physmem(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".