From patchwork Tue Jun 26 21:19:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 935098 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41FfB80YT1z9rx7 for ; Wed, 27 Jun 2018 07:21:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B3833C21DB6; Tue, 26 Jun 2018 21:20:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2F4F5C21DFA; Tue, 26 Jun 2018 21:19:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 51A60C21D65; Tue, 26 Jun 2018 21:19:44 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id 26133C21C29 for ; Tue, 26 Jun 2018 21:19:42 +0000 (UTC) Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QLGLSG026155; Tue, 26 Jun 2018 16:19:35 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2jucuu2n10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:35 -0500 Received: from us-aus-exch1.ni.corp.natinst.com (us-aus-exch1.ni.corp.natinst.com [130.164.68.11]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w5QLJY4c031552 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exch3.ni.corp.natinst.com (130.164.68.13) by us-aus-exch1.ni.corp.natinst.com (130.164.68.11) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch3.ni.corp.natinst.com (130.164.68.13) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:33 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 26 Jun 2018 16:19:33 -0500 From: Joe Hershberger To: Date: Tue, 26 Jun 2018 16:19:22 -0500 Message-ID: <20180626211926.13172-2-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626211926.13172-1-joe.hershberger@ni.com> References: <20180626211926.13172-1-joe.hershberger@ni.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Heinrich Schuchardt , Joe Hershberger Subject: [U-Boot] [PATCH 1/5] sandbox: eth-raw: Correct valid socket test in send/recv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In open, the socket is correctly checked to be -1 in the error case. In send and recv, we checked for 0, but that is a valid socket number. Correct this by checking for -1 as a bad socket everywhere. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- arch/sandbox/cpu/eth-raw-os.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index e054a0702a..61f23ed210 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -156,7 +156,7 @@ int sandbox_eth_raw_os_send(void *packet, int length, int retval; struct udphdr *udph = packet + sizeof(struct iphdr); - if (!priv->sd || !priv->device) + if (priv->sd < 0 || !priv->device) return -EINVAL; /* @@ -221,7 +221,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length, int retval; int saddr_size; - if (!priv->sd || !priv->device) + if (priv->sd < 0 || !priv->device) return -EINVAL; saddr_size = sizeof(struct sockaddr); retval = recvfrom(priv->sd, packet, 1536, 0, From patchwork Tue Jun 26 21:19:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 935097 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41Ff8T6b3Lz9rx7 for ; Wed, 27 Jun 2018 07:20:25 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8D1B5C21D8E; Tue, 26 Jun 2018 21:20:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 76A1BC21DAF; Tue, 26 Jun 2018 21:19:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5B6EEC21C29; Tue, 26 Jun 2018 21:19:42 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id AA230C21C8B for ; Tue, 26 Jun 2018 21:19:41 +0000 (UTC) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QLGKEZ032737; Tue, 26 Jun 2018 16:19:35 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2jskqr9cyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (us-aus-exhub1.ni.corp.natinst.com [130.164.68.41]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w5QLJYsO031544 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exch5.ni.corp.natinst.com (130.164.68.15) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:33 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch5.ni.corp.natinst.com (130.164.68.15) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:33 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 26 Jun 2018 16:19:33 -0500 From: Joe Hershberger To: Date: Tue, 26 Jun 2018 16:19:23 -0500 Message-ID: <20180626211926.13172-3-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626211926.13172-1-joe.hershberger@ni.com> References: <20180626211926.13172-1-joe.hershberger@ni.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Heinrich Schuchardt , Joe Hershberger Subject: [U-Boot] [PATCH 2/5] net: Correct comment in Kconfig X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index e88f056d84..5f26a0004a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -8,7 +8,7 @@ config DM_ETH Enable driver model for Ethernet. The eth_*() interface will be implemented by the UC_ETH class - This is currently implemented in net/eth.c + This is currently implemented in net/eth-uclass.c Look in include/net.h for details. config DRIVER_TI_CPSW From patchwork Tue Jun 26 21:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 935102 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41FfCj3L3fz9ry1 for ; Wed, 27 Jun 2018 07:23:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3997BC21DAF; Tue, 26 Jun 2018 21:20:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 268F2C21D56; Tue, 26 Jun 2018 21:19:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BE0FCC21DA1; Tue, 26 Jun 2018 21:19:49 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id 3C210C21D8E for ; Tue, 26 Jun 2018 21:19:44 +0000 (UTC) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QLGKEa032737; Tue, 26 Jun 2018 16:19:35 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2jskqr9cyw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exch2.ni.corp.natinst.com (us-aus-exch2.ni.corp.natinst.com [130.164.68.12]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w5QLJYQl031545 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch2.ni.corp.natinst.com (130.164.68.12) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:33 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 26 Jun 2018 16:19:33 -0500 From: Joe Hershberger To: Date: Tue, 26 Jun 2018 16:19:24 -0500 Message-ID: <20180626211926.13172-4-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626211926.13172-1-joe.hershberger@ni.com> References: <20180626211926.13172-1-joe.hershberger@ni.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Heinrich Schuchardt , Joe Hershberger Subject: [U-Boot] [PATCH 3/5] net: sandbox: Convert sandbox mock eth driver to livetree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Use the dev_ functions to access DT properties. Also correct the reading of the fake MAC address. The format from the DT is u32s, so to accurately read the MAC from the DT, we need to cast each value to a u8. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- drivers/net/sandbox.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c index b34712bd06..d5a30c05b8 100644 --- a/drivers/net/sandbox.c +++ b/drivers/net/sandbox.c @@ -56,13 +56,20 @@ void sandbox_eth_skip_timeout(void) static int sb_eth_start(struct udevice *dev) { struct eth_sandbox_priv *priv = dev_get_priv(dev); + /* The DT integers are 32-bits */ + const u32 mac[ARP_HLEN]; debug("eth_sandbox: Start\n"); - fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev), - "fake-host-hwaddr", priv->fake_host_hwaddr, - ARP_HLEN); + if (dev_read_u32_array(dev, "fake-host-hwaddr", mac, ARP_HLEN)) { + printf("'fake-host-hwaddr' is missing from the DT\n"); + return -EINVAL; + } + for (int i = 0; i < ARP_HLEN; i++) + priv->fake_host_hwaddr[i] = (uint8_t)mac[i]; + priv->recv_packet_buffer = net_rx_packets[0]; + return 0; } @@ -204,7 +211,7 @@ static int sb_eth_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); return 0; } From patchwork Tue Jun 26 21:19:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 935095 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41Ff7m6X69z9s0n for ; Wed, 27 Jun 2018 07:19:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 61CC1C21DED; Tue, 26 Jun 2018 21:19:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8CBEEC21C8B; Tue, 26 Jun 2018 21:19:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3CBB4C21C93; Tue, 26 Jun 2018 21:19:42 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id 907F1C21C29 for ; Tue, 26 Jun 2018 21:19:41 +0000 (UTC) Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QLGLdQ026161; Tue, 26 Jun 2018 16:19:35 -0500 Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by mx0a-00010702.pphosted.com with ESMTP id 2jucuu2n0y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:35 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (us-aus-exhub1.ni.corp.natinst.com [130.164.68.41]) by us-aus-skprod3.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w5QLJYDT005837 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:34 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 26 Jun 2018 16:19:34 -0500 From: Joe Hershberger To: Date: Tue, 26 Jun 2018 16:19:25 -0500 Message-ID: <20180626211926.13172-5-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626211926.13172-1-joe.hershberger@ni.com> References: <20180626211926.13172-1-joe.hershberger@ni.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Heinrich Schuchardt , Joe Hershberger Subject: [U-Boot] [PATCH 4/5] net: sandbox-raw: Convert raw eth driver to livetree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- drivers/net/sandbox-raw.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index 3f8020f629..f835a6a7f3 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -25,17 +25,19 @@ static int sb_eth_raw_start(struct udevice *dev) debug("eth_sandbox_raw: Start\n"); - interface = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), - "host-raw-interface", NULL); - if (interface == NULL) - return -EINVAL; - - if (strcmp(interface, "lo") == 0) { - priv->local = 1; - env_set("ipaddr", "127.0.0.1"); - env_set("serverip", "127.0.0.1"); + interface = dev_read_prop(dev, "host-raw-interface", NULL); + if (interface) { + printf("eth_sandbox_raw: Using %s from DT\n", interface); + if (strcmp(interface, "lo") == 0) { + priv->local = 1; + env_set("ipaddr", "127.0.0.1"); + env_set("serverip", "127.0.0.1"); + } + return sandbox_eth_raw_os_start(interface, pdata->enetaddr, + priv); } - return sandbox_eth_raw_os_start(interface, pdata->enetaddr, priv); + + return -EINVAL; } static int sb_eth_raw_send(struct udevice *dev, void *packet, int length) @@ -144,7 +146,7 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); - pdata->iobase = devfdt_get_addr(dev); + pdata->iobase = dev_read_addr(dev); return 0; } From patchwork Tue Jun 26 21:19:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 935099 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41FfBt2Xtmz9rx7 for ; Wed, 27 Jun 2018 07:22:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 8AB74C21C93; Tue, 26 Jun 2018 21:20:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 65190C21DC1; Tue, 26 Jun 2018 21:19:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FE12C21C2C; Tue, 26 Jun 2018 21:19:42 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id A33AAC21C2C for ; Tue, 26 Jun 2018 21:19:41 +0000 (UTC) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5QLGLpu032740; Tue, 26 Jun 2018 16:19:35 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2jskqr9cyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:35 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (us-aus-exhub1.ni.corp.natinst.com [130.164.68.41]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w5QLJYaI031553 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exch4.ni.corp.natinst.com (130.164.68.14) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:34 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch4.ni.corp.natinst.com (130.164.68.14) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 26 Jun 2018 16:19:34 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 26 Jun 2018 16:19:34 -0500 From: Joe Hershberger To: Date: Tue, 26 Jun 2018 16:19:26 -0500 Message-ID: <20180626211926.13172-6-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180626211926.13172-1-joe.hershberger@ni.com> References: <20180626211926.13172-1-joe.hershberger@ni.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-26_09:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Heinrich Schuchardt , Joe Hershberger Subject: [U-Boot] [PATCH 5/5] net: sandbox-raw: Allow interface to be specified by index X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" With systemd stable interface names, eth0 will almost never exist. Instead of using that name in the sandbox.dts, use index 2 (the first interface after "lo"). Enumerate the interfaces on the system to choose a valid interace name. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- arch/sandbox/cpu/eth-raw-os.c | 28 ++++++++++++++++++++++++++++ arch/sandbox/dts/sandbox.dts | 2 +- arch/sandbox/include/asm/eth-raw-os.h | 4 +++- drivers/net/sandbox-raw.c | 8 +++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index 61f23ed210..11b5271f31 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -150,6 +150,34 @@ int sandbox_eth_raw_os_start(const char *ifname, unsigned char *ethmac, return _raw_packet_start(ifname, ethmac, priv); } +int sandbox_eth_raw_os_start_idx(unsigned int ifindex, unsigned char *ethmac, + struct eth_sandbox_raw_priv *priv) +{ + int ret; + struct if_nameindex *ni, *i; + const char *ifname = NULL; + + ni = if_nameindex(); + if (!ni) + return -EINVAL; + + for (i = ni; !(i->if_index == 0 && !i->if_name); i++) { + if (ifindex == i->if_index) { + ifname = i->if_name; + printf("(%s)\n", ifname); + break; + } + } + /* Don't bother supporting 'lo' by index. Just use the name in DTS */ + if (ifname) + ret = _raw_packet_start(ifname, ethmac, priv); + else + ret = -EINVAL; + + if_freenameindex(ni); + return ret; +} + int sandbox_eth_raw_os_send(void *packet, int length, struct eth_sandbox_raw_priv *priv) { diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts index 0ea2452742..e7f6c194d0 100644 --- a/arch/sandbox/dts/sandbox.dts +++ b/arch/sandbox/dts/sandbox.dts @@ -56,7 +56,7 @@ eth@80000000 { compatible = "sandbox,eth-raw"; reg = <0x80000000 0x1000>; - host-raw-interface = "eth0"; + host-raw-interface-idx = <2>; }; eth@90000000 { diff --git a/arch/sandbox/include/asm/eth-raw-os.h b/arch/sandbox/include/asm/eth-raw-os.h index f986d3142d..70b29b4508 100644 --- a/arch/sandbox/include/asm/eth-raw-os.h +++ b/arch/sandbox/include/asm/eth-raw-os.h @@ -29,7 +29,9 @@ struct eth_sandbox_raw_priv { }; int sandbox_eth_raw_os_start(const char *ifname, unsigned char *ethmac, - struct eth_sandbox_raw_priv *priv); + struct eth_sandbox_raw_priv *priv); +int sandbox_eth_raw_os_start_idx(unsigned int ifindex, unsigned char *ethmac, + struct eth_sandbox_raw_priv *priv); int sandbox_eth_raw_os_send(void *packet, int length, struct eth_sandbox_raw_priv *priv); int sandbox_eth_raw_os_recv(void *packet, int *length, diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index f835a6a7f3..3bde8d84ce 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -22,6 +22,7 @@ static int sb_eth_raw_start(struct udevice *dev) struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); const char *interface; + u32 index; debug("eth_sandbox_raw: Start\n"); @@ -37,7 +38,12 @@ static int sb_eth_raw_start(struct udevice *dev) priv); } - return -EINVAL; + if (dev_read_u32(dev, "host-raw-interface-idx", &index) < 0) + return -EINVAL; + + printf("eth_sandbox_raw: Using interface index %d from DT ", index); + + return sandbox_eth_raw_os_start_idx(index, pdata->enetaddr, priv); } static int sb_eth_raw_send(struct udevice *dev, void *packet, int length)