netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Ajay.Kathat@microchip.com, kvalo@kernel.org, heiko.thiery@gmail.com
Cc: michael@walle.cc, kuba@kernel.org, Claudiu.Beznea@microchip.com,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	Amisha.Patel@microchip.com, thaller@redhat.com,
	bgalvani@redhat.com, Sripad.Balwadgi@microchip.com
Subject: Re: wilc1000 MAC address is 00:00:00:00:00:00
Date: Fri, 10 Feb 2023 15:28:14 -0600	[thread overview]
Message-ID: <aef63f6a367896950f9e61041cfcff4b99bd6c7d.camel@redhat.com> (raw)
In-Reply-To: <2c2e656e-6dad-67d9-8da0-d507804e7df3@microchip.com>

On Fri, 2023-02-10 at 19:12 +0000, Ajay.Kathat@microchip.com wrote:
> Hi Kalle,
> 
> On 2/10/23 02:25, Kalle Valo wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> > 
> > Heiko Thiery <heiko.thiery@gmail.com> writes:
> > 
> > > HI,
> > > 
> > > Am Do., 9. Feb. 2023 um 22:19 Uhr schrieb Michael Walle
> > > <michael@walle.cc>:
> > > > 
> > > > Am 2023-02-09 22:07, schrieb Jakub Kicinski:
> > > > > On Thu, 9 Feb 2023 18:51:58 +0000
> > > > > Ajay.Kathat@microchip.com wrote:
> > > > > > > netdev should be created with a valid lladdr, is there
> > > > > > > something
> > > > > > > wifi-specific here that'd prevalent that? The canonical
> > > > > > > flow is
> > > > > > > to this before registering the netdev:
> > > > > > 
> > > > > > Here it's the timing in wilc1000 by when the MAC address is
> > > > > > available
> > > > > > to
> > > > > > read from NV. NV read is available in "mac_open"
> > > > > > net_device_ops
> > > > > > instead
> > > > > > of bus probe function. I think, mostly the operations on
> > > > > > netdev which
> > > > > > make use of mac address are performed after the "mac_open"
> > > > > > (I may be
> > > > > > missing something).
> > > > > > 
> > > > > > Does it make sense to assign a random address in probe and
> > > > > > later read
> > > > > > back from NV in mac_open to make use of stored value?
> > > > > 
> > > > > Hard to say, I'd suspect that may be even more confusing than
> > > > > starting with zeroes. There aren't any hard rules around the
> > > > > addresses AFAIK, but addrs are visible to user space. So user
> > > > > space will likely make assumptions based on the most commonly
> > > > > observed sequence (reading real addr at probe).
> > > > 
> > > > Maybe we should also ask the NetworkManager guys. IMHO random
> > > > MAC address sounds bogus.
> > > 
> > > Maybe it would be a "workaround" with loading the firmware while
> > > probing the device to set the real hw address.
> > > 
> > > probe()
> > >   load_fw()
> > >   read_hw_addr_from_nv()
> > >   eth_hw_addr_set(ndev, addr)
> > >   unload_fw()
> > > 
> > > mac_open()
> > >   load_fw()
> > > 
> > > mac_close()
> > >   unload_fw()
> > 
> > This is exactly what many wireless drivers already do and I
> > recommend
> > that wilc1000 would do the same.
> > 
> 
> In wilc1000, the bus interface is up in probe but we don't have
> access
> to mac address via register until the driver starts the wilc firmware
> because of design limitation. This information is only available
> after
> the MAC layer is initialized.

So... initialize the MAC layer and read the address, then stop the card
until dev open which reloads and reinits? That's what eg Atmel does
(though it has a special "read the MAC only" firmware to do that):

	/* No stored firmware so load a small stub which just
	   tells us the MAC address */
	int i;
	priv->card_type = CARD_TYPE_EEPROM;
	atmel_write16(dev, BSR, BSS_IRAM);
	atmel_copy_to_card(dev, 0, mac_reader, sizeof(mac_reader));
	atmel_set_gcr(dev, GCR_REMAP);
	atmel_clear_gcr(priv->dev, 0x0040);
	atmel_write16(dev, BSR, BSS_SRAM);
	for (i = LOOP_RETRY_LIMIT; i; i--)
		if (atmel_read16(dev, MR3) & MAC_BOOT_COMPLETE)
			break;
	if (i == 0) {
		printk(KERN_ALERT "%s: MAC failed to boot MAC address reader.\n", dev->name);
	} else {

		atmel_copy_to_host(dev, addr, atmel_read16(dev, MR2), 6);
		eth_hw_addr_set(dev, addr);
		/* got address, now squash it again until the network
		   interface is opened */
		if (priv->bus_type == BUS_TYPE_PCCARD)
			atmel_write16(dev, GCR, 0x0060);
		atmel_write16(dev, GCR, 0x0040);
		rc = 1;
	}

Dan

> 
> 
> Regards,
> Ajay


  reply	other threads:[~2023-02-10 21:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 14:24 wilc1000 MAC address is 00:00:00:00:00:00 Heiko Thiery
2023-02-09 17:15 ` Ajay.Kathat
2023-02-09 17:48   ` Jakub Kicinski
2023-02-09 18:51     ` Ajay.Kathat
2023-02-09 21:07       ` Jakub Kicinski
2023-02-09 21:19         ` Michael Walle
2023-02-10  9:17           ` Heiko Thiery
2023-02-10  9:25             ` Kalle Valo
2023-02-10 19:12               ` Ajay.Kathat
2023-02-10 21:28                 ` Dan Williams [this message]
2023-02-15 20:14                   ` Johannes Berg
2023-02-23 10:44                     ` Heiko Thiery
2023-02-23 21:48                       ` Ajay.Kathat
2023-02-09 18:40   ` Heiko Thiery
2023-02-09 19:09     ` Ajay.Kathat

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=aef63f6a367896950f9e61041cfcff4b99bd6c7d.camel@redhat.com \
    --to=dcbw@redhat.com \
    --cc=Ajay.Kathat@microchip.com \
    --cc=Amisha.Patel@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=Sripad.Balwadgi@microchip.com \
    --cc=bgalvani@redhat.com \
    --cc=heiko.thiery@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=netdev@vger.kernel.org \
    --cc=thaller@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).