[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <56441d58-df03-1e4c-4178-a10c7ba9a3e3@redhat.com>
Date: Mon, 30 Nov 2020 11:20:24 +0800
From: Jason Wang <jasowang@...hat.com>
To: Stefano Garzarella <sgarzare@...hat.com>,
virtualization@...ts.linux-foundation.org
Cc: Stefan Hajnoczi <stefanha@...hat.com>,
linux-kernel@...r.kernel.org, Laurent Vivier <lvivier@...hat.com>,
Max Gurtovoy <mgurtovoy@...dia.com>,
"Michael S. Tsirkin" <mst@...hat.com>, Eli Cohen <elic@...dia.com>
Subject: Re: [PATCH v2 10/17] vdpa_sim: store parsed MAC address in a buffer
On 2020/11/26 下午10:49, Stefano Garzarella wrote:
> 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.
>
> Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>
> ---
> drivers/vdpa/vdpa_sim/vdpa_sim.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Acked-by: Jason Wang <jasowang@...hat.com>
>
> diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> index b84d9acd130c..9f2ca3a77025 100644
> --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
> +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
> @@ -29,6 +29,8 @@ static char *macaddr;
> module_param(macaddr, charp, 0);
> MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
>
> +u8 macaddr_buf[ETH_ALEN];
> +
> struct vdpasim_virtqueue {
> struct vringh vring;
> struct vringh_kiov iov;
> @@ -386,13 +388,13 @@ static struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
> goto err_iommu;
>
> if (macaddr) {
> - mac_pton(macaddr, vdpasim->config.mac);
> - if (!is_valid_ether_addr(vdpasim->config.mac)) {
> + mac_pton(macaddr, macaddr_buf);
> + if (!is_valid_ether_addr(macaddr_buf)) {
> ret = -EADDRNOTAVAIL;
> goto err_iommu;
> }
> } else {
> - eth_random_addr(vdpasim->config.mac);
> + eth_random_addr(macaddr_buf);
> }
>
> for (i = 0; i < dev_attr->nvqs; i++)
> @@ -528,6 +530,8 @@ static int vdpasim_set_features(struct vdpa_device *vdpa, u64 features)
>
> config->mtu = cpu_to_vdpasim16(vdpasim, 1500);
> config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
> + memcpy(config->mac, macaddr_buf, ETH_ALEN);
> +
> return 0;
> }
>
Powered by blists - more mailing lists