From patchwork Mon Dec 8 12:02:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 42000 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BB670202E0 for ; Mon, 8 Dec 2014 12:04:38 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf2721034eek.4 for ; Mon, 08 Dec 2014 04:04:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=7LqLDl6dbrx5WhuKcYEyWLRZsWs6P7PmbspWunZklAk=; b=liW2GUMTltJXT7H+ygbd7TyYBIsVh3NRjs3c4uUraSiPsn7NIUjtiFAyBTMAxCOx30 GAcpgaZbtLNLdKY8d0uJKU/xD7tqv50PXjl7tJP9ZirK37j2zOxYlbCWiCw5BRKAdr/x yJr+RmFfi7HlnXcG5bBnaCOhNbPooNwlYJUySx9aQ8ByWIMF6sqC4yeBBWx9edS8Sfgm jv+tX6LLl2pFBKzEAducp9Q8MwR+gdQjjRs4MFVLanEdRV72k2rIg5gcxhbjVcq8i4px sfKg+mp3ehy32gyW5D5SloSffkInHktMX9nachP9Sjelw3JjvceHYNH8sCUvyDFCVD4r ux+Q== X-Gm-Message-State: ALoCoQksu7q7NDNcKEBh1VnWiWyR6pSvle1XyDp8xYUiz6eRqjTsDVqlS8mHKEHWm8j6CB1nHKBh X-Received: by 10.180.101.40 with SMTP id fd8mr3388702wib.5.1418040278005; Mon, 08 Dec 2014 04:04:38 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.71 with SMTP id da7ls622821lad.31.gmail; Mon, 08 Dec 2014 04:04:37 -0800 (PST) X-Received: by 10.152.205.74 with SMTP id le10mr15798534lac.96.1418040277708; Mon, 08 Dec 2014 04:04:37 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id g1si36782149lah.45.2014.12.08.04.04.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 04:04:37 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hs14so3754761lab.25 for ; Mon, 08 Dec 2014 04:04:37 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr15959064laz.71.1418040277612; Mon, 08 Dec 2014 04:04:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp591177lbc; Mon, 8 Dec 2014 04:04:36 -0800 (PST) X-Received: by 10.229.235.194 with SMTP id kh2mr51621906qcb.10.1418040275845; Mon, 08 Dec 2014 04:04:35 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id c12si43024238qae.103.2014.12.08.04.04.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 08 Dec 2014 04:04:35 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xxx3H-0006iz-A0; Mon, 08 Dec 2014 12:04:31 +0000 Received: from mail-ig0-f172.google.com ([209.85.213.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xxx38-0006iX-NV for lng-odp@lists.linaro.org; Mon, 08 Dec 2014 12:04:22 +0000 Received: by mail-ig0-f172.google.com with SMTP id hl2so2573370igb.17 for ; Mon, 08 Dec 2014 04:04:17 -0800 (PST) X-Received: by 10.107.12.234 with SMTP id 103mr10399305iom.71.1418040257311; Mon, 08 Dec 2014 04:04:17 -0800 (PST) Received: from bala-PowerEdge-T110-II.caveonetworks.com ([111.93.218.67]) by mx.google.com with ESMTPSA id b2sm16103616ioe.2.2014.12.08.04.04.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 04:04:16 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Mon, 8 Dec 2014 17:32:55 +0530 Message-Id: <1418040176-9134-2-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418040176-9134-1-git-send-email-bala.manoharan@linaro.org> References: <1418040176-9134-1-git-send-email-bala.manoharan@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v6 2/3] linux-generic:pktio:move static inline functions to header X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bala.manoharan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Moves static inline access functions in pktio module to header file. This changes is required as these functions are accessed by classification module Signed-off-by: Balasubramanian Manoharan Reviewed-by: Bill Fischofer Reviewed-by: Ciprian Barbu --- .../linux-generic/include/odp_packet_io_internal.h | 17 ++++++++++ platform/linux-generic/odp_packet_io.c | 38 ++++++++-------------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 7819dc7..d129f22 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -22,6 +22,8 @@ extern "C" { #include #include +#include +#include #include /** @@ -50,6 +52,21 @@ typedef union { uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pktio_entry))]; } pktio_entry_t; +typedef struct { + pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; +} pktio_table_t; + +extern void *pktio_entry_ptr[]; + + +static inline pktio_entry_t *get_pktio_entry(odp_pktio_t id) +{ + if (odp_unlikely(id == ODP_PKTIO_INVALID || + id > ODP_CONFIG_PKTIO_ENTRIES)) + return NULL; + + return pktio_entry_ptr[id - 1]; +} #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 7e3eca2..19b9eea 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -22,21 +22,10 @@ #include #include -typedef struct { - pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; -} pktio_table_t; - static pktio_table_t *pktio_tbl; - -static pktio_entry_t *get_entry(odp_pktio_t id) -{ - if (odp_unlikely(id == ODP_PKTIO_INVALID || - id > ODP_CONFIG_PKTIO_ENTRIES)) - return NULL; - - return &pktio_tbl->entries[id - 1]; -} +/* pktio pointer entries ( for inlines) */ +void *pktio_entry_ptr[ODP_CONFIG_PKTIO_ENTRIES]; int odp_pktio_init_global(void) { @@ -58,10 +47,11 @@ int odp_pktio_init_global(void) memset(pktio_tbl, 0, sizeof(pktio_table_t)); for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) { - pktio_entry = get_entry(id); + pktio_entry = &pktio_tbl->entries[id - 1]; odp_spinlock_init(&pktio_entry->s.lock); + pktio_entry_ptr[id - 1] = pktio_entry; /* Create a default output queue for each pktio resource */ snprintf(name, sizeof(name), "%i-pktio_outq_default", (int)id); name[ODP_QUEUE_NAME_LEN-1] = '\0'; @@ -140,7 +130,7 @@ static odp_pktio_t alloc_lock_pktio_entry(void) static int free_pktio_entry(odp_pktio_t id) { - pktio_entry_t *entry = get_entry(id); + pktio_entry_t *entry = get_pktio_entry(id); if (entry == NULL) return -1; @@ -164,7 +154,7 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) } /* if successful, alloc_pktio_entry() returns with the entry locked */ - pktio_entry = get_entry(id); + pktio_entry = get_pktio_entry(id); if (!pktio_entry) return ODP_PKTIO_INVALID; @@ -216,7 +206,7 @@ int odp_pktio_close(odp_pktio_t id) pktio_entry_t *entry; int res = -1; - entry = get_entry(id); + entry = get_pktio_entry(id); if (entry == NULL) return -1; @@ -255,7 +245,7 @@ odp_pktio_t odp_pktio_get_input(odp_packet_t pkt) int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) { - pktio_entry_t *pktio_entry = get_entry(id); + pktio_entry_t *pktio_entry = get_pktio_entry(id); int pkts; int i; @@ -293,7 +283,7 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) { - pktio_entry_t *pktio_entry = get_entry(id); + pktio_entry_t *pktio_entry = get_pktio_entry(id); int pkts; if (pktio_entry == NULL) @@ -323,7 +313,7 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) { - pktio_entry_t *pktio_entry = get_entry(id); + pktio_entry_t *pktio_entry = get_pktio_entry(id); queue_entry_t *qentry; if (pktio_entry == NULL || queue == ODP_QUEUE_INVALID) @@ -355,7 +345,7 @@ int odp_pktio_inq_remdef(odp_pktio_t id) odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) { - pktio_entry_t *pktio_entry = get_entry(id); + pktio_entry_t *pktio_entry = get_pktio_entry(id); if (pktio_entry == NULL) return ODP_QUEUE_INVALID; @@ -365,7 +355,7 @@ odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id) { - pktio_entry_t *pktio_entry = get_entry(id); + pktio_entry_t *pktio_entry = get_pktio_entry(id); if (pktio_entry == NULL) return ODP_QUEUE_INVALID; @@ -495,7 +485,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) return -1; } - entry = get_entry(id); + entry = get_pktio_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); return -1; @@ -525,7 +515,7 @@ int odp_pktio_mtu(odp_pktio_t id) struct ifreq ifr; int ret; - entry = get_entry(id); + entry = get_pktio_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); return -1;