From patchwork Sun Feb 1 00:16: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: 44116 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 748002359E for ; Sun, 1 Feb 2015 00:18:09 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf9136713wiv.0 for ; Sat, 31 Jan 2015 16:18:08 -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=MEkl4+aA6BhuBcMtXLevR5rIX/gCHBwnqGz2LxS/JF9cmsVWLgBRJfhIxrrNgWxtHg JDro4jlv5Jb6q263UaY9ObzM42uQh5l8K2eo/GGWKQrqWXmMFicYvcTMC34KHgADx3Cr tlcl95dy3bQyktHAdzSdrIobbeWuye3omeUAR8M2voQAO4GkRcBepJ67YgJrFIIqjWQx f7HLGjmmALg2ty7da86BolenHlJBVOU9EJ6IIekmYZxcxX04F7kt3UB8+3hUwCarbK/L Sg1raUHR/hQe6ywRVW2qXk2okunpDVnzls2M2NepFC/u/5mBV1BZ6toUM91yuL68yMFZ smGA== X-Gm-Message-State: ALoCoQkeyGVSfwHLER8uUhdBdI2tWDUe9yMJ4NKJl56ZaGdHz8SnGfQ95/E3uApDavt35/n4HFQI X-Received: by 10.194.161.194 with SMTP id xu2mr1588417wjb.1.1422749888698; Sat, 31 Jan 2015 16:18:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.130 with SMTP id v2ls453604lae.98.gmail; Sat, 31 Jan 2015 16:18:08 -0800 (PST) X-Received: by 10.152.42.131 with SMTP id o3mr12912929lal.43.1422749888543; Sat, 31 Jan 2015 16:18:08 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id a9si13415240lbc.44.2015.01.31.16.18.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:18:08 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so31311818lab.10 for ; Sat, 31 Jan 2015 16:18:08 -0800 (PST) X-Received: by 10.112.63.134 with SMTP id g6mr9065905lbs.52.1422749888449; Sat, 31 Jan 2015 16:18:08 -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 h5csp507856lbj; Sat, 31 Jan 2015 16:18:07 -0800 (PST) X-Received: by 10.140.39.179 with SMTP id v48mr8374081qgv.77.1422749887035; Sat, 31 Jan 2015 16:18:07 -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 kv9si15979893qcb.21.2015.01.31.16.18.02 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 16:18:07 -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 1YHiEj-0002SQ-4H; Sun, 01 Feb 2015 00:18:01 +0000 Received: from mail-oi0-f41.google.com ([209.85.218.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHiE2-0002Jg-6C for lng-odp@lists.linaro.org; Sun, 01 Feb 2015 00:17:18 +0000 Received: by mail-oi0-f41.google.com with SMTP id z81so39792538oif.0 for ; Sat, 31 Jan 2015 16:17:13 -0800 (PST) X-Received: by 10.182.81.98 with SMTP id z2mr7982916obx.35.1422749832941; Sat, 31 Jan 2015 16:17:12 -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 xr17sm5945905oeb.12.2015.01.31.16.17.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 16:17:12 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 18:16:44 -0600 Message-Id: <1422749807-20228-14-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> References: <1422749807-20228-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 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.51 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); } /******************************************************************************