Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A80DC25B0C for ; Mon, 8 Aug 2022 12:16:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4EEB384117; Mon, 8 Aug 2022 14:16:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pw74iX1u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C79B83FB1; Mon, 8 Aug 2022 14:16:29 +0200 (CEST) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 50DAC84047 for ; Mon, 8 Aug 2022 14:16:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=joel.stan@gmail.com Received: by mail-pl1-x62b.google.com with SMTP id d16so8347528pll.11 for ; Mon, 08 Aug 2022 05:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc; bh=+A3AdqgRrZBeVsgUUDWsNi2hDtdzf+pafSRqe2Azrag=; b=pw74iX1u1Jc3VHITRUZ9RUIUFWMwsxdJ3oTWseiPlrx9/nllXz2YTUgslCwRcL+Ug1 c6Fpdthe5MGeujs9icuTIl/2cfGUQAHK7G3GzbhEWTkc7Nl4ODzJ2BWyOADbFuSrLBfx FCrQK+cv4DnkdjldkGXqNDJvwpAC7wuBruhL9UL3OEr84h2DKrfGRagCpiJJqaFOSJNY b7+fiQC9dWVaof6ARzOcQPXLhiMGM61ydyyCTcgDt4PFztPnPCjHKJ+n6RxEcNOoUNY5 EYug0GoOXitSBIPcSdZiWY6RLDphi3fNfSvw4bRrCQG0wHJY2BB0gUQFgQD+xetec+wJ jqzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc; bh=+A3AdqgRrZBeVsgUUDWsNi2hDtdzf+pafSRqe2Azrag=; b=CnVYhwvq2MSd6dBDB68cslssUiK6W4k5r9AdNlDOWkvXiBI0v2cCpWmZLCF7OJP3vj whvyzVxRK4USiX98Rmd3WhH+OQh8fMBASfJXd1Aw30BVLSskvI541o4pcA7qeJQSpFb0 FPvSouIfnrWol3Tl6shkpJY/xNMmRe+JW74b/FIni6MA13Dbhu3ICbF9cbueB1+srvX3 FpW7h6o/FuCEjX7gSerAL843FpZmcerp5Pc6AiAAqBoBL0UIiMaYV3857tFoGaKXzGPy FdR85RzQ08gHGwab8T4j/XDnGH75IEQM3N2O+WWtnmwtugGz1bjOcrHvfzEYKCdvven1 QW7Q== X-Gm-Message-State: ACgBeo1oxEANlgl9C5Y8oJsZMeWZGe2K+Y/o437cI0qKD3tbrDiu9Gp2 qTIyLELTwUslRhew4cls2X0= X-Google-Smtp-Source: AA6agR4d6U6P/utZTeYnn3SDDzJhJgbUFqPIWgkK6owoR45ZosO/eZJJqjrKSbuOoBjf0AWASmsCDQ== X-Received: by 2002:a17:903:22c3:b0:16f:2182:6f3e with SMTP id y3-20020a17090322c300b0016f21826f3emr18727261plg.59.1659960984453; Mon, 08 Aug 2022 05:16:24 -0700 (PDT) Received: from voyager.lan ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id t16-20020a62d150000000b0052b6ed5ca40sm8482163pfl.192.2022.08.08.05.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 05:16:23 -0700 (PDT) From: Joel Stanley To: Joe Hershberger , Ramon Fried , Ryan Chen , BMC-SW@aspeedtech.com Cc: Samuel Mendoza-Jonas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , u-boot@lists.denx.de Subject: [PATCH v4 1/4] net: NC-SI setup and handling Date: Mon, 8 Aug 2022 21:46:03 +0930 Message-Id: <20220808121606.188002-2-joel@jms.id.au> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808121606.188002-1-joel@jms.id.au> References: <20220808121606.188002-1-joel@jms.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Samuel Mendoza-Jonas Add the handling of NC-SI ethernet frames, and add a check at the start of net_loop() to configure NC-SI before starting other network commands. Signed-off-by: Samuel Mendoza-Jonas Signed-off-by: Joel Stanley --- v4: split out cmd addition into a separate patch v3: - Fix compilation. There were no configs that enabled the NCSI phy code so it had bitrotted - Use NCSI_PHY instead of CMD_NCSI so NCSI can work without the command - Add phy_interface_is_ncsi() helper, thanks Cédric for this suggestion - Only create NCSI phy device when driver is configured for it include/net.h | 2 +- include/phy.h | 2 ++ drivers/net/phy/ncsi.c | 1 + drivers/net/phy/phy.c | 9 ++++++++- net/net.c | 26 +++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/net.h b/include/net.h index e3889a0bc85e..0681b8246323 100644 --- a/include/net.h +++ b/include/net.h @@ -558,7 +558,7 @@ extern int net_restart_wrap; /* Tried all network devices */ enum proto_t { BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP, - TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP + TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI }; extern char net_boot_file_name[1024];/* Boot File name */ diff --git a/include/phy.h b/include/phy.h index b32959571069..1e0f8856f629 100644 --- a/include/phy.h +++ b/include/phy.h @@ -583,6 +583,8 @@ static inline bool phy_interface_is_sgmii(struct phy_device *phydev) phydev->interface <= PHY_INTERFACE_MODE_QSGMII; } +bool phy_interface_is_ncsi(void); + /* PHY UIDs for various PHYs that are referenced in external code */ #define PHY_UID_CS4340 0x13e51002 #define PHY_UID_CS4223 0x03e57003 diff --git a/drivers/net/phy/ncsi.c b/drivers/net/phy/ncsi.c index bf1e832be9f1..bb7ecebed382 100644 --- a/drivers/net/phy/ncsi.c +++ b/drivers/net/phy/ncsi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 1121b99abff5..d04538838852 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1026,7 +1026,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, #endif #ifdef CONFIG_PHY_NCSI - if (!phydev) + if (!phydev && interface == PHY_INTERFACE_MODE_NCSI) phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false); #endif @@ -1101,3 +1101,10 @@ int phy_modify(struct phy_device *phydev, int devad, int regnum, u16 mask, return phy_write(phydev, devad, regnum, (ret & ~mask) | set); } + +bool phy_interface_is_ncsi(void) +{ + struct eth_pdata *pdata = dev_get_plat(eth_get_dev()); + + return pdata->phy_interface == PHY_INTERFACE_MODE_NCSI; +} diff --git a/net/net.c b/net/net.c index 81905f631592..f0faf33d0d77 100644 --- a/net/net.c +++ b/net/net.c @@ -93,6 +93,7 @@ #include #include #include +#include #if defined(CONFIG_CMD_PCAP) #include #endif @@ -410,6 +411,16 @@ int net_loop(enum proto_t protocol) net_try_count = 1; debug_cond(DEBUG_INT_STATE, "--- net_loop Entry\n"); +#ifdef CONFIG_PHY_NCSI + if (phy_interface_is_ncsi() && protocol != NCSI && !ncsi_active()) { + printf("%s: configuring NCSI first\n", __func__); + if (net_loop(NCSI) < 0) + return ret; + eth_init_state_only(); + goto restart; + } +#endif + bootstage_mark_name(BOOTSTAGE_ID_ETH_START, "eth_start"); net_init(); if (eth_is_on_demand_init()) { @@ -526,6 +537,11 @@ restart: case WOL: wol_start(); break; +#endif +#if defined(CONFIG_PHY_NCSI) + case NCSI: + ncsi_probe_packages(); + break; #endif default: break; @@ -637,7 +653,7 @@ restart: env_set_hex("filesize", net_boot_file_size); env_set_hex("fileaddr", image_load_addr); } - if (protocol != NETCONS) + if (protocol != NETCONS && protocol != NCSI) eth_halt(); else eth_halt_state_only(); @@ -1321,6 +1337,11 @@ void net_process_received_packet(uchar *in_packet, int len) case PROT_WOL: wol_receive(ip, len); break; +#endif +#ifdef CONFIG_PHY_NCSI + case PROT_NCSI: + ncsi_receive(et, ip, len); + break; #endif } } @@ -1381,6 +1402,9 @@ common: #ifdef CONFIG_CMD_RARP case RARP: +#endif +#ifdef CONFIG_PHY_NCSI + case NCSI: #endif case BOOTP: case CDP: -- 2.35.1