Commit 0c86d774 authored by Laurent Vivier's avatar Laurent Vivier Committed by Michael S. Tsirkin
Browse files

vdpasim: allow to assign a MAC address



Add macaddr parameter to the module to set the MAC address to use

Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
Link: https://lore.kernel.org/r/20201029122050.776445-3-lvivier@redhat.com


Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
parent 4a6a42db
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -38,6 +38,10 @@ static int batch_mapping = 1;
module_param(batch_mapping, int, 0444);
MODULE_PARM_DESC(batch_mapping, "Batched mapping 1 -Enable; 0 - Disable");

static char *macaddr;
module_param(macaddr, charp, 0);
MODULE_PARM_DESC(macaddr, "Ethernet MAC address");

struct vdpasim_virtqueue {
	struct vringh vring;
	struct vringh_kiov iov;
@@ -375,7 +379,15 @@ static struct vdpasim *vdpasim_create(void)
	if (!vdpasim->buffer)
		goto err_iommu;

	if (macaddr) {
		mac_pton(macaddr, vdpasim->config.mac);
		if (!is_valid_ether_addr(vdpasim->config.mac)) {
			ret = -EADDRNOTAVAIL;
			goto err_iommu;
		}
	} else {
		eth_random_addr(vdpasim->config.mac);
	}

	vringh_set_iotlb(&vdpasim->vqs[0].vring, vdpasim->iommu);
	vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);