linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <alejandro.lucero-palau@amd.com>
To: <netdev@vger.kernel.org>, <linux-net-drivers@amd.com>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<edumazet@google.com>, <habetsm.xilinx@gmail.com>,
	<ecree.xilinx@gmail.com>, <linux-doc@vger.kernel.org>,
	<corbet@lwn.net>, <jiri@nvidia.com>,
	"Alejandro Lucero" <alejandro.lucero-palau@amd.com>
Subject: [PATCH v4 net-next 8/8] sfc: add support for devlink port_function_hw_addr_set in ef100
Date: Tue, 31 Jan 2023 14:58:22 +0000	[thread overview]
Message-ID: <20230131145822.36208-9-alejandro.lucero-palau@amd.com> (raw)
In-Reply-To: <20230131145822.36208-1-alejandro.lucero-palau@amd.com>

From: Alejandro Lucero <alejandro.lucero-palau@amd.com>

Using the builtin client handle id infrastructure, this patch adds
support for setting the mac address linked to mports in ef100. This
implies to execute an MCDI command for giving the address to the
firmware for the specific devlink port.

Signed-off-by: Alejandro Lucero <alejandro.lucero-palau@amd.com>
---
 drivers/net/ethernet/sfc/efx_devlink.c | 50 ++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c
index 709418b1935a..454187b7f98b 100644
--- a/drivers/net/ethernet/sfc/efx_devlink.c
+++ b/drivers/net/ethernet/sfc/efx_devlink.c
@@ -107,6 +107,55 @@ static int efx_devlink_port_addr_get(struct devlink_port *port, u8 *hw_addr,
 	return rc;
 }
 
+static int efx_devlink_port_addr_set(struct devlink_port *port,
+				     const u8 *hw_addr, int hw_addr_len,
+				     struct netlink_ext_ack *extack)
+{
+	MCDI_DECLARE_BUF(inbuf, MC_CMD_SET_CLIENT_MAC_ADDRESSES_IN_LEN(1));
+	struct efx_devlink *devlink = devlink_priv(port->devlink);
+	struct mae_mport_desc *mport_desc;
+	efx_qword_t pciefn;
+	u32 client_id;
+	int rc;
+
+	mport_desc = container_of(port, struct mae_mport_desc, dl_port);
+
+	if (!ef100_mport_is_vf(mport_desc)) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "port mac change not allowed (mport: %u)",
+				   mport_desc->mport_id);
+		return -EPERM;
+	}
+
+	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);
+
+	rc = efx_ef100_lookup_client_id(devlink->efx, pciefn, &client_id);
+	if (rc) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "No internal client_ID for port (mport: %u)",
+				   mport_desc->mport_id);
+		return rc;
+	}
+
+	MCDI_SET_DWORD(inbuf, SET_CLIENT_MAC_ADDRESSES_IN_CLIENT_HANDLE,
+		       client_id);
+
+	ether_addr_copy(MCDI_PTR(inbuf, SET_CLIENT_MAC_ADDRESSES_IN_MAC_ADDRS),
+			hw_addr);
+
+	rc = efx_mcdi_rpc(devlink->efx, MC_CMD_SET_CLIENT_MAC_ADDRESSES, inbuf,
+			  sizeof(inbuf), NULL, 0, NULL);
+	if (rc)
+		NL_SET_ERR_MSG_FMT(extack,
+				   "sfc MC_CMD_SET_CLIENT_MAC_ADDRESSES mcdi error (mport: %u)",
+				   mport_desc->mport_id);
+
+	return rc;
+}
+
 static int efx_devlink_info_nvram_partition(struct efx_nic *efx,
 					    struct devlink_info_req *req,
 					    unsigned int partition_type,
@@ -513,6 +562,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,
+	.port_function_hw_addr_set	= efx_devlink_port_addr_set,
 };
 
 static struct devlink_port *ef100_set_devlink_port(struct efx_nic *efx, u32 idx)
-- 
2.17.1


      parent reply	other threads:[~2023-01-31 14:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 14:58 [PATCH v4 net-next 0/8] sfc: devlink support for ef100 alejandro.lucero-palau
2023-01-31 14:58 ` [PATCH v4 net-next 1/8] sfc: add " alejandro.lucero-palau
2023-01-31 16:00   ` Jiri Pirko
2023-02-01  8:49     ` Lucero Palau, Alejandro
2023-02-01  9:07       ` Jiri Pirko
2023-02-01 19:01         ` Jakub Kicinski
2023-02-02  6:41           ` Lucero Palau, Alejandro
2023-02-02  9:24           ` Martin Habets
2023-02-02 17:43             ` Jakub Kicinski
2023-01-31 14:58 ` [PATCH v4 net-next 2/8] sfc: add devlink info " alejandro.lucero-palau
2023-01-31 16:03   ` Jiri Pirko
2023-02-01  9:09     ` Lucero Palau, Alejandro
2023-02-01 12:03       ` Jiri Pirko
2023-01-31 14:58 ` [PATCH v4 net-next 3/8] sfc: enumerate mports in ef100 alejandro.lucero-palau
2023-02-01 11:12   ` kernel test robot
2023-01-31 14:58 ` [PATCH v4 net-next 4/8] sfc: add mport lookup based on driver's mport data alejandro.lucero-palau
2023-01-31 14:58 ` [PATCH v4 net-next 5/8] sfc: add devlink port support for ef100 alejandro.lucero-palau
2023-01-31 16:12   ` Jiri Pirko
2023-02-01  9:03     ` Lucero Palau, Alejandro
2023-02-01  9:08       ` Jiri Pirko
2023-02-01 14:57   ` kernel test robot
2023-01-31 14:58 ` [PATCH v4 net-next 6/8] sfc: obtain device mac address based on firmware handle " alejandro.lucero-palau
2023-01-31 14:58 ` [PATCH v4 net-next 7/8] sfc: add support for devlink port_function_hw_addr_get in ef100 alejandro.lucero-palau
2023-02-01 19:15   ` kernel test robot
2023-01-31 14:58 ` alejandro.lucero-palau [this message]

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=20230131145822.36208-9-alejandro.lucero-palau@amd.com \
    --to=alejandro.lucero-palau@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=habetsm.xilinx@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).