[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b1d716304a883a4e93178957defee2c560f5b3d4.1747822866.git.pabeni@redhat.com>
Date: Wed, 21 May 2025 12:32:37 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: netdev@...r.kernel.org
Cc: Willem de Bruijn <willemdebruijn.kernel@...il.com>,
Jason Wang <jasowang@...hat.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Eugenio Pérez <eperezma@...hat.com>
Subject: [PATCH net-next 3/8] vhost-net: allow configuring extended features
Use the extended feature type for 'acked_features' and implement
two new ioctls operation to get and set the extended features.
Note that the legacy ioctls implicitly truncate the negotiated
features to the lower 64 bits range.
Signed-off-by: Paolo Abeni <pabeni@...hat.com>
---
drivers/vhost/net.c | 26 +++++++++++++++++++++++++-
drivers/vhost/vhost.h | 2 +-
include/uapi/linux/vhost.h | 8 ++++++++
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 7cbfc7d718b3f..b894685dded3e 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -77,6 +77,10 @@ enum {
(1ULL << VIRTIO_F_RING_RESET)
};
+#ifdef VIRTIO_HAS_EXTENDED_FEATURES
+#define VHOST_NET_FEATURES_EX VHOST_NET_FEATURES
+#endif
+
enum {
VHOST_NET_BACKEND_FEATURES = (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)
};
@@ -1614,7 +1618,7 @@ static long vhost_net_reset_owner(struct vhost_net *n)
return err;
}
-static int vhost_net_set_features(struct vhost_net *n, u64 features)
+static int vhost_net_set_features(struct vhost_net *n, virtio_features_t features)
{
size_t vhost_hlen, sock_hlen, hdr_len;
int i;
@@ -1704,6 +1708,26 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
if (features & ~VHOST_NET_FEATURES)
return -EOPNOTSUPP;
return vhost_net_set_features(n, features);
+#ifdef VIRTIO_HAS_EXTENDED_FEATURES
+ case VHOST_GET_FEATURES_EX:
+ {
+ virtio_features_t features_ex = VHOST_NET_FEATURES_EX;
+
+ if (copy_to_user(featurep, &features_ex, sizeof(features_ex)))
+ return -EFAULT;
+ return 0;
+ }
+ case VHOST_SET_FEATURES_EX:
+ {
+ virtio_features_t features_ex;
+
+ if (copy_from_user(&features_ex, featurep, sizeof(features_ex)))
+ return -EFAULT;
+ if (features_ex & ~VHOST_NET_FEATURES_EX)
+ return -EOPNOTSUPP;
+ return vhost_net_set_features(n, features_ex);
+ }
+#endif
case VHOST_GET_BACKEND_FEATURES:
features = VHOST_NET_BACKEND_FEATURES;
if (copy_to_user(featurep, &features, sizeof(features)))
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index bb75a292d50cd..ef1c7fd6f4e19 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -133,7 +133,7 @@ struct vhost_virtqueue {
struct vhost_iotlb *umem;
struct vhost_iotlb *iotlb;
void *private_data;
- u64 acked_features;
+ virtio_features_t acked_features;
u64 acked_backend_features;
/* Log write descriptors */
void __user *log_base;
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
index d4b3e2ae1314d..328e81badf1ad 100644
--- a/include/uapi/linux/vhost.h
+++ b/include/uapi/linux/vhost.h
@@ -235,4 +235,12 @@
*/
#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \
struct vhost_vring_state)
+
+/* Extended features manipulation
+ */
+#ifdef __SIZEOF_INT128__
+#define VHOST_GET_FEATURES_EX _IOR(VHOST_VIRTIO, 0x83, __u128)
+#define VHOST_SET_FEATURES_EX _IOW(VHOST_VIRTIO, 0x83, __u128)
+#endif
+
#endif
--
2.49.0
Powered by blists - more mailing lists