[PATCH v5 1/2] net: brcm: netXtreme driver
Roman Bacik
roman.bacik at broadcom.com
Tue Nov 2 19:15:27 CET 2021
Hi Marek,
> -----Original Message-----
> From: Marek Behún <kabel at kernel.org>
> Sent: Tuesday, November 2, 2021 5:07 AM
> To: Roman Bacik <roman.bacik at broadcom.com>
> Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Bharat Gooty
> <bharat.gooty at broadcom.com>; Joe Hershberger
> <joe.hershberger at ni.com>; Ramon Fried <rfried.dev at gmail.com>
> Subject: Re: [PATCH v5 1/2] net: brcm: netXtreme driver
>
> On Mon, 1 Nov 2021 13:21:44 -0700
> Roman Bacik <roman.bacik at 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
We will remove env_set() calls in v6 as requested.
Thanks,
Roman
--
This electronic communication and the information and any files transmitted
with it, or attached to it, are confidential and are intended solely for
the use of the individual or entity to whom it is addressed and may contain
information that is confidential, legally privileged, protected by privacy
laws, or otherwise restricted from disclosure to anyone else. If you are
not the intended recipient or the person responsible for delivering the
e-mail to the intended recipient, you are hereby notified that any use,
copying, distributing, dissemination, forwarding, printing, or copying of
this e-mail is strictly prohibited. If you received this e-mail in error,
please return the e-mail to the sender, delete it from your computer, and
destroy any printed copy of it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4206 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20211102/eb72785b/attachment.bin>
More information about the U-Boot
mailing list