From: "Marek Behún" <kabel@kernel.org>
To: Roman Bacik <roman.bacik@broadcom.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
Bharat Gooty <bharat.gooty@broadcom.com>,
Joe Hershberger <joe.hershberger@ni.com>,
Ramon Fried <rfried.dev@gmail.com>
Subject: Re: [PATCH v5 1/2] net: brcm: netXtreme driver
Date: Tue, 2 Nov 2021 13:07:00 +0100 [thread overview]
Message-ID: <20211102130700.1ce19d24@thinkpad> (raw)
In-Reply-To: <20211101202145.26318-1-roman.bacik@broadcom.com>
On Mon, 1 Nov 2021 13:21:44 -0700
Roman Bacik <roman.bacik@broadcom.com> 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
next prev parent reply other threads:[~2021-11-02 12:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 20:21 [PATCH v5 1/2] net: brcm: netXtreme driver Roman Bacik
2021-11-01 20:21 ` [PATCH v5 2/2] board: brcm-ns3: Load netXtreme firmware Roman Bacik
2021-11-02 12:07 ` Marek Behún [this message]
2021-11-02 18:15 ` [PATCH v5 1/2] net: brcm: netXtreme driver Roman Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211102130700.1ce19d24@thinkpad \
--to=kabel@kernel.org \
--cc=bharat.gooty@broadcom.com \
--cc=joe.hershberger@ni.com \
--cc=rfried.dev@gmail.com \
--cc=roman.bacik@broadcom.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox