mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-21 01:51:18 +00:00
vdpa_sim: store parsed MAC address in a buffer
commit cf1a3b3538
upstream.
As preparation for the next patches, we store the MAC address,
parsed during the vdpasim_create(), in a buffer that will be used
to fill 'config' together with other configurations.
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-11-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
0ed8181561
commit
0fb67eda6a
1 changed files with 7 additions and 3 deletions
|
@ -42,6 +42,8 @@ static char *macaddr;
|
||||||
module_param(macaddr, charp, 0);
|
module_param(macaddr, charp, 0);
|
||||||
MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
|
MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
|
||||||
|
|
||||||
|
u8 macaddr_buf[ETH_ALEN];
|
||||||
|
|
||||||
struct vdpasim_virtqueue {
|
struct vdpasim_virtqueue {
|
||||||
struct vringh vring;
|
struct vringh vring;
|
||||||
struct vringh_kiov iov;
|
struct vringh_kiov iov;
|
||||||
|
@ -392,13 +394,13 @@ static struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
|
||||||
goto err_iommu;
|
goto err_iommu;
|
||||||
|
|
||||||
if (macaddr) {
|
if (macaddr) {
|
||||||
mac_pton(macaddr, vdpasim->config.mac);
|
mac_pton(macaddr, macaddr_buf);
|
||||||
if (!is_valid_ether_addr(vdpasim->config.mac)) {
|
if (!is_valid_ether_addr(macaddr_buf)) {
|
||||||
ret = -EADDRNOTAVAIL;
|
ret = -EADDRNOTAVAIL;
|
||||||
goto err_iommu;
|
goto err_iommu;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eth_random_addr(vdpasim->config.mac);
|
eth_random_addr(macaddr_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < dev_attr->nvqs; i++)
|
for (i = 0; i < dev_attr->nvqs; i++)
|
||||||
|
@ -532,6 +534,8 @@ static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features)
|
||||||
|
|
||||||
config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
|
config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
|
||||||
config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
|
config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
|
||||||
|
memcpy(config->mac, macaddr_buf, ETH_ALEN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue