15 #ifndef __VIRTIO_VHOST_USER_INLINE_H__ 16 #define __VIRTIO_VHOST_USER_INLINE_H__ 24 ((vui->
regions[i].guest_phys_addr +
25 vui->
regions[i].memory_size) > addr)))
31 __m128i rl, rh, al, ah, r;
32 al = _mm_set1_epi64x (addr + 1);
33 ah = _mm_set1_epi64x (addr);
36 rl = _mm_cmpgt_epi64 (al, rl);
38 rh = _mm_cmpgt_epi64 (rh, ah);
39 r = _mm_and_si128 (rl, rh);
42 rl = _mm_cmpgt_epi64 (al, rl);
44 rh = _mm_cmpgt_epi64 (rh, ah);
45 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x22);
48 rl = _mm_cmpgt_epi64 (al, rl);
50 rh = _mm_cmpgt_epi64 (rh, ah);
51 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x44);
54 rl = _mm_cmpgt_epi64 (al, rl);
56 rh = _mm_cmpgt_epi64 (rh, ah);
57 r = _mm_blend_epi16 (r, _mm_and_si128 (rl, rh), 0x88);
59 r = _mm_shuffle_epi8 (r, _mm_set_epi64x (0, 0x0e060c040a020800));
69 #elif __aarch64__ && __ARM_NEON 70 uint64x2_t al, ah, rl, rh, r;
73 al = vdupq_n_u64 (addr + 1);
74 ah = vdupq_n_u64 (addr);
78 rl = vcgtq_u64 (al, rl);
80 rh = vcgtq_u64 (rh, ah);
81 r = vandq_u64 (rl, rh);
82 u32 |= (vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 0) & 0x1);
83 u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 8) & 0x1) << 1);
88 goto vhost_map_guest_mem_done;
93 rl = vcgtq_u64 (al, rl);
95 rh = vcgtq_u64 (rh, ah);
96 r = vandq_u64 (rl, rh);
97 u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 0) & 0x1) << 2);
98 u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 8) & 0x1) << 3);
103 goto vhost_map_guest_mem_done;
108 rl = vcgtq_u64 (al, rl);
110 rh = vcgtq_u64 (rh, ah);
111 r = vandq_u64 (rl, rh);
112 u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 0) & 0x1) << 6);
113 u32 |= ((vgetq_lane_u8 (vreinterpretq_u8_u64 (r), 8) & 0x1) << 7);
117 vhost_map_guest_mem_done:
118 if (i < vui->nregions)
127 if ((vui->
regions[i].guest_phys_addr <= addr) &&
137 vu_log_err (vui,
"failed to map guest mem addr %llx", addr);
148 if ((vui->
regions[i].userspace_addr <= addr) &&
159 #define VHOST_LOG_PAGE 0x1000 166 || !(vui->
features & (1 << FEAT_VHOST_F_LOG_ALL))))
176 vu_log_debug (vui,
"vhost_user_log_dirty_pages(): out of range\n");
190 #define vhost_user_log_dirty_ring(vui, vq, member) \ 191 if (PREDICT_FALSE(vq->log_used)) { \ 192 vhost_user_log_dirty_pages_2(vui, vq->log_guest_addr + STRUCT_OFFSET_OF(vring_used_t, member), \ 193 sizeof(vq->used->member), 0); \ 216 if (t->virtio_ring_flags & (1 << VIRTIO_TRACE_F_##n)) \ 217 s = format (s, "%U %s %s\n", format_white_space, indent, #n, st); 220 s =
format (s,
"%U virtio_net_hdr first_desc_len %u\n",
223 s =
format (s,
"%U flags 0x%02x gso_type %u\n",
225 t->
hdr.hdr.flags, t->
hdr.hdr.gso_type);
228 s =
format (s,
"%U num_buff %u",
242 rv = write (fd, &x,
sizeof (x));
246 (
"Error: Could not write to unix socket for callfd %d", fd);
virtio_net_hdr_mrg_rxbuf_t hdr
Length of the first data descriptor.
vnet_main_t * vnet_get_main(void)
u64 region_guest_addr_hi[VHOST_MEMORY_MAX_NREGIONS]
static f64 vlib_time_now(vlib_main_t *vm)
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define count_trailing_zeros(x)
#define vu_log_debug(dev, f,...)
#define static_always_inline
#define UNIX_GET_FD(unixfd_idx)
static_always_inline void * map_guest_mem(vhost_user_intf_t *vui, uword addr, u32 *hint)
static_always_inline u8 * format_vhost_trace(u8 *s, va_list *va)
format_function_t format_vnet_sw_interface_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vhost_user_main_t vhost_user_main
vhost_user_memory_region_t regions[VHOST_MEMORY_MAX_NREGIONS]
static_always_inline u8 vui_is_link_up(vhost_user_intf_t *vui)
u16 device_index
The interface queue index (Not the virtio vring idx)
vhost_user_intf_t * vhost_user_interfaces
u16 first_desc_len
Runtime queue flags.
#define vu_log_err(dev, f,...)
static_always_inline void vhost_user_send_call(vlib_main_t *vm, vhost_user_vring_t *vq)
static uword pointer_to_uword(const void *p)
void * region_mmap_addr[VHOST_MEMORY_MAX_NREGIONS]
#define clib_unix_warning(format, args...)
#define VHOST_MEMORY_MAX_NREGIONS
static_always_inline void vhost_user_log_dirty_pages_2(vhost_user_intf_t *vui, u64 addr, u64 len, u8 is_host_address)
u64 region_guest_addr_lo[VHOST_MEMORY_MAX_NREGIONS]
#define CLIB_MEMORY_BARRIER()
static_always_inline void * map_user_mem(vhost_user_intf_t *vui, uword addr)