X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ethdev%2Frte_ethdev.c;h=c33d51e86b3b6a6cdbaf3a412c2fa43344803450;hb=ac7d3b6ddf87e1e0435de6d40cfe2749dc0ff9a4;hp=3578b87a1fe158fa283c900b45820522a42c3713;hpb=33c73aae32e4ec46d16ab6968b164682e648579a;p=dpdk.git diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 3578b87a1f..c33d51e86b 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -234,8 +234,8 @@ is_allocated(const struct rte_eth_dev *ethdev) return ethdev->data->name[0] != '\0'; } -struct rte_eth_dev * -rte_eth_dev_allocated(const char *name) +static struct rte_eth_dev * +_rte_eth_dev_allocated(const char *name) { unsigned i; @@ -247,6 +247,22 @@ rte_eth_dev_allocated(const char *name) return NULL; } +struct rte_eth_dev * +rte_eth_dev_allocated(const char *name) +{ + struct rte_eth_dev *ethdev; + + rte_eth_dev_shared_data_prepare(); + + rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); + + ethdev = _rte_eth_dev_allocated(name); + + rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); + + return ethdev; +} + static uint16_t rte_eth_dev_find_free_port(void) { @@ -293,7 +309,7 @@ rte_eth_dev_allocate(const char *name) goto unlock; } - if (rte_eth_dev_allocated(name) != NULL) { + if (_rte_eth_dev_allocated(name) != NULL) { ethdev_log(ERR, "Ethernet Device with name %s already allocated!", name);