From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 9B90E2BF7 for ; Wed, 29 Jun 2016 01:47:54 +0200 (CEST) Received: by mail-pf0-f170.google.com with SMTP id t190so11426327pfb.3 for ; Tue, 28 Jun 2016 16:47:54 -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=aivy1Q48kbbVv4qyptwc5ea7pEcqauBbI9a9ExyPhg4=; b=crShT+sjQ+Dv3i0S8pB0s7pEfuVyMvYzHYx0n2HKJaCCcLq7rffgAGFuxTh0BmC1aa 7Q43CkH5Nluu94KuMQuGea2tJRht/j34iDYcp7g3jRAWb1NjkJ6f8vcZ38VaOHLgzE4l OeWn1aGB9u7xCkiocS7im9mFSPj6SBsQn1xvfVIeF/fgQcfequ4JRBT/yvLT03SLUoTO s+Z83yaQgZILqIqYihq5lzp6GRzBcHHA+Fpm5jUHIoRhKGhJiB75dTwjHiR7YSbxPh8A IDAyoHOioYdDpyAsl2+iZDtIwTQVU7oY7Tes4PzJnLCGZJu/fjB0FwHEocvv2AbITcRd fygw== 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=aivy1Q48kbbVv4qyptwc5ea7pEcqauBbI9a9ExyPhg4=; b=UhADeo1sKqRpJM9wjaRXcABEpxS+ztWmjxKrlajxWeFG1RtQLU9bvxjEVsuYDp2LId f4xP2E+vhh2molkKYolCRsv8Y+oYWM4n1WtEvK4vh6UTAYpJHhMqaYDPPAE3Jk83KTnn TwHpdgv2Is3/ZeLasSRIRjbzIjdRUluEtjQ8jmw0qM6etV+ttFvIlIz7adVSnO6IbSEr c2ZjDsjiUs6rcATL2KcyTWavpgiLtQtrszq2p4mccEpKeVodBSusNy3J6lwvxOu6YvMS vinr4BJEpbzAp2XRFcEkxXn5aq5fXAhSCBtEv5xci2GPpDHT3Vy58IRhR9P+obSfqf5+ rBRg== X-Gm-Message-State: ALyK8tJMWYx5MX721oQzMy8l5Aw4O88XE3BEQjXy9qSfeisFqYaNqmiYJBwzjEwHRRX3UA== X-Received: by 10.98.216.199 with SMTP id e190mr6499489pfg.76.1467157673676; Tue, 28 Jun 2016 16:47:53 -0700 (PDT) Received: from lap-3.2f30.org (cpc92320-cmbg19-2-0-cust3.5-4.cable.virginm.net. [82.13.64.4]) by smtp.gmail.com with ESMTPSA id p63sm608488pfp.65.2016.06.28.16.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 16:47:53 -0700 (PDT) From: Lazaros Koromilas To: dev@dpdk.org Cc: Olivier Matz Date: Wed, 29 Jun 2016 00:47:37 +0100 Message-Id: <1467157658-28935-3-git-send-email-l@nofutznetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467157658-28935-1-git-send-email-l@nofutznetworks.com> References: <1467042637-22907-1-git-send-email-olivier.matz@6wind.com> <1467157658-28935-1-git-send-email-l@nofutznetworks.com> Subject: [dpdk-dev] [PATCH v5 2/3] mempool: use bit flags to set multi consumers and producers 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: Tue, 28 Jun 2016 23:47:55 -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 Acked-by: Olivier Matz --- 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 a48f46d..971b1ba 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -953,12 +953,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; @@ -971,7 +972,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; @@ -1024,15 +1025,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); } /** @@ -1050,7 +1052,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); } /** @@ -1068,7 +1070,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); } /** @@ -1089,8 +1091,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); } /** @@ -1105,7 +1106,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); } /** @@ -1120,7 +1121,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); } /** @@ -1149,15 +1150,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; @@ -1167,7 +1169,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; @@ -1232,18 +1234,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; @@ -1271,7 +1274,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); } /** @@ -1297,7 +1300,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); } /** @@ -1325,8 +1328,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); } /** @@ -1349,7 +1351,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); } /** @@ -1372,7 +1374,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