Advertisement
Guest User

diff for virtio

a guest
Sep 30th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. --- a/kernel/virtio/virtio_net.c
  2. +++ b/kernel/virtio/virtio_net.c
  3. @@ -199,6 +199,7 @@ void virtio_config_network(uint16_t base, unsigned irq)
  4. net_configured = 1;
  5. intr_register_irq(irq, handle_virtio_net_interrupt, NULL);
  6. recv_setup();
  7. + recvq.next_avail = 0;
  8.  
  9. /*
  10. * 8. Set the DRIVER_OK status bit. At this point the device is "live".
  11. @@ -209,12 +210,10 @@ void virtio_config_network(uint16_t base, unsigned irq)
  12.  
  13. int virtio_net_pkt_poll(void)
  14. {
  15. - uint16_t mask = recvq.num - 1;
  16. if (!net_configured)
  17. return 0;
  18.  
  19. - /* We need the masks otherwise this won't be true: (vq->num + 1) == 0 */
  20. - if ((recvq.next_avail & mask) == (recvq.last_used & mask))
  21. + if (recvq.next_avail == recvq.last_used)
  22. return 0;
  23. else
  24. return 1;
  25. @@ -229,7 +228,7 @@ uint8_t *virtio_net_recv_pkt_get(int *size)
  26.  
  27. /* last_used advances whenever we receive a packet, and if it's ahead of
  28. * next_avail it means that we have a pending packet. */
  29. - if ((recvq.next_avail & mask) == (recvq.last_used & mask))
  30. + if (recvq.next_avail == recvq.last_used)
  31. return NULL;
  32.  
  33. buf = &recvq.bufs[recvq.next_avail & mask];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement