VHOST_USER_MAX
};
+#ifndef VHOST_BACKEND_F_IOTLB_MSG_V2
+#define VHOST_BACKEND_F_IOTLB_MSG_V2 1
+#endif
+
extern const char * const vhost_msg_strings[VHOST_USER_MAX];
struct vhost_memory_region {
#define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8)
#define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, \
struct vhost_vring_state)
+#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
+#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
static uint64_t vhost_req_user_to_vdpa[] = {
[VHOST_USER_SET_OWNER] = VHOST_SET_OWNER,
[VHOST_USER_SET_STATUS] = VHOST_VDPA_SET_STATUS,
[VHOST_USER_GET_STATUS] = VHOST_VDPA_GET_STATUS,
[VHOST_USER_SET_VRING_ENABLE] = VHOST_VDPA_SET_VRING_ENABLE,
+ [VHOST_USER_GET_PROTOCOL_FEATURES] = VHOST_GET_BACKEND_FEATURES,
+ [VHOST_USER_SET_PROTOCOL_FEATURES] = VHOST_SET_BACKEND_FEATURES,
};
/* no alignment requirement */
{
struct vhost_msg msg = {};
+ if (!(dev->protocol_features & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2))) {
+ PMD_DRV_LOG(ERR, "IOTLB_MSG_V2 not supported by the backend.");
+ return -1;
+ }
+
msg.type = VHOST_IOTLB_MSG_V2;
msg.iotlb.type = VHOST_IOTLB_UPDATE;
msg.iotlb.iova = iova;
{
struct vhost_msg msg = {};
+ if (!(dev->protocol_features & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2))) {
+ PMD_DRV_LOG(ERR, "IOTLB_MSG_V2 not supported by the backend.");
+ return -1;
+ }
+
msg.type = VHOST_IOTLB_MSG_V2;
msg.iotlb.type = VHOST_IOTLB_INVALIDATE;
msg.iotlb.iova = iova;
1ULL << VIRTIO_F_RING_PACKED | \
1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
-#define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \
+#define VHOST_USER_SUPPORTED_PROTOCOL_FEATURES \
(1ULL << VHOST_USER_PROTOCOL_F_MQ | \
1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | \
1ULL << VHOST_USER_PROTOCOL_F_STATUS)
+#define VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES \
+ (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)
int
virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
int cq, int queue_size, const char *mac, char **ifname,
dev->mac_specified = 0;
dev->frontend_features = 0;
dev->unsupported_features = ~VIRTIO_USER_SUPPORTED_FEATURES;
- dev->protocol_features = VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES;
dev->backend_type = backend_type;
+ if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER)
+ dev->protocol_features = VHOST_USER_SUPPORTED_PROTOCOL_FEATURES;
+ else if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)
+ dev->protocol_features = VHOST_VDPA_SUPPORTED_PROTOCOL_FEATURES;
+
parse_mac(dev, mac);
if (*ifname) {
}
- if (dev->device_features &
- (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) {
+ if ((dev->device_features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||
+ (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_VDPA)) {
if (dev->ops->send_request(dev,
VHOST_USER_GET_PROTOCOL_FEATURES,
&protocol_features))
uint64_t device_features; /* supported features by device */
uint64_t frontend_features; /* enabled frontend features */
uint64_t unsupported_features; /* unsupported features mask */
- uint64_t protocol_features; /* negotiated protocol features
- * (Vhost-user only)
- */
+ uint64_t protocol_features; /* negotiated protocol features */
uint8_t status;
uint16_t net_status;
uint16_t port_id;