Lines Matching +full:rx +full:- +full:queues +full:- +full:to +full:- +full:use

4  * Copyright (c) 2002-2005, K A Fraser
11 * software packages, subject to the following license:
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this source file (the "Software"), to deal in the Software without
15 * restriction, including without limitation the rights to use, copy, modify,
17 * and to permit persons to whom the Software is furnished to do so, subject to
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
67 "Maximum number of queues per virtual interface");
77 #define NETFRONT_SKB_CB(skb) ((struct netfront_cb *)((skb)->cb))
86 /* Minimum number of Rx slots (includes slot for GSO metadata). */
89 /* Queue name is interface name with "-qNNN" appended */
92 /* IRQ name is queue name with "-tx" or "-rx" appended */
106 unsigned int id; /* Queue ID, 0-based */
107 char name[QUEUE_NAME_SIZE]; /* DEVNAME-qN */
120 char tx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-tx */
121 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */
128 * {tx,rx}_skbs store outstanding skbuffs. Free tx_skb entries
131 * NB. Freelist index entries are always going to be less than
132 * PAGE_OFFSET, whereas pointers to skbs will always be equal or
133 * greater than PAGE_OFFSET: we use this property to distinguish
146 struct xen_netif_rx_front_ring rx; member
165 /* Multi-queue support */
166 struct netfront_queue *queues; member
180 struct xen_netif_rx_response rx; member
181 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1];
186 list->link = id; in skb_entry_set_link()
191 BUILD_BUG_ON(sizeof(list->skb) != sizeof(list->link)); in skb_entry_is_link()
192 return (unsigned long)list->skb < PAGE_OFFSET; in skb_entry_is_link()
216 return idx & (NET_RX_RING_SIZE - 1); in xennet_rxidx()
223 struct sk_buff *skb = queue->rx_skbs[i]; in xennet_get_rx_skb()
224 queue->rx_skbs[i] = NULL; in xennet_get_rx_skb()
232 grant_ref_t ref = queue->grant_rx_ref[i]; in xennet_get_rx_ref()
233 queue->grant_rx_ref[i] = GRANT_INVALID_REF; in xennet_get_rx_ref()
243 return dev->features & NETIF_F_SG; in xennet_can_sg()
250 napi_schedule(&queue->napi); in rx_refill_timeout()
255 return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) < in netfront_tx_slot_available()
256 (NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1); in netfront_tx_slot_available()
261 struct net_device *dev = queue->info->netdev; in xennet_maybe_wake_tx()
262 struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, queue->id); in xennet_maybe_wake_tx()
267 netif_tx_wake_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_maybe_wake_tx()
276 skb = __netdev_alloc_skb(queue->info->netdev, in xennet_alloc_one_rx_buffer()
282 page = page_pool_dev_alloc_pages(queue->page_pool); in xennet_alloc_one_rx_buffer()
289 /* Align ip header to a 16 bytes boundary */ in xennet_alloc_one_rx_buffer()
291 skb->dev = queue->info->netdev; in xennet_alloc_one_rx_buffer()
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()
317 err = -ENOMEM; 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()
330 page = skb_frag_page(&skb_shinfo(skb)->frags[0]); 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()
337 req->id = id; in xennet_alloc_rx_buffers()
338 req->gref = ref; 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()
362 unsigned int num_queues = dev->real_num_tx_queues; in xennet_open()
366 if (!np->queues) in xennet_open()
367 return -ENODEV; in xennet_open()
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()
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()
395 BUG_ON(!netif_carrier_ok(queue->info->netdev)); in xennet_tx_buf_gc()
398 prod = queue->tx.sring->rsp_prod; in xennet_tx_buf_gc()
399 rmb(); /* Ensure we see responses up to 'rp'. */ in xennet_tx_buf_gc()
401 for (cons = queue->tx.rsp_cons; cons != prod; cons++) { in xennet_tx_buf_gc()
404 txrsp = RING_GET_RESPONSE(&queue->tx, cons); in xennet_tx_buf_gc()
405 if (txrsp->status == XEN_NETIF_RSP_NULL) in xennet_tx_buf_gc()
408 id = txrsp->id; in xennet_tx_buf_gc()
409 skb = queue->tx_skbs[id].skb; in xennet_tx_buf_gc()
411 queue->grant_tx_ref[id]) != 0)) { in xennet_tx_buf_gc()
412 pr_alert("%s: warning -- grant still in use by backend domain\n", in xennet_tx_buf_gc()
417 queue->grant_tx_ref[id], GNTMAP_readonly); in xennet_tx_buf_gc()
419 &queue->gref_tx_head, queue->grant_tx_ref[id]); in xennet_tx_buf_gc()
420 queue->grant_tx_ref[id] = GRANT_INVALID_REF; in xennet_tx_buf_gc()
421 queue->grant_tx_page[id] = NULL; in xennet_tx_buf_gc()
422 add_id_to_freelist(&queue->tx_skb_freelist, queue->tx_skbs, id); in xennet_tx_buf_gc()
426 queue->tx.rsp_cons = prod; in xennet_tx_buf_gc()
428 RING_FINAL_CHECK_FOR_RESPONSES(&queue->tx, more_to_do); in xennet_tx_buf_gc()
450 struct page *page = info->page; in xennet_tx_setup_grant()
451 struct netfront_queue *queue = info->queue; in xennet_tx_setup_grant()
452 struct sk_buff *skb = info->skb; in xennet_tx_setup_grant()
454 id = get_id_from_freelist(&queue->tx_skb_freelist, queue->tx_skbs); in xennet_tx_setup_grant()
455 tx = RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_tx_setup_grant()
456 ref = gnttab_claim_grant_reference(&queue->gref_tx_head); in xennet_tx_setup_grant()
459 gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, in xennet_tx_setup_grant()
462 queue->tx_skbs[id].skb = skb; in xennet_tx_setup_grant()
463 queue->grant_tx_page[id] = page; in xennet_tx_setup_grant()
464 queue->grant_tx_ref[id] = ref; in xennet_tx_setup_grant()
466 tx->id = id; in xennet_tx_setup_grant()
467 tx->gref = ref; in xennet_tx_setup_grant()
468 tx->offset = offset; in xennet_tx_setup_grant()
469 tx->size = len; in xennet_tx_setup_grant()
470 tx->flags = 0; in xennet_tx_setup_grant()
472 info->tx = tx; in xennet_tx_setup_grant()
473 info->size += tx->size; in xennet_tx_setup_grant()
497 info->tx->flags |= XEN_NETTXF_more_data; in xennet_make_one_txreq()
498 skb_get(info->skb); in xennet_make_one_txreq()
527 len -= info.size; in xennet_make_txreqs()
534 * Count how many ring slots are required to send this skb. Each frag
539 int i, frags = skb_shinfo(skb)->nr_frags; in xennet_count_skb_slots()
542 slots = gnttab_count_grant(offset_in_page(skb->data), in xennet_count_skb_slots()
546 skb_frag_t *frag = skb_shinfo(skb)->frags + i; in xennet_count_skb_slots()
562 unsigned int num_queues = dev->real_num_tx_queues; in xennet_select_queue()
582 struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats); in xennet_xdp_xmit_one()
586 virt_to_page(xdpf->data), in xennet_xdp_xmit_one()
587 offset_in_page(xdpf->data), in xennet_xdp_xmit_one()
588 xdpf->len); in xennet_xdp_xmit_one()
590 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_xdp_xmit_one()
592 notify_remote_via_irq(queue->tx_irq); in xennet_xdp_xmit_one()
594 u64_stats_update_begin(&tx_stats->syncp); in xennet_xdp_xmit_one()
595 tx_stats->bytes += xdpf->len; in xennet_xdp_xmit_one()
596 tx_stats->packets++; in xennet_xdp_xmit_one()
597 u64_stats_update_end(&tx_stats->syncp); in xennet_xdp_xmit_one()
607 unsigned int num_queues = dev->real_num_tx_queues; in xennet_xdp_xmit()
615 return -EINVAL; in xennet_xdp_xmit()
617 queue = &np->queues[smp_processor_id() % num_queues]; in xennet_xdp_xmit()
619 spin_lock_irqsave(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
631 spin_unlock_irqrestore(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
633 return n - drops; in xennet_xdp_xmit()
642 struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats); in xennet_start_xmit()
652 unsigned int num_queues = dev->real_num_tx_queues; in xennet_start_xmit()
656 /* Drop the packet if no queues are set up */ in xennet_start_xmit()
659 /* Determine which queue to transmit this SKB on */ in xennet_start_xmit()
661 queue = &np->queues[queue_index]; in xennet_start_xmit()
663 /* If skb->len is too big for wire format, drop skb and alert in xennet_start_xmit()
666 if (unlikely(skb->len > XEN_NETIF_MAX_TX_SIZE)) { in xennet_start_xmit()
668 "xennet: skb->len = %u, too big for wire format\n", in xennet_start_xmit()
669 skb->len); in xennet_start_xmit()
676 slots, skb->len); in xennet_start_xmit()
681 page = virt_to_page(skb->data); in xennet_start_xmit()
682 offset = offset_in_page(skb->data); in xennet_start_xmit()
687 if (unlikely(PAGE_SIZE - offset < ETH_HLEN)) { in xennet_start_xmit()
693 page = virt_to_page(skb->data); in xennet_start_xmit()
694 offset = offset_in_page(skb->data); in xennet_start_xmit()
699 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_start_xmit()
704 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
711 offset += tx->size; in xennet_start_xmit()
716 len -= tx->size; in xennet_start_xmit()
718 if (skb->ip_summed == CHECKSUM_PARTIAL) in xennet_start_xmit()
720 tx->flags |= XEN_NETTXF_csum_blank | XEN_NETTXF_data_validated; in xennet_start_xmit()
721 else if (skb->ip_summed == CHECKSUM_UNNECESSARY) in xennet_start_xmit()
723 tx->flags |= XEN_NETTXF_data_validated; in xennet_start_xmit()
726 if (skb_shinfo(skb)->gso_size) { in xennet_start_xmit()
730 RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_start_xmit()
732 tx->flags |= XEN_NETTXF_extra_info; in xennet_start_xmit()
734 gso->u.gso.size = skb_shinfo(skb)->gso_size; in xennet_start_xmit()
735 gso->u.gso.type = (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) ? in xennet_start_xmit()
738 gso->u.gso.pad = 0; in xennet_start_xmit()
739 gso->u.gso.features = 0; in xennet_start_xmit()
741 gso->type = XEN_NETIF_EXTRA_TYPE_GSO; in xennet_start_xmit()
742 gso->flags = 0; in xennet_start_xmit()
749 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in xennet_start_xmit()
750 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in xennet_start_xmit()
757 first_tx->size = skb->len; in xennet_start_xmit()
762 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_start_xmit()
764 notify_remote_via_irq(queue->tx_irq); in xennet_start_xmit()
766 u64_stats_update_begin(&tx_stats->syncp); in xennet_start_xmit()
767 tx_stats->bytes += skb->len; in xennet_start_xmit()
768 tx_stats->packets++; in xennet_start_xmit()
769 u64_stats_update_end(&tx_stats->syncp); in xennet_start_xmit()
771 /* Note: It is not safe to access skb after xennet_tx_buf_gc()! */ in xennet_start_xmit()
775 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_start_xmit()
777 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
782 dev->stats.tx_dropped++; in xennet_start_xmit()
790 unsigned int num_queues = dev->real_num_tx_queues; in xennet_close()
793 netif_tx_stop_all_queues(np->netdev); in xennet_close()
795 queue = &np->queues[i]; in xennet_close()
796 napi_disable(&queue->napi); in xennet_close()
804 int new = xennet_rxidx(queue->rx.req_prod_pvt); in xennet_move_rx_slot()
806 BUG_ON(queue->rx_skbs[new]); in xennet_move_rx_slot()
807 queue->rx_skbs[new] = skb; in xennet_move_rx_slot()
808 queue->grant_rx_ref[new] = ref; in xennet_move_rx_slot()
809 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->id = new; in xennet_move_rx_slot()
810 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->gref = ref; in xennet_move_rx_slot()
811 queue->rx.req_prod_pvt++; in xennet_move_rx_slot()
820 struct device *dev = &queue->info->netdev->dev; in xennet_get_extras()
821 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_extras()
831 err = -EBADR; in xennet_get_extras()
836 RING_GET_RESPONSE(&queue->rx, ++cons); in xennet_get_extras()
838 if (unlikely(!extra->type || in xennet_get_extras()
839 extra->type >= XEN_NETIF_EXTRA_TYPE_MAX)) { in xennet_get_extras()
842 extra->type); in xennet_get_extras()
843 err = -EINVAL; in xennet_get_extras()
845 memcpy(&extras[extra->type - 1], extra, in xennet_get_extras()
852 } while (extra->flags & XEN_NETIF_EXTRA_FLAG_MORE); in xennet_get_extras()
854 queue->rx.rsp_cons = cons; in xennet_get_extras()
859 struct xen_netif_rx_response *rx, struct bpf_prog *prog, in xennet_run_xdp() argument
863 u32 len = rx->status; in xennet_run_xdp()
867 xdp->data_hard_start = page_address(pdata); in xennet_run_xdp()
868 xdp->data = xdp->data_hard_start + XDP_PACKET_HEADROOM; in xennet_run_xdp()
870 xdp->data_end = xdp->data + len; in xennet_run_xdp()
871 xdp->rxq = &queue->xdp_rxq; in xennet_run_xdp()
872 xdp->frame_sz = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM; in xennet_run_xdp()
879 err = xennet_xdp_xmit(queue->info->netdev, 1, &xdpf, 0); in xennet_run_xdp()
881 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
885 err = xdp_do_redirect(queue->info->netdev, xdp, prog); in xennet_run_xdp()
888 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
895 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
910 struct xen_netif_rx_response *rx = &rinfo->rx; in xennet_get_responses() local
911 int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD); in xennet_get_responses()
912 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_responses()
914 struct xen_netif_extra_info *extras = rinfo->extras; in xennet_get_responses()
916 struct device *dev = &queue->info->netdev->dev; in xennet_get_responses()
924 if (rx->flags & XEN_NETRXF_extra_info) { in xennet_get_responses()
927 if (extras[XEN_NETIF_EXTRA_TYPE_XDP - 1].type) { in xennet_get_responses()
930 xdp = &extras[XEN_NETIF_EXTRA_TYPE_XDP - 1]; in xennet_get_responses()
931 rx->offset = xdp->u.xdp.headroom; in xennet_get_responses()
934 cons = queue->rx.rsp_cons; in xennet_get_responses()
938 if (unlikely(rx->status < 0 || in xennet_get_responses()
939 rx->offset + rx->status > XEN_PAGE_SIZE)) { in xennet_get_responses()
941 dev_warn(dev, "rx->offset: %u, size: %d\n", in xennet_get_responses()
942 rx->offset, rx->status); in xennet_get_responses()
944 err = -EINVAL; in xennet_get_responses()
951 * situation to the system controller to reboot the backend. in xennet_get_responses()
955 dev_warn(dev, "Bad rx response id %d.\n", in xennet_get_responses()
956 rx->id); in xennet_get_responses()
957 err = -EINVAL; in xennet_get_responses()
964 gnttab_release_grant_reference(&queue->gref_rx_head, ref); in xennet_get_responses()
967 xdp_prog = rcu_dereference(queue->xdp_prog); in xennet_get_responses()
969 if (!(rx->flags & XEN_NETRXF_more_data)) { in xennet_get_responses()
972 skb_frag_page(&skb_shinfo(skb)->frags[0]), in xennet_get_responses()
973 rx, xdp_prog, &xdp, need_xdp_flush); in xennet_get_responses()
975 err = -EINVAL; in xennet_get_responses()
978 err = -EINVAL; in xennet_get_responses()
984 if (!(rx->flags & XEN_NETRXF_more_data)) in xennet_get_responses()
990 err = -ENOENT; in xennet_get_responses()
994 rx = RING_GET_RESPONSE(&queue->rx, cons + slots); in xennet_get_responses()
1003 err = -E2BIG; in xennet_get_responses()
1007 queue->rx.rsp_cons = cons + slots; in xennet_get_responses()
1015 if (!gso->u.gso.size) { in xennet_set_skb_gso()
1018 return -EINVAL; in xennet_set_skb_gso()
1021 if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4 && in xennet_set_skb_gso()
1022 gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV6) { in xennet_set_skb_gso()
1024 pr_warn("Bad GSO type %d\n", gso->u.gso.type); in xennet_set_skb_gso()
1025 return -EINVAL; in xennet_set_skb_gso()
1028 skb_shinfo(skb)->gso_size = gso->u.gso.size; in xennet_set_skb_gso()
1029 skb_shinfo(skb)->gso_type = in xennet_set_skb_gso()
1030 (gso->u.gso.type == XEN_NETIF_GSO_TYPE_TCPV4) ? in xennet_set_skb_gso()
1035 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; in xennet_set_skb_gso()
1036 skb_shinfo(skb)->gso_segs = 0; in xennet_set_skb_gso()
1045 RING_IDX cons = queue->rx.rsp_cons; in xennet_fill_frags()
1049 struct xen_netif_rx_response *rx = in xennet_fill_frags() local
1050 RING_GET_RESPONSE(&queue->rx, ++cons); in xennet_fill_frags()
1051 skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0]; in xennet_fill_frags()
1053 if (skb_shinfo(skb)->nr_frags == MAX_SKB_FRAGS) { in xennet_fill_frags()
1054 unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to; in xennet_fill_frags()
1057 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); in xennet_fill_frags()
1059 if (unlikely(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS)) { in xennet_fill_frags()
1060 queue->rx.rsp_cons = ++cons + skb_queue_len(list); in xennet_fill_frags()
1062 return -ENOENT; in xennet_fill_frags()
1065 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, in xennet_fill_frags()
1067 rx->offset, rx->status, PAGE_SIZE); in xennet_fill_frags()
1069 skb_shinfo(nskb)->nr_frags = 0; in xennet_fill_frags()
1073 queue->rx.rsp_cons = cons; in xennet_fill_frags()
1084 * peers can fail to set NETRXF_csum_blank when sending a GSO in checksum_setup()
1085 * frame. In this case force the SKB to CHECKSUM_PARTIAL and in checksum_setup()
1088 if (skb->ip_summed != CHECKSUM_PARTIAL && skb_is_gso(skb)) { in checksum_setup()
1090 atomic_inc(&np->rx_gso_checksum_fixup); in checksum_setup()
1091 skb->ip_summed = CHECKSUM_PARTIAL; in checksum_setup()
1095 /* A non-CHECKSUM_PARTIAL SKB does not require setup. */ in checksum_setup()
1096 if (skb->ip_summed != CHECKSUM_PARTIAL) in checksum_setup()
1105 struct netfront_stats *rx_stats = this_cpu_ptr(queue->info->rx_stats); in handle_incoming_queue()
1110 int pull_to = NETFRONT_SKB_CB(skb)->pull_to; in handle_incoming_queue()
1113 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); in handle_incoming_queue()
1115 /* Ethernet work: Delayed to here as it peeks the header. */ in handle_incoming_queue()
1116 skb->protocol = eth_type_trans(skb, queue->info->netdev); in handle_incoming_queue()
1119 if (checksum_setup(queue->info->netdev, skb)) { in handle_incoming_queue()
1122 queue->info->netdev->stats.rx_errors++; in handle_incoming_queue()
1126 u64_stats_update_begin(&rx_stats->syncp); in handle_incoming_queue()
1127 rx_stats->packets++; in handle_incoming_queue()
1128 rx_stats->bytes += skb->len; in handle_incoming_queue()
1129 u64_stats_update_end(&rx_stats->syncp); in handle_incoming_queue()
1132 napi_gro_receive(&queue->napi, skb); in handle_incoming_queue()
1141 struct net_device *dev = queue->info->netdev; in xennet_poll()
1144 struct xen_netif_rx_response *rx = &rinfo.rx; in xennet_poll() local
1154 spin_lock(&queue->rx_lock); in xennet_poll()
1160 rp = queue->rx.sring->rsp_prod; in xennet_poll()
1161 rmb(); /* Ensure we see queued responses up to 'rp'. */ in xennet_poll()
1163 i = queue->rx.rsp_cons; in xennet_poll()
1166 memcpy(rx, RING_GET_RESPONSE(&queue->rx, i), sizeof(*rx)); in xennet_poll()
1176 dev->stats.rx_errors++; in xennet_poll()
1177 i = queue->rx.rsp_cons; in xennet_poll()
1183 if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) { in xennet_poll()
1185 gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1]; in xennet_poll()
1189 queue->rx.rsp_cons += skb_queue_len(&tmpq); in xennet_poll()
1194 NETFRONT_SKB_CB(skb)->pull_to = rx->status; in xennet_poll()
1195 if (NETFRONT_SKB_CB(skb)->pull_to > RX_COPY_THRESHOLD) in xennet_poll()
1196 NETFRONT_SKB_CB(skb)->pull_to = RX_COPY_THRESHOLD; in xennet_poll()
1198 skb_frag_off_set(&skb_shinfo(skb)->frags[0], rx->offset); in xennet_poll()
1199 skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status); in xennet_poll()
1200 skb->data_len = rx->status; in xennet_poll()
1201 skb->len += rx->status; in xennet_poll()
1206 if (rx->flags & XEN_NETRXF_csum_blank) in xennet_poll()
1207 skb->ip_summed = CHECKSUM_PARTIAL; in xennet_poll()
1208 else if (rx->flags & XEN_NETRXF_data_validated) in xennet_poll()
1209 skb->ip_summed = CHECKSUM_UNNECESSARY; in xennet_poll()
1213 i = ++queue->rx.rsp_cons; in xennet_poll()
1221 work_done -= handle_incoming_queue(queue, &rxq); in xennet_poll()
1230 RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do); in xennet_poll()
1235 spin_unlock(&queue->rx_lock); in xennet_poll()
1245 return -EINVAL; in xennet_change_mtu()
1246 dev->mtu = mtu; in xennet_change_mtu()
1257 struct netfront_stats *rx_stats = per_cpu_ptr(np->rx_stats, cpu); in xennet_get_stats64()
1258 struct netfront_stats *tx_stats = per_cpu_ptr(np->tx_stats, cpu); in xennet_get_stats64()
1263 start = u64_stats_fetch_begin_irq(&tx_stats->syncp); in xennet_get_stats64()
1264 tx_packets = tx_stats->packets; in xennet_get_stats64()
1265 tx_bytes = tx_stats->bytes; in xennet_get_stats64()
1266 } while (u64_stats_fetch_retry_irq(&tx_stats->syncp, start)); in xennet_get_stats64()
1269 start = u64_stats_fetch_begin_irq(&rx_stats->syncp); in xennet_get_stats64()
1270 rx_packets = rx_stats->packets; in xennet_get_stats64()
1271 rx_bytes = rx_stats->bytes; in xennet_get_stats64()
1272 } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start)); in xennet_get_stats64()
1274 tot->rx_packets += rx_packets; in xennet_get_stats64()
1275 tot->tx_packets += tx_packets; in xennet_get_stats64()
1276 tot->rx_bytes += rx_bytes; in xennet_get_stats64()
1277 tot->tx_bytes += tx_bytes; in xennet_get_stats64()
1280 tot->rx_errors = dev->stats.rx_errors; in xennet_get_stats64()
1281 tot->tx_dropped = dev->stats.tx_dropped; in xennet_get_stats64()
1291 if (skb_entry_is_link(&queue->tx_skbs[i])) in xennet_release_tx_bufs()
1294 skb = queue->tx_skbs[i].skb; in xennet_release_tx_bufs()
1295 get_page(queue->grant_tx_page[i]); in xennet_release_tx_bufs()
1296 gnttab_end_foreign_access(queue->grant_tx_ref[i], in xennet_release_tx_bufs()
1298 (unsigned long)page_address(queue->grant_tx_page[i])); in xennet_release_tx_bufs()
1299 queue->grant_tx_page[i] = NULL; in xennet_release_tx_bufs()
1300 queue->grant_tx_ref[i] = GRANT_INVALID_REF; in xennet_release_tx_bufs()
1301 add_id_to_freelist(&queue->tx_skb_freelist, queue->tx_skbs, i); in xennet_release_tx_bufs()
1310 spin_lock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1316 skb = queue->rx_skbs[id]; in xennet_release_rx_bufs()
1320 ref = queue->grant_rx_ref[id]; in xennet_release_rx_bufs()
1324 page = skb_frag_page(&skb_shinfo(skb)->frags[0]); in xennet_release_rx_bufs()
1332 queue->grant_rx_ref[id] = GRANT_INVALID_REF; in xennet_release_rx_bufs()
1337 spin_unlock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1346 !xenbus_read_unsigned(np->xbdev->otherend, "feature-sg", 0)) in xennet_fix_features()
1350 !xenbus_read_unsigned(np->xbdev->otherend, in xennet_fix_features()
1351 "feature-ipv6-csum-offload", 0)) in xennet_fix_features()
1355 !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv4", 0)) in xennet_fix_features()
1359 !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv6", 0)) in xennet_fix_features()
1368 if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) { in xennet_set_features()
1370 dev->mtu = ETH_DATA_LEN; in xennet_set_features()
1381 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_tx_interrupt()
1383 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_tx_interrupt()
1391 struct net_device *dev = queue->info->netdev; in xennet_rx_interrupt()
1394 RING_HAS_UNCONSUMED_RESPONSES(&queue->rx))) in xennet_rx_interrupt()
1395 napi_schedule(&queue->napi); in xennet_rx_interrupt()
1412 unsigned int num_queues = dev->real_num_tx_queues; in xennet_poll_controller()
1415 xennet_interrupt(0, &info->queues[i]); in xennet_poll_controller()
1428 err = xenbus_printf(XBT_NIL, np->xbdev->nodename, in talk_to_netback_xdp()
1429 "xdp-headroom", "%hu", in talk_to_netback_xdp()
1432 pr_warn("Error writing xdp-headroom\n"); in talk_to_netback_xdp()
1440 unsigned long max_mtu = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM; in xennet_xdp_set()
1445 if (dev->mtu > max_mtu) { in xennet_xdp_set()
1447 return -EINVAL; in xennet_xdp_set()
1450 if (!np->netback_has_xdp_headroom) in xennet_xdp_set()
1453 xenbus_switch_state(np->xbdev, XenbusStateReconfiguring); in xennet_xdp_set()
1462 xenbus_read_driver_state(np->xbdev->otherend) == in xennet_xdp_set()
1464 np->netfront_xdp_enabled = true; in xennet_xdp_set()
1466 old_prog = rtnl_dereference(np->queues[0].xdp_prog); in xennet_xdp_set()
1469 bpf_prog_add(prog, dev->real_num_tx_queues); in xennet_xdp_set()
1471 for (i = 0; i < dev->real_num_tx_queues; ++i) in xennet_xdp_set()
1472 rcu_assign_pointer(np->queues[i].xdp_prog, prog); in xennet_xdp_set()
1475 for (i = 0; i < dev->real_num_tx_queues; ++i) in xennet_xdp_set()
1478 xenbus_switch_state(np->xbdev, XenbusStateConnected); in xennet_xdp_set()
1485 switch (xdp->command) { in xennet_xdp()
1487 return xennet_xdp_set(dev, xdp->prog, xdp->extack); in xennet_xdp()
1489 return -EINVAL; in xennet_xdp()
1515 free_percpu(np->rx_stats); in xennet_free_netdev()
1516 free_percpu(np->tx_stats); in xennet_free_netdev()
1528 return ERR_PTR(-ENOMEM); in xennet_create_dev()
1531 np->xbdev = dev; in xennet_create_dev()
1533 np->queues = NULL; in xennet_create_dev()
1535 err = -ENOMEM; in xennet_create_dev()
1536 np->rx_stats = netdev_alloc_pcpu_stats(struct netfront_stats); in xennet_create_dev()
1537 if (np->rx_stats == NULL) in xennet_create_dev()
1539 np->tx_stats = netdev_alloc_pcpu_stats(struct netfront_stats); in xennet_create_dev()
1540 if (np->tx_stats == NULL) in xennet_create_dev()
1543 netdev->netdev_ops = &xennet_netdev_ops; in xennet_create_dev()
1545 netdev->features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM | in xennet_create_dev()
1547 netdev->hw_features = NETIF_F_SG | in xennet_create_dev()
1553 * will be adjusted by the call to netdev_update_features() in in xennet_create_dev()
1557 netdev->features |= netdev->hw_features; in xennet_create_dev()
1559 netdev->ethtool_ops = &xennet_ethtool_ops; in xennet_create_dev()
1560 netdev->min_mtu = ETH_MIN_MTU; in xennet_create_dev()
1561 netdev->max_mtu = XEN_NETIF_MAX_TX_SIZE; in xennet_create_dev()
1562 SET_NETDEV_DEV(netdev, &dev->dev); in xennet_create_dev()
1564 np->netdev = netdev; in xennet_create_dev()
1565 np->netfront_xdp_enabled = false; in xennet_create_dev()
1572 xenbus_read_driver_state(dev->otherend) != in xennet_create_dev()
1574 xenbus_read_driver_state(dev->otherend) != in xennet_create_dev()
1586 * Entry point to this code when a new device is created. Allocate the basic
1605 dev_set_drvdata(&dev->dev, info); in netfront_probe()
1607 info->netdev->sysfs_groups[0] = &xennet_dev_group; in netfront_probe()
1615 /* This frees the page as a side-effect */ in xennet_end_access()
1623 unsigned int num_queues = info->netdev->real_num_tx_queues; in xennet_disconnect_backend()
1625 netif_carrier_off(info->netdev); in xennet_disconnect_backend()
1627 for (i = 0; i < num_queues && info->queues; ++i) { in xennet_disconnect_backend()
1628 struct netfront_queue *queue = &info->queues[i]; in xennet_disconnect_backend()
1630 del_timer_sync(&queue->rx_refill_timer); in xennet_disconnect_backend()
1632 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) in xennet_disconnect_backend()
1633 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1634 if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { in xennet_disconnect_backend()
1635 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1636 unbind_from_irqhandler(queue->rx_irq, queue); in xennet_disconnect_backend()
1638 queue->tx_evtchn = queue->rx_evtchn = 0; in xennet_disconnect_backend()
1639 queue->tx_irq = queue->rx_irq = 0; in xennet_disconnect_backend()
1641 if (netif_running(info->netdev)) in xennet_disconnect_backend()
1642 napi_synchronize(&queue->napi); in xennet_disconnect_backend()
1646 gnttab_free_grant_references(queue->gref_tx_head); in xennet_disconnect_backend()
1647 gnttab_free_grant_references(queue->gref_rx_head); in xennet_disconnect_backend()
1650 xennet_end_access(queue->tx_ring_ref, queue->tx.sring); in xennet_disconnect_backend()
1651 xennet_end_access(queue->rx_ring_ref, queue->rx.sring); in xennet_disconnect_backend()
1653 queue->tx_ring_ref = GRANT_INVALID_REF; in xennet_disconnect_backend()
1654 queue->rx_ring_ref = GRANT_INVALID_REF; in xennet_disconnect_backend()
1655 queue->tx.sring = NULL; in xennet_disconnect_backend()
1656 queue->rx.sring = NULL; in xennet_disconnect_backend()
1658 page_pool_destroy(queue->page_pool); in xennet_disconnect_backend()
1663 * We are reconnecting to the backend, due to a suspend/resume, or a backend
1665 * leave the device-layer structures intact so that this is transparent to the
1670 struct netfront_info *info = dev_get_drvdata(&dev->dev); in netfront_resume()
1672 dev_dbg(&dev->dev, "%s\n", dev->nodename); in netfront_resume()
1683 macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL); in xen_net_read_mac()
1689 if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) { in xen_net_read_mac()
1691 return -ENOENT; in xen_net_read_mac()
1704 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_single()
1708 err = bind_evtchn_to_irqhandler(queue->tx_evtchn, in setup_netfront_single()
1710 0, queue->info->netdev->name, queue); in setup_netfront_single()
1713 queue->rx_evtchn = queue->tx_evtchn; in setup_netfront_single()
1714 queue->rx_irq = queue->tx_irq = err; in setup_netfront_single()
1719 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_single()
1720 queue->tx_evtchn = 0; in setup_netfront_single()
1729 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_split()
1732 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->rx_evtchn); in setup_netfront_split()
1736 snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), in setup_netfront_split()
1737 "%s-tx", queue->name); in setup_netfront_split()
1738 err = bind_evtchn_to_irqhandler(queue->tx_evtchn, in setup_netfront_split()
1740 0, queue->tx_irq_name, queue); in setup_netfront_split()
1743 queue->tx_irq = err; in setup_netfront_split()
1745 snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), in setup_netfront_split()
1746 "%s-rx", queue->name); in setup_netfront_split()
1747 err = bind_evtchn_to_irqhandler(queue->rx_evtchn, in setup_netfront_split()
1749 0, queue->rx_irq_name, queue); in setup_netfront_split()
1752 queue->rx_irq = err; in setup_netfront_split()
1757 unbind_from_irqhandler(queue->tx_irq, queue); in setup_netfront_split()
1758 queue->tx_irq = 0; in setup_netfront_split()
1760 xenbus_free_evtchn(queue->info->xbdev, queue->rx_evtchn); in setup_netfront_split()
1761 queue->rx_evtchn = 0; in setup_netfront_split()
1763 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_split()
1764 queue->tx_evtchn = 0; in setup_netfront_split()
1777 queue->tx_ring_ref = GRANT_INVALID_REF; in setup_netfront()
1778 queue->rx_ring_ref = GRANT_INVALID_REF; in setup_netfront()
1779 queue->rx.sring = NULL; in setup_netfront()
1780 queue->tx.sring = NULL; in setup_netfront()
1784 err = -ENOMEM; in setup_netfront()
1789 FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); in setup_netfront()
1794 queue->tx_ring_ref = gref; in setup_netfront()
1798 err = -ENOMEM; in setup_netfront()
1799 xenbus_dev_fatal(dev, err, "allocating rx ring page"); in setup_netfront()
1803 FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); in setup_netfront()
1808 queue->rx_ring_ref = gref; in setup_netfront()
1813 * a) feature-split-event-channels == 0 in setup_netfront()
1814 * b) feature-split-event-channels == 1 but failed to setup in setup_netfront()
1824 /* If we fail to setup netfront, it is safe to just revoke access to in setup_netfront()
1828 gnttab_end_foreign_access_ref(queue->rx_ring_ref, 0); in setup_netfront()
1832 gnttab_end_foreign_access_ref(queue->tx_ring_ref, 0); in setup_netfront()
1839 /* Queue-specific initialisation
1840 * This used to be done in xennet_create_dev() but must now
1841 * be run per-queue.
1849 spin_lock_init(&queue->tx_lock); in xennet_init_queue()
1850 spin_lock_init(&queue->rx_lock); in xennet_init_queue()
1852 timer_setup(&queue->rx_refill_timer, rx_refill_timeout, 0); in xennet_init_queue()
1854 devid = strrchr(queue->info->xbdev->nodename, '/') + 1; in xennet_init_queue()
1855 snprintf(queue->name, sizeof(queue->name), "vif%s-q%u", in xennet_init_queue()
1856 devid, queue->id); in xennet_init_queue()
1859 queue->tx_skb_freelist = 0; in xennet_init_queue()
1861 skb_entry_set_link(&queue->tx_skbs[i], i+1); in xennet_init_queue()
1862 queue->grant_tx_ref[i] = GRANT_INVALID_REF; in xennet_init_queue()
1863 queue->grant_tx_page[i] = NULL; in xennet_init_queue()
1868 queue->rx_skbs[i] = NULL; in xennet_init_queue()
1869 queue->grant_rx_ref[i] = GRANT_INVALID_REF; in xennet_init_queue()
1874 &queue->gref_tx_head) < 0) { in xennet_init_queue()
1876 err = -ENOMEM; in xennet_init_queue()
1880 /* A grant for every rx ring slot */ in xennet_init_queue()
1882 &queue->gref_rx_head) < 0) { in xennet_init_queue()
1883 pr_alert("can't alloc rx grant refs\n"); in xennet_init_queue()
1884 err = -ENOMEM; in xennet_init_queue()
1891 gnttab_free_grant_references(queue->gref_tx_head); in xennet_init_queue()
1899 /* Write the queue-specific keys into XenStore in the traditional in write_queue_xenstore_keys()
1901 * queues. in write_queue_xenstore_keys()
1903 struct xenbus_device *dev = queue->info->xbdev; in write_queue_xenstore_keys()
1909 /* Choose the correct place to write the keys */ in write_queue_xenstore_keys()
1911 pathsize = strlen(dev->nodename) + 10; in write_queue_xenstore_keys()
1914 err = -ENOMEM; in write_queue_xenstore_keys()
1918 snprintf(path, pathsize, "%s/queue-%u", in write_queue_xenstore_keys()
1919 dev->nodename, queue->id); in write_queue_xenstore_keys()
1921 path = (char *)dev->nodename; in write_queue_xenstore_keys()
1925 err = xenbus_printf(*xbt, path, "tx-ring-ref", "%u", in write_queue_xenstore_keys()
1926 queue->tx_ring_ref); in write_queue_xenstore_keys()
1928 message = "writing tx-ring-ref"; in write_queue_xenstore_keys()
1932 err = xenbus_printf(*xbt, path, "rx-ring-ref", "%u", in write_queue_xenstore_keys()
1933 queue->rx_ring_ref); in write_queue_xenstore_keys()
1935 message = "writing rx-ring-ref"; in write_queue_xenstore_keys()
1942 if (queue->tx_evtchn == queue->rx_evtchn) { in write_queue_xenstore_keys()
1945 "event-channel", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
1947 message = "writing event-channel"; in write_queue_xenstore_keys()
1953 "event-channel-tx", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
1955 message = "writing event-channel-tx"; in write_queue_xenstore_keys()
1960 "event-channel-rx", "%u", queue->rx_evtchn); in write_queue_xenstore_keys()
1962 message = "writing event-channel-rx"; in write_queue_xenstore_keys()
1982 for (i = 0; i < info->netdev->real_num_tx_queues; i++) { in xennet_destroy_queues()
1983 struct netfront_queue *queue = &info->queues[i]; in xennet_destroy_queues()
1985 if (netif_running(info->netdev)) in xennet_destroy_queues()
1986 napi_disable(&queue->napi); in xennet_destroy_queues()
1987 netif_napi_del(&queue->napi); in xennet_destroy_queues()
1990 kfree(info->queues); in xennet_destroy_queues()
1991 info->queues = NULL; in xennet_destroy_queues()
2004 .dev = &queue->info->netdev->dev, in xennet_create_page_pool()
2006 .max_len = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM, in xennet_create_page_pool()
2009 queue->page_pool = page_pool_create(&pp_params); in xennet_create_page_pool()
2010 if (IS_ERR(queue->page_pool)) { in xennet_create_page_pool()
2011 err = PTR_ERR(queue->page_pool); in xennet_create_page_pool()
2012 queue->page_pool = NULL; in xennet_create_page_pool()
2016 err = xdp_rxq_info_reg(&queue->xdp_rxq, queue->info->netdev, in xennet_create_page_pool()
2017 queue->id); in xennet_create_page_pool()
2019 netdev_err(queue->info->netdev, "xdp_rxq_info_reg failed\n"); in xennet_create_page_pool()
2023 err = xdp_rxq_info_reg_mem_model(&queue->xdp_rxq, in xennet_create_page_pool()
2024 MEM_TYPE_PAGE_POOL, queue->page_pool); in xennet_create_page_pool()
2026 netdev_err(queue->info->netdev, "xdp_rxq_info_reg_mem_model failed\n"); in xennet_create_page_pool()
2032 xdp_rxq_info_unreg(&queue->xdp_rxq); in xennet_create_page_pool()
2034 page_pool_destroy(queue->page_pool); in xennet_create_page_pool()
2035 queue->page_pool = NULL; in xennet_create_page_pool()
2045 info->queues = kcalloc(*num_queues, sizeof(struct netfront_queue), in xennet_create_queues()
2047 if (!info->queues) in xennet_create_queues()
2048 return -ENOMEM; in xennet_create_queues()
2051 struct netfront_queue *queue = &info->queues[i]; in xennet_create_queues()
2053 queue->id = i; in xennet_create_queues()
2054 queue->info = info; in xennet_create_queues()
2058 dev_warn(&info->xbdev->dev, in xennet_create_queues()
2059 "only created %d queues\n", i); in xennet_create_queues()
2064 /* use page pool recycling instead of buddy allocator */ in xennet_create_queues()
2067 dev_err(&info->xbdev->dev, "can't allocate page pool\n"); in xennet_create_queues()
2072 netif_napi_add(queue->info->netdev, &queue->napi, in xennet_create_queues()
2074 if (netif_running(info->netdev)) in xennet_create_queues()
2075 napi_enable(&queue->napi); in xennet_create_queues()
2078 netif_set_real_num_tx_queues(info->netdev, *num_queues); in xennet_create_queues()
2081 dev_err(&info->xbdev->dev, "no queues\n"); in xennet_create_queues()
2082 return -EINVAL; in xennet_create_queues()
2100 info->netdev->irq = 0; in talk_to_netback()
2102 /* Check if backend supports multiple queues */ in talk_to_netback()
2103 max_queues = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2104 "multi-queue-max-queues", 1); in talk_to_netback()
2107 /* Check feature-split-event-channels */ in talk_to_netback()
2108 feature_split_evtchn = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2109 "feature-split-event-channels", 0); in talk_to_netback()
2112 err = xen_net_read_mac(dev, info->netdev->dev_addr); in talk_to_netback()
2114 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); in talk_to_netback()
2118 info->netback_has_xdp_headroom = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2119 "feature-xdp-headroom", 0); in talk_to_netback()
2120 if (info->netback_has_xdp_headroom) { in talk_to_netback()
2121 /* set the current xen-netfront xdp state */ in talk_to_netback()
2122 err = talk_to_netback_xdp(info, info->netfront_xdp_enabled ? in talk_to_netback()
2130 if (info->queues) in talk_to_netback()
2135 xenbus_dev_fatal(dev, err, "creating queues"); in talk_to_netback()
2136 kfree(info->queues); in talk_to_netback()
2137 info->queues = NULL; in talk_to_netback()
2142 /* Create shared ring, alloc event channel -- for each queue */ in talk_to_netback()
2144 queue = &info->queues[i]; in talk_to_netback()
2158 info->xbdev->otherend, "multi-queue-max-queues")) { in talk_to_netback()
2159 /* Write the number of queues */ in talk_to_netback()
2160 err = xenbus_printf(xbt, dev->nodename, in talk_to_netback()
2161 "multi-queue-num-queues", "%u", num_queues); in talk_to_netback()
2163 message = "writing multi-queue-num-queues"; in talk_to_netback()
2169 err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */ in talk_to_netback()
2175 queue = &info->queues[i]; in talk_to_netback()
2182 /* The remaining keys are not queue-specific */ in talk_to_netback()
2183 err = xenbus_printf(xbt, dev->nodename, "request-rx-copy", "%u", in talk_to_netback()
2186 message = "writing request-rx-copy"; in talk_to_netback()
2190 err = xenbus_printf(xbt, dev->nodename, "feature-rx-notify", "%d", 1); in talk_to_netback()
2192 message = "writing feature-rx-notify"; in talk_to_netback()
2196 err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", 1); in talk_to_netback()
2198 message = "writing feature-sg"; in talk_to_netback()
2202 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1); in talk_to_netback()
2204 message = "writing feature-gso-tcpv4"; in talk_to_netback()
2208 err = xenbus_write(xbt, dev->nodename, "feature-gso-tcpv6", "1"); in talk_to_netback()
2210 message = "writing feature-gso-tcpv6"; in talk_to_netback()
2214 err = xenbus_write(xbt, dev->nodename, "feature-ipv6-csum-offload", in talk_to_netback()
2217 message = "writing feature-ipv6-csum-offload"; in talk_to_netback()
2223 if (err == -EAGAIN) in talk_to_netback()
2242 device_unregister(&dev->dev); in talk_to_netback()
2254 if (!xenbus_read_unsigned(np->xbdev->otherend, "feature-rx-copy", 0)) { in xennet_connect()
2255 dev_info(&dev->dev, in xennet_connect()
2257 return -ENODEV; in xennet_connect()
2260 err = talk_to_netback(np->xbdev, np); in xennet_connect()
2263 if (np->netback_has_xdp_headroom) in xennet_connect()
2266 /* talk_to_netback() sets the correct number of queues */ in xennet_connect()
2267 num_queues = dev->real_num_tx_queues; in xennet_connect()
2269 if (dev->reg_state == NETREG_UNINITIALIZED) { in xennet_connect()
2273 device_unregister(&np->xbdev->dev); in xennet_connect()
2284 * ready to start sending and receiving packets and give the driver in xennet_connect()
2288 netif_carrier_on(np->netdev); in xennet_connect()
2290 queue = &np->queues[j]; in xennet_connect()
2292 notify_remote_via_irq(queue->tx_irq); in xennet_connect()
2293 if (queue->tx_irq != queue->rx_irq) in xennet_connect()
2294 notify_remote_via_irq(queue->rx_irq); in xennet_connect()
2296 spin_lock_irq(&queue->tx_lock); in xennet_connect()
2298 spin_unlock_irq(&queue->tx_lock); in xennet_connect()
2300 spin_lock_bh(&queue->rx_lock); in xennet_connect()
2302 spin_unlock_bh(&queue->rx_lock); in xennet_connect()
2314 struct netfront_info *np = dev_get_drvdata(&dev->dev); in netback_changed()
2315 struct net_device *netdev = np->netdev; in netback_changed()
2317 dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state)); in netback_changed()
2330 if (dev->state != XenbusStateInitialising) in netback_changed()
2342 if (dev->state == XenbusStateClosed) in netback_changed()
2367 return -EINVAL; in xennet_get_sset_count()
2419 return -EPERM; in store_rxbuf()
2423 return -EBADMSG; in store_rxbuf()
2450 if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) in xennet_bus_close()
2455 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2457 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2459 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2464 if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) in xennet_bus_close()
2470 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2472 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2480 struct netfront_info *info = dev_get_drvdata(&dev->dev); in xennet_remove()
2485 if (info->netdev->reg_state == NETREG_REGISTERED) in xennet_remove()
2486 unregister_netdev(info->netdev); in xennet_remove()
2488 if (info->queues) { in xennet_remove()
2493 xennet_free_netdev(info->netdev); in xennet_remove()
2514 return -ENODEV; in netif_init()
2517 return -ENODEV; in netif_init()
2521 /* Allow as many queues as there are CPUs inut max. 8 if user has not in netif_init()