Lines Matching full:queue

44 /* Number of bytes allowed on the internal guest Rx 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()
122 /* If the queue is rate-limited, it shall be 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
223 /* Obtain the queue to be used to transmit this packet */ in xenvif_start_xmit()
226 pr_warn_ratelimited("Invalid queue %hu for packet on interface %s\n", in xenvif_start_xmit()
230 queue = &vif->queues[index]; in xenvif_start_xmit()
232 /* Drop the packet if queue is not ready */ in xenvif_start_xmit()
233 if (queue->task == NULL || in xenvif_start_xmit()
234 queue->dealloc_task == NULL || in xenvif_start_xmit()
258 if (!xenvif_rx_queue_tail(queue, skb)) in xenvif_start_xmit()
261 xenvif_kick_thread(queue); in xenvif_start_xmit()
274 struct xenvif_queue *queue = NULL; in xenvif_get_stats() local
285 /* Aggregate tx and rx stats from each queue */ in xenvif_get_stats()
287 queue = &vif->queues[index]; in xenvif_get_stats()
288 rx_bytes += queue->stats.rx_bytes; in xenvif_get_stats()
289 rx_packets += queue->stats.rx_packets; in xenvif_get_stats()
290 tx_bytes += queue->stats.tx_bytes; in xenvif_get_stats()
291 tx_packets += queue->stats.tx_packets; in xenvif_get_stats()
306 struct xenvif_queue *queue = NULL; in xenvif_up() local
311 queue = &vif->queues[queue_index]; in xenvif_up()
312 napi_enable(&queue->napi); in xenvif_up()
313 enable_irq(queue->tx_irq); in xenvif_up()
314 if (queue->tx_irq != queue->rx_irq) in xenvif_up()
315 enable_irq(queue->rx_irq); in xenvif_up()
316 xenvif_napi_schedule_or_enable_events(queue); in xenvif_up()
322 struct xenvif_queue *queue = NULL; in xenvif_down() local
327 queue = &vif->queues[queue_index]; in xenvif_down()
328 disable_irq(queue->tx_irq); in xenvif_down()
329 if (queue->tx_irq != queue->rx_irq) in xenvif_down()
330 disable_irq(queue->rx_irq); in xenvif_down()
331 napi_disable(&queue->napi); in xenvif_down()
332 del_timer_sync(&queue->credit_timeout); in xenvif_down()
561 int xenvif_init_queue(struct xenvif_queue *queue) in xenvif_init_queue() argument
565 queue->credit_bytes = queue->remaining_credit = ~0UL; in xenvif_init_queue()
566 queue->credit_usec = 0UL; in xenvif_init_queue()
567 timer_setup(&queue->credit_timeout, xenvif_tx_credit_callback, 0); in xenvif_init_queue()
568 queue->credit_window_start = get_jiffies_64(); in xenvif_init_queue()
570 queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES; in xenvif_init_queue()
572 skb_queue_head_init(&queue->rx_queue); in xenvif_init_queue()
573 skb_queue_head_init(&queue->tx_queue); in xenvif_init_queue()
575 queue->pending_cons = 0; in xenvif_init_queue()
576 queue->pending_prod = MAX_PENDING_REQS; in xenvif_init_queue()
578 queue->pending_ring[i] = i; in xenvif_init_queue()
580 spin_lock_init(&queue->callback_lock); in xenvif_init_queue()
581 spin_lock_init(&queue->response_lock); in xenvif_init_queue()
588 queue->mmap_pages); in xenvif_init_queue()
590 netdev_err(queue->vif->dev, "Could not reserve mmap_pages\n"); in xenvif_init_queue()
595 queue->pending_tx_info[i].callback_struct = (struct ubuf_info_msgzc) in xenvif_init_queue()
599 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; in xenvif_init_queue()
671 static void xenvif_disconnect_queue(struct xenvif_queue *queue) in xenvif_disconnect_queue() argument
673 if (queue->task) { in xenvif_disconnect_queue()
674 kthread_stop_put(queue->task); in xenvif_disconnect_queue()
675 queue->task = NULL; in xenvif_disconnect_queue()
678 if (queue->dealloc_task) { in xenvif_disconnect_queue()
679 kthread_stop(queue->dealloc_task); in xenvif_disconnect_queue()
680 queue->dealloc_task = NULL; in xenvif_disconnect_queue()
683 if (queue->napi.poll) { in xenvif_disconnect_queue()
684 netif_napi_del(&queue->napi); in xenvif_disconnect_queue()
685 queue->napi.poll = NULL; in xenvif_disconnect_queue()
688 if (queue->tx_irq) { in xenvif_disconnect_queue()
689 unbind_from_irqhandler(queue->tx_irq, queue); in xenvif_disconnect_queue()
690 if (queue->tx_irq == queue->rx_irq) in xenvif_disconnect_queue()
691 queue->rx_irq = 0; in xenvif_disconnect_queue()
692 queue->tx_irq = 0; in xenvif_disconnect_queue()
695 if (queue->rx_irq) { in xenvif_disconnect_queue()
696 unbind_from_irqhandler(queue->rx_irq, queue); in xenvif_disconnect_queue()
697 queue->rx_irq = 0; in xenvif_disconnect_queue()
700 xenvif_unmap_frontend_data_rings(queue); in xenvif_disconnect_queue()
703 int xenvif_connect_data(struct xenvif_queue *queue, in xenvif_connect_data() argument
709 struct xenbus_device *dev = xenvif_to_xenbus_device(queue->vif); in xenvif_connect_data()
713 BUG_ON(queue->tx_irq); in xenvif_connect_data()
714 BUG_ON(queue->task); in xenvif_connect_data()
715 BUG_ON(queue->dealloc_task); in xenvif_connect_data()
717 err = xenvif_map_frontend_data_rings(queue, tx_ring_ref, in xenvif_connect_data()
722 init_waitqueue_head(&queue->wq); in xenvif_connect_data()
723 init_waitqueue_head(&queue->dealloc_wq); in xenvif_connect_data()
724 atomic_set(&queue->inflight_packets, 0); in xenvif_connect_data()
726 netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll); in xenvif_connect_data()
728 queue->stalled = true; in xenvif_connect_data()
730 task = kthread_run(xenvif_kthread_guest_rx, queue, in xenvif_connect_data()
731 "%s-guest-rx", queue->name); in xenvif_connect_data()
734 queue->task = task; in xenvif_connect_data()
741 task = kthread_run(xenvif_dealloc_kthread, queue, in xenvif_connect_data()
742 "%s-dealloc", queue->name); in xenvif_connect_data()
745 queue->dealloc_task = task; in xenvif_connect_data()
751 queue->name, queue); in xenvif_connect_data()
754 queue->tx_irq = queue->rx_irq = err; in xenvif_connect_data()
755 disable_irq(queue->tx_irq); in xenvif_connect_data()
758 snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), in xenvif_connect_data()
759 "%s-tx", queue->name); in xenvif_connect_data()
762 queue->tx_irq_name, queue); in xenvif_connect_data()
765 queue->tx_irq = err; in xenvif_connect_data()
766 disable_irq(queue->tx_irq); in xenvif_connect_data()
768 snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), in xenvif_connect_data()
769 "%s-rx", queue->name); in xenvif_connect_data()
772 queue->rx_irq_name, queue); in xenvif_connect_data()
775 queue->rx_irq = err; in xenvif_connect_data()
776 disable_irq(queue->rx_irq); in xenvif_connect_data()
782 pr_warn("Could not allocate kthread for %s\n", queue->name); in xenvif_connect_data()
785 xenvif_disconnect_queue(queue); in xenvif_connect_data()
804 struct xenvif_queue *queue = NULL; in xenvif_disconnect_data() local
811 queue = &vif->queues[queue_index]; in xenvif_disconnect_data()
813 xenvif_disconnect_queue(queue); in xenvif_disconnect_data()
835 * Used for queue teardown from xenvif_free(), and on the
838 void xenvif_deinit_queue(struct xenvif_queue *queue) in xenvif_deinit_queue() argument
840 gnttab_free_pages(MAX_PENDING_REQS, queue->mmap_pages); in xenvif_deinit_queue()