Lines Matching refs:queue
218 static struct sk_buff *xennet_get_rx_skb(struct netfront_queue *queue, in xennet_get_rx_skb() argument
222 struct sk_buff *skb = queue->rx_skbs[i]; in xennet_get_rx_skb()
223 queue->rx_skbs[i] = NULL; in xennet_get_rx_skb()
227 static grant_ref_t xennet_get_rx_ref(struct netfront_queue *queue, in xennet_get_rx_ref() argument
231 grant_ref_t ref = queue->grant_rx_ref[i]; in xennet_get_rx_ref()
232 queue->grant_rx_ref[i] = INVALID_GRANT_REF; in xennet_get_rx_ref()
248 struct netfront_queue *queue = from_timer(queue, t, rx_refill_timer); in rx_refill_timeout() local
249 napi_schedule(&queue->napi); in rx_refill_timeout()
252 static int netfront_tx_slot_available(struct netfront_queue *queue) in netfront_tx_slot_available() argument
254 return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) < in netfront_tx_slot_available()
258 static void xennet_maybe_wake_tx(struct netfront_queue *queue) in xennet_maybe_wake_tx() argument
260 struct net_device *dev = queue->info->netdev; in xennet_maybe_wake_tx()
261 struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, queue->id); in xennet_maybe_wake_tx()
264 netfront_tx_slot_available(queue) && in xennet_maybe_wake_tx()
266 netif_tx_wake_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_maybe_wake_tx()
270 static struct sk_buff *xennet_alloc_one_rx_buffer(struct netfront_queue *queue) in xennet_alloc_one_rx_buffer() argument
275 skb = __netdev_alloc_skb(queue->info->netdev, in xennet_alloc_one_rx_buffer()
281 page = page_pool_alloc_pages(queue->page_pool, in xennet_alloc_one_rx_buffer()
291 skb->dev = queue->info->netdev; in xennet_alloc_one_rx_buffer()
297 static void xennet_alloc_rx_buffers(struct netfront_queue *queue) in xennet_alloc_rx_buffers() argument
299 RING_IDX req_prod = queue->rx.req_prod_pvt; in xennet_alloc_rx_buffers()
303 if (unlikely(!netif_carrier_ok(queue->info->netdev))) in xennet_alloc_rx_buffers()
306 for (req_prod = queue->rx.req_prod_pvt; in xennet_alloc_rx_buffers()
307 req_prod - queue->rx.rsp_cons < NET_RX_RING_SIZE; in xennet_alloc_rx_buffers()
315 skb = xennet_alloc_one_rx_buffer(queue); in xennet_alloc_rx_buffers()
323 BUG_ON(queue->rx_skbs[id]); in xennet_alloc_rx_buffers()
324 queue->rx_skbs[id] = skb; in xennet_alloc_rx_buffers()
326 ref = gnttab_claim_grant_reference(&queue->gref_rx_head); in xennet_alloc_rx_buffers()
328 queue->grant_rx_ref[id] = ref; in xennet_alloc_rx_buffers()
332 req = RING_GET_REQUEST(&queue->rx, req_prod); in xennet_alloc_rx_buffers()
334 queue->info->xbdev->otherend_id, in xennet_alloc_rx_buffers()
341 queue->rx.req_prod_pvt = req_prod; in xennet_alloc_rx_buffers()
348 if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN || in xennet_alloc_rx_buffers()
350 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); in xennet_alloc_rx_buffers()
354 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->rx, notify); in xennet_alloc_rx_buffers()
356 notify_remote_via_irq(queue->rx_irq); in xennet_alloc_rx_buffers()
364 struct netfront_queue *queue = NULL; in xennet_open() local
370 queue = &np->queues[i]; in xennet_open()
371 napi_enable(&queue->napi); in xennet_open()
373 spin_lock_bh(&queue->rx_lock); in xennet_open()
375 xennet_alloc_rx_buffers(queue); in xennet_open()
376 queue->rx.sring->rsp_event = queue->rx.rsp_cons + 1; in xennet_open()
377 if (RING_HAS_UNCONSUMED_RESPONSES(&queue->rx)) in xennet_open()
378 napi_schedule(&queue->napi); in xennet_open()
380 spin_unlock_bh(&queue->rx_lock); in xennet_open()
388 static bool xennet_tx_buf_gc(struct netfront_queue *queue) in xennet_tx_buf_gc() argument
395 const struct device *dev = &queue->info->netdev->dev; in xennet_tx_buf_gc()
397 BUG_ON(!netif_carrier_ok(queue->info->netdev)); in xennet_tx_buf_gc()
400 prod = queue->tx.sring->rsp_prod; in xennet_tx_buf_gc()
401 if (RING_RESPONSE_PROD_OVERFLOW(&queue->tx, prod)) { in xennet_tx_buf_gc()
403 prod - queue->tx.rsp_cons); in xennet_tx_buf_gc()
408 for (cons = queue->tx.rsp_cons; cons != prod; cons++) { in xennet_tx_buf_gc()
413 RING_COPY_RESPONSE(&queue->tx, cons, &txrsp); in xennet_tx_buf_gc()
418 if (id >= RING_SIZE(&queue->tx)) { in xennet_tx_buf_gc()
424 if (queue->tx_link[id] != TX_PENDING) { in xennet_tx_buf_gc()
430 queue->tx_link[id] = TX_LINK_NONE; in xennet_tx_buf_gc()
431 skb = queue->tx_skbs[id]; in xennet_tx_buf_gc()
432 queue->tx_skbs[id] = NULL; in xennet_tx_buf_gc()
434 queue->grant_tx_ref[id]))) { in xennet_tx_buf_gc()
440 &queue->gref_tx_head, queue->grant_tx_ref[id]); in xennet_tx_buf_gc()
441 queue->grant_tx_ref[id] = INVALID_GRANT_REF; in xennet_tx_buf_gc()
442 queue->grant_tx_page[id] = NULL; in xennet_tx_buf_gc()
443 add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id); in xennet_tx_buf_gc()
447 queue->tx.rsp_cons = prod; in xennet_tx_buf_gc()
449 RING_FINAL_CHECK_FOR_RESPONSES(&queue->tx, more_to_do); in xennet_tx_buf_gc()
452 xennet_maybe_wake_tx(queue); in xennet_tx_buf_gc()
457 queue->info->broken = true; in xennet_tx_buf_gc()
464 struct netfront_queue *queue; member
481 struct netfront_queue *queue = info->queue; in xennet_tx_setup_grant() local
484 id = get_id_from_list(&queue->tx_skb_freelist, queue->tx_link); in xennet_tx_setup_grant()
485 tx = RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_tx_setup_grant()
486 ref = gnttab_claim_grant_reference(&queue->gref_tx_head); in xennet_tx_setup_grant()
489 gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, in xennet_tx_setup_grant()
492 queue->tx_skbs[id] = skb; in xennet_tx_setup_grant()
493 queue->grant_tx_page[id] = page; in xennet_tx_setup_grant()
494 queue->grant_tx_ref[id] = ref; in xennet_tx_setup_grant()
508 add_id_to_list(&queue->tx_pend_queue, queue->tx_link, id); in xennet_tx_setup_grant()
602 static void xennet_mark_tx_pending(struct netfront_queue *queue) in xennet_mark_tx_pending() argument
606 while ((i = get_id_from_list(&queue->tx_pend_queue, queue->tx_link)) != in xennet_mark_tx_pending()
608 queue->tx_link[i] = TX_PENDING; in xennet_mark_tx_pending()
612 struct netfront_queue *queue, in xennet_xdp_xmit_one() argument
618 .queue = queue, in xennet_xdp_xmit_one()
628 xennet_mark_tx_pending(queue); in xennet_xdp_xmit_one()
630 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_xdp_xmit_one()
632 notify_remote_via_irq(queue->tx_irq); in xennet_xdp_xmit_one()
639 xennet_tx_buf_gc(queue); in xennet_xdp_xmit_one()
649 struct netfront_queue *queue = NULL; in xennet_xdp_xmit() local
659 queue = &np->queues[smp_processor_id() % num_queues]; in xennet_xdp_xmit()
661 spin_lock_irqsave(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
667 if (xennet_xdp_xmit_one(dev, queue, xdpf)) in xennet_xdp_xmit()
671 spin_unlock_irqrestore(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
718 struct netfront_queue *queue = NULL; in xennet_start_xmit() local
731 queue = &np->queues[queue_index]; in xennet_start_xmit()
773 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_start_xmit()
778 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
783 info.queue = queue; in xennet_start_xmit()
807 RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_start_xmit()
839 xennet_mark_tx_pending(queue); in xennet_start_xmit()
841 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_start_xmit()
843 notify_remote_via_irq(queue->tx_irq); in xennet_start_xmit()
851 xennet_tx_buf_gc(queue); in xennet_start_xmit()
853 if (!netfront_tx_slot_available(queue)) in xennet_start_xmit()
854 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_start_xmit()
856 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
871 struct netfront_queue *queue; in xennet_close() local
874 queue = &np->queues[i]; in xennet_close()
875 napi_disable(&queue->napi); in xennet_close()
885 struct netfront_queue *queue = &info->queues[i]; in xennet_destroy_queues() local
888 napi_disable(&queue->napi); in xennet_destroy_queues()
889 netif_napi_del(&queue->napi); in xennet_destroy_queues()
902 static void xennet_set_rx_rsp_cons(struct netfront_queue *queue, RING_IDX val) in xennet_set_rx_rsp_cons() argument
906 spin_lock_irqsave(&queue->rx_cons_lock, flags); in xennet_set_rx_rsp_cons()
907 queue->rx.rsp_cons = val; in xennet_set_rx_rsp_cons()
908 queue->rx_rsp_unconsumed = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); in xennet_set_rx_rsp_cons()
909 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_set_rx_rsp_cons()
912 static void xennet_move_rx_slot(struct netfront_queue *queue, struct sk_buff *skb, in xennet_move_rx_slot() argument
915 int new = xennet_rxidx(queue->rx.req_prod_pvt); in xennet_move_rx_slot()
917 BUG_ON(queue->rx_skbs[new]); in xennet_move_rx_slot()
918 queue->rx_skbs[new] = skb; in xennet_move_rx_slot()
919 queue->grant_rx_ref[new] = ref; in xennet_move_rx_slot()
920 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->id = new; in xennet_move_rx_slot()
921 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->gref = ref; in xennet_move_rx_slot()
922 queue->rx.req_prod_pvt++; in xennet_move_rx_slot()
925 static int xennet_get_extras(struct netfront_queue *queue, in xennet_get_extras() argument
931 struct device *dev = &queue->info->netdev->dev; in xennet_get_extras()
932 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_extras()
946 RING_COPY_RESPONSE(&queue->rx, ++cons, &extra); in xennet_get_extras()
958 skb = xennet_get_rx_skb(queue, cons); in xennet_get_extras()
959 ref = xennet_get_rx_ref(queue, cons); in xennet_get_extras()
960 xennet_move_rx_slot(queue, skb, ref); in xennet_get_extras()
963 xennet_set_rx_rsp_cons(queue, cons); in xennet_get_extras()
967 static u32 xennet_run_xdp(struct netfront_queue *queue, struct page *pdata, in xennet_run_xdp() argument
977 &queue->xdp_rxq); in xennet_run_xdp()
986 err = xennet_xdp_xmit(queue->info->netdev, 1, &xdpf, 0); in xennet_run_xdp()
990 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
994 err = xdp_do_redirect(queue->info->netdev, xdp, prog); in xennet_run_xdp()
997 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
1004 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
1008 bpf_warn_invalid_xdp_action(queue->info->netdev, prog, act); in xennet_run_xdp()
1014 static int xennet_get_responses(struct netfront_queue *queue, in xennet_get_responses() argument
1021 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_responses()
1022 struct sk_buff *skb = xennet_get_rx_skb(queue, cons); in xennet_get_responses()
1024 grant_ref_t ref = xennet_get_rx_ref(queue, cons); in xennet_get_responses()
1025 struct device *dev = &queue->info->netdev->dev; in xennet_get_responses()
1033 err = xennet_get_extras(queue, extras, rp); in xennet_get_responses()
1042 cons = queue->rx.rsp_cons; in xennet_get_responses()
1064 xennet_move_rx_slot(queue, skb, ref); in xennet_get_responses()
1072 queue->info->broken = true; in xennet_get_responses()
1077 gnttab_release_grant_reference(&queue->gref_rx_head, ref); in xennet_get_responses()
1080 xdp_prog = rcu_dereference(queue->xdp_prog); in xennet_get_responses()
1084 verdict = xennet_run_xdp(queue, in xennet_get_responses()
1109 RING_COPY_RESPONSE(&queue->rx, cons + slots, &rx_local); in xennet_get_responses()
1111 skb = xennet_get_rx_skb(queue, cons + slots); in xennet_get_responses()
1112 ref = xennet_get_rx_ref(queue, cons + slots); in xennet_get_responses()
1123 xennet_set_rx_rsp_cons(queue, cons + slots); in xennet_get_responses()
1157 static int xennet_fill_frags(struct netfront_queue *queue, in xennet_fill_frags() argument
1161 RING_IDX cons = queue->rx.rsp_cons; in xennet_fill_frags()
1168 RING_COPY_RESPONSE(&queue->rx, ++cons, &rx); in xennet_fill_frags()
1177 xennet_set_rx_rsp_cons(queue, in xennet_fill_frags()
1191 xennet_set_rx_rsp_cons(queue, cons); in xennet_fill_frags()
1220 static int handle_incoming_queue(struct netfront_queue *queue, in handle_incoming_queue() argument
1223 struct netfront_stats *rx_stats = this_cpu_ptr(queue->info->rx_stats); in handle_incoming_queue()
1234 skb->protocol = eth_type_trans(skb, queue->info->netdev); in handle_incoming_queue()
1237 if (checksum_setup(queue->info->netdev, skb)) { in handle_incoming_queue()
1240 queue->info->netdev->stats.rx_errors++; in handle_incoming_queue()
1250 napi_gro_receive(&queue->napi, skb); in handle_incoming_queue()
1258 struct netfront_queue *queue = container_of(napi, struct netfront_queue, napi); in xennet_poll() local
1259 struct net_device *dev = queue->info->netdev; in xennet_poll()
1272 spin_lock(&queue->rx_lock); in xennet_poll()
1278 rp = queue->rx.sring->rsp_prod; in xennet_poll()
1279 if (RING_RESPONSE_PROD_OVERFLOW(&queue->rx, rp)) { in xennet_poll()
1281 rp - queue->rx.rsp_cons); in xennet_poll()
1282 queue->info->broken = true; in xennet_poll()
1283 spin_unlock(&queue->rx_lock); in xennet_poll()
1288 i = queue->rx.rsp_cons; in xennet_poll()
1291 RING_COPY_RESPONSE(&queue->rx, i, rx); in xennet_poll()
1294 err = xennet_get_responses(queue, &rinfo, rp, &tmpq, in xennet_poll()
1298 if (queue->info->broken) { in xennet_poll()
1299 spin_unlock(&queue->rx_lock); in xennet_poll()
1306 i = queue->rx.rsp_cons; in xennet_poll()
1318 xennet_set_rx_rsp_cons(queue, in xennet_poll()
1319 queue->rx.rsp_cons + in xennet_poll()
1334 if (unlikely(xennet_fill_frags(queue, skb, &tmpq))) in xennet_poll()
1344 i = queue->rx.rsp_cons + 1; in xennet_poll()
1345 xennet_set_rx_rsp_cons(queue, i); in xennet_poll()
1353 work_done -= handle_incoming_queue(queue, &rxq); in xennet_poll()
1355 xennet_alloc_rx_buffers(queue); in xennet_poll()
1362 RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do); in xennet_poll()
1367 spin_unlock(&queue->rx_lock); in xennet_poll()
1416 static void xennet_release_tx_bufs(struct netfront_queue *queue) in xennet_release_tx_bufs() argument
1423 if (!queue->tx_skbs[i]) in xennet_release_tx_bufs()
1426 skb = queue->tx_skbs[i]; in xennet_release_tx_bufs()
1427 queue->tx_skbs[i] = NULL; in xennet_release_tx_bufs()
1428 get_page(queue->grant_tx_page[i]); in xennet_release_tx_bufs()
1429 gnttab_end_foreign_access(queue->grant_tx_ref[i], in xennet_release_tx_bufs()
1430 queue->grant_tx_page[i]); in xennet_release_tx_bufs()
1431 queue->grant_tx_page[i] = NULL; in xennet_release_tx_bufs()
1432 queue->grant_tx_ref[i] = INVALID_GRANT_REF; in xennet_release_tx_bufs()
1433 add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, i); in xennet_release_tx_bufs()
1438 static void xennet_release_rx_bufs(struct netfront_queue *queue) in xennet_release_rx_bufs() argument
1442 spin_lock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1448 skb = queue->rx_skbs[id]; in xennet_release_rx_bufs()
1452 ref = queue->grant_rx_ref[id]; in xennet_release_rx_bufs()
1463 queue->grant_rx_ref[id] = INVALID_GRANT_REF; in xennet_release_rx_bufs()
1468 spin_unlock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1507 static bool xennet_handle_tx(struct netfront_queue *queue, unsigned int *eoi) in xennet_handle_tx() argument
1511 if (unlikely(queue->info->broken)) in xennet_handle_tx()
1514 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_handle_tx()
1515 if (xennet_tx_buf_gc(queue)) in xennet_handle_tx()
1517 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_handle_tx()
1532 static bool xennet_handle_rx(struct netfront_queue *queue, unsigned int *eoi) in xennet_handle_rx() argument
1537 if (unlikely(queue->info->broken)) in xennet_handle_rx()
1540 spin_lock_irqsave(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1541 work_queued = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); in xennet_handle_rx()
1542 if (work_queued > queue->rx_rsp_unconsumed) { in xennet_handle_rx()
1543 queue->rx_rsp_unconsumed = work_queued; in xennet_handle_rx()
1545 } else if (unlikely(work_queued < queue->rx_rsp_unconsumed)) { in xennet_handle_rx()
1546 const struct device *dev = &queue->info->netdev->dev; in xennet_handle_rx()
1548 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1551 queue->info->broken = true; in xennet_handle_rx()
1554 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1556 if (likely(netif_carrier_ok(queue->info->netdev) && work_queued)) in xennet_handle_rx()
1557 napi_schedule(&queue->napi); in xennet_handle_rx()
1816 struct netfront_queue *queue = &info->queues[i]; in xennet_disconnect_backend() local
1818 del_timer_sync(&queue->rx_refill_timer); in xennet_disconnect_backend()
1820 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) in xennet_disconnect_backend()
1821 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1822 if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { in xennet_disconnect_backend()
1823 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1824 unbind_from_irqhandler(queue->rx_irq, queue); in xennet_disconnect_backend()
1826 queue->tx_evtchn = queue->rx_evtchn = 0; in xennet_disconnect_backend()
1827 queue->tx_irq = queue->rx_irq = 0; in xennet_disconnect_backend()
1830 napi_synchronize(&queue->napi); in xennet_disconnect_backend()
1832 xennet_release_tx_bufs(queue); in xennet_disconnect_backend()
1833 xennet_release_rx_bufs(queue); in xennet_disconnect_backend()
1834 gnttab_free_grant_references(queue->gref_tx_head); in xennet_disconnect_backend()
1835 gnttab_free_grant_references(queue->gref_rx_head); in xennet_disconnect_backend()
1838 xennet_end_access(queue->tx_ring_ref, queue->tx.sring); in xennet_disconnect_backend()
1839 xennet_end_access(queue->rx_ring_ref, queue->rx.sring); in xennet_disconnect_backend()
1841 queue->tx_ring_ref = INVALID_GRANT_REF; in xennet_disconnect_backend()
1842 queue->rx_ring_ref = INVALID_GRANT_REF; in xennet_disconnect_backend()
1843 queue->tx.sring = NULL; in xennet_disconnect_backend()
1844 queue->rx.sring = NULL; in xennet_disconnect_backend()
1846 page_pool_destroy(queue->page_pool); in xennet_disconnect_backend()
1898 static int setup_netfront_single(struct netfront_queue *queue) in setup_netfront_single() argument
1902 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_single()
1906 err = bind_evtchn_to_irqhandler_lateeoi(queue->tx_evtchn, in setup_netfront_single()
1908 queue->info->netdev->name, in setup_netfront_single()
1909 queue); in setup_netfront_single()
1912 queue->rx_evtchn = queue->tx_evtchn; in setup_netfront_single()
1913 queue->rx_irq = queue->tx_irq = err; in setup_netfront_single()
1918 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_single()
1919 queue->tx_evtchn = 0; in setup_netfront_single()
1924 static int setup_netfront_split(struct netfront_queue *queue) in setup_netfront_split() argument
1928 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_split()
1931 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->rx_evtchn); in setup_netfront_split()
1935 snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), in setup_netfront_split()
1936 "%s-tx", queue->name); in setup_netfront_split()
1937 err = bind_evtchn_to_irqhandler_lateeoi(queue->tx_evtchn, in setup_netfront_split()
1939 queue->tx_irq_name, queue); in setup_netfront_split()
1942 queue->tx_irq = err; in setup_netfront_split()
1944 snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), in setup_netfront_split()
1945 "%s-rx", queue->name); in setup_netfront_split()
1946 err = bind_evtchn_to_irqhandler_lateeoi(queue->rx_evtchn, in setup_netfront_split()
1948 queue->rx_irq_name, queue); in setup_netfront_split()
1951 queue->rx_irq = err; in setup_netfront_split()
1956 unbind_from_irqhandler(queue->tx_irq, queue); in setup_netfront_split()
1957 queue->tx_irq = 0; in setup_netfront_split()
1959 xenbus_free_evtchn(queue->info->xbdev, queue->rx_evtchn); in setup_netfront_split()
1960 queue->rx_evtchn = 0; in setup_netfront_split()
1962 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_split()
1963 queue->tx_evtchn = 0; in setup_netfront_split()
1969 struct netfront_queue *queue, unsigned int feature_split_evtchn) in setup_netfront() argument
1975 queue->tx_ring_ref = INVALID_GRANT_REF; in setup_netfront()
1976 queue->rx_ring_ref = INVALID_GRANT_REF; in setup_netfront()
1977 queue->rx.sring = NULL; in setup_netfront()
1978 queue->tx.sring = NULL; in setup_netfront()
1981 1, &queue->tx_ring_ref); in setup_netfront()
1985 XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); in setup_netfront()
1988 1, &queue->rx_ring_ref); in setup_netfront()
1992 XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); in setup_netfront()
1995 err = setup_netfront_split(queue); in setup_netfront()
2001 err = setup_netfront_single(queue); in setup_netfront()
2009 xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref); in setup_netfront()
2010 xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref); in setup_netfront()
2019 static int xennet_init_queue(struct netfront_queue *queue) in xennet_init_queue() argument
2025 spin_lock_init(&queue->tx_lock); in xennet_init_queue()
2026 spin_lock_init(&queue->rx_lock); in xennet_init_queue()
2027 spin_lock_init(&queue->rx_cons_lock); in xennet_init_queue()
2029 timer_setup(&queue->rx_refill_timer, rx_refill_timeout, 0); in xennet_init_queue()
2031 devid = strrchr(queue->info->xbdev->nodename, '/') + 1; in xennet_init_queue()
2032 snprintf(queue->name, sizeof(queue->name), "vif%s-q%u", in xennet_init_queue()
2033 devid, queue->id); in xennet_init_queue()
2036 queue->tx_skb_freelist = 0; in xennet_init_queue()
2037 queue->tx_pend_queue = TX_LINK_NONE; in xennet_init_queue()
2039 queue->tx_link[i] = i + 1; in xennet_init_queue()
2040 queue->grant_tx_ref[i] = INVALID_GRANT_REF; in xennet_init_queue()
2041 queue->grant_tx_page[i] = NULL; in xennet_init_queue()
2043 queue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE; in xennet_init_queue()
2047 queue->rx_skbs[i] = NULL; in xennet_init_queue()
2048 queue->grant_rx_ref[i] = INVALID_GRANT_REF; in xennet_init_queue()
2053 &queue->gref_tx_head) < 0) { in xennet_init_queue()
2061 &queue->gref_rx_head) < 0) { in xennet_init_queue()
2070 gnttab_free_grant_references(queue->gref_tx_head); in xennet_init_queue()
2075 static int write_queue_xenstore_keys(struct netfront_queue *queue, in write_queue_xenstore_keys() argument
2082 struct xenbus_device *dev = queue->info->xbdev; in write_queue_xenstore_keys()
2098 dev->nodename, queue->id); in write_queue_xenstore_keys()
2105 queue->tx_ring_ref); in write_queue_xenstore_keys()
2112 queue->rx_ring_ref); in write_queue_xenstore_keys()
2121 if (queue->tx_evtchn == queue->rx_evtchn) { in write_queue_xenstore_keys()
2124 "event-channel", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
2132 "event-channel-tx", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
2139 "event-channel-rx", "%u", queue->rx_evtchn); in write_queue_xenstore_keys()
2159 static int xennet_create_page_pool(struct netfront_queue *queue) in xennet_create_page_pool() argument
2167 .dev = &queue->info->netdev->dev, in xennet_create_page_pool()
2172 queue->page_pool = page_pool_create(&pp_params); in xennet_create_page_pool()
2173 if (IS_ERR(queue->page_pool)) { in xennet_create_page_pool()
2174 err = PTR_ERR(queue->page_pool); in xennet_create_page_pool()
2175 queue->page_pool = NULL; in xennet_create_page_pool()
2179 err = xdp_rxq_info_reg(&queue->xdp_rxq, queue->info->netdev, in xennet_create_page_pool()
2180 queue->id, 0); in xennet_create_page_pool()
2182 netdev_err(queue->info->netdev, "xdp_rxq_info_reg failed\n"); in xennet_create_page_pool()
2186 err = xdp_rxq_info_reg_mem_model(&queue->xdp_rxq, in xennet_create_page_pool()
2187 MEM_TYPE_PAGE_POOL, queue->page_pool); in xennet_create_page_pool()
2189 netdev_err(queue->info->netdev, "xdp_rxq_info_reg_mem_model failed\n"); in xennet_create_page_pool()
2195 xdp_rxq_info_unreg(&queue->xdp_rxq); in xennet_create_page_pool()
2197 page_pool_destroy(queue->page_pool); in xennet_create_page_pool()
2198 queue->page_pool = NULL; in xennet_create_page_pool()
2214 struct netfront_queue *queue = &info->queues[i]; in xennet_create_queues() local
2216 queue->id = i; in xennet_create_queues()
2217 queue->info = info; in xennet_create_queues()
2219 ret = xennet_init_queue(queue); in xennet_create_queues()
2228 ret = xennet_create_page_pool(queue); in xennet_create_queues()
2235 netif_napi_add(queue->info->netdev, &queue->napi, xennet_poll); in xennet_create_queues()
2237 napi_enable(&queue->napi); in xennet_create_queues()
2259 struct netfront_queue *queue = NULL; in talk_to_netback() local
2315 queue = &info->queues[i]; in talk_to_netback()
2316 err = setup_netfront(dev, queue, feature_split_evtchn); in talk_to_netback()
2346 queue = &info->queues[i]; in talk_to_netback()
2347 err = write_queue_xenstore_keys(queue, &xbt, 1); /* hierarchical */ in talk_to_netback()
2423 struct netfront_queue *queue = NULL; in xennet_connect() local
2468 queue = &np->queues[j]; in xennet_connect()
2470 notify_remote_via_irq(queue->tx_irq); in xennet_connect()
2471 if (queue->tx_irq != queue->rx_irq) in xennet_connect()
2472 notify_remote_via_irq(queue->rx_irq); in xennet_connect()
2474 spin_lock_bh(&queue->rx_lock); in xennet_connect()
2475 xennet_alloc_rx_buffers(queue); in xennet_connect()
2476 spin_unlock_bh(&queue->rx_lock); in xennet_connect()