diff mbox series

[net-next,7/7] sfc: add support for devlink port_function_hw_addr_set in ef100

Message ID 20230119113140.20208-8-alejandro.lucero-palau@amd.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series sfc: devlink support for ef100 | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers warning 1 maintainers not CCed: habetsm.xilinx@gmail.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 56 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lucero Palau, Alejandro Jan. 19, 2023, 11:31 a.m. UTC
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 | 44 ++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

Comments

Jiri Pirko Jan. 19, 2023, 12:27 p.m. UTC | #1
Thu, Jan 19, 2023 at 12:31:40PM 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 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 | 44 ++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
>diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c
>index 2a57c4f6d2b2..a85b2d4e54ab 100644
>--- a/drivers/net/ethernet/sfc/efx_devlink.c
>+++ b/drivers/net/ethernet/sfc/efx_devlink.c
>@@ -472,6 +472,49 @@ 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,

Similar comments here as for the _get callback: embed devlink_port
struct, use extack.


>+				     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 = efx_mae_get_mport(devlink->efx, port->index);
>+	if (!mport_desc)
>+		return -EINVAL;
>+
>+	if (!ef100_mport_is_vf(mport_desc))
>+		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) {
>+		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;
>+	}
>+
>+	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);
>+
>+	return rc;
>+}
>+
> static int efx_devlink_info_get(struct devlink *devlink,
> 				struct devlink_info_req *req,
> 				struct netlink_ext_ack *extack)
>@@ -486,6 +529,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
>
Lucero Palau, Alejandro Jan. 19, 2023, 3:10 p.m. UTC | #2
On 1/19/23 12:27, Jiri Pirko wrote:
> Thu, Jan 19, 2023 at 12:31:40PM 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 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 | 44 ++++++++++++++++++++++++++
>> 1 file changed, 44 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c
>> index 2a57c4f6d2b2..a85b2d4e54ab 100644
>> --- a/drivers/net/ethernet/sfc/efx_devlink.c
>> +++ b/drivers/net/ethernet/sfc/efx_devlink.c
>> @@ -472,6 +472,49 @@ 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,
> Similar comments here as for the _get callback: embed devlink_port
> struct, use extack.
>

I'll do.

Thanks


>> +				     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 = efx_mae_get_mport(devlink->efx, port->index);
>> +	if (!mport_desc)
>> +		return -EINVAL;
>> +
>> +	if (!ef100_mport_is_vf(mport_desc))
>> +		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) {
>> +		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;
>> +	}
>> +
>> +	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);
>> +
>> +	return rc;
>> +}
>> +
>> static int efx_devlink_info_get(struct devlink *devlink,
>> 				struct devlink_info_req *req,
>> 				struct netlink_ext_ack *extack)
>> @@ -486,6 +529,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
>>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/efx_devlink.c b/drivers/net/ethernet/sfc/efx_devlink.c
index 2a57c4f6d2b2..a85b2d4e54ab 100644
--- a/drivers/net/ethernet/sfc/efx_devlink.c
+++ b/drivers/net/ethernet/sfc/efx_devlink.c
@@ -472,6 +472,49 @@  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 = efx_mae_get_mport(devlink->efx, port->index);
+	if (!mport_desc)
+		return -EINVAL;
+
+	if (!ef100_mport_is_vf(mport_desc))
+		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) {
+		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;
+	}
+
+	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);
+
+	return rc;
+}
+
 static int efx_devlink_info_get(struct devlink *devlink,
 				struct devlink_info_req *req,
 				struct netlink_ext_ack *extack)
@@ -486,6 +529,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)