• Home
  • Raw
  • Download

Lines Matching refs:vi

79 static void give_a_page(struct virtnet_info *vi, struct page *page)  in give_a_page()  argument
81 page->private = (unsigned long)vi->pages; in give_a_page()
82 vi->pages = page; in give_a_page()
85 static void trim_pages(struct virtnet_info *vi, struct sk_buff *skb) in trim_pages() argument
90 give_a_page(vi, skb_shinfo(skb)->frags[i].page); in trim_pages()
95 static struct page *get_a_page(struct virtnet_info *vi, gfp_t gfp_mask) in get_a_page() argument
97 struct page *p = vi->pages; in get_a_page()
100 vi->pages = (struct page *)p->private; in get_a_page()
108 struct virtnet_info *vi = svq->vdev->priv; in skb_xmit_done() local
114 netif_wake_queue(vi->dev); in skb_xmit_done()
118 tasklet_schedule(&vi->tasklet); in skb_xmit_done()
124 struct virtnet_info *vi = netdev_priv(dev); in receive_skb() local
135 if (vi->mergeable_rx_bufs) { in receive_skb()
156 give_a_page(vi, skb_shinfo(skb)->frags[0].page); in receive_skb()
177 nskb = vi->rvq->vq_ops->get_buf(vi->rvq, &len); in receive_skb()
185 __skb_unlink(nskb, &vi->recv); in receive_skb()
186 vi->num--; in receive_skb()
204 trim_pages(vi, skb); in receive_skb()
273 static void try_fill_recv_maxbufs(struct virtnet_info *vi) in try_fill_recv_maxbufs() argument
283 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); in try_fill_recv_maxbufs()
292 if (vi->big_packets) { in try_fill_recv_maxbufs()
295 f->page = get_a_page(vi, GFP_ATOMIC); in try_fill_recv_maxbufs()
310 skb_queue_head(&vi->recv, skb); in try_fill_recv_maxbufs()
312 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, num, skb); in try_fill_recv_maxbufs()
314 skb_unlink(skb, &vi->recv); in try_fill_recv_maxbufs()
315 trim_pages(vi, skb); in try_fill_recv_maxbufs()
319 vi->num++; in try_fill_recv_maxbufs()
321 if (unlikely(vi->num > vi->max)) in try_fill_recv_maxbufs()
322 vi->max = vi->num; in try_fill_recv_maxbufs()
323 vi->rvq->vq_ops->kick(vi->rvq); in try_fill_recv_maxbufs()
326 static void try_fill_recv(struct virtnet_info *vi) in try_fill_recv() argument
332 if (!vi->mergeable_rx_bufs) { in try_fill_recv()
333 try_fill_recv_maxbufs(vi); in try_fill_recv()
340 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN); in try_fill_recv()
347 f->page = get_a_page(vi, GFP_ATOMIC); in try_fill_recv()
359 skb_queue_head(&vi->recv, skb); in try_fill_recv()
361 err = vi->rvq->vq_ops->add_buf(vi->rvq, sg, 0, 1, skb); in try_fill_recv()
363 skb_unlink(skb, &vi->recv); in try_fill_recv()
367 vi->num++; in try_fill_recv()
369 if (unlikely(vi->num > vi->max)) in try_fill_recv()
370 vi->max = vi->num; in try_fill_recv()
371 vi->rvq->vq_ops->kick(vi->rvq); in try_fill_recv()
376 struct virtnet_info *vi = rvq->vdev->priv; in skb_recv_done() local
378 if (netif_rx_schedule_prep(&vi->napi)) { in skb_recv_done()
380 __netif_rx_schedule(&vi->napi); in skb_recv_done()
386 struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); in virtnet_poll() local
392 (skb = vi->rvq->vq_ops->get_buf(vi->rvq, &len)) != NULL) { in virtnet_poll()
393 __skb_unlink(skb, &vi->recv); in virtnet_poll()
394 receive_skb(vi->dev, skb, len); in virtnet_poll()
395 vi->num--; in virtnet_poll()
401 if (vi->num < vi->max / 2) in virtnet_poll()
402 try_fill_recv(vi); in virtnet_poll()
407 if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq)) in virtnet_poll()
409 vi->rvq->vq_ops->disable_cb(vi->rvq); in virtnet_poll()
418 static void free_old_xmit_skbs(struct virtnet_info *vi) in free_old_xmit_skbs() argument
423 while ((skb = vi->svq->vq_ops->get_buf(vi->svq, &len)) != NULL) { in free_old_xmit_skbs()
425 __skb_unlink(skb, &vi->send); in free_old_xmit_skbs()
426 vi->dev->stats.tx_bytes += skb->len; in free_old_xmit_skbs()
427 vi->dev->stats.tx_packets++; in free_old_xmit_skbs()
436 struct virtnet_info *vi = (void *)data; in xmit_free() local
438 netif_tx_lock(vi->dev); in xmit_free()
440 free_old_xmit_skbs(vi); in xmit_free()
442 if (!skb_queue_empty(&vi->send)) in xmit_free()
443 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10)); in xmit_free()
445 netif_tx_unlock(vi->dev); in xmit_free()
448 static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) in xmit_skb() argument
458 pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest); in xmit_skb()
490 if (vi->mergeable_rx_bufs) in xmit_skb()
497 err = vi->svq->vq_ops->add_buf(vi->svq, sg, num, 0, skb); in xmit_skb()
498 if (!err && !vi->free_in_tasklet) in xmit_skb()
499 mod_timer(&vi->xmit_free_timer, jiffies + (HZ/10)); in xmit_skb()
506 struct virtnet_info *vi = (void *)data; in xmit_tasklet() local
508 netif_tx_lock_bh(vi->dev); in xmit_tasklet()
509 if (vi->last_xmit_skb && xmit_skb(vi, vi->last_xmit_skb) == 0) { in xmit_tasklet()
510 vi->svq->vq_ops->kick(vi->svq); in xmit_tasklet()
511 vi->last_xmit_skb = NULL; in xmit_tasklet()
513 if (vi->free_in_tasklet) in xmit_tasklet()
514 free_old_xmit_skbs(vi); in xmit_tasklet()
515 netif_tx_unlock_bh(vi->dev); in xmit_tasklet()
520 struct virtnet_info *vi = netdev_priv(dev); in start_xmit() local
524 free_old_xmit_skbs(vi); in start_xmit()
527 if (unlikely(vi->last_xmit_skb) && in start_xmit()
528 xmit_skb(vi, vi->last_xmit_skb) != 0) in start_xmit()
531 vi->last_xmit_skb = NULL; in start_xmit()
535 __skb_queue_head(&vi->send, skb); in start_xmit()
536 if (xmit_skb(vi, skb) != 0) { in start_xmit()
537 vi->last_xmit_skb = skb; in start_xmit()
543 vi->svq->vq_ops->kick(vi->svq); in start_xmit()
552 if (unlikely(!vi->svq->vq_ops->enable_cb(vi->svq))) { in start_xmit()
553 vi->svq->vq_ops->disable_cb(vi->svq); in start_xmit()
559 vi->dev->stats.tx_dropped++; in start_xmit()
568 struct virtnet_info *vi = netdev_priv(dev); in virtnet_netpoll() local
570 napi_schedule(&vi->napi); in virtnet_netpoll()
576 struct virtnet_info *vi = netdev_priv(dev); in virtnet_open() local
578 napi_enable(&vi->napi); in virtnet_open()
584 if (netif_rx_schedule_prep(&vi->napi)) { in virtnet_open()
585 vi->rvq->vq_ops->disable_cb(vi->rvq); in virtnet_open()
586 __netif_rx_schedule(&vi->napi); in virtnet_open()
593 struct virtnet_info *vi = netdev_priv(dev); in virtnet_close() local
595 napi_disable(&vi->napi); in virtnet_close()
602 struct virtnet_info *vi = netdev_priv(dev); in virtnet_set_tx_csum() local
603 struct virtio_device *vdev = vi->vdev; in virtnet_set_tx_csum()
645 struct virtnet_info *vi; in virtnet_probe() local
686 vi = netdev_priv(dev); in virtnet_probe()
687 netif_napi_add(dev, &vi->napi, virtnet_poll, napi_weight); in virtnet_probe()
688 vi->dev = dev; in virtnet_probe()
689 vi->vdev = vdev; in virtnet_probe()
690 vdev->priv = vi; in virtnet_probe()
691 vi->pages = NULL; in virtnet_probe()
695 vi->free_in_tasklet = virtio_has_feature(vdev,VIRTIO_F_NOTIFY_ON_EMPTY); in virtnet_probe()
701 vi->big_packets = true; in virtnet_probe()
704 vi->mergeable_rx_bufs = true; in virtnet_probe()
707 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done); in virtnet_probe()
708 if (IS_ERR(vi->rvq)) { in virtnet_probe()
709 err = PTR_ERR(vi->rvq); in virtnet_probe()
713 vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done); in virtnet_probe()
714 if (IS_ERR(vi->svq)) { in virtnet_probe()
715 err = PTR_ERR(vi->svq); in virtnet_probe()
720 skb_queue_head_init(&vi->recv); in virtnet_probe()
721 skb_queue_head_init(&vi->send); in virtnet_probe()
723 tasklet_init(&vi->tasklet, xmit_tasklet, (unsigned long)vi); in virtnet_probe()
725 if (!vi->free_in_tasklet) in virtnet_probe()
726 setup_timer(&vi->xmit_free_timer, xmit_free, (unsigned long)vi); in virtnet_probe()
735 try_fill_recv(vi); in virtnet_probe()
738 if (vi->num == 0) { in virtnet_probe()
751 vdev->config->del_vq(vi->svq); in virtnet_probe()
753 vdev->config->del_vq(vi->rvq); in virtnet_probe()
761 struct virtnet_info *vi = vdev->priv; in virtnet_remove() local
767 if (!vi->free_in_tasklet) in virtnet_remove()
768 del_timer_sync(&vi->xmit_free_timer); in virtnet_remove()
771 while ((skb = __skb_dequeue(&vi->recv)) != NULL) { in virtnet_remove()
773 vi->num--; in virtnet_remove()
775 __skb_queue_purge(&vi->send); in virtnet_remove()
777 BUG_ON(vi->num != 0); in virtnet_remove()
779 vdev->config->del_vq(vi->svq); in virtnet_remove()
780 vdev->config->del_vq(vi->rvq); in virtnet_remove()
781 unregister_netdev(vi->dev); in virtnet_remove()
783 while (vi->pages) in virtnet_remove()
784 __free_pages(get_a_page(vi, GFP_KERNEL), 0); in virtnet_remove()
786 free_netdev(vi->dev); in virtnet_remove()