From patchwork Wed Mar 11 23:44:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 449240 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 73B6314008F for ; Thu, 12 Mar 2015 10:47:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28EE3A7437; Thu, 12 Mar 2015 00:47:27 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8zfsXI9Ae67n; Thu, 12 Mar 2015 00:47:27 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 57ACBA7448; Thu, 12 Mar 2015 00:47:11 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D10B3A7424 for ; Thu, 12 Mar 2015 00:46:30 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d8H8Gb6sVN0C for ; Thu, 12 Mar 2015 00:46:30 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by theia.denx.de (Postfix) with ESMTPS id A84B1A7427 for ; Thu, 12 Mar 2015 00:46:27 +0100 (CET) Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod3.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id t2BNkPXm027343; Wed, 11 Mar 2015 18:46:25 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6) with ESMTP id 2015031118462558-293909 ; Wed, 11 Mar 2015 18:46:25 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Wed, 11 Mar 2015 18:44:13 -0500 Message-Id: <1426117465-16072-16-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1426117465-16072-1-git-send-email-joe.hershberger@ni.com> References: <1425436881-10323-1-git-send-email-joe.hershberger@ni.com> <1426117465-16072-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 03/11/2015 06:46:25 PM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 03/11/2015 06:46:25 PM, Serialize complete at 03/11/2015 06:46:25 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2015-03-11_08:, , signatures=0 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v6 15/27] dm: eth: Pass the packet pointer as a parameter to recv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Stop forcing drivers to call net_process_received_packet() - formerly called NetReceive(). Now the uclass will handle calling the driver for each packet until the driver errors or has nothing to return. The uclass will then pass the good packets off to the network stack by calling net_process_received_packet(). Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- Changes in v6: -Swallow -EAGAIN error in eth_rx() -Updated function documentation Changes in v5: -New to v5 Changes in v4: None Changes in v3: None Changes in v2: None include/net.h | 6 ++++-- net/eth.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/net.h b/include/net.h index 31ef1ff..241a096 100644 --- a/include/net.h +++ b/include/net.h @@ -95,7 +95,9 @@ struct eth_pdata { * * start: Prepare the hardware to send and receive packets * send: Send the bytes passed in "packet" as a packet on the wire - * recv: Check if the hardware received a packet. Call the network stack if so + * recv: Check if the hardware received a packet. If so, set the pointer to the + * packet buffer in the packetp parameter. If not, return an error or 0 to + * indicate that the hardware receive FIFO is empty * stop: Stop the hardware from looking for packets - may be called even if * state == PASSIVE * mcast: Join or leave a multicast group (for TFTP) - optional @@ -110,7 +112,7 @@ struct eth_pdata { struct eth_ops { int (*start)(struct udevice *dev); int (*send)(struct udevice *dev, void *packet, int length); - int (*recv)(struct udevice *dev); + int (*recv)(struct udevice *dev, uchar **packetp); void (*stop)(struct udevice *dev); #ifdef CONFIG_MCAST_TFTP int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join); diff --git a/net/eth.c b/net/eth.c index 1abf027..058c55a 100644 --- a/net/eth.c +++ b/net/eth.c @@ -259,6 +259,9 @@ int eth_send(void *packet, int length) int eth_rx(void) { struct udevice *current; + uchar *packet; + int ret; + int i; current = eth_get_dev(); if (!current) @@ -267,7 +270,17 @@ int eth_rx(void) if (!device_active(current)) return -EINVAL; - return eth_get_ops(current)->recv(current); + /* Process up to 32 packets at one time */ + for (i = 0; i < 32; i++) { + ret = eth_get_ops(current)->recv(current, &packet); + if (ret > 0) + net_process_received_packet(packet, ret); + else + break; + } + if (ret == -EAGAIN) + ret = 0; + return ret; } static int eth_write_hwaddr(struct udevice *dev)