From patchwork Fri Jan 30 04:27:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44016 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4D8F624128 for ; Fri, 30 Jan 2015 04:28:45 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf26742898lbj.0 for ; Thu, 29 Jan 2015 20:28:44 -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=Hglow7QmsBfoOtvNfYtlyMFleTZBszkWG0cqByCqG8U=; b=CJwBeAUyWteeBYxppur7ZtMnq85LYduXdW2p0Dbh8P15EzCf6jHvKF8UQPuf3go3sb Aee78wHnoQXZUa2VN7k77JRbfAy6tnEY9MDuo/oiZcWsVo5EuN2XAdCBg57A8DF6A2Ts IOmb2xR40kJq3lR8nn7efcBr+m3T0C4uP1W24H/BqhsDvs0ouMqnrmjiHd43tUkzftgG qpHibPnix3d1ltpsCu997uNER/LWljz2qspXnF6a4Gv13cFbcE6ueE7MtxdnlCAzYw51 J3gaOu28FXzKg4XqUonXS+C0sODrf2B/EZTvh8KI6yZAiIfAY9uBs0V/hJKIHx0zuRuy 4ahg== X-Gm-Message-State: ALoCoQnvaNBZYc4hd3zZQD5x3757Jhds8vw/BphouuDddGVhO8CjpN5mn6y/crc3xBfkDvnRzk+R X-Received: by 10.152.5.98 with SMTP id r2mr521207lar.6.1422592124206; Thu, 29 Jan 2015 20:28:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.67 with SMTP id de3ls384326lac.60.gmail; Thu, 29 Jan 2015 20:28:43 -0800 (PST) X-Received: by 10.112.198.1 with SMTP id iy1mr4521458lbc.13.1422592123834; Thu, 29 Jan 2015 20:28:43 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ob7si9195485lbb.127.2015.01.29.20.28.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 20:28:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id hs14so21652439lab.9 for ; Thu, 29 Jan 2015 20:28:43 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr4565486lac.38.1422592123744; Thu, 29 Jan 2015 20:28:43 -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 h5csp159240lbj; Thu, 29 Jan 2015 20:28:43 -0800 (PST) X-Received: by 10.140.88.48 with SMTP id s45mr8366237qgd.28.1422592122808; Thu, 29 Jan 2015 20:28:42 -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 96si12917672qgh.88.2015.01.29.20.28.41 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 20:28:42 -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 1YH3CC-0007UO-2b; Fri, 30 Jan 2015 04:28:40 +0000 Received: from mail-ob0-f176.google.com ([209.85.214.176]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YH3Bk-0007NQ-KC for lng-odp@lists.linaro.org; Fri, 30 Jan 2015 04:28:12 +0000 Received: by mail-ob0-f176.google.com with SMTP id va2so22080663obc.7 for ; Thu, 29 Jan 2015 20:28:07 -0800 (PST) X-Received: by 10.182.247.99 with SMTP id yd3mr2730799obc.24.1422592087377; Thu, 29 Jan 2015 20:28:07 -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 x21sm4737369oix.24.2015.01.29.20.28.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 20:28:06 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 22:27:44 -0600 Message-Id: <1422592065-15875-9-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422592065-15875-1-git-send-email-bill.fischofer@linaro.org> References: <1422592065-15875-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [patch 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.50 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 38cf4b9..ec185df 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 5b1c703..4e3e750 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 c596ad1..7d2d0da 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); } /******************************************************************************