Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vhost: Add event index for interrupt notification to driver
[vpp.git]
/
src
/
vnet
/
devices
/
virtio
/
vhost_user_output.c
diff --git
a/src/vnet/devices/virtio/vhost_user_output.c
b/src/vnet/devices/virtio/vhost_user_output.c
index
2d17ddf
..
465c0ea
100644
(file)
--- a/
src/vnet/devices/virtio/vhost_user_output.c
+++ b/
src/vnet/devices/virtio/vhost_user_output.c
@@
-34,8
+34,6
@@
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
-#include <vnet/ip/ip.h>
-
#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
@@
-120,24
+118,13
@@
vhost_user_name_renumber (vnet_hw_interface_t * hi, u32 new_dev_instance)
return 0;
}
return 0;
}
-/**
- * @brief Try once to lock the vring
- * @return 0 on success, non-zero on failure.
- */
-static_always_inline int
-vhost_user_vring_try_lock (vhost_user_intf_t * vui, u32 qid)
-{
- return clib_atomic_test_and_set (vui->vring_locks[qid]);
-}
-
/**
* @brief Spin until the vring is successfully locked
*/
static_always_inline void
vhost_user_vring_lock (vhost_user_intf_t * vui, u32 qid)
{
/**
* @brief Spin until the vring is successfully locked
*/
static_always_inline void
vhost_user_vring_lock (vhost_user_intf_t * vui, u32 qid)
{
- while (vhost_user_vring_try_lock (vui, qid))
- ;
+ clib_spinlock_lock_if_init (&vui->vrings[qid].vring_lock);
}
/**
}
/**
@@
-146,7
+133,7
@@
vhost_user_vring_lock (vhost_user_intf_t * vui, u32 qid)
static_always_inline void
vhost_user_vring_unlock (vhost_user_intf_t * vui, u32 qid)
{
static_always_inline void
vhost_user_vring_unlock (vhost_user_intf_t * vui, u32 qid)
{
- clib_
atomic_release (vui->vring_locks[qid]
);
+ clib_
spinlock_unlock_if_init (&vui->vrings[qid].vring_lock
);
}
static_always_inline void
}
static_always_inline void
@@
-256,18
+243,12
@@
vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (udp_header_t, checksum);
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (udp_header_t, checksum);
- udp_header_t *udp =
- (udp_header_t *) (vlib_buffer_get_current (b) + gho.l4_hdr_offset);
- udp->checksum = 0;
}
else if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (tcp_header_t, checksum);
}
else if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (tcp_header_t, checksum);
- tcp_header_t *tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b) + gho.l4_hdr_offset);
- tcp->checksum = 0;
}
/* GSO offload */
}
/* GSO offload */
@@
-298,7
+279,8
@@
vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
}
static_always_inline void
}
static_always_inline void
-vhost_user_mark_desc_available (vlib_main_t * vm, vhost_user_vring_t * rxvq,
+vhost_user_mark_desc_available (vlib_main_t * vm, vhost_user_intf_t * vui,
+ vhost_user_vring_t * rxvq,
u16 * n_descs_processed, u8 chained,
vlib_frame_t * frame, u32 n_left)
{
u16 * n_descs_processed, u8 chained,
vlib_frame_t * frame, u32 n_left)
{
@@
-353,7
+335,7
@@
vhost_user_mark_desc_available (vlib_main_t * vm, vhost_user_vring_t * rxvq,
rxvq->n_since_last_int += frame->n_vectors - n_left;
if (rxvq->n_since_last_int > vum->coalesce_frames)
rxvq->n_since_last_int += frame->n_vectors - n_left;
if (rxvq->n_since_last_int > vum->coalesce_frames)
- vhost_user_send_call (vm, rxvq);
+ vhost_user_send_call (vm,
vui,
rxvq);
}
}
}
}
@@
-664,7
+646,7
@@
retry:
copy_len = 0;
/* give buffers back to driver */
copy_len = 0;
/* give buffers back to driver */
- vhost_user_mark_desc_available (vm, rxvq, &n_descs_processed,
+ vhost_user_mark_desc_available (vm,
vui,
rxvq, &n_descs_processed,
chained, frame, n_left);
}
chained, frame, n_left);
}
@@
-679,8
+661,8
@@
done:
vlib_error_count (vm, node->node_index,
VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL, 1);
vlib_error_count (vm, node->node_index,
VHOST_USER_TX_FUNC_ERROR_MMAP_FAIL, 1);
- vhost_user_mark_desc_available (vm,
rxvq, &n_descs_processed, chain
ed,
- frame, n_left);
+ vhost_user_mark_desc_available (vm,
vui, rxvq, &n_descs_process
ed,
+
chained,
frame, n_left);
}
/*
}
/*
@@
-1038,7
+1020,7
@@
done:
rxvq->n_since_last_int += frame->n_vectors - n_left;
if (rxvq->n_since_last_int > vum->coalesce_frames)
rxvq->n_since_last_int += frame->n_vectors - n_left;
if (rxvq->n_since_last_int > vum->coalesce_frames)
- vhost_user_send_call (vm, rxvq);
+ vhost_user_send_call (vm,
vui,
rxvq);
}
vhost_user_vring_unlock (vui, qid);
}
vhost_user_vring_unlock (vui, qid);
@@
-1059,7
+1041,7
@@
done3:
static __clib_unused clib_error_t *
vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index,
static __clib_unused clib_error_t *
vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index,
- u32 qid, vnet_hw_i
nterface
_rx_mode mode)
+ u32 qid, vnet_hw_i
f
_rx_mode mode)
{
vlib_main_t *vm = vnm->vlib_main;
vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index);
{
vlib_main_t *vm = vnm->vlib_main;
vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index);
@@
-1068,15
+1050,15
@@
vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index,
pool_elt_at_index (vum->vhost_user_interfaces, hif->dev_instance);
vhost_user_vring_t *txvq = &vui->vrings[VHOST_VRING_IDX_TX (qid)];
pool_elt_at_index (vum->vhost_user_interfaces, hif->dev_instance);
vhost_user_vring_t *txvq = &vui->vrings[VHOST_VRING_IDX_TX (qid)];
- if ((mode == VNET_HW_I
NTERFACE
_RX_MODE_INTERRUPT) ||
- (mode == VNET_HW_I
NTERFACE
_RX_MODE_ADAPTIVE))
+ if ((mode == VNET_HW_I
F
_RX_MODE_INTERRUPT) ||
+ (mode == VNET_HW_I
F
_RX_MODE_ADAPTIVE))
{
if (txvq->kickfd_idx == ~0)
{
// We cannot support interrupt mode if the driver opts out
return clib_error_return (0, "Driver does not support interrupt");
}
{
if (txvq->kickfd_idx == ~0)
{
// We cannot support interrupt mode if the driver opts out
return clib_error_return (0, "Driver does not support interrupt");
}
- if (txvq->mode == VNET_HW_I
NTERFACE
_RX_MODE_POLLING)
+ if (txvq->mode == VNET_HW_I
F
_RX_MODE_POLLING)
{
vum->ifq_count++;
// Start the timer if this is the first encounter on interrupt
{
vum->ifq_count++;
// Start the timer if this is the first encounter on interrupt
@@
-1088,11
+1070,10
@@
vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index,
VHOST_USER_EVENT_START_TIMER, 0);
}
}
VHOST_USER_EVENT_START_TIMER, 0);
}
}
- else if (mode == VNET_HW_I
NTERFACE
_RX_MODE_POLLING)
+ else if (mode == VNET_HW_I
F
_RX_MODE_POLLING)
{
{
- if (((txvq->mode == VNET_HW_INTERFACE_RX_MODE_INTERRUPT) ||
- (txvq->mode == VNET_HW_INTERFACE_RX_MODE_ADAPTIVE)) &&
- vum->ifq_count)
+ if (((txvq->mode == VNET_HW_IF_RX_MODE_INTERRUPT) ||
+ (txvq->mode == VNET_HW_IF_RX_MODE_ADAPTIVE)) && vum->ifq_count)
{
vum->ifq_count--;
// Stop the timer if there is no more interrupt interface/queue
{
vum->ifq_count--;
// Stop the timer if there is no more interrupt interface/queue
@@
-1105,10
+1086,10
@@
vhost_user_interface_rx_mode_change (vnet_main_t * vnm, u32 hw_if_index,
}
txvq->mode = mode;
}
txvq->mode = mode;
- if (mode == VNET_HW_I
NTERFACE
_RX_MODE_POLLING)
+ if (mode == VNET_HW_I
F
_RX_MODE_POLLING)
txvq->used->flags = VRING_USED_F_NO_NOTIFY;
txvq->used->flags = VRING_USED_F_NO_NOTIFY;
- else if ((mode == VNET_HW_I
NTERFACE
_RX_MODE_ADAPTIVE) ||
- (mode == VNET_HW_I
NTERFACE
_RX_MODE_INTERRUPT))
+ else if ((mode == VNET_HW_I
F
_RX_MODE_ADAPTIVE) ||
+ (mode == VNET_HW_I
F
_RX_MODE_INTERRUPT))
txvq->used->flags = 0;
else
{
txvq->used->flags = 0;
else
{