From patchwork Sat Jan 31 16:14:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44089 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5F0E32359E for ; Sat, 31 Jan 2015 16:15:24 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf13332942lab.3 for ; Sat, 31 Jan 2015 08:15:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state: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=Ek6tK+mnguGx1L3uaf70q/ylr9H1OD0pmjJUJ44wCuA=; b=LepOWkgkdlszZytkyZzbXrrEBiKx2dkYRnz8u0k8iN2BysO6SaPDkCT3LtAeNpRTR4 DakwrqIt3QlaEevJ11dLtsPijYBErII0vryKBDfwGCDv2+El9c0kw9oMEL6cEK8kXQ/x T4dAh6PJqnobwqoS80BDxgTT8cz8QqOek2KupYInJWs/MvzIXH0NpW+gwK27JkIadNXG tus7dHHhYTLpUHwoJb3n/reB9TgOVh/cPK6HvEiw6PoaJCdcLCsLnXp9aN4iG94Yt4o8 DELAuAdpEg8mCV5gflJcnQtblAIBQ9PdLJpk/q/kd2g6y5Bd2gqH6yK4CesCtB42p9oE zvPw== X-Gm-Message-State: ALoCoQkhY70fPyyhxslZj3esCdNe6XKydjXnLR/InK4ndDsekfKFubO2JkWuAAIRWdou61/WLIkQ X-Received: by 10.112.175.10 with SMTP id bw10mr1460217lbc.7.1422720922737; Sat, 31 Jan 2015 08:15:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.35 with SMTP id p3ls597248lap.49.gmail; Sat, 31 Jan 2015 08:15:22 -0800 (PST) X-Received: by 10.112.160.193 with SMTP id xm1mr11589494lbb.5.1422720922590; Sat, 31 Jan 2015 08:15:22 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id xk2si12596155lac.117.2015.01.31.08.15.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 08:15:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id gf13so29429010lab.8 for ; Sat, 31 Jan 2015 08:15:22 -0800 (PST) X-Received: by 10.112.125.41 with SMTP id mn9mr11485598lbb.80.1422720922464; Sat, 31 Jan 2015 08:15:22 -0800 (PST) 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.35.133 with SMTP id h5csp352058lbj; Sat, 31 Jan 2015 08:15:21 -0800 (PST) X-Received: by 10.224.24.132 with SMTP id v4mr24076800qab.17.1422720920861; Sat, 31 Jan 2015 08:15:20 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id s33si18396557qge.13.2015.01.31.08.15.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 08:15:20 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHaha-0005AJ-4O; Sat, 31 Jan 2015 16:15:18 +0000 Received: from mail-ob0-f178.google.com ([209.85.214.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHah9-00056B-PU for lng-odp@lists.linaro.org; Sat, 31 Jan 2015 16:14:51 +0000 Received: by mail-ob0-f178.google.com with SMTP id uz6so10644156obc.9 for ; Sat, 31 Jan 2015 08:14:46 -0800 (PST) X-Received: by 10.202.88.132 with SMTP id m126mr4142493oib.57.1422720886485; Sat, 31 Jan 2015 08:14:46 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id ur1sm6921411obc.3.2015.01.31.08.14.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 08:14:46 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 10:14:25 -0600 Message-Id: <1422720866-22194-9-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422720866-22194-1-git-send-email-bill.fischofer@linaro.org> References: <1422720866-22194-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 8/9] linux-generic: queue: add strong typing support X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@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.49 as permitted sender) smtp.mail=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 Signed-off-by: Bill Fischofer --- example/generator/odp_generator.c | 5 +++-- example/ipsec/odp_ipsec.c | 12 +++++++----- example/packet/odp_pktio.c | 8 ++++---- include/odp/api/queue.h | 13 +++++++++++++ platform/linux-generic/include/odp/plat/queue_types.h | 14 +++++++++++--- platform/linux-generic/include/odp_queue_internal.h | 4 ++-- platform/linux-generic/odp_timer.c | 4 ++-- 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index b98aba5..26f0cde 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -322,9 +322,10 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) printf(" created pktio:%02" PRIu64 ", dev:%s, queue mode (ATOMIC queues)\n" - " default pktio%02" PRIu64 "-INPUT queue:%u\n", + " default pktio%02" PRIu64 + "-INPUT queue:%" PRIu64 "\n", odp_pktio_t_print(pktio), dev, - odp_pktio_t_print(pktio), inq_def); + odp_pktio_t_print(pktio), odp_queue_t_print(inq_def)); return pktio; } diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 2f7106d..04be16e 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -520,10 +520,11 @@ void initialize_loop(char *intf) mac = query_loopback_db_mac(idx); printf("Created loop:%02i, queue mode (ATOMIC queues)\n" - " default loop%02i-INPUT queue:%u\n" - " default loop%02i-OUTPUT queue:%u\n" + " default loop%02i-INPUT queue:%" PRIu64 "\n" + " default loop%02i-OUTPUT queue:%" PRIu64 "\n" " source mac address %s\n", - idx, idx, inq_def, idx, outq_def, + idx, idx, odp_queue_t_print(inq_def), idx, + odp_queue_t_print(outq_def), mac_addr_str(mac_str, mac)); /* Resolve any routes using this interface for output */ @@ -597,9 +598,10 @@ void initialize_intf(char *intf) } printf("Created pktio:%02" PRIu64 ", queue mode (ATOMIC queues)\n" - " default pktio%02" PRIu64 "-INPUT queue:%u\n" + " default pktio%02" PRIu64 "-INPUT queue:%" PRIu64 "\n" " source mac address %s\n", - odp_pktio_t_print(pktio), odp_pktio_t_print(pktio), inq_def, + odp_pktio_t_print(pktio), odp_pktio_t_print(pktio), + odp_queue_t_print(inq_def), mac_addr_str(src_mac_str, src_mac)); /* Resolve any routes using this interface for output */ diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index cd13576..77ac4f5 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -134,9 +134,9 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode) printf(" created pktio:%02" PRIu64 ", dev:%s, queue mode (ATOMIC queues)\n" - " \tdefault pktio%02" PRIu64 "-INPUT queue:%u\n", + " \tdefault pktio%02" PRIu64 "-INPUT queue:%" PRIu64 "\n", odp_pktio_t_print(pktio), dev, - odp_pktio_t_print(pktio), inq_def); + odp_pktio_t_print(pktio), odp_queue_t_print(inq_def)); return pktio; } @@ -169,9 +169,9 @@ static void *pktio_queue_thread(void *arg) printf(" [%02i] looked up pktio:%02" PRIu64 ", queue mode (ATOMIC queues)\n" - " default pktio%02" PRIu64 "-INPUT queue:%u\n", + " default pktio%02" PRIu64 "-INPUT queue:%" PRIu64 "\n", thr, odp_pktio_t_print(pktio), odp_pktio_t_print(pktio), - odp_pktio_inq_getdef(pktio)); + odp_queue_t_print(odp_pktio_inq_getdef(pktio))); /* Loop packets */ for (;;) { diff --git a/include/odp/api/queue.h b/include/odp/api/queue.h index b63cc34..de609ca 100644 --- a/include/odp/api/queue.h +++ b/include/odp/api/queue.h @@ -298,6 +298,19 @@ odp_schedule_prio_t odp_queue_sched_prio(odp_queue_t queue); odp_schedule_group_t odp_queue_sched_group(odp_queue_t queue); /** + * Get printable value for an odp_queue_t + * + * @param hdl odp_queue_t handle to be printed + * @return uint64_t value that can be used to print/display this + * handle + * + * @note This routine is intended to be used for diagnostic purposes + * to enable applications to generate a printable value that represents + * an odp_queue_t handle. + */ +uint64_t odp_queue_t_print(odp_queue_t hdl); + +/** * @} */ diff --git a/platform/linux-generic/include/odp/plat/queue_types.h b/platform/linux-generic/include/odp/plat/queue_types.h index cb81373..a634bac 100644 --- a/platform/linux-generic/include/odp/plat/queue_types.h +++ b/platform/linux-generic/include/odp/plat/queue_types.h @@ -17,16 +17,19 @@ extern "C" { #endif +#include +#include + /** @addtogroup odp_queue ODP QUEUE * Macros and operation on a queue. * @{ */ -typedef uint32_t odp_queue_t; +typedef odp_handle_t odp_queue_t; -typedef uint32_t odp_queue_group_t; +typedef odp_handle_t odp_queue_group_t; -#define ODP_QUEUE_INVALID 0 +#define ODP_QUEUE_INVALID _odp_cast_scalar(odp_queue_t, 0) #define ODP_QUEUE_NAME_LEN 32 @@ -63,6 +66,11 @@ typedef int odp_schedule_group_t; #define ODP_SCHED_GROUP_DEFAULT ODP_SCHED_GROUP_ALL +/** Get printable format of odp_queue_t */ +static inline uint64_t odp_queue_t_print(odp_queue_t hdl) +{ + return _odp_pri(hdl); +} /** * @} diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 340e20d..bfa36df 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -105,12 +105,12 @@ int queue_sched_atomic(odp_queue_t handle); static inline uint32_t queue_to_id(odp_queue_t handle) { - return handle - 1; + return _odp_typeval(handle) - 1; } static inline odp_queue_t queue_from_id(uint32_t queue_id) { - return queue_id + 1; + return _odp_cast_scalar(odp_queue_t, queue_id + 1); } static inline queue_entry_t *queue_to_qentry(odp_queue_t handle) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 0b2e675..727f3a1 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -132,14 +132,14 @@ static void timer_fini(odp_timer *tim, tick_buf_t *tb) static inline uint32_t get_next_free(odp_timer *tim) { /* Reusing 'queue' for next free index */ - return tim->queue; + return _odp_typeval(tim->queue); } static inline void set_next_free(odp_timer *tim, uint32_t nf) { assert(tim->queue == ODP_QUEUE_INVALID); /* Reusing 'queue' for next free index */ - tim->queue = nf; + tim->queue = _odp_cast_scalar(odp_queue_t, nf); } /******************************************************************************