vhost: make SPDK internal vhost library can work compatible with live recovery

We will not enable the live recovery feature for SPDK internal vhost library,
so we unmask the protocol flag for internal vhost library.

For the purpose to make it can be compiled with latest DPDK version, some
mandatory APIs are required, so add them here.

Change-Id: I34fab7ed90c86a0fb612852a47f6cadeb8a072f3
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482069
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Changpeng Liu 2020-01-07 23:24:42 +08:00 committed by Tomasz Zawadzki
parent ca073ef3ac
commit 5e8a3a77b6
3 changed files with 183 additions and 3 deletions

View File

@ -74,10 +74,50 @@ struct rte_vhost_memory {
struct rte_vhost_mem_region regions[0];
};
struct rte_vhost_inflight_desc_split {
uint8_t inflight;
uint8_t padding[5];
uint16_t next;
uint64_t counter;
};
struct rte_vhost_inflight_info_split {
uint64_t features;
uint16_t version;
uint16_t desc_num;
uint16_t last_inflight_io;
uint16_t used_idx;
struct rte_vhost_inflight_desc_split desc[0];
};
struct rte_vhost_resubmit_desc {
uint16_t index;
uint64_t counter;
};
struct rte_vhost_resubmit_info {
struct rte_vhost_resubmit_desc *resubmit_list;
uint16_t resubmit_num;
};
struct rte_vhost_ring_inflight {
struct rte_vhost_inflight_info_split *inflight_split;
struct rte_vhost_resubmit_info *resubmit_inflight;
};
struct rte_vhost_vring {
union {
struct vring_desc *desc;
struct vring_packed_desc *desc_packed;
};
union {
struct vring_avail *avail;
struct vring_packed_desc_event *driver_event;
};
union {
struct vring_used *used;
struct vring_packed_desc_event *device_event;
};
uint64_t log_guest_addr;
int callfd;
@ -484,4 +524,112 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id,
*/
int rte_vhost_vring_call(int vid, uint16_t vring_idx);
/**
* Get guest inflight vring info, including inflight ring and resubmit list.
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param vring
* the structure to hold the requested inflight vring info
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
struct rte_vhost_ring_inflight *vring);
/**
* Set split inflight descriptor.
*
* This function save descriptors that has been comsumed in available
* ring
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param idx
* inflight entry index
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_set_inflight_desc_split(int vid, uint16_t vring_idx,
uint16_t idx);
/**
* Save the head of list that the last batch of used descriptors.
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param idx
* descriptor entry index
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_set_last_inflight_io_split(int vid,
uint16_t vring_idx, uint16_t idx);
/**
* Clear the split inflight status.
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param last_used_idx
* last used idx of used ring
* @param idx
* inflight entry index
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx,
uint16_t last_used_idx, uint16_t idx);
/**
* Save the head of list that the last batch of used descriptors.
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param idx
* descriptor entry index
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_set_last_inflight_io_split(int vid,
uint16_t vring_idx, uint16_t idx);
/**
* Clear the split inflight status.
*
* @param vid
* vhost device ID
* @param vring_idx
* vring index
* @param last_used_idx
* last used idx of used ring
* @param idx
* inflight entry index
* @return
* 0 on success, -1 on failure
*/
__rte_experimental
int
rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx,
uint16_t last_used_idx, uint16_t idx);
#endif /* _RTE_VHOST_H_ */

View File

@ -535,3 +535,31 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
return -1;
}
int
rte_vhost_set_last_inflight_io_split(int vid, uint16_t vring_idx,
uint16_t idx)
{
return 0;
}
int
rte_vhost_clr_inflight_desc_split(int vid, uint16_t vring_idx,
uint16_t last_used_idx, uint16_t idx)
{
return 0;
}
int
rte_vhost_set_inflight_desc_split(int vid, uint16_t vring_idx,
uint16_t idx)
{
return 0;
}
int
rte_vhost_get_vhost_ring_inflight(int vid, uint16_t vring_idx,
struct rte_vhost_ring_inflight *vring)
{
return 0;
}

View File

@ -59,8 +59,12 @@
(1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI))
/* Vhost-blk support protocol features */
#ifndef SPDK_CONFIG_VHOST_INTERNAL_LIB
#define SPDK_VHOST_BLK_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_CONFIG) | \
(1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD))
#else
#define SPDK_VHOST_BLK_PROTOCOL_FEATURES (1ULL << VHOST_USER_PROTOCOL_F_CONFIG)
#endif
struct spdk_vhost_blk_task {
struct spdk_bdev_io *bdev_io;