diff options
Diffstat (limited to 'lib/librte_eal')
-rw-r--r-- | lib/librte_eal/bsdapp/eal/eal.c | 6 | ||||
-rw-r--r-- | lib/librte_eal/common/eal_common_dev.c | 12 | ||||
-rw-r--r-- | lib/librte_eal/common/eal_common_proc.c | 34 | ||||
-rw-r--r-- | lib/librte_eal/common/hotplug_mp.c | 43 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_bitmap.h | 45 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_common.h | 32 | ||||
-rw-r--r-- | lib/librte_eal/common/include/rte_version.h | 4 | ||||
-rw-r--r-- | lib/librte_eal/linuxapp/eal/eal_memory.c | 2 |
8 files changed, 78 insertions, 100 deletions
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 508cbc46..b8152a75 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -556,9 +556,11 @@ int rte_eal_has_hugepages(void) int rte_eal_iopl_init(void) { - static int fd; + static int fd = -1; + + if (fd < 0) + fd = open("/dev/io", O_RDWR); - fd = open("/dev/io", O_RDWR); if (fd < 0) return -1; /* keep fd open for iopl */ diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 1fdc9ab1..fd7f5ca7 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -166,18 +166,20 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) ret = -ENODEV; goto err_devarg; } + /* Since there is a matching device, it is now its responsibility + * to manage the devargs we've just inserted. From this point + * those devargs shouldn't be removed manually anymore. + */ ret = dev->bus->plug(dev); - if (ret) { - if (rte_dev_is_probed(dev)) /* if already succeeded earlier */ - return ret; /* no rollback */ + if (ret && !rte_dev_is_probed(dev)) { /* if hasn't ever succeeded */ RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); - goto err_devarg; + return ret; } *new_dev = dev; - return 0; + return ret; err_devarg: if (rte_devargs_remove(da) != 0) { diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index f65ef56c..1c3f09aa 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -827,28 +827,6 @@ mp_request_async(const char *dst, struct rte_mp_msg *req, goto fail; } - /* - * set the alarm before sending message. there are two possible error - * scenarios to consider here: - * - * - if the alarm set fails, we free the memory right there - * - if the alarm set succeeds but sending message fails, then the alarm - * will trigger and clean up the memory - * - * Even if the alarm triggers too early (i.e. immediately), we're still - * holding the lock to pending requests queue, so the interrupt thread - * will just spin until we release the lock, and either release the - * memory, or doesn't find any pending requests in the queue because we - * never added any due to send message failure. - */ - if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000, - async_reply_handle, pending_req) < 0) { - RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n", - dst, req->name); - ret = -1; - goto fail; - } - ret = send_msg(dst, req, MP_REQ); if (ret < 0) { RTE_LOG(ERR, EAL, "Fail to send request %s:%s\n", @@ -859,10 +837,18 @@ mp_request_async(const char *dst, struct rte_mp_msg *req, ret = 0; goto fail; } - TAILQ_INSERT_TAIL(&pending_requests.requests, pending_req, next); - param->user_reply.nb_sent++; + /* if alarm set fails, we simply ignore the reply */ + if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000, + async_reply_handle, pending_req) < 0) { + RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n", + dst, req->name); + ret = -1; + goto fail; + } + TAILQ_INSERT_TAIL(&pending_requests.requests, pending_req, next); + return 0; fail: free(pending_req); diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 7c9fcc46..070e2e0c 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -87,7 +87,7 @@ __handle_secondary_request(void *param) const struct eal_dev_mp_req *req = (const struct eal_dev_mp_req *)msg->param; struct eal_dev_mp_req tmp_req; - struct rte_devargs *da; + struct rte_devargs da; struct rte_device *dev; struct rte_bus *bus; int ret = 0; @@ -114,15 +114,11 @@ __handle_secondary_request(void *param) goto rollback; } } else if (req->t == EAL_DEV_REQ_TYPE_DETACH) { - da = calloc(1, sizeof(*da)); - if (da == NULL) { - ret = -ENOMEM; - goto finish; - } - - ret = rte_devargs_parse(da, req->devargs); + ret = rte_devargs_parse(&da, req->devargs); if (ret != 0) goto finish; + free(da.args); /* we don't need those */ + da.args = NULL; ret = eal_dev_hotplug_request_to_secondary(&tmp_req); if (ret != 0) { @@ -131,16 +127,16 @@ __handle_secondary_request(void *param) goto rollback; } - bus = rte_bus_find_by_name(da->bus->name); + bus = rte_bus_find_by_name(da.bus->name); if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da->bus->name); + RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da.bus->name); ret = -ENOENT; goto finish; } - dev = bus->find_device(NULL, cmp_dev_name, da->name); + dev = bus->find_device(NULL, cmp_dev_name, da.name); if (dev == NULL) { - RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da->name); + RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da.name); ret = -ENOENT; goto finish; } @@ -264,6 +260,19 @@ static void __handle_primary_request(void *param) goto quit; } + if (!rte_dev_is_probed(dev)) { + if (req->t == EAL_DEV_REQ_TYPE_ATTACH_ROLLBACK) { + /** + * Don't fail the rollback just because there's + * nothing to do. + */ + ret = 0; + } else + ret = -ENODEV; + + goto quit; + } + ret = local_dev_remove(dev); quit: free(da->args); @@ -391,13 +400,13 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) struct eal_dev_mp_req *resp = (struct eal_dev_mp_req *)mp_reply.msgs[i].param; if (resp->result != 0) { - req->result = resp->result; if (req->t == EAL_DEV_REQ_TYPE_ATTACH && - req->result != -EEXIST) - break; + resp->result == -EEXIST) + continue; if (req->t == EAL_DEV_REQ_TYPE_DETACH && - req->result != -ENOENT) - break; + resp->result == -ENOENT) + continue; + req->result = resp->result; } } diff --git a/lib/librte_eal/common/include/rte_bitmap.h b/lib/librte_eal/common/include/rte_bitmap.h index 7a36ce73..77727c82 100644 --- a/lib/librte_eal/common/include/rte_bitmap.h +++ b/lib/librte_eal/common/include/rte_bitmap.h @@ -43,10 +43,6 @@ extern "C" { #include <rte_branch_prediction.h> #include <rte_prefetch.h> -#ifndef RTE_BITMAP_OPTIMIZATIONS -#define RTE_BITMAP_OPTIMIZATIONS 1 -#endif - /* Slab */ #define RTE_BITMAP_SLAB_BIT_SIZE 64 #define RTE_BITMAP_SLAB_BIT_SIZE_LOG2 6 @@ -97,43 +93,12 @@ __rte_bitmap_index2_set(struct rte_bitmap *bmp) bmp->index2 = (((bmp->index1 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2) + bmp->offset1) << RTE_BITMAP_CL_SLAB_SIZE_LOG2); } -#if RTE_BITMAP_OPTIMIZATIONS - -static inline int +static inline int __rte_deprecated rte_bsf64(uint64_t slab, uint32_t *pos) { - if (likely(slab == 0)) { - return 0; - } - - *pos = __builtin_ctzll(slab); - return 1; + return rte_bsf64_safe(slab, pos); } -#else - -static inline int -rte_bsf64(uint64_t slab, uint32_t *pos) -{ - uint64_t mask; - uint32_t i; - - if (likely(slab == 0)) { - return 0; - } - - for (i = 0, mask = 1; i < RTE_BITMAP_SLAB_BIT_SIZE; i ++, mask <<= 1) { - if (unlikely(slab & mask)) { - *pos = i; - return 1; - } - } - - return 0; -} - -#endif - static inline uint32_t __rte_bitmap_get_memory_footprint(uint32_t n_bits, uint32_t *array1_byte_offset, uint32_t *array1_slabs, @@ -439,9 +404,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp) value1 = bmp->array1[bmp->index1]; value1 &= __rte_bitmap_mask1_get(bmp); - if (rte_bsf64(value1, &bmp->offset1)) { + if (rte_bsf64_safe(value1, &bmp->offset1)) return 1; - } __rte_bitmap_index1_inc(bmp); bmp->offset1 = 0; @@ -450,9 +414,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp) for (i = 0; i < bmp->array1_size; i ++, __rte_bitmap_index1_inc(bmp)) { value1 = bmp->array1[bmp->index1]; - if (rte_bsf64(value1, &bmp->offset1)) { + if (rte_bsf64_safe(value1, &bmp->offset1)) return 1; - } } return 0; diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 87f0f630..66cdf60b 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -270,16 +270,7 @@ rte_is_aligned(void *ptr, unsigned align) /** * Triggers an error at compilation time if the condition is true. */ -#ifndef __OPTIMIZE__ #define RTE_BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#else -extern int RTE_BUILD_BUG_ON_detected_error; -#define RTE_BUILD_BUG_ON(condition) do { \ - ((void)sizeof(char[1 - 2*!!(condition)])); \ - if (condition) \ - RTE_BUILD_BUG_ON_detected_error = 1; \ -} while(0) -#endif /** * Combines 32b inputs most significant set bits into the least @@ -491,6 +482,29 @@ rte_fls_u32(uint32_t x) return (x == 0) ? 0 : 32 - __builtin_clz(x); } +/** + * Searches the input parameter for the least significant set bit + * (starting from zero). Safe version (checks for input parameter being zero). + * + * @warning ``pos`` must be a valid pointer. It is not checked! + * + * @param v + * The input parameter. + * @param pos + * If ``v`` was not 0, this value will contain position of least significant + * bit within the input parameter. + * @return + * Returns 0 if ``v`` was 0, otherwise returns 1. + */ +static inline int +rte_bsf64_safe(uint64_t v, uint32_t *pos) +{ + if (v == 0) + return 0; + + *pos = __builtin_ctzll(v); + return 1; +} #ifndef offsetof /** Return the offset of a field in a structure. */ diff --git a/lib/librte_eal/common/include/rte_version.h b/lib/librte_eal/common/include/rte_version.h index 45b89430..f01c227f 100644 --- a/lib/librte_eal/common/include/rte_version.h +++ b/lib/librte_eal/common/include/rte_version.h @@ -42,14 +42,14 @@ extern "C" { /** * Extra string to be appended to version number */ -#define RTE_VER_SUFFIX "-rc" +#define RTE_VER_SUFFIX "" /** * Patch release number * 0-15 = release candidates * 16 = release */ -#define RTE_VER_RELEASE 4 +#define RTE_VER_RELEASE 16 /** * Macro to compute a version number usable for comparisons diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 6f94621d..32feb415 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -2230,6 +2230,8 @@ memseg_primary_init(void) socket_id, hugepage_sz); } } + /* number of memtypes could have been lower due to no NUMA support */ + n_memtypes = cur_type; /* set up limits for types */ max_mem = (uint64_t)RTE_MAX_MEM_MB << 20; |