Skip to content

Commit a007d94

Browse files
elic307imstsirkin
authored andcommitted
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: Eli Cohen <[email protected]> Reviewed-by: Parav Pandit <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent ef76eb8 commit a007d94

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/vringh.h>
77
#include <uapi/linux/virtio_net.h>
88
#include <uapi/linux/virtio_ids.h>
9+
#include <uapi/linux/vdpa.h>
910
#include <linux/virtio_config.h>
1011
#include <linux/auxiliary_bus.h>
1112
#include <linux/mlx5/cq.h>
@@ -2524,17 +2525,20 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name,
25242525
goto err_mtu;
25252526

25262527
ndev->config.mtu = cpu_to_mlx5vdpa16(mvdev, mtu);
2527-
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
2528-
2529-
err = mlx5_query_nic_vport_mac_address(mdev, 0, 0, config->mac);
2530-
if (err)
2531-
goto err_mtu;
25322528

25332529
if (get_link_state(mvdev))
25342530
ndev->config.status |= cpu_to_mlx5vdpa16(mvdev, VIRTIO_NET_S_LINK_UP);
25352531
else
25362532
ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP);
25372533

2534+
if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
2535+
memcpy(ndev->config.mac, add_config->net.mac, ETH_ALEN);
2536+
} else {
2537+
err = mlx5_query_nic_vport_mac_address(mdev, 0, 0, config->mac);
2538+
if (err)
2539+
goto err_mtu;
2540+
}
2541+
25382542
if (!is_zero_ether_addr(config->mac)) {
25392543
pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
25402544
err = mlx5_mpfs_add_mac(pfmdev, config->mac);
@@ -2632,6 +2636,7 @@ static int mlx5v_probe(struct auxiliary_device *adev,
26322636
mgtdev->mgtdev.ops = &mdev_ops;
26332637
mgtdev->mgtdev.device = mdev->device;
26342638
mgtdev->mgtdev.id_table = id_table;
2639+
mgtdev->mgtdev.config_attr_mask = (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR);
26352640
mgtdev->madev = madev;
26362641

26372642
err = vdpa_mgmtdev_register(&mgtdev->mgtdev);

0 commit comments

Comments
 (0)