vhost: remove spdk_ prefix from private functions

Remove them all at once. spdk_ prefix should be
only applied to publicly exported functions.

Change-Id: Ib6d2bd0954ec5cb7c8cf253d79b9d3cd8aa0eeef
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466728
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Darek Stojaczyk 2019-07-20 23:06:19 +02:00 committed by Jim Harris
parent 89bdba564a
commit 0cf5d5160b
8 changed files with 400 additions and 399 deletions

View File

@ -57,7 +57,7 @@ spdk_extern_vhost_pre_msg_handler(int vid, void *_msg)
struct vhost_user_msg *msg = _msg;
struct spdk_vhost_session *vsession;
vsession = spdk_vhost_session_find_by_vid(vid);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Received a message to unitialized session (vid %d).\n", vid);
assert(false);
@ -151,7 +151,7 @@ spdk_extern_vhost_post_msg_handler(int vid, void *_msg)
struct vhost_user_msg *msg = _msg;
struct spdk_vhost_session *vsession;
vsession = spdk_vhost_session_find_by_vid(vid);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Received a message to unitialized session (vid %d).\n", vid);
assert(false);
@ -203,7 +203,7 @@ struct rte_vhost_user_extern_ops g_spdk_extern_vhost_ops = {
};
void
spdk_vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession)
vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession)
{
int rc;
@ -216,7 +216,7 @@ spdk_vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession)
}
void
spdk_vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev)
vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev)
{
uint64_t protocol_features = 0;
@ -227,13 +227,13 @@ spdk_vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev)
#else /* SPDK_CONFIG_VHOST_INTERNAL_LIB */
void
spdk_vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession)
vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession)
{
/* nothing to do. all the changes are already incorporated into rte_vhost */
}
void
spdk_vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev)
vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev)
{
/* nothing to do */
}

View File

