Lines Matching +full:num +full:- +full:guest +full:- +full:ids

1 // SPDX-License-Identifier: GPL-2.0-or-later
28 struct xenvif_queue *queue = m->private; in xenvif_read_io_ring()
29 struct xen_netif_tx_back_ring *tx_ring = &queue->tx; in xenvif_read_io_ring()
30 struct xen_netif_rx_back_ring *rx_ring = &queue->rx; in xenvif_read_io_ring()
33 if (tx_ring->sring) { in xenvif_read_io_ring()
34 struct xen_netif_tx_sring *sring = tx_ring->sring; in xenvif_read_io_ring()
36 seq_printf(m, "Queue %d\nTX: nr_ents %u\n", queue->id, in xenvif_read_io_ring()
37 tx_ring->nr_ents); in xenvif_read_io_ring()
39 sring->req_prod, in xenvif_read_io_ring()
40 sring->req_prod - sring->rsp_prod, in xenvif_read_io_ring()
41 tx_ring->req_cons, in xenvif_read_io_ring()
42 tx_ring->req_cons - sring->rsp_prod, in xenvif_read_io_ring()
43 sring->req_event, in xenvif_read_io_ring()
44 sring->req_event - sring->rsp_prod); in xenvif_read_io_ring()
46 sring->rsp_prod, in xenvif_read_io_ring()
47 tx_ring->rsp_prod_pvt, in xenvif_read_io_ring()
48 tx_ring->rsp_prod_pvt - sring->rsp_prod, in xenvif_read_io_ring()
49 sring->rsp_event, in xenvif_read_io_ring()
50 sring->rsp_event - sring->rsp_prod); in xenvif_read_io_ring()
52 queue->pending_prod, in xenvif_read_io_ring()
53 queue->pending_cons, in xenvif_read_io_ring()
56 queue->dealloc_prod, in xenvif_read_io_ring()
57 queue->dealloc_cons, in xenvif_read_io_ring()
58 queue->dealloc_prod - queue->dealloc_cons); in xenvif_read_io_ring()
61 if (rx_ring->sring) { in xenvif_read_io_ring()
62 struct xen_netif_rx_sring *sring = rx_ring->sring; in xenvif_read_io_ring()
64 seq_printf(m, "RX: nr_ents %u\n", rx_ring->nr_ents); in xenvif_read_io_ring()
66 sring->req_prod, in xenvif_read_io_ring()
67 sring->req_prod - sring->rsp_prod, in xenvif_read_io_ring()
68 rx_ring->req_cons, in xenvif_read_io_ring()
69 rx_ring->req_cons - sring->rsp_prod, in xenvif_read_io_ring()
70 sring->req_event, in xenvif_read_io_ring()
71 sring->req_event - sring->rsp_prod); in xenvif_read_io_ring()
73 sring->rsp_prod, in xenvif_read_io_ring()
74 rx_ring->rsp_prod_pvt, in xenvif_read_io_ring()
75 rx_ring->rsp_prod_pvt - sring->rsp_prod, in xenvif_read_io_ring()
76 sring->rsp_event, in xenvif_read_io_ring()
77 sring->rsp_event - sring->rsp_prod); in xenvif_read_io_ring()
83 queue->napi.state, queue->napi.weight, in xenvif_read_io_ring()
84 skb_queue_len(&queue->tx_queue), in xenvif_read_io_ring()
85 timer_pending(&queue->credit_timeout), in xenvif_read_io_ring()
86 queue->credit_bytes, in xenvif_read_io_ring()
87 queue->credit_usec, in xenvif_read_io_ring()
88 queue->remaining_credit, in xenvif_read_io_ring()
89 queue->credit_timeout.expires, in xenvif_read_io_ring()
92 dev_queue = netdev_get_tx_queue(queue->vif->dev, queue->id); in xenvif_read_io_ring()
95 queue->rx_queue_len, queue->rx_queue_max, in xenvif_read_io_ring()
96 skb_queue_len(&queue->rx_queue), in xenvif_read_io_ring()
110 ((struct seq_file *)filp->private_data)->private; in xenvif_write_io_ring()
118 return -ENOSPC; in xenvif_write_io_ring()
121 sizeof(write) - 1, in xenvif_write_io_ring()
130 if (!strncmp(write, XENVIF_KICK_STR, sizeof(XENVIF_KICK_STR) - 1)) in xenvif_write_io_ring()
134 queue->id); in xenvif_write_io_ring()
135 count = -EINVAL; in xenvif_write_io_ring()
145 if (inode->i_private) in xenvif_io_ring_open()
146 queue = inode->i_private; in xenvif_io_ring_open()
148 filp->f_mode |= FMODE_PWRITE; in xenvif_io_ring_open()
163 struct xenvif *vif = m->private; in xenvif_ctrl_show()
175 vif->xenvif_dbg_root = debugfs_create_dir(vif->dev->name, in xenvif_debugfs_addif()
177 for (i = 0; i < vif->num_queues; ++i) { in xenvif_debugfs_addif()
181 debugfs_create_file(filename, 0600, vif->xenvif_dbg_root, in xenvif_debugfs_addif()
182 &vif->queues[i], in xenvif_debugfs_addif()
186 if (vif->ctrl_irq) in xenvif_debugfs_addif()
187 debugfs_create_file("ctrl", 0400, vif->xenvif_dbg_root, vif, in xenvif_debugfs_addif()
193 debugfs_remove_recursive(vif->xenvif_dbg_root); in xenvif_debugfs_delif()
194 vif->xenvif_dbg_root = NULL; in xenvif_debugfs_delif()
200 * and vif variables to the environment, for the benefit of the vif-* hotplug
206 struct backend_info *be = dev_get_drvdata(&xdev->dev); in netback_uevent()
211 if (add_uevent_var(env, "script=%s", be->hotplug_script)) in netback_uevent()
212 return -ENOMEM; in netback_uevent()
214 if (!be->vif) in netback_uevent()
217 return add_uevent_var(env, "vif=%s", be->vif->dev->name); in netback_uevent()
225 struct xenbus_device *dev = be->dev; in backend_create_xenvif()
228 if (be->vif != NULL) in backend_create_xenvif()
231 err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle); in backend_create_xenvif()
234 return (err < 0) ? err : -EINVAL; in backend_create_xenvif()
237 vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle); in backend_create_xenvif()
243 be->vif = vif; in backend_create_xenvif()
244 vif->be = be; in backend_create_xenvif()
246 kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE); in backend_create_xenvif()
252 struct xenvif *vif = be->vif; in backend_disconnect()
255 unsigned int num_queues = vif->num_queues; in backend_disconnect()
267 vif->num_queues = 0; in backend_disconnect()
271 xenvif_deinit_queue(&vif->queues[queue_index]); in backend_disconnect()
273 vfree(vif->queues); in backend_disconnect()
274 vif->queues = NULL; in backend_disconnect()
282 if (be->vif) in backend_connect()
289 struct xenbus_device *dev = be->dev; in backend_switch_state()
291 pr_debug("%s -> %s\n", dev->nodename, xenbus_strstate(state)); in backend_switch_state()
292 be->state = state; in backend_switch_state()
297 if (!be->have_hotplug_status_watch) in backend_switch_state()
306 * Initialising -> InitWait -> Connected
316 * Closed <-> Closing
324 while (be->state != state) { in set_backend_state()
325 switch (be->state) { in set_backend_state()
399 struct xenvif *vif = be->vif; in read_xenbus_frontend_xdp()
403 err = xenbus_scanf(XBT_NIL, dev->otherend, in read_xenbus_frontend_xdp()
404 "xdp-headroom", "%hu", &headroom); in read_xenbus_frontend_xdp()
406 vif->xdp_headroom = 0; in read_xenbus_frontend_xdp()
411 vif->xdp_headroom = headroom; in read_xenbus_frontend_xdp()
420 struct backend_info *be = dev_get_drvdata(&dev->dev); in frontend_changed()
422 pr_debug("%s -> %s\n", dev->otherend, xenbus_strstate(frontend_state)); in frontend_changed()
424 be->frontend_state = frontend_state; in frontend_changed()
454 device_unregister(&dev->dev); in frontend_changed()
458 xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend", in frontend_changed()
476 ratestr = xenbus_read(XBT_NIL, dev->nodename, "rate", NULL); in xen_net_read_rate()
506 macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL); in xen_net_read_mac()
512 if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) { in xen_net_read_mac()
514 return -ENOENT; in xen_net_read_mac()
533 for (queue_index = 0; queue_index < vif->num_queues; queue_index++) { in xen_net_rate_changed()
534 struct xenvif_queue *queue = &vif->queues[queue_index]; in xen_net_rate_changed()
536 queue->credit_bytes = credit_bytes; in xen_net_rate_changed()
537 queue->credit_usec = credit_usec; in xen_net_rate_changed()
538 if (!mod_timer_pending(&queue->credit_timeout, jiffies) && in xen_net_rate_changed()
539 queue->remaining_credit > queue->credit_bytes) { in xen_net_rate_changed()
540 queue->remaining_credit = queue->credit_bytes; in xen_net_rate_changed()
550 unsigned maxlen = strlen(dev->nodename) + sizeof("/rate"); in xen_register_credit_watch()
552 if (vif->credit_watch.node) in xen_register_credit_watch()
553 return -EADDRINUSE; in xen_register_credit_watch()
557 return -ENOMEM; in xen_register_credit_watch()
558 snprintf(node, maxlen, "%s/rate", dev->nodename); in xen_register_credit_watch()
559 vif->credit_watch.node = node; in xen_register_credit_watch()
560 vif->credit_watch.will_handle = NULL; in xen_register_credit_watch()
561 vif->credit_watch.callback = xen_net_rate_changed; in xen_register_credit_watch()
562 err = register_xenbus_watch(&vif->credit_watch); in xen_register_credit_watch()
564 pr_err("Failed to set watcher %s\n", vif->credit_watch.node); in xen_register_credit_watch()
566 vif->credit_watch.node = NULL; in xen_register_credit_watch()
567 vif->credit_watch.will_handle = NULL; in xen_register_credit_watch()
568 vif->credit_watch.callback = NULL; in xen_register_credit_watch()
575 if (vif->credit_watch.node) { in xen_unregister_credit_watch()
576 unregister_xenbus_watch(&vif->credit_watch); in xen_unregister_credit_watch()
577 kfree(vif->credit_watch.node); in xen_unregister_credit_watch()
578 vif->credit_watch.node = NULL; in xen_unregister_credit_watch()
589 vif->multicast_control = !!xenbus_read_unsigned(dev->otherend, in xen_mcast_ctrl_changed()
590 "request-multicast-control", 0); in xen_mcast_ctrl_changed()
598 unsigned maxlen = strlen(dev->otherend) + in xen_register_mcast_ctrl_watch()
599 sizeof("/request-multicast-control"); in xen_register_mcast_ctrl_watch()
601 if (vif->mcast_ctrl_watch.node) { in xen_register_mcast_ctrl_watch()
603 return -EADDRINUSE; in xen_register_mcast_ctrl_watch()
609 return -ENOMEM; in xen_register_mcast_ctrl_watch()
611 snprintf(node, maxlen, "%s/request-multicast-control", in xen_register_mcast_ctrl_watch()
612 dev->otherend); in xen_register_mcast_ctrl_watch()
613 vif->mcast_ctrl_watch.node = node; in xen_register_mcast_ctrl_watch()
614 vif->mcast_ctrl_watch.will_handle = NULL; in xen_register_mcast_ctrl_watch()
615 vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; in xen_register_mcast_ctrl_watch()
616 err = register_xenbus_watch(&vif->mcast_ctrl_watch); in xen_register_mcast_ctrl_watch()
619 vif->mcast_ctrl_watch.node); in xen_register_mcast_ctrl_watch()
621 vif->mcast_ctrl_watch.node = NULL; in xen_register_mcast_ctrl_watch()
622 vif->mcast_ctrl_watch.will_handle = NULL; in xen_register_mcast_ctrl_watch()
623 vif->mcast_ctrl_watch.callback = NULL; in xen_register_mcast_ctrl_watch()
630 if (vif->mcast_ctrl_watch.node) { in xen_unregister_mcast_ctrl_watch()
631 unregister_xenbus_watch(&vif->mcast_ctrl_watch); in xen_unregister_mcast_ctrl_watch()
632 kfree(vif->mcast_ctrl_watch.node); in xen_unregister_mcast_ctrl_watch()
633 vif->mcast_ctrl_watch.node = NULL; in xen_unregister_mcast_ctrl_watch()
652 if (be->have_hotplug_status_watch) { in unregister_hotplug_status_watch()
653 unregister_xenbus_watch(&be->hotplug_status_watch); in unregister_hotplug_status_watch()
654 kfree(be->hotplug_status_watch.node); in unregister_hotplug_status_watch()
656 be->have_hotplug_status_watch = 0; in unregister_hotplug_status_watch()
669 str = xenbus_read(XBT_NIL, be->dev->nodename, "hotplug-status", &len); in hotplug_status_changed()
672 if (len == sizeof("connected")-1 && !memcmp(str, "connected", len)) { in hotplug_status_changed()
674 xenbus_switch_state(be->dev, be->state); in hotplug_status_changed()
684 struct xenbus_device *dev = be->dev; in connect_ctrl_ring()
685 struct xenvif *vif = be->vif; in connect_ctrl_ring()
691 err = xenbus_scanf(XBT_NIL, dev->otherend, in connect_ctrl_ring()
692 "ctrl-ring-ref", "%u", &val); in connect_ctrl_ring()
698 err = xenbus_scanf(XBT_NIL, dev->otherend, in connect_ctrl_ring()
699 "event-channel-ctrl", "%u", &val); in connect_ctrl_ring()
702 "reading %s/event-channel-ctrl", in connect_ctrl_ring()
703 dev->otherend); in connect_ctrl_ring()
712 "mapping shared-frame %u port %u", in connect_ctrl_ring()
727 struct xenbus_device *dev = be->dev; in connect()
736 requested_num_queues = xenbus_read_unsigned(dev->otherend, in connect()
737 "multi-queue-num-queues", 1); in connect()
739 /* buggy or malicious guest */ in connect()
740 xenbus_dev_fatal(dev, -EINVAL, in connect()
741 "guest requested %u queues, exceeding the maximum of %u.", in connect()
746 err = xen_net_read_mac(dev, be->vif->fe_dev_addr); in connect()
748 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename); in connect()
753 xen_unregister_watchers(be->vif); in connect()
754 xen_register_watchers(dev, be->vif); in connect()
764 be->vif->queues = vzalloc(array_size(requested_num_queues, in connect()
766 if (!be->vif->queues) { in connect()
767 xenbus_dev_fatal(dev, -ENOMEM, in connect()
772 be->vif->num_queues = requested_num_queues; in connect()
773 be->vif->stalled_queues = requested_num_queues; in connect()
776 queue = &be->vif->queues[queue_index]; in connect()
777 queue->vif = be->vif; in connect()
778 queue->id = queue_index; in connect()
779 snprintf(queue->name, sizeof(queue->name), "%s-q%u", in connect()
780 be->vif->dev->name, queue->id); in connect()
790 be->vif->num_queues = queue_index; in connect()
794 queue->credit_bytes = credit_bytes; in connect()
795 queue->remaining_credit = credit_bytes; in connect()
796 queue->credit_usec = credit_usec; in connect()
806 be->vif->num_queues = queue_index; in connect()
812 xenvif_debugfs_addif(be->vif); in connect()
819 netif_set_real_num_tx_queues(be->vif->dev, requested_num_queues); in connect()
820 netif_set_real_num_rx_queues(be->vif->dev, requested_num_queues); in connect()
823 xenvif_carrier_on(be->vif); in connect()
826 err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, in connect()
828 "%s/%s", dev->nodename, "hotplug-status"); in connect()
830 be->have_hotplug_status_watch = 1; in connect()
832 netif_tx_wake_all_queues(be->vif->dev); in connect()
837 if (be->vif->num_queues > 0) in connect()
838 xenvif_disconnect_data(be->vif); /* Clean up existing queues */ in connect()
839 for (queue_index = 0; queue_index < be->vif->num_queues; ++queue_index) in connect()
840 xenvif_deinit_queue(&be->vif->queues[queue_index]); in connect()
841 vfree(be->vif->queues); in connect()
842 be->vif->queues = NULL; in connect()
843 be->vif->num_queues = 0; in connect()
844 xenvif_disconnect_ctrl(be->vif); in connect()
852 struct xenbus_device *dev = be->dev; in connect_data_rings()
853 unsigned int num_queues = queue->vif->num_queues; in connect_data_rings()
859 const size_t xenstore_path_ext_size = 11; /* sufficient for "/queue-NNN" */ in connect_data_rings()
862 * to single queue due to lack of frontend support for multi- in connect_data_rings()
865 * queue-N. in connect_data_rings()
868 xspath = kstrdup(dev->otherend, GFP_KERNEL); in connect_data_rings()
870 xenbus_dev_fatal(dev, -ENOMEM, in connect_data_rings()
872 return -ENOMEM; in connect_data_rings()
875 xspathsize = strlen(dev->otherend) + xenstore_path_ext_size; in connect_data_rings()
878 xenbus_dev_fatal(dev, -ENOMEM, in connect_data_rings()
880 return -ENOMEM; in connect_data_rings()
882 snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend, in connect_data_rings()
883 queue->id); in connect_data_rings()
887 "tx-ring-ref", "%lu", &tx_ring_ref, in connect_data_rings()
888 "rx-ring-ref", "%lu", &rx_ring_ref, NULL); in connect_data_rings()
891 "reading %s/ring-ref", in connect_data_rings()
898 "event-channel-tx", "%u", &tx_evtchn, in connect_data_rings()
899 "event-channel-rx", "%u", &rx_evtchn, NULL); in connect_data_rings()
902 "event-channel", "%u", &tx_evtchn); in connect_data_rings()
905 "reading %s/event-channel(-tx/rx)", in connect_data_rings()
917 "mapping shared-frames %lu/%lu port tx %u rx %u", in connect_data_rings()
931 struct xenvif *vif = be->vif; in read_xenbus_vif_flags()
932 struct xenbus_device *dev = be->dev; in read_xenbus_vif_flags()
936 err = xenbus_scanf(XBT_NIL, dev->otherend, "request-rx-copy", "%u", in read_xenbus_vif_flags()
938 if (err == -ENOENT) { in read_xenbus_vif_flags()
943 xenbus_dev_fatal(dev, err, "reading %s/request-rx-copy", in read_xenbus_vif_flags()
944 dev->otherend); in read_xenbus_vif_flags()
948 return -EOPNOTSUPP; in read_xenbus_vif_flags()
950 if (!xenbus_read_unsigned(dev->otherend, "feature-rx-notify", 0)) { in read_xenbus_vif_flags()
951 /* - Reduce drain timeout to poll more frequently for in read_xenbus_vif_flags()
953 * - Disable Rx stall detection. in read_xenbus_vif_flags()
955 be->vif->drain_timeout = msecs_to_jiffies(30); in read_xenbus_vif_flags()
956 be->vif->stall_timeout = 0; in read_xenbus_vif_flags()
959 vif->can_sg = !!xenbus_read_unsigned(dev->otherend, "feature-sg", 0); in read_xenbus_vif_flags()
961 vif->gso_mask = 0; in read_xenbus_vif_flags()
963 if (xenbus_read_unsigned(dev->otherend, "feature-gso-tcpv4", 0)) in read_xenbus_vif_flags()
964 vif->gso_mask |= GSO_BIT(TCPV4); in read_xenbus_vif_flags()
966 if (xenbus_read_unsigned(dev->otherend, "feature-gso-tcpv6", 0)) in read_xenbus_vif_flags()
967 vif->gso_mask |= GSO_BIT(TCPV6); in read_xenbus_vif_flags()
969 vif->ip_csum = !xenbus_read_unsigned(dev->otherend, in read_xenbus_vif_flags()
970 "feature-no-csum-offload", 0); in read_xenbus_vif_flags()
972 vif->ipv6_csum = !!xenbus_read_unsigned(dev->otherend, in read_xenbus_vif_flags()
973 "feature-ipv6-csum-offload", 0); in read_xenbus_vif_flags()
982 struct backend_info *be = dev_get_drvdata(&dev->dev); in netback_remove()
985 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status"); in netback_remove()
986 if (be->vif) { in netback_remove()
987 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE); in netback_remove()
989 xenvif_free(be->vif); in netback_remove()
990 be->vif = NULL; in netback_remove()
992 kfree(be->hotplug_script); in netback_remove()
994 dev_set_drvdata(&dev->dev, NULL); in netback_remove()
1012 xenbus_dev_fatal(dev, -ENOMEM, in netback_probe()
1014 return -ENOMEM; in netback_probe()
1017 be->dev = dev; in netback_probe()
1018 dev_set_drvdata(&dev->dev, be); in netback_probe()
1029 err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", sg); in netback_probe()
1031 message = "writing feature-sg"; in netback_probe()
1035 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", in netback_probe()
1038 message = "writing feature-gso-tcpv4"; in netback_probe()
1042 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv6", in netback_probe()
1045 message = "writing feature-gso-tcpv6"; in netback_probe()
1050 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1051 "feature-ipv6-csum-offload", in netback_probe()
1054 message = "writing feature-ipv6-csum-offload"; in netback_probe()
1058 /* We support rx-copy path. */ in netback_probe()
1059 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1060 "feature-rx-copy", "%d", 1); in netback_probe()
1062 message = "writing feature-rx-copy"; in netback_probe()
1067 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1068 "feature-xdp-headroom", "%d", in netback_probe()
1071 message = "writing feature-xdp-headroom"; in netback_probe()
1075 /* We don't support rx-flip path (except old guests who in netback_probe()
1078 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1079 "feature-rx-flip", "%d", 0); in netback_probe()
1081 message = "writing feature-rx-flip"; in netback_probe()
1085 /* We support dynamic multicast-control. */ in netback_probe()
1086 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1087 "feature-multicast-control", "%d", 1); in netback_probe()
1089 message = "writing feature-multicast-control"; in netback_probe()
1093 err = xenbus_printf(xbt, dev->nodename, in netback_probe()
1094 "feature-dynamic-multicast-control", in netback_probe()
1097 message = "writing feature-dynamic-multicast-control"; in netback_probe()
1102 } while (err == -EAGAIN); in netback_probe()
1112 err = xenbus_printf(XBT_NIL, dev->nodename, in netback_probe()
1113 "feature-split-event-channels", in netback_probe()
1116 pr_debug("Error writing feature-split-event-channels\n"); in netback_probe()
1118 /* Multi-queue support: This is an optional feature. */ in netback_probe()
1119 err = xenbus_printf(XBT_NIL, dev->nodename, in netback_probe()
1120 "multi-queue-max-queues", "%u", xenvif_max_queues); in netback_probe()
1122 pr_debug("Error writing multi-queue-max-queues\n"); in netback_probe()
1124 err = xenbus_printf(XBT_NIL, dev->nodename, in netback_probe()
1125 "feature-ctrl-ring", in netback_probe()
1128 pr_debug("Error writing feature-ctrl-ring\n"); in netback_probe()
1132 script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL); in netback_probe()
1139 be->hotplug_script = script; in netback_probe()
1163 .ids = netback_ids,