Skip to content

Commit

Permalink
sfc: obtain device mac address based on firmware handle for ef100
Browse files Browse the repository at this point in the history
Getting device mac address is currently based on a specific MCDI command
only available for the PF. This patch changes the MCDI command to a
generic one for PFs and VFs based on a client handle. This allows both
PFs and VFs to ask for their mac address during initialization using the
CLIENT_HANDLE_SELF.

Moreover, the patch allows other client handles which will be used by
the PF to ask for mac addresses linked to VFs. This is necessary for
suporting the port_function_hw_addr_get devlink function in further
patches.

Signed-off-by: Alejandro Lucero <alejandro.lucero-palau@amd.com>
Acked-by: Martin Habets <habetsm.xilinx@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Alejandro Lucero authored and Paolo Abeni committed Feb 16, 2023
1 parent 25414b2 commit 7e056e2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
10 changes: 10 additions & 0 deletions drivers/net/ethernet/sfc/ef100_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
{
struct efx_nic *efx = &probe_data->efx;
struct efx_probe_data **probe_ptr;
struct ef100_nic_data *nic_data;
struct net_device *net_dev;
int rc;

Expand Down Expand Up @@ -410,6 +411,15 @@ int ef100_probe_netdev(struct efx_probe_data *probe_data)
/* Don't fail init if RSS setup doesn't work. */
efx_mcdi_push_default_indir_table(efx, efx->n_rx_channels);

nic_data = efx->nic_data;
rc = ef100_get_mac_address(efx, net_dev->perm_addr, CLIENT_HANDLE_SELF,
efx->type->is_vf);
if (rc)
return rc;
/* Assign MAC address */
eth_hw_addr_set(net_dev, net_dev->perm_addr);
ether_addr_copy(nic_data->port_id, net_dev->perm_addr);

/* devlink creation, registration and lock */
rc = efx_probe_devlink_and_lock(efx);
if (rc)
Expand Down
37 changes: 19 additions & 18 deletions drivers/net/ethernet/sfc/ef100_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,34 @@ 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)
int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
int client_handle, bool empty_ok)
{
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_MAC_ADDRESSES_OUT_LEN);
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1));
MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_MAC_ADDRESSES_IN_LEN);
size_t outlen;
int rc;

BUILD_BUG_ON(MC_CMD_GET_MAC_ADDRESSES_IN_LEN != 0);
MCDI_SET_DWORD(inbuf, GET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
client_handle);

rc = efx_mcdi_rpc(efx, MC_CMD_GET_MAC_ADDRESSES, NULL, 0,
outbuf, sizeof(outbuf), &outlen);
rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_MAC_ADDRESSES, inbuf,
sizeof(inbuf), 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));
if (outlen >= MC_CMD_GET_CLIENT_MAC_ADDRESSES_OUT_LEN(1)) {
ether_addr_copy(mac_address,
MCDI_PTR(outbuf, GET_CLIENT_MAC_ADDRESSES_OUT_MAC_ADDRS));
} else if (empty_ok) {
pci_warn(efx->pci_dev,
"No MAC address provisioned for client ID %#x.\n",
client_handle);
eth_zero_addr(mac_address);
} else {
return -ENOENT;
}
return 0;
}

Expand Down Expand Up @@ -1117,13 +1128,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx)
struct net_device *net_dev = efx->net_dev;
int rc;

rc = ef100_get_mac_address(efx, net_dev->perm_addr);
if (rc)
goto fail;
/* Assign MAC address */
eth_hw_addr_set(net_dev, net_dev->perm_addr);
memcpy(nic_data->port_id, net_dev->perm_addr, ETH_ALEN);

if (!nic_data->grp_mae)
return 0;

Expand Down Expand Up @@ -1163,9 +1167,6 @@ int ef100_probe_netdev_pf(struct efx_nic *efx)
efx->fixed_features |= NETIF_F_HW_TC;
}
#endif
return 0;

fail:
return rc;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/sfc/ef100_nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ int efx_ef100_init_datapath_caps(struct efx_nic *efx);
int ef100_phy_probe(struct efx_nic *efx);
int ef100_filter_table_probe(struct efx_nic *efx);

int ef100_get_mac_address(struct efx_nic *efx, u8 *mac_address,
int client_handle, bool empty_ok);
#endif /* EFX_EF100_NIC_H */

0 comments on commit 7e056e2

Please sign in to comment.