From patchwork Tue Feb 3 04:44:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44198 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 27DF42034D for ; Tue, 3 Feb 2015 04:46:30 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id k14sf18706283wgh.3 for ; Mon, 02 Feb 2015 20:46:29 -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=YkQJysozpk+XbA7E3Qm1mUSa/VjLw9mDeQWd646b5l0=; b=e5LV4wpNjpKubkoQ1d2m1ft/GW/mX4tZ4p9Je3vr15ygUouEeBYnaAMtjiIATiXI76 3PqLb+z9RLZLDzyyxl5RlByhW5+Cy11DiBs8EIcrhdl8snuCq4YBsTsmOsDZyK0TkRLs Tsy4r6Zd/FNeFVuQx1LczpnGid4Vuhk03ty/MfxNczdIjq8B/I9IDLhl8VoN0pONG2Ao 3U7BqAW0Y/6UTs0Vn/4G5YuZrgXPI6tuVecG8fLqIhIsEYojLmXGCoR2859AvUKrc2T+ vqz1N7Ukgr90fdE6gtN7yvYbOvpr3bDbGocWzw51A3a++Y2u3cvp8FgIwJEydwSjZROy 7lRw== X-Gm-Message-State: ALoCoQlany3B88Fmnzv6sJ24GgJBC4GB/1wcNebi9gVMft1KLEl+EZx0ko2lZVeu9m9onkRfB1JU X-Received: by 10.112.174.36 with SMTP id bp4mr2733200lbc.15.1422938789426; Mon, 02 Feb 2015 20:46:29 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.167 with SMTP id x7ls405364lal.61.gmail; Mon, 02 Feb 2015 20:46:29 -0800 (PST) X-Received: by 10.152.203.137 with SMTP id kq9mr22531675lac.51.1422938789075; Mon, 02 Feb 2015 20:46:29 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id c8si18353370lbb.103.2015.02.02.20.46.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:29 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id s18so48042803lam.3 for ; Mon, 02 Feb 2015 20:46:29 -0800 (PST) X-Received: by 10.112.176.236 with SMTP id cl12mr3462706lbc.3.1422938788988; Mon, 02 Feb 2015 20:46:28 -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 h5csp1712557lbj; Mon, 2 Feb 2015 20:46:27 -0800 (PST) X-Received: by 10.140.25.245 with SMTP id 108mr45974435qgt.57.1422938787300; Mon, 02 Feb 2015 20:46:27 -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 v5si10799999qae.59.2015.02.02.20.46.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Feb 2015 20:46:27 -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 1YIVNY-0006BL-3m; Tue, 03 Feb 2015 04:46:24 +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 1YIVMp-00061I-ND for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 04:45:39 +0000 Received: by mail-ob0-f178.google.com with SMTP id uz6so20187704obc.9 for ; Mon, 02 Feb 2015 20:45:34 -0800 (PST) X-Received: by 10.60.134.200 with SMTP id pm8mr14427707oeb.61.1422938734470; Mon, 02 Feb 2015 20:45:34 -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.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Feb 2015 20:45:34 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 2 Feb 2015 22:44:55 -0600 Message-Id: <1422938699-12877-16-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 15/19] linux-generic: pktio: 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.44 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 | 11 +++++++---- example/ipsec/odp_ipsec.c | 10 ++++++---- example/l2fwd/odp_l2fwd.c | 11 +++++++---- example/packet/odp_pktio.c | 22 ++++++++++++++-------- .../include/odp/plat/packet_io_types.h | 15 ++++++++++++--- .../linux-generic/include/odp_packet_io_internal.h | 4 ++-- platform/linux-generic/odp_packet.c | 3 ++- platform/linux-generic/odp_packet_io.c | 11 ++++++----- test/validation/odp_pktio.c | 3 ++- 9 files changed, 58 insertions(+), 32 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 03dab50..98dc76d 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -308,7 +308,8 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); + snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", + odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); @@ -319,9 +320,11 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool) if (ret != 0) EXAMPLE_ABORT("Error: default input-Q setup for %s\n", dev); - printf(" created pktio:%02i, dev:%s, queue mode (ATOMIC queues)\n" - " default pktio%02i-INPUT queue:%u\n", - pktio, dev, pktio, inq_def); + printf(" created pktio:%02" PRIu64 + ", dev:%s, queue mode (ATOMIC queues)\n" + " default pktio%02" PRIu64 "-INPUT queue:%u\n", + odp_pktio_to_u64(pktio), dev, + odp_pktio_to_u64(pktio), inq_def); return pktio; } diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 03f2419..f8377e4 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -567,7 +567,8 @@ void initialize_intf(char *intf) qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); + snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", + odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; inq_def = QUEUE_CREATE(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); @@ -595,10 +596,11 @@ void initialize_intf(char *intf) exit(EXIT_FAILURE); } - printf("Created pktio:%02i, queue mode (ATOMIC queues)\n" - " default pktio%02i-INPUT queue:%u\n" + printf("Created pktio:%02" PRIu64 ", queue mode (ATOMIC queues)\n" + " default pktio%02" PRIu64 "-INPUT queue:%u\n" " source mac address %s\n", - pktio, pktio, inq_def, mac_addr_str(src_mac_str, src_mac)); + odp_pktio_to_u64(pktio), odp_pktio_to_u64(pktio), inq_def, + mac_addr_str(src_mac_str, src_mac)); /* Resolve any routes using this interface for output */ resolve_fwd_db(intf, outq_def, src_mac); diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 7a520fb..aeb55ff 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -197,11 +197,12 @@ static void *pktio_ifburst_thread(void *arg) pktio_src = gbl_args->pktios[src_idx]; pktio_dst = gbl_args->pktios[dst_idx]; - printf("[%02i] srcif:%s dstif:%s spktio:%02i dpktio:%02i BURST mode\n", + printf("[%02i] srcif:%s dstif:%s spktio:%02" PRIu64 + " dpktio:%02" PRIu64 " BURST mode\n", thr, gbl_args->appl.if_names[src_idx], gbl_args->appl.if_names[dst_idx], - pktio_src, pktio_dst); + odp_pktio_to_u64(pktio_src), odp_pktio_to_u64(pktio_dst)); /* Loop packets */ for (;;) { @@ -255,7 +256,8 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, return ODP_PKTIO_INVALID; } - printf("created pktio %d (%s)\n", pktio, dev); + printf("created pktio %" PRIu64 " (%s)\n", + odp_pktio_to_u64(pktio), dev); /* no further setup needed for burst mode */ if (mode == APPL_MODE_PKT_BURST) @@ -264,7 +266,8 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); + snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", + odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 28ed98c..ad83968 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -120,7 +120,8 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode) qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); + snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", + odp_pktio_to_u64(pktio)); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); @@ -131,9 +132,11 @@ static odp_pktio_t create_pktio(const char *dev, odp_pool_t pool, int mode) if (ret != 0) EXAMPLE_ABORT("Error: default input-Q setup for %s\n", dev); - printf(" created pktio:%02i, dev:%s, queue mode (ATOMIC queues)\n" - " \tdefault pktio%02i-INPUT queue:%u\n", - pktio, dev, pktio, inq_def); + printf(" created pktio:%02" PRIu64 + ", dev:%s, queue mode (ATOMIC queues)\n" + " \tdefault pktio%02" PRIu64 "-INPUT queue:%u\n", + odp_pktio_to_u64(pktio), dev, + odp_pktio_to_u64(pktio), inq_def); return pktio; } @@ -164,9 +167,11 @@ static void *pktio_queue_thread(void *arg) return NULL; } - printf(" [%02i] looked up pktio:%02i, queue mode (ATOMIC queues)\n" - " default pktio%02i-INPUT queue:%u\n", - thr, pktio, pktio, odp_pktio_inq_getdef(pktio)); + printf(" [%02i] looked up pktio:%02" PRIu64 + ", queue mode (ATOMIC queues)\n" + " default pktio%02" PRIu64 "-INPUT queue:%u\n", + thr, odp_pktio_to_u64(pktio), odp_pktio_to_u64(pktio), + odp_pktio_inq_getdef(pktio)); /* Loop packets */ for (;;) { @@ -242,7 +247,8 @@ static void *pktio_ifburst_thread(void *arg) return NULL; } - printf(" [%02i] looked up pktio:%02i, burst mode\n", thr, pktio); + printf(" [%02i] looked up pktio:%02" PRIu64 ", burst mode\n", + thr, odp_pktio_to_u64(pktio)); /* Loop packets */ for (;;) { diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h b/platform/linux-generic/include/odp/plat/packet_io_types.h index a6bbacf..dfa7cba 100644 --- a/platform/linux-generic/include/odp/plat/packet_io_types.h +++ b/platform/linux-generic/include/odp/plat/packet_io_types.h @@ -18,16 +18,25 @@ extern "C" { #endif +#include +#include + /** @addtogroup odp_packet_io ODP PACKET IO * Operations on a packet. * @{ */ -typedef uint32_t odp_pktio_t; +typedef odp_handle_t odp_pktio_t; + +#define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0) -#define ODP_PKTIO_INVALID 0 +#define ODP_PKTIO_ANY _odp_cast_scalar(odp_pktio_t, ~0) -#define ODP_PKTIO_ANY ((odp_pktio_t)~0) +/** Get printable format of odp_pktio_t */ +static inline uint64_t odp_pktio_to_u64(odp_pktio_t hdl) +{ + return _odp_pri(hdl); +} /** * @} diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 488818c..47b8992 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -68,10 +68,10 @@ extern void *pktio_entry_ptr[]; static inline pktio_entry_t *get_pktio_entry(odp_pktio_t id) { if (odp_unlikely(id == ODP_PKTIO_INVALID || - id > ODP_CONFIG_PKTIO_ENTRIES)) + _odp_typeval(id) > ODP_CONFIG_PKTIO_ENTRIES)) return NULL; - return pktio_entry_ptr[id - 1]; + return pktio_entry_ptr[_odp_typeval(id) - 1]; } #ifdef __cplusplus } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index a031f13..599d768 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -572,7 +572,8 @@ void odp_packet_print(odp_packet_t pkt) len += snprintf(&str[len], n-len, " frame_len %u\n", hdr->frame_len); len += snprintf(&str[len], n-len, - " input %u\n", hdr->input); + " input %" PRIu64 "\n", + odp_pktio_to_u64(hdr->input)); str[len] = '\0'; ODP_PRINT("\n%s\n", str); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index bdb690e..c3336cf 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -73,7 +73,7 @@ int odp_pktio_init_global(void) pktio_entry->s.outq_default = qid; queue_entry = queue_to_qentry(qid); - queue_entry->s.pktout = id; + queue_entry->s.pktout = _odp_cast_scalar(odp_pktio_t, id); } return 0; @@ -146,7 +146,7 @@ static odp_pktio_t alloc_lock_pktio_entry(void) lock_entry_classifier(entry); if (is_free(entry)) { init_pktio_entry(entry); - id = i + 1; + id = _odp_cast_scalar(odp_pktio_t, i + 1); return id; /* return with entry locked! */ } unlock_entry_classifier(entry); @@ -205,7 +205,8 @@ static int init_loop(pktio_entry_t *entry, odp_pktio_t id) char loopq_name[ODP_QUEUE_NAME_LEN]; entry->s.type = ODP_PKTIO_TYPE_LOOPBACK; - snprintf(loopq_name, sizeof(loopq_name), "%i-pktio_loopq", (int)id); + snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq", + odp_pktio_to_u64(id)); entry->s.loopq = odp_queue_create(loopq_name, ODP_QUEUE_TYPE_POLL, NULL); @@ -319,7 +320,7 @@ odp_pktio_t odp_pktio_lookup(const char *dev) odp_spinlock_lock(&pktio_tbl->lock); for (i = 1; i <= ODP_CONFIG_PKTIO_ENTRIES; ++i) { - entry = get_pktio_entry(i); + entry = get_pktio_entry(_odp_cast_scalar(odp_pktio_t, i)); if (is_free(entry)) continue; @@ -327,7 +328,7 @@ odp_pktio_t odp_pktio_lookup(const char *dev) if (!is_free(entry) && strncmp(entry->s.name, dev, IFNAMSIZ) == 0) - id = i; + id = _odp_cast_scalar(odp_pktio_t, i); unlock_entry(entry); diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 84121f5..65274b9 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -234,7 +234,8 @@ static int create_inq(odp_pktio_t pktio) qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; - snprintf(inq_name, sizeof(inq_name), "inq-pktio-%d", pktio); + snprintf(inq_name, sizeof(inq_name), "inq-pktio-%" PRIu64, + odp_pktio_to_u64(pktio)); inq_def = odp_queue_lookup(inq_name); if (inq_def == ODP_QUEUE_INVALID) inq_def = odp_queue_create(inq_name,