All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
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, habetsm@gmail.com, ecree.xilinx@gmail.com
Subject: Re: [PATCH net-next 6/7] sfc: add support for port_function_hw_addr_get devlink in ef100
Date: Thu, 19 Jan 2023 13:37:22 +0100	[thread overview]
Message-ID: <Y8k5glNLX1eE2iKE@nanopsycho> (raw)
In-Reply-To: <20230119113140.20208-7-alejandro.lucero-palau@amd.com>

Thu, Jan 19, 2023 at 12:31:39PM CET, alejandro.lucero-palau@amd.com wrote:
>From: Alejandro Lucero <alejandro.lucero-palau@amd.com>
>
>Using the builtin client handle id infrastructure, this patch adds
>support for obtaining the mac address linked to mports in ef100. This
>implies to execute an MCDI command for getting the data from the
>firmware for each devlink port.
>
>Signed-off-by: Alejandro Lucero <alejandro.lucero-palau@amd.com>
>---
> drivers/net/ethernet/sfc/ef100_nic.c   | 27 ++++++++++++++++
> drivers/net/ethernet/sfc/ef100_nic.h   |  1 +
> drivers/net/ethernet/sfc/ef100_rep.c   |  8 +++++
> drivers/net/ethernet/sfc/ef100_rep.h   |  1 +
> drivers/net/ethernet/sfc/efx_devlink.c | 44 ++++++++++++++++++++++++++
> 5 files changed, 81 insertions(+)
>
>diff --git a/drivers/net/ethernet/sfc/ef100_nic.c b/drivers/net/ethernet/sfc/ef100_nic.c
>index f4e913593f2b..4400ce622228 100644
>--- a/drivers/net/ethernet/sfc/ef100_nic.c
>+++ b/drivers/net/ethernet/sfc/ef100_nic.c
>@@ -1121,6 +1121,33 @@ static int ef100_probe_main(struct efx_nic *efx)
> 	return rc;
> }
> 
>+/* MCDI commands are related to the same device issuing them. This function
>+ * allows to do an MCDI command on behalf of another device, mainly PFs setting
>+ * things for VFs.
>+ */
>+int efx_ef100_lookup_client_id(struct efx_nic *efx, efx_qword_t pciefn, u32 *id)
>+{
>+	MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_CLIENT_HANDLE_OUT_LEN);
>+	MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_CLIENT_HANDLE_IN_LEN);
>+	u64 pciefn_flat = le64_to_cpu(pciefn.u64[0]);
>+	size_t outlen;
>+	int rc;
>+
>+	MCDI_SET_DWORD(inbuf, GET_CLIENT_HANDLE_IN_TYPE,
>+		       MC_CMD_GET_CLIENT_HANDLE_IN_TYPE_FUNC);
>+	MCDI_SET_QWORD(inbuf, GET_CLIENT_HANDLE_IN_FUNC,
>+		       pciefn_flat);
>+
>+	rc = efx_mcdi_rpc(efx, MC_CMD_GET_CLIENT_HANDLE, inbuf, sizeof(inbuf),
>+			  outbuf, sizeof(outbuf), &outlen);
>+	if (rc)
>+		return rc;
>+	if (outlen < sizeof(outbuf))
>+		return -EIO;
>+	*id = MCDI_DWORD(outbuf, GET_CLIENT_HANDLE_OUT_HANDLE);
>+	return 0;
>+}
>+
> int ef100_probe_netdev_pf(struct efx_nic *efx)
> {
> 	struct ef100_nic_data *nic_data = efx->nic_data;
>diff --git a/drivers/net/ethernet/sfc/ef100_nic.h b/drivers/net/ethernet/sfc/ef100_nic.h
>index e59044072333..f1ed481c1260 100644
>--- a/drivers/net/ethernet/sfc/ef100_nic.h
>+++ b/drivers/net/ethernet/sfc/ef100_nic.h
>@@ -94,4 +94,5 @@ 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);
>+int efx_ef100_lookup_client_id(struct efx_nic *efx, efx_qword_t pciefn, u32 *id);
> #endif	/* EFX_EF100_NIC_H */
>diff --git a/drivers/net/ethernet/sfc/ef100_rep.c b/drivers/net/ethernet/sfc/ef100_rep.c
>index ff0c8da61919..974c9ff901a0 100644
>--- a/drivers/net/ethernet/sfc/ef100_rep.c
>+++ b/drivers/net/ethernet/sfc/ef100_rep.c
>@@ -362,6 +362,14 @@ bool ef100_mport_on_local_intf(struct efx_nic *efx,
> 		     mport_desc->interface_idx == nic_data->local_mae_intf;
> }
> 
>+bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc)
>+{
>+	bool pcie_func;
>+
>+	pcie_func = ef100_mport_is_pcie_vnic(mport_desc);
>+	return pcie_func && (mport_desc->vf_idx != MAE_MPORT_DESC_VF_IDX_NULL);
>+}
>+
> void efx_ef100_init_reps(struct efx_nic *efx)
> {
> 	struct ef100_nic_data *nic_data = efx->nic_data;
>diff --git a/drivers/net/ethernet/sfc/ef100_rep.h b/drivers/net/ethernet/sfc/ef100_rep.h
>index 9cca41614982..74853ccbc937 100644
>--- a/drivers/net/ethernet/sfc/ef100_rep.h
>+++ b/drivers/net/ethernet/sfc/ef100_rep.h
>@@ -75,4 +75,5 @@ void efx_ef100_fini_reps(struct efx_nic *efx);
> struct mae_mport_desc;
> bool ef100_mport_on_local_intf(struct efx_nic *efx,
> 			       struct mae_mport_desc *mport_desc);
>+bool ef100_mport_is_vf(struct mae_mport_desc *mport_desc);
> #endif /* EF100_REP_H */
>diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c
>index bb19d3ad7ffd..2a57c4f6d2b2 100644
>--- a/drivers/net/ethernet/sfc/efx_devlink.c
>+++ b/drivers/net/ethernet/sfc/efx_devlink.c
>@@ -429,6 +429,49 @@ static int efx_devlink_add_port(struct efx_nic *efx,
> 	return err;
> }
> 
>+static int efx_devlink_port_addr_get(struct devlink_port *port, u8 *hw_addr,
>+				     int *hw_addr_len,
>+				     struct netlink_ext_ack *extack)
>+{
>+	struct efx_devlink *devlink = devlink_priv(port->devlink);
>+	struct mae_mport_desc *mport_desc;
>+	efx_qword_t pciefn;
>+	u32 client_id;
>+	int rc = 0;
>+
>+	mport_desc = efx_mae_get_mport(devlink->efx, port->index);

I may be missing something, where do you fail with -EOPNOTSUPP
in case this is called for PHYSICAL port ?



>+	if (!mport_desc)
>+		return -EINVAL;
>+
>+	if (!ef100_mport_on_local_intf(devlink->efx, mport_desc))
>+		goto out;
>+
>+	if (ef100_mport_is_vf(mport_desc))
>+		EFX_POPULATE_QWORD_3(pciefn,
>+				     PCIE_FUNCTION_PF, PCIE_FUNCTION_PF_NULL,
>+				     PCIE_FUNCTION_VF, mport_desc->vf_idx,
>+				     PCIE_FUNCTION_INTF, PCIE_INTERFACE_CALLER);
>+	else
>+		EFX_POPULATE_QWORD_3(pciefn,
>+				     PCIE_FUNCTION_PF, mport_desc->pf_idx,
>+				     PCIE_FUNCTION_VF, PCIE_FUNCTION_VF_NULL,
>+				     PCIE_FUNCTION_INTF, PCIE_INTERFACE_CALLER);
>+
>+	rc = efx_ef100_lookup_client_id(devlink->efx, pciefn, &client_id);
>+	if (rc) {
>+		netif_err(devlink->efx, drv, devlink->efx->net_dev,
>+			  "Failed to get client ID for port index %u, rc %d\n",
>+			  port->index, rc);
>+		return rc;
>+	}
>+
>+	rc = ef100_get_mac_address(devlink->efx, hw_addr, client_id, true);
>+out:
>+	*hw_addr_len = ETH_ALEN;
>+
>+	return rc;
>+}
>+
> static int efx_devlink_info_get(struct devlink *devlink,
> 				struct devlink_info_req *req,
> 				struct netlink_ext_ack *extack)
>@@ -442,6 +485,7 @@ static int efx_devlink_info_get(struct devlink *devlink,
> 
> static const struct devlink_ops sfc_devlink_ops = {
> 	.info_get			= efx_devlink_info_get,
>+	.port_function_hw_addr_get	= efx_devlink_port_addr_get,
> };
> 
> static struct devlink_port *ef100_set_devlink_port(struct efx_nic *efx, u32 idx)
>-- 
>2.17.1
>

  parent reply	other threads:[~2023-01-19 12:41 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 11:31 [PATCH net-next 0/7] sfc: devlink support for ef100 alejandro.lucero-palau
2023-01-19 11:31 ` [PATCH net-next 1/7] sfc: add " alejandro.lucero-palau
2023-01-19 12:14   ` Jiri Pirko
2023-01-19 14:51     ` Lucero Palau, Alejandro
2023-01-19 16:29       ` Lucero Palau, Alejandro
2023-01-20 11:02         ` Jiri Pirko
2023-01-20 11:00       ` Jiri Pirko
2023-01-19 15:50   ` kernel test robot
2023-01-19 17:16   ` Jakub Kicinski
2023-01-19 17:52     ` Lucero Palau, Alejandro
2023-01-19 18:44       ` Jakub Kicinski
2023-01-19 19:08         ` Lucero Palau, Alejandro
2023-01-19 23:40   ` Jacob Keller
2023-01-20 14:11     ` Lucero Palau, Alejandro
2023-01-24  6:13       ` Edward Cree
2023-01-24  7:31         ` Lucero Palau, Alejandro
2023-01-24 11:05     ` Lucero Palau, Alejandro
2023-01-24 22:12       ` Jacob Keller
2023-01-20 13:59   ` kernel test robot
2023-01-19 11:31 ` [PATCH net-next 2/7] sfc: enumerate mports in ef100 alejandro.lucero-palau
2023-01-19 23:48   ` Jacob Keller
2023-01-20 14:13     ` Lucero Palau, Alejandro
2023-01-20 12:47   ` kernel test robot
2023-01-19 11:31 ` [PATCH net-next 3/7] sfc: add mport lookup based on driver's mport data alejandro.lucero-palau
2023-01-19 23:57   ` Jacob Keller
2023-01-20  9:34     ` Lucero Palau, Alejandro
2023-01-20 18:36       ` Keller, Jacob E
2023-01-19 11:31 ` [PATCH net-next 4/7] sfc: add devlink port support for ef100 alejandro.lucero-palau
2023-01-19 12:33   ` Jiri Pirko
2023-01-19 15:03     ` Lucero Palau, Alejandro
2023-01-19 13:37   ` kernel test robot
2023-01-20 21:21   ` kernel test robot
2023-01-19 11:31 ` [PATCH net-next 5/7] sfc: obtain device mac address based on firmware handle " alejandro.lucero-palau
2023-01-19 19:47   ` kernel test robot
2023-01-20  0:03   ` Jacob Keller
2023-01-19 11:31 ` [PATCH net-next 6/7] sfc: add support for port_function_hw_addr_get devlink in ef100 alejandro.lucero-palau
2023-01-19 12:25   ` Jiri Pirko
2023-01-19 14:59     ` Lucero Palau, Alejandro
2023-01-20 11:05       ` Jiri Pirko
2023-01-22 16:41         ` Lucero Palau, Alejandro
2023-01-19 12:37   ` Jiri Pirko [this message]
2023-01-19 15:09     ` Lucero Palau, Alejandro
2023-01-20 11:08       ` Jiri Pirko
2023-01-20 12:48         ` Lucero Palau, Alejandro
2023-01-22 16:36           ` Lucero Palau, Alejandro
2023-01-23  8:38             ` Jiri Pirko
2023-01-23  9:45               ` Lucero Palau, Alejandro
2023-01-23 10:18                 ` Jiri Pirko
2023-01-19 11:31 ` [PATCH net-next 7/7] sfc: add support for devlink port_function_hw_addr_set " alejandro.lucero-palau
2023-01-19 12:27   ` Jiri Pirko
2023-01-19 15:10     ` Lucero Palau, Alejandro
2023-01-20  8:55 ` [PATCH net-next 0/7] sfc: devlink support for ef100 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=Y8k5glNLX1eE2iKE@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=alejandro.lucero-palau@amd.com \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=habetsm@gmail.com \
    --cc=kuba@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.