Skip to content

Commit 6d17035

Browse files
lulu-github-namemstsirkin
authored andcommitted
vdpa/mlx5: Add the support of set mac address
Add the function to support setting the MAC address. For vdpa/mlx5, the function will use mlx5_mpfs_add_mac to set the mac address Tested in ConnectX-6 Dx device Signed-off-by: Cindy Lu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 218bb7e commit 6d17035

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,9 +3937,37 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
39373937
mgtdev->ndev = NULL;
39383938
}
39393939

3940+
static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *dev,
3941+
const struct vdpa_dev_set_config *add_config)
3942+
{
3943+
struct virtio_net_config *config;
3944+
struct mlx5_core_dev *pfmdev;
3945+
struct mlx5_vdpa_dev *mvdev;
3946+
struct mlx5_vdpa_net *ndev;
3947+
struct mlx5_core_dev *mdev;
3948+
int err = -EOPNOTSUPP;
3949+
3950+
mvdev = to_mvdev(dev);
3951+
ndev = to_mlx5_vdpa_ndev(mvdev);
3952+
mdev = mvdev->mdev;
3953+
config = &ndev->config;
3954+
3955+
down_write(&ndev->reslock);
3956+
if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
3957+
pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
3958+
err = mlx5_mpfs_add_mac(pfmdev, config->mac);
3959+
if (!err)
3960+
ether_addr_copy(config->mac, add_config->net.mac);
3961+
}
3962+
3963+
up_write(&ndev->reslock);
3964+
return err;
3965+
}
3966+
39403967
static const struct vdpa_mgmtdev_ops mdev_ops = {
39413968
.dev_add = mlx5_vdpa_dev_add,
39423969
.dev_del = mlx5_vdpa_dev_del,
3970+
.dev_set_attr = mlx5_vdpa_set_attr,
39433971
};
39443972

39453973
static struct virtio_device_id id_table[] = {

0 commit comments

Comments
 (0)