* Reset some variables in device structure, while keeping few * others untouched, such as vid, ifname, nr_vring: they * should be same unless the device is removed. */
| 666 | * should be same unless the device is removed. |
| 667 | */ |
| 668 | void |
| 669 | reset_device(struct virtio_net *dev) |
| 670 | { |
| 671 | uint32_t i; |
| 672 | |
| 673 | dev->features = 0; |
| 674 | dev->protocol_features = 0; |
| 675 | dev->flags &= VIRTIO_DEV_BUILTIN_VIRTIO_NET; |
| 676 | |
| 677 | for (i = 0; i < dev->nr_vring; i++) { |
| 678 | struct vhost_virtqueue *vq = dev->virtqueue[i]; |
| 679 | |
| 680 | if (!vq) { |
| 681 | VHOST_LOG_CONFIG(dev->ifname, ERR, |
| 682 | "failed to reset vring, virtqueue not allocated (%d)\n", i); |
| 683 | continue; |
| 684 | } |
| 685 | reset_vring_queue(dev, vq); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /* |
| 690 | * Invoked when there is a new vhost-user connection established (when |
no test coverage detected