Lines Matching refs:queue
42 static void xenvif_update_needed_slots(struct xenvif_queue *queue, in xenvif_update_needed_slots() argument
55 WRITE_ONCE(queue->rx_slots_needed, needed); in xenvif_update_needed_slots()
58 static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) in xenvif_rx_ring_slots_available() argument
63 needed = READ_ONCE(queue->rx_slots_needed); in xenvif_rx_ring_slots_available()
68 prod = queue->rx.sring->req_prod; in xenvif_rx_ring_slots_available()
69 cons = queue->rx.req_cons; in xenvif_rx_ring_slots_available()
74 queue->rx.sring->req_event = prod + 1; in xenvif_rx_ring_slots_available()
80 } while (queue->rx.sring->req_prod != prod); in xenvif_rx_ring_slots_available()
85 bool xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb) in xenvif_rx_queue_tail() argument
90 spin_lock_irqsave(&queue->rx_queue.lock, flags); in xenvif_rx_queue_tail()
92 if (queue->rx_queue_len >= queue->rx_queue_max) { in xenvif_rx_queue_tail()
93 struct net_device *dev = queue->vif->dev; in xenvif_rx_queue_tail()
95 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); in xenvif_rx_queue_tail()
98 if (skb_queue_empty(&queue->rx_queue)) in xenvif_rx_queue_tail()
99 xenvif_update_needed_slots(queue, skb); in xenvif_rx_queue_tail()
101 __skb_queue_tail(&queue->rx_queue, skb); in xenvif_rx_queue_tail()
103 queue->rx_queue_len += skb->len; in xenvif_rx_queue_tail()
106 spin_unlock_irqrestore(&queue->rx_queue.lock, flags); in xenvif_rx_queue_tail()
111 static struct sk_buff *xenvif_rx_dequeue(struct xenvif_queue *queue) in xenvif_rx_dequeue() argument
115 spin_lock_irq(&queue->rx_queue.lock); in xenvif_rx_dequeue()
117 skb = __skb_dequeue(&queue->rx_queue); in xenvif_rx_dequeue()
119 xenvif_update_needed_slots(queue, skb_peek(&queue->rx_queue)); in xenvif_rx_dequeue()
121 queue->rx_queue_len -= skb->len; in xenvif_rx_dequeue()
122 if (queue->rx_queue_len < queue->rx_queue_max) { in xenvif_rx_dequeue()
125 txq = netdev_get_tx_queue(queue->vif->dev, queue->id); in xenvif_rx_dequeue()
130 spin_unlock_irq(&queue->rx_queue.lock); in xenvif_rx_dequeue()
135 static void xenvif_rx_queue_purge(struct xenvif_queue *queue) in xenvif_rx_queue_purge() argument
139 while ((skb = xenvif_rx_dequeue(queue)) != NULL) in xenvif_rx_queue_purge()
143 static void xenvif_rx_queue_drop_expired(struct xenvif_queue *queue) in xenvif_rx_queue_drop_expired() argument
148 skb = skb_peek(&queue->rx_queue); in xenvif_rx_queue_drop_expired()
153 xenvif_rx_dequeue(queue); in xenvif_rx_queue_drop_expired()
155 queue->vif->dev->stats.rx_dropped++; in xenvif_rx_queue_drop_expired()
159 static void xenvif_rx_copy_flush(struct xenvif_queue *queue) in xenvif_rx_copy_flush() argument
164 gnttab_batch_copy(queue->rx_copy.op, queue->rx_copy.num); in xenvif_rx_copy_flush()
166 for (i = 0; i < queue->rx_copy.num; i++) { in xenvif_rx_copy_flush()
169 op = &queue->rx_copy.op[i]; in xenvif_rx_copy_flush()
177 rsp = RING_GET_RESPONSE(&queue->rx, in xenvif_rx_copy_flush()
178 queue->rx_copy.idx[i]); in xenvif_rx_copy_flush()
183 queue->rx_copy.num = 0; in xenvif_rx_copy_flush()
186 RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&queue->rx, notify); in xenvif_rx_copy_flush()
188 notify_remote_via_irq(queue->rx_irq); in xenvif_rx_copy_flush()
190 __skb_queue_purge(queue->rx_copy.completed); in xenvif_rx_copy_flush()
193 static void xenvif_rx_copy_add(struct xenvif_queue *queue, in xenvif_rx_copy_add() argument
201 if (queue->rx_copy.num == COPY_BATCH_SIZE) in xenvif_rx_copy_add()
202 xenvif_rx_copy_flush(queue); in xenvif_rx_copy_add()
204 op = &queue->rx_copy.op[queue->rx_copy.num]; in xenvif_rx_copy_add()
222 op->dest.domid = queue->vif->domid; in xenvif_rx_copy_add()
226 queue->rx_copy.idx[queue->rx_copy.num] = queue->rx.req_cons; in xenvif_rx_copy_add()
227 queue->rx_copy.num++; in xenvif_rx_copy_add()
252 static void xenvif_rx_next_skb(struct xenvif_queue *queue, in xenvif_rx_next_skb() argument
258 skb = xenvif_rx_dequeue(queue); in xenvif_rx_next_skb()
260 queue->stats.tx_bytes += skb->len; in xenvif_rx_next_skb()
261 queue->stats.tx_packets++; in xenvif_rx_next_skb()
272 if ((1 << gso_type) & queue->vif->gso_mask) { in xenvif_rx_next_skb()
287 if (queue->vif->xdp_headroom) { in xenvif_rx_next_skb()
293 extra->u.xdp.headroom = queue->vif->xdp_headroom; in xenvif_rx_next_skb()
328 static void xenvif_rx_complete(struct xenvif_queue *queue, in xenvif_rx_complete() argument
332 queue->rx.rsp_prod_pvt = queue->rx.req_cons; in xenvif_rx_complete()
334 __skb_queue_tail(queue->rx_copy.completed, pkt->skb); in xenvif_rx_complete()
355 static void xenvif_rx_next_chunk(struct xenvif_queue *queue, in xenvif_rx_next_chunk() argument
393 static void xenvif_rx_data_slot(struct xenvif_queue *queue, in xenvif_rx_data_slot() argument
398 unsigned int offset = queue->vif->xdp_headroom; in xenvif_rx_data_slot()
405 xenvif_rx_next_chunk(queue, pkt, offset, &data, &len); in xenvif_rx_data_slot()
406 xenvif_rx_copy_add(queue, req, offset, data, len); in xenvif_rx_data_slot()
437 static void xenvif_rx_extra_slot(struct xenvif_queue *queue, in xenvif_rx_extra_slot() argument
461 static void xenvif_rx_skb(struct xenvif_queue *queue) in xenvif_rx_skb() argument
465 xenvif_rx_next_skb(queue, &pkt); in xenvif_rx_skb()
467 queue->last_rx_time = jiffies; in xenvif_rx_skb()
473 req = RING_GET_REQUEST(&queue->rx, queue->rx.req_cons); in xenvif_rx_skb()
474 rsp = RING_GET_RESPONSE(&queue->rx, queue->rx.req_cons); in xenvif_rx_skb()
478 xenvif_rx_extra_slot(queue, &pkt, req, rsp); in xenvif_rx_skb()
480 xenvif_rx_data_slot(queue, &pkt, req, rsp); in xenvif_rx_skb()
482 queue->rx.req_cons++; in xenvif_rx_skb()
486 xenvif_rx_complete(queue, &pkt); in xenvif_rx_skb()
491 static void xenvif_rx_action(struct xenvif_queue *queue) in xenvif_rx_action() argument
497 queue->rx_copy.completed = &completed_skbs; in xenvif_rx_action()
499 while (xenvif_rx_ring_slots_available(queue) && in xenvif_rx_action()
500 !skb_queue_empty(&queue->rx_queue) && in xenvif_rx_action()
502 xenvif_rx_skb(queue); in xenvif_rx_action()
507 xenvif_rx_copy_flush(queue); in xenvif_rx_action()
510 static RING_IDX xenvif_rx_queue_slots(const struct xenvif_queue *queue) in xenvif_rx_queue_slots() argument
514 prod = queue->rx.sring->req_prod; in xenvif_rx_queue_slots()
515 cons = queue->rx.req_cons; in xenvif_rx_queue_slots()
520 static bool xenvif_rx_queue_stalled(const struct xenvif_queue *queue) in xenvif_rx_queue_stalled() argument
522 unsigned int needed = READ_ONCE(queue->rx_slots_needed); in xenvif_rx_queue_stalled()
524 return !queue->stalled && in xenvif_rx_queue_stalled()
525 xenvif_rx_queue_slots(queue) < needed && in xenvif_rx_queue_stalled()
527 queue->last_rx_time + queue->vif->stall_timeout); in xenvif_rx_queue_stalled()
530 static bool xenvif_rx_queue_ready(struct xenvif_queue *queue) in xenvif_rx_queue_ready() argument
532 unsigned int needed = READ_ONCE(queue->rx_slots_needed); in xenvif_rx_queue_ready()
534 return queue->stalled && xenvif_rx_queue_slots(queue) >= needed; in xenvif_rx_queue_ready()
537 bool xenvif_have_rx_work(struct xenvif_queue *queue, bool test_kthread) in xenvif_have_rx_work() argument
539 return xenvif_rx_ring_slots_available(queue) || in xenvif_have_rx_work()
540 (queue->vif->stall_timeout && in xenvif_have_rx_work()
541 (xenvif_rx_queue_stalled(queue) || in xenvif_have_rx_work()
542 xenvif_rx_queue_ready(queue))) || in xenvif_have_rx_work()
544 queue->vif->disabled; in xenvif_have_rx_work()
547 static long xenvif_rx_queue_timeout(struct xenvif_queue *queue) in xenvif_rx_queue_timeout() argument
552 skb = skb_peek(&queue->rx_queue); in xenvif_rx_queue_timeout()
570 static void xenvif_wait_for_rx_work(struct xenvif_queue *queue) in xenvif_wait_for_rx_work() argument
574 if (xenvif_have_rx_work(queue, true)) in xenvif_wait_for_rx_work()
580 prepare_to_wait(&queue->wq, &wait, TASK_INTERRUPTIBLE); in xenvif_wait_for_rx_work()
581 if (xenvif_have_rx_work(queue, true)) in xenvif_wait_for_rx_work()
584 &queue->eoi_pending) & in xenvif_wait_for_rx_work()
586 xen_irq_lateeoi(queue->rx_irq, 0); in xenvif_wait_for_rx_work()
588 ret = schedule_timeout(xenvif_rx_queue_timeout(queue)); in xenvif_wait_for_rx_work()
592 finish_wait(&queue->wq, &wait); in xenvif_wait_for_rx_work()
595 static void xenvif_queue_carrier_off(struct xenvif_queue *queue) in xenvif_queue_carrier_off() argument
597 struct xenvif *vif = queue->vif; in xenvif_queue_carrier_off()
599 queue->stalled = true; in xenvif_queue_carrier_off()
610 static void xenvif_queue_carrier_on(struct xenvif_queue *queue) in xenvif_queue_carrier_on() argument
612 struct xenvif *vif = queue->vif; in xenvif_queue_carrier_on()
614 queue->last_rx_time = jiffies; /* Reset Rx stall detection. */ in xenvif_queue_carrier_on()
615 queue->stalled = false; in xenvif_queue_carrier_on()
628 struct xenvif_queue *queue = data; in xenvif_kthread_guest_rx() local
629 struct xenvif *vif = queue->vif; in xenvif_kthread_guest_rx()
632 xenvif_queue_carrier_on(queue); in xenvif_kthread_guest_rx()
635 xenvif_wait_for_rx_work(queue); in xenvif_kthread_guest_rx()
647 if (unlikely(vif->disabled && queue->id == 0)) { in xenvif_kthread_guest_rx()
652 if (!skb_queue_empty(&queue->rx_queue)) in xenvif_kthread_guest_rx()
653 xenvif_rx_action(queue); in xenvif_kthread_guest_rx()
660 if (xenvif_rx_queue_stalled(queue)) in xenvif_kthread_guest_rx()
661 xenvif_queue_carrier_off(queue); in xenvif_kthread_guest_rx()
662 else if (xenvif_rx_queue_ready(queue)) in xenvif_kthread_guest_rx()
663 xenvif_queue_carrier_on(queue); in xenvif_kthread_guest_rx()
671 xenvif_rx_queue_drop_expired(queue); in xenvif_kthread_guest_rx()
677 xenvif_rx_queue_purge(queue); in xenvif_kthread_guest_rx()