From patchwork Sun Nov 8 20:25:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 56155 Delivered-To: patch@linaro.org Received: by 10.112.1.169 with SMTP id 9csp122005lbn; Sun, 8 Nov 2015 12:26:57 -0800 (PST) X-Received: by 10.55.73.18 with SMTP id w18mr25777146qka.95.1447014416929; Sun, 08 Nov 2015 12:26:56 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y75si8535589qka.91.2015.11.08.12.26.56; Sun, 08 Nov 2015 12:26:56 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 8439F6195B; Sun, 8 Nov 2015 20:26:56 +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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED 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 8A12661973; Sun, 8 Nov 2015 20:25:53 +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 BEAB061959; Sun, 8 Nov 2015 20:25:46 +0000 (UTC) Received: from mail-yk0-f174.google.com (mail-yk0-f174.google.com [209.85.160.174]) by lists.linaro.org (Postfix) with ESMTPS id DEA2A61941 for ; Sun, 8 Nov 2015 20:25:44 +0000 (UTC) Received: by ykba4 with SMTP id a4so235711185ykb.3 for ; Sun, 08 Nov 2015 12:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f3vHZ1CSE6MGMlcZOK0Qfaif7cQ8QEmjPysftvS3z1M=; b=izJTptNO/hdES1Q5u35lRQKf/mtv70GvPtQ3l/SG30CrMVMO5nJDWH0ebk0+gjNqyq TJWShHPlzhPVvXll34LLAW3f7bMxQKa3T4Bd2fMjy2XX7eoJ0VCeyoV93twMqKjnwPrN LO7JvAxewNJLk0liPosn07Gh1Z+QqL4/Lykrre4mZKBeqStPuSEPYB+dU6HNO4Xyr+wr OVbgx6tXpvhlrqu8xMI/nkllU0rXPfAkUWgp1tmLlVc0AIWEaWmYHKhHM7jbrj/rl0yg PSoFg8x8SsVmyjpEFosflUeeJeNU0wUE4W7lwQYk7PD7rFknoSp8A5NDKjPBTBnp1qIt 49hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f3vHZ1CSE6MGMlcZOK0Qfaif7cQ8QEmjPysftvS3z1M=; b=iEz5oCUPnZ/OI5MPOetyNC9HegJ6iXlnayjybjNLh8/ARBSvpiJCi5oC5UbwtPq0cp WtSsEj/Ca7vl6gRjMjTSWm7AQk86t52u4dS3V+zi2glBnqjiTx833bl+EVTmRefi3AwK jAgWePFArEFWvCaEXjKJ60CLRYo3MNGDdAoYmpVlweTSvh45cSoqZbIf623RTUi3muJp NwmQ9EB58+aNEvv3jbpGfv0um3gYfSe8uf3cZzpH0Y6h4sqQ8u8nqZhibrMJ4g4rgkei X0qA1WHE2qOkhN+mzZLA7/BQisAEx9YJ23GOXsqP/jghWHt/ldrkyEF2V8okrur35CYt DrvA== X-Gm-Message-State: ALoCoQk/dZEx1tAi4uibYu+JtA4lq+DUWEqSdCbTy2mCc27/GNY1wrDIM/xAh2XHaIrLWOix484W X-Received: by 10.129.101.134 with SMTP id z128mr2645736ywb.92.1447014344621; Sun, 08 Nov 2015 12:25:44 -0800 (PST) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id h83sm7362134ywc.6.2015.11.08.12.25.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Nov 2015 12:25:44 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 8 Nov 2015 14:25:34 -0600 Message-Id: <1447014338-6409-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447014338-6409-1-git-send-email-bill.fischofer@linaro.org> References: <1447014338-6409-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/6] linux-generic: queue: add utility functions for restructure 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Bill Fischofer --- .../linux-generic/include/odp_queue_internal.h | 44 ++++++++++++++++++++++ platform/linux-generic/odp_queue.c | 7 ++++ 2 files changed, 51 insertions(+) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 6322948..32e3288 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -159,6 +159,50 @@ static inline int queue_prio(queue_entry_t *qe) return qe->s.param.sched.prio; } +static inline odp_buffer_hdr_t *get_buf_tail(odp_buffer_hdr_t *buf_hdr) +{ + odp_buffer_hdr_t *buf_tail = buf_hdr->link ? buf_hdr->link : buf_hdr; + + buf_hdr->next = buf_hdr->link; + buf_hdr->link = NULL; + + while (buf_tail->next) + buf_tail = buf_tail->next; + + return buf_tail; +} + +static inline void queue_add(queue_entry_t *queue, + odp_buffer_hdr_t *buf_hdr) +{ + buf_hdr->next = NULL; + + if (queue->s.head) + queue->s.tail->next = buf_hdr; + else + queue->s.head = buf_hdr; + + queue->s.tail = buf_hdr; +} + +static inline void queue_add_list(queue_entry_t *queue, + odp_buffer_hdr_t *buf_head, + odp_buffer_hdr_t *buf_tail) +{ + if (queue->s.head) + queue->s.tail->next = buf_head; + else + queue->s.head = buf_head; + + queue->s.tail = buf_tail; +} + +static inline void queue_add_chain(queue_entry_t *queue, + odp_buffer_hdr_t *buf_hdr) +{ + queue_add_list(queue, buf_hdr, get_buf_tail(buf_hdr)); +} + static inline void reorder_enq(queue_entry_t *queue, uint64_t order, queue_entry_t *origin_qe, diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 2071870..bcc8190 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -69,6 +69,13 @@ static inline void get_qe_locks(queue_entry_t *qe1, queue_entry_t *qe2) } } +static inline void free_qe_locks(queue_entry_t *qe1, queue_entry_t *qe2) +{ + UNLOCK(&qe1->s.lock); + if (qe1 != qe2) + UNLOCK(&qe2->s.lock); +} + queue_entry_t *get_qentry(uint32_t queue_id) { return &queue_tbl->queue[queue_id];