From patchwork Tue Feb 3 04:44:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44201 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 29F272034D for ; Tue, 3 Feb 2015 04:46:42 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf23628163wiv.2 for ; Mon, 02 Feb 2015 20:46:41 -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=cT482qHPO2HKgQptlQv8OV6Jk98NQVEAB0VNJf1j5zQ=; b=DrRjntyZLQs5fugldpMUbdwoJ96oztZx1X9Xba7rlTVLyuhH1R9bfyRS9WufwWjMzB aPWPwBx6uM+2Y/ibVTEqhzbC93MkkkSyhHHiZxkjFOB4hKJBAf49k4GJ8+m8uLw5SWoC lU+7zTx9fEjGwgHVa8pYitgnW32/Yr+KQkk9zG/rKs0Q6uxZmo4CjvhB+b4yE6ePnhoQ KTcKZhm6jvEyd1LV0KVZCOub7UcKPcWN0AIX0NojCUGOP4Pfuv1u8Nmhjbv6KgDRvwLa OYkqASPvQEhwCkRRNWFGXKw8A9DVvBn8VLlcoU8L2YdOUSGpupauhLe/ZHyQ+dT10Fxx Thjw== X-Gm-Message-State: ALoCoQlpQ155CjQlSU/QsoM4XSP2jbYOuPYzVWz0d4boYlVajjDZ4srkc751fqvb3mrbh1Sntr4s X-Received: by 10.180.98.199 with SMTP id ek7mr1658680wib.1.1422938801497; Mon, 02 Feb 2015 20:46:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.141 with SMTP id o13ls640824lal.78.gmail; Mon, 02 Feb 2015 20:46:41 -0800 (PST) X-Received: by 10.112.224.133 with SMTP id rc5mr18369545lbc.31.1422938801266; Mon, 02 Feb 2015 20:46:41 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id le11si18358899lac.102.2015.02.02.20.46.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id pv20so47783365lab.7 for ; Mon, 02 Feb 2015 20:46:40 -0800 (PST) X-Received: by 10.112.188.227 with SMTP id gd3mr22562570lbc.22.1422938800820; Mon, 02 Feb 2015 20:46:40 -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 h5csp1712639lbj; Mon, 2 Feb 2015 20:46:40 -0800 (PST) X-Received: by 10.224.54.205 with SMTP id r13mr49584851qag.12.1422938799502; Mon, 02 Feb 2015 20:46:39 -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 hu8si26951326qcb.26.2015.02.02.20.46.38 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:39 -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 1YIVNk-0006EE-JX; Tue, 03 Feb 2015 04:46:36 +0000 Received: from mail-oi0-f54.google.com ([209.85.218.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIVMv-00062H-1w for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 04:45:45 +0000 Received: by mail-oi0-f54.google.com with SMTP id v63so47464630oia.13 for ; Mon, 02 Feb 2015 20:45:39 -0800 (PST) X-Received: by 10.60.175.226 with SMTP id cd2mr14120044oec.81.1422938739732; Mon, 02 Feb 2015 20:45:39 -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 vs5sm10277537oeb.14.2015.02.02.20.45.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Feb 2015 20:45:39 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 2 Feb 2015 22:44:58 -0600 Message-Id: <1422938699-12877-19-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422938699-12877-1-git-send-email-bill.fischofer@linaro.org> References: <1422938699-12877-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 18/19] linux-generic: queues: 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.48 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 ++++---- 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 ++-- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 98dc76d..b073987 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_to_u64(pktio), dev, - odp_pktio_to_u64(pktio), inq_def); + odp_pktio_to_u64(pktio), odp_queue_to_u64(inq_def)); return pktio; } diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index f8377e4..1defb8f 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_to_u64(inq_def), idx, + odp_queue_to_u64(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_to_u64(pktio), odp_pktio_to_u64(pktio), inq_def, + odp_pktio_to_u64(pktio), odp_pktio_to_u64(pktio), + odp_queue_to_u64(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 ad83968..4c02ece 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_to_u64(pktio), dev, - odp_pktio_to_u64(pktio), inq_def); + odp_pktio_to_u64(pktio), odp_queue_to_u64(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_to_u64(pktio), odp_pktio_to_u64(pktio), - odp_pktio_inq_getdef(pktio)); + odp_queue_to_u64(odp_pktio_inq_getdef(pktio))); /* Loop packets */ for (;;) { diff --git a/platform/linux-generic/include/odp/plat/queue_types.h b/platform/linux-generic/include/odp/plat/queue_types.h index cb81373..04a0be9 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_to_u64(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); } /******************************************************************************