@ -72,7 +72,7 @@ static sem_t g_dpdk_sem;
/** Return code for the current DPDK callback */
static int g_dpdk_response;
struct spdk_vhost_session_fn_ctx {
struct vhost_session_fn_ctx {
/** Device pointer obtained before enqueuing the event */
struct spdk_vhost_dev *vdev;
@ -105,18 +105,18 @@ const struct vhost_device_ops g_spdk_vhost_ops = {
#ifdef SPDK_CONFIG_VHOST_INTERNAL_LIB
.get_config = get_config,
.set_config = set_config,
.vhost_nvme_admin_passthrough = spdk_vhost_nvme_admin_passthrough,
.vhost_nvme_set_cq_call = spdk_vhost_nvme_set_cq_call,
.vhost_nvme_get_cap = spdk_vhost_nvme_get_cap,
.vhost_nvme_set_bar_mr = spdk_vhost_nvme_set_bar_mr,
.vhost_nvme_admin_passthrough = vhost_nvme_admin_passthrough,
.vhost_nvme_set_cq_call = vhost_nvme_set_cq_call,
.vhost_nvme_get_cap = vhost_nvme_get_cap,
.vhost_nvme_set_bar_mr = vhost_nvme_set_bar_mr,
#endif
};
static TAILQ_HEAD(, spdk_vhost_dev) g_spdk_vhost_devices = TAILQ_HEAD_INITIALIZER(
g_spdk_vhost_devices);
static pthread_mutex_t g_spdk_vhost_mutex = PTHREAD_MUTEX_INITIALIZER;
static TAILQ_HEAD(, spdk_vhost_dev) g_vhost_devices = TAILQ_HEAD_INITIALIZER(
g_vhost_devices);
static pthread_mutex_t g_vhost_mutex = PTHREAD_MUTEX_INITIALIZER;
void *spdk_vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr, uint64_t len)
void *vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr, uint64_t len)
{
void *vva;
uint64_t newlen;
@ -132,44 +132,44 @@ void *spdk_vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr,
}
static void
spdk_vhost_log_req_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *virtqueue,
uint16_t req_id)
vhost_log_req_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *virtqueue,
uint16_t req_id)
{
struct vring_desc *desc, *desc_table;
uint32_t desc_table_size;
int rc;
if (spdk_likely(!spdk_vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
if (spdk_likely(!vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
return;
}
rc = spdk_vhost_vq_get_desc(vsession, virtqueue, req_id, &desc, &desc_table, &desc_table_size);
rc = vhost_vq_get_desc(vsession, virtqueue, req_id, &desc, &desc_table, &desc_table_size);
if (spdk_unlikely(rc != 0)) {
SPDK_ERRLOG("Can't log used ring descriptors!\n");
return;
}
do {
if (spdk_vhost_vring_desc_is_wr(desc)) {
if (vhost_vring_desc_is_wr(desc)) {
/* To be honest, only pages realy touched should be logged, but
* doing so would require tracking those changes in each backed.
* Also backend most likely will touch all/most of those pages so
* for lets assume we touched all pages passed to as writeable buffers. */
rte_vhost_log_write(vsession->vid, desc->addr, desc->len);
}
spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
} while (desc);
}
static void
spdk_vhost_log_used_vring_elem(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue,
uint16_t idx)
vhost_log_used_vring_elem(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue,
uint16_t idx)
{
uint64_t offset, len;
uint16_t vq_idx;
if (spdk_likely(!spdk_vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
if (spdk_likely(!vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
return;
}
@ -181,13 +181,13 @@ spdk_vhost_log_used_vring_elem(struct spdk_vhost_session *vsession,
}
static void
spdk_vhost_log_used_vring_idx(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue)
vhost_log_used_vring_idx(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue)
{
uint64_t offset, len;
uint16_t vq_idx;
if (spdk_likely(!spdk_vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
if (spdk_likely(!vhost_dev_has_feature(vsession, VHOST_F_LOG_ALL))) {
return;
}
@ -202,8 +202,8 @@ spdk_vhost_log_used_vring_idx(struct spdk_vhost_session *vsession,
* Get available requests from avail ring.
*/
uint16_t
spdk_vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *virtqueue, uint16_t *reqs,
uint16_t reqs_len)
vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *virtqueue, uint16_t *reqs,
uint16_t reqs_len)
{
struct rte_vhost_vring *vring = &virtqueue->vring;
struct vring_avail *avail = vring->avail;
@ -237,15 +237,15 @@ spdk_vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *virtqueue, uint16_t *r
}
static bool
spdk_vhost_vring_desc_is_indirect(struct vring_desc *cur_desc)
vhost_vring_desc_is_indirect(struct vring_desc *cur_desc)
{
return !!(cur_desc->flags & VRING_DESC_F_INDIRECT);
}
int
spdk_vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *virtqueue,
uint16_t req_idx, struct vring_desc **desc, struct vring_desc **desc_table,
uint32_t *desc_table_size)
vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *virtqueue,
uint16_t req_idx, struct vring_desc **desc, struct vring_desc **desc_table,
uint32_t *desc_table_size)
{
if (spdk_unlikely(req_idx >= virtqueue->vring.size)) {
return -1;
@ -253,10 +253,10 @@ spdk_vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_vi
*desc = &virtqueue->vring.desc[req_idx];
if (spdk_vhost_vring_desc_is_indirect(*desc)) {
if (vhost_vring_desc_is_indirect(*desc)) {
*desc_table_size = (*desc)->len / sizeof(**desc);
*desc_table = spdk_vhost_gpa_to_vva(vsession, (*desc)->addr,
sizeof(**desc) * *desc_table_size);
*desc_table = vhost_gpa_to_vva(vsession, (*desc)->addr,
sizeof(**desc) * *desc_table_size);
*desc = *desc_table;
if (*desc == NULL) {
return -1;
@ -272,8 +272,8 @@ spdk_vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_vi
}
int
spdk_vhost_vq_used_signal(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue)
vhost_vq_used_signal(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue)
{
if (virtqueue->used_req_cnt == 0) {
return 0;
@ -328,7 +328,7 @@ check_session_io_stats(struct spdk_vhost_session *vsession, uint64_t now)
}
void
spdk_vhost_session_used_signal(struct spdk_vhost_session *vsession)
vhost_session_used_signal(struct spdk_vhost_session *vsession)
{
struct spdk_vhost_virtqueue *virtqueue;
uint64_t now;
@ -343,7 +343,7 @@ spdk_vhost_session_used_signal(struct spdk_vhost_session *vsession)
continue;
}
spdk_vhost_vq_used_signal(vsession, virtqueue);
vhost_vq_used_signal(vsession, virtqueue);
}
} else {
now = spdk_get_ticks();
@ -358,7 +358,7 @@ spdk_vhost_session_used_signal(struct spdk_vhost_session *vsession)
continue;
}
if (!spdk_vhost_vq_used_signal(vsession, virtqueue)) {
if (!vhost_vq_used_signal(vsession, virtqueue)) {
continue;
}
@ -370,8 +370,8 @@ spdk_vhost_session_used_signal(struct spdk_vhost_session *vsession)
}
static int
spdk_vhost_session_set_coalescing(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
vhost_session_set_coalescing(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
{
if (vdev == NULL || vsession == NULL) {
/* nothing to do */
@ -417,7 +417,7 @@ spdk_vhost_set_coalescing(struct spdk_vhost_dev *vdev, uint32_t delay_base_us,
return rc;
}
spdk_vhost_dev_foreach_session(vdev, spdk_vhost_session_set_coalescing, NULL);
vhost_dev_foreach_session(vdev, vhost_session_set_coalescing, NULL);
return 0;
}
@ -438,9 +438,9 @@ spdk_vhost_get_coalescing(struct spdk_vhost_dev *vdev, uint32_t *delay_base_us,
* Enqueue id and len to used ring.
*/
void
spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue,
uint16_t id, uint32_t len)
vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *virtqueue,
uint16_t id, uint32_t len)
{
struct rte_vhost_vring *vring = &virtqueue->vring;
struct vring_used *used = vring->used;
@ -450,7 +450,7 @@ spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
"Queue %td - USED RING: last_idx=%"PRIu16" req id=%"PRIu16" len=%"PRIu32"\n",
virtqueue - vsession->virtqueue, virtqueue->last_used_idx, id, len);
spdk_vhost_log_req_desc(vsession, virtqueue, id);
vhost_log_req_desc(vsession, virtqueue, id);
virtqueue->last_used_idx++;
used->ring[last_idx].id = id;
@ -459,16 +459,16 @@ spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
/* Ensure the used ring is updated before we log it or increment used->idx. */
spdk_smp_wmb();
spdk_vhost_log_used_vring_elem(vsession, virtqueue, last_idx);
vhost_log_used_vring_elem(vsession, virtqueue, last_idx);
* (volatile uint16_t *) &used->idx = virtqueue->last_used_idx;
spdk_vhost_log_used_vring_idx(vsession, virtqueue);
vhost_log_used_vring_idx(vsession, virtqueue);
virtqueue->used_req_cnt++;
}
int
spdk_vhost_vring_desc_get_next(struct vring_desc **desc,
struct vring_desc *desc_table, uint32_t desc_table_size)
vhost_vring_desc_get_next(struct vring_desc **desc,
struct vring_desc *desc_table, uint32_t desc_table_size)
{
struct vring_desc *old_desc = *desc;
uint16_t next_idx;
@ -489,14 +489,14 @@ spdk_vhost_vring_desc_get_next(struct vring_desc **desc,
}
bool
spdk_vhost_vring_desc_is_wr(struct vring_desc *cur_desc)
vhost_vring_desc_is_wr(struct vring_desc *cur_desc)
{
return !!(cur_desc->flags & VRING_DESC_F_WRITE);
}
int
spdk_vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov,
uint16_t *iov_index, const struct vring_desc *desc)
vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov,
uint16_t *iov_index, const struct vring_desc *desc)
{
uint64_t len;
uint64_t remaining = desc->len;
@ -525,7 +525,7 @@ spdk_vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *
}
static struct spdk_vhost_session *
spdk_vhost_session_find_by_id(struct spdk_vhost_dev *vdev, unsigned id)
vhost_session_find_by_id(struct spdk_vhost_dev *vdev, unsigned id)
{
struct spdk_vhost_session *vsession;
@ -539,12 +539,12 @@ spdk_vhost_session_find_by_id(struct spdk_vhost_dev *vdev, unsigned id)
}
struct spdk_vhost_session *
spdk_vhost_session_find_by_vid(int vid)
vhost_session_find_by_vid(int vid)
{
struct spdk_vhost_dev *vdev;
struct spdk_vhost_session *vsession;
TAILQ_FOREACH(vdev, &g_spdk_vhost_devices, tailq) {
TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
TAILQ_FOREACH(vsession, &vdev->vsessions, tailq) {
if (vsession->vid == vid) {
return vsession;
@ -561,7 +561,7 @@ spdk_vhost_session_find_by_vid(int vid)
#define CEIL_2MB(x) ((((uintptr_t)x) + SIZE_2MB - 1) / SIZE_2MB) << SHIFT_2MB
static void
spdk_vhost_session_mem_register(struct spdk_vhost_session *vsession)
vhost_session_mem_register(struct spdk_vhost_session *vsession)
{
struct rte_vhost_mem_region *region;
uint32_t i;
@ -589,7 +589,7 @@ spdk_vhost_session_mem_register(struct spdk_vhost_session *vsession)
}
static void
spdk_vhost_session_mem_unregister(struct spdk_vhost_session *vsession)
vhost_session_mem_unregister(struct spdk_vhost_session *vsession)
{
struct rte_vhost_mem_region *region;
uint32_t i;
@ -621,7 +621,7 @@ struct spdk_vhost_dev *
spdk_vhost_dev_next(struct spdk_vhost_dev *vdev)
{
if (vdev == NULL) {
return TAILQ_FIRST(&g_spdk_vhost_devices);
return TAILQ_FIRST(&g_vhost_devices);
}
return TAILQ_NEXT(vdev, tailq);
@ -637,7 +637,7 @@ spdk_vhost_dev_find(const char *ctrlr_name)
ctrlr_name += dev_dirname_len;
}
TAILQ_FOREACH(vdev, &g_spdk_vhost_devices, tailq) {
TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
if (strcmp(vdev->name, ctrlr_name) == 0) {
return vdev;
}
@ -647,7 +647,7 @@ spdk_vhost_dev_find(const char *ctrlr_name)
}
static int
spdk_vhost_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask)
vhost_parse_core_mask(const char *mask, struct spdk_cpuset *cpumask)
{
int rc;
@ -688,8 +688,8 @@ _start_rte_driver(void *arg)
}
int
spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str,
const struct spdk_vhost_dev_backend *backend)
vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str,
const struct spdk_vhost_dev_backend *backend)
{
char path[PATH_MAX];
struct stat file_stat;
@ -708,7 +708,7 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
return -ENOMEM;
}
if (spdk_vhost_parse_core_mask(mask_str, cpumask) != 0) {
if (vhost_parse_core_mask(mask_str, cpumask) != 0) {
SPDK_ERRLOG("cpumask %s is invalid (app mask is 0x%s)\n",
mask_str, spdk_cpuset_fmt(spdk_app_get_core_mask()));
rc = -EINVAL;
@ -781,12 +781,12 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
vdev->registered = true;
vdev->backend = backend;
TAILQ_INIT(&vdev->vsessions);
TAILQ_INSERT_TAIL(&g_spdk_vhost_devices, vdev, tailq);
TAILQ_INSERT_TAIL(&g_vhost_devices, vdev, tailq);
vhost_dev_set_coalescing(vdev, SPDK_VHOST_COALESCING_DELAY_BASE_US,
SPDK_VHOST_VQ_IOPS_COALESCING_THRESHOLD);
spdk_vhost_dev_install_rte_compat_hooks(vdev);
vhost_dev_install_rte_compat_hooks(vdev);
/* The following might start a POSIX thread that polls for incoming
* socket connections and calls backend->start/stop_device. These backend
@ -797,7 +797,7 @@ spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const cha
SPDK_ERRLOG("Failed to start vhost driver for controller %s (%d): %s\n",
name, errno, spdk_strerror(errno));
rte_vhost_driver_unregister(path);
TAILQ_REMOVE(&g_spdk_vhost_devices, vdev, tailq);
TAILQ_REMOVE(&g_vhost_devices, vdev, tailq);
free(vdev->name);
free(vdev->path);
rc = -EIO;
@ -813,7 +813,7 @@ out:
}
int
spdk_vhost_dev_unregister(struct spdk_vhost_dev *vdev)
vhost_dev_unregister(struct spdk_vhost_dev *vdev)
{
if (!TAILQ_EMPTY(&vdev->vsessions)) {
SPDK_ERRLOG("Controller %s has still valid connection.\n", vdev->name);
@ -832,12 +832,12 @@ spdk_vhost_dev_unregister(struct spdk_vhost_dev *vdev)
free(vdev->name);
free(vdev->path);
spdk_cpuset_free(vdev->cpumask);
TAILQ_REMOVE(&g_spdk_vhost_devices, vdev, tailq);
TAILQ_REMOVE(&g_vhost_devices, vdev, tailq);
return 0;
}
static struct spdk_vhost_session *
spdk_vhost_session_next(struct spdk_vhost_dev *vdev, unsigned prev_id)
vhost_session_next(struct spdk_vhost_dev *vdev, unsigned prev_id)
{
struct spdk_vhost_session *vsession;
@ -865,7 +865,7 @@ spdk_vhost_dev_get_cpumask(struct spdk_vhost_dev *vdev)
}
struct vhost_poll_group *
spdk_vhost_get_poll_group(struct spdk_cpuset *cpumask)
vhost_get_poll_group(struct spdk_cpuset *cpumask)
{
struct vhost_poll_group *pg, *selected_pg;
uint32_t min_ctrlrs;
@ -895,14 +895,14 @@ spdk_vhost_get_poll_group(struct spdk_cpuset *cpumask)
}
void
spdk_vhost_put_poll_group(struct vhost_poll_group *pg)
vhost_put_poll_group(struct vhost_poll_group *pg)
{
assert(pg->ref > 0);
pg->ref--;
}
void
spdk_vhost_session_start_done(struct spdk_vhost_session *vsession, int response)
vhost_session_start_done(struct spdk_vhost_session *vsession, int response)
{
if (response == 0) {
vsession->started = true;
@ -915,7 +915,7 @@ spdk_vhost_session_start_done(struct spdk_vhost_session *vsession, int response)
}
void
spdk_vhost_session_stop_done(struct spdk_vhost_session *vsession, int response)
vhost_session_stop_done(struct spdk_vhost_session *vsession, int response)
{
if (response == 0) {
vsession->started = false;
@ -928,28 +928,28 @@ spdk_vhost_session_stop_done(struct spdk_vhost_session *vsession, int response)
}
static void
spdk_vhost_event_cb(void *arg1)
vhost_event_cb(void *arg1)
{
struct spdk_vhost_session_fn_ctx *ctx = arg1;
struct vhost_session_fn_ctx *ctx = arg1;
struct spdk_vhost_session *vsession;
if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) {
spdk_thread_send_msg(spdk_get_thread(), spdk_vhost_event_cb, arg1);
if (pthread_mutex_trylock(&g_vhost_mutex) != 0) {
spdk_thread_send_msg(spdk_get_thread(), vhost_event_cb, arg1);
return;
}
vsession = spdk_vhost_session_find_by_id(ctx->vdev, ctx->vsession_id);
vsession = vhost_session_find_by_id(ctx->vdev, ctx->vsession_id);
ctx->cb_fn(ctx->vdev, vsession, NULL);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
}
int
spdk_vhost_session_send_event(struct vhost_poll_group *pg,
struct spdk_vhost_session *vsession,
spdk_vhost_session_fn cb_fn, unsigned timeout_sec,
const char *errmsg)
vhost_session_send_event(struct vhost_poll_group *pg,
struct spdk_vhost_session *vsession,
spdk_vhost_session_fn cb_fn, unsigned timeout_sec,
const char *errmsg)
{
struct spdk_vhost_session_fn_ctx ev_ctx = {0};
struct vhost_session_fn_ctx ev_ctx = {0};
struct timespec timeout;
int rc;
@ -958,8 +958,8 @@ spdk_vhost_session_send_event(struct vhost_poll_group *pg,
ev_ctx.cb_fn = cb_fn;
vsession->poll_group = pg;
spdk_thread_send_msg(pg->thread, spdk_vhost_event_cb, &ev_ctx);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
spdk_thread_send_msg(pg->thread, vhost_event_cb, &ev_ctx);
pthread_mutex_unlock(&g_vhost_mutex);
clock_gettime(CLOCK_REALTIME, &timeout);
timeout.tv_sec += timeout_sec;
@ -970,20 +970,20 @@ spdk_vhost_session_send_event(struct vhost_poll_group *pg,
sem_wait(&g_dpdk_sem);
}
pthread_mutex_lock(&g_spdk_vhost_mutex);
pthread_mutex_lock(&g_vhost_mutex);
return g_dpdk_response;
}
static void foreach_session_continue(struct spdk_vhost_session_fn_ctx *ev_ctx,
static void foreach_session_continue(struct vhost_session_fn_ctx *ev_ctx,
struct spdk_vhost_session *vsession);
static void
foreach_session_finish_cb(void *arg1)
{
struct spdk_vhost_session_fn_ctx *ctx = arg1;
struct vhost_session_fn_ctx *ctx = arg1;
struct spdk_vhost_dev *vdev = ctx->vdev;
if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) {
if (pthread_mutex_trylock(&g_vhost_mutex) != 0) {
spdk_thread_send_msg(spdk_get_thread(),
foreach_session_finish_cb, arg1);
return;
@ -994,25 +994,25 @@ foreach_session_finish_cb(void *arg1)
/* Call fn one last time with vsession == NULL */
ctx->cb_fn(vdev, NULL, ctx->user_ctx);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
free(ctx);
}
static void
foreach_session_continue_cb(void *arg1)
{
struct spdk_vhost_session_fn_ctx *ctx = arg1;
struct vhost_session_fn_ctx *ctx = arg1;
struct spdk_vhost_session *vsession = NULL;
struct spdk_vhost_dev *vdev = ctx->vdev;
int rc;
if (pthread_mutex_trylock(&g_spdk_vhost_mutex) != 0) {
if (pthread_mutex_trylock(&g_vhost_mutex) != 0) {
spdk_thread_send_msg(spdk_get_thread(),
foreach_session_continue_cb, arg1);
return;
}
vsession = spdk_vhost_session_find_by_id(vdev, ctx->vsession_id);
vsession = vhost_session_find_by_id(vdev, ctx->vsession_id);
if (vsession == NULL || !vsession->initialized) {
/* The session must have been removed in the meantime, so we
* just skip it in our foreach chain
@ -1028,25 +1028,25 @@ foreach_session_continue_cb(void *arg1)
*/
spdk_thread_send_msg(vsession->poll_group->thread,
foreach_session_continue_cb, arg1);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return;
}
rc = ctx->cb_fn(vdev, vsession, ctx->user_ctx);
if (rc < 0) {
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
free(ctx);
return;
}
out_unlock_continue:
vsession = spdk_vhost_session_next(vdev, ctx->vsession_id);
vsession = vhost_session_next(vdev, ctx->vsession_id);
foreach_session_continue(ctx, vsession);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
}
static void
foreach_session_continue(struct spdk_vhost_session_fn_ctx *ev_ctx,
foreach_session_continue(struct vhost_session_fn_ctx *ev_ctx,
struct spdk_vhost_session *vsession)
{
struct spdk_vhost_dev *vdev = ev_ctx->vdev;
@ -1060,7 +1060,7 @@ foreach_session_continue(struct spdk_vhost_session_fn_ctx *ev_ctx,
}
}
vsession = spdk_vhost_session_next(vdev, vsession->id);
vsession = vhost_session_next(vdev, vsession->id);
}
if (vsession != NULL) {
@ -1075,11 +1075,11 @@ foreach_session_continue(struct spdk_vhost_session_fn_ctx *ev_ctx,
}
void
spdk_vhost_dev_foreach_session(struct spdk_vhost_dev *vdev,
spdk_vhost_session_fn fn, void *arg)
vhost_dev_foreach_session(struct spdk_vhost_dev *vdev,
spdk_vhost_session_fn fn, void *arg)
{
struct spdk_vhost_session *vsession = TAILQ_FIRST(&vdev->vsessions);
struct spdk_vhost_session_fn_ctx *ev_ctx;
struct vhost_session_fn_ctx *ev_ctx;
ev_ctx = calloc(1, sizeof(*ev_ctx));
if (ev_ctx == NULL) {
@ -1108,7 +1108,7 @@ _stop_session(struct spdk_vhost_session *vsession)
rc = vdev->backend->stop_session(vsession);
if (rc != 0) {
SPDK_ERRLOG("Couldn't stop device with vid %d.\n", vsession->vid);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return;
}
@ -1120,7 +1120,7 @@ _stop_session(struct spdk_vhost_session *vsession)
rte_vhost_set_vring_base(vsession->vid, i, q->last_avail_idx, q->last_used_idx);
}
spdk_vhost_session_mem_unregister(vsession);
vhost_session_mem_unregister(vsession);
free(vsession->mem);
}
@ -1129,22 +1129,22 @@ stop_device(int vid)
{
struct spdk_vhost_session *vsession;
pthread_mutex_lock(&g_spdk_vhost_mutex);
vsession = spdk_vhost_session_find_by_vid(vid);
pthread_mutex_lock(&g_vhost_mutex);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Couldn't find session with vid %d.\n", vid);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return;
}
if (!vsession->started) {
/* already stopped, nothing to do */
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return;
}
_stop_session(vsession);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
}
static int
@ -1155,9 +1155,9 @@ start_device(int vid)
int rc = -1;
uint16_t i;
pthread_mutex_lock(&g_spdk_vhost_mutex);
pthread_mutex_lock(&g_vhost_mutex);
vsession = spdk_vhost_session_find_by_vid(vid);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Couldn't find session with vid %d.\n", vid);
goto out;
@ -1226,18 +1226,18 @@ start_device(int vid)
}
}
spdk_vhost_session_set_coalescing(vdev, vsession, NULL);
spdk_vhost_session_mem_register(vsession);
vhost_session_set_coalescing(vdev, vsession, NULL);
vhost_session_mem_register(vsession);
vsession->initialized = true;
rc = vdev->backend->start_session(vsession);
if (rc != 0) {
spdk_vhost_session_mem_unregister(vsession);
vhost_session_mem_unregister(vsession);
free(vsession->mem);
goto out;
}
out:
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return rc;
}
@ -1249,8 +1249,8 @@ get_config(int vid, uint8_t *config, uint32_t len)
struct spdk_vhost_dev *vdev;
int rc = -1;
pthread_mutex_lock(&g_spdk_vhost_mutex);
vsession = spdk_vhost_session_find_by_vid(vid);
pthread_mutex_lock(&g_vhost_mutex);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Couldn't find session with vid %d.\n", vid);
goto out;
@ -1262,7 +1262,7 @@ get_config(int vid, uint8_t *config, uint32_t len)
}
out:
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return rc;
}
@ -1273,8 +1273,8 @@ set_config(int vid, uint8_t *config, uint32_t offset, uint32_t size, uint32_t fl
struct spdk_vhost_dev *vdev;
int rc = -1;
pthread_mutex_lock(&g_spdk_vhost_mutex);
vsession = spdk_vhost_session_find_by_vid(vid);
pthread_mutex_lock(&g_vhost_mutex);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Couldn't find session with vid %d.\n", vid);
goto out;
@ -1286,7 +1286,7 @@ set_config(int vid, uint8_t *config, uint32_t offset, uint32_t size, uint32_t fl
}
out:
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return rc;
}
#endif
@ -1316,7 +1316,7 @@ spdk_vhost_set_socket_path(const char *basename)
}
void
spdk_vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
{
assert(vdev->backend->dump_info_json != NULL);
vdev->backend->dump_info_json(vdev, w);
@ -1339,18 +1339,18 @@ new_connection(int vid)
struct spdk_vhost_session *vsession;
char ifname[PATH_MAX];
pthread_mutex_lock(&g_spdk_vhost_mutex);
pthread_mutex_lock(&g_vhost_mutex);
if (rte_vhost_get_ifname(vid, ifname, PATH_MAX) < 0) {
SPDK_ERRLOG("Couldn't get a valid ifname for device with vid %d\n", vid);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return -1;
}
vdev = spdk_vhost_dev_find(ifname);
if (vdev == NULL) {
SPDK_ERRLOG("Couldn't find device with vid %d to create connection for.\n", vid);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return -1;
}
@ -1367,7 +1367,7 @@ new_connection(int vid)
if (posix_memalign((void **)&vsession, SPDK_CACHE_LINE_SIZE, sizeof(*vsession) +
vdev->backend->session_ctx_size)) {
SPDK_ERRLOG("vsession alloc failed\n");
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return -1;
}
memset(vsession, 0, sizeof(*vsession) + vdev->backend->session_ctx_size);
@ -1378,7 +1378,7 @@ new_connection(int vid)
vsession->name = spdk_sprintf_alloc("%ss%u", vdev->name, vsession->vid);
if (vsession->name == NULL) {
SPDK_ERRLOG("vsession alloc failed\n");
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
free(vsession);
return -1;
}
@ -1390,8 +1390,8 @@ new_connection(int vid)
spdk_get_ticks_hz() / 1000UL;
TAILQ_INSERT_TAIL(&vdev->vsessions, vsession, tailq);
spdk_vhost_session_install_rte_compat_hooks(vsession);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
vhost_session_install_rte_compat_hooks(vsession);
pthread_mutex_unlock(&g_vhost_mutex);
return 0;
}
@ -1400,11 +1400,11 @@ destroy_connection(int vid)
{
struct spdk_vhost_session *vsession;
pthread_mutex_lock(&g_spdk_vhost_mutex);
vsession = spdk_vhost_session_find_by_vid(vid);
pthread_mutex_lock(&g_vhost_mutex);
vsession = vhost_session_find_by_vid(vid);
if (vsession == NULL) {
SPDK_ERRLOG("Couldn't find session with vid %d.\n", vid);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
return;
}
@ -1415,25 +1415,25 @@ destroy_connection(int vid)
TAILQ_REMOVE(&vsession->vdev->vsessions, vsession, tailq);
free(vsession->name);
free(vsession);
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
}
void
spdk_vhost_lock(void)
{
pthread_mutex_lock(&g_spdk_vhost_mutex);
pthread_mutex_lock(&g_vhost_mutex);
}
int
spdk_vhost_trylock(void)
{
return -pthread_mutex_trylock(&g_spdk_vhost_mutex);
return -pthread_mutex_trylock(&g_vhost_mutex);
}
void
spdk_vhost_unlock(void)
{
pthread_mutex_unlock(&g_spdk_vhost_mutex);
pthread_mutex_unlock(&g_vhost_mutex);
}
static void
@ -1448,20 +1448,20 @@ vhost_create_poll_group_done(void *ctx)
return;
}
ret = spdk_vhost_scsi_controller_construct();
ret = vhost_scsi_controller_construct();
if (ret != 0) {
SPDK_ERRLOG("Cannot construct vhost controllers\n");
goto out;
}
ret = spdk_vhost_blk_controller_construct();
ret = vhost_blk_controller_construct();
if (ret != 0) {
SPDK_ERRLOG("Cannot construct vhost block controllers\n");
goto out;
}
#ifdef SPDK_CONFIG_VHOST_INTERNAL_LIB
ret = spdk_vhost_nvme_controller_construct();
ret = vhost_nvme_controller_construct();
if (ret != 0) {
SPDK_ERRLOG("Cannot construct vhost NVMe controllers\n");
goto out;
@ -1564,7 +1564,7 @@ session_shutdown(void *arg)
{
struct spdk_vhost_dev *vdev = NULL;
TAILQ_FOREACH(vdev, &g_spdk_vhost_devices, tailq) {
TAILQ_FOREACH(vdev, &g_vhost_devices, tailq) {
rte_vhost_driver_unregister(vdev->path);
vdev->registered = false;
}

View File

@ -105,8 +105,8 @@ invalid_blk_request(struct spdk_vhost_blk_task *task, uint8_t status)
*task->status = status;
}
spdk_vhost_vq_used_ring_enqueue(&task->bvsession->vsession, task->vq, task->req_idx,
task->used_len);
vhost_vq_used_ring_enqueue(&task->bvsession->vsession, task->vq, task->req_idx,
task->used_len);
blk_task_finish(task);
SPDK_DEBUGLOG(SPDK_LOG_VHOST_BLK_DATA, "Invalid request (status=%" PRIu8")\n", status);
}
@ -130,7 +130,7 @@ blk_iovs_setup(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtq
uint32_t desc_handled_cnt;
int rc;
rc = spdk_vhost_vq_get_desc(vsession, vq, req_idx, &desc, &desc_table, &desc_table_size);
rc = vhost_vq_get_desc(vsession, vq, req_idx, &desc, &desc_table, &desc_table_size);
if (rc != 0) {
SPDK_ERRLOG("%s: invalid descriptor at index %"PRIu16".\n", vdev->name, req_idx);
return -1;
@ -148,7 +148,7 @@ blk_iovs_setup(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtq
return -1;
}
if (spdk_unlikely(spdk_vhost_vring_desc_to_iov(vsession, iovs, &cnt, desc))) {
if (spdk_unlikely(vhost_vring_desc_to_iov(vsession, iovs, &cnt, desc))) {
SPDK_DEBUGLOG(SPDK_LOG_VHOST_BLK, "%s: invalid descriptor %" PRIu16" (req_idx = %"PRIu16").\n",
vsession->name, req_idx, cnt);
return -1;
@ -156,9 +156,9 @@ blk_iovs_setup(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtq
len += desc->len;
out_cnt += spdk_vhost_vring_desc_is_wr(desc);
out_cnt += vhost_vring_desc_is_wr(desc);
rc = spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
rc = vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
if (rc != 0) {
SPDK_ERRLOG("%s: descriptor chain at index %"PRIu16" terminated unexpectedly.\n",
vsession->name, req_idx);
@ -194,8 +194,8 @@ static void
blk_request_finish(bool success, struct spdk_vhost_blk_task *task)
{
*task->status = success ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR;
spdk_vhost_vq_used_ring_enqueue(&task->bvsession->vsession, task->vq, task->req_idx,
task->used_len);
vhost_vq_used_ring_enqueue(&task->bvsession->vsession, task->vq, task->req_idx,
task->used_len);
SPDK_DEBUGLOG(SPDK_LOG_VHOST_BLK, "Finished task (%p) req_idx=%d\n status: %s\n", task,
task->req_idx, success ? "OK" : "FAIL");
blk_task_finish(task);
@ -425,7 +425,7 @@ process_vq(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtqueue
uint16_t reqs[32];
uint16_t reqs_cnt, i;
reqs_cnt = spdk_vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
reqs_cnt = vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
if (!reqs_cnt) {
return;
}
@ -437,7 +437,7 @@ process_vq(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtqueue
if (spdk_unlikely(reqs[i] >= vq->vring.size)) {
SPDK_ERRLOG("%s: request idx '%"PRIu16"' exceeds virtqueue size (%"PRIu16").\n",
vsession->name, reqs[i], vq->vring.size);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -445,7 +445,7 @@ process_vq(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_virtqueue
if (spdk_unlikely(task->used)) {
SPDK_ERRLOG("%s: request with idx '%"PRIu16"' is already pending.\n",
vsession->name, reqs[i]);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -478,7 +478,7 @@ vdev_worker(void *arg)
process_vq(bvsession, &vsession->virtqueue[q_idx]);
}
spdk_vhost_session_used_signal(vsession);
vhost_session_used_signal(vsession);
return -1;
}
@ -491,7 +491,7 @@ no_bdev_process_vq(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_v
uint32_t length;
uint16_t iovcnt, req_idx;
if (spdk_vhost_vq_avail_ring_get(vq, &req_idx, 1) != 1) {
if (vhost_vq_avail_ring_get(vq, &req_idx, 1) != 1) {
return;
}
@ -501,7 +501,7 @@ no_bdev_process_vq(struct spdk_vhost_blk_session *bvsession, struct spdk_vhost_v
SPDK_DEBUGLOG(SPDK_LOG_VHOST_BLK_DATA, "Aborting request %" PRIu16"\n", req_idx);
}
spdk_vhost_vq_used_ring_enqueue(vsession, vq, req_idx, 0);
vhost_vq_used_ring_enqueue(vsession, vq, req_idx, 0);
}
static int
@ -515,7 +515,7 @@ no_bdev_vdev_worker(void *arg)
no_bdev_process_vq(bvsession, &vsession->virtqueue[q_idx]);
}
spdk_vhost_session_used_signal(vsession);
vhost_session_used_signal(vsession);
if (vsession->task_cnt == 0 && bvsession->io_channel) {
spdk_put_io_channel(bvsession->io_channel);
@ -557,8 +557,9 @@ spdk_vhost_blk_get_dev(struct spdk_vhost_dev *vdev)
}
static int
_spdk_vhost_session_bdev_remove_cb(struct spdk_vhost_dev *vdev, struct spdk_vhost_session *vsession,
void *ctx)
vhost_session_bdev_remove_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession,
void *ctx)
{
struct spdk_vhost_blk_session *bvsession;
@ -596,7 +597,7 @@ bdev_remove_cb(void *remove_ctx)
bvdev->vdev.name);
spdk_vhost_lock();
spdk_vhost_dev_foreach_session(&bvdev->vdev, _spdk_vhost_session_bdev_remove_cb, NULL);
vhost_dev_foreach_session(&bvdev->vdev, vhost_session_bdev_remove_cb, NULL);
spdk_vhost_unlock();
}
@ -664,8 +665,8 @@ alloc_task_pool(struct spdk_vhost_blk_session *bvsession)
}
static int
spdk_vhost_blk_start_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
vhost_blk_start_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
{
struct spdk_vhost_blk_session *bvsession = to_blk_session(vsession);
struct spdk_vhost_blk_dev *bvdev;
@ -705,22 +706,22 @@ spdk_vhost_blk_start_cb(struct spdk_vhost_dev *vdev,
SPDK_INFOLOG(SPDK_LOG_VHOST, "%s: started poller on lcore %d\n",
vsession->name, spdk_env_get_current_core());
out:
spdk_vhost_session_start_done(vsession, rc);
vhost_session_start_done(vsession, rc);
return rc;
}
static int
spdk_vhost_blk_start(struct spdk_vhost_session *vsession)
vhost_blk_start(struct spdk_vhost_session *vsession)
{
struct vhost_poll_group *pg;
int rc;
pg = spdk_vhost_get_poll_group(vsession->vdev->cpumask);
rc = spdk_vhost_session_send_event(pg, vsession, spdk_vhost_blk_start_cb,
3, "start session");
pg = vhost_get_poll_group(vsession->vdev->cpumask);
rc = vhost_session_send_event(pg, vsession, vhost_blk_start_cb,
3, "start session");
if (rc != 0) {
spdk_vhost_put_poll_group(pg);
vhost_put_poll_group(pg);
}
return rc;
@ -743,7 +744,7 @@ destroy_session_poller_cb(void *arg)
for (i = 0; i < vsession->max_queues; i++) {
vsession->virtqueue[i].next_event_time = 0;
spdk_vhost_vq_used_signal(vsession, &vsession->virtqueue[i]);
vhost_vq_used_signal(vsession, &vsession->virtqueue[i]);
}
SPDK_INFOLOG(SPDK_LOG_VHOST, "%s: stopping poller on lcore %d\n",
@ -756,15 +757,15 @@ destroy_session_poller_cb(void *arg)
free_task_pool(bvsession);
spdk_poller_unregister(&bvsession->stop_poller);
spdk_vhost_session_stop_done(vsession, 0);
vhost_session_stop_done(vsession, 0);
spdk_vhost_unlock();
return -1;
}
static int
spdk_vhost_blk_stop_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
vhost_blk_stop_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
{
struct spdk_vhost_blk_session *bvsession = to_blk_session(vsession);
@ -775,14 +776,14 @@ spdk_vhost_blk_stop_cb(struct spdk_vhost_dev *vdev,
}
static int
spdk_vhost_blk_stop(struct spdk_vhost_session *vsession)
vhost_blk_stop(struct spdk_vhost_session *vsession)
{
return spdk_vhost_session_send_event(vsession->poll_group, vsession,
spdk_vhost_blk_stop_cb, 3, "stop session");
return vhost_session_send_event(vsession->poll_group, vsession,
vhost_blk_stop_cb, 3, "stop session");
}
static void
spdk_vhost_blk_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
vhost_blk_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
{
struct spdk_bdev *bdev = spdk_vhost_blk_get_dev(vdev);
struct spdk_vhost_blk_dev *bvdev;
@ -804,7 +805,7 @@ spdk_vhost_blk_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_writ
}
static void
spdk_vhost_blk_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
vhost_blk_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
{
struct spdk_vhost_blk_dev *bvdev;
@ -827,11 +828,11 @@ spdk_vhost_blk_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_w
spdk_json_write_object_end(w);
}
static int spdk_vhost_blk_destroy(struct spdk_vhost_dev *dev);
static int vhost_blk_destroy(struct spdk_vhost_dev *dev);
static int
spdk_vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config,
uint32_t len)
vhost_blk_get_config(struct spdk_vhost_dev *vdev, uint8_t *config,
uint32_t len)
{
struct virtio_blk_config blkcfg;
struct spdk_vhost_blk_dev *bvdev;
@ -908,16 +909,16 @@ static const struct spdk_vhost_dev_backend vhost_blk_device_backend = {
(1ULL << VIRTIO_BLK_F_BARRIER) | (1ULL << VIRTIO_BLK_F_SCSI) | (1ULL << VIRTIO_BLK_F_DISCARD) |
(1ULL << VIRTIO_BLK_F_WRITE_ZEROES),
.session_ctx_size = sizeof(struct spdk_vhost_blk_session) - sizeof(struct spdk_vhost_session),
.start_session = spdk_vhost_blk_start,
.stop_session = spdk_vhost_blk_stop,
.vhost_get_config = spdk_vhost_blk_get_config,
.dump_info_json = spdk_vhost_blk_dump_info_json,
.write_config_json = spdk_vhost_blk_write_config_json,
.remove_device = spdk_vhost_blk_destroy,
.start_session = vhost_blk_start,
.stop_session = vhost_blk_stop,
.vhost_get_config = vhost_blk_get_config,
.dump_info_json = vhost_blk_dump_info_json,
.write_config_json = vhost_blk_write_config_json,
.remove_device = vhost_blk_destroy,
};
int
spdk_vhost_blk_controller_construct(void)
vhost_blk_controller_construct(void)
{
struct spdk_conf_section *sp;
unsigned ctrlr_num;
@ -991,7 +992,7 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_
bvdev->bdev = bdev;
bvdev->readonly = readonly;
ret = spdk_vhost_dev_register(&bvdev->vdev, name, cpumask, &vhost_blk_device_backend);
ret = vhost_dev_register(&bvdev->vdev, name, cpumask, &vhost_blk_device_backend);
if (ret != 0) {
spdk_bdev_close(bvdev->bdev_desc);
goto out;
@ -1013,7 +1014,7 @@ spdk_vhost_blk_construct(const char *name, const char *cpumask, const char *dev_
if (features && rte_vhost_driver_enable_features(bvdev->vdev.path, features)) {
SPDK_ERRLOG("%s: failed to enable features 0x%"PRIx64"\n", name, features);
if (spdk_vhost_dev_unregister(&bvdev->vdev) != 0) {
if (vhost_dev_unregister(&bvdev->vdev) != 0) {
SPDK_ERRLOG("%s: failed to remove device\n", name);
}
@ -1032,13 +1033,13 @@ out:
}
static int
spdk_vhost_blk_destroy(struct spdk_vhost_dev *vdev)
vhost_blk_destroy(struct spdk_vhost_dev *vdev)
{
struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev);
int rc;
assert(bvdev != NULL);
rc = spdk_vhost_dev_unregister(&bvdev->vdev);
rc = vhost_dev_unregister(&bvdev->vdev);
if (rc != 0) {
return rc;
}

View File

@ -231,10 +231,10 @@ struct spdk_vhost_dev_backend {
int (*remove_device)(struct spdk_vhost_dev *vdev);
};
void *spdk_vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr, uint64_t len);
void *vhost_gpa_to_vva(struct spdk_vhost_session *vsession, uint64_t addr, uint64_t len);
uint16_t spdk_vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *vq, uint16_t *reqs,
uint16_t reqs_len);
uint16_t vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *vq, uint16_t *reqs,
uint16_t reqs_len);
/**
* Get a virtio descriptor at given index in given virtqueue.
@ -253,9 +253,9 @@ uint16_t spdk_vhost_vq_avail_ring_get(struct spdk_vhost_virtqueue *vq, uint16_t
* \return 0 on success, -1 if given index is invalid.
* If -1 is returned, the content of params is undefined.
*/
int spdk_vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq,
uint16_t req_idx, struct vring_desc **desc, struct vring_desc **desc_table,
uint32_t *desc_table_size);
int vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq,
uint16_t req_idx, struct vring_desc **desc, struct vring_desc **desc_table,
uint32_t *desc_table_size);
/**
* Send IRQ/call client (if pending) for \c vq.
@ -265,7 +265,7 @@ int spdk_vhost_vq_get_desc(struct spdk_vhost_session *vsession, struct spdk_vhos
* 0 - if no interrupt was signalled
* 1 - if interrupt was signalled
*/
int spdk_vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq);
int vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_vhost_virtqueue *vq);
/**
@ -273,11 +273,11 @@ int spdk_vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_v
* \param vsession vhost session
* \param vq virtqueue
*/
void spdk_vhost_session_used_signal(struct spdk_vhost_session *vsession);
void vhost_session_used_signal(struct spdk_vhost_session *vsession);
void spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *vq,
uint16_t id, uint32_t len);
void vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
struct spdk_vhost_virtqueue *vq,
uint16_t id, uint32_t len);
/**
* Get subsequent descriptor from given table.
@ -290,26 +290,26 @@ void spdk_vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
* The *desc* param will be set regardless of the
* return value.
*/
int spdk_vhost_vring_desc_get_next(struct vring_desc **desc,
struct vring_desc *desc_table, uint32_t desc_table_size);
bool spdk_vhost_vring_desc_is_wr(struct vring_desc *cur_desc);
int vhost_vring_desc_get_next(struct vring_desc **desc,
struct vring_desc *desc_table, uint32_t desc_table_size);
bool vhost_vring_desc_is_wr(struct vring_desc *cur_desc);
int spdk_vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov,
uint16_t *iov_index, const struct vring_desc *desc);
int vhost_vring_desc_to_iov(struct spdk_vhost_session *vsession, struct iovec *iov,
uint16_t *iov_index, const struct vring_desc *desc);
static inline bool __attribute__((always_inline))
spdk_vhost_dev_has_feature(struct spdk_vhost_session *vsession, unsigned feature_id)
vhost_dev_has_feature(struct spdk_vhost_session *vsession, unsigned feature_id)
{
return vsession->negotiated_features & (1ULL << feature_id);
}
int spdk_vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str,
const struct spdk_vhost_dev_backend *backend);
int spdk_vhost_dev_unregister(struct spdk_vhost_dev *vdev);
int vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *mask_str,
const struct spdk_vhost_dev_backend *backend);
int vhost_dev_unregister(struct spdk_vhost_dev *vdev);
int spdk_vhost_scsi_controller_construct(void);
int spdk_vhost_blk_controller_construct(void);
void spdk_vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w);
int vhost_scsi_controller_construct(void);
int vhost_blk_controller_construct(void);
void vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w);
/*
* Call function for each active session on the provided
@ -320,8 +320,8 @@ void spdk_vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_wri
* \param fn function to call
* \param arg additional argument to \c fn
*/
void spdk_vhost_dev_foreach_session(struct spdk_vhost_dev *dev,
spdk_vhost_session_fn fn, void *arg);
void vhost_dev_foreach_session(struct spdk_vhost_dev *dev,
spdk_vhost_session_fn fn, void *arg);
/**
* Call a function on the provided lcore and block until either
@ -341,10 +341,10 @@ void spdk_vhost_dev_foreach_session(struct spdk_vhost_dev *dev,
* \param errmsg error message to print once the timeout expires
* \return return the code passed to spdk_vhost_session_event_done().
*/
int spdk_vhost_session_send_event(struct vhost_poll_group *pg,
struct spdk_vhost_session *vsession,
spdk_vhost_session_fn cb_fn, unsigned timeout_sec,
const char *errmsg);
int vhost_session_send_event(struct vhost_poll_group *pg,
struct spdk_vhost_session *vsession,
spdk_vhost_session_fn cb_fn, unsigned timeout_sec,
const char *errmsg);
/**
* Finish a blocking spdk_vhost_session_send_event() call and finally
@ -357,7 +357,7 @@ int spdk_vhost_session_send_event(struct vhost_poll_group *pg,
* \param vsession vhost session
* \param response return code
*/
void spdk_vhost_session_start_done(struct spdk_vhost_session *vsession, int response);
void vhost_session_start_done(struct spdk_vhost_session *vsession, int response);
/**
* Finish a blocking spdk_vhost_session_send_event() call and finally
@ -373,27 +373,27 @@ void spdk_vhost_session_start_done(struct spdk_vhost_session *vsession, int resp
* \param vsession vhost session
* \param response return code
*/
void spdk_vhost_session_stop_done(struct spdk_vhost_session *vsession, int response);
void vhost_session_stop_done(struct spdk_vhost_session *vsession, int response);
struct spdk_vhost_session *spdk_vhost_session_find_by_vid(int vid);
void spdk_vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession);
void spdk_vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev);
struct spdk_vhost_session *vhost_session_find_by_vid(int vid);
void vhost_session_install_rte_compat_hooks(struct spdk_vhost_session *vsession);
void vhost_dev_install_rte_compat_hooks(struct spdk_vhost_dev *vdev);
struct vhost_poll_group *spdk_vhost_get_poll_group(struct spdk_cpuset *cpumask);
void spdk_vhost_put_poll_group(struct vhost_poll_group *pg);
struct vhost_poll_group *vhost_get_poll_group(struct spdk_cpuset *cpumask);
void vhost_put_poll_group(struct vhost_poll_group *pg);
int spdk_remove_vhost_controller(struct spdk_vhost_dev *vdev);
int remove_vhost_controller(struct spdk_vhost_dev *vdev);
#ifdef SPDK_CONFIG_VHOST_INTERNAL_LIB
int spdk_vhost_nvme_admin_passthrough(int vid, void *cmd, void *cqe, void *buf);
int spdk_vhost_nvme_set_cq_call(int vid, uint16_t qid, int fd);
int spdk_vhost_nvme_set_bar_mr(int vid, void *bar_addr, uint64_t bar_size);
int spdk_vhost_nvme_get_cap(int vid, uint64_t *cap);
int spdk_vhost_nvme_controller_construct(void);
int spdk_vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t io_queues);
int spdk_vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev);
int spdk_vhost_nvme_dev_add_ns(struct spdk_vhost_dev *vdev,
const char *bdev_name);
int vhost_nvme_admin_passthrough(int vid, void *cmd, void *cqe, void *buf);
int vhost_nvme_set_cq_call(int vid, uint16_t qid, int fd);
int vhost_nvme_set_bar_mr(int vid, void *bar_addr, uint64_t bar_size);
int vhost_nvme_get_cap(int vid, uint64_t *cap);
int vhost_nvme_controller_construct(void);
int vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t io_queues);
int vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev);
int vhost_nvme_dev_add_ns(struct spdk_vhost_dev *vdev,
const char *bdev_name);
#endif
#endif /* SPDK_VHOST_INTERNAL_H */

View File

@ -265,7 +265,7 @@ spdk_nvme_map_prps(struct spdk_vhost_nvme_dev *nvme, struct spdk_nvme_cmd *cmd,
residue_len = mps - (prp1 % mps);
residue_len = spdk_min(len, residue_len);
vva = spdk_vhost_gpa_to_vva(vsession, prp1, residue_len);
vva = vhost_gpa_to_vva(vsession, prp1, residue_len);
if (spdk_unlikely(vva == NULL)) {
SPDK_ERRLOG("GPA to VVA failed\n");
return -1;
@ -283,7 +283,7 @@ spdk_nvme_map_prps(struct spdk_vhost_nvme_dev *nvme, struct spdk_nvme_cmd *cmd,
if (len <= mps) {
/* 2 PRP used */
task->iovcnt = 2;
vva = spdk_vhost_gpa_to_vva(vsession, prp2, len);
vva = vhost_gpa_to_vva(vsession, prp2, len);
if (spdk_unlikely(vva == NULL)) {
return -1;
}
@ -292,7 +292,7 @@ spdk_nvme_map_prps(struct spdk_vhost_nvme_dev *nvme, struct spdk_nvme_cmd *cmd,
} else {
/* PRP list used */
nents = (len + mps - 1) / mps;
vva = spdk_vhost_gpa_to_vva(vsession, prp2, nents * sizeof(*prp_list));
vva = vhost_gpa_to_vva(vsession, prp2, nents * sizeof(*prp_list));
if (spdk_unlikely(vva == NULL)) {
return -1;
}
@ -300,7 +300,7 @@ spdk_nvme_map_prps(struct spdk_vhost_nvme_dev *nvme, struct spdk_nvme_cmd *cmd,
i = 0;
while (len != 0) {
residue_len = spdk_min(len, mps);
vva = spdk_vhost_gpa_to_vva(vsession, prp_list[i], residue_len);
vva = vhost_gpa_to_vva(vsession, prp_list[i], residue_len);
if (spdk_unlikely(vva == NULL)) {
return -1;
}
@ -712,8 +712,8 @@ vhost_nvme_doorbell_buffer_config(struct spdk_vhost_nvme_dev *nvme,
return -1;
}
/* Guest Physical Address to Host Virtual Address */
nvme->dbbuf_dbs = spdk_vhost_gpa_to_vva(vsession, dbs_dma_addr, 4096);
nvme->dbbuf_eis = spdk_vhost_gpa_to_vva(vsession, eis_dma_addr, 4096);
nvme->dbbuf_dbs = vhost_gpa_to_vva(vsession, dbs_dma_addr, 4096);
nvme->dbbuf_eis = vhost_gpa_to_vva(vsession, eis_dma_addr, 4096);
if (!nvme->dbbuf_dbs || !nvme->dbbuf_eis) {
return -1;
}
@ -768,7 +768,7 @@ vhost_nvme_create_io_sq(struct spdk_vhost_nvme_dev *nvme,
sq->size = qsize + 1;
sq->sq_head = sq->sq_tail = 0;
requested_len = sizeof(struct spdk_nvme_cmd) * sq->size;
sq->sq_cmd = spdk_vhost_gpa_to_vva(nvme->vsession, dma_addr, requested_len);
sq->sq_cmd = vhost_gpa_to_vva(nvme->vsession, dma_addr, requested_len);
if (!sq->sq_cmd) {
return -1;
}
@ -851,7 +851,7 @@ vhost_nvme_create_io_cq(struct spdk_vhost_nvme_dev *nvme,
cq->guest_signaled_cq_head = 0;
cq->need_signaled_cnt = 0;
requested_len = sizeof(struct spdk_nvme_cpl) * cq->size;
cq->cq_cqe = spdk_vhost_gpa_to_vva(nvme->vsession, dma_addr, requested_len);
cq->cq_cqe = vhost_gpa_to_vva(nvme->vsession, dma_addr, requested_len);
if (!cq->cq_cqe) {
return -1;
}
@ -910,7 +910,7 @@ spdk_vhost_nvme_get_by_name(int vid)
}
int
spdk_vhost_nvme_get_cap(int vid, uint64_t *cap)
vhost_nvme_get_cap(int vid, uint64_t *cap)
{
struct spdk_vhost_nvme_dev *nvme;
@ -924,7 +924,7 @@ spdk_vhost_nvme_get_cap(int vid, uint64_t *cap)
}
int
spdk_vhost_nvme_admin_passthrough(int vid, void *cmd, void *cqe, void *buf)
vhost_nvme_admin_passthrough(int vid, void *cmd, void *cqe, void *buf)
{
struct spdk_nvme_cmd *req = (struct spdk_nvme_cmd *)cmd;
struct spdk_nvme_cpl *cpl = (struct spdk_nvme_cpl *)cqe;
@ -998,7 +998,7 @@ spdk_vhost_nvme_admin_passthrough(int vid, void *cmd, void *cqe, void *buf)
}
int
spdk_vhost_nvme_set_bar_mr(int vid, void *bar_addr, uint64_t bar_size)
vhost_nvme_set_bar_mr(int vid, void *bar_addr, uint64_t bar_size)
{
struct spdk_vhost_nvme_dev *nvme;
@ -1016,7 +1016,7 @@ spdk_vhost_nvme_set_bar_mr(int vid, void *bar_addr, uint64_t bar_size)
}
int
spdk_vhost_nvme_set_cq_call(int vid, uint16_t qid, int fd)
vhost_nvme_set_cq_call(int vid, uint16_t qid, int fd)
{
struct spdk_vhost_nvme_dev *nvme;
struct spdk_vhost_nvme_cq *cq;
@ -1106,7 +1106,7 @@ spdk_vhost_nvme_start_cb(struct spdk_vhost_dev *vdev,
/* Start the NVMe Poller */
nvme->requestq_poller = spdk_poller_register(nvme_worker, nvme, 0);
spdk_vhost_session_start_done(vsession, 0);
vhost_session_start_done(vsession, 0);
return 0;
}
@ -1122,12 +1122,12 @@ spdk_vhost_nvme_start(struct spdk_vhost_session *vsession)
return -1;
}
pg = spdk_vhost_get_poll_group(vsession->vdev->cpumask);
rc = spdk_vhost_session_send_event(pg, vsession, spdk_vhost_nvme_start_cb,
3, "start session");
pg = vhost_get_poll_group(vsession->vdev->cpumask);
rc = vhost_session_send_event(pg, vsession, spdk_vhost_nvme_start_cb,
3, "start session");
if (rc != 0) {
spdk_vhost_put_poll_group(pg);
vhost_put_poll_group(pg);
}
return rc;
@ -1186,7 +1186,7 @@ destroy_device_poller_cb(void *arg)
nvme->dataplane_started = false;
spdk_poller_unregister(&nvme->stop_poller);
spdk_vhost_session_stop_done(nvme->vsession, 0);
vhost_session_stop_done(nvme->vsession, 0);
spdk_vhost_unlock();
return -1;
@ -1199,7 +1199,7 @@ spdk_vhost_nvme_stop_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_nvme_dev *nvme = to_nvme_dev(vdev);
if (nvme == NULL) {
spdk_vhost_session_stop_done(vsession, -1);
vhost_session_stop_done(vsession, -1);
return -1;
}
@ -1215,8 +1215,8 @@ spdk_vhost_nvme_stop_cb(struct spdk_vhost_dev *vdev,
static int
spdk_vhost_nvme_stop(struct spdk_vhost_session *vsession)
{
return spdk_vhost_session_send_event(vsession->poll_group, vsession,
spdk_vhost_nvme_stop_cb, 3, "start session");
return vhost_session_send_event(vsession->poll_group, vsession,
spdk_vhost_nvme_stop_cb, 3, "start session");
}
static void
@ -1293,7 +1293,7 @@ static const struct spdk_vhost_dev_backend spdk_vhost_nvme_device_backend = {
.stop_session = spdk_vhost_nvme_stop,
.dump_info_json = spdk_vhost_nvme_dump_info_json,
.write_config_json = spdk_vhost_nvme_write_config_json,
.remove_device = spdk_vhost_nvme_dev_remove,
.remove_device = vhost_nvme_dev_remove,
};
static int
@ -1377,7 +1377,7 @@ spdk_vhost_nvme_ctrlr_identify_update(struct spdk_vhost_nvme_dev *dev)
}
int
spdk_vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t num_io_queues)
vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t num_io_queues)
{
struct spdk_vhost_nvme_dev *dev;
int rc;
@ -1393,8 +1393,8 @@ spdk_vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t nu
}
spdk_vhost_lock();
rc = spdk_vhost_dev_register(&dev->vdev, name, cpumask,
&spdk_vhost_nvme_device_backend);
rc = vhost_dev_register(&dev->vdev, name, cpumask,
&spdk_vhost_nvme_device_backend);
if (rc) {
free(dev);
@ -1414,7 +1414,7 @@ spdk_vhost_nvme_dev_construct(const char *name, const char *cpumask, uint32_t nu
}
int
spdk_vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev)
vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev)
{
struct spdk_vhost_nvme_dev *nvme = to_nvme_dev(vdev);
struct spdk_vhost_nvme_ns *ns;
@ -1433,7 +1433,7 @@ spdk_vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev)
}
}
rc = spdk_vhost_dev_unregister(vdev);
rc = vhost_dev_unregister(vdev);
if (rc != 0) {
return rc;
}
@ -1443,7 +1443,7 @@ spdk_vhost_nvme_dev_remove(struct spdk_vhost_dev *vdev)
}
int
spdk_vhost_nvme_dev_add_ns(struct spdk_vhost_dev *vdev, const char *bdev_name)
vhost_nvme_dev_add_ns(struct spdk_vhost_dev *vdev, const char *bdev_name)
{
struct spdk_vhost_nvme_dev *nvme = to_nvme_dev(vdev);
struct spdk_vhost_nvme_ns *ns;
@ -1484,7 +1484,7 @@ spdk_vhost_nvme_dev_add_ns(struct spdk_vhost_dev *vdev, const char *bdev_name)
}
int
spdk_vhost_nvme_controller_construct(void)
vhost_nvme_controller_construct(void)
{
struct spdk_conf_section *sp;
const char *name;
@ -1519,7 +1519,7 @@ spdk_vhost_nvme_controller_construct(void)
io_queues = 1;
}
rc = spdk_vhost_nvme_dev_construct(name, cpumask, io_queues);
rc = vhost_nvme_dev_construct(name, cpumask, io_queues);
if (rc < 0) {
SPDK_ERRLOG("VhostNvme%u: Construct failed\n", ctrlr_num);
return -1;
@ -1536,7 +1536,7 @@ spdk_vhost_nvme_controller_construct(void)
SPDK_ERRLOG("namespace configuration missing bdev name\n");
break;
}
rc = spdk_vhost_nvme_dev_add_ns(vdev, bdev_name);
rc = vhost_nvme_dev_add_ns(vdev, bdev_name);
if (rc < 0) {
SPDK_WARNLOG("VhostNvme%u: Construct Namespace with %s failed\n",
ctrlr_num, bdev_name);

View File

@ -371,7 +371,7 @@ _spdk_rpc_get_vhost_controller(struct spdk_json_write_ctx *w, struct spdk_vhost_
spdk_json_write_named_string(w, "socket", vdev->path);
spdk_json_write_named_object_begin(w, "backend_specific");
spdk_vhost_dump_info_json(vdev, w);
vhost_dump_info_json(vdev, w);
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
@ -549,7 +549,7 @@ spdk_rpc_construct_vhost_nvme_controller(struct spdk_jsonrpc_request *request,
goto invalid;
}
rc = spdk_vhost_nvme_dev_construct(req.ctrlr, req.cpumask, req.io_queues);
rc = vhost_nvme_dev_construct(req.ctrlr, req.cpumask, req.io_queues);
if (rc < 0) {
goto invalid;
}
@ -612,7 +612,7 @@ spdk_rpc_add_vhost_nvme_ns(struct spdk_jsonrpc_request *request,
goto invalid;
}
rc = spdk_vhost_nvme_dev_add_ns(vdev, req.bdev_name);
rc = vhost_nvme_dev_add_ns(vdev, req.bdev_name);
spdk_vhost_unlock();
if (rc < 0) {
goto invalid;

View File

@ -140,33 +140,33 @@ struct spdk_vhost_scsi_task {
struct spdk_vhost_virtqueue *vq;
};
static int spdk_vhost_scsi_start(struct spdk_vhost_session *vsession);
static int spdk_vhost_scsi_stop(struct spdk_vhost_session *vsession);
static void spdk_vhost_scsi_dump_info_json(struct spdk_vhost_dev *vdev,
static int vhost_scsi_start(struct spdk_vhost_session *vsession);
static int vhost_scsi_stop(struct spdk_vhost_session *vsession);
static void vhost_scsi_dump_info_json(struct spdk_vhost_dev *vdev,
struct spdk_json_write_ctx *w);
static void vhost_scsi_write_config_json(struct spdk_vhost_dev *vdev,
struct spdk_json_write_ctx *w);
static void spdk_vhost_scsi_write_config_json(struct spdk_vhost_dev *vdev,
struct spdk_json_write_ctx *w);
static int spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev);
static int vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev);
const struct spdk_vhost_dev_backend spdk_vhost_scsi_device_backend = {
.virtio_features = SPDK_VHOST_SCSI_FEATURES,
.disabled_features = SPDK_VHOST_SCSI_DISABLED_FEATURES,
.session_ctx_size = sizeof(struct spdk_vhost_scsi_session) - sizeof(struct spdk_vhost_session),
.start_session = spdk_vhost_scsi_start,
.stop_session = spdk_vhost_scsi_stop,
.dump_info_json = spdk_vhost_scsi_dump_info_json,
.write_config_json = spdk_vhost_scsi_write_config_json,
.remove_device = spdk_vhost_scsi_dev_remove,
.start_session = vhost_scsi_start,
.stop_session = vhost_scsi_stop,
.dump_info_json = vhost_scsi_dump_info_json,
.write_config_json = vhost_scsi_write_config_json,
.remove_device = vhost_scsi_dev_remove,
};
static void
spdk_vhost_scsi_task_put(struct spdk_vhost_scsi_task *task)
vhost_scsi_task_put(struct spdk_vhost_scsi_task *task)
{
spdk_scsi_task_put(&task->scsi);
}
static void
spdk_vhost_scsi_task_free_cb(struct spdk_scsi_task *scsi_task)
vhost_scsi_task_free_cb(struct spdk_scsi_task *scsi_task)
{
struct spdk_vhost_scsi_task *task = SPDK_CONTAINEROF(scsi_task, struct spdk_vhost_scsi_task, scsi);
struct spdk_vhost_session *vsession = &task->svsession->vsession;
@ -199,8 +199,8 @@ remove_scsi_tgt(struct spdk_vhost_scsi_dev *svdev,
}
static int
spdk_vhost_scsi_session_process_removed(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
vhost_scsi_session_process_removed(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
{
unsigned scsi_tgt_num = (unsigned)(uintptr_t)ctx;
struct spdk_vhost_scsi_session *svsession;
@ -252,9 +252,9 @@ process_removed_devs(struct spdk_vhost_scsi_session *svsession)
state->status = VHOST_SCSI_DEV_REMOVED;
/* try to detach it globally */
spdk_vhost_lock();
spdk_vhost_dev_foreach_session(&svsession->svdev->vdev,
spdk_vhost_scsi_session_process_removed,
(void *)(uintptr_t)i);
vhost_dev_foreach_session(&svsession->svdev->vdev,
vhost_scsi_session_process_removed,
(void *)(uintptr_t)i);
spdk_vhost_unlock();
}
}
@ -275,20 +275,20 @@ eventq_enqueue(struct spdk_vhost_scsi_session *svsession, unsigned scsi_dev_num,
assert(scsi_dev_num < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS);
vq = &vsession->virtqueue[VIRTIO_SCSI_EVENTQ];
if (vq->vring.desc == NULL || spdk_vhost_vq_avail_ring_get(vq, &req, 1) != 1) {
if (vq->vring.desc == NULL || vhost_vq_avail_ring_get(vq, &req, 1) != 1) {
SPDK_ERRLOG("%s: failed to send virtio event (no avail ring entries?).\n",
vsession->name);
return;
}
rc = spdk_vhost_vq_get_desc(vsession, vq, req, &desc, &desc_table, &desc_table_size);
rc = vhost_vq_get_desc(vsession, vq, req, &desc, &desc_table, &desc_table_size);
if (rc != 0 || desc->len < sizeof(*desc_ev)) {
SPDK_ERRLOG("%s: invalid eventq descriptor at index %"PRIu16".\n",
vsession->name, req);
goto out;
}
desc_ev = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*desc_ev));
desc_ev = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*desc_ev));
if (desc_ev == NULL) {
SPDK_ERRLOG("%s: eventq descriptor at index %"PRIu16" points "
"to unmapped guest memory address %p.\n",
@ -312,7 +312,7 @@ eventq_enqueue(struct spdk_vhost_scsi_session *svsession, unsigned scsi_dev_num,
req_size = sizeof(*desc_ev);
out:
spdk_vhost_vq_used_ring_enqueue(vsession, vq, req, req_size);
vhost_vq_used_ring_enqueue(vsession, vq, req, req_size);
}
static void
@ -320,15 +320,15 @@ submit_completion(struct spdk_vhost_scsi_task *task)
{
struct spdk_vhost_session *vsession = &task->svsession->vsession;
spdk_vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx,
task->used_len);
vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx,
task->used_len);
SPDK_DEBUGLOG(SPDK_LOG_VHOST_SCSI, "Finished task (%p) req_idx=%d\n", task, task->req_idx);
spdk_vhost_scsi_task_put(task);
vhost_scsi_task_put(task);
}
static void
spdk_vhost_scsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
vhost_scsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
{
struct spdk_vhost_scsi_task *task = SPDK_CONTAINEROF(scsi_task, struct spdk_vhost_scsi_task, scsi);
@ -336,7 +336,7 @@ spdk_vhost_scsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task)
}
static void
spdk_vhost_scsi_task_cpl(struct spdk_scsi_task *scsi_task)
vhost_scsi_task_cpl(struct spdk_scsi_task *scsi_task)
{
struct spdk_vhost_scsi_task *task = SPDK_CONTAINEROF(scsi_task, struct spdk_vhost_scsi_task, scsi);
@ -377,16 +377,16 @@ invalid_request(struct spdk_vhost_scsi_task *task)
{
struct spdk_vhost_session *vsession = &task->svsession->vsession;
spdk_vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx,
task->used_len);
spdk_vhost_scsi_task_put(task);
vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx,
task->used_len);
vhost_scsi_task_put(task);
SPDK_DEBUGLOG(SPDK_LOG_VHOST_SCSI, "Invalid request (status=%" PRIu8")\n",
task->resp ? task->resp->response : -1);
}
static int
spdk_vhost_scsi_task_init_target(struct spdk_vhost_scsi_task *task, const __u8 *lun)
vhost_scsi_task_init_target(struct spdk_vhost_scsi_task *task, const __u8 *lun)
{
struct spdk_vhost_scsi_session *svsession = task->svsession;
struct spdk_scsi_dev_session_state *state;
@ -423,16 +423,16 @@ process_ctrl_request(struct spdk_vhost_scsi_task *task)
uint32_t desc_table_size, used_len = 0;
int rc;
spdk_scsi_task_construct(&task->scsi, spdk_vhost_scsi_task_mgmt_cpl, spdk_vhost_scsi_task_free_cb);
rc = spdk_vhost_vq_get_desc(vsession, task->vq, task->req_idx, &desc, &desc_table,
&desc_table_size);
spdk_scsi_task_construct(&task->scsi, vhost_scsi_task_mgmt_cpl, vhost_scsi_task_free_cb);
rc = vhost_vq_get_desc(vsession, task->vq, task->req_idx, &desc, &desc_table,
&desc_table_size);
if (spdk_unlikely(rc != 0)) {
SPDK_ERRLOG("%s: invalid controlq descriptor at index %d.\n",
vsession->name, task->req_idx);
goto out;
}
ctrl_req = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*ctrl_req));
ctrl_req = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*ctrl_req));
if (ctrl_req == NULL) {
SPDK_ERRLOG("%s: invalid task management request at index %d.\n",
vsession->name, task->req_idx);
@ -445,9 +445,9 @@ process_ctrl_request(struct spdk_vhost_scsi_task *task)
task->vq->vring.kickfd, task->vq->vring.size);
SPDK_LOGDUMP(SPDK_LOG_VHOST_SCSI_QUEUE, "Request descriptor", (uint8_t *)ctrl_req, desc->len);
spdk_vhost_scsi_task_init_target(task, ctrl_req->lun);
vhost_scsi_task_init_target(task, ctrl_req->lun);
spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
vhost_vring_desc_get_next(&desc, desc_table, desc_table_size);
if (spdk_unlikely(desc == NULL)) {
SPDK_ERRLOG("%s: no response descriptor for controlq request %d.\n",
vsession->name, task->req_idx);
@ -457,7 +457,7 @@ process_ctrl_request(struct spdk_vhost_scsi_task *task)
/* Process the TMF request */
switch (ctrl_req->type) {
case VIRTIO_SCSI_T_TMF:
task->tmf_resp = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->tmf_resp));
task->tmf_resp = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->tmf_resp));
if (spdk_unlikely(desc->len < sizeof(struct virtio_scsi_ctrl_tmf_resp) || task->tmf_resp == NULL)) {
SPDK_ERRLOG("%s: TMF response descriptor at index %d points to invalid guest memory region\n",
vsession->name, task->req_idx);
@ -487,7 +487,7 @@ process_ctrl_request(struct spdk_vhost_scsi_task *task)
break;
case VIRTIO_SCSI_T_AN_QUERY:
case VIRTIO_SCSI_T_AN_SUBSCRIBE: {
an_resp = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*an_resp));
an_resp = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*an_resp));
if (spdk_unlikely(desc->len < sizeof(struct virtio_scsi_ctrl_an_resp) || an_resp == NULL)) {
SPDK_WARNLOG("%s: asynchronous response descriptor points to invalid guest memory region\n",
vsession->name);
@ -505,8 +505,8 @@ process_ctrl_request(struct spdk_vhost_scsi_task *task)
used_len = sizeof(struct virtio_scsi_ctrl_tmf_resp);
out:
spdk_vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx, used_len);
spdk_vhost_scsi_task_put(task);
vhost_vq_used_ring_enqueue(vsession, task->vq, task->req_idx, used_len);
vhost_scsi_task_put(task);
}
/*
@ -526,18 +526,18 @@ task_data_setup(struct spdk_vhost_scsi_task *task,
uint32_t desc_table_len, len = 0;
int rc;
spdk_scsi_task_construct(&task->scsi, spdk_vhost_scsi_task_cpl, spdk_vhost_scsi_task_free_cb);
spdk_scsi_task_construct(&task->scsi, vhost_scsi_task_cpl, vhost_scsi_task_free_cb);
rc = spdk_vhost_vq_get_desc(vsession, task->vq, task->req_idx, &desc, &desc_table, &desc_table_len);
rc = vhost_vq_get_desc(vsession, task->vq, task->req_idx, &desc, &desc_table, &desc_table_len);
/* First descriptor must be readable */
if (spdk_unlikely(rc != 0 || spdk_vhost_vring_desc_is_wr(desc) ||
if (spdk_unlikely(rc != 0 || vhost_vring_desc_is_wr(desc) ||
desc->len < sizeof(struct virtio_scsi_cmd_req))) {
SPDK_WARNLOG("%s: invalid first request descriptor at index %"PRIu16".\n",
vsession->name, task->req_idx);
goto invalid_task;
}
*req = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(**req));
*req = vhost_gpa_to_vva(vsession, desc->addr, sizeof(**req));
if (spdk_unlikely(*req == NULL)) {
SPDK_WARNLOG("%s: request descriptor at index %d points to invalid guest memory region\n",
vsession->name, task->req_idx);
@ -545,13 +545,13 @@ task_data_setup(struct spdk_vhost_scsi_task *task,
}
/* Each request must have at least 2 descriptors (e.g. request and response) */
spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
if (desc == NULL) {
SPDK_WARNLOG("%s: descriptor chain at index %d contains neither payload nor response buffer.\n",
vsession->name, task->req_idx);
goto invalid_task;
}
task->scsi.dxfer_dir = spdk_vhost_vring_desc_is_wr(desc) ? SPDK_SCSI_DIR_FROM_DEV :
task->scsi.dxfer_dir = vhost_vring_desc_is_wr(desc) ? SPDK_SCSI_DIR_FROM_DEV :
SPDK_SCSI_DIR_TO_DEV;
task->scsi.iovs = iovs;
@ -559,13 +559,13 @@ task_data_setup(struct spdk_vhost_scsi_task *task,
/*
* FROM_DEV (READ): [RD_req][WR_resp][WR_buf0]...[WR_bufN]
*/
task->resp = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->resp));
task->resp = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->resp));
if (spdk_unlikely(desc->len < sizeof(struct virtio_scsi_cmd_resp) || task->resp == NULL)) {
SPDK_WARNLOG("%s: response descriptor at index %d points to invalid guest memory region\n",
vsession->name, task->req_idx);
goto invalid_task;
}
rc = spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
rc = vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
if (spdk_unlikely(rc != 0)) {
SPDK_WARNLOG("%s: invalid descriptor chain at request index %d (descriptor id overflow?).\n",
vsession->name, task->req_idx);
@ -589,18 +589,18 @@ task_data_setup(struct spdk_vhost_scsi_task *task,
/* All remaining descriptors are data. */
while (desc) {
if (spdk_unlikely(!spdk_vhost_vring_desc_is_wr(desc))) {
if (spdk_unlikely(!vhost_vring_desc_is_wr(desc))) {
SPDK_WARNLOG("%s: FROM DEV cmd: descriptor nr %" PRIu16" in payload chain is read only.\n",
vsession->name, iovcnt);
goto invalid_task;
}
if (spdk_unlikely(spdk_vhost_vring_desc_to_iov(vsession, iovs, &iovcnt, desc))) {
if (spdk_unlikely(vhost_vring_desc_to_iov(vsession, iovs, &iovcnt, desc))) {
goto invalid_task;
}
len += desc->len;
rc = spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
rc = vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
if (spdk_unlikely(rc != 0)) {
SPDK_WARNLOG("%s: invalid payload in descriptor chain starting at index %d.\n",
vsession->name, task->req_idx);
@ -617,20 +617,20 @@ task_data_setup(struct spdk_vhost_scsi_task *task,
*/
/* Process descriptors up to response. */
while (!spdk_vhost_vring_desc_is_wr(desc)) {
if (spdk_unlikely(spdk_vhost_vring_desc_to_iov(vsession, iovs, &iovcnt, desc))) {
while (!vhost_vring_desc_is_wr(desc)) {
if (spdk_unlikely(vhost_vring_desc_to_iov(vsession, iovs, &iovcnt, desc))) {
goto invalid_task;
}
len += desc->len;
spdk_vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
vhost_vring_desc_get_next(&desc, desc_table, desc_table_len);
if (spdk_unlikely(desc == NULL)) {
SPDK_WARNLOG("%s: TO_DEV cmd: no response descriptor.\n", vsession->name);
goto invalid_task;
}
}
task->resp = spdk_vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->resp));
task->resp = vhost_gpa_to_vva(vsession, desc->addr, sizeof(*task->resp));
if (spdk_unlikely(desc->len < sizeof(struct virtio_scsi_cmd_resp) || task->resp == NULL)) {
SPDK_WARNLOG("%s: response descriptor at index %d points to invalid guest memory region\n",
vsession->name, task->req_idx);
@ -662,7 +662,7 @@ process_request(struct spdk_vhost_scsi_task *task)
return result;
}
result = spdk_vhost_scsi_task_init_target(task, req->lun);
result = vhost_scsi_task_init_target(task, req->lun);
if (spdk_unlikely(result != 0)) {
task->resp->response = VIRTIO_SCSI_S_BAD_TARGET;
return -1;
@ -688,12 +688,12 @@ process_controlq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
uint16_t reqs[32];
uint16_t reqs_cnt, i;
reqs_cnt = spdk_vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
reqs_cnt = vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
for (i = 0; i < reqs_cnt; i++) {
if (spdk_unlikely(reqs[i] >= vq->vring.size)) {
SPDK_ERRLOG("%s: invalid entry in avail ring. Buffer '%"PRIu16"' exceeds virtqueue size (%"PRIu16")\n",
vsession->name, reqs[i], vq->vring.size);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -701,7 +701,7 @@ process_controlq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
if (spdk_unlikely(task->used)) {
SPDK_ERRLOG("%s: invalid entry in avail ring. Buffer '%"PRIu16"' is still in use!\n",
vsession->name, reqs[i]);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -722,7 +722,7 @@ process_requestq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
uint16_t reqs_cnt, i;
int result;
reqs_cnt = spdk_vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
reqs_cnt = vhost_vq_avail_ring_get(vq, reqs, SPDK_COUNTOF(reqs));
assert(reqs_cnt <= 32);
for (i = 0; i < reqs_cnt; i++) {
@ -732,7 +732,7 @@ process_requestq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
if (spdk_unlikely(reqs[i] >= vq->vring.size)) {
SPDK_ERRLOG("%s: request idx '%"PRIu16"' exceeds virtqueue size (%"PRIu16").\n",
vsession->name, reqs[i], vq->vring.size);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -740,7 +740,7 @@ process_requestq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
if (spdk_unlikely(task->used)) {
SPDK_ERRLOG("%s: request with idx '%"PRIu16"' is already pending.\n",
vsession->name, reqs[i]);
spdk_vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
vhost_vq_used_ring_enqueue(vsession, vq, reqs[i], 0);
continue;
}
@ -755,7 +755,7 @@ process_requestq(struct spdk_vhost_scsi_session *svsession, struct spdk_vhost_vi
SPDK_DEBUGLOG(SPDK_LOG_VHOST_SCSI, "====== Task %p req_idx %d submitted ======\n", task,
task->req_idx);
} else if (result > 0) {
spdk_vhost_scsi_task_cpl(&task->scsi);
vhost_scsi_task_cpl(&task->scsi);
SPDK_DEBUGLOG(SPDK_LOG_VHOST_SCSI, "====== Task %p req_idx %d finished early ======\n", task,
task->req_idx);
} else {
@ -773,10 +773,10 @@ vdev_mgmt_worker(void *arg)
struct spdk_vhost_session *vsession = &svsession->vsession;
process_removed_devs(svsession);
spdk_vhost_vq_used_signal(vsession, &vsession->virtqueue[VIRTIO_SCSI_EVENTQ]);
vhost_vq_used_signal(vsession, &vsession->virtqueue[VIRTIO_SCSI_EVENTQ]);
process_controlq(svsession, &vsession->virtqueue[VIRTIO_SCSI_CONTROLQ]);
spdk_vhost_vq_used_signal(vsession, &vsession->virtqueue[VIRTIO_SCSI_CONTROLQ]);
vhost_vq_used_signal(vsession, &vsession->virtqueue[VIRTIO_SCSI_CONTROLQ]);
return -1;
}
@ -792,7 +792,7 @@ vdev_worker(void *arg)
process_requestq(svsession, &vsession->virtqueue[q_idx]);
}
spdk_vhost_session_used_signal(vsession);
vhost_session_used_signal(vsession);
return -1;
}
@ -830,8 +830,8 @@ spdk_vhost_scsi_dev_construct(const char *name, const char *cpumask)
}
spdk_vhost_lock();
rc = spdk_vhost_dev_register(&svdev->vdev, name, cpumask,
&spdk_vhost_scsi_device_backend);
rc = vhost_dev_register(&svdev->vdev, name, cpumask,
&spdk_vhost_scsi_device_backend);
if (rc) {
free(svdev);
@ -842,7 +842,7 @@ spdk_vhost_scsi_dev_construct(const char *name, const char *cpumask)
}
static int
spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev)
vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev)
{
struct spdk_vhost_scsi_dev *svdev = to_scsi_dev(vdev);
int rc, i;
@ -863,7 +863,7 @@ spdk_vhost_scsi_dev_remove(struct spdk_vhost_dev *vdev)
}
}
rc = spdk_vhost_dev_unregister(vdev);
rc = vhost_dev_unregister(vdev);
if (rc != 0) {
return rc;
}
@ -889,7 +889,7 @@ spdk_vhost_scsi_dev_get_tgt(struct spdk_vhost_dev *vdev, uint8_t num)
}
static void
spdk_vhost_scsi_lun_hotremove(const struct spdk_scsi_lun *lun, void *arg)
vhost_scsi_lun_hotremove(const struct spdk_scsi_lun *lun, void *arg)
{
struct spdk_vhost_scsi_dev *svdev = arg;
const struct spdk_scsi_dev *scsi_dev;
@ -914,8 +914,8 @@ spdk_vhost_scsi_lun_hotremove(const struct spdk_scsi_lun *lun, void *arg)
}
static int
spdk_vhost_scsi_session_add_tgt(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
vhost_scsi_session_add_tgt(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *ctx)
{
unsigned scsi_tgt_num = (unsigned)(uintptr_t)ctx;
struct spdk_vhost_scsi_session *svsession;
@ -965,7 +965,7 @@ spdk_vhost_scsi_session_add_tgt(struct spdk_vhost_dev *vdev,
return 0;
}
if (spdk_vhost_dev_has_feature(vsession, VIRTIO_SCSI_F_HOTPLUG)) {
if (vhost_dev_has_feature(vsession, VIRTIO_SCSI_F_HOTPLUG)) {
eventq_enqueue(svsession, scsi_tgt_num,
VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_RESCAN);
} else {
@ -1029,7 +1029,7 @@ spdk_vhost_scsi_dev_add_tgt(struct spdk_vhost_dev *vdev, int scsi_tgt_num,
state->status = VHOST_SCSI_DEV_ADDING;
state->dev = spdk_scsi_dev_construct(target_name, bdev_names_list, lun_id_list, 1,
SPDK_SPC_PROTOCOL_IDENTIFIER_SAS,
spdk_vhost_scsi_lun_hotremove, svdev);
vhost_scsi_lun_hotremove, svdev);
if (state->dev == NULL) {
state->status = VHOST_SCSI_DEV_EMPTY;
@ -1042,8 +1042,8 @@ spdk_vhost_scsi_dev_add_tgt(struct spdk_vhost_dev *vdev, int scsi_tgt_num,
SPDK_INFOLOG(SPDK_LOG_VHOST, "%s: added SCSI target %u using bdev '%s'\n",
vdev->name, scsi_tgt_num, bdev_name);
spdk_vhost_dev_foreach_session(vdev, spdk_vhost_scsi_session_add_tgt,
(void *)(uintptr_t)scsi_tgt_num);
vhost_dev_foreach_session(vdev, vhost_scsi_session_add_tgt,
(void *)(uintptr_t)scsi_tgt_num);
return scsi_tgt_num;
}
@ -1053,8 +1053,8 @@ struct scsi_tgt_hotplug_ctx {
};
static int
spdk_vhost_scsi_session_remove_tgt(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *_ctx)
vhost_scsi_session_remove_tgt(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *_ctx)
{
struct scsi_tgt_hotplug_ctx *ctx = _ctx;
unsigned scsi_tgt_num = ctx->scsi_tgt_num;
@ -1088,7 +1088,7 @@ spdk_vhost_scsi_session_remove_tgt(struct spdk_vhost_dev *vdev,
state->status = VHOST_SCSI_DEV_REMOVING;
/* Send a hotremove Virtio event */
if (spdk_vhost_dev_has_feature(vsession, VIRTIO_SCSI_F_HOTPLUG)) {
if (vhost_dev_has_feature(vsession, VIRTIO_SCSI_F_HOTPLUG)) {
eventq_enqueue(svsession, scsi_tgt_num,
VIRTIO_SCSI_T_TRANSPORT_RESET, VIRTIO_SCSI_EVT_RESET_REMOVED);
}
@ -1141,12 +1141,12 @@ spdk_vhost_scsi_dev_remove_tgt(struct spdk_vhost_dev *vdev, unsigned scsi_tgt_nu
scsi_dev_state->remove_ctx = cb_arg;
scsi_dev_state->status = VHOST_SCSI_DEV_REMOVING;
spdk_vhost_dev_foreach_session(vdev, spdk_vhost_scsi_session_remove_tgt, ctx);
vhost_dev_foreach_session(vdev, vhost_scsi_session_remove_tgt, ctx);
return 0;
}
int
spdk_vhost_scsi_controller_construct(void)
vhost_scsi_controller_construct(void)
{
struct spdk_conf_section *sp = spdk_conf_first_section(NULL);
struct spdk_vhost_dev *vdev;
@ -1277,8 +1277,8 @@ alloc_task_pool(struct spdk_vhost_scsi_session *svsession)
}
static int
spdk_vhost_scsi_start_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
vhost_scsi_start_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
{
struct spdk_vhost_scsi_session *svsession = to_scsi_session(vsession);
struct spdk_vhost_scsi_dev *svdev = svsession->svdev;
@ -1333,12 +1333,12 @@ spdk_vhost_scsi_start_cb(struct spdk_vhost_dev *vdev,
MGMT_POLL_PERIOD_US);
}
out:
spdk_vhost_session_start_done(vsession, rc);
vhost_session_start_done(vsession, rc);
return rc;
}
static int
spdk_vhost_scsi_start(struct spdk_vhost_session *vsession)
vhost_scsi_start(struct spdk_vhost_session *vsession)
{
struct spdk_vhost_scsi_session *svsession = to_scsi_session(vsession);
struct spdk_vhost_scsi_dev *svdev;
@ -1349,14 +1349,14 @@ spdk_vhost_scsi_start(struct spdk_vhost_session *vsession)
svsession->svdev = svdev;
if (svdev->vdev.active_session_num == 0) {
svdev->poll_group = spdk_vhost_get_poll_group(svdev->vdev.cpumask);
svdev->poll_group = vhost_get_poll_group(svdev->vdev.cpumask);
}
rc = spdk_vhost_session_send_event(svdev->poll_group, vsession, spdk_vhost_scsi_start_cb,
3, "start session");
rc = vhost_session_send_event(svdev->poll_group, vsession, vhost_scsi_start_cb,
3, "start session");
if (rc != 0) {
if (svdev->vdev.active_session_num == 0) {
spdk_vhost_put_poll_group(svdev->poll_group);
vhost_put_poll_group(svdev->poll_group);
svdev->poll_group = NULL;
}
}
@ -1381,7 +1381,7 @@ destroy_session_poller_cb(void *arg)
}
for (i = 0; i < vsession->max_queues; i++) {
spdk_vhost_vq_used_signal(vsession, &vsession->virtqueue[i]);
vhost_vq_used_signal(vsession, &vsession->virtqueue[i]);
}
for (i = 0; i < SPDK_VHOST_SCSI_CTRLR_MAX_DEVS; i++) {
@ -1401,9 +1401,9 @@ destroy_session_poller_cb(void *arg)
if (prev_status == VHOST_SCSI_DEV_REMOVING) {
/* try to detach it globally */
spdk_vhost_dev_foreach_session(vsession->vdev,
spdk_vhost_scsi_session_process_removed,
(void *)(uintptr_t)i);
vhost_dev_foreach_session(vsession->vdev,
vhost_scsi_session_process_removed,
(void *)(uintptr_t)i);
}
}
@ -1413,15 +1413,15 @@ destroy_session_poller_cb(void *arg)
free_task_pool(svsession);
spdk_poller_unregister(&svsession->stop_poller);
spdk_vhost_session_stop_done(vsession, 0);
vhost_session_stop_done(vsession, 0);
spdk_vhost_unlock();
return -1;
}
static int
spdk_vhost_scsi_stop_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
vhost_scsi_stop_cb(struct spdk_vhost_dev *vdev,
struct spdk_vhost_session *vsession, void *unused)
{
struct spdk_vhost_scsi_session *svsession = to_scsi_session(vsession);
@ -1444,26 +1444,26 @@ spdk_vhost_scsi_stop_cb(struct spdk_vhost_dev *vdev,
}
static int
spdk_vhost_scsi_stop(struct spdk_vhost_session *vsession)
vhost_scsi_stop(struct spdk_vhost_session *vsession)
{
struct spdk_vhost_scsi_session *svsession = to_scsi_session(vsession);
int rc;
rc = spdk_vhost_session_send_event(vsession->poll_group, vsession,
spdk_vhost_scsi_stop_cb, 3, "stop session");
rc = vhost_session_send_event(vsession->poll_group, vsession,
vhost_scsi_stop_cb, 3, "stop session");
if (rc != 0) {
return rc;
}
if (vsession->vdev->active_session_num == 0) {
spdk_vhost_put_poll_group(svsession->svdev->poll_group);
vhost_put_poll_group(svsession->svdev->poll_group);
svsession->svdev->poll_group = NULL;
}
return 0;
}
static void
spdk_vhost_scsi_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
vhost_scsi_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
{
struct spdk_scsi_dev *sdev;
struct spdk_scsi_lun *lun;
@ -1511,7 +1511,7 @@ spdk_vhost_scsi_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_wri
}
static void
spdk_vhost_scsi_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
vhost_scsi_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ctx *w)
{
struct spdk_scsi_dev *scsi_dev;
struct spdk_scsi_lun *lun;

View File

@ -46,9 +46,9 @@ DEFINE_STUB(rte_vhost_set_vring_base, int, (int vid, uint16_t queue_id,
uint16_t last_avail_idx, uint16_t last_used_idx), 0);
DEFINE_STUB(rte_vhost_get_vring_base, int, (int vid, uint16_t queue_id,
uint16_t *last_avail_idx, uint16_t *last_used_idx), 0);
DEFINE_STUB_V(spdk_vhost_session_install_rte_compat_hooks,
DEFINE_STUB_V(vhost_session_install_rte_compat_hooks,
(struct spdk_vhost_session *vsession));
DEFINE_STUB_V(spdk_vhost_dev_install_rte_compat_hooks,
DEFINE_STUB_V(vhost_dev_install_rte_compat_hooks,
(struct spdk_vhost_dev *vdev));
DEFINE_STUB(rte_vhost_driver_unregister, int, (const char *path), 0);
DEFINE_STUB(spdk_event_allocate, struct spdk_event *,
@ -98,10 +98,10 @@ DEFINE_STUB(rte_vhost_driver_callback_register, int,
DEFINE_STUB(rte_vhost_driver_disable_features, int, (const char *path, uint64_t features), 0);
DEFINE_STUB(rte_vhost_driver_set_features, int, (const char *path, uint64_t features), 0);
DEFINE_STUB(rte_vhost_driver_register, int, (const char *path, uint64_t flags), 0);
DEFINE_STUB(spdk_vhost_nvme_admin_passthrough, int, (int vid, void *cmd, void *cqe, void *buf), 0);
DEFINE_STUB(spdk_vhost_nvme_set_cq_call, int, (int vid, uint16_t qid, int fd), 0);
DEFINE_STUB(spdk_vhost_nvme_set_bar_mr, int, (int vid, void *bar, uint64_t bar_size), 0);
DEFINE_STUB(spdk_vhost_nvme_get_cap, int, (int vid, uint64_t *cap), 0);
DEFINE_STUB(vhost_nvme_admin_passthrough, int, (int vid, void *cmd, void *cqe, void *buf), 0);
DEFINE_STUB(vhost_nvme_set_cq_call, int, (int vid, uint16_t qid, int fd), 0);
DEFINE_STUB(vhost_nvme_set_bar_mr, int, (int vid, void *bar, uint64_t bar_size), 0);
DEFINE_STUB(vhost_nvme_get_cap, int, (int vid, uint64_t *cap), 0);
void *
spdk_call_unaffinitized(void *cb(void *arg), void *arg)
@ -128,7 +128,7 @@ alloc_vdev(struct spdk_vhost_dev **vdev_p, const char *name, const char *cpumask
CU_ASSERT(rc == 0);
SPDK_CU_ASSERT_FATAL(vdev != NULL);
memset(vdev, 0, sizeof(*vdev));
rc = spdk_vhost_dev_register(vdev, name, cpumask, &g_vdev_backend);
rc = vhost_dev_register(vdev, name, cpumask, &g_vdev_backend);
if (rc == 0) {
*vdev_p = vdev;
} else {
@ -183,7 +183,7 @@ cleanup_vdev(struct spdk_vhost_dev *vdev)
if (!TAILQ_EMPTY(&vdev->vsessions)) {
stop_vdev(vdev);
}
spdk_vhost_dev_unregister(vdev);
vhost_dev_unregister(vdev);
free(vdev);
}
@ -207,7 +207,7 @@ desc_to_iov_test(void)
desc.addr = 0x110000;
desc.len = 0x1000;
iov_index = 0;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc == 0);
CU_ASSERT(iov_index == 1);
CU_ASSERT(iov[0].iov_base == (void *)0x1110000);
@ -220,7 +220,7 @@ desc_to_iov_test(void)
/* Same test, but ensure it respects the non-zero starting iov_index. */
iov_index = SPDK_VHOST_IOVS_MAX - 1;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc == 0);
CU_ASSERT(iov_index == SPDK_VHOST_IOVS_MAX);
CU_ASSERT(iov[SPDK_VHOST_IOVS_MAX - 1].iov_base == (void *)0x1110000);
@ -229,7 +229,7 @@ desc_to_iov_test(void)
/* Test for failure if iov_index already equals SPDK_VHOST_IOVS_MAX. */
iov_index = SPDK_VHOST_IOVS_MAX;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc != 0);
memset(iov, 0, sizeof(iov));
@ -237,7 +237,7 @@ desc_to_iov_test(void)
desc.addr = 0x1F0000;
desc.len = 0x20000;
iov_index = 0;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc == 0);
CU_ASSERT(iov_index == 1);
CU_ASSERT(iov[0].iov_base == (void *)0x11F0000);
@ -246,7 +246,7 @@ desc_to_iov_test(void)
/* Same test, but ensure it respects the non-zero starting iov_index. */
iov_index = SPDK_VHOST_IOVS_MAX - 1;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc == 0);
CU_ASSERT(iov_index == SPDK_VHOST_IOVS_MAX);
CU_ASSERT(iov[SPDK_VHOST_IOVS_MAX - 1].iov_base == (void *)0x11F0000);
@ -257,7 +257,7 @@ desc_to_iov_test(void)
desc.addr = 0x3F0000;
desc.len = 0x20000;
iov_index = 0;
rc = spdk_vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
rc = vhost_vring_desc_to_iov(vsession, iov, &iov_index, &desc);
CU_ASSERT(rc == 0);
CU_ASSERT(iov_index == 2);
CU_ASSERT(iov[0].iov_base == (void *)0x13F0000);
@ -318,11 +318,11 @@ session_find_by_vid_test(void)
vsession = TAILQ_FIRST(&vdev->vsessions);
tmp = spdk_vhost_session_find_by_vid(vsession->vid);
tmp = vhost_session_find_by_vid(vsession->vid);
CU_ASSERT(tmp == vsession);
/* Search for a device with incorrect vid */
tmp = spdk_vhost_session_find_by_vid(vsession->vid + 0xFF);
tmp = vhost_session_find_by_vid(vsession->vid + 0xFF);
CU_ASSERT(tmp == NULL);
cleanup_vdev(vdev);
@ -340,7 +340,7 @@ remove_controller_test(void)
/* Remove device when controller is in use */
start_vdev(vdev);
SPDK_CU_ASSERT_FATAL(!TAILQ_EMPTY(&vdev->vsessions));
ret = spdk_vhost_dev_unregister(vdev);
ret = vhost_dev_unregister(vdev);
CU_ASSERT(ret != 0);
cleanup_vdev(vdev);
@ -365,7 +365,7 @@ vq_avail_ring_get_test(void)
vq.vring.avail->ring[i] = i;
}
ret = spdk_vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
ret = vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
CU_ASSERT(ret == 5);
CU_ASSERT(vq.last_avail_idx == 29);
for (i = 0; i < ret; i++) {
@ -377,7 +377,7 @@ vq_avail_ring_get_test(void)
vq.vring.avail->idx = 29;
reqs_len = 6;
ret = spdk_vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
ret = vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
CU_ASSERT(ret == reqs_len);
CU_ASSERT(vq.last_avail_idx == 26);
for (i = 0; i < ret; i++) {
@ -389,14 +389,14 @@ vq_avail_ring_get_test(void)
vq.vring.avail->idx = 156;
reqs_len = 6;
ret = spdk_vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
ret = vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
CU_ASSERT(ret == 0);
/* Test overflow in the avail->idx variable. */
vq.last_avail_idx = 65535;
vq.vring.avail->idx = 4;
reqs_len = 6;
ret = spdk_vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
ret = vhost_vq_avail_ring_get(&vq, reqs, reqs_len);
CU_ASSERT(ret == 5);
CU_ASSERT(vq.last_avail_idx == 4);
CU_ASSERT(reqs[0] == vq.vring.avail->ring[31]);