diff options
Diffstat (limited to 'vnet/vnet/devices/dpdk/vhost_user.c')
-rw-r--r-- | vnet/vnet/devices/dpdk/vhost_user.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/vnet/vnet/devices/dpdk/vhost_user.c b/vnet/vnet/devices/dpdk/vhost_user.c index 0965456e0f9..a9b2082b4d4 100644 --- a/vnet/vnet/devices/dpdk/vhost_user.c +++ b/vnet/vnet/devices/dpdk/vhost_user.c @@ -187,7 +187,7 @@ static inline void * map_guest_mem(dpdk_device_t * xd, u64 addr) } 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(); @@ -332,6 +332,9 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id) /* * 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); @@ -340,6 +343,7 @@ dpdk_create_vhost_user_if_internal (u32 * hw_if_index, u32 if_id) memcpy (addr+2, &rnd, sizeof(rnd)); addr[0] = 2; addr[1] = 0xfe; + } error = ethernet_register_interface (dm->vnet_main, @@ -1275,7 +1279,8 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm, 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; @@ -1286,7 +1291,7 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm, // 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) { @@ -1300,9 +1305,9 @@ int dpdk_vhost_user_create_if(vnet_main_t * vnm, vlib_main_t * vm, 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); @@ -1548,6 +1553,8 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm, 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); @@ -1564,6 +1571,8 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm, 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; } @@ -1579,7 +1588,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm, 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; |