From patchwork Thu Apr 14 21:06:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 65849 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp825284qge; Thu, 14 Apr 2016 14:07:19 -0700 (PDT) X-Received: by 10.140.176.23 with SMTP id w23mr22155844qhw.76.1460668039381; Thu, 14 Apr 2016 14:07:19 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z17si10445597qka.125.2016.04.14.14.07.19; Thu, 14 Apr 2016 14:07:19 -0700 (PDT) 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; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 08E026854B; Thu, 14 Apr 2016 21:07: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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 D5F93685D0; Thu, 14 Apr 2016 21:06:48 +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 9AEF3684E6; Thu, 14 Apr 2016 21:06:45 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by lists.linaro.org (Postfix) with ESMTPS id D9660684D7 for ; Thu, 14 Apr 2016 21:06:44 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id p188so105994278oih.2 for ; Thu, 14 Apr 2016 14:06:44 -0700 (PDT) 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=EOeSEdqatEOX1pJ1HJo96nYqH0bzcNZr7yNUdYCbvLk=; b=c+EMiQXFyRDGSA93LaQAzlsz7PowQ8uvKoCFiIpVNHaIcylgakxsv0/wnE8hPKTwHo 5HK+s0nR6BXuDM77I5SjcVpCOmVGlU//XhzX1bfN0jbH5OfLDZ8ljSazvm4amaCHG/36 xHjedl1UG1eYGJxIjKRJ6qH0s9SsIKdKn5QVoxJyyvHSxa8yA5gsGOtdhFEDFCDaaT+a zGEKbyW2lGAlQ0mtyHDKTXpRg7uP4zxDfjRBxOEka0CdTsuYP6iMV7GaO4advbdWR8sE tNd6OcIPU3p5lo7K1W4cJujZSKFhleGJ4+6ROrdytukIIwH7fUz79hcJDI0+0PpfugJN OCAw== X-Gm-Message-State: AOPr4FUhK8XHDGqGb1OPfCvXHfYdzUsHGn3Z0rxTCFSXwu+geA8d2d3h90FqWtWOBkk8q5GUAWY= X-Received: by 10.157.43.104 with SMTP id f37mr8380344otd.77.1460668004435; Thu, 14 Apr 2016 14:06:44 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id xm14sm13871138oeb.17.2016.04.14.14.06.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Apr 2016 14:06:43 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 14 Apr 2016 16:06:37 -0500 Message-Id: <1460668001-25533-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460668001-25533-1-git-send-email-bill.fischofer@linaro.org> References: <1460668001-25533-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 2/6] linux-generic: pktio: implement pktio index conversion functions 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 --- platform/linux-generic/odp_packet_io.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 574f987..41d93e1 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -921,6 +921,24 @@ int odp_pktio_info(odp_pktio_t id, odp_pktio_info_t *info) return 0; } +int odp_pktio_to_index(odp_pktio_t pktio) +{ + pktio_entry_t *entry = get_pktio_entry(pktio); + + if (!entry || is_free(entry)) + return -1; + + return pktio_to_id(pktio); +} + +odp_pktio_t odp_pktio_from_index(int ndx) +{ + if (ndx < 0 || ndx > ODP_CONFIG_PKTIO_ENTRIES) + return ODP_PKTIO_INVALID; + + return _odp_cast_scalar(odp_pktio_t, ndx + 1); +} + void odp_pktio_print(odp_pktio_t id) { pktio_entry_t *entry;