From: Martin Habets <habetsm.xilinx@gmail.com>
To: alejandro.lucero-palau@amd.com
Cc: netdev@vger.kernel.org, linux-net-drivers@amd.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, ecree.xilinx@gmail.com,
linux-doc@vger.kernel.org, corbet@lwn.net, jiri@nvidia.com
Subject: Re: [PATCH v6 net-next 6/8] sfc: obtain device mac address based on firmware handle for ef100
Date: Fri, 10 Feb 2023 08:50:51 +0000 [thread overview]
Message-ID: <Y+YFa62Yuz9kHtzM@gmail.com> (raw)
In-Reply-To: <20230208142519.31192-7-alejandro.lucero-palau@amd.com>
On Wed, Feb 08, 2023 at 02:25:17PM +0000, alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alejandro.lucero-palau@amd.com>
>
> 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>
> ---
> drivers/net/ethernet/sfc/ef100_netdev.c | 10 +++++++
> drivers/net/ethernet/sfc/ef100_nic.c | 37 +++++++++++++------------
> drivers/net/ethernet/sfc/ef100_nic.h | 2 ++
> 3 files changed, 31 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/ef100_netdev.c b/drivers/net/ethernet/sfc/ef100_netdev.c
> index 368147359299..d916877b5a9a 100644
> --- a/drivers/net/ethernet/sfc/ef100_netdev.c
> +++ b/drivers/net/ethernet/sfc/ef100_netdev.c
> @@ -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;
>
> @@ -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)
> diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
> index aa11f0925e27..aa48c79a2149 100644
> --- a/drivers/net/ethernet/sfc/ef100_nic.c
> +++ b/drivers/net/ethernet/sfc/ef100_nic.c
> @@ -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;
> }
>
> @@ -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;
>
> @@ -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;
> }
>
> diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
> index 496aea43c60f..e59044072333 100644
> --- a/drivers/net/ethernet/sfc/ef100_nic.h
> +++ b/drivers/net/ethernet/sfc/ef100_nic.h
> @@ -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 */
> --
> 2.17.1
next prev parent reply other threads:[~2023-02-10 8:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 14:25 [PATCH v6 net-next 0/8] sfc: devlink support for ef100 alejandro.lucero-palau
2023-02-08 14:25 ` [PATCH v6 net-next 1/8] sfc: add " alejandro.lucero-palau
2023-02-10 8:28 ` Martin Habets
2023-02-08 14:25 ` [PATCH v6 net-next 2/8] sfc: add devlink info " alejandro.lucero-palau
2023-02-08 14:38 ` Jiri Pirko
2023-02-08 15:24 ` Lucero Palau, Alejandro
2023-02-09 10:46 ` Lucero Palau, Alejandro
2023-02-10 11:56 ` Jiri Pirko
2023-02-10 8:40 ` Martin Habets
2023-02-10 9:07 ` Lucero Palau, Alejandro
2023-02-10 15:01 ` Lucero Palau, Alejandro
2023-02-08 14:25 ` [PATCH v6 net-next 3/8] sfc: enumerate mports in ef100 alejandro.lucero-palau
2023-02-10 8:46 ` Martin Habets
2023-02-08 14:25 ` [PATCH v6 net-next 4/8] sfc: add mport lookup based on driver's mport data alejandro.lucero-palau
2023-02-10 8:47 ` Martin Habets
2023-02-08 14:25 ` [PATCH v6 net-next 5/8] sfc: add devlink port support for ef100 alejandro.lucero-palau
2023-02-10 8:49 ` Martin Habets
2023-02-08 14:25 ` [PATCH v6 net-next 6/8] sfc: obtain device mac address based on firmware handle " alejandro.lucero-palau
2023-02-10 8:50 ` Martin Habets [this message]
2023-02-08 14:25 ` [PATCH v6 net-next 7/8] sfc: add support for devlink port_function_hw_addr_get in ef100 alejandro.lucero-palau
2023-02-08 14:40 ` Jiri Pirko
2023-02-10 8:52 ` Martin Habets
2023-02-08 14:25 ` [PATCH v6 net-next 8/8] sfc: add support for devlink port_function_hw_addr_set " alejandro.lucero-palau
2023-02-08 14:40 ` Jiri Pirko
2023-02-10 8:53 ` Martin Habets
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=Y+YFa62Yuz9kHtzM@gmail.com \
--to=habetsm.xilinx@gmail.com \
--cc=alejandro.lucero-palau@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-net-drivers@amd.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@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 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.