static void virtio_net_check_queues(void) { struct packet *p; size_t len; /* Put the received packets into the recv list */ while (virtio_from_queue(net_dev, RX_Q, (void **)&p, &len) == 0) { p->len = len; STAILQ_INSERT_TAIL(&recv_list, p, next); in_rx--; virtio_net_stats.ets_packetR++; } /* * Packets from the TX queue just indicated they are free to * be reused now. inet already knows about them as being sent. */ while (virtio_from_queue(net_dev, TX_Q, (void **)&p, NULL) == 0) { memset(p->vhdr, 0, sizeof(*p->vhdr)); memset(p->vdata, 0, MAX_PACK_SIZE); STAILQ_INSERT_HEAD(&free_list, p, next); virtio_net_stats.ets_packetT++; } }
static void virtio_net_check_queues(void) { struct packet *p; size_t len; /* Put the received packets into the recv list */ while (virtio_from_queue(to_virtio_dev_t(&pci_vn), RX_Q, (void **)&p, &len) == 0) { pci_d("virtio_from_queue:%lx,len:%x\n", p, len); p->len = len; pci_d("vhdr:%lx,phdr:%lx,vdata:%lx,pdata:%lx,len:%d\n", p->vhdr, p->phdr, p->vdata, p->pdata, p->len); struct virtio_net_hdr { u8 flags; u8 gso_type; u16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ u16 gso_size; /* Bytes to append to hdr_len per frame */ u16 csum_start; /* Position to start checksumming from */ u16 csum_offset; /* Offset after that to place checksum */ }; pci_d ("flags:%x,gso_type:%x,hdr_len:%x,gso_size:%x,csum_start:%x,csum_offset:%x\n", p->vhdr->flags, p->vhdr->gso_type, p->vhdr->hdr_len, p->vhdr->gso_size, p->vhdr->csum_start, p->vhdr->csum_offset); ulong *pl = (ulong *) p->vdata; pci_d("%lx,%lx,%lx,%lx,%lx,%lx,%lx\n", pl[0], pl[1], pl[2], pl[3], pl[4], pl[5], pl[6]); u16 *pw = (u16 *) p->vdata; pci_d("%lx,%lx,%lx\n", pw[5], pw[6], pw[7]); uchar *pc = (uchar *) p->vdata+8; pci_d("To:%x:%x:%x:%x:%x:%x,From:%x:%x:%x:%x:%x:%x: len:%x,type:%x\n", pc[0], pc[1], pc[2], pc[3], pc[4], pc[5], pc[6], pc[7], pc[8], pc[9], pc[10], pc[11],pw[10],pw[11]); STAILQ_INSERT_TAIL(&recv_list, p, next); in_rx--; virtio_net_stats.ets_packetR++; } /* * Packets from the TX queue just indicated they are free to * be reused now. inet already knows about them as being sent. */ while (virtio_from_queue(to_virtio_dev_t(&pci_vn), TX_Q, (void **)&p, NULL) == 0) { pci_d("virtio_from_queue:%lx,len:%x\n", p, len); ulong *pl = (ulong *) p; pci_d("%lx,%lx,%lx,%lx,%lx,%lx,%lx\n", pl[0], pl[1], pl[2], pl[3], pl[4], pl[5], pl[6]); memset(p->vhdr, 0, sizeof(*p->vhdr)); memset(p->vdata, 0, MAX_PACK_SIZE); STAILQ_INSERT_HEAD(&free_list, p, next); virtio_net_stats.ets_packetT++; } }
static void virtio_blk_device_intr(void) { thread_id_t *tid; /* Multiple requests might have finished */ while (!virtio_from_queue(blk_dev, 0, (void**)&tid)) blockdriver_mt_wakeup(*tid); }