From: Cindy Lu <lulu@redhat.com>
To: lulu@redhat.com, dtatulea@nvidia.com, mst@redhat.com,
jasowang@redhat.com, parav@nvidia.com, sgarzare@redhat.com,
netdev@vger.kernel.org,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH v3 2/2] vdpa_sim_net: Add the support of set mac address
Date: Mon, 8 Jul 2024 14:47:03 +0800 [thread overview]
Message-ID: <20240708064820.88955-3-lulu@redhat.com> (raw)
In-Reply-To: <20240708064820.88955-1-lulu@redhat.com>
Add the function to support setting the MAC address.
For vdpa_sim_net, the driver will write the MAC address
to the config space, and other devices can implement
their own functions to support this.
Signed-off-by: Cindy Lu <lulu@redhat.com>
---
drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
index cfe962911804..a472c3c43bfd 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -414,6 +414,22 @@ static void vdpasim_net_get_config(struct vdpasim *vdpasim, void *config)
net_config->status = cpu_to_vdpasim16(vdpasim, VIRTIO_NET_S_LINK_UP);
}
+static int vdpasim_net_set_attr(struct vdpa_mgmt_dev *mdev,
+ struct vdpa_device *dev,
+ const struct vdpa_dev_set_config *config)
+{
+ struct vdpasim *vdpasim = container_of(dev, struct vdpasim, vdpa);
+
+ struct virtio_net_config *vio_config = vdpasim->config;
+ if (config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
+ if (!is_zero_ether_addr(config->net.mac)) {
+ memcpy(vio_config->mac, config->net.mac, ETH_ALEN);
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+
static void vdpasim_net_setup_config(struct vdpasim *vdpasim,
const struct vdpa_dev_set_config *config)
{
@@ -510,7 +526,8 @@ static void vdpasim_net_dev_del(struct vdpa_mgmt_dev *mdev,
static const struct vdpa_mgmtdev_ops vdpasim_net_mgmtdev_ops = {
.dev_add = vdpasim_net_dev_add,
- .dev_del = vdpasim_net_dev_del
+ .dev_del = vdpasim_net_dev_del,
+ .dev_set_attr = vdpasim_net_set_attr
};
static struct virtio_device_id id_table[] = {
--
2.45.0
next prev parent reply other threads:[~2024-07-08 6:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 6:47 [PATCH v3 0/2] vdpa: support set mac address from vdpa tool Cindy Lu
2024-07-08 6:47 ` [PATCH v3 1/2] " Cindy Lu
2024-07-08 7:04 ` Jason Wang
2024-07-08 9:15 ` kernel test robot
2024-07-08 6:47 ` Cindy Lu [this message]
2024-07-08 7:06 ` [PATCH v3 2/2] vdpa_sim_net: Add the support of set mac address Jason Wang
2024-07-08 7:18 ` Cindy Lu
2024-07-08 8:01 ` Jason Wang
2024-07-09 3:59 ` [PATCH v3 0/2] vdpa: support set mac address from vdpa tool Parav Pandit
2024-07-09 6:19 ` Cindy Lu
2024-07-09 12:41 ` Michael S. Tsirkin
2024-07-10 3:05 ` Jason Wang
2024-07-10 3:44 ` Parav Pandit
2024-07-10 6:10 ` Michael S. Tsirkin
2024-07-10 9:46 ` Cindy Lu
2024-07-11 9:08 ` Leonardo Milleri
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=20240708064820.88955-3-lulu@redhat.com \
--to=lulu@redhat.com \
--cc=dtatulea@nvidia.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=parav@nvidia.com \
--cc=sgarzare@redhat.com \
--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