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

Function vduse_device_start

dpdk/lib/vhost/vduse.c:282–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282static void
283vduse_device_start(struct virtio_net *dev)
284{
285 unsigned int i, ret;
286
287 VHOST_LOG_CONFIG(dev->ifname, INFO, "Starting device...\n");
288
289 dev->notify_ops = vhost_driver_callback_get(dev->ifname);
290 if (!dev->notify_ops) {
291 VHOST_LOG_CONFIG(dev->ifname, ERR,
292 "Failed to get callback ops for driver\n");
293 return;
294 }
295
296 ret = ioctl(dev->vduse_dev_fd, VDUSE_DEV_GET_FEATURES, &dev->features);
297 if (ret) {
298 VHOST_LOG_CONFIG(dev->ifname, ERR, "Failed to get features: %s\n",
299 strerror(errno));
300 return;
301 }
302
303 VHOST_LOG_CONFIG(dev->ifname, INFO, "Negotiated Virtio features: 0x%" PRIx64 "\n",
304 dev->features);
305
306 if (dev->features &
307 ((1ULL << VIRTIO_NET_F_MRG_RXBUF) |
308 (1ULL << VIRTIO_F_VERSION_1) |
309 (1ULL << VIRTIO_F_RING_PACKED))) {
310 dev->vhost_hlen = sizeof(struct virtio_net_hdr_mrg_rxbuf);
311 } else {
312 dev->vhost_hlen = sizeof(struct virtio_net_hdr);
313 }
314
315 for (i = 0; i < dev->nr_vring; i++)
316 vduse_vring_setup(dev, i);
317
318 dev->flags |= VIRTIO_DEV_READY;
319
320 if (!dev->notify_ops->new_device ||
321 dev->notify_ops->new_device(dev->vid) == 0)
322 dev->flags |= VIRTIO_DEV_RUNNING;
323
324 for (i = 0; i < dev->nr_vring; i++) {
325 struct vhost_virtqueue *vq = dev->virtqueue[i];
326
327 if (vq == dev->cvq)
328 continue;
329
330 if (dev->notify_ops->vring_state_changed)
331 dev->notify_ops->vring_state_changed(dev->vid, i, vq->enabled);
332 }
333}
334
335static void
336vduse_device_stop(struct virtio_net *dev)

Callers 1

vduse_events_handlerFunction · 0.85

Calls 3

vduse_vring_setupFunction · 0.85
ioctlFunction · 0.50

Tested by

no test coverage detected