-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
um: drivers: Add virtio vhost-user driver
This module allows virtio devices to be used over a vhost-user socket. Signed-off-by: Erel Geron <erelx.geron@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
- Loading branch information
1 parent
851b6cb
commit 5d38f32
Showing
11 changed files
with
1,169 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* Vhost-user protocol */ | ||
|
||
#ifndef __VHOST_USER_H__ | ||
#define __VHOST_USER_H__ | ||
|
||
/* Message flags */ | ||
#define VHOST_USER_FLAG_REPLY BIT(2) | ||
/* Feature bits */ | ||
#define VHOST_USER_F_PROTOCOL_FEATURES 30 | ||
/* Protocol feature bits */ | ||
#define VHOST_USER_PROTOCOL_F_CONFIG 9 | ||
/* Vring state index masks */ | ||
#define VHOST_USER_VRING_INDEX_MASK 0xff | ||
#define VHOST_USER_VRING_POLL_MASK BIT(8) | ||
|
||
/* Supported version */ | ||
#define VHOST_USER_VERSION 1 | ||
/* Supported transport features */ | ||
#define VHOST_USER_SUPPORTED_F BIT_ULL(VHOST_USER_F_PROTOCOL_FEATURES) | ||
/* Supported protocol features */ | ||
#define VHOST_USER_SUPPORTED_PROTOCOL_F BIT_ULL(VHOST_USER_PROTOCOL_F_CONFIG) | ||
|
||
enum vhost_user_request { | ||
VHOST_USER_GET_FEATURES = 1, | ||
VHOST_USER_SET_FEATURES = 2, | ||
VHOST_USER_SET_OWNER = 3, | ||
VHOST_USER_RESET_OWNER = 4, | ||
VHOST_USER_SET_MEM_TABLE = 5, | ||
VHOST_USER_SET_LOG_BASE = 6, | ||
VHOST_USER_SET_LOG_FD = 7, | ||
VHOST_USER_SET_VRING_NUM = 8, | ||
VHOST_USER_SET_VRING_ADDR = 9, | ||
VHOST_USER_SET_VRING_BASE = 10, | ||
VHOST_USER_GET_VRING_BASE = 11, | ||
VHOST_USER_SET_VRING_KICK = 12, | ||
VHOST_USER_SET_VRING_CALL = 13, | ||
VHOST_USER_SET_VRING_ERR = 14, | ||
VHOST_USER_GET_PROTOCOL_FEATURES = 15, | ||
VHOST_USER_SET_PROTOCOL_FEATURES = 16, | ||
VHOST_USER_GET_QUEUE_NUM = 17, | ||
VHOST_USER_SET_VRING_ENABLE = 18, | ||
VHOST_USER_SEND_RARP = 19, | ||
VHOST_USER_NET_SEND_MTU = 20, | ||
VHOST_USER_SET_SLAVE_REQ_FD = 21, | ||
VHOST_USER_IOTLB_MSG = 22, | ||
VHOST_USER_SET_VRING_ENDIAN = 23, | ||
VHOST_USER_GET_CONFIG = 24, | ||
VHOST_USER_SET_CONFIG = 25, | ||
}; | ||
|
||
struct vhost_user_header { | ||
u32 request; /* Use enum vhost_user_request */ | ||
u32 flags; | ||
u32 size; | ||
} __packed; | ||
|
||
struct vhost_user_config { | ||
u32 offset; | ||
u32 size; | ||
u32 flags; | ||
u8 payload[0]; /* Variable length */ | ||
} __packed; | ||
|
||
struct vhost_user_vring_state { | ||
u32 index; | ||
u32 num; | ||
} __packed; | ||
|
||
struct vhost_user_vring_addr { | ||
u32 index; | ||
u32 flags; | ||
u64 desc, used, avail, log; | ||
} __packed; | ||
|
||
struct vhost_user_mem_region { | ||
u64 guest_addr; | ||
u64 size; | ||
u64 user_addr; | ||
u64 mmap_offset; | ||
} __packed; | ||
|
||
struct vhost_user_mem_regions { | ||
u32 num; | ||
u32 padding; | ||
struct vhost_user_mem_region regions[2]; /* Currently supporting 2 */ | ||
} __packed; | ||
|
||
union vhost_user_payload { | ||
u64 integer; | ||
struct vhost_user_config config; | ||
struct vhost_user_vring_state vring_state; | ||
struct vhost_user_vring_addr vring_addr; | ||
struct vhost_user_mem_regions mem_regions; | ||
}; | ||
|
||
struct vhost_user_msg { | ||
struct vhost_user_header header; | ||
union vhost_user_payload payload; | ||
} __packed; | ||
|
||
#endif |
Oops, something went wrong.