All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
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>,
	pali@kernel.org
Subject: Re: [PATCH v4 1/2] net: brcm: netXtreme driver
Date: Sat, 30 Oct 2021 17:00:03 +0200	[thread overview]
Message-ID: <20211030170003.20219284@thinkpad> (raw)
In-Reply-To: <20211028232929.16607-1-roman.bacik@broadcom.com>

Hello Roman,

On Thu, 28 Oct 2021 16:29:28 -0700
Roman Bacik <roman.bacik@broadcom.com> wrote:

> +void bnxt_env_set_ethaddr(struct udevice *dev)
> +{
> +	struct eth_pdata *plat = dev_get_plat(dev);
> +	char cmd[100];
> +	char var[32];
> +	u8 mac_env[ARP_HLEN];
> +
> +	eth_env_get_enetaddr_by_index("eth", dev_seq(dev), mac_env);
> +	if (!memcmp(plat->enetaddr, mac_env, ARP_HLEN))
> +		return;
> +
> +	sprintf(var, dev_seq(dev) ? "%s%daddr" : "%saddr", "eth", dev_seq(dev));
> +	sprintf(cmd, "%s %s %pM", "env set -f", var, plat->enetaddr);
> +	run_command(cmd, CMD_FLAG_ENV);
> +}
> +
> +void bnxt_env_del_ethaddr(struct udevice *dev)
> +{
> +	struct eth_pdata *plat = dev_get_plat(dev);
> +	char cmd[100];
> +	char var[32];
> +
> +	sprintf(var, dev_seq(dev) ? "%s%daddr" : "%saddr", "eth", dev_seq(dev));
> +	sprintf(cmd, "%s %s %pM", "env delete -f", var, plat->enetaddr);
> +	run_command(cmd, CMD_FLAG_ENV);
> +}

And then in bnxt_eth_probe():
> +	eth_env_get_enetaddr_by_index("eth", dev_seq(dev), bp->mac_set);
...
> +	memcpy(plat->enetaddr, bp->mac_set, ETH_ALEN);
> +	bnxt_env_set_ethaddr(dev);

So if I understand this correctly, in bnxt_eth_probe(), you read env
variable ethNaddr into bp->mac_set. Then bnxt_bring_chip() is called,
which calls various functions, including bnxt_hwrm_func_qcaps_req(),
which may overwrite bp->mac_set. Then bp->mac_set is copied into
plat->enetaddr.

Then bnxt_env_set_ethaddr() is called, which reads the env variable
ethNaddr again, and compares it with value in plat->enetaddr, and if
they are different, it overwrites the value in ethNaddr with
plat->enetaddr.

I have this to say:
- could you please explain why this is done so? I mean the logic behind
  this...
- it seems to me that you haven't read the documentation for struct
  env_ops in include/net.h: there are methods read_rom_hwaddr() and
  write_hwaddr(), which you could use, instead of implementing this
  whole mechanism ad-hoc. You should use those or explain your reasons
  why you aren't doing this
- why do you need the plat structure? Why not use bp->mac_set directly,
  without plat->enetaddr?
- the way you set and delete ethNaddr variable, by running U-Boot
  commands, is very weird, when there is a direct function for setting
  the value:
    eth_env_set_enetaddr_by_index()
  As for deleting:
  - why do you need it in the first place? I mean you are removing the
    variable upon driver removal. No other ethernet driver does that...
  - instead of assembling the "env delete" command it would make far
    more sense to include patch that adds env_del() function into
    env/common.c

I have another question: does this driver support adapters with SFP
cages only, or also those with RJ-45 ports?

Thank you.

Marek

  parent reply	other threads:[~2021-10-30 15:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 23:29 [PATCH v4 1/2] net: brcm: netXtreme driver Roman Bacik
2021-10-28 23:29 ` [PATCH v4 2/2] board: brcm-ns3: Load netXtreme firmware Roman Bacik
2021-10-30 15:00 ` Marek Behún [this message]
2021-10-30 15:48   ` [PATCH v4 1/2] net: brcm: netXtreme driver Roman Bacik
2021-10-31 10:56     ` Marek Behún
2021-11-01 20:14       ` 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=20211030170003.20219284@thinkpad \
    --to=marek.behun@nic.cz \
    --cc=bharat.gooty@broadcom.com \
    --cc=joe.hershberger@ni.com \
    --cc=pali@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.