From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CFABC433EF for ; Tue, 2 Nov 2021 12:07:16 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7288960EBC for ; Tue, 2 Nov 2021 12:07:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7288960EBC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A07881BC8; Tue, 2 Nov 2021 13:07:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="LV+Ag7mP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E78A382006; Tue, 2 Nov 2021 13:07:11 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4B4BB807D7 for ; Tue, 2 Nov 2021 13:07:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id DCF3E60F5A; Tue, 2 Nov 2021 12:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635854825; bh=NXvKoLpTMFRK1iBNAfNJsg9GUxIlSEqSovfzO+UTdMY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LV+Ag7mP6px8ufCb58l47wwmjOw6wB59cBnG45aQNdCwRGR746uBHJA0JektWovSb fiKsCoMkzVihMljsp1K/AnoYOO5r3CEpzE/f6ThQI/kDKntWQjkdDZLCIRaiyYopEh rJkaaTfRjpWC7n1Wc62EgM8NdRH+3ItAuqplyMwp4DsW7LOWY/ouA5Zo0UrA0dL9MT 3VpprWTnO4FcerYRXPS+VxVdvw5+bv0jKqdSxLEKPh0TtE9IUoNTSU2w8IQ8jRd+17 m+XazNTsJzxLCSLYirA3AjQiqui0MJUFclZRUNqJJKdPyMIe8WOaUQGpvKxypf+5l7 W0OyBbfHti6OA== Date: Tue, 2 Nov 2021 13:07:00 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Roman Bacik Cc: U-Boot Mailing List , Bharat Gooty , Joe Hershberger , Ramon Fried Subject: Re: [PATCH v5 1/2] net: brcm: netXtreme driver Message-ID: <20211102130700.1ce19d24@thinkpad> In-Reply-To: <20211101202145.26318-1-roman.bacik@broadcom.com> References: <20211101202145.26318-1-roman.bacik@broadcom.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On Mon, 1 Nov 2021 13:21:44 -0700 Roman Bacik wrote: > +static int set_phy_speed(struct bnxt *bp) > +{ > + char name[20]; > + char name1[30]; > + u16 flag = PHY_STATUS | PHY_SPEED | DETECT_MEDIA; > + > + /* Query Link Status */ > + if (bnxt_hwrm_port_phy_qcfg(bp, flag) != STATUS_SUCCESS) > + return STATUS_FAILURE; > + > + switch (bp->current_link_speed) { > + case PORT_PHY_QCFG_RESP_LINK_SPEED_100GB: > + sprintf(name, "%s %s", str_100, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_50GB: > + sprintf(name, "%s %s", str_50, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_40GB: > + sprintf(name, "%s %s", str_40, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_25GB: > + sprintf(name, "%s %s", str_25, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_20GB: > + sprintf(name, "%s %s", str_20, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_10GB: > + sprintf(name, "%s %s", str_10, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB: > + sprintf(name, "%s %s", str_2_5, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_2GB: > + sprintf(name, "%s %s", str_2, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_1GB: > + sprintf(name, "%s %s", str_1, str_gbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_100MB: > + sprintf(name, "%s %s", str_100, str_mbps); > + break; > + case PORT_PHY_QCFG_RESP_LINK_SPEED_10MB: > + sprintf(name, "%s %s", str_10, str_mbps); > + break; > + default: > + sprintf(name, "%s %x", str_unknown, bp->current_link_speed); > + } > + > + sprintf(name1, "bnxt_eth%u_phy_speed", bp->cardnum); > + env_set(name1, name); > + dbg_phy_speed(bp, name); > + > + return STATUS_SUCCESS; > +} > + > +static int set_phy_link(struct bnxt *bp, u32 tmo) > +{ > + char name[32]; > + int ret; > + > + set_phy_speed(bp); > + dbg_link_status(bp); > + if (bp->link_status == STATUS_LINK_ACTIVE) { > + dbg_link_state(bp, tmo); > + sprintf(name, "bnxt_eth%u_link", bp->cardnum); > + env_set(name, "up"); > + sprintf(name, "bnxt_eth%u_media", bp->cardnum); > + env_set(name, "connected"); > + ret = STATUS_SUCCESS; > + } else { > + sprintf(name, "bnxt_eth%u_link", bp->cardnum); > + env_set(name, "down"); > + sprintf(name, "bnxt_eth%u_media", bp->cardnum); > + env_set(name, "disconnected"); > + ret = STATUS_FAILURE; > + } > + > + return ret; > +} Hi Roman, your proposal still contains non-standard and unneeded setting of environment variables. An ethernet driver should never do this. In fact no driver besides board code or sysinfo driver should do this directly. There are other mechanisms for reporting PHY connection information in U-Boot, please use those if you need them (e.g. implement a PHY driver), but remove all env_set() calls from your ethernet driver. Rationale: historically, many times things were solved with ad-hoc code in U-Boot, which did this kind of thing and similar. It got out of hand pretty fast, and it was horrible. So some people dedided to fix it, proposing APIs, unifying code, deduplicating code and so on. This is still, in fact, going on. For your driver to have it's own mechanism for reporting link status, by setting env variables, is going against this whole work. I suggest for now just to remove these calls. When the driver is merged, we can work on extending support for passing link information to U-Boot via ethernet PHY API, if you need it. Marek