From patchwork Tue Nov 10 14:46: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: 56329 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp814188lbb; Tue, 10 Nov 2015 06:51:19 -0800 (PST) X-Received: by 10.140.171.197 with SMTP id r188mr5049663qhr.93.1447167079439; Tue, 10 Nov 2015 06:51:19 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x5si3152482qka.90.2015.11.10.06.51.19; Tue, 10 Nov 2015 06:51:19 -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 0D2C561D5A; Tue, 10 Nov 2015 14:51:19 +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 D280661D15; Tue, 10 Nov 2015 14:48:22 +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 329A661CEB; Tue, 10 Nov 2015 14:48:11 +0000 (UTC) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by lists.linaro.org (Postfix) with ESMTPS id 1063561D14 for ; Tue, 10 Nov 2015 14:47:09 +0000 (UTC) Received: by pabfh17 with SMTP id fh17so236563938pab.0 for ; Tue, 10 Nov 2015 06:47:08 -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=fhm169YreoBvUvxBmzih/wSI2B8guY8TkIKZNRu87GDa6bnRcEXhkxVKHhuaRghCsq Pe7qwLkMcLe04jnBy+6mOcPWFuFvHfcpFwZ2p33c54SPLE0ewgAckvkGqCKEDFNkdLv8 7oRMwssb+yF4AoABd12jRO0Im9O3c6X68gjgSPY4VtR1zNLgDgIupRCydBFxXAGWBa6o PLDDrcbbV2vnp+cKOOnMtR9Z9EjEMKN2OsdG4IMtg6j05aOr41xTQM/6s03yRfHtTEEh Ok7N5ZLj533dWqkkLLpIdmYyPGKEEWTBYW2U/LYYY/21YsZ4EVHjvkvCnQ6UuHw7C9JZ 4gXA== 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=e4TuhUquqGgl4rEi4cVAWAtnC/iW+moEHS8TWuRMDD8aZGKo3jmwF7Ba6qhsDkVjCk EJiV0oZ+DVtTZ3uisoS/lN5SzFuwgALTTHUeyRyWk6jemInIGdknutx9jNwZeX/bfgFW bCJHJIxu/2gg7dhxXuvJHJKcS57Z5HguSlAjYqxnhmLLGAUgcdtZdWs6b4sgbdc5EUwj IRhAevlc9n6j33g4ztEUVg6zRiUke0ZnxgV7PQJIY+uxxZZdIfeGbNQDmQfCjiptqYiO O8JLqQhoohcofb9Wx99JRuIi+KqXiv9cux93/VskBO6rBosw2B9XVvKH5KLycUXrvlB2 CIXw== X-Gm-Message-State: ALoCoQmOv+ybdzHMlTHU+vZXJbglOi/FvLI6A1J7Duw9sjNKLgDALf4hH5sQypxQPozMik5w0JVB X-Received: by 10.66.146.162 with SMTP id td2mr6078859pab.45.1447166828356; Tue, 10 Nov 2015 06:47:08 -0800 (PST) Received: from Ubuntu15.localdomain ([40.139.248.3]) by smtp.gmail.com with ESMTPSA id w11sm4531237pbs.87.2015.11.10.06.47.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Nov 2015 06:47:07 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 10 Nov 2015 06:46:55 -0800 Message-Id: <1447166821-24585-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447166821-24585-1-git-send-email-bill.fischofer@linaro.org> References: <1447166821-24585-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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];