2 * Xenbus code for netif backend
4 * Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
5 * Copyright (C) 2005 XenSource Ltd
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include <linux/vmalloc.h>
23 #include <linux/rtnetlink.h>
26 struct xenbus_device *dev;
29 /* This is the state that will be reflected in xenstore when any
30 * active hotplug script completes.
32 enum xenbus_state state;
34 enum xenbus_state frontend_state;
35 struct xenbus_watch hotplug_status_watch;
36 u8 have_hotplug_status_watch:1;
39 static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
40 static void connect(struct backend_info *be);
41 static int read_xenbus_vif_flags(struct backend_info *be);
42 static int backend_create_xenvif(struct backend_info *be);
43 static void unregister_hotplug_status_watch(struct backend_info *be);
44 static void xen_unregister_watchers(struct xenvif *vif);
45 static void set_backend_state(struct backend_info *be,
46 enum xenbus_state state);
48 #ifdef CONFIG_DEBUG_FS
49 struct dentry *xen_netback_dbg_root = NULL;
51 static int xenvif_read_io_ring(struct seq_file *m, void *v)
53 struct xenvif_queue *queue = m->private;
54 struct xen_netif_tx_back_ring *tx_ring = &queue->tx;
55 struct xen_netif_rx_back_ring *rx_ring = &queue->rx;
56 struct netdev_queue *dev_queue;
59 struct xen_netif_tx_sring *sring = tx_ring->sring;
61 seq_printf(m, "Queue %d\nTX: nr_ents %u\n", queue->id,
63 seq_printf(m, "req prod %u (%d) cons %u (%d) event %u (%d)\n",
65 sring->req_prod - sring->rsp_prod,
67 tx_ring->req_cons - sring->rsp_prod,
69 sring->req_event - sring->rsp_prod);
70 seq_printf(m, "rsp prod %u (base) pvt %u (%d) event %u (%d)\n",
72 tx_ring->rsp_prod_pvt,
73 tx_ring->rsp_prod_pvt - sring->rsp_prod,
75 sring->rsp_event - sring->rsp_prod);
76 seq_printf(m, "pending prod %u pending cons %u nr_pending_reqs %u\n",
79 nr_pending_reqs(queue));
80 seq_printf(m, "dealloc prod %u dealloc cons %u dealloc_queue %u\n\n",
83 queue->dealloc_prod - queue->dealloc_cons);
87 struct xen_netif_rx_sring *sring = rx_ring->sring;
89 seq_printf(m, "RX: nr_ents %u\n", rx_ring->nr_ents);
90 seq_printf(m, "req prod %u (%d) cons %u (%d) event %u (%d)\n",
92 sring->req_prod - sring->rsp_prod,
94 rx_ring->req_cons - sring->rsp_prod,
96 sring->req_event - sring->rsp_prod);
97 seq_printf(m, "rsp prod %u (base) pvt %u (%d) event %u (%d)\n\n",
99 rx_ring->rsp_prod_pvt,
100 rx_ring->rsp_prod_pvt - sring->rsp_prod,
102 sring->rsp_event - sring->rsp_prod);
105 seq_printf(m, "NAPI state: %lx NAPI weight: %d TX queue len %u\n"
106 "Credit timer_pending: %d, credit: %lu, usec: %lu\n"
107 "remaining: %lu, expires: %lu, now: %lu\n",
108 queue->napi.state, queue->napi.weight,
109 skb_queue_len(&queue->tx_queue),
110 timer_pending(&queue->credit_timeout),
113 queue->remaining_credit,
114 queue->credit_timeout.expires,
117 dev_queue = netdev_get_tx_queue(queue->vif->dev, queue->id);
119 seq_printf(m, "\nRx internal queue: len %u max %u pkts %u %s\n",
120 queue->rx_queue_len, queue->rx_queue_max,
121 skb_queue_len(&queue->rx_queue),
122 netif_tx_queue_stopped(dev_queue) ? "stopped" : "running");
127 #define XENVIF_KICK_STR "kick"
128 #define BUFFER_SIZE 32
131 xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
134 struct xenvif_queue *queue =
135 ((struct seq_file *)filp->private_data)->private;
137 char write[BUFFER_SIZE];
139 /* don't allow partial writes and check the length */
142 if (count >= sizeof(write))
145 len = simple_write_to_buffer(write,
155 if (!strncmp(write, XENVIF_KICK_STR, sizeof(XENVIF_KICK_STR) - 1))
156 xenvif_interrupt(0, (void *)queue);
158 pr_warn("Unknown command to io_ring_q%d. Available: kick\n",
165 static int xenvif_dump_open(struct inode *inode, struct file *filp)
170 if (inode->i_private)
171 queue = inode->i_private;
172 ret = single_open(filp, xenvif_read_io_ring, queue);
173 filp->f_mode |= FMODE_PWRITE;
177 static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
178 .owner = THIS_MODULE,
179 .open = xenvif_dump_open,
182 .release = single_release,
183 .write = xenvif_write_io_ring,
186 static void xenvif_debugfs_addif(struct xenvif *vif)
188 struct dentry *pfile;
191 if (IS_ERR_OR_NULL(xen_netback_dbg_root))
194 vif->xenvif_dbg_root = debugfs_create_dir(vif->dev->name,
195 xen_netback_dbg_root);
196 if (!IS_ERR_OR_NULL(vif->xenvif_dbg_root)) {
197 for (i = 0; i < vif->num_queues; ++i) {
198 char filename[sizeof("io_ring_q") + 4];
200 snprintf(filename, sizeof(filename), "io_ring_q%d", i);
201 pfile = debugfs_create_file(filename,
203 vif->xenvif_dbg_root,
205 &xenvif_dbg_io_ring_ops_fops);
206 if (IS_ERR_OR_NULL(pfile))
207 pr_warn("Creation of io_ring file returned %ld!\n",
211 netdev_warn(vif->dev,
212 "Creation of vif debugfs dir returned %ld!\n",
213 PTR_ERR(vif->xenvif_dbg_root));
216 static void xenvif_debugfs_delif(struct xenvif *vif)
218 if (IS_ERR_OR_NULL(xen_netback_dbg_root))
221 if (!IS_ERR_OR_NULL(vif->xenvif_dbg_root))
222 debugfs_remove_recursive(vif->xenvif_dbg_root);
223 vif->xenvif_dbg_root = NULL;
225 #endif /* CONFIG_DEBUG_FS */
227 static int netback_remove(struct xenbus_device *dev)
229 struct backend_info *be = dev_get_drvdata(&dev->dev);
231 set_backend_state(be, XenbusStateClosed);
233 unregister_hotplug_status_watch(be);
235 kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
236 xen_unregister_watchers(be->vif);
237 xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
238 xenvif_free(be->vif);
242 dev_set_drvdata(&dev->dev, NULL);
248 * Entry point to this code when a new device is created. Allocate the basic
249 * structures and switch to InitWait.
251 static int netback_probe(struct xenbus_device *dev,
252 const struct xenbus_device_id *id)
255 struct xenbus_transaction xbt;
258 struct backend_info *be = kzalloc(sizeof(struct backend_info),
261 xenbus_dev_fatal(dev, -ENOMEM,
262 "allocating backend structure");
267 dev_set_drvdata(&dev->dev, be);
272 err = xenbus_transaction_start(&xbt);
274 xenbus_dev_fatal(dev, err, "starting transaction");
278 err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", sg);
280 message = "writing feature-sg";
281 goto abort_transaction;
284 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4",
287 message = "writing feature-gso-tcpv4";
288 goto abort_transaction;
291 err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv6",
294 message = "writing feature-gso-tcpv6";
295 goto abort_transaction;
298 /* We support partial checksum setup for IPv6 packets */
299 err = xenbus_printf(xbt, dev->nodename,
300 "feature-ipv6-csum-offload",
303 message = "writing feature-ipv6-csum-offload";
304 goto abort_transaction;
307 /* We support rx-copy path. */
308 err = xenbus_printf(xbt, dev->nodename,
309 "feature-rx-copy", "%d", 1);
311 message = "writing feature-rx-copy";
312 goto abort_transaction;
316 * We don't support rx-flip path (except old guests who don't
317 * grok this feature flag).
319 err = xenbus_printf(xbt, dev->nodename,
320 "feature-rx-flip", "%d", 0);
322 message = "writing feature-rx-flip";
323 goto abort_transaction;
326 err = xenbus_transaction_end(xbt, 0);
327 } while (err == -EAGAIN);
330 xenbus_dev_fatal(dev, err, "completing transaction");
335 * Split event channels support, this is optional so it is not
336 * put inside the above loop.
338 err = xenbus_printf(XBT_NIL, dev->nodename,
339 "feature-split-event-channels",
340 "%u", separate_tx_rx_irq);
342 pr_debug("Error writing feature-split-event-channels\n");
344 /* Multi-queue support: This is an optional feature. */
345 err = xenbus_printf(XBT_NIL, dev->nodename,
346 "multi-queue-max-queues", "%u", xenvif_max_queues);
348 pr_debug("Error writing multi-queue-max-queues\n");
350 err = xenbus_switch_state(dev, XenbusStateInitWait);
354 be->state = XenbusStateInitWait;
356 /* This kicks hotplug scripts, so do it immediately. */
357 err = backend_create_xenvif(be);
364 xenbus_transaction_end(xbt, 1);
365 xenbus_dev_fatal(dev, err, "%s", message);
367 pr_debug("failed\n");
374 * Handle the creation of the hotplug script environment. We add the script
375 * and vif variables to the environment, for the benefit of the vif-* hotplug
378 static int netback_uevent(struct xenbus_device *xdev,
379 struct kobj_uevent_env *env)
381 struct backend_info *be = dev_get_drvdata(&xdev->dev);
384 val = xenbus_read(XBT_NIL, xdev->nodename, "script", NULL);
386 int err = PTR_ERR(val);
387 xenbus_dev_fatal(xdev, err, "reading script");
390 if (add_uevent_var(env, "script=%s", val)) {
400 return add_uevent_var(env, "vif=%s", be->vif->dev->name);
404 static int backend_create_xenvif(struct backend_info *be)
408 struct xenbus_device *dev = be->dev;
414 err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
416 xenbus_dev_fatal(dev, err, "reading handle");
417 return (err < 0) ? err : -EINVAL;
420 vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
423 xenbus_dev_fatal(dev, err, "creating interface");
428 kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
432 static void backend_disconnect(struct backend_info *be)
435 xen_unregister_watchers(be->vif);
436 #ifdef CONFIG_DEBUG_FS
437 xenvif_debugfs_delif(be->vif);
438 #endif /* CONFIG_DEBUG_FS */
439 xenvif_disconnect(be->vif);
443 static void backend_connect(struct backend_info *be)
449 static inline void backend_switch_state(struct backend_info *be,
450 enum xenbus_state state)
452 struct xenbus_device *dev = be->dev;
454 pr_debug("%s -> %s\n", dev->nodename, xenbus_strstate(state));
457 /* If we are waiting for a hotplug script then defer the
458 * actual xenbus state change.
460 if (!be->have_hotplug_status_watch)
461 xenbus_switch_state(dev, state);
464 /* Handle backend state transitions:
466 * The backend state starts in InitWait and the following transitions are
469 * InitWait -> Connected
481 * The state argument specifies the eventual state of the backend and the
482 * function transitions to that state via the shortest path.
484 static void set_backend_state(struct backend_info *be,
485 enum xenbus_state state)
487 while (be->state != state) {
489 case XenbusStateClosed:
491 case XenbusStateInitWait:
492 case XenbusStateConnected:
493 pr_info("%s: prepare for reconnect\n",
495 backend_switch_state(be, XenbusStateInitWait);
497 case XenbusStateClosing:
498 backend_switch_state(be, XenbusStateClosing);
504 case XenbusStateInitWait:
506 case XenbusStateConnected:
508 backend_switch_state(be, XenbusStateConnected);
510 case XenbusStateClosing:
511 case XenbusStateClosed:
512 backend_switch_state(be, XenbusStateClosing);
518 case XenbusStateConnected:
520 case XenbusStateInitWait:
521 case XenbusStateClosing:
522 case XenbusStateClosed:
523 backend_disconnect(be);
524 backend_switch_state(be, XenbusStateClosing);
530 case XenbusStateClosing:
532 case XenbusStateInitWait:
533 case XenbusStateConnected:
534 case XenbusStateClosed:
535 backend_switch_state(be, XenbusStateClosed);
548 * Callback received when the frontend's state changes.
550 static void frontend_changed(struct xenbus_device *dev,
551 enum xenbus_state frontend_state)
553 struct backend_info *be = dev_get_drvdata(&dev->dev);
555 pr_debug("%s -> %s\n", dev->otherend, xenbus_strstate(frontend_state));
557 be->frontend_state = frontend_state;
559 switch (frontend_state) {
560 case XenbusStateInitialising:
561 set_backend_state(be, XenbusStateInitWait);
564 case XenbusStateInitialised:
567 case XenbusStateConnected:
568 set_backend_state(be, XenbusStateConnected);
571 case XenbusStateClosing:
572 set_backend_state(be, XenbusStateClosing);
575 case XenbusStateClosed:
576 set_backend_state(be, XenbusStateClosed);
577 if (xenbus_dev_is_online(dev))
579 /* fall through if not online */
580 case XenbusStateUnknown:
581 set_backend_state(be, XenbusStateClosed);
582 device_unregister(&dev->dev);
586 xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
593 static void xen_net_read_rate(struct xenbus_device *dev,
594 unsigned long *bytes, unsigned long *usec)
600 /* Default to unlimited bandwidth. */
604 ratestr = xenbus_read(XBT_NIL, dev->nodename, "rate", NULL);
609 b = simple_strtoul(s, &e, 10);
610 if ((s == e) || (*e != ','))
614 u = simple_strtoul(s, &e, 10);
615 if ((s == e) || (*e != '\0'))
625 pr_warn("Failed to parse network rate limit. Traffic unlimited.\n");
629 static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
631 char *s, *e, *macstr;
634 macstr = s = xenbus_read(XBT_NIL, dev->nodename, "mac", NULL);
636 return PTR_ERR(macstr);
638 for (i = 0; i < ETH_ALEN; i++) {
639 mac[i] = simple_strtoul(s, &e, 16);
640 if ((s == e) || (*e != ((i == ETH_ALEN-1) ? '\0' : ':'))) {
651 static void xen_net_rate_changed(struct xenbus_watch *watch,
652 const char **vec, unsigned int len)
654 struct xenvif *vif = container_of(watch, struct xenvif, credit_watch);
655 struct xenbus_device *dev = xenvif_to_xenbus_device(vif);
656 unsigned long credit_bytes;
657 unsigned long credit_usec;
658 unsigned int queue_index;
660 xen_net_read_rate(dev, &credit_bytes, &credit_usec);
661 for (queue_index = 0; queue_index < vif->num_queues; queue_index++) {
662 struct xenvif_queue *queue = &vif->queues[queue_index];
664 queue->credit_bytes = credit_bytes;
665 queue->credit_usec = credit_usec;
666 if (!mod_timer_pending(&queue->credit_timeout, jiffies) &&
667 queue->remaining_credit > queue->credit_bytes) {
668 queue->remaining_credit = queue->credit_bytes;
673 static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
677 unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
679 node = kmalloc(maxlen, GFP_KERNEL);
682 snprintf(node, maxlen, "%s/rate", dev->nodename);
683 vif->credit_watch.node = node;
684 vif->credit_watch.callback = xen_net_rate_changed;
685 err = register_xenbus_watch(&vif->credit_watch);
687 pr_err("Failed to set watcher %s\n", vif->credit_watch.node);
689 vif->credit_watch.node = NULL;
690 vif->credit_watch.callback = NULL;
695 static void xen_unregister_watchers(struct xenvif *vif)
697 if (vif->credit_watch.node) {
698 unregister_xenbus_watch(&vif->credit_watch);
699 kfree(vif->credit_watch.node);
700 vif->credit_watch.node = NULL;
704 static void unregister_hotplug_status_watch(struct backend_info *be)
706 if (be->have_hotplug_status_watch) {
707 unregister_xenbus_watch(&be->hotplug_status_watch);
708 kfree(be->hotplug_status_watch.node);
710 be->have_hotplug_status_watch = 0;
713 static void hotplug_status_changed(struct xenbus_watch *watch,
715 unsigned int vec_size)
717 struct backend_info *be = container_of(watch,
719 hotplug_status_watch);
723 str = xenbus_read(XBT_NIL, be->dev->nodename, "hotplug-status", &len);
726 if (len == sizeof("connected")-1 && !memcmp(str, "connected", len)) {
727 /* Complete any pending state change */
728 xenbus_switch_state(be->dev, be->state);
730 /* Not interested in this watch anymore. */
731 unregister_hotplug_status_watch(be);
736 static void connect(struct backend_info *be)
739 struct xenbus_device *dev = be->dev;
740 unsigned long credit_bytes, credit_usec;
741 unsigned int queue_index;
742 unsigned int requested_num_queues;
743 struct xenvif_queue *queue;
745 /* Check whether the frontend requested multiple queues
746 * and read the number requested.
748 err = xenbus_scanf(XBT_NIL, dev->otherend,
749 "multi-queue-num-queues",
750 "%u", &requested_num_queues);
752 requested_num_queues = 1; /* Fall back to single queue */
753 } else if (requested_num_queues > xenvif_max_queues) {
754 /* buggy or malicious guest */
755 xenbus_dev_fatal(dev, err,
756 "guest requested %u queues, exceeding the maximum of %u.",
757 requested_num_queues, xenvif_max_queues);
761 err = xen_net_read_mac(dev, be->vif->fe_dev_addr);
763 xenbus_dev_fatal(dev, err, "parsing %s/mac", dev->nodename);
767 xen_net_read_rate(dev, &credit_bytes, &credit_usec);
768 xen_register_watchers(dev, be->vif);
769 read_xenbus_vif_flags(be);
771 /* Use the number of queues requested by the frontend */
772 be->vif->queues = vzalloc(requested_num_queues *
773 sizeof(struct xenvif_queue));
774 be->vif->num_queues = requested_num_queues;
775 be->vif->stalled_queues = requested_num_queues;
777 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) {
778 queue = &be->vif->queues[queue_index];
779 queue->vif = be->vif;
780 queue->id = queue_index;
781 snprintf(queue->name, sizeof(queue->name), "%s-q%u",
782 be->vif->dev->name, queue->id);
784 err = xenvif_init_queue(queue);
786 /* xenvif_init_queue() cleans up after itself on
787 * failure, but we need to clean up any previously
788 * initialised queues. Set num_queues to i so that
789 * earlier queues can be destroyed using the regular
792 be->vif->num_queues = queue_index;
796 queue->credit_bytes = credit_bytes;
797 queue->remaining_credit = credit_bytes;
798 queue->credit_usec = credit_usec;
800 err = connect_rings(be, queue);
802 /* connect_rings() cleans up after itself on failure,
803 * but we need to clean up after xenvif_init_queue() here,
804 * and also clean up any previously initialised queues.
806 xenvif_deinit_queue(queue);
807 be->vif->num_queues = queue_index;
812 #ifdef CONFIG_DEBUG_FS
813 xenvif_debugfs_addif(be->vif);
814 #endif /* CONFIG_DEBUG_FS */
816 /* Initialisation completed, tell core driver the number of
820 netif_set_real_num_tx_queues(be->vif->dev, requested_num_queues);
821 netif_set_real_num_rx_queues(be->vif->dev, requested_num_queues);
824 xenvif_carrier_on(be->vif);
826 unregister_hotplug_status_watch(be);
827 err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
828 hotplug_status_changed,
829 "%s/%s", dev->nodename, "hotplug-status");
831 be->have_hotplug_status_watch = 1;
833 netif_tx_wake_all_queues(be->vif->dev);
838 if (be->vif->num_queues > 0)
839 xenvif_disconnect(be->vif); /* Clean up existing queues */
840 vfree(be->vif->queues);
841 be->vif->queues = NULL;
842 be->vif->num_queues = 0;
847 static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)
849 struct xenbus_device *dev = be->dev;
850 unsigned int num_queues = queue->vif->num_queues;
851 unsigned long tx_ring_ref, rx_ring_ref;
852 unsigned int tx_evtchn, rx_evtchn;
856 const size_t xenstore_path_ext_size = 11; /* sufficient for "/queue-NNN" */
858 /* If the frontend requested 1 queue, or we have fallen back
859 * to single queue due to lack of frontend support for multi-
860 * queue, expect the remaining XenStore keys in the toplevel
861 * directory. Otherwise, expect them in a subdirectory called
864 if (num_queues == 1) {
865 xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
867 xenbus_dev_fatal(dev, -ENOMEM,
868 "reading ring references");
871 strcpy(xspath, dev->otherend);
873 xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
874 xspath = kzalloc(xspathsize, GFP_KERNEL);
876 xenbus_dev_fatal(dev, -ENOMEM,
877 "reading ring references");
880 snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
884 err = xenbus_gather(XBT_NIL, xspath,
885 "tx-ring-ref", "%lu", &tx_ring_ref,
886 "rx-ring-ref", "%lu", &rx_ring_ref, NULL);
888 xenbus_dev_fatal(dev, err,
889 "reading %s/ring-ref",
894 /* Try split event channels first, then single event channel. */
895 err = xenbus_gather(XBT_NIL, xspath,
896 "event-channel-tx", "%u", &tx_evtchn,
897 "event-channel-rx", "%u", &rx_evtchn, NULL);
899 err = xenbus_scanf(XBT_NIL, xspath,
900 "event-channel", "%u", &tx_evtchn);
902 xenbus_dev_fatal(dev, err,
903 "reading %s/event-channel(-tx/rx)",
907 rx_evtchn = tx_evtchn;
910 /* Map the shared frame, irq etc. */
911 err = xenvif_connect(queue, tx_ring_ref, rx_ring_ref,
912 tx_evtchn, rx_evtchn);
914 xenbus_dev_fatal(dev, err,
915 "mapping shared-frames %lu/%lu port tx %u rx %u",
916 tx_ring_ref, rx_ring_ref,
917 tx_evtchn, rx_evtchn);
922 err: /* Regular return falls through with err == 0 */
927 static int read_xenbus_vif_flags(struct backend_info *be)
929 struct xenvif *vif = be->vif;
930 struct xenbus_device *dev = be->dev;
931 unsigned int rx_copy;
934 err = xenbus_scanf(XBT_NIL, dev->otherend, "request-rx-copy", "%u",
936 if (err == -ENOENT) {
941 xenbus_dev_fatal(dev, err, "reading %s/request-rx-copy",
948 if (xenbus_scanf(XBT_NIL, dev->otherend,
949 "feature-rx-notify", "%d", &val) < 0)
952 /* - Reduce drain timeout to poll more frequently for
954 * - Disable Rx stall detection.
956 be->vif->drain_timeout = msecs_to_jiffies(30);
957 be->vif->stall_timeout = 0;
960 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
966 vif->gso_prefix_mask = 0;
968 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4",
972 vif->gso_mask |= GSO_BIT(TCPV4);
974 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4-prefix",
978 vif->gso_prefix_mask |= GSO_BIT(TCPV4);
980 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv6",
984 vif->gso_mask |= GSO_BIT(TCPV6);
986 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv6-prefix",
990 vif->gso_prefix_mask |= GSO_BIT(TCPV6);
992 if (vif->gso_mask & vif->gso_prefix_mask) {
993 xenbus_dev_fatal(dev, err,
994 "%s: gso and gso prefix flags are not "
995 "mutually exclusive",
1000 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload",
1003 vif->ip_csum = !val;
1005 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-ipv6-csum-offload",
1008 vif->ipv6_csum = !!val;
1013 static const struct xenbus_device_id netback_ids[] = {
1018 static struct xenbus_driver netback_driver = {
1020 .probe = netback_probe,
1021 .remove = netback_remove,
1022 .uevent = netback_uevent,
1023 .otherend_changed = frontend_changed,
1026 int xenvif_xenbus_init(void)
1028 return xenbus_register_backend(&netback_driver);
1031 void xenvif_xenbus_fini(void)
1033 return xenbus_unregister_driver(&netback_driver);