Re: [PATCH v6] ice: Add get/set hw address for VFs using devlink commands

From: Simon Horman
Date: Tue Mar 26 2024 - 10:12:15 EST


On Thu, Mar 21, 2024 at 01:46:25PM +0530, Karthik Sundaravel wrote:
> Changing the MAC address of the VFs is currently unsupported via devlink.
> Add the function handlers to set and get the HW address for the VFs.
>
> Signed-off-by: Karthik Sundaravel <ksundara@xxxxxxxxxx>
> ---
> drivers/net/ethernet/intel/ice/ice_devlink.c | 66 +++++++++++++++++++-
> drivers/net/ethernet/intel/ice/ice_sriov.c | 62 ++++++++++++++++++
> drivers/net/ethernet/intel/ice/ice_sriov.h | 8 +++
> 3 files changed, 135 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c
> index 80dc5445b50d..35c7cfc8ce9a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_devlink.c
> +++ b/drivers/net/ethernet/intel/ice/ice_devlink.c
> @@ -1576,6 +1576,69 @@ void ice_devlink_destroy_pf_port(struct ice_pf *pf)
> devlink_port_unregister(&pf->devlink_port);
> }
>
> +/**
> + * ice_devlink_port_get_vf_fn_mac - .port_fn_hw_addr_get devlink handler
> + * @port: devlink port structure
> + * @hw_addr: MAC address of the port
> + * @hw_addr_len: length of MAC address
> + * @extack: extended netdev ack structure
> + *
> + * Callback for the devlink .port_fn_hw_addr_get operation
> + * Return: zero on success or an error code on failure.
> + */
> +
> +static int ice_devlink_port_get_vf_fn_mac(struct devlink_port *port,
> + u8 *hw_addr, int *hw_addr_len,
> + struct netlink_ext_ack *extack)
> +{
> + struct ice_vf *vf = container_of(port, struct ice_vf, devlink_port);

nit: blank line here please.

Flagged by checkpatch.

> + if (!vf) {

Given the way that container_of works, I don't think vf can be NULL.

Flagged by Smatch.

> + NL_SET_ERR_MSG_MOD(extack, "Unable to get the vf");
> + return -EINVAL;
> + }
> + ether_addr_copy(hw_addr, vf->dev_lan_addr);
> + *hw_addr_len = ETH_ALEN;
> +
> + return 0;
> +}

..