From patchwork Sun Nov 8 20:42:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 56161 Delivered-To: patch@linaro.org Received: by 10.112.1.169 with SMTP id 9csp126975lbn; Sun, 8 Nov 2015 12:43:32 -0800 (PST) X-Received: by 10.55.78.143 with SMTP id c137mr25411408qkb.72.1447015412722; Sun, 08 Nov 2015 12:43:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u9si8604713qku.29.2015.11.08.12.43.32; Sun, 08 Nov 2015 12:43:32 -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 6771861973; Sun, 8 Nov 2015 20:43:32 +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 67AB761975; Sun, 8 Nov 2015 20:42:25 +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 5CF1461947; Sun, 8 Nov 2015 20:42:18 +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 6FC1261942 for ; Sun, 8 Nov 2015 20:42:17 +0000 (UTC) Received: by ykba4 with SMTP id a4so236023078ykb.3 for ; Sun, 08 Nov 2015 12:42:17 -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=V4m1pzY0f4bS0gvQKqzUoOJmgcFXgiDkCKlaeFosn7u7R+W0nH5bXCwaVlLu/lnJ+f wWGWX/TJ+roHYRS3Gtln0wgJnvzYG5ldyAg/VpSG56v4B3xHBwu8SCe4IoUjun3a54Gz 2+kXsUSM9QrU51y97/N5i0oGUby4lPzoJZAnIVSjfDVWNh3UcVu8acH7zumY0wLwmP35 BnQ48dygo/IVAzxWYfnNfcOAiW8LYeTUU9hwNXtwCaQqOaMqHqtISo/4OeRAe/nTIyB2 D80/kH2OzQCCI3NGCWp//MSzyZjMO92XEmoOXTIK1GOk/kQDUDeVQXn+npy1uy75d8Yx HKwg== 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=UvU/aVTcAgjd8LvCgz+mgJg1eAKtcJhyn26ypY99QWx+W7F5XXbJM9VEo4oOanMy2G 6DaPe/j+r31ZkpHa5FlJ11r3ZHEgEkiRDl+1hexA10tYsomk/ZTrYSL7rKg2snPdo3U+ mUA+pHll5Xvvfh99/FdKouEZRA8RgWS1Wo+Rbd8tx6tE6DJCUSuovvGxEdVfqa7aGQJ5 wSPRX50DZEdreglyIKSGHeD3lSvJoo45UF9nIzIbf2WEV6tcOi6d0rwsTAvfZJoT4Ebi YWRgppQgUczHvIpd08oheSD5lZj2xOsQ4knby4ZqvdgPalAe7BqAr6BAu/pXVTCSHSYp iS+Q== X-Gm-Message-State: ALoCoQm+V2GoWAtskpzAUkVtQq8ujDTgQcj0S40fS/LgSF+n9T4z7slto2Onn10dpdXfKWf2XHK0 X-Received: by 10.129.51.17 with SMTP id z17mr19559063ywz.148.1447015337166; Sun, 08 Nov 2015 12:42:17 -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 f133sm10270399ywa.27.2015.11.08.12.42.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Nov 2015 12:42:16 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 8 Nov 2015 14:42:06 -0600 Message-Id: <1447015330-24420-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447015330-24420-1-git-send-email-bill.fischofer@linaro.org> References: <1447015330-24420-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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];