aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Ratnikov <vratnikov@netgate.com>2021-01-28 11:08:35 -0500
committerMatthew Smith <mgsmith@netgate.com>2021-02-12 19:30:14 +0000
commit088bf1dcc32fcd26dac312a5561e0f263fa401d9 (patch)
treeaf8070c449399de0fb9ab0689882342c197d0a16
parentbbccdc583c91c21ee4caf9043845468cd758ca9f (diff)
dpdk: use whole vmbus address as hash key for devconf
u32[0] is not enough unique for some platforms like azure where several devices(not only network) can have almost the same addresses and this can cause collisions. Change hash to mhash type for vmbus devices with key of whole 16 bytes of vmbus address. Type: improvement Signed-off-by: Vladimir Ratnikov <vratnikov@netgate.com> Change-Id: Ic6c6a657ae29f45beddd0c69d8e785e702349460
-rw-r--r--src/plugins/dpdk/device/dpdk.h4
-rw-r--r--src/plugins/dpdk/device/init.c39
2 files changed, 22 insertions, 21 deletions
diff --git a/src/plugins/dpdk/device/dpdk.h b/src/plugins/dpdk/device/dpdk.h
index 3712015d438..be8c47b5128 100644
--- a/src/plugins/dpdk/device/dpdk.h
+++ b/src/plugins/dpdk/device/dpdk.h
@@ -317,12 +317,12 @@ typedef struct
dpdk_device_config_t default_devconf;
dpdk_device_config_t *dev_confs;
uword *device_config_index_by_pci_addr;
- uword *device_config_index_by_vmbus_addr;
+ mhash_t device_config_index_by_vmbus_addr;
/* devices blacklist by pci vendor_id, device_id */
u32 *blacklist_by_pci_vendor_and_device;
/* devices blacklist by VMBUS address */
- u32 *blacklist_by_vmbus_addr;
+ vlib_vmbus_addr_t *blacklist_by_vmbus_addr;
} dpdk_config_main_t;
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 8e4bf558a19..19d664a5778 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -291,8 +291,8 @@ dpdk_lib_init (dpdk_main_t * dm)
if (unformat (&input_vmbus, "%U", unformat_vlib_vmbus_addr,
&vmbus_addr))
{
- p = hash_get (dm->conf->device_config_index_by_vmbus_addr,
- vmbus_addr.as_u32[0]);
+ p = mhash_get (&dm->conf->device_config_index_by_vmbus_addr,
+ &vmbus_addr);
}
}
@@ -1062,15 +1062,15 @@ dpdk_bind_vmbus_devices_to_uio (dpdk_config_main_t * conf)
dpdk_device_config_t *devconf = 0;
if (num_whitelisted)
{
- uword *p = hash_get (conf->device_config_index_by_vmbus_addr,
- addr->as_u32[0]);
+ uword *p =
+ mhash_get (&conf->device_config_index_by_vmbus_addr, addr);
if (!p)
{
/* No devices blacklisted, but have whitelisted. blacklist all
* non-whitelisted */
pool_get (conf->dev_confs, devconf);
- hash_set (conf->device_config_index_by_vmbus_addr,
- addr->as_u32[0], devconf - conf->dev_confs);
+ mhash_set (&conf->device_config_index_by_vmbus_addr, addr,
+ devconf - conf->dev_confs, 0);
devconf->vmbus_addr = *addr;
devconf->dev_addr_type = VNET_DEV_ADDR_VMBUS;
devconf->is_blacklisted = 1;
@@ -1084,15 +1084,16 @@ dpdk_bind_vmbus_devices_to_uio (dpdk_config_main_t * conf)
/* Enforce Device blacklist by vmbus_addr */
for (i = 0; i < vec_len (conf->blacklist_by_vmbus_addr); i++)
{
- u32 vmbus_as_u32 = conf->blacklist_by_vmbus_addr[i];
- if (vmbus_as_u32 == addr->as_u32[0])
+ vlib_vmbus_addr_t *a1 = &conf->blacklist_by_vmbus_addr[i];
+ vlib_vmbus_addr_t *a2 = addr;
+ if (memcmp (a1, a2, sizeof (vlib_vmbus_addr_t)) == 0)
{
if (devconf == 0)
{
/* Device not whitelisted */
pool_get (conf->dev_confs, devconf);
- hash_set (conf->device_config_index_by_vmbus_addr,
- addr->as_u32[0], devconf - conf->dev_confs);
+ mhash_set (&conf->device_config_index_by_vmbus_addr, addr,
+ devconf - conf->dev_confs, 0);
devconf->vmbus_addr = *addr;
devconf->dev_addr_type = VNET_DEV_ADDR_VMBUS;
devconf->is_blacklisted = 1;
@@ -1111,8 +1112,8 @@ dpdk_bind_vmbus_devices_to_uio (dpdk_config_main_t * conf)
if (devconf == 0)
{
pool_get (conf->dev_confs, devconf);
- hash_set (conf->device_config_index_by_vmbus_addr,
- addr->as_u32[0], devconf - conf->dev_confs);
+ mhash_set (&conf->device_config_index_by_vmbus_addr, addr,
+ devconf - conf->dev_confs, 0);
devconf->vmbus_addr = *addr;
}
devconf->dev_addr_type = VNET_DEV_ADDR_VMBUS;
@@ -1156,15 +1157,14 @@ dpdk_device_config (dpdk_config_main_t *conf, void *addr,
}
else if (addr_type == VNET_DEV_ADDR_VMBUS)
{
- p = hash_get (conf->device_config_index_by_vmbus_addr,
- ((vlib_vmbus_addr_t *) (addr))->as_u32[0]);
+ p = mhash_get (&conf->device_config_index_by_vmbus_addr,
+ (vlib_vmbus_addr_t *) (addr));
if (!p)
{
pool_get (conf->dev_confs, devconf);
- hash_set (conf->device_config_index_by_vmbus_addr,
- ((vlib_vmbus_addr_t *) (addr))->as_u32[0],
- devconf - conf->dev_confs);
+ mhash_set (&conf->device_config_index_by_vmbus_addr, addr,
+ devconf - conf->dev_confs, 0);
}
else
return clib_error_return (
@@ -1310,7 +1310,8 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
format (0, "%s/hugepages%c", vlib_unix_get_runtime_dir (), 0);
conf->device_config_index_by_pci_addr = hash_create (0, sizeof (uword));
- conf->device_config_index_by_vmbus_addr = hash_create (0, sizeof (uword));
+ mhash_init (&conf->device_config_index_by_vmbus_addr, sizeof (uword),
+ sizeof (vlib_vmbus_addr_t));
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@ -1407,7 +1408,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
else if (unformat (input, "blacklist %U", unformat_vlib_vmbus_addr,
&vmbus_addr))
{
- vec_add1 (conf->blacklist_by_vmbus_addr, vmbus_addr.as_u32[0]);
+ vec_add1 (conf->blacklist_by_vmbus_addr, vmbus_addr);
}
else
if (unformat