MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vhost_user_get_vring_base

Function vhost_user_get_vring_base

dpdk/lib/vhost/vhost_user.c:2135–2208  ·  view source on GitHub ↗

* when virtio is stopped, qemu will send us the GET_VRING_BASE message. */

Source from the content-addressed store, hash-verified

2133 * when virtio is stopped, qemu will send us the GET_VRING_BASE message.
2134 */
2135static int
2136vhost_user_get_vring_base(struct virtio_net **pdev,
2137 struct vhu_msg_context *ctx,
2138 int main_fd __rte_unused)
2139{
2140 struct virtio_net *dev = *pdev;
2141 struct vhost_virtqueue *vq = dev->virtqueue[ctx->msg.payload.state.index];
2142 uint64_t val;
2143
2144 /* We have to stop the queue (virtio) if it is running. */
2145 vhost_destroy_device_notify(dev);
2146
2147 dev->flags &= ~VIRTIO_DEV_READY;
2148 dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
2149
2150 /* Here we are safe to get the indexes */
2151 if (vq_is_packed(dev)) {
2152 /*
2153 * Bit[0:14]: avail index
2154 * Bit[15]: avail wrap counter
2155 */
2156 val = vq->last_avail_idx & 0x7fff;
2157 val |= vq->avail_wrap_counter << 15;
2158 ctx->msg.payload.state.num = val;
2159 } else {
2160 ctx->msg.payload.state.num = vq->last_avail_idx;
2161 }
2162
2163 VHOST_LOG_CONFIG(dev->ifname, INFO,
2164 "vring base idx:%d file:%d\n",
2165 ctx->msg.payload.state.index, ctx->msg.payload.state.num);
2166 /*
2167 * Based on current qemu vhost-user implementation, this message is
2168 * sent and only sent in vhost_vring_stop.
2169 * TODO: cleanup the vring, it isn't usable since here.
2170 */
2171 if (vq->kickfd >= 0)
2172 close(vq->kickfd);
2173
2174 vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
2175
2176 if (vq->callfd >= 0)
2177 close(vq->callfd);
2178
2179 vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;
2180
2181 vq->signalled_used_valid = false;
2182
2183 if (vq_is_packed(dev)) {
2184 rte_free(vq->shadow_used_packed);
2185 vq->shadow_used_packed = NULL;
2186 } else {
2187 rte_free(vq->shadow_used_split);
2188 vq->shadow_used_split = NULL;
2189 }
2190
2191 rte_free(vq->batch_copy_elems);
2192 vq->batch_copy_elems = NULL;

Callers

nothing calls this directly

Calls 7

vq_is_packedFunction · 0.85
rte_freeFunction · 0.85
vring_invalidateFunction · 0.85
memsetFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected