From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 44D4FC614 for ; Thu, 16 Jun 2016 13:02:23 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id r190so31473803wmr.0 for ; Thu, 16 Jun 2016 04:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nofutznetworks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HqJ94YvK8xEg+hLXpGTzC/1fqpUEBUqHESNA+bjG2PM=; b=gbcT+PPUcIyo9y5YS8ayYCGcaueWJmJ1/A3z3p9M+Iz15OJXc10aYzmxkzEXhiBDme bg/Mpubi+qadZjW1g42WCesCD3qezCW9hnNHFmaOd8JfbDm3WeKnVJ0gONTuhEVpc5r0 IdwbOJC3aD78ESa3Al6gVQuoVwVNrfE+N0uPsLYc1bYyaNIw8HRi6+jZvIFNRhUa0esd xdJ/8fbL27J7qmXdMNPCvQUraJXTSlaFvaMFGXLa/0y5bdLlZdEr+tJFt3uQZDr1bzhb s592kKUSuFOZPvBj5kPILXgV0U10MTjhtgwnEeLrbHloRCO5cBv5E5+fT6bVTfOqoECK 8WEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HqJ94YvK8xEg+hLXpGTzC/1fqpUEBUqHESNA+bjG2PM=; b=P24P5V3JMJs/VuBTu1YphRWQBDN5ugtZHK1wND7/FBYVEqzqpN1MNivbi8Nu/1Qblb sYKid2XO4+VVgVbYJ9Mjyv6iYgKzYohpfcBb/wA7sffWGppiKcC58j/dtKthlTzDUsNv kJp5uU11bJOZ68VzU3QzZXHchG9QqmtH9SF1bDzi9jDNkhIQsJSbSLkj/oIRn+Pq3M3N QF2lSRkxL0qX2nOZqe/3HONoKlWL5+RJtw5gH3QPTQIlVUWmf1k75PdRJ1rhFv03zWaM Wk33iaF4jyXy9RC5kHNxbO+bIATt5/uKZA5X5uswBq3rjE5m9empMd3ErYEjkdUEj1Ai xeVA== X-Gm-Message-State: ALyK8tK1AXR+RdDAkTKTLwO6oYzHx8hIxnxLvEh1a8BWBdC9Gn4vNON2NERhppLZ+IQmuA== X-Received: by 10.28.26.4 with SMTP id a4mr4071351wma.92.1466074943009; Thu, 16 Jun 2016 04:02:23 -0700 (PDT) Received: from localhost.localdomain (host109-145-5-24.range109-145.btcentralplus.com. [109.145.5.24]) by smtp.gmail.com with ESMTPSA id q71sm14383530wme.17.2016.06.16.04.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 04:02:22 -0700 (PDT) From: Lazaros Koromilas To: dev@dpdk.org Cc: Olivier Matz , Konstantin Ananyev , David Hunt Date: Thu, 16 Jun 2016 12:02:18 +0100 Message-Id: <1466074939-29863-3-git-send-email-l@nofutznetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466074939-29863-1-git-send-email-l@nofutznetworks.com> References: <1466074939-29863-1-git-send-email-l@nofutznetworks.com> Subject: [dpdk-dev] [PATCH v3 2/3] mempool: use bit flags instead of is_mp and is_mc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jun 2016 11:02:23 -0000 Pass the same flags as in rte_mempool_create(). Changes API calls: rte_mempool_generic_put(mp, obj_table, n, flags) rte_mempool_generic_get(mp, obj_table, n, flags) Signed-off-by: Lazaros Koromilas --- lib/librte_mempool/rte_mempool.h | 58 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 7446843..191edba 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -949,12 +949,13 @@ void rte_mempool_dump(FILE *f, struct rte_mempool *mp); * @param n * The number of objects to store back in the mempool, must be strictly * positive. - * @param is_mp - * Mono-producer (0) or multi-producers (1). + * @param flags + * The flags used for the mempool creation. + * Single-producer (MEMPOOL_F_SP_PUT flag) or multi-producers. */ static inline void __attribute__((always_inline)) __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table, - unsigned n, int is_mp) + unsigned n, int flags) { struct rte_mempool_cache *cache; uint32_t index; @@ -967,7 +968,7 @@ __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table, __MEMPOOL_STAT_ADD(mp, put, n); /* cache is not enabled or single producer or non-EAL thread */ - if (unlikely(cache_size == 0 || is_mp == 0 || + if (unlikely(cache_size == 0 || flags & MEMPOOL_F_SP_PUT || lcore_id >= RTE_MAX_LCORE)) goto ring_enqueue; @@ -1020,15 +1021,16 @@ ring_enqueue: * A pointer to a table of void * pointers (objects). * @param n * The number of objects to add in the mempool from the obj_table. - * @param is_mp - * Mono-producer (0) or multi-producers (1). + * @param flags + * The flags used for the mempool creation. + * Single-producer (MEMPOOL_F_SP_PUT flag) or multi-producers. */ static inline void __attribute__((always_inline)) rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table, - unsigned n, int is_mp) + unsigned n, int flags) { __mempool_check_cookies(mp, obj_table, n, 0); - __mempool_generic_put(mp, obj_table, n, is_mp); + __mempool_generic_put(mp, obj_table, n, flags); } /** @@ -1046,7 +1048,7 @@ __rte_deprecated static inline void __attribute__((always_inline)) rte_mempool_mp_put_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - rte_mempool_generic_put(mp, obj_table, n, 1); + rte_mempool_generic_put(mp, obj_table, n, 0); } /** @@ -1064,7 +1066,7 @@ __rte_deprecated static inline void __attribute__((always_inline)) rte_mempool_sp_put_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - rte_mempool_generic_put(mp, obj_table, n, 0); + rte_mempool_generic_put(mp, obj_table, n, MEMPOOL_F_SP_PUT); } /** @@ -1085,8 +1087,7 @@ static inline void __attribute__((always_inline)) rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned n) { - rte_mempool_generic_put(mp, obj_table, n, - !(mp->flags & MEMPOOL_F_SP_PUT)); + rte_mempool_generic_put(mp, obj_table, n, mp->flags); } /** @@ -1101,7 +1102,7 @@ rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table, __rte_deprecated static inline void __attribute__((always_inline)) rte_mempool_mp_put(struct rte_mempool *mp, void *obj) { - rte_mempool_generic_put(mp, &obj, 1, 1); + rte_mempool_generic_put(mp, &obj, 1, 0); } /** @@ -1116,7 +1117,7 @@ rte_mempool_mp_put(struct rte_mempool *mp, void *obj) __rte_deprecated static inline void __attribute__((always_inline)) rte_mempool_sp_put(struct rte_mempool *mp, void *obj) { - rte_mempool_generic_put(mp, &obj, 1, 0); + rte_mempool_generic_put(mp, &obj, 1, MEMPOOL_F_SP_PUT); } /** @@ -1145,15 +1146,16 @@ rte_mempool_put(struct rte_mempool *mp, void *obj) * A pointer to a table of void * pointers (objects). * @param n * The number of objects to get, must be strictly positive. - * @param is_mc - * Mono-consumer (0) or multi-consumers (1). + * @param flags + * The flags used for the mempool creation. + * Single-consumer (MEMPOOL_F_SC_GET flag) or multi-consumers. * @return * - >=0: Success; number of objects supplied. * - <0: Error; code of ring dequeue function. */ static inline int __attribute__((always_inline)) __mempool_generic_get(struct rte_mempool *mp, void **obj_table, - unsigned n, int is_mc) + unsigned n, int flags) { int ret; struct rte_mempool_cache *cache; @@ -1163,7 +1165,7 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table, uint32_t cache_size = mp->cache_size; /* cache is not enabled or single consumer */ - if (unlikely(cache_size == 0 || is_mc == 0 || + if (unlikely(cache_size == 0 || flags & MEMPOOL_F_SC_GET || n >= cache_size || lcore_id >= RTE_MAX_LCORE)) goto ring_dequeue; @@ -1228,18 +1230,19 @@ ring_dequeue: * A pointer to a table of void * pointers (objects) that will be filled. * @param n * The number of objects to get from mempool to obj_table. - * @param is_mc - * Mono-consumer (0) or multi-consumers (1). + * @param flags + * The flags used for the mempool creation. + * Single-consumer (MEMPOOL_F_SC_GET flag) or multi-consumers. * @return * - 0: Success; objects taken. * - -ENOENT: Not enough entries in the mempool; no object is retrieved. */ static inline int __attribute__((always_inline)) rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, unsigned n, - int is_mc) + int flags) { int ret; - ret = __mempool_generic_get(mp, obj_table, n, is_mc); + ret = __mempool_generic_get(mp, obj_table, n, flags); if (ret == 0) __mempool_check_cookies(mp, obj_table, n, 1); return ret; @@ -1267,7 +1270,7 @@ rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, unsigned n, __rte_deprecated static inline int __attribute__((always_inline)) rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) { - return rte_mempool_generic_get(mp, obj_table, n, 1); + return rte_mempool_generic_get(mp, obj_table, n, 0); } /** @@ -1293,7 +1296,7 @@ rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) __rte_deprecated static inline int __attribute__((always_inline)) rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) { - return rte_mempool_generic_get(mp, obj_table, n, 0); + return rte_mempool_generic_get(mp, obj_table, n, MEMPOOL_F_SC_GET); } /** @@ -1321,8 +1324,7 @@ rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) static inline int __attribute__((always_inline)) rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) { - return rte_mempool_generic_get(mp, obj_table, n, - !(mp->flags & MEMPOOL_F_SC_GET)); + return rte_mempool_generic_get(mp, obj_table, n, mp->flags); } /** @@ -1345,7 +1347,7 @@ rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n) __rte_deprecated static inline int __attribute__((always_inline)) rte_mempool_mc_get(struct rte_mempool *mp, void **obj_p) { - return rte_mempool_generic_get(mp, obj_p, 1, 1); + return rte_mempool_generic_get(mp, obj_p, 1, 0); } /** @@ -1368,7 +1370,7 @@ rte_mempool_mc_get(struct rte_mempool *mp, void **obj_p) __rte_deprecated static inline int __attribute__((always_inline)) rte_mempool_sc_get(struct rte_mempool *mp, void **obj_p) { - return rte_mempool_generic_get(mp, obj_p, 1, 0); + return rte_mempool_generic_get(mp, obj_p, 1, MEMPOOL_F_SC_GET); } /** -- 1.9.1