From patchwork Fri Jan 8 20:30:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 59405 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp757064lbb; Fri, 8 Jan 2016 11:51:30 -0800 (PST) X-Received: by 10.141.23.195 with SMTP id z186mr153948481qhd.52.1452282689757; Fri, 08 Jan 2016 11:51:29 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 195si55758459qhy.17.2016.01.08.11.51.29; Fri, 08 Jan 2016 11:51:29 -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 Received: by lists.linaro.org (Postfix, from userid 109) id 3030361648; Fri, 8 Jan 2016 19:51:29 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=UAO+A7CJ; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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 E0DF561C8B; Fri, 8 Jan 2016 19:37:44 +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 968EC617B4; Fri, 8 Jan 2016 19:35:24 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 4142861C83 for ; Fri, 8 Jan 2016 19:31:56 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id m198so33834972lfm.0 for ; Fri, 08 Jan 2016 11:31:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F14VbJyfqYe0YQnzsUfcz9UK47HAynf8DvzA5OI7MMc=; b=UAO+A7CJxm0/SGPllroP0KNHkf7Zk8IfZQZeh0F2T3yTrvdsfJDcJDKcCtZhyotWhz vrMcOEp192r20ejycSDiOmY7UHi2TrZknqfkFVjfQOVn5jHoI1cGETz8XB30EqtZemVn at6YpREUZI04P8bFKS6w0PzjMSioOkASgg17w= 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=F14VbJyfqYe0YQnzsUfcz9UK47HAynf8DvzA5OI7MMc=; b=en6WXzoGDBA5huIQATFwNRMz8BT2ZnJYc52DIwlWitKr/P86RVx0dBTSY0BvryU5Z7 ysK6Sxit5uUNuovw+AIelgdpqIA97WFG4UCHlXR7yQM5bxkUdSFTWzIt3dCEizOIbw8e oVWJRC501dOofTN/pveKjugl/iyYTRbZ+9qr8bE2g4eHVeM5AKIJ9jkwLjIqq8eerM42 vV1t+owhajRmyUgDKHvHYwLsEKP0+p49B0N0K5iOAfXnO7YRrYHVzEEHATaf2rTTSHsp +12IKazcybV0vkHlaRruMt6C3B3llf57yqyr2d9M/u+MEddm+bBEucjIKpMcko/CN/pL yIYw== X-Gm-Message-State: ALoCoQkpnK4FFF8+oc4QTj6mMfOVcbqPHuCT9wN3kqjJ9/Y7r++KuyGgwiPJjj2NDQNWmfqjmi2E9TuiU7d0cjuf+rRFsGnk4Q== X-Received: by 10.25.17.32 with SMTP id g32mr43404214lfi.38.1452281515153; Fri, 08 Jan 2016 11:31:55 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id l204sm2085534lfg.49.2016.01.08.11.31.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 11:31:54 -0800 (PST) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org, bill.fischofer@linaro.org, petri.savolainen@linaro.org, edavis@broadcom.com Date: Fri, 8 Jan 2016 21:30:01 +0100 Message-Id: <1452285014-60320-19-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> References: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [API-NEXT RFC 18/31] linux-generic: nic pktio: adding tx and rx 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: Christophe Milard --- platform/linux-generic/include/odp_nic_internal.h | 5 ++++ platform/linux-generic/pktio/nic.c | 31 +++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_nic_internal.h b/platform/linux-generic/include/odp_nic_internal.h index 4f0f137..5ced7e8 100644 --- a/platform/linux-generic/include/odp_nic_internal.h +++ b/platform/linux-generic/include/odp_nic_internal.h @@ -48,6 +48,11 @@ int driver_probe(odp_pktio_t pktio, const char *pci_address, odp_pool_t pool); */ void driver_unprobe(pktio_entry_t *pktio_entry); +static inline odp_nic_dev_t *nic_dev_from_pktio(odp_pktio_t pktio) +{ + return _odp_nic_pktio_tbl[_odp_typeval(pktio)].nic_dev; +} + /** * @} */ diff --git a/platform/linux-generic/pktio/nic.c b/platform/linux-generic/pktio/nic.c index 1df93e1..1c25c90 100644 --- a/platform/linux-generic/pktio/nic.c +++ b/platform/linux-generic/pktio/nic.c @@ -46,6 +46,33 @@ static int nic_close(pktio_entry_t *entry) return 0; } +static int nic_recv(pktio_entry_t *pktio_entry, + odp_packet_t pkt_table[], unsigned len) +{ + int nbrx; + odp_nic_dev_t *nic_dev; + + nic_dev = nic_dev_from_pktio(pktio_entry->s.handle); + + nbrx = nic_dev->rx_pkt_burst(nic_dev->data->rx_queues[0], + (odp_nic_sgmt_t *)pkt_table, + len); + return nbrx; +} + +static int nic_send(pktio_entry_t *pktio_entry, + odp_packet_t pkt_table[], unsigned len) +{ + int nbtx; + odp_nic_dev_t *nic_dev; + + nic_dev = nic_dev_from_pktio(pktio_entry->s.handle); + nbtx = nic_dev->tx_pkt_burst(nic_dev->data->tx_queues[0], + (odp_nic_sgmt_t *)pkt_table, + len); + return nbtx; +} + const pktio_if_ops_t nic_pktio_ops = { .name = "Nic", .init = NULL, @@ -54,8 +81,8 @@ const pktio_if_ops_t nic_pktio_ops = { .close = nic_close, .start = NULL, .stop = NULL, - .recv = NULL, - .send = NULL, + .recv = nic_recv, + .send = nic_send, .mtu_get = NULL, .promisc_mode_set = NULL, .promisc_mode_get = NULL,