From: Stefano Garzarella <sgarzare@redhat.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
stable@vger.kernel.org, Jason Wang <jasowang@redhat.com>,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: [PATCH for 5.10 v2 3/5] vdpa_sim: store parsed MAC address in a buffer
Date: Tue, 16 Feb 2021 15:24:37 +0100 [thread overview]
Message-ID: <20210216142439.258713-4-sgarzare@redhat.com> (raw)
In-Reply-To: <20210216142439.258713-1-sgarzare@redhat.com>
commit cf1a3b35382c10ce315c32bd2b3d7789897fbe13 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>
Cc: <stable@vger.kernel.org> # 5.10.x
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 6a5603f9d24c..bc27fa485c3e 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -42,6 +42,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;
@@ -392,13 +394,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++)
@@ -532,6 +534,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;
}
--
2.29.2
next prev parent reply other threads:[~2021-02-16 14:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 14:24 [PATCH for 5.10 v2 0/5] vdpa_sim: fix param validation in vdpasim_get_config() Stefano Garzarella
2021-02-16 14:24 ` [PATCH for 5.10 v2 1/5] vdpa_sim: remove hard-coded virtq count Stefano Garzarella
2021-02-16 14:24 ` [PATCH for 5.10 v2 2/5] vdpa_sim: add struct vdpasim_dev_attr for device attributes Stefano Garzarella
2021-02-16 14:24 ` Stefano Garzarella [this message]
2021-02-16 14:24 ` [PATCH for 5.10 v2 4/5] vdpa_sim: make 'config' generic and usable for any device type Stefano Garzarella
2021-02-16 14:24 ` [PATCH for 5.10 v2 5/5] vdpa_sim: add get_config callback in vdpasim_dev_attr Stefano Garzarella
2021-02-17 10:58 ` [PATCH for 5.10 v2 0/5] vdpa_sim: fix param validation in vdpasim_get_config() Greg KH
2021-02-17 11:10 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210216142439.258713-4-sgarzare@redhat.com \
--to=sgarzare@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).