Lines Matching +full:tx +full:- +full:hw +full:- +full:gso +full:- +full:packets
4 * Copyright (c) 2002-2005, K A Fraser
81 #define NETFRONT_SKB_CB(skb) ((struct netfront_cb *)((skb)->cb))
88 /* Minimum number of Rx slots (includes slot for GSO metadata). */
91 /* Queue name is interface name with "-qNNN" appended */
94 /* IRQ name is queue name with "-tx" or "-rx" appended */
100 u64 packets; member
108 unsigned int id; /* Queue ID, 0-based */
109 char name[QUEUE_NAME_SIZE]; /* DEVNAME-qN */
122 char tx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-tx */
123 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */
126 struct xen_netif_tx_front_ring tx; member
130 * {tx,rx}_skbs store outstanding skbuffs. Free tx_skb entries
166 /* Multi-queue support */
188 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1];
215 return idx & (NET_RX_RING_SIZE - 1); in xennet_rxidx()
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()
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()
242 return dev->features & NETIF_F_SG; in xennet_can_sg()
249 napi_schedule(&queue->napi); in rx_refill_timeout()
254 return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) < in netfront_tx_slot_available()
255 (NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1); in netfront_tx_slot_available()
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()
266 netif_tx_wake_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_maybe_wake_tx()
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()
292 skb->dev = queue->info->netdev; in xennet_alloc_one_rx_buffer()
300 RING_IDX req_prod = queue->rx.req_prod_pvt; in xennet_alloc_rx_buffers()
304 if (unlikely(!netif_carrier_ok(queue->info->netdev))) in xennet_alloc_rx_buffers()
307 for (req_prod = queue->rx.req_prod_pvt; in xennet_alloc_rx_buffers()
308 req_prod - queue->rx.rsp_cons < NET_RX_RING_SIZE; in xennet_alloc_rx_buffers()
318 err = -ENOMEM; in xennet_alloc_rx_buffers()
324 BUG_ON(queue->rx_skbs[id]); in xennet_alloc_rx_buffers()
325 queue->rx_skbs[id] = skb; in xennet_alloc_rx_buffers()
327 ref = gnttab_claim_grant_reference(&queue->gref_rx_head); in xennet_alloc_rx_buffers()
329 queue->grant_rx_ref[id] = ref; in xennet_alloc_rx_buffers()
331 page = skb_frag_page(&skb_shinfo(skb)->frags[0]); in xennet_alloc_rx_buffers()
333 req = RING_GET_REQUEST(&queue->rx, req_prod); in xennet_alloc_rx_buffers()
335 queue->info->xbdev->otherend_id, in xennet_alloc_rx_buffers()
338 req->id = id; in xennet_alloc_rx_buffers()
339 req->gref = ref; in xennet_alloc_rx_buffers()
342 queue->rx.req_prod_pvt = req_prod; in xennet_alloc_rx_buffers()
349 if (req_prod - queue->rx.rsp_cons < NET_RX_SLOTS_MIN || in xennet_alloc_rx_buffers()
351 mod_timer(&queue->rx_refill_timer, jiffies + (HZ/10)); in xennet_alloc_rx_buffers()
355 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->rx, notify); in xennet_alloc_rx_buffers()
357 notify_remote_via_irq(queue->rx_irq); in xennet_alloc_rx_buffers()
363 unsigned int num_queues = dev->real_num_tx_queues; in xennet_open()
367 if (!np->queues || np->broken) in xennet_open()
368 return -ENODEV; in xennet_open()
371 queue = &np->queues[i]; in xennet_open()
372 napi_enable(&queue->napi); in xennet_open()
374 spin_lock_bh(&queue->rx_lock); in xennet_open()
377 queue->rx.sring->rsp_event = queue->rx.rsp_cons + 1; in xennet_open()
378 if (RING_HAS_UNCONSUMED_RESPONSES(&queue->rx)) in xennet_open()
379 napi_schedule(&queue->napi); in xennet_open()
381 spin_unlock_bh(&queue->rx_lock); in xennet_open()
396 const struct device *dev = &queue->info->netdev->dev; in xennet_tx_buf_gc()
398 BUG_ON(!netif_carrier_ok(queue->info->netdev)); in xennet_tx_buf_gc()
401 prod = queue->tx.sring->rsp_prod; in xennet_tx_buf_gc()
402 if (RING_RESPONSE_PROD_OVERFLOW(&queue->tx, prod)) { in xennet_tx_buf_gc()
404 prod - queue->tx.rsp_cons); in xennet_tx_buf_gc()
409 for (cons = queue->tx.rsp_cons; cons != prod; cons++) { in xennet_tx_buf_gc()
414 RING_COPY_RESPONSE(&queue->tx, cons, &txrsp); in xennet_tx_buf_gc()
419 if (id >= RING_SIZE(&queue->tx)) { in xennet_tx_buf_gc()
425 if (queue->tx_link[id] != TX_PENDING) { in xennet_tx_buf_gc()
431 queue->tx_link[id] = TX_LINK_NONE; in xennet_tx_buf_gc()
432 skb = queue->tx_skbs[id]; in xennet_tx_buf_gc()
433 queue->tx_skbs[id] = NULL; in xennet_tx_buf_gc()
435 queue->grant_tx_ref[id]))) { in xennet_tx_buf_gc()
441 &queue->gref_tx_head, queue->grant_tx_ref[id]); in xennet_tx_buf_gc()
442 queue->grant_tx_ref[id] = INVALID_GRANT_REF; in xennet_tx_buf_gc()
443 queue->grant_tx_page[id] = NULL; in xennet_tx_buf_gc()
444 add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id); in xennet_tx_buf_gc()
448 queue->tx.rsp_cons = prod; in xennet_tx_buf_gc()
450 RING_FINAL_CHECK_FOR_RESPONSES(&queue->tx, more_to_do); in xennet_tx_buf_gc()
458 queue->info->broken = true; in xennet_tx_buf_gc()
468 struct xen_netif_tx_request *tx; /* Last request on ring page */ member
478 struct xen_netif_tx_request *tx; in xennet_tx_setup_grant() local
481 struct page *page = info->page; in xennet_tx_setup_grant()
482 struct netfront_queue *queue = info->queue; in xennet_tx_setup_grant()
483 struct sk_buff *skb = info->skb; in xennet_tx_setup_grant()
485 id = get_id_from_list(&queue->tx_skb_freelist, queue->tx_link); in xennet_tx_setup_grant()
486 tx = RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_tx_setup_grant()
487 ref = gnttab_claim_grant_reference(&queue->gref_tx_head); in xennet_tx_setup_grant()
490 gnttab_grant_foreign_access_ref(ref, queue->info->xbdev->otherend_id, in xennet_tx_setup_grant()
493 queue->tx_skbs[id] = skb; in xennet_tx_setup_grant()
494 queue->grant_tx_page[id] = page; in xennet_tx_setup_grant()
495 queue->grant_tx_ref[id] = ref; in xennet_tx_setup_grant()
497 info->tx_local.id = id; in xennet_tx_setup_grant()
498 info->tx_local.gref = ref; in xennet_tx_setup_grant()
499 info->tx_local.offset = offset; in xennet_tx_setup_grant()
500 info->tx_local.size = len; in xennet_tx_setup_grant()
501 info->tx_local.flags = 0; in xennet_tx_setup_grant()
503 *tx = info->tx_local; in xennet_tx_setup_grant()
509 add_id_to_list(&queue->tx_pend_queue, queue->tx_link, id); in xennet_tx_setup_grant()
511 info->tx = tx; in xennet_tx_setup_grant()
512 info->size += info->tx_local.size; in xennet_tx_setup_grant()
519 info->size = 0; in xennet_make_first_txreq()
521 gnttab_for_one_grant(info->page, offset, len, xennet_tx_setup_grant, info); in xennet_make_first_txreq()
523 return info->tx; in xennet_make_first_txreq()
531 info->tx->flags |= XEN_NETTXF_more_data; in xennet_make_one_txreq()
532 skb_get(info->skb); in xennet_make_one_txreq()
546 info->page = page; in xennet_make_txreqs()
547 info->size = 0; in xennet_make_txreqs()
555 len -= info->size; in xennet_make_txreqs()
565 int i, frags = skb_shinfo(skb)->nr_frags; in xennet_count_skb_slots()
568 slots = gnttab_count_grant(offset_in_page(skb->data), in xennet_count_skb_slots()
572 skb_frag_t *frag = skb_shinfo(skb)->frags + i; in xennet_count_skb_slots()
588 unsigned int num_queues = dev->real_num_tx_queues; in xennet_select_queue()
607 while ((i = get_id_from_list(&queue->tx_pend_queue, queue->tx_link)) != in xennet_mark_tx_pending()
609 queue->tx_link[i] = TX_PENDING; in xennet_mark_tx_pending()
617 struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats); in xennet_xdp_xmit_one()
621 .page = virt_to_page(xdpf->data), in xennet_xdp_xmit_one()
626 offset_in_page(xdpf->data), in xennet_xdp_xmit_one()
627 xdpf->len); in xennet_xdp_xmit_one()
631 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_xdp_xmit_one()
633 notify_remote_via_irq(queue->tx_irq); in xennet_xdp_xmit_one()
635 u64_stats_update_begin(&tx_stats->syncp); in xennet_xdp_xmit_one()
636 tx_stats->bytes += xdpf->len; in xennet_xdp_xmit_one()
637 tx_stats->packets++; in xennet_xdp_xmit_one()
638 u64_stats_update_end(&tx_stats->syncp); in xennet_xdp_xmit_one()
648 unsigned int num_queues = dev->real_num_tx_queues; in xennet_xdp_xmit()
655 if (unlikely(np->broken)) in xennet_xdp_xmit()
656 return -ENODEV; in xennet_xdp_xmit()
658 return -EINVAL; in xennet_xdp_xmit()
660 queue = &np->queues[smp_processor_id() % num_queues]; in xennet_xdp_xmit()
662 spin_lock_irqsave(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
672 spin_unlock_irqrestore(&queue->tx_lock, irq_flags); in xennet_xdp_xmit()
681 unsigned int size = ALIGN(skb_end_offset(skb) + skb->data_len, in bounce_skb()
688 if (!IS_ALIGNED((uintptr_t)n->head, XEN_PAGE_SIZE)) { in bounce_skb()
697 skb_put(n, skb->len); in bounce_skb()
699 BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len)); in bounce_skb()
710 struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats); in xennet_start_xmit()
721 unsigned int num_queues = dev->real_num_tx_queues; in xennet_start_xmit()
728 if (unlikely(np->broken)) in xennet_start_xmit()
732 queue = &np->queues[queue_index]; in xennet_start_xmit()
734 /* If skb->len is too big for wire format, drop skb and alert in xennet_start_xmit()
737 if (unlikely(skb->len > XEN_NETIF_MAX_TX_SIZE)) { in xennet_start_xmit()
739 "xennet: skb->len = %u, too big for wire format\n", in xennet_start_xmit()
740 skb->len); in xennet_start_xmit()
747 slots, skb->len); in xennet_start_xmit()
752 page = virt_to_page(skb->data); in xennet_start_xmit()
753 offset = offset_in_page(skb->data); in xennet_start_xmit()
762 if (np->bounce || unlikely(PAGE_SIZE - offset < ETH_HLEN)) { in xennet_start_xmit()
768 page = virt_to_page(skb->data); in xennet_start_xmit()
769 offset = offset_in_page(skb->data); in xennet_start_xmit()
774 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_start_xmit()
779 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
793 len -= info.tx_local.size; in xennet_start_xmit()
795 if (skb->ip_summed == CHECKSUM_PARTIAL) in xennet_start_xmit()
797 first_tx->flags |= XEN_NETTXF_csum_blank | in xennet_start_xmit()
799 else if (skb->ip_summed == CHECKSUM_UNNECESSARY) in xennet_start_xmit()
801 first_tx->flags |= XEN_NETTXF_data_validated; in xennet_start_xmit()
804 if (skb_shinfo(skb)->gso_size) { in xennet_start_xmit()
805 struct xen_netif_extra_info *gso; in xennet_start_xmit() local
807 gso = (struct xen_netif_extra_info *) in xennet_start_xmit()
808 RING_GET_REQUEST(&queue->tx, queue->tx.req_prod_pvt++); in xennet_start_xmit()
810 first_tx->flags |= XEN_NETTXF_extra_info; in xennet_start_xmit()
812 gso->u.gso.size = skb_shinfo(skb)->gso_size; in xennet_start_xmit()
813 gso->u.gso.type = (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) ? in xennet_start_xmit()
816 gso->u.gso.pad = 0; in xennet_start_xmit()
817 gso->u.gso.features = 0; in xennet_start_xmit()
819 gso->type = XEN_NETIF_EXTRA_TYPE_GSO; in xennet_start_xmit()
820 gso->flags = 0; in xennet_start_xmit()
827 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { in xennet_start_xmit()
828 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; in xennet_start_xmit()
835 first_tx->size = skb->len; in xennet_start_xmit()
842 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify); in xennet_start_xmit()
844 notify_remote_via_irq(queue->tx_irq); in xennet_start_xmit()
846 u64_stats_update_begin(&tx_stats->syncp); in xennet_start_xmit()
847 tx_stats->bytes += skb->len; in xennet_start_xmit()
848 tx_stats->packets++; in xennet_start_xmit()
849 u64_stats_update_end(&tx_stats->syncp); in xennet_start_xmit()
855 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id)); in xennet_start_xmit()
857 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_start_xmit()
862 dev->stats.tx_dropped++; in xennet_start_xmit()
870 unsigned int num_queues = np->queues ? dev->real_num_tx_queues : 0; in xennet_close()
873 netif_tx_stop_all_queues(np->netdev); in xennet_close()
875 queue = &np->queues[i]; in xennet_close()
876 napi_disable(&queue->napi); in xennet_close()
885 if (!info->queues) in xennet_destroy_queues()
888 for (i = 0; i < info->netdev->real_num_tx_queues; i++) { in xennet_destroy_queues()
889 struct netfront_queue *queue = &info->queues[i]; in xennet_destroy_queues()
891 if (netif_running(info->netdev)) in xennet_destroy_queues()
892 napi_disable(&queue->napi); in xennet_destroy_queues()
893 netif_napi_del(&queue->napi); in xennet_destroy_queues()
896 kfree(info->queues); in xennet_destroy_queues()
897 info->queues = NULL; in xennet_destroy_queues()
910 spin_lock_irqsave(&queue->rx_cons_lock, flags); in xennet_set_rx_rsp_cons()
911 queue->rx.rsp_cons = val; in xennet_set_rx_rsp_cons()
912 queue->rx_rsp_unconsumed = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); in xennet_set_rx_rsp_cons()
913 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_set_rx_rsp_cons()
919 int new = xennet_rxidx(queue->rx.req_prod_pvt); in xennet_move_rx_slot()
921 BUG_ON(queue->rx_skbs[new]); in xennet_move_rx_slot()
922 queue->rx_skbs[new] = skb; in xennet_move_rx_slot()
923 queue->grant_rx_ref[new] = ref; in xennet_move_rx_slot()
924 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->id = new; in xennet_move_rx_slot()
925 RING_GET_REQUEST(&queue->rx, queue->rx.req_prod_pvt)->gref = ref; in xennet_move_rx_slot()
926 queue->rx.req_prod_pvt++; in xennet_move_rx_slot()
935 struct device *dev = &queue->info->netdev->dev; in xennet_get_extras()
936 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_extras()
946 err = -EBADR; in xennet_get_extras()
950 RING_COPY_RESPONSE(&queue->rx, ++cons, &extra); in xennet_get_extras()
957 err = -EINVAL; in xennet_get_extras()
959 extras[extra.type - 1] = extra; in xennet_get_extras()
976 u32 len = rx->status; in xennet_run_xdp()
980 xdp_init_buff(xdp, XEN_PAGE_SIZE - XDP_PACKET_HEADROOM, in xennet_run_xdp()
981 &queue->xdp_rxq); in xennet_run_xdp()
990 err = xennet_xdp_xmit(queue->info->netdev, 1, &xdpf, 0); in xennet_run_xdp()
994 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
998 err = xdp_do_redirect(queue->info->netdev, xdp, prog); in xennet_run_xdp()
1001 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
1008 trace_xdp_exception(queue->info->netdev, prog, act); in xennet_run_xdp()
1012 bpf_warn_invalid_xdp_action(queue->info->netdev, prog, act); in xennet_run_xdp()
1023 struct xen_netif_rx_response *rx = &rinfo->rx, rx_local; in xennet_get_responses()
1024 int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD); in xennet_get_responses()
1025 RING_IDX cons = queue->rx.rsp_cons; in xennet_get_responses()
1027 struct xen_netif_extra_info *extras = rinfo->extras; in xennet_get_responses()
1029 struct device *dev = &queue->info->netdev->dev; in xennet_get_responses()
1036 if (rx->flags & XEN_NETRXF_extra_info) { in xennet_get_responses()
1039 if (extras[XEN_NETIF_EXTRA_TYPE_XDP - 1].type) { in xennet_get_responses()
1042 xdp = &extras[XEN_NETIF_EXTRA_TYPE_XDP - 1]; in xennet_get_responses()
1043 rx->offset = xdp->u.xdp.headroom; in xennet_get_responses()
1046 cons = queue->rx.rsp_cons; in xennet_get_responses()
1058 rx->id); in xennet_get_responses()
1059 err = -EINVAL; in xennet_get_responses()
1063 if (unlikely(rx->status < 0 || in xennet_get_responses()
1064 rx->offset + rx->status > XEN_PAGE_SIZE)) { in xennet_get_responses()
1066 dev_warn(dev, "rx->offset: %u, size: %d\n", in xennet_get_responses()
1067 rx->offset, rx->status); in xennet_get_responses()
1069 err = -EINVAL; in xennet_get_responses()
1076 queue->info->broken = true; in xennet_get_responses()
1078 return -EINVAL; in xennet_get_responses()
1081 gnttab_release_grant_reference(&queue->gref_rx_head, ref); in xennet_get_responses()
1084 xdp_prog = rcu_dereference(queue->xdp_prog); in xennet_get_responses()
1086 if (!(rx->flags & XEN_NETRXF_more_data)) { in xennet_get_responses()
1089 skb_frag_page(&skb_shinfo(skb)->frags[0]), in xennet_get_responses()
1092 err = -EINVAL; in xennet_get_responses()
1095 err = -EINVAL; in xennet_get_responses()
1103 if (!(rx->flags & XEN_NETRXF_more_data)) in xennet_get_responses()
1109 err = -ENOENT; in xennet_get_responses()
1113 RING_COPY_RESPONSE(&queue->rx, cons + slots, &rx_local); in xennet_get_responses()
1123 err = -E2BIG; in xennet_get_responses()
1133 struct xen_netif_extra_info *gso) in xennet_set_skb_gso() argument
1135 if (!gso->u.gso.size) { in xennet_set_skb_gso()
1137 pr_warn("GSO size must not be zero\n"); in xennet_set_skb_gso()
1138 return -EINVAL; in xennet_set_skb_gso()
1141 if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4 && in xennet_set_skb_gso()
1142 gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV6) { in xennet_set_skb_gso()
1144 pr_warn("Bad GSO type %d\n", gso->u.gso.type); in xennet_set_skb_gso()
1145 return -EINVAL; in xennet_set_skb_gso()
1148 skb_shinfo(skb)->gso_size = gso->u.gso.size; in xennet_set_skb_gso()
1149 skb_shinfo(skb)->gso_type = in xennet_set_skb_gso()
1150 (gso->u.gso.type == XEN_NETIF_GSO_TYPE_TCPV4) ? in xennet_set_skb_gso()
1155 skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; in xennet_set_skb_gso()
1156 skb_shinfo(skb)->gso_segs = 0; in xennet_set_skb_gso()
1165 RING_IDX cons = queue->rx.rsp_cons; in xennet_fill_frags()
1170 skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0]; in xennet_fill_frags()
1172 RING_COPY_RESPONSE(&queue->rx, ++cons, &rx); in xennet_fill_frags()
1174 if (skb_shinfo(skb)->nr_frags == MAX_SKB_FRAGS) { in xennet_fill_frags()
1175 unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to; in xennet_fill_frags()
1178 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); in xennet_fill_frags()
1180 if (unlikely(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS)) { in xennet_fill_frags()
1184 return -ENOENT; in xennet_fill_frags()
1187 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, in xennet_fill_frags()
1191 skb_shinfo(nskb)->nr_frags = 0; in xennet_fill_frags()
1205 * A GSO SKB must be CHECKSUM_PARTIAL. However some buggy in checksum_setup()
1206 * peers can fail to set NETRXF_csum_blank when sending a GSO in checksum_setup()
1210 if (skb->ip_summed != CHECKSUM_PARTIAL && skb_is_gso(skb)) { in checksum_setup()
1212 atomic_inc(&np->rx_gso_checksum_fixup); in checksum_setup()
1213 skb->ip_summed = CHECKSUM_PARTIAL; in checksum_setup()
1217 /* A non-CHECKSUM_PARTIAL SKB does not require setup. */ in checksum_setup()
1218 if (skb->ip_summed != CHECKSUM_PARTIAL) in checksum_setup()
1227 struct netfront_stats *rx_stats = this_cpu_ptr(queue->info->rx_stats); in handle_incoming_queue()
1232 int pull_to = NETFRONT_SKB_CB(skb)->pull_to; in handle_incoming_queue()
1235 __pskb_pull_tail(skb, pull_to - skb_headlen(skb)); in handle_incoming_queue()
1238 skb->protocol = eth_type_trans(skb, queue->info->netdev); in handle_incoming_queue()
1241 if (checksum_setup(queue->info->netdev, skb)) { in handle_incoming_queue()
1244 queue->info->netdev->stats.rx_errors++; in handle_incoming_queue()
1248 u64_stats_update_begin(&rx_stats->syncp); in handle_incoming_queue()
1249 rx_stats->packets++; in handle_incoming_queue()
1250 rx_stats->bytes += skb->len; in handle_incoming_queue()
1251 u64_stats_update_end(&rx_stats->syncp); in handle_incoming_queue()
1254 napi_gro_receive(&queue->napi, skb); in handle_incoming_queue()
1263 struct net_device *dev = queue->info->netdev; in xennet_poll()
1276 spin_lock(&queue->rx_lock); in xennet_poll()
1282 rp = queue->rx.sring->rsp_prod; in xennet_poll()
1283 if (RING_RESPONSE_PROD_OVERFLOW(&queue->rx, rp)) { in xennet_poll()
1284 dev_alert(&dev->dev, "Illegal number of responses %u\n", in xennet_poll()
1285 rp - queue->rx.rsp_cons); in xennet_poll()
1286 queue->info->broken = true; in xennet_poll()
1287 spin_unlock(&queue->rx_lock); in xennet_poll()
1292 i = queue->rx.rsp_cons; in xennet_poll()
1295 RING_COPY_RESPONSE(&queue->rx, i, rx); in xennet_poll()
1302 if (queue->info->broken) { in xennet_poll()
1303 spin_unlock(&queue->rx_lock); in xennet_poll()
1309 dev->stats.rx_errors++; in xennet_poll()
1310 i = queue->rx.rsp_cons; in xennet_poll()
1316 if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) { in xennet_poll()
1317 struct xen_netif_extra_info *gso; in xennet_poll() local
1318 gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1]; in xennet_poll()
1320 if (unlikely(xennet_set_skb_gso(skb, gso))) { in xennet_poll()
1323 queue->rx.rsp_cons + in xennet_poll()
1329 NETFRONT_SKB_CB(skb)->pull_to = rx->status; in xennet_poll()
1330 if (NETFRONT_SKB_CB(skb)->pull_to > RX_COPY_THRESHOLD) in xennet_poll()
1331 NETFRONT_SKB_CB(skb)->pull_to = RX_COPY_THRESHOLD; in xennet_poll()
1333 skb_frag_off_set(&skb_shinfo(skb)->frags[0], rx->offset); in xennet_poll()
1334 skb_frag_size_set(&skb_shinfo(skb)->frags[0], rx->status); in xennet_poll()
1335 skb->data_len = rx->status; in xennet_poll()
1336 skb->len += rx->status; in xennet_poll()
1341 if (rx->flags & XEN_NETRXF_csum_blank) in xennet_poll()
1342 skb->ip_summed = CHECKSUM_PARTIAL; in xennet_poll()
1343 else if (rx->flags & XEN_NETRXF_data_validated) in xennet_poll()
1344 skb->ip_summed = CHECKSUM_UNNECESSARY; in xennet_poll()
1348 i = queue->rx.rsp_cons + 1; in xennet_poll()
1357 work_done -= handle_incoming_queue(queue, &rxq); in xennet_poll()
1366 RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do); in xennet_poll()
1371 spin_unlock(&queue->rx_lock); in xennet_poll()
1381 return -EINVAL; in xennet_change_mtu()
1382 WRITE_ONCE(dev->mtu, mtu); in xennet_change_mtu()
1393 struct netfront_stats *rx_stats = per_cpu_ptr(np->rx_stats, cpu); in xennet_get_stats64()
1394 struct netfront_stats *tx_stats = per_cpu_ptr(np->tx_stats, cpu); in xennet_get_stats64()
1399 start = u64_stats_fetch_begin(&tx_stats->syncp); in xennet_get_stats64()
1400 tx_packets = tx_stats->packets; in xennet_get_stats64()
1401 tx_bytes = tx_stats->bytes; in xennet_get_stats64()
1402 } while (u64_stats_fetch_retry(&tx_stats->syncp, start)); in xennet_get_stats64()
1405 start = u64_stats_fetch_begin(&rx_stats->syncp); in xennet_get_stats64()
1406 rx_packets = rx_stats->packets; in xennet_get_stats64()
1407 rx_bytes = rx_stats->bytes; in xennet_get_stats64()
1408 } while (u64_stats_fetch_retry(&rx_stats->syncp, start)); in xennet_get_stats64()
1410 tot->rx_packets += rx_packets; in xennet_get_stats64()
1411 tot->tx_packets += tx_packets; in xennet_get_stats64()
1412 tot->rx_bytes += rx_bytes; in xennet_get_stats64()
1413 tot->tx_bytes += tx_bytes; in xennet_get_stats64()
1416 tot->rx_errors = dev->stats.rx_errors; in xennet_get_stats64()
1417 tot->tx_dropped = dev->stats.tx_dropped; in xennet_get_stats64()
1427 if (!queue->tx_skbs[i]) in xennet_release_tx_bufs()
1430 skb = queue->tx_skbs[i]; in xennet_release_tx_bufs()
1431 queue->tx_skbs[i] = NULL; in xennet_release_tx_bufs()
1432 get_page(queue->grant_tx_page[i]); in xennet_release_tx_bufs()
1433 gnttab_end_foreign_access(queue->grant_tx_ref[i], in xennet_release_tx_bufs()
1434 queue->grant_tx_page[i]); in xennet_release_tx_bufs()
1435 queue->grant_tx_page[i] = NULL; in xennet_release_tx_bufs()
1436 queue->grant_tx_ref[i] = INVALID_GRANT_REF; in xennet_release_tx_bufs()
1437 add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, i); in xennet_release_tx_bufs()
1446 spin_lock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1452 skb = queue->rx_skbs[id]; in xennet_release_rx_bufs()
1456 ref = queue->grant_rx_ref[id]; in xennet_release_rx_bufs()
1460 page = skb_frag_page(&skb_shinfo(skb)->frags[0]); in xennet_release_rx_bufs()
1467 queue->grant_rx_ref[id] = INVALID_GRANT_REF; in xennet_release_rx_bufs()
1472 spin_unlock_bh(&queue->rx_lock); in xennet_release_rx_bufs()
1481 !xenbus_read_unsigned(np->xbdev->otherend, "feature-sg", 0)) in xennet_fix_features()
1485 !xenbus_read_unsigned(np->xbdev->otherend, in xennet_fix_features()
1486 "feature-ipv6-csum-offload", 0)) in xennet_fix_features()
1490 !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv4", 0)) in xennet_fix_features()
1494 !xenbus_read_unsigned(np->xbdev->otherend, "feature-gso-tcpv6", 0)) in xennet_fix_features()
1503 if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) { in xennet_set_features()
1505 dev->mtu = ETH_DATA_LEN; in xennet_set_features()
1515 if (unlikely(queue->info->broken)) in xennet_handle_tx()
1518 spin_lock_irqsave(&queue->tx_lock, flags); in xennet_handle_tx()
1521 spin_unlock_irqrestore(&queue->tx_lock, flags); in xennet_handle_tx()
1541 if (unlikely(queue->info->broken)) in xennet_handle_rx()
1544 spin_lock_irqsave(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1545 work_queued = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); in xennet_handle_rx()
1546 if (work_queued > queue->rx_rsp_unconsumed) { in xennet_handle_rx()
1547 queue->rx_rsp_unconsumed = work_queued; in xennet_handle_rx()
1549 } else if (unlikely(work_queued < queue->rx_rsp_unconsumed)) { in xennet_handle_rx()
1550 const struct device *dev = &queue->info->netdev->dev; in xennet_handle_rx()
1552 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1555 queue->info->broken = true; in xennet_handle_rx()
1558 spin_unlock_irqrestore(&queue->rx_cons_lock, flags); in xennet_handle_rx()
1560 if (likely(netif_carrier_ok(queue->info->netdev) && work_queued)) in xennet_handle_rx()
1561 napi_schedule(&queue->napi); in xennet_handle_rx()
1592 unsigned int num_queues = dev->real_num_tx_queues; in xennet_poll_controller()
1595 if (info->broken) in xennet_poll_controller()
1599 xennet_interrupt(0, &info->queues[i]); in xennet_poll_controller()
1612 err = xenbus_printf(XBT_NIL, np->xbdev->nodename, in talk_to_netback_xdp()
1613 "xdp-headroom", "%hu", in talk_to_netback_xdp()
1616 pr_warn("Error writing xdp-headroom\n"); in talk_to_netback_xdp()
1624 unsigned long max_mtu = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM; in xennet_xdp_set()
1629 if (dev->mtu > max_mtu) { in xennet_xdp_set()
1631 return -EINVAL; in xennet_xdp_set()
1634 if (!np->netback_has_xdp_headroom) in xennet_xdp_set()
1637 xenbus_switch_state(np->xbdev, XenbusStateReconfiguring); in xennet_xdp_set()
1646 xenbus_read_driver_state(np->xbdev->otherend) == in xennet_xdp_set()
1648 np->netfront_xdp_enabled = true; in xennet_xdp_set()
1650 old_prog = rtnl_dereference(np->queues[0].xdp_prog); in xennet_xdp_set()
1653 bpf_prog_add(prog, dev->real_num_tx_queues); in xennet_xdp_set()
1655 for (i = 0; i < dev->real_num_tx_queues; ++i) in xennet_xdp_set()
1656 rcu_assign_pointer(np->queues[i].xdp_prog, prog); in xennet_xdp_set()
1659 for (i = 0; i < dev->real_num_tx_queues; ++i) in xennet_xdp_set()
1662 xenbus_switch_state(np->xbdev, XenbusStateConnected); in xennet_xdp_set()
1671 if (np->broken) in xennet_xdp()
1672 return -ENODEV; in xennet_xdp()
1674 switch (xdp->command) { in xennet_xdp()
1676 return xennet_xdp_set(dev, xdp->prog, xdp->extack); in xennet_xdp()
1678 return -EINVAL; in xennet_xdp()
1705 free_percpu(np->rx_stats); in xennet_free_netdev()
1706 free_percpu(np->tx_stats); in xennet_free_netdev()
1718 return ERR_PTR(-ENOMEM); in xennet_create_dev()
1721 np->xbdev = dev; in xennet_create_dev()
1723 np->queues = NULL; in xennet_create_dev()
1725 err = -ENOMEM; in xennet_create_dev()
1726 np->rx_stats = netdev_alloc_pcpu_stats(struct netfront_stats); in xennet_create_dev()
1727 if (np->rx_stats == NULL) in xennet_create_dev()
1729 np->tx_stats = netdev_alloc_pcpu_stats(struct netfront_stats); in xennet_create_dev()
1730 if (np->tx_stats == NULL) in xennet_create_dev()
1733 netdev->netdev_ops = &xennet_netdev_ops; in xennet_create_dev()
1735 netdev->features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM | in xennet_create_dev()
1737 netdev->hw_features = NETIF_F_SG | in xennet_create_dev()
1742 * Assume that all hw features are available for now. This set in xennet_create_dev()
1747 netdev->features |= netdev->hw_features; in xennet_create_dev()
1748 netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in xennet_create_dev()
1751 netdev->ethtool_ops = &xennet_ethtool_ops; in xennet_create_dev()
1752 netdev->min_mtu = ETH_MIN_MTU; in xennet_create_dev()
1753 netdev->max_mtu = XEN_NETIF_MAX_TX_SIZE; in xennet_create_dev()
1754 SET_NETDEV_DEV(netdev, &dev->dev); in xennet_create_dev()
1756 np->netdev = netdev; in xennet_create_dev()
1757 np->netfront_xdp_enabled = false; in xennet_create_dev()
1764 xenbus_read_driver_state(dev->otherend) != in xennet_create_dev()
1766 xenbus_read_driver_state(dev->otherend) != in xennet_create_dev()
1797 dev_set_drvdata(&dev->dev, info); in netfront_probe()
1799 info->netdev->sysfs_groups[0] = &xennet_dev_group; in netfront_probe()
1807 /* This frees the page as a side-effect */ in xennet_end_access()
1815 unsigned int num_queues = info->netdev->real_num_tx_queues; in xennet_disconnect_backend()
1817 netif_carrier_off(info->netdev); in xennet_disconnect_backend()
1819 for (i = 0; i < num_queues && info->queues; ++i) { in xennet_disconnect_backend()
1820 struct netfront_queue *queue = &info->queues[i]; in xennet_disconnect_backend()
1822 del_timer_sync(&queue->rx_refill_timer); in xennet_disconnect_backend()
1824 if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) in xennet_disconnect_backend()
1825 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1826 if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { in xennet_disconnect_backend()
1827 unbind_from_irqhandler(queue->tx_irq, queue); in xennet_disconnect_backend()
1828 unbind_from_irqhandler(queue->rx_irq, queue); in xennet_disconnect_backend()
1830 queue->tx_evtchn = queue->rx_evtchn = 0; in xennet_disconnect_backend()
1831 queue->tx_irq = queue->rx_irq = 0; in xennet_disconnect_backend()
1833 if (netif_running(info->netdev)) in xennet_disconnect_backend()
1834 napi_synchronize(&queue->napi); in xennet_disconnect_backend()
1838 gnttab_free_grant_references(queue->gref_tx_head); in xennet_disconnect_backend()
1839 gnttab_free_grant_references(queue->gref_rx_head); in xennet_disconnect_backend()
1842 xennet_end_access(queue->tx_ring_ref, queue->tx.sring); in xennet_disconnect_backend()
1843 xennet_end_access(queue->rx_ring_ref, queue->rx.sring); in xennet_disconnect_backend()
1845 queue->tx_ring_ref = INVALID_GRANT_REF; in xennet_disconnect_backend()
1846 queue->rx_ring_ref = INVALID_GRANT_REF; in xennet_disconnect_backend()
1847 queue->tx.sring = NULL; in xennet_disconnect_backend()
1848 queue->rx.sring = NULL; in xennet_disconnect_backend()
1850 page_pool_destroy(queue->page_pool); in xennet_disconnect_backend()
1857 * leave the device-layer structures intact so that this is transparent to the
1862 struct netfront_info *info = dev_get_drvdata(&dev->dev); in netfront_resume()
1864 dev_dbg(&dev->dev, "%s\n", dev->nodename); in netfront_resume()
1866 netif_tx_lock_bh(info->netdev); in netfront_resume()
1867 netif_device_detach(info->netdev); in netfront_resume()
1868 netif_tx_unlock_bh(info->netdev); in netfront_resume()
1873 if (info->queues) in netfront_resume()
1885 macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL); in xen_net_read_mac()
1891 if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) { in xen_net_read_mac()
1893 return -ENOENT; in xen_net_read_mac()
1906 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_single()
1910 err = bind_evtchn_to_irqhandler_lateeoi(queue->tx_evtchn, in setup_netfront_single()
1912 queue->info->netdev->name, in setup_netfront_single()
1916 queue->rx_evtchn = queue->tx_evtchn; in setup_netfront_single()
1917 queue->rx_irq = queue->tx_irq = err; in setup_netfront_single()
1922 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_single()
1923 queue->tx_evtchn = 0; in setup_netfront_single()
1932 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->tx_evtchn); in setup_netfront_split()
1935 err = xenbus_alloc_evtchn(queue->info->xbdev, &queue->rx_evtchn); in setup_netfront_split()
1939 snprintf(queue->tx_irq_name, sizeof(queue->tx_irq_name), in setup_netfront_split()
1940 "%s-tx", queue->name); in setup_netfront_split()
1941 err = bind_evtchn_to_irqhandler_lateeoi(queue->tx_evtchn, in setup_netfront_split()
1943 queue->tx_irq_name, queue); in setup_netfront_split()
1946 queue->tx_irq = err; in setup_netfront_split()
1948 snprintf(queue->rx_irq_name, sizeof(queue->rx_irq_name), in setup_netfront_split()
1949 "%s-rx", queue->name); in setup_netfront_split()
1950 err = bind_evtchn_to_irqhandler_lateeoi(queue->rx_evtchn, in setup_netfront_split()
1952 queue->rx_irq_name, queue); in setup_netfront_split()
1955 queue->rx_irq = err; in setup_netfront_split()
1960 unbind_from_irqhandler(queue->tx_irq, queue); in setup_netfront_split()
1961 queue->tx_irq = 0; in setup_netfront_split()
1963 xenbus_free_evtchn(queue->info->xbdev, queue->rx_evtchn); in setup_netfront_split()
1964 queue->rx_evtchn = 0; in setup_netfront_split()
1966 xenbus_free_evtchn(queue->info->xbdev, queue->tx_evtchn); in setup_netfront_split()
1967 queue->tx_evtchn = 0; in setup_netfront_split()
1979 queue->tx_ring_ref = INVALID_GRANT_REF; in setup_netfront()
1980 queue->rx_ring_ref = INVALID_GRANT_REF; in setup_netfront()
1981 queue->rx.sring = NULL; in setup_netfront()
1982 queue->tx.sring = NULL; in setup_netfront()
1985 1, &queue->tx_ring_ref); in setup_netfront()
1989 XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); in setup_netfront()
1992 1, &queue->rx_ring_ref); in setup_netfront()
1996 XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); in setup_netfront()
2001 * a) feature-split-event-channels == 0 in setup_netfront()
2002 * b) feature-split-event-channels == 1 but failed to setup in setup_netfront()
2013 xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref); in setup_netfront()
2014 xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref); in setup_netfront()
2019 /* Queue-specific initialisation
2021 * be run per-queue.
2029 spin_lock_init(&queue->tx_lock); in xennet_init_queue()
2030 spin_lock_init(&queue->rx_lock); in xennet_init_queue()
2031 spin_lock_init(&queue->rx_cons_lock); in xennet_init_queue()
2033 timer_setup(&queue->rx_refill_timer, rx_refill_timeout, 0); in xennet_init_queue()
2035 devid = strrchr(queue->info->xbdev->nodename, '/') + 1; in xennet_init_queue()
2036 snprintf(queue->name, sizeof(queue->name), "vif%s-q%u", in xennet_init_queue()
2037 devid, queue->id); in xennet_init_queue()
2040 queue->tx_skb_freelist = 0; in xennet_init_queue()
2041 queue->tx_pend_queue = TX_LINK_NONE; in xennet_init_queue()
2043 queue->tx_link[i] = i + 1; in xennet_init_queue()
2044 queue->grant_tx_ref[i] = INVALID_GRANT_REF; in xennet_init_queue()
2045 queue->grant_tx_page[i] = NULL; in xennet_init_queue()
2047 queue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE; in xennet_init_queue()
2051 queue->rx_skbs[i] = NULL; in xennet_init_queue()
2052 queue->grant_rx_ref[i] = INVALID_GRANT_REF; in xennet_init_queue()
2055 /* A grant for every tx ring slot */ in xennet_init_queue()
2057 &queue->gref_tx_head) < 0) { in xennet_init_queue()
2058 pr_alert("can't alloc tx grant refs\n"); in xennet_init_queue()
2059 err = -ENOMEM; in xennet_init_queue()
2065 &queue->gref_rx_head) < 0) { in xennet_init_queue()
2067 err = -ENOMEM; in xennet_init_queue()
2074 gnttab_free_grant_references(queue->gref_tx_head); in xennet_init_queue()
2082 /* Write the queue-specific keys into XenStore in the traditional in write_queue_xenstore_keys()
2086 struct xenbus_device *dev = queue->info->xbdev; in write_queue_xenstore_keys()
2094 pathsize = strlen(dev->nodename) + 10; in write_queue_xenstore_keys()
2097 err = -ENOMEM; in write_queue_xenstore_keys()
2101 snprintf(path, pathsize, "%s/queue-%u", in write_queue_xenstore_keys()
2102 dev->nodename, queue->id); in write_queue_xenstore_keys()
2104 path = (char *)dev->nodename; in write_queue_xenstore_keys()
2108 err = xenbus_printf(*xbt, path, "tx-ring-ref", "%u", in write_queue_xenstore_keys()
2109 queue->tx_ring_ref); in write_queue_xenstore_keys()
2111 message = "writing tx-ring-ref"; in write_queue_xenstore_keys()
2115 err = xenbus_printf(*xbt, path, "rx-ring-ref", "%u", in write_queue_xenstore_keys()
2116 queue->rx_ring_ref); in write_queue_xenstore_keys()
2118 message = "writing rx-ring-ref"; in write_queue_xenstore_keys()
2125 if (queue->tx_evtchn == queue->rx_evtchn) { in write_queue_xenstore_keys()
2128 "event-channel", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
2130 message = "writing event-channel"; in write_queue_xenstore_keys()
2136 "event-channel-tx", "%u", queue->tx_evtchn); in write_queue_xenstore_keys()
2138 message = "writing event-channel-tx"; in write_queue_xenstore_keys()
2143 "event-channel-rx", "%u", queue->rx_evtchn); in write_queue_xenstore_keys()
2145 message = "writing event-channel-rx"; in write_queue_xenstore_keys()
2171 .dev = &queue->info->netdev->dev, in xennet_create_page_pool()
2173 .max_len = XEN_PAGE_SIZE - XDP_PACKET_HEADROOM, in xennet_create_page_pool()
2176 queue->page_pool = page_pool_create(&pp_params); in xennet_create_page_pool()
2177 if (IS_ERR(queue->page_pool)) { in xennet_create_page_pool()
2178 err = PTR_ERR(queue->page_pool); in xennet_create_page_pool()
2179 queue->page_pool = NULL; in xennet_create_page_pool()
2183 err = xdp_rxq_info_reg(&queue->xdp_rxq, queue->info->netdev, in xennet_create_page_pool()
2184 queue->id, 0); in xennet_create_page_pool()
2186 netdev_err(queue->info->netdev, "xdp_rxq_info_reg failed\n"); in xennet_create_page_pool()
2190 err = xdp_rxq_info_reg_mem_model(&queue->xdp_rxq, in xennet_create_page_pool()
2191 MEM_TYPE_PAGE_POOL, queue->page_pool); in xennet_create_page_pool()
2193 netdev_err(queue->info->netdev, "xdp_rxq_info_reg_mem_model failed\n"); in xennet_create_page_pool()
2199 xdp_rxq_info_unreg(&queue->xdp_rxq); in xennet_create_page_pool()
2201 page_pool_destroy(queue->page_pool); in xennet_create_page_pool()
2202 queue->page_pool = NULL; in xennet_create_page_pool()
2212 info->queues = kcalloc(*num_queues, sizeof(struct netfront_queue), in xennet_create_queues()
2214 if (!info->queues) in xennet_create_queues()
2215 return -ENOMEM; in xennet_create_queues()
2218 struct netfront_queue *queue = &info->queues[i]; in xennet_create_queues()
2220 queue->id = i; in xennet_create_queues()
2221 queue->info = info; in xennet_create_queues()
2225 dev_warn(&info->xbdev->dev, in xennet_create_queues()
2234 dev_err(&info->xbdev->dev, "can't allocate page pool\n"); in xennet_create_queues()
2239 netif_napi_add(queue->info->netdev, &queue->napi, xennet_poll); in xennet_create_queues()
2240 if (netif_running(info->netdev)) in xennet_create_queues()
2241 napi_enable(&queue->napi); in xennet_create_queues()
2244 netif_set_real_num_tx_queues(info->netdev, *num_queues); in xennet_create_queues()
2247 dev_err(&info->xbdev->dev, "no queues\n"); in xennet_create_queues()
2248 return -EINVAL; in xennet_create_queues()
2267 info->netdev->irq = 0; in talk_to_netback()
2270 info->bounce = !xennet_trusted || in talk_to_netback()
2271 !xenbus_read_unsigned(dev->nodename, "trusted", 1); in talk_to_netback()
2274 max_queues = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2275 "multi-queue-max-queues", 1); in talk_to_netback()
2278 /* Check feature-split-event-channels */ in talk_to_netback()
2279 feature_split_evtchn = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2280 "feature-split-event-channels", 0); in talk_to_netback()
2285 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); in talk_to_netback()
2288 eth_hw_addr_set(info->netdev, addr); in talk_to_netback()
2290 info->netback_has_xdp_headroom = xenbus_read_unsigned(info->xbdev->otherend, in talk_to_netback()
2291 "feature-xdp-headroom", 0); in talk_to_netback()
2292 if (info->netback_has_xdp_headroom) { in talk_to_netback()
2293 /* set the current xen-netfront xdp state */ in talk_to_netback()
2294 err = talk_to_netback_xdp(info, info->netfront_xdp_enabled ? in talk_to_netback()
2302 if (info->queues) in talk_to_netback()
2306 info->broken = false; in talk_to_netback()
2311 kfree(info->queues); in talk_to_netback()
2312 info->queues = NULL; in talk_to_netback()
2317 /* Create shared ring, alloc event channel -- for each queue */ in talk_to_netback()
2319 queue = &info->queues[i]; in talk_to_netback()
2333 info->xbdev->otherend, "multi-queue-max-queues")) { in talk_to_netback()
2335 err = xenbus_printf(xbt, dev->nodename, in talk_to_netback()
2336 "multi-queue-num-queues", "%u", num_queues); in talk_to_netback()
2338 message = "writing multi-queue-num-queues"; in talk_to_netback()
2344 err = write_queue_xenstore_keys(&info->queues[0], &xbt, 0); /* flat */ in talk_to_netback()
2350 queue = &info->queues[i]; in talk_to_netback()
2357 /* The remaining keys are not queue-specific */ in talk_to_netback()
2358 err = xenbus_printf(xbt, dev->nodename, "request-rx-copy", "%u", in talk_to_netback()
2361 message = "writing request-rx-copy"; in talk_to_netback()
2365 err = xenbus_printf(xbt, dev->nodename, "feature-rx-notify", "%d", 1); in talk_to_netback()
2367 message = "writing feature-rx-notify"; in talk_to_netback()
2371 err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", 1); in talk_to_netback()
2373 message = "writing feature-sg"; in talk_to_netback()
2377 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1); in talk_to_netback()
2379 message = "writing feature-gso-tcpv4"; in talk_to_netback()
2383 err = xenbus_write(xbt, dev->nodename, "feature-gso-tcpv6", "1"); in talk_to_netback()
2385 message = "writing feature-gso-tcpv6"; in talk_to_netback()
2389 err = xenbus_write(xbt, dev->nodename, "feature-ipv6-csum-offload", in talk_to_netback()
2392 message = "writing feature-ipv6-csum-offload"; in talk_to_netback()
2398 if (err == -EAGAIN) in talk_to_netback()
2417 device_unregister(&dev->dev); in talk_to_netback()
2429 if (!xenbus_read_unsigned(np->xbdev->otherend, "feature-rx-copy", 0)) { in xennet_connect()
2430 dev_info(&dev->dev, in xennet_connect()
2432 return -ENODEV; in xennet_connect()
2435 err = talk_to_netback(np->xbdev, np); in xennet_connect()
2438 if (np->netback_has_xdp_headroom) in xennet_connect()
2440 if (np->bounce) in xennet_connect()
2441 dev_info(&np->xbdev->dev, in xennet_connect()
2445 num_queues = dev->real_num_tx_queues; in xennet_connect()
2447 if (dev->reg_state == NETREG_UNINITIALIZED) { in xennet_connect()
2451 device_unregister(&np->xbdev->dev); in xennet_connect()
2462 * ready to start sending and receiving packets and give the driver in xennet_connect()
2464 * packets. in xennet_connect()
2466 netif_tx_lock_bh(np->netdev); in xennet_connect()
2467 netif_device_attach(np->netdev); in xennet_connect()
2468 netif_tx_unlock_bh(np->netdev); in xennet_connect()
2470 netif_carrier_on(np->netdev); in xennet_connect()
2472 queue = &np->queues[j]; in xennet_connect()
2474 notify_remote_via_irq(queue->tx_irq); in xennet_connect()
2475 if (queue->tx_irq != queue->rx_irq) in xennet_connect()
2476 notify_remote_via_irq(queue->rx_irq); in xennet_connect()
2478 spin_lock_bh(&queue->rx_lock); in xennet_connect()
2480 spin_unlock_bh(&queue->rx_lock); in xennet_connect()
2492 struct netfront_info *np = dev_get_drvdata(&dev->dev); in netback_changed()
2493 struct net_device *netdev = np->netdev; in netback_changed()
2495 dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state)); in netback_changed()
2508 if (dev->state != XenbusStateInitialising) in netback_changed()
2520 if (dev->state == XenbusStateClosed) in netback_changed()
2545 return -EINVAL; in xennet_get_sset_count()
2596 return -EPERM; in store_rxbuf()
2600 return -EBADMSG; in store_rxbuf()
2627 if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) in xennet_bus_close()
2632 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2634 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2636 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2641 if (xenbus_read_driver_state(dev->otherend) == XenbusStateClosed) in xennet_bus_close()
2647 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2649 xenbus_read_driver_state(dev->otherend) == in xennet_bus_close()
2657 struct netfront_info *info = dev_get_drvdata(&dev->dev); in xennet_remove()
2662 if (info->netdev->reg_state == NETREG_REGISTERED) in xennet_remove()
2663 unregister_netdev(info->netdev); in xennet_remove()
2665 if (info->queues) { in xennet_remove()
2670 xennet_free_netdev(info->netdev); in xennet_remove()
2689 return -ENODEV; in netif_init()
2692 return -ENODEV; in netif_init()