Commit a007d940 authored by Eli Cohen's avatar Eli Cohen Committed by Michael S. Tsirkin

vdpa/mlx5: Support configuration of MAC

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 while adding a device:
$ vdpa dev add mgmtdev pci/0000:06:00.2 name 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 max_vq_pairs 8 mtu 1500
Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
Reviewed-by: default avatarParav Pandit <parav@nvidia.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20211026175519.87795-8-parav@nvidia.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent ef76eb83
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/vringh.h> #include <linux/vringh.h>
#include <uapi/linux/virtio_net.h> #include <uapi/linux/virtio_net.h>
#include <uapi/linux/virtio_ids.h> #include <uapi/linux/virtio_ids.h>
#include <uapi/linux/vdpa.h>
#include <linux/virtio_config.h> #include <linux/virtio_config.h>
#include <linux/auxiliary_bus.h> #include <linux/auxiliary_bus.h>
#include <linux/mlx5/cq.h> #include <linux/mlx5/cq.h>
...@@ -2524,17 +2525,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, ...@@ -2524,17 +2525,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
goto err_mtu; goto err_mtu;
ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu); ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
err = mlx5_query_nic_vport_mac_address(mdev, 0, 0, config->mac);
if (err)
goto err_mtu;
if (get_link_state(mvdev)) if (get_link_state(mvdev))
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP); ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
else else
ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP);
if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);
} else {
err = mlx5_query_nic_vport_mac_address(mdev, 0, 0, config->mac);
if (err)
goto err_mtu;
}
if (!is_zero_ether_addr(config->mac)) { if (!is_zero_ether_addr(config->mac)) {
pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev)); pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
err = mlx5_mpfs_add_mac(pfmdev, config->mac); err = mlx5_mpfs_add_mac(pfmdev, config->mac);
...@@ -2632,6 +2636,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, ...@@ -2632,6 +2636,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
mgtdev->mgtdev.ops = &mdev_ops; mgtdev->mgtdev.ops = &mdev_ops;
mgtdev->mgtdev.device = mdev->device; mgtdev->mgtdev.device = mdev->device;
mgtdev->mgtdev.id_table = id_table; mgtdev->mgtdev.id_table = id_table;
mgtdev->mgtdev.config_attr_mask = (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR);
mgtdev->madev = madev; mgtdev->madev = madev;
err = vdpa_mgmtdev_register(&mgtdev->mgtdev); err = vdpa_mgmtdev_register(&mgtdev->mgtdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment