Skip to content

Commit 553217c

Browse files
cthbleachbitdavem330
authored andcommitted
ethernet: aquantia: Try MAC address from device tree
Apple M1 Mac minis (2020) with 10GE NICs do not have MAC address in the card, but instead need to obtain MAC addresses from the device tree. In this case the hardware will report an invalid MAC. Currently atlantic driver does not query the DT for MAC address and will randomly assign a MAC if the NIC doesn't have a permanent MAC burnt in. This patch causes the driver to perfer a valid MAC address from OF (if present) over HW self-reported MAC and only fall back to a random MAC address when neither of them is valid. Signed-off-by: Tianhao Chai <[email protected]> Reviewed-by: Igor Russkikh <[email protected]> Reviewed-by: Hector Martin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 213f5f8 commit 553217c

File tree

1 file changed

+14
-10
lines changed
  • drivers/net/ethernet/aquantia/atlantic

1 file changed

+14
-10
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_nic.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,22 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
316316
aq_macsec_init(self);
317317
#endif
318318

319-
mutex_lock(&self->fwreq_mutex);
320-
err = self->aq_fw_ops->get_mac_permanent(self->aq_hw, addr);
321-
mutex_unlock(&self->fwreq_mutex);
322-
if (err)
323-
goto err_exit;
319+
if (platform_get_ethdev_address(&self->pdev->dev, self->ndev) != 0) {
320+
// If DT has none or an invalid one, ask device for MAC address
321+
mutex_lock(&self->fwreq_mutex);
322+
err = self->aq_fw_ops->get_mac_permanent(self->aq_hw, addr);
323+
mutex_unlock(&self->fwreq_mutex);
324324

325-
eth_hw_addr_set(self->ndev, addr);
325+
if (err)
326+
goto err_exit;
326327

327-
if (!is_valid_ether_addr(self->ndev->dev_addr) ||
328-
!aq_nic_is_valid_ether_addr(self->ndev->dev_addr)) {
329-
netdev_warn(self->ndev, "MAC is invalid, will use random.");
330-
eth_hw_addr_random(self->ndev);
328+
if (is_valid_ether_addr(addr) &&
329+
aq_nic_is_valid_ether_addr(addr)) {
330+
eth_hw_addr_set(self->ndev, addr);
331+
} else {
332+
netdev_warn(self->ndev, "MAC is invalid, will use random.");
333+
eth_hw_addr_random(self->ndev);
334+
}
331335
}
332336

333337
#if defined(AQ_CFG_MAC_ADDR_PERMANENT)

0 commit comments

Comments
 (0)