vdpasim: allow to set MAC address
cover vdpasim: allow to set MAC address
This series starts by fixing a bug:vdpa_sim generates a MAC address that is never show to upper layer, and thus virtio-net generates another random MAC address, that changes each time virtio-net is loaded (even if vdpa_sim is not unloaded).
Then it adds a parameter to vpa_sim module to allow the user to set the MAC address. With that we use vdpa_sim with a stable MAC addres, that doesn't change between reboots.
Laurent Vivier (2):
vdpasim: fix MAC address configuration
vdpasim: allow to assign a MAC address
drivers/vdpa/vdpa_sim/vdpa_sim.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
Signature · 7 lines
2.26.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 1/2 vdpasim: fix MAC address configuration
vdpa_sim generates a ramdom MAC address but it is never used by upper layers because the VIRTIO_NET_F_MAC bit is not set in the features list.
Because of that, virtio-net always regenerates a random MAC address each time it is loaded whereas the address should only change on vdpa_sim load/unload.
Fix that by adding VIRTIO_NET_F_MAC in the features list of vdpa_sim.
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +2 -1
@@ -60,7 +60,8 @@ struct vdpasim_virtqueue {static u64 vdpasim_features = (1ULL <<VIRTIO_F_ANY_LAYOUT ) | (1ULL <<VIRTIO_F_VERSION_1 ) | - (1ULL <<VIRTIO_F_ACCESS_PLATFORM ); + (1ULL <<VIRTIO_F_ACCESS_PLATFORM ) | + (1ULL <<VIRTIO_NET_F_MAC );/* State of each vdpasim device */ struct vdpasim {
Signature · 6 lines
2.26.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH 2/2 vdpasim: allow to assign a MAC address
In reply to Laurent VivierAdd macaddr parameter to the module to set the MAC address to use
--- drivers/vdpa/vdpa_sim/vdpa_sim.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_sim/vdpa_sim.c +13 -1
@@ -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;
@@ -373,7 +377,15 @@ static struct vdpasim *vdpasim_create(void)if (!vdpasim->buffer) goto err_iommu; -eth_random_addr (vdpasim->config.mac); +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);
Signature · 6 lines
2.26.2 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 10 lines · Laurent Vivier
This series starts by fixing a bug:
vdpa_simgenerates a MAC address that is never show to upper layer, and thus virtio-net generates another random MAC address, that changes each time virtio-net is loaded (even ifvdpa_simis not unloaded).Then it adds a parameter to
vpa_simmodule to allow the user to set the MAC address. With that we usevdpa_simwith a stable MAC addres, that doesn't change between reboots.
Quoted 7 lines
Laurent Vivier (2):
vdpasim: fix MAC address configuration
vdpasim: allow to assign a MAC addressdrivers/vdpa/vdpa_sim/vdpa_sim.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)