-static clib_error_t *
-set_dpdk_if_placement (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- dpdk_main_t *dm = &dpdk_main;
- dpdk_device_and_queue_t *dq;
- vnet_hw_interface_t *hw;
- dpdk_device_t *xd;
- u32 hw_if_index = (u32) ~ 0;
- u32 queue = (u32) 0;
- u32 cpu = (u32) ~ 0;
- int i;
- clib_error_t *error = NULL;
-
- if (!unformat_user (input, unformat_line_input, line_input))
- return 0;
-
- 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))
- ;
- else if (unformat (line_input, "queue %d", &queue))
- ;
- else if (unformat (line_input, "thread %d", &cpu))
- ;
- else
- {
- error = clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- goto done;
- }
- }
-
- if (hw_if_index == (u32) ~ 0)
- {
- error = clib_error_return (0, "please specify valid interface name");
- goto done;
- }
-
- if (cpu < dm->input_cpu_first_index ||
- cpu >= (dm->input_cpu_first_index + dm->input_cpu_count))
- {
- error = clib_error_return (0, "please specify valid thread id");
- goto done;
- }
-
- hw = vnet_get_hw_interface (dm->vnet_main, hw_if_index);
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- for (i = 0; i < vec_len (dm->devices_by_cpu); i++)
- {
- /* *INDENT-OFF* */
- vec_foreach(dq, dm->devices_by_cpu[i])
- {
- if (hw_if_index == dm->devices[dq->device].vlib_hw_if_index &&
- queue == dq->queue_id)
- {
- if (cpu == i) /* nothing to do */
- goto done;
-
- vec_del1(dm->devices_by_cpu[i], dq - dm->devices_by_cpu[i]);
- vec_add2(dm->devices_by_cpu[cpu], dq, 1);
- dq->queue_id = queue;
- dq->device = xd->device_index;
- xd->cpu_socket_id_by_queue[queue] =
- rte_lcore_to_socket_id(vlib_worker_threads[cpu].lcore_id);
-
- vec_sort_with_function(dm->devices_by_cpu[i],
- dpdk_device_queue_sort);
-
- vec_sort_with_function(dm->devices_by_cpu[cpu],
- dpdk_device_queue_sort);
-
- if (vec_len(dm->devices_by_cpu[i]) == 0)
- vlib_node_set_state (vlib_mains[i], dpdk_input_node.index,
- VLIB_NODE_STATE_DISABLED);
-
- if (vec_len(dm->devices_by_cpu[cpu]) == 1)
- vlib_node_set_state (vlib_mains[cpu], dpdk_input_node.index,
- VLIB_NODE_STATE_POLLING);
-
- goto done;
- }
- }
- /* *INDENT-ON* */
- }
-
- error = clib_error_return (0, "not found");
-
-done:
- unformat_free (line_input);
-
- return error;
-}
-
-/*?
- * This command is used to assign a given interface, and optionally a
- * given queue, to a different thread. This will not create a thread,
- * so the thread must already exist. Use '<em>/etc/vpp/startup.conf</em>'
- * for the initial thread creation. If the '<em>queue</em>' is not provided,
- * it defaults to 0.
- *
- * @cliexpar
- * Example of how to display the DPDK interface placement:
- * @cliexstart{show dpdk interface placement}
- * Thread 1 (vpp_wk_0 at lcore 1):
- * GigabitEthernet0/8/0 queue 0
- * GigabitEthernet0/9/0 queue 0
- * Thread 2 (vpp_wk_1 at lcore 2):
- * GigabitEthernet0/8/0 queue 1
- * GigabitEthernet0/9/0 queue 1
- * @cliexend
- * Example of how to assign a DPDK interface and queue to a thread:
- * @cliexcmd{set dpdk interface placement GigabitEthernet0/8/0 queue 1 thread 1}
-?*/
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (cmd_set_dpdk_if_placement,static) = {
- .path = "set dpdk interface placement",
- .short_help = "set dpdk interface placement <interface> [queue <n>] thread <n>",
- .function = set_dpdk_if_placement,
-};
-/* *INDENT-ON* */