From patchwork Tue Nov 10 04:20:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 56277 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp549800lbb; Mon, 9 Nov 2015 20:21:39 -0800 (PST) X-Received: by 10.107.129.144 with SMTP id l16mr1747332ioi.174.1447129299696; Mon, 09 Nov 2015 20:21:39 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id xh11si14092365igb.40.2015.11.09.20.21.39; Mon, 09 Nov 2015 20:21:39 -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 2190861D0E; Tue, 10 Nov 2015 04:21:39 +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=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, 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 AD4C661CEF; Tue, 10 Nov 2015 04:20:31 +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 9073161CDE; Tue, 10 Nov 2015 04:20:26 +0000 (UTC) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by lists.linaro.org (Postfix) with ESMTPS id 2A72361CB1 for ; Tue, 10 Nov 2015 04:20:25 +0000 (UTC) Received: by padhx2 with SMTP id hx2so212870592pad.1 for ; Mon, 09 Nov 2015 20:20:24 -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=kq6mu+FBAr/0ew60nbolxiCG+UEBMJ4eZOc9gO17n7/kEmrtBeFyJyiDd7CXKJKH0T 8USP+y8PyCNt9lKwnPUD1qmRinBnG8dhIs9ACRxKMUTQocLnBt/Mf/TIJRLStqSNXPb0 zN8s2wfopLwAsJMIO1zKBn1T5mxZla6prILn0BSTbzQ1mba1Mib4Q+g8A7QfyBoBZqs7 8yOQRgzMA6D2o2C+7iOOucKLw2xzaGyz3SxyOhP73ZfmbJ+GMpms6BAkURE7+kVar589 1mmvaDUcGofO8pG9l1gyX5EuOXwcTiPYlyS5C2+m5zwYH3AAjsXGsyXmlS3SeVkqYhF9 Z2LA== 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=jhGGA969V59cc9W851zEO4o86of+CaCBdDPx+UQCDGJWBM+FPm6g94Q9yeZHECtmRc AxR96r5zA1nqC52TmMpodncY22hIiQNWtPx2ke2RuDDrNv++9Cr9sEQsHWMw1nj5NLM2 uWUMVN5KT7IQcGLiLElPh+UNIxBLD14AsuKIjtOh65y2F3fqpEDaxcgDnbntMfX35XJK xzAM1ZNizEnXVRIIy8kYU+WMxmv8ZU2O9PRmLgJIaNF39xBeuEt+plu93N7TEdYCij5v VxdRs1KGCdr39CM6xa27RsRKdmcqZ+KDCi62Tadfx5tqMHIaNlchGYkSnHnv9ZKe+bVe 3P4w== X-Gm-Message-State: ALoCoQm6QSqIhO4cyz0hPcySqHM2F72Q+O+hKFnAfaUv5pDGA4fpZU31NnniC3IPSFfON2uDCy2j X-Received: by 10.66.246.201 with SMTP id xy9mr2436047pac.31.1447129224464; Mon, 09 Nov 2015 20:20:24 -0800 (PST) Received: from Ubuntu15.localdomain ([40.139.248.3]) by smtp.gmail.com with ESMTPSA id fl5sm1137315pbd.70.2015.11.09.20.20.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Nov 2015 20:20:23 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 9 Nov 2015 20:20:05 -0800 Message-Id: <1447129211-9095-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447129211-9095-1-git-send-email-bill.fischofer@linaro.org> References: <1447129211-9095-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 2/8] 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];