X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fdpdk%2Fdevice%2Fcli.c;h=77f9a27f97b6e2018b1dcb0d614b90f44b98f52e;hb=HEAD;hp=0f771c6ba77e6b52b36ffc3854d927a941e46d55;hpb=548d70de68a4156d5bd4148e50a81555a0ef169f;p=vpp.git diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c index 0f771c6ba77..77f9a27f97b 100644 --- a/src/plugins/dpdk/device/cli.c +++ b/src/plugins/dpdk/device/cli.c @@ -77,26 +77,30 @@ show_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input, * name="mbuf_pool_socket0" available = 15104 allocated = 1280 total = 16384 * @cliexend ?*/ -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (cmd_show_dpdk_buffer,static) = { .path = "show dpdk buffer", .short_help = "show dpdk buffer", .function = show_dpdk_buffer, .is_mp_safe = 1, }; -/* *INDENT-ON* */ static clib_error_t * show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { clib_error_t *err = 0; - u32 pipe_max_size; int fds[2]; u8 *s = 0; int n, n_try; FILE *f; + /* + * XXX: Pipes on FreeBSD grow dynamically up to 64KB (FreeBSD 15), don't + * manually tweak this value on FreeBSD at the moment. + */ +#ifdef __linux__ + u32 pipe_max_size; + err = clib_sysfs_read ("/proc/sys/fs/pipe-max-size", "%u", &pipe_max_size); if (err) @@ -114,6 +118,7 @@ show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input, err = clib_error_return_unix (0, "fcntl(F_SETPIPE_SZ)"); goto error; } +#endif /* __linux__ */ if (fcntl (fds[0], F_SETFL, O_NONBLOCK) == -1) { @@ -142,7 +147,7 @@ show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input, err = clib_error_return_unix (0, "read"); goto error; } - _vec_len (s) = len + (n < 0 ? 0 : n); + vec_set_len (s, len + (n < 0 ? 0 : n)); } vlib_cli_output (vm, "%v", s); @@ -162,14 +167,12 @@ error: * @cliexstart{show dpdk physmem} * @cliexend ?*/ -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (cmd_show_dpdk_physmem,static) = { .path = "show dpdk physmem", .short_help = "show dpdk physmem", .function = show_dpdk_physmem, .is_mp_safe = 1, }; -/* *INDENT-ON* */ static clib_error_t * test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input, @@ -198,7 +201,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input, first = vec_len (allocated_buffers) - n_free; vlib_buffer_free (vm, allocated_buffers + first, n_free); - _vec_len (allocated_buffers) = first; + vec_set_len (allocated_buffers, first); } if (n_alloc) { @@ -208,7 +211,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input, actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first, n_alloc); - _vec_len (allocated_buffers) = first + actual_alloc; + vec_set_len (allocated_buffers, first + actual_alloc); if (actual_alloc < n_alloc) vlib_cli_output (vm, "WARNING: only allocated %d buffers", @@ -250,14 +253,12 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input, * @cliexend * @endparblock ?*/ -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (cmd_test_dpdk_buffer,static) = { .path = "test dpdk buffer", .short_help = "test dpdk buffer [allocate ] [free ]", .function = test_dpdk_buffer, .is_mp_safe = 1, }; -/* *INDENT-ON* */ static clib_error_t * set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, @@ -265,6 +266,7 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, { unformat_input_t _line_input, *line_input = &_line_input; dpdk_main_t *dm = &dpdk_main; + vnet_main_t *vnm = vnet_get_main (); vnet_hw_interface_t *hw; dpdk_device_t *xd; u32 hw_if_index = (u32) ~ 0; @@ -277,9 +279,8 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { - if (unformat - (line_input, "%U", unformat_vnet_hw_interface, dm->vnet_main, - &hw_if_index)) + if (unformat (line_input, "%U", unformat_vnet_hw_interface, vnm, + &hw_if_index)) ; else if (unformat (line_input, "tx %d", &nb_tx_desc)) ; @@ -299,30 +300,21 @@ set_dpdk_if_desc (vlib_main_t * vm, unformat_input_t * input, goto done; } - hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index); + hw = vnet_get_hw_interface (vnm, hw_if_index); xd = vec_elt_at_index (dm->devices, hw->dev_instance); - if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0) - { - error = - clib_error_return (0, - "number of descriptors can be set only for " - "physical devices"); - goto done; - } - - if ((nb_rx_desc == (u32) ~ 0 || nb_rx_desc == xd->nb_rx_desc) && - (nb_tx_desc == (u32) ~ 0 || nb_tx_desc == xd->nb_tx_desc)) + if ((nb_rx_desc == (u32) ~0 || nb_rx_desc == xd->conf.n_rx_desc) && + (nb_tx_desc == (u32) ~0 || nb_tx_desc == xd->conf.n_tx_desc)) { error = clib_error_return (0, "nothing changed"); goto done; } if (nb_rx_desc != (u32) ~ 0) - xd->nb_rx_desc = nb_rx_desc; + xd->conf.n_rx_desc = nb_rx_desc; if (nb_tx_desc != (u32) ~ 0) - xd->nb_tx_desc = nb_tx_desc; + xd->conf.n_tx_desc = nb_tx_desc; dpdk_device_setup (xd); @@ -345,13 +337,11 @@ done: * Example of how to set the DPDK interface descriptors: * @cliexcmd{set dpdk interface descriptors GigabitEthernet0/8/0 rx 512 tx 512} ?*/ -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (cmd_set_dpdk_if_desc,static) = { .path = "set dpdk interface descriptors", .short_help = "set dpdk interface descriptors [rx ] [tx ]", .function = set_dpdk_if_desc, }; -/* *INDENT-ON* */ static clib_error_t * show_dpdk_version_command_fn (vlib_main_t * vm, @@ -373,16 +363,15 @@ show_dpdk_version_command_fn (vlib_main_t * vm, * Example of how to display how many DPDK buffer test command has allocated: * @cliexstart{show dpdk version} * DPDK Version: DPDK 16.11.0 - * DPDK EAL init args: -c 1 -n 4 --huge-dir /run/vpp/hugepages --file-prefix vpp -w 0000:00:08.0 -w 0000:00:09.0 --master-lcore 0 --socket-mem 256 + * DPDK EAL init args: --in-memory --no-telemetry --file-prefix vpp + * -w 0000:00:08.0 -w 0000:00:09.0 * @cliexend ?*/ -/* *INDENT-OFF* */ VLIB_CLI_COMMAND (show_vpe_version_command, static) = { .path = "show dpdk version", .short_help = "show dpdk version", .function = show_dpdk_version_command_fn, }; -/* *INDENT-ON* */ /* Dummy function to get us linked in. */ void