summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/sfc
diff options
context:
space:
mode:
authorEdward Cree <ecree@solarflare.com>2020-07-27 13:05:31 +0100
committerDavid S. Miller <davem@davemloft.net>2020-07-27 12:26:56 -0700
commit29ec1b27e73990cf32aedd9208aa6eff2d4a1e5e (patch)
tree94e1ba4f056999692f59de0592e66e1098062fb9 /drivers/net/ethernet/sfc
parent99a23c1168b7a6b8d1d1b228788b32749b06cbfe (diff)
downloadlinux-29ec1b27e73990cf32aedd9208aa6eff2d4a1e5e.tar.gz
linux-29ec1b27e73990cf32aedd9208aa6eff2d4a1e5e.tar.bz2
linux-29ec1b27e73990cf32aedd9208aa6eff2d4a1e5e.zip
sfc_ef100: read device MAC address at probe time
Signed-off-by: Edward Cree <ecree@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/sfc')
-rw-r--r--drivers/net/ethernet/sfc/ef100_nic.c40
-rw-r--r--drivers/net/ethernet/sfc/ef100_nic.h1
2 files changed, 40 insertions, 1 deletions
diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
index dc7d4aaa2b04..1161190391b1 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.c
+++ b/drivers/net/ethernet/sfc/ef100_nic.c
@@ -126,6 +126,26 @@ static void ef100_mcdi_reboot_detected(struct efx_nic *efx)
/* MCDI calls
*/
+static int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address)
+{
+ MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN);
+ size_t outlen;
+ int rc;
+
+ BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0);
+
+ rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0,
+ outbuf, sizeof(outbuf), &outlen);
+ if (rc)
+ return rc;
+ if (outlen < MC_CMD_GET_MAC_ADDRESSES_OUT_LEN)
+ return -EIO;
+
+ ether_addr_copy(mac_address,
+ MCDI_PTR(outbuf, GET_MAC_ADDRESSES_OUT_MAC_ADDR_BASE));
+ return 0;
+}
+
static int efx_ef100_init_datapath_caps(struct efx_nic *efx)
{
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CAPABILITIES_V7_OUT_LEN);
@@ -540,7 +560,25 @@ fail:
int ef100_probe_pf(struct efx_nic *efx)
{
- return ef100_probe_main(efx);
+ struct net_device *net_dev = efx->net_dev;
+ struct ef100_nic_data *nic_data;
+ int rc = ef100_probe_main(efx);
+
+ if (rc)
+ goto fail;
+
+ nic_data = efx->nic_data;
+ rc = ef100_get_mac_address(efx, net_dev->perm_addr);
+ if (rc)
+ goto fail;
+ /* Assign MAC address */
+ memcpy(net_dev->dev_addr, net_dev->perm_addr, ETH_ALEN);
+ memcpy(nic_data->port_id, net_dev->perm_addr, ETH_ALEN);
+
+ return 0;
+
+fail:
+ return rc;
}
void ef100_remove(struct efx_nic *efx)
diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
index 7744ec85bec6..6367bbb2c9b3 100644
--- a/drivers/net/ethernet/sfc/ef100_nic.h
+++ b/drivers/net/ethernet/sfc/ef100_nic.h
@@ -24,6 +24,7 @@ struct ef100_nic_data {
u32 datapath_caps2;
u32 datapath_caps3;
u16 warm_boot_count;
+ u8 port_id[ETH_ALEN];
DECLARE_BITMAP(evq_phases, EFX_MAX_CHANNELS);
};