From patchwork Tue Aug 18 11:01:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52500 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id D4E3F22DB1 for ; Tue, 18 Aug 2015 11:07:13 +0000 (UTC) Received: by lbcue2 with SMTP id ue2sf5634236lbc.1 for ; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=UfJdlmlFaCWpLMh9WjZtpYEGh9sVgDeAIqBcEU93McI=; b=gJ+FntA9w+8th9If9phWdrIPaJySwtBnj/lYXXg7AxxDvKTziLptfy3AJE+VKPcMgh 5+4Evk7wjH70Bptsbnr9FgJgzvtQdALcLHyA2VsjPsfxxwmUEfuSQkyw3AAoq+WoyRrD uYQtev7hL/zICiccRAR3YYn6lTZNu0OUstjJXcPlywt/gGAbz+FsSVOwxHxpkdyrO7hW 58uxwuloOPbdwzvgZoHKTlen6IoHT443/+Z7mIfvGg39PRAy7zfkzsz9E6rd2B3HIK+t Bk5z07LJCqiUobsyxFmeqGi6zsvEK6Cikk1i+ZXuXiG92rierY4qrKGSjvGMkc6Ma2CX UUEQ== X-Gm-Message-State: ALoCoQmFa33LHgTzXDIwcQRfb2Gxfb1+hEV260mHvVQko5dxtdfW/c0AHqK6sf12vz/rDtFxbozJ X-Received: by 10.112.16.200 with SMTP id i8mr1683062lbd.20.1439896032822; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.163 with SMTP id w3ls772113lae.21.gmail; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) X-Received: by 10.152.23.132 with SMTP id m4mr5598017laf.107.1439896032487; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id xs6si13883255lac.46.2015.08.18.04.07.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2015 04:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lalv9 with SMTP id v9so96871327lal.0 for ; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr5711552lbb.29.1439896032283; Tue, 18 Aug 2015 04:07:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.162.200 with SMTP id yc8csp407074lbb; Tue, 18 Aug 2015 04:07:10 -0700 (PDT) X-Received: by 10.140.31.201 with SMTP id f67mr473907qgf.11.1439896030264; Tue, 18 Aug 2015 04:07:10 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n28si23754446qki.39.2015.08.18.04.07.09; Tue, 18 Aug 2015 04:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 45AE661D91; Tue, 18 Aug 2015 11:07:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B63DD61F7F; Tue, 18 Aug 2015 11:02:56 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B8EDE61F64; Tue, 18 Aug 2015 11:02:42 +0000 (UTC) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by lists.linaro.org (Postfix) with ESMTPS id 2D38661F62 for ; Tue, 18 Aug 2015 11:01:55 +0000 (UTC) Received: by wibhh20 with SMTP id hh20so105159680wib.0 for ; Tue, 18 Aug 2015 04:01:54 -0700 (PDT) X-Received: by 10.180.206.211 with SMTP id lq19mr44413037wic.81.1439895714338; Tue, 18 Aug 2015 04:01:54 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id e8sm20892047wiz.0.2015.08.18.04.01.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Aug 2015 04:01:53 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 18 Aug 2015 14:01:33 +0300 Message-Id: <1439895698-18597-8-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439895698-18597-1-git-send-email-maxim.uvarov@linaro.org> References: <1439895698-18597-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv8 07/12] linux-generic: rename odph_ring.., to shm_ring... X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Drop odph_ prefix due to it's not helper anymore and do not add odp_ prefix because it's not api. Signed-off-by: Maxim Uvarov --- platform/linux-generic/include/odp_ring_internal.h | 64 +++++++------- platform/linux-generic/pktio/ring.c | 98 +++++++++++----------- platform/linux-generic/test/ring/odp_ring_test.c | 58 ++++++------- 3 files changed, 110 insertions(+), 110 deletions(-) diff --git a/platform/linux-generic/include/odp_ring_internal.h b/platform/linux-generic/include/odp_ring_internal.h index c3c2f6a..04f2b25 100644 --- a/platform/linux-generic/include/odp_ring_internal.h +++ b/platform/linux-generic/include/odp_ring_internal.h @@ -103,7 +103,7 @@ extern "C" { #include #include -enum odph_ring_queue_behavior { +enum shm_ring_queue_behavior { ODPH_RING_QUEUE_FIXED = 0, /**< Enq/Deq a fixed number of items from a ring */ ODPH_RING_QUEUE_VARIABLE /**< Enq/Deq as many items @@ -123,9 +123,9 @@ enum odph_ring_queue_behavior { * values in a modulo-32bit base: that's why the overflow of the indexes is not * a problem. */ -typedef struct odph_ring { +typedef struct shm_ring { /** @private Next in list. */ - TAILQ_ENTRY(odph_ring) next; + TAILQ_ENTRY(shm_ring) next; /** @private Name of the ring. */ char name[ODPH_RING_NAMESIZE]; @@ -153,7 +153,7 @@ typedef struct odph_ring { /** @private Memory space of ring starts here. */ void *ring[0] ODP_ALIGNED_CACHE; -} odph_ring_t; +} shm_ring_t; #define ODPH_RING_F_SP_ENQ (1 << 0) /* The default enqueue is "single-producer".*/ @@ -194,7 +194,7 @@ typedef struct odph_ring { * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone */ -odph_ring_t *odph_ring_create(const char *name, unsigned count, +shm_ring_t *shm_ring_create(const char *name, unsigned count, unsigned flags); @@ -213,14 +213,14 @@ odph_ring_t *odph_ring_create(const char *name, unsigned count, * @return 0: Success; water mark changed. * -EINVAL: Invalid water mark value. */ -int odph_ring_set_water_mark(odph_ring_t *r, unsigned count); +int shm_ring_set_water_mark(shm_ring_t *r, unsigned count); /** * Dump the status of the ring to the console. * * @param r A pointer to the ring structure. */ -void odph_ring_dump(const odph_ring_t *r); +void shm_ring_dump(const shm_ring_t *r); /** * Enqueue several objects on the ring (multi-producers safe). @@ -247,9 +247,9 @@ void odph_ring_dump(const odph_ring_t *r); * if behavior = ODP_RING_QUEUE_VARIABLE * - n: Actual number of objects enqueued. */ -int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, +int __shm_ring_mp_do_enqueue(shm_ring_t *r, void * const *obj_table, unsigned n, - enum odph_ring_queue_behavior behavior); + enum shm_ring_queue_behavior behavior); /** * Enqueue several objects on a ring (NOT multi-producers safe). @@ -273,9 +273,9 @@ int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, * if behavior = ODP_RING_QUEUE_VARIABLE * - n: Actual number of objects enqueued. */ -int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, +int __shm_ring_sp_do_enqueue(shm_ring_t *r, void * const *obj_table, unsigned n, - enum odph_ring_queue_behavior behavior); + enum shm_ring_queue_behavior behavior); /** * Dequeue several objects from a ring (multi-consumers safe). When @@ -304,9 +304,9 @@ int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, * - n: Actual number of objects dequeued. */ -int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, +int __shm_ring_mc_do_dequeue(shm_ring_t *r, void **obj_table, unsigned n, - enum odph_ring_queue_behavior behavior); + enum shm_ring_queue_behavior behavior); /** * Dequeue several objects from a ring (NOT multi-consumers safe). @@ -331,9 +331,9 @@ int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, * if behavior = ODP_RING_QUEUE_VARIABLE * - n: Actual number of objects dequeued. */ -int __odph_ring_sc_do_dequeue(odph_ring_t *r, void **obj_table, +int __shm_ring_sc_do_dequeue(shm_ring_t *r, void **obj_table, unsigned n, - enum odph_ring_queue_behavior behavior); + enum shm_ring_queue_behavior behavior); /** * Enqueue several objects on the ring (multi-producers safe). @@ -353,7 +353,7 @@ int __odph_ring_sc_do_dequeue(odph_ring_t *r, void **obj_table, * high water mark is exceeded. * - -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued. */ -int odph_ring_mp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, +int shm_ring_mp_enqueue_bulk(shm_ring_t *r, void * const *obj_table, unsigned n); /** @@ -371,7 +371,7 @@ int odph_ring_mp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, * high water mark is exceeded. * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued. */ -int odph_ring_sp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, +int shm_ring_sp_enqueue_bulk(shm_ring_t *r, void * const *obj_table, unsigned n); /** @@ -391,7 +391,7 @@ int odph_ring_sp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, * - -ENOENT: Not enough entries in the ring to dequeue; no object is * dequeued. */ -int odph_ring_mc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n); +int shm_ring_mc_dequeue_bulk(shm_ring_t *r, void **obj_table, unsigned n); /** * Dequeue several objects from a ring (NOT multi-consumers safe). @@ -408,7 +408,7 @@ int odph_ring_mc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n); * - -ENOENT: Not enough entries in the ring to dequeue; no object is * dequeued. */ -int odph_ring_sc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n); +int shm_ring_sc_dequeue_bulk(shm_ring_t *r, void **obj_table, unsigned n); /** * Test if a ring is full. @@ -419,7 +419,7 @@ int odph_ring_sc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n); * - 1: The ring is full. * - 0: The ring is not full. */ -int odph_ring_full(const odph_ring_t *r); +int shm_ring_full(const shm_ring_t *r); /** * Test if a ring is empty. @@ -430,7 +430,7 @@ int odph_ring_full(const odph_ring_t *r); * - 1: The ring is empty. * - 0: The ring is not empty. */ -int odph_ring_empty(const odph_ring_t *r); +int shm_ring_empty(const shm_ring_t *r); /** * Return the number of entries in a ring. @@ -440,7 +440,7 @@ int odph_ring_empty(const odph_ring_t *r); * @return * The number of entries in the ring. */ -unsigned odph_ring_count(const odph_ring_t *r); +unsigned shm_ring_count(const shm_ring_t *r); /** * Return the number of free entries in a ring. @@ -450,14 +450,14 @@ unsigned odph_ring_count(const odph_ring_t *r); * @return * The number of free entries in the ring. */ -unsigned odph_ring_free_count(const odph_ring_t *r); +unsigned shm_ring_free_count(const shm_ring_t *r); /** * search ring by name * @param name ring name to search * @return pointer to ring otherwise NULL */ -odph_ring_t *odph_ring_lookup(const char *name); +shm_ring_t *shm_ring_lookup(const char *name); /** * Enqueue several objects on the ring (multi-producers safe). @@ -474,7 +474,7 @@ odph_ring_t *odph_ring_lookup(const char *name); * @return * - n: Actual number of objects enqueued. */ -int odph_ring_mp_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_mp_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n); /** @@ -489,7 +489,7 @@ int odph_ring_mp_enqueue_burst(odph_ring_t *r, void * const *obj_table, * @return * - n: Actual number of objects enqueued. */ -int odph_ring_sp_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_sp_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n); /** * Enqueue several objects on a ring. @@ -507,7 +507,7 @@ int odph_ring_sp_enqueue_burst(odph_ring_t *r, void * const *obj_table, * @return * - n: Actual number of objects enqueued. */ -int odph_ring_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n); /** @@ -527,7 +527,7 @@ int odph_ring_enqueue_burst(odph_ring_t *r, void * const *obj_table, * @return * - n: Actual number of objects dequeued, 0 if ring is empty */ -int odph_ring_mc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n); +int shm_ring_mc_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n); /** * Dequeue several objects from a ring (NOT multi-consumers safe).When the @@ -543,7 +543,7 @@ int odph_ring_mc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n); * @return * - n: Actual number of objects dequeued, 0 if ring is empty */ -int odph_ring_sc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n); +int shm_ring_sc_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n); /** * Dequeue multiple objects from a ring up to a maximum number. @@ -561,17 +561,17 @@ int odph_ring_sc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n); * @return * - Number of objects dequeued, or a negative error code on error */ -int odph_ring_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n); +int shm_ring_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n); /** * dump the status of all rings on the console */ -void odph_ring_list_dump(void); +void shm_ring_list_dump(void); /** * initialise ring tailq */ -void odph_ring_tailq_init(void); +void shm_ring_tailq_init(void); #ifdef __cplusplus } diff --git a/platform/linux-generic/pktio/ring.c b/platform/linux-generic/pktio/ring.c index 0ab5dd3..fed7f63 100644 --- a/platform/linux-generic/pktio/ring.c +++ b/platform/linux-generic/pktio/ring.c @@ -80,7 +80,7 @@ #include #include -static TAILQ_HEAD(, odph_ring) odp_ring_list; +static TAILQ_HEAD(, shm_ring) odp_ring_list; #define RING_VAL_IS_POWER_2(x) ((((x) - 1) & (x)) == 0) @@ -145,18 +145,18 @@ static TAILQ_HEAD(, odph_ring) odp_ring_list; static odp_rwlock_t qlock; /* rings tailq lock */ /* init tailq_ring */ -void odph_ring_tailq_init(void) +void shm_ring_tailq_init(void) { TAILQ_INIT(&odp_ring_list); odp_rwlock_init(&qlock); } /* create the ring */ -odph_ring_t * -odph_ring_create(const char *name, unsigned count, unsigned flags) +shm_ring_t * +shm_ring_create(const char *name, unsigned count, unsigned flags) { char ring_name[ODPH_RING_NAMESIZE]; - odph_ring_t *r; + shm_ring_t *r; size_t ring_size; uint32_t shm_flag; odp_shm_t shm; @@ -174,7 +174,7 @@ odph_ring_create(const char *name, unsigned count, unsigned flags) } snprintf(ring_name, sizeof(ring_name), "%s", name); - ring_size = count*sizeof(void *)+sizeof(odph_ring_t); + ring_size = count*sizeof(void *)+sizeof(shm_ring_t); odp_rwlock_write_lock(&qlock); /* reserve a memory zone for this ring.*/ @@ -213,7 +213,7 @@ odph_ring_create(const char *name, unsigned count, unsigned flags) * change the high water mark. If *count* is 0, water marking is * disabled */ -int odph_ring_set_water_mark(odph_ring_t *r, unsigned count) +int shm_ring_set_water_mark(shm_ring_t *r, unsigned count) { if (count >= r->prod.size) return -EINVAL; @@ -229,8 +229,8 @@ int odph_ring_set_water_mark(odph_ring_t *r, unsigned count) /** * Enqueue several objects on the ring (multi-producers safe). */ -int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, - unsigned n, enum odph_ring_queue_behavior behavior) +int __shm_ring_mp_do_enqueue(shm_ring_t *r, void * const *obj_table, + unsigned n, enum shm_ring_queue_behavior behavior) { uint32_t prod_head, prod_next; uint32_t cons_tail, free_entries; @@ -302,8 +302,8 @@ int __odph_ring_mp_do_enqueue(odph_ring_t *r, void * const *obj_table, /** * Enqueue several objects on a ring (NOT multi-producers safe). */ -int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, - unsigned n, enum odph_ring_queue_behavior behavior) +int __shm_ring_sp_do_enqueue(shm_ring_t *r, void * const *obj_table, + unsigned n, enum shm_ring_queue_behavior behavior) { uint32_t prod_head, cons_tail; uint32_t prod_next, free_entries; @@ -356,8 +356,8 @@ int __odph_ring_sp_do_enqueue(odph_ring_t *r, void * const *obj_table, * Dequeue several objects from a ring (multi-consumers safe). */ -int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, - unsigned n, enum odph_ring_queue_behavior behavior) +int __shm_ring_mc_do_dequeue(shm_ring_t *r, void **obj_table, + unsigned n, enum shm_ring_queue_behavior behavior) { uint32_t cons_head, prod_tail; uint32_t cons_next, entries; @@ -420,8 +420,8 @@ int __odph_ring_mc_do_dequeue(odph_ring_t *r, void **obj_table, /** * Dequeue several objects from a ring (NOT multi-consumers safe). */ -int __odph_ring_sc_do_dequeue(odph_ring_t *r, void **obj_table, - unsigned n, enum odph_ring_queue_behavior behavior) +int __shm_ring_sc_do_dequeue(shm_ring_t *r, void **obj_table, + unsigned n, enum shm_ring_queue_behavior behavior) { uint32_t cons_head, prod_tail; uint32_t cons_next, entries; @@ -462,45 +462,45 @@ int __odph_ring_sc_do_dequeue(odph_ring_t *r, void **obj_table, /** * Enqueue several objects on the ring (multi-producers safe). */ -int odph_ring_mp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, +int shm_ring_mp_enqueue_bulk(shm_ring_t *r, void * const *obj_table, unsigned n) { - return __odph_ring_mp_do_enqueue(r, obj_table, n, + return __shm_ring_mp_do_enqueue(r, obj_table, n, ODPH_RING_QUEUE_FIXED); } /** * Enqueue several objects on a ring (NOT multi-producers safe). */ -int odph_ring_sp_enqueue_bulk(odph_ring_t *r, void * const *obj_table, +int shm_ring_sp_enqueue_bulk(shm_ring_t *r, void * const *obj_table, unsigned n) { - return __odph_ring_sp_do_enqueue(r, obj_table, n, + return __shm_ring_sp_do_enqueue(r, obj_table, n, ODPH_RING_QUEUE_FIXED); } /** * Dequeue several objects from a ring (multi-consumers safe). */ -int odph_ring_mc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n) +int shm_ring_mc_dequeue_bulk(shm_ring_t *r, void **obj_table, unsigned n) { - return __odph_ring_mc_do_dequeue(r, obj_table, n, + return __shm_ring_mc_do_dequeue(r, obj_table, n, ODPH_RING_QUEUE_FIXED); } /** * Dequeue several objects from a ring (NOT multi-consumers safe). */ -int odph_ring_sc_dequeue_bulk(odph_ring_t *r, void **obj_table, unsigned n) +int shm_ring_sc_dequeue_bulk(shm_ring_t *r, void **obj_table, unsigned n) { - return __odph_ring_sc_do_dequeue(r, obj_table, n, + return __shm_ring_sc_do_dequeue(r, obj_table, n, ODPH_RING_QUEUE_FIXED); } /** * Test if a ring is full. */ -int odph_ring_full(const odph_ring_t *r) +int shm_ring_full(const shm_ring_t *r) { uint32_t prod_tail = r->prod.tail; uint32_t cons_tail = r->cons.tail; @@ -510,7 +510,7 @@ int odph_ring_full(const odph_ring_t *r) /** * Test if a ring is empty. */ -int odph_ring_empty(const odph_ring_t *r) +int shm_ring_empty(const shm_ring_t *r) { uint32_t prod_tail = r->prod.tail; uint32_t cons_tail = r->cons.tail; @@ -520,7 +520,7 @@ int odph_ring_empty(const odph_ring_t *r) /** * Return the number of entries in a ring. */ -unsigned odph_ring_count(const odph_ring_t *r) +unsigned shm_ring_count(const shm_ring_t *r) { uint32_t prod_tail = r->prod.tail; uint32_t cons_tail = r->cons.tail; @@ -530,7 +530,7 @@ unsigned odph_ring_count(const odph_ring_t *r) /** * Return the number of free entries in a ring. */ -unsigned odph_ring_free_count(const odph_ring_t *r) +unsigned shm_ring_free_count(const shm_ring_t *r) { uint32_t prod_tail = r->prod.tail; uint32_t cons_tail = r->cons.tail; @@ -538,7 +538,7 @@ unsigned odph_ring_free_count(const odph_ring_t *r) } /* dump the status of the ring on the console */ -void odph_ring_dump(const odph_ring_t *r) +void shm_ring_dump(const shm_ring_t *r) { ODPH_DBG("ring <%s>@%p\n", r->name, r); ODPH_DBG(" flags=%x\n", r->flags); @@ -547,8 +547,8 @@ void odph_ring_dump(const odph_ring_t *r) ODPH_DBG(" ch=%" PRIu32 "\n", r->cons.head); ODPH_DBG(" pt=%" PRIu32 "\n", r->prod.tail); ODPH_DBG(" ph=%" PRIu32 "\n", r->prod.head); - ODPH_DBG(" used=%u\n", odph_ring_count(r)); - ODPH_DBG(" avail=%u\n", odph_ring_free_count(r)); + ODPH_DBG(" used=%u\n", shm_ring_count(r)); + ODPH_DBG(" avail=%u\n", shm_ring_free_count(r)); if (r->prod.watermark == r->prod.size) ODPH_DBG(" watermark=0\n"); else @@ -556,23 +556,23 @@ void odph_ring_dump(const odph_ring_t *r) } /* dump the status of all rings on the console */ -void odph_ring_list_dump(void) +void shm_ring_list_dump(void) { - const odph_ring_t *mp = NULL; + const shm_ring_t *mp = NULL; odp_rwlock_read_lock(&qlock); TAILQ_FOREACH(mp, &odp_ring_list, next) { - odph_ring_dump(mp); + shm_ring_dump(mp); } odp_rwlock_read_unlock(&qlock); } /* search a ring from its name */ -odph_ring_t *odph_ring_lookup(const char *name) +shm_ring_t *shm_ring_lookup(const char *name) { - odph_ring_t *r; + shm_ring_t *r; odp_rwlock_read_lock(&qlock); TAILQ_FOREACH(r, &odp_ring_list, next) { @@ -587,60 +587,60 @@ odph_ring_t *odph_ring_lookup(const char *name) /** * Enqueue several objects on the ring (multi-producers safe). */ -int odph_ring_mp_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_mp_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n) { - return __odph_ring_mp_do_enqueue(r, obj_table, n, + return __shm_ring_mp_do_enqueue(r, obj_table, n, ODPH_RING_QUEUE_VARIABLE); } /** * Enqueue several objects on a ring (NOT multi-producers safe). */ -int odph_ring_sp_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_sp_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n) { - return __odph_ring_sp_do_enqueue(r, obj_table, n, + return __shm_ring_sp_do_enqueue(r, obj_table, n, ODPH_RING_QUEUE_VARIABLE); } /** * Enqueue several objects on a ring. */ -int odph_ring_enqueue_burst(odph_ring_t *r, void * const *obj_table, +int shm_ring_enqueue_burst(shm_ring_t *r, void * const *obj_table, unsigned n) { if (r->prod.sp_enqueue) - return odph_ring_sp_enqueue_burst(r, obj_table, n); + return shm_ring_sp_enqueue_burst(r, obj_table, n); else - return odph_ring_mp_enqueue_burst(r, obj_table, n); + return shm_ring_mp_enqueue_burst(r, obj_table, n); } /** * Dequeue several objects from a ring (multi-consumers safe). */ -int odph_ring_mc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n) +int shm_ring_mc_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n) { - return __odph_ring_mc_do_dequeue(r, obj_table, n, + return __shm_ring_mc_do_dequeue(r, obj_table, n, ODPH_RING_QUEUE_VARIABLE); } /** * Dequeue several objects from a ring (NOT multi-consumers safe). */ -int odph_ring_sc_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n) +int shm_ring_sc_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n) { - return __odph_ring_sc_do_dequeue(r, obj_table, n, + return __shm_ring_sc_do_dequeue(r, obj_table, n, ODPH_RING_QUEUE_VARIABLE); } /** * Dequeue multiple objects from a ring up to a maximum number. */ -int odph_ring_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n) +int shm_ring_dequeue_burst(shm_ring_t *r, void **obj_table, unsigned n) { if (r->cons.sc_dequeue) - return odph_ring_sc_dequeue_burst(r, obj_table, n); + return shm_ring_sc_dequeue_burst(r, obj_table, n); else - return odph_ring_mc_dequeue_burst(r, obj_table, n); + return shm_ring_mc_dequeue_burst(r, obj_table, n); } diff --git a/platform/linux-generic/test/ring/odp_ring_test.c b/platform/linux-generic/test/ring/odp_ring_test.c index cec8221..799f5c6 100644 --- a/platform/linux-generic/test/ring/odp_ring_test.c +++ b/platform/linux-generic/test/ring/odp_ring_test.c @@ -57,7 +57,7 @@ #define RING_TEST_BASIC -static int test_ring_basic(odph_ring_t *r) +static int test_ring_basic(shm_ring_t *r) { void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; @@ -86,7 +86,7 @@ static int test_ring_basic(odph_ring_t *r) printf("Test SP & SC basic functions\n"); printf("enqueue 1 obj\n"); - ret = odph_ring_sp_enqueue_burst(r, cur_src, 1); + ret = shm_ring_sp_enqueue_burst(r, cur_src, 1); cur_src += 1; if ((ret & ODPH_RING_SZ_MASK) != 1) { LOG_ERR("sp_enq for 1 obj failed\n"); @@ -94,7 +94,7 @@ static int test_ring_basic(odph_ring_t *r) } printf("enqueue 2 objs\n"); - ret = odph_ring_sp_enqueue_burst(r, cur_src, 2); + ret = shm_ring_sp_enqueue_burst(r, cur_src, 2); cur_src += 2; if ((ret & ODPH_RING_SZ_MASK) != 2) { LOG_ERR("sp_enq for 2 obj failed\n"); @@ -102,14 +102,14 @@ static int test_ring_basic(odph_ring_t *r) } printf("enqueue MAX_BULK objs\n"); - ret = odph_ring_sp_enqueue_burst(r, cur_src, MAX_BULK); + ret = shm_ring_sp_enqueue_burst(r, cur_src, MAX_BULK); if ((ret & ODPH_RING_SZ_MASK) != MAX_BULK) { LOG_ERR("sp_enq for %d obj failed\n", MAX_BULK); goto fail; } printf("dequeue 1 obj\n"); - ret = odph_ring_sc_dequeue_burst(r, cur_dst, 1); + ret = shm_ring_sc_dequeue_burst(r, cur_dst, 1); cur_dst += 1; if ((ret & ODPH_RING_SZ_MASK) != 1) { LOG_ERR("sc_deq for 1 obj failed\n"); @@ -117,7 +117,7 @@ static int test_ring_basic(odph_ring_t *r) } printf("dequeue 2 objs\n"); - ret = odph_ring_sc_dequeue_burst(r, cur_dst, 2); + ret = shm_ring_sc_dequeue_burst(r, cur_dst, 2); cur_dst += 2; if ((ret & ODPH_RING_SZ_MASK) != 2) { LOG_ERR("sc_deq for 2 obj failed\n"); @@ -125,7 +125,7 @@ static int test_ring_basic(odph_ring_t *r) } printf("dequeue MAX_BULK objs\n"); - ret = odph_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK); + ret = shm_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK); cur_dst += MAX_BULK; if ((ret & ODPH_RING_SZ_MASK) != MAX_BULK) { LOG_ERR("sc_deq for %d obj failed\n", MAX_BULK); @@ -144,41 +144,41 @@ static int test_ring_basic(odph_ring_t *r) printf("Test MP & MC basic functions\n"); printf("enqueue 1 obj\n"); - ret = odph_ring_mp_enqueue_bulk(r, cur_src, 1); + ret = shm_ring_mp_enqueue_bulk(r, cur_src, 1); cur_src += 1; if (ret != 0) { LOG_ERR("mp_enq for 1 obj failed\n"); goto fail; } printf("enqueue 2 objs\n"); - ret = odph_ring_mp_enqueue_bulk(r, cur_src, 2); + ret = shm_ring_mp_enqueue_bulk(r, cur_src, 2); cur_src += 2; if (ret != 0) { LOG_ERR("mp_enq for 2 obj failed\n"); goto fail; } printf("enqueue MAX_BULK objs\n"); - ret = odph_ring_mp_enqueue_bulk(r, cur_src, MAX_BULK); + ret = shm_ring_mp_enqueue_bulk(r, cur_src, MAX_BULK); if (ret != 0) { LOG_ERR("mp_enq for %d obj failed\n", MAX_BULK); goto fail; } printf("dequeue 1 obj\n"); - ret = odph_ring_mc_dequeue_bulk(r, cur_dst, 1); + ret = shm_ring_mc_dequeue_bulk(r, cur_dst, 1); cur_dst += 1; if (ret != 0) { LOG_ERR("mc_deq for 1 obj failed\n"); goto fail; } printf("dequeue 2 objs\n"); - ret = odph_ring_mc_dequeue_bulk(r, cur_dst, 2); + ret = shm_ring_mc_dequeue_bulk(r, cur_dst, 2); cur_dst += 2; if (ret != 0) { LOG_ERR("mc_deq for 2 obj failed\n"); goto fail; } printf("dequeue MAX_BULK objs\n"); - ret = odph_ring_mc_dequeue_bulk(r, cur_dst, MAX_BULK); + ret = shm_ring_mc_dequeue_bulk(r, cur_dst, MAX_BULK); cur_dst += MAX_BULK; if (ret != 0) { LOG_ERR("mc_deq for %d obj failed\n", MAX_BULK); @@ -191,30 +191,30 @@ static int test_ring_basic(odph_ring_t *r) } printf("test watermark and default bulk enqueue / dequeue\n"); - odph_ring_set_water_mark(r, 20); + shm_ring_set_water_mark(r, 20); num_elems = 16; cur_src = src; cur_dst = dst; - ret = odph_ring_mp_enqueue_bulk(r, cur_src, num_elems); + ret = shm_ring_mp_enqueue_bulk(r, cur_src, num_elems); cur_src += num_elems; if (ret != 0) { LOG_ERR("Cannot enqueue\n"); goto fail; } - ret = odph_ring_mp_enqueue_bulk(r, cur_src, num_elems); + ret = shm_ring_mp_enqueue_bulk(r, cur_src, num_elems); if (ret != -EDQUOT) { LOG_ERR("Watermark not exceeded\n"); goto fail; } - ret = odph_ring_mc_dequeue_bulk(r, cur_dst, num_elems); + ret = shm_ring_mc_dequeue_bulk(r, cur_dst, num_elems); cur_dst += num_elems; if (ret != 0) { LOG_ERR("Cannot dequeue\n"); goto fail; } - ret = odph_ring_mc_dequeue_bulk(r, cur_dst, num_elems); + ret = shm_ring_mc_dequeue_bulk(r, cur_dst, num_elems); cur_dst += num_elems; if (ret != 0) { LOG_ERR("Cannot dequeue2\n"); @@ -241,7 +241,7 @@ fail: } /* global shared ring used for stress testing */ -static odph_ring_t *r_stress; +static shm_ring_t *r_stress; /* Stress func for Multi producer only */ static int producer_fn(void) @@ -260,7 +260,7 @@ static int producer_fn(void) src[i] = (void *)(unsigned long)i; do { - i = odph_ring_mp_enqueue_bulk(r_stress, src, MAX_BULK); + i = shm_ring_mp_enqueue_bulk(r_stress, src, MAX_BULK); if (i == 0) { free(src); return 0; @@ -282,7 +282,7 @@ static int consumer_fn(void) } do { - i = odph_ring_mc_dequeue_bulk(r_stress, src, MAX_BULK); + i = shm_ring_mc_dequeue_bulk(r_stress, src, MAX_BULK); if (i == 0) { for (i = 0; i < MAX_BULK; i++) { if (src[i] != (void *)(unsigned long)i) { @@ -356,7 +356,7 @@ static void *test_ring(void *arg) ring_arg_t *parg = (ring_arg_t *)arg; int thr; char ring_name[ODPH_RING_NAMESIZE]; - odph_ring_t *r; + shm_ring_t *r; int result = 0; thr = odp_thread_id(); @@ -367,7 +367,7 @@ static void *test_ring(void *arg) case ODP_RING_TEST_BASIC: snprintf(ring_name, sizeof(ring_name), "test_ring_%i", thr); - r = odph_ring_create(ring_name, RING_SIZE, + r = shm_ring_create(ring_name, RING_SIZE, 0 /* not used, alignement taken care inside func : todo */); if (r == NULL) { @@ -376,7 +376,7 @@ static void *test_ring(void *arg) break; } /* lookup ring from its name */ - if (odph_ring_lookup(ring_name) != r) { + if (shm_ring_lookup(ring_name) != r) { LOG_ERR("ring lookup failed\n"); result = -1; break; @@ -389,7 +389,7 @@ static void *test_ring(void *arg) } /* dump ring stats */ - odph_ring_list_dump(); + shm_ring_list_dump(); break; @@ -397,7 +397,7 @@ static void *test_ring(void *arg) test_ring_stress(parg->stress_type); /* dump ring stats */ - odph_ring_list_dump(); + shm_ring_list_dump(); break; default: @@ -428,7 +428,7 @@ int main(int argc __attribute__((__unused__)), odp_print_system_info(); - odph_ring_tailq_init(); + shm_ring_tailq_init(); rarg.thrdarg.numthrds = odp_cpu_count(); @@ -444,7 +444,7 @@ int main(int argc __attribute__((__unused__)), /* create a ring */ snprintf(ring_name, sizeof(ring_name), "test_ring_stress"); - r_stress = odph_ring_create(ring_name, RING_SIZE, + r_stress = shm_ring_create(ring_name, RING_SIZE, 0 /* not used, alignement taken care inside func : todo */); if (r_stress == NULL) { @@ -452,7 +452,7 @@ int main(int argc __attribute__((__unused__)), goto fail; } /* lookup ring from its name */ - if (odph_ring_lookup(ring_name) != r_stress) { + if (shm_ring_lookup(ring_name) != r_stress) { LOG_ERR("ring lookup failed\n"); goto fail; }