#define DBG_SOCK(args...)
#endif
-static const char *vhost_message_str[] = {
+static const char *vhost_message_str[] __attribute__((unused)) = {
[VHOST_USER_NONE] = "VHOST_USER_NONE",
[VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES",
[VHOST_USER_SET_FEATURES] = "VHOST_USER_SET_FEATURES",
}
static clib_error_t *
-dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id)
+dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id, u8 *hwaddr)
{
dpdk_main_t * dm = &dpdk_main;
vlib_main_t * vm = vlib_get_main();
}
// reset lockp
- if (xd->lockp)
- memset ((void *) xd->lockp, 0, CLIB_CACHE_LINE_BYTES);
+ dpdk_device_lock_free(xd);
+
+ if (xd->tx_q_used < tm->n_vlib_mains)
+ dpdk_device_lock_init(xd);
// reset tx vectors
for (j = 0; j < tm->n_vlib_mains; j++)
xd->vu_vhost_dev.virtqueue[j]->backend = -1;
}
- xd->lockp = NULL;
- if (xd->tx_q_used < dm->input_cpu_count) {
- xd->lockp = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES,
- CLIB_CACHE_LINE_BYTES);
- memset ((void *) xd->lockp, 0, CLIB_CACHE_LINE_BYTES);
- }
+ if (xd->tx_q_used < dm->input_cpu_count)
+ dpdk_device_lock_init(xd);
DBG_SOCK("tm->n_vlib_mains: %d. TX %d, RX: %d, num_qpairs: %d, Lock: %p",
tm->n_vlib_mains, xd->tx_q_used, xd->rx_q_used, num_qpairs, xd->lockp);
/*
* Generate random MAC address for the interface
*/
+ if (hwaddr) {
+ memcpy(addr, hwaddr, sizeof(addr));
+ } else {
f64 now = vlib_time_now(vm);
u32 rnd;
rnd = (u32) (now * 1e6);
memcpy (addr+2, &rnd, sizeof(rnd));
addr[0] = 2;
addr[1] = 0xfe;
+ }
error = ethernet_register_interface
(dm->vnet_main,
u8 is_server,
u32 * sw_if_index,
u64 feature_mask,
- u8 renumber, u32 custom_dev_instance)
+ u8 renumber, u32 custom_dev_instance,
+ u8 *hwaddr)
{
dpdk_main_t * dm = &dpdk_main;
dpdk_device_t *xd;
// using virtio vhost user?
if (dm->use_virtio_vhost) {
return vhost_user_create_if(vnm, vm, sock_filename, is_server,
- sw_if_index, feature_mask, renumber, custom_dev_instance);
+ sw_if_index, feature_mask, renumber, custom_dev_instance, hwaddr);
}
if (is_server) {
if (custom_dev_instance >= dm->next_vu_if_id)
dm->next_vu_if_id = custom_dev_instance + 1;
- dpdk_create_vhost_user_if_internal(&hw_if_idx, custom_dev_instance);
+ dpdk_create_vhost_user_if_internal(&hw_if_idx, custom_dev_instance, hwaddr);
} else
- dpdk_create_vhost_user_if_internal(&hw_if_idx, (u32)~0);
+ dpdk_create_vhost_user_if_internal(&hw_if_idx, (u32)~0, hwaddr);
DBG_SOCK("dpdk vhost-user interface created hw_if_index %d", hw_if_idx);
xd = dpdk_vhost_user_device_from_hw_if_index(hw_if_idx);
u64 feature_mask = (u64)~0;
u8 renumber = 0;
u32 custom_dev_instance = ~0;
+ u8 hwaddr[6];
+ u8 *hw = NULL;
if (dm->use_virtio_vhost) {
return vhost_user_connect_command_fn(vm, input, cmd);
is_server = 1;
else if (unformat (line_input, "feature-mask 0x%llx", &feature_mask))
;
+ else if (unformat (line_input, "hwaddr %U", unformat_ethernet_address, hwaddr))
+ hw = hwaddr;
else if (unformat (line_input, "renumber %d", &custom_dev_instance)) {
renumber = 1;
}
dpdk_vhost_user_create_if(vnm, vm, (char *)sock_filename,
is_server, &sw_if_index, feature_mask,
- renumber, custom_dev_instance);
+ renumber, custom_dev_instance, hw);
vec_free(sock_filename);
return 0;
.short_help = "show vhost-user interface",
.function = show_dpdk_vhost_user_command_fn,
};
-