Re: [PATCH linux-next 8/9] vdpa/mlx5: Support configuration of MAC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2021/2/24 2:18 下午, Parav Pandit wrote:
From: Eli Cohen <elic@xxxxxxxxxx>

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 <elic@xxxxxxxxxx>
Reviewed-by: Parav Pandit <parav@xxxxxxxxxx>
---


Acked-by: Jason Wang <jasowang@xxxxxxxxxx>


  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[] = {

_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux