vhost: extract vhost_session_vq_used_signal
Change-Id: I249e3e0df45f394c03aedfa7fa2a960de7419a58 Signed-off-by: Liu Xiaodong <xiaodong.liu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4862 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
6a1ec6a640
commit
d2db3cdf8f
@ -327,20 +327,15 @@ session_vq_io_stats_update(struct spdk_vhost_session *vsession,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_session_io_stats(struct spdk_vhost_session *vsession, uint64_t now)
|
check_session_vq_io_stats(struct spdk_vhost_session *vsession,
|
||||||
|
struct spdk_vhost_virtqueue *virtqueue, uint64_t now)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_virtqueue *virtqueue;
|
|
||||||
uint16_t q_idx;
|
|
||||||
|
|
||||||
if (now < vsession->next_stats_check_time) {
|
if (now < vsession->next_stats_check_time) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vsession->next_stats_check_time = now + vsession->stats_check_interval;
|
vsession->next_stats_check_time = now + vsession->stats_check_interval;
|
||||||
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
session_vq_io_stats_update(vsession, virtqueue, now);
|
||||||
virtqueue = &vsession->virtqueue[q_idx];
|
|
||||||
session_vq_io_stats_update(vsession, virtqueue, now);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
@ -359,51 +354,54 @@ vhost_vq_event_is_suppressed(struct spdk_vhost_virtqueue *vq)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vhost_session_vq_used_signal(struct spdk_vhost_virtqueue *virtqueue)
|
||||||
|
{
|
||||||
|
struct spdk_vhost_session *vsession = virtqueue->vsession;
|
||||||
|
uint64_t now;
|
||||||
|
|
||||||
|
if (vsession->coalescing_delay_time_base == 0) {
|
||||||
|
if (virtqueue->vring.desc == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vhost_vq_event_is_suppressed(virtqueue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vhost_vq_used_signal(vsession, virtqueue);
|
||||||
|
} else {
|
||||||
|
now = spdk_get_ticks();
|
||||||
|
check_session_vq_io_stats(vsession, virtqueue, now);
|
||||||
|
|
||||||
|
/* No need for event right now */
|
||||||
|
if (now < virtqueue->next_event_time) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vhost_vq_event_is_suppressed(virtqueue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vhost_vq_used_signal(vsession, virtqueue)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Syscall is quite long so update time */
|
||||||
|
now = spdk_get_ticks();
|
||||||
|
virtqueue->next_event_time = now + virtqueue->irq_delay_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vhost_session_used_signal(struct spdk_vhost_session *vsession)
|
vhost_session_used_signal(struct spdk_vhost_session *vsession)
|
||||||
{
|
{
|
||||||
struct spdk_vhost_virtqueue *virtqueue;
|
struct spdk_vhost_virtqueue *virtqueue;
|
||||||
uint64_t now;
|
|
||||||
uint16_t q_idx;
|
uint16_t q_idx;
|
||||||
|
|
||||||
if (vsession->coalescing_delay_time_base == 0) {
|
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
||||||
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
virtqueue = &vsession->virtqueue[q_idx];
|
||||||
virtqueue = &vsession->virtqueue[q_idx];
|
vhost_session_vq_used_signal(virtqueue);
|
||||||
|
|
||||||
if (virtqueue->vring.desc == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vhost_vq_event_is_suppressed(virtqueue)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vhost_vq_used_signal(vsession, virtqueue);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
now = spdk_get_ticks();
|
|
||||||
check_session_io_stats(vsession, now);
|
|
||||||
|
|
||||||
for (q_idx = 0; q_idx < vsession->max_queues; q_idx++) {
|
|
||||||
virtqueue = &vsession->virtqueue[q_idx];
|
|
||||||
|
|
||||||
/* No need for event right now */
|
|
||||||
if (now < virtqueue->next_event_time) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vhost_vq_event_is_suppressed(virtqueue)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!vhost_vq_used_signal(vsession, virtqueue)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Syscall is quite long so update time */
|
|
||||||
now = spdk_get_ticks();
|
|
||||||
virtqueue->next_event_time = now + virtqueue->irq_delay_time;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,6 +1213,7 @@ vhost_start_device_cb(int vid)
|
|||||||
for (i = 0; i < SPDK_VHOST_MAX_VQUEUES; i++) {
|
for (i = 0; i < SPDK_VHOST_MAX_VQUEUES; i++) {
|
||||||
struct spdk_vhost_virtqueue *q = &vsession->virtqueue[i];
|
struct spdk_vhost_virtqueue *q = &vsession->virtqueue[i];
|
||||||
|
|
||||||
|
q->vsession = vsession;
|
||||||
q->vring_idx = -1;
|
q->vring_idx = -1;
|
||||||
if (rte_vhost_get_vhost_vring(vid, i, &q->vring)) {
|
if (rte_vhost_get_vhost_vring(vid, i, &q->vring)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -122,6 +122,8 @@ struct spdk_vhost_virtqueue {
|
|||||||
|
|
||||||
/* Associated vhost_virtqueue in the virtio device's virtqueue list */
|
/* Associated vhost_virtqueue in the virtio device's virtqueue list */
|
||||||
uint32_t vring_idx;
|
uint32_t vring_idx;
|
||||||
|
|
||||||
|
struct spdk_vhost_session *vsession;
|
||||||
} __attribute((aligned(SPDK_CACHE_LINE_SIZE)));
|
} __attribute((aligned(SPDK_CACHE_LINE_SIZE)));
|
||||||
|
|
||||||
struct spdk_vhost_session {
|
struct spdk_vhost_session {
|
||||||
@ -300,6 +302,12 @@ int vhost_vq_used_signal(struct spdk_vhost_session *vsession, struct spdk_vhost_
|
|||||||
*/
|
*/
|
||||||
void vhost_session_used_signal(struct spdk_vhost_session *vsession);
|
void vhost_session_used_signal(struct spdk_vhost_session *vsession);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send IRQs for the queue that need to be signaled.
|
||||||
|
* \param vq virtqueue
|
||||||
|
*/
|
||||||
|
void vhost_session_vq_used_signal(struct spdk_vhost_virtqueue *virtqueue);
|
||||||
|
|
||||||
void vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
|
void vhost_vq_used_ring_enqueue(struct spdk_vhost_session *vsession,
|
||||||
struct spdk_vhost_virtqueue *vq,
|
struct spdk_vhost_virtqueue *vq,
|
||||||
uint16_t id, uint32_t len);
|
uint16_t id, uint32_t len);
|
||||||
|
Loading…
Reference in New Issue
Block a user