From patchwork Wed Feb 21 11:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 129048 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp548614ljc; Wed, 21 Feb 2018 04:09:59 -0800 (PST) X-Google-Smtp-Source: AH8x224kMb1VnUjvuAiNVjCFRBKSwRejyVrQp6HOXAZ76MBx3lQy7Xpnv3EO062BljjnAwzqXFf+ X-Received: by 10.200.41.18 with SMTP id y18mr5031320qty.181.1519214999164; Wed, 21 Feb 2018 04:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519214999; cv=none; d=google.com; s=arc-20160816; b=EIK5sAku2FPq5SJ+olkIcXEhCOTqLofBs2E1LMNfNxl9Wuj6urLos9cPLdthTlAvq2 NLOG/XGLN24wIzGl3QTXhS9H/jeh8Y2BcgmTvFEbxiix4QZfina95JXtT6I7wIOoF4AW fBQh+OedNIhotaYQf7J1x6dcJAPn+A4WnA9GY5qJ7Tm7NSZ979twpEKlhUFhVGIN6GkR RI+85FTqCwz0ucMusnH2UxPYA9zjvGFNoJmgvKXa4BnvOr4CkDXai67R1jlagbplWRUI vDTMvjG6Z8Mrh2aJxplYIoTjQMj+44wMZps/R4XdyCeX5+XvouMbLvfQR1H6fC/RVE2c P+RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=NdtJ1aXwjxNFRe7hf/Bng3JRhk8yeBMoEvr4mWHxT4E=; b=VmOW7hyMkkzzBwx0/DLUg8a3aGP0Fy/apb2KZDz9LycK9syIopJXjFew2lNjLmzitx e2iAqHJdFpnhplg/+L54U5U9CA6U4ij29WhgzXGerZ+8K9dRryPuC+wNLG02p0DQAPsD LnqltQVtlhF5MVqmwFIriH6iZ0n7/Y0FZUT8bXR4Ymr0ONVEFdp+0C6VqEZyIaXH3YTM fRqLipYpt6LOFoN1KvRGCayY6i4oX0RpNPNLWpsEVcC5py9sxYgkpACiMOUjimvSx5An u4Hk0IbOHYlvBxqZG0MBmPeTPaq2mM6LNWf6/jvzGOGwHGRW1iTX4jgNlkUr8ruISsty 0t/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id y186si378083qkd.306.2018.02.21.04.09.58; Wed, 21 Feb 2018 04:09:59 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id D3B586176B; Wed, 21 Feb 2018 12:09:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4561A6173E; Wed, 21 Feb 2018 12:02:33 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C141260750; Wed, 21 Feb 2018 12:02:06 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 38A4060750 for ; Wed, 21 Feb 2018 12:01:08 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 723B55105B29 for ; Wed, 21 Feb 2018 15:00:09 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id LtX1oeOB62-09dOqIOg; Wed, 21 Feb 2018 15:00:09 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id a6UlmCoovI-08v8LoHk; Wed, 21 Feb 2018 15:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Wed, 21 Feb 2018 14:59:58 +0300 Message-Id: <1519214407-28047-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519214407-28047-1-git-send-email-odpbot@yandex.ru> References: <1519214407-28047-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 492 Subject: [lng-odp] [PATCH v1 1/10] linux-gen: queue: inline queue from index conversion X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Inline queue handle from queue index conversion function. Signed-off-by: Petri Savolainen --- /** Email created from pull request 492 (psavol:master-sched-optim) ** https://github.com/Linaro/odp/pull/492 ** Patch: https://github.com/Linaro/odp/pull/492.patch ** Base sha: 5a58bbf2bb331fd7dde2ebbc0430634ace6900fb ** Merge commit sha: 82a6bfe942419330a430b63149220e6b472f419c **/ .../linux-generic/include/odp_queue_internal.h | 7 ++++- platform/linux-generic/odp_queue.c | 30 +++++++--------------- platform/linux-generic/odp_schedule.c | 5 +--- platform/linux-generic/odp_schedule_iquery.c | 2 +- platform/linux-generic/odp_schedule_sp.c | 3 ++- 5 files changed, 19 insertions(+), 28 deletions(-) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 158b1d5f1..6fe3fb462 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -62,11 +62,16 @@ union queue_entry_u { uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct queue_entry_s))]; }; -static inline uint32_t queue_to_id(odp_queue_t handle) +static inline uint32_t queue_to_index(odp_queue_t handle) { return _odp_typeval(handle) - 1; } +static inline odp_queue_t queue_from_index(uint32_t queue_id) +{ + return _odp_cast_scalar(odp_queue_t, queue_id + 1); +} + static inline queue_entry_t *qentry_from_int(queue_t q_int) { return (queue_entry_t *)(void *)(q_int); diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 58103930c..21135df63 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -45,26 +45,19 @@ typedef struct queue_table_t { static queue_table_t *queue_tbl; -static -queue_entry_t *get_qentry(uint32_t queue_id); +static queue_entry_t *get_qentry(uint32_t queue_id); -static inline queue_entry_t *handle_to_qentry(odp_queue_t handle) +static inline queue_entry_t *get_qentry(uint32_t queue_id) { - uint32_t queue_id; - - queue_id = queue_to_id(handle); - return get_qentry(queue_id); + return &queue_tbl->queue[queue_id]; } -static inline odp_queue_t queue_from_id(uint32_t queue_id) +static inline queue_entry_t *handle_to_qentry(odp_queue_t handle) { - return _odp_cast_scalar(odp_queue_t, queue_id + 1); -} + uint32_t queue_id; -static -queue_entry_t *get_qentry(uint32_t queue_id) -{ - return &queue_tbl->queue[queue_id]; + queue_id = queue_to_index(handle); + return get_qentry(queue_id); } static int queue_init_global(void) @@ -90,7 +83,7 @@ static int queue_init_global(void) queue_entry_t *queue = get_qentry(i); LOCK_INIT(&queue->s.lock); queue->s.index = i; - queue->s.handle = queue_from_id(i); + queue->s.handle = queue_from_index(i); } ODP_DBG("done\n"); @@ -620,7 +613,7 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return -1; } - queue_id = queue_to_id(handle); + queue_id = queue_to_index(handle); if (odp_unlikely(queue_id >= ODP_CONFIG_QUEUES)) { ODP_ERR("Invalid queue handle:%" PRIu64 "\n", @@ -648,11 +641,6 @@ static int queue_info(odp_queue_t handle, odp_queue_info_t *info) return 0; } -odp_queue_t sched_cb_queue_handle(uint32_t queue_index) -{ - return queue_from_id(queue_index); -} - int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num) { queue_entry_t *qe = get_qentry(queue_index); diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 118f9eb17..0a12487e9 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -25,10 +25,7 @@ #include #include #include - -/* Should remove this dependency */ #include -#include /* Number of priority levels */ #define NUM_PRIO 8 @@ -876,7 +873,7 @@ static inline int do_schedule_grp(odp_queue_t *out_queue, odp_event_t out_ev[], continue; } - handle = sched_cb_queue_handle(qi); + handle = queue_from_index(qi); sched_local.num = num; sched_local.index = 0; sched_local.queue = handle; diff --git a/platform/linux-generic/odp_schedule_iquery.c b/platform/linux-generic/odp_schedule_iquery.c index 33767c1f8..c41eb857d 100644 --- a/platform/linux-generic/odp_schedule_iquery.c +++ b/platform/linux-generic/odp_schedule_iquery.c @@ -1529,7 +1529,7 @@ static inline int consume_queue(int prio, unsigned int queue_index) cache->top = &cache->stash[0]; cache->count = count; - cache->queue = sched_cb_queue_handle(queue_index); + cache->queue = queue_from_index(queue_index); return count; } diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index 017eaee34..01a3d4948 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -18,6 +18,7 @@ #include #include #include +#include #define NUM_THREAD ODP_THREAD_COUNT_MAX #define NUM_QUEUE ODP_CONFIG_QUEUES @@ -564,7 +565,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait, sched_local.cmd = cmd; if (from) - *from = sched_cb_queue_handle(qi); + *from = queue_from_index(qi); return num; }