lib/vhost: move changing vsession interrupt_mode to rte_vhost_user
This functionality is specific for rte_vhost, so move it to appropriate file. Renamed to include vhost_user_* prefix. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I9630902f52d4944d0d18a39dfbff05945ce2bdba Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11024 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c0b0cfb9f4
commit
8ca52b6d7c
@ -425,6 +425,55 @@ static const struct vhost_device_ops g_spdk_vhost_ops = {
|
|||||||
.destroy_connection = destroy_connection,
|
.destroy_connection = destroy_connection,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
vhost_user_session_set_interrupt_mode(struct spdk_vhost_session *vsession, bool interrupt_mode)
|
||||||
|
{
|
||||||
|
uint16_t i;
|
||||||
|
bool packed_ring;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
packed_ring = ((vsession->negotiated_features & (1ULL << VIRTIO_F_RING_PACKED)) != 0);
|
||||||
|
|
||||||
|
for (i = 0; i < vsession->max_queues; i++) {
|
||||||
|
struct spdk_vhost_virtqueue *q = &vsession->virtqueue[i];
|
||||||
|
uint64_t num_events = 1;
|
||||||
|
|
||||||
|
/* vring.desc and vring.desc_packed are in a union struct
|
||||||
|
* so q->vring.desc can replace q->vring.desc_packed.
|
||||||
|
*/
|
||||||
|
if (q->vring.desc == NULL || q->vring.size == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interrupt_mode) {
|
||||||
|
/* Enable I/O submission notifications, we'll be interrupting. */
|
||||||
|
if (packed_ring) {
|
||||||
|
* (volatile uint16_t *) &q->vring.device_event->flags = VRING_PACKED_EVENT_FLAG_ENABLE;
|
||||||
|
} else {
|
||||||
|
* (volatile uint16_t *) &q->vring.used->flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In case of race condition, always kick vring when switch to intr */
|
||||||
|
rc = write(q->vring.kickfd, &num_events, sizeof(num_events));
|
||||||
|
if (rc < 0) {
|
||||||
|
SPDK_ERRLOG("failed to kick vring: %s.\n", spdk_strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
vsession->interrupt_mode = true;
|
||||||
|
} else {
|
||||||
|
/* Disable I/O submission notifications, we'll be polling. */
|
||||||
|
if (packed_ring) {
|
||||||
|
* (volatile uint16_t *) &q->vring.device_event->flags = VRING_PACKED_EVENT_FLAG_DISABLE;
|
||||||
|
} else {
|
||||||
|
* (volatile uint16_t *) &q->vring.used->flags = VRING_USED_F_NO_NOTIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
vsession->interrupt_mode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static enum rte_vhost_msg_result
|
static enum rte_vhost_msg_result
|
||||||
extern_vhost_pre_msg_handler(int vid, void *_msg)
|
extern_vhost_pre_msg_handler(int vid, void *_msg)
|
||||||
{
|
{
|
||||||
|
@ -1083,54 +1083,6 @@ vhost_dev_foreach_session(struct spdk_vhost_dev *vdev,
|
|||||||
spdk_thread_send_msg(vdev->thread, foreach_session, ev_ctx);
|
spdk_thread_send_msg(vdev->thread, foreach_session, ev_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
vhost_session_set_interrupt_mode(struct spdk_vhost_session *vsession, bool interrupt_mode)
|
|
||||||
{
|
|
||||||
uint16_t i;
|
|
||||||
bool packed_ring;
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
packed_ring = ((vsession->negotiated_features & (1ULL << VIRTIO_F_RING_PACKED)) != 0);
|
|
||||||
|
|
||||||
for (i = 0; i < vsession->max_queues; i++) {
|
|
||||||
struct spdk_vhost_virtqueue *q = &vsession->virtqueue[i];
|
|
||||||
uint64_t num_events = 1;
|
|
||||||
|
|
||||||
/* vring.desc and vring.desc_packed are in a union struct
|
|
||||||
* so q->vring.desc can replace q->vring.desc_packed.
|
|
||||||
*/
|
|
||||||
if (q->vring.desc == NULL || q->vring.size == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (interrupt_mode) {
|
|
||||||
/* Enable I/O submission notifications, we'll be interrupting. */
|
|
||||||
if (packed_ring) {
|
|
||||||
* (volatile uint16_t *) &q->vring.device_event->flags = VRING_PACKED_EVENT_FLAG_ENABLE;
|
|
||||||
} else {
|
|
||||||
* (volatile uint16_t *) &q->vring.used->flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case of race condition, always kick vring when switch to intr */
|
|
||||||
rc = write(q->vring.kickfd, &num_events, sizeof(num_events));
|
|
||||||
if (rc < 0) {
|
|
||||||
SPDK_ERRLOG("failed to kick vring: %s.\n", spdk_strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
vsession->interrupt_mode = true;
|
|
||||||
} else {
|
|
||||||
/* Disable I/O submission notifications, we'll be polling. */
|
|
||||||
if (packed_ring) {
|
|
||||||
* (volatile uint16_t *) &q->vring.device_event->flags = VRING_PACKED_EVENT_FLAG_DISABLE;
|
|
||||||
} else {
|
|
||||||
* (volatile uint16_t *) &q->vring.used->flags = VRING_USED_F_NO_NOTIFY;
|
|
||||||
}
|
|
||||||
|
|
||||||
vsession->interrupt_mode = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -1072,7 +1072,7 @@ vhost_blk_poller_set_interrupt_mode(struct spdk_poller *poller, void *cb_arg, bo
|
|||||||
{
|
{
|
||||||
struct spdk_vhost_blk_session *bvsession = cb_arg;
|
struct spdk_vhost_blk_session *bvsession = cb_arg;
|
||||||
|
|
||||||
vhost_session_set_interrupt_mode(&bvsession->vsession, interrupt_mode);
|
vhost_user_session_set_interrupt_mode(&bvsession->vsession, interrupt_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spdk_vhost_blk_dev *
|
static struct spdk_vhost_blk_dev *
|
||||||
|
@ -423,7 +423,8 @@ void vhost_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ct
|
|||||||
/*
|
/*
|
||||||
* Set vhost session to run in interrupt or poll mode
|
* Set vhost session to run in interrupt or poll mode
|
||||||
*/
|
*/
|
||||||
void vhost_session_set_interrupt_mode(struct spdk_vhost_session *vsession, bool interrupt_mode);
|
void vhost_user_session_set_interrupt_mode(struct spdk_vhost_session *vsession,
|
||||||
|
bool interrupt_mode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory registration functions used in start/stop device callbacks
|
* Memory registration functions used in start/stop device callbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user