Lines Matching refs:queue
52 void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue, in xenvif_skb_zerocopy_prepare() argument
56 atomic_inc(&queue->inflight_packets); in xenvif_skb_zerocopy_prepare()
59 void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue) in xenvif_skb_zerocopy_complete() argument
61 atomic_dec(&queue->inflight_packets); in xenvif_skb_zerocopy_complete()
67 wake_up(&queue->dealloc_wq); in xenvif_skb_zerocopy_complete()
77 static bool xenvif_handle_tx_interrupt(struct xenvif_queue *queue) in xenvif_handle_tx_interrupt() argument
81 rc = RING_HAS_UNCONSUMED_REQUESTS(&queue->tx); in xenvif_handle_tx_interrupt()
83 napi_schedule(&queue->napi); in xenvif_handle_tx_interrupt()
89 struct xenvif_queue *queue = dev_id; in xenvif_tx_interrupt() local
92 old = atomic_fetch_or(NETBK_TX_EOI, &queue->eoi_pending); in xenvif_tx_interrupt()
95 if (!xenvif_handle_tx_interrupt(queue)) { in xenvif_tx_interrupt()
96 atomic_andnot(NETBK_TX_EOI, &queue->eoi_pending); in xenvif_tx_interrupt()
105 struct xenvif_queue *queue = in xenvif_poll() local
113 if (unlikely(queue->vif->disabled)) { in xenvif_poll()
118 work_done = xenvif_tx_action(queue, budget); in xenvif_poll()
125 if (likely(!queue->rate_limited)) in xenvif_poll()
126 xenvif_napi_schedule_or_enable_events(queue); in xenvif_poll()
132 static bool xenvif_handle_rx_interrupt(struct xenvif_queue *queue) in xenvif_handle_rx_interrupt() argument
136 rc = xenvif_have_rx_work(queue, false); in xenvif_handle_rx_interrupt()
138 xenvif_kick_thread(queue); in xenvif_handle_rx_interrupt()
144 struct xenvif_queue *queue = dev_id; in xenvif_rx_interrupt() local
147 old = atomic_fetch_or(NETBK_RX_EOI, &queue->eoi_pending); in xenvif_rx_interrupt()
150 if (!xenvif_handle_rx_interrupt(queue)) { in xenvif_rx_interrupt()
151 atomic_andnot(NETBK_RX_EOI, &queue->eoi_pending); in xenvif_rx_interrupt()
160 struct xenvif_queue *queue = dev_id; in xenvif_interrupt() local
164 old = atomic_fetch_or(NETBK_COMMON_EOI, &queue->eoi_pending); in xenvif_interrupt()
167 has_tx = xenvif_handle_tx_interrupt(queue); in xenvif_interrupt()
168 has_rx = xenvif_handle_rx_interrupt(queue); in xenvif_interrupt()
171 atomic_andnot(NETBK_COMMON_EOI, &queue->eoi_pending); in xenvif_interrupt()
208 struct xenvif_queue *queue = NULL; in xenvif_start_xmit() local
230 queue = &vif->queues[index]; in xenvif_start_xmit()
233 if (queue->task == NULL || in xenvif_start_xmit()
234 queue->dealloc_task == NULL || in xenvif_start_xmit()
255 if (!xenvif_rx_queue_tail(queue, skb)) in xenvif_start_xmit()
258 xenvif_kick_thread(queue); in xenvif_start_xmit()
271 struct xenvif_queue *queue = NULL; in xenvif_get_stats() local
284 queue = &vif->queues[index]; in xenvif_get_stats()
285 rx_bytes += queue->stats.rx_bytes; in xenvif_get_stats()
286 rx_packets += queue->stats.rx_packets; in xenvif_get_stats()
287 tx_bytes += queue->stats.tx_bytes; in xenvif_get_stats()
288 tx_packets += queue->stats.tx_packets; in xenvif_get_stats()
303 struct xenvif_queue *queue = NULL; in xenvif_up() local
308 queue = &vif->queues[queue_index]; in xenvif_up()
309 napi_enable(&queue->napi); in xenvif_up()
310 enable_irq(queue->tx_irq); in xenvif_up()
311 if (queue->tx_irq != queue->rx_irq) in xenvif_up()
312 enable_irq(queue->rx_irq); in xenvif_up()
313 xenvif_napi_schedule_or_enable_events(queue); in xenvif_up()
319 struct xenvif_queue *queue = NULL; in xenvif_down() local
324 queue = &vif->queues[queue_index]; in xenvif_down()
325 disable_irq(queue->tx_irq); in xenvif_down()
326 if (queue->tx_irq != queue->rx_irq) in xenvif_down()
327 disable_irq(queue->rx_irq); in xenvif_down()
328 napi_disable(&queue->napi); in xenvif_down()
329 del_timer_sync(&queue->credit_timeout); in xenvif_down()
558 int xenvif_init_queue(struct xenvif_queue *queue) in xenvif_init_queue() argument
562 queue->credit_bytes = queue->remaining_credit = ~0UL; in xenvif_init_queue()
563 queue->credit_usec = 0UL; in xenvif_init_queue()
564 timer_setup(&queue->credit_timeout, xenvif_tx_credit_callback, 0); in xenvif_init_queue()
565 queue->credit_window_start = get_jiffies_64(); in xenvif_init_queue()
567 queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES; in xenvif_init_queue()
569 skb_queue_head_init(&queue->rx_queue); in xenvif_init_queue()
570 skb_queue_head_init(&queue->tx_queue); in xenvif_init_queue()
572 queue->pending_cons = 0; in xenvif_init_queue()
573 queue->pending_prod = MAX_PENDING_REQS; in xenvif_init_queue()
575 queue->pending_ring[i] = i; in xenvif_init_queue()
577 spin_lock_init(&queue->callback_lock); in xenvif_init_queue()
578 spin_lock_init(&queue->response_lock); in xenvif_init_queue()
585 queue->mmap_pages); in xenvif_init_queue()
587 netdev_err(queue->vif->dev, "Could not reserve mmap_pages\n"); in xenvif_init_queue()
592 queue->pending_tx_info[i].callback_struct = (struct ubuf_info_msgzc) in xenvif_init_queue()
596 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; in xenvif_init_queue()
668 static void xenvif_disconnect_queue(struct xenvif_queue *queue) in xenvif_disconnect_queue() argument
670 if (queue->task) { in xenvif_disconnect_queue()
671 kthread_stop(queue->task); in xenvif_disconnect_queue()
672 put_task_struct(queue->task); in xenvif_disconnect_queue()
673 queue->task = NULL; in xenvif_disconnect_queue()
676 if (queue->dealloc_task) { in xenvif_disconnect_queue()
677 kthread_stop(queue->dealloc_task); in xenvif_disconnect_queue()
678 queue->dealloc_task = NULL; in xenvif_disconnect_queue()
681 if (queue->napi.poll) { in xenvif_disconnect_queue()
682 netif_napi_del(&queue->napi); in xenvif_disconnect_queue()
683 queue->napi.poll = NULL; in xenvif_disconnect_queue()
686 if (queue->tx_irq) { in xenvif_disconnect_queue()
687 unbind_from_irqhandler(queue->tx_irq, queue); in xenvif_disconnect_queue()
688 if (queue->tx_irq == queue->rx_irq) in xenvif_disconnect_queue()
689 queue->rx_irq = 0; in xenvif_disconnect_queue()
690 queue->tx_irq = 0; in xenvif_disconnect_queue()
693 if (queue->rx_irq) { in xenvif_disconnect_queue()
694 unbind_from_irqhandler(queue->rx_irq, queue); in xenvif_disconnect_queue()
695 queue->rx_irq = 0; in xenvif_disconnect_queue()
698 xenvif_unmap_frontend_data_rings(queue); in xenvif_disconnect_queue()
701 int xenvif_connect_data(struct xenvif_queue *queue, in xenvif_connect_data() argument
707 struct xenbus_device *dev = xenvif_to_xenbus_device(queue->vif); in xenvif_connect_data()
711 BUG_ON(queue->tx_irq); in xenvif_connect_data()
712 BUG_ON(queue->task); in xenvif_connect_data()
713 BUG_ON(queue->dealloc_task); in xenvif_connect_data()
715 err = xenvif_map_frontend_data_rings(queue, tx_ring_ref, in xenvif_connect_data()
720 init_waitqueue_head(&queue->wq); in xenvif_connect_data()
721 init_waitqueue_head(&queue->dealloc_wq); in xenvif_connect_data()
722 atomic_set(&queue->inflight_packets, 0); in xenvif_connect_data()
724 netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll); in xenvif_connect_data()
726 queue->stalled = true; in xenvif_connect_data()
728 task = kthread_run(xenvif_kthread_guest_rx, queue, in xenvif_connect_data()
729 "%s-guest-rx", queue->name); in xenvif_connect_data()
732 queue->task = task; in xenvif_connect_data()
739 task = kthread_run(xenvif_dealloc_kthread, queue, in xenvif_connect_data()
740 "%s-dealloc", queue->name); in xenvif_connect_data()
743 queue->dealloc_task = task; in xenvif_connect_data()
749 queue->name, queue); in xenvif_connect_data()
752 queue->tx_irq = queue->rx_irq = err; in xenvif_connect_data()
753 disable_irq(queue->tx_irq); in xenvif_connect_data()
756 snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), in xenvif_connect_data()
757 "%s-tx", queue->name); in xenvif_connect_data()
760 queue->tx_irq_name, queue); in xenvif_connect_data()
763 queue->tx_irq = err; in xenvif_connect_data()
764 disable_irq(queue->tx_irq); in xenvif_connect_data()
766 snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), in xenvif_connect_data()
767 "%s-rx", queue->name); in xenvif_connect_data()
770 queue->rx_irq_name, queue); in xenvif_connect_data()
773 queue->rx_irq = err; in xenvif_connect_data()
774 disable_irq(queue->rx_irq); in xenvif_connect_data()
780 pr_warn("Could not allocate kthread for %s\n", queue->name); in xenvif_connect_data()
783 xenvif_disconnect_queue(queue); in xenvif_connect_data()
802 struct xenvif_queue *queue = NULL; in xenvif_disconnect_data() local
809 queue = &vif->queues[queue_index]; in xenvif_disconnect_data()
811 xenvif_disconnect_queue(queue); in xenvif_disconnect_data()
836 void xenvif_deinit_queue(struct xenvif_queue *queue) in xenvif_deinit_queue() argument
838 gnttab_free_pages(MAX_PENDING_REQS, queue->mmap_pages); in xenvif_deinit_queue()