From: Eli Cohen <[email protected]>

Add code to accept MAC configuration through vdpa tool. The MAC is
written into the config struct and later can be retrieved through
get_config().

Examples:
1. Configure MAC:
$ vdpa dev config set vdpa0 mac 00:11:22:33:44:55

2. Show configured params:
$ vdpa dev config show
vdpa0: mac 00:11:22:33:44:55 link down link_announce false mtu 0 speed 0 duplex 0

Signed-off-by: Eli Cohen <[email protected]>
Reviewed-by: Parav Pandit <[email protected]>
---
 drivers/vdpa/mlx5/net/mlx5_vnet.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c 
b/drivers/vdpa/mlx5/net/mlx5_vnet.c
index ece2183e7b20..51a3fc4cde4d 100644
--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
@@ -1972,6 +1972,22 @@ struct mlx5_vdpa_mgmtdev {
        struct mlx5_vdpa_net *ndev;
 };
 
+static int mlx5_vdpa_net_dev_config_set(struct vdpa_mgmt_dev *v_mdev,
+                                       struct vdpa_device *vdev,
+                                       const struct vdpa_dev_config_set_attr 
*attrs)
+{
+       struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct 
mlx5_vdpa_mgmtdev, mgtdev);
+       struct mlx5_vdpa_net *ndev = mgtdev->ndev;
+
+       if (attrs->mask.mtu_valid)
+               return -EOPNOTSUPP;
+
+       if (attrs->mask.mac_valid)
+               memcpy(ndev->config.mac, attrs->cfg.mac, ETH_ALEN);
+
+       return 0;
+}
+
 static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name)
 {
        struct mlx5_vdpa_mgmtdev *mgtdev = container_of(v_mdev, struct 
mlx5_vdpa_mgmtdev, mgtdev);
@@ -2044,6 +2060,7 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev 
*v_mdev, struct vdpa_device *
 static const struct vdpa_mgmtdev_ops mdev_ops = {
        .dev_add = mlx5_vdpa_dev_add,
        .dev_del = mlx5_vdpa_dev_del,
+       .dev_config_set = mlx5_vdpa_net_dev_config_set,
 };
 
 static struct virtio_device_id id_table[] = {
-- 
2.26.2

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to