.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Xenbus code for netif backend |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au> |
---|
5 | 6 | * Copyright (C) 2005 XenSource Ltd |
---|
6 | | - * |
---|
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. |
---|
11 | | - * |
---|
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. |
---|
16 | | - * |
---|
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/>. |
---|
19 | 7 | */ |
---|
20 | 8 | |
---|
21 | 9 | #include "common.h" |
---|
22 | 10 | #include <linux/vmalloc.h> |
---|
23 | 11 | #include <linux/rtnetlink.h> |
---|
24 | | - |
---|
25 | | -struct backend_info { |
---|
26 | | - struct xenbus_device *dev; |
---|
27 | | - struct xenvif *vif; |
---|
28 | | - |
---|
29 | | - /* This is the state that will be reflected in xenstore when any |
---|
30 | | - * active hotplug script completes. |
---|
31 | | - */ |
---|
32 | | - enum xenbus_state state; |
---|
33 | | - |
---|
34 | | - enum xenbus_state frontend_state; |
---|
35 | | - struct xenbus_watch hotplug_status_watch; |
---|
36 | | - u8 have_hotplug_status_watch:1; |
---|
37 | | - |
---|
38 | | - const char *hotplug_script; |
---|
39 | | -}; |
---|
40 | 12 | |
---|
41 | 13 | static int connect_data_rings(struct backend_info *be, |
---|
42 | 14 | struct xenvif_queue *queue); |
---|
.. | .. |
---|
186 | 158 | .write = xenvif_write_io_ring, |
---|
187 | 159 | }; |
---|
188 | 160 | |
---|
189 | | -static int xenvif_read_ctrl(struct seq_file *m, void *v) |
---|
| 161 | +static int xenvif_ctrl_show(struct seq_file *m, void *v) |
---|
190 | 162 | { |
---|
191 | 163 | struct xenvif *vif = m->private; |
---|
192 | 164 | |
---|
.. | .. |
---|
194 | 166 | |
---|
195 | 167 | return 0; |
---|
196 | 168 | } |
---|
197 | | - |
---|
198 | | -static int xenvif_ctrl_open(struct inode *inode, struct file *filp) |
---|
199 | | -{ |
---|
200 | | - return single_open(filp, xenvif_read_ctrl, inode->i_private); |
---|
201 | | -} |
---|
202 | | - |
---|
203 | | -static const struct file_operations xenvif_dbg_ctrl_ops_fops = { |
---|
204 | | - .owner = THIS_MODULE, |
---|
205 | | - .open = xenvif_ctrl_open, |
---|
206 | | - .read = seq_read, |
---|
207 | | - .llseek = seq_lseek, |
---|
208 | | - .release = single_release, |
---|
209 | | -}; |
---|
| 169 | +DEFINE_SHOW_ATTRIBUTE(xenvif_ctrl); |
---|
210 | 170 | |
---|
211 | 171 | static void xenvif_debugfs_addif(struct xenvif *vif) |
---|
212 | 172 | { |
---|
213 | | - struct dentry *pfile; |
---|
214 | 173 | int i; |
---|
215 | | - |
---|
216 | | - if (IS_ERR_OR_NULL(xen_netback_dbg_root)) |
---|
217 | | - return; |
---|
218 | 174 | |
---|
219 | 175 | vif->xenvif_dbg_root = debugfs_create_dir(vif->dev->name, |
---|
220 | 176 | xen_netback_dbg_root); |
---|
221 | | - if (!IS_ERR_OR_NULL(vif->xenvif_dbg_root)) { |
---|
222 | | - for (i = 0; i < vif->num_queues; ++i) { |
---|
223 | | - char filename[sizeof("io_ring_q") + 4]; |
---|
| 177 | + for (i = 0; i < vif->num_queues; ++i) { |
---|
| 178 | + char filename[sizeof("io_ring_q") + 4]; |
---|
224 | 179 | |
---|
225 | | - snprintf(filename, sizeof(filename), "io_ring_q%d", i); |
---|
226 | | - pfile = debugfs_create_file(filename, |
---|
227 | | - 0600, |
---|
228 | | - vif->xenvif_dbg_root, |
---|
229 | | - &vif->queues[i], |
---|
230 | | - &xenvif_dbg_io_ring_ops_fops); |
---|
231 | | - if (IS_ERR_OR_NULL(pfile)) |
---|
232 | | - pr_warn("Creation of io_ring file returned %ld!\n", |
---|
233 | | - PTR_ERR(pfile)); |
---|
234 | | - } |
---|
| 180 | + snprintf(filename, sizeof(filename), "io_ring_q%d", i); |
---|
| 181 | + debugfs_create_file(filename, 0600, vif->xenvif_dbg_root, |
---|
| 182 | + &vif->queues[i], |
---|
| 183 | + &xenvif_dbg_io_ring_ops_fops); |
---|
| 184 | + } |
---|
235 | 185 | |
---|
236 | | - if (vif->ctrl_irq) { |
---|
237 | | - pfile = debugfs_create_file("ctrl", |
---|
238 | | - 0400, |
---|
239 | | - vif->xenvif_dbg_root, |
---|
240 | | - vif, |
---|
241 | | - &xenvif_dbg_ctrl_ops_fops); |
---|
242 | | - if (IS_ERR_OR_NULL(pfile)) |
---|
243 | | - pr_warn("Creation of ctrl file returned %ld!\n", |
---|
244 | | - PTR_ERR(pfile)); |
---|
245 | | - } |
---|
246 | | - } else |
---|
247 | | - netdev_warn(vif->dev, |
---|
248 | | - "Creation of vif debugfs dir returned %ld!\n", |
---|
249 | | - PTR_ERR(vif->xenvif_dbg_root)); |
---|
| 186 | + if (vif->ctrl_irq) |
---|
| 187 | + debugfs_create_file("ctrl", 0400, vif->xenvif_dbg_root, vif, |
---|
| 188 | + &xenvif_ctrl_fops); |
---|
250 | 189 | } |
---|
251 | 190 | |
---|
252 | 191 | static void xenvif_debugfs_delif(struct xenvif *vif) |
---|
253 | 192 | { |
---|
254 | | - if (IS_ERR_OR_NULL(xen_netback_dbg_root)) |
---|
255 | | - return; |
---|
256 | | - |
---|
257 | | - if (!IS_ERR_OR_NULL(vif->xenvif_dbg_root)) |
---|
258 | | - debugfs_remove_recursive(vif->xenvif_dbg_root); |
---|
| 193 | + debugfs_remove_recursive(vif->xenvif_dbg_root); |
---|
259 | 194 | vif->xenvif_dbg_root = NULL; |
---|
260 | 195 | } |
---|
261 | 196 | #endif /* CONFIG_DEBUG_FS */ |
---|
262 | | - |
---|
263 | | -static int netback_remove(struct xenbus_device *dev) |
---|
264 | | -{ |
---|
265 | | - struct backend_info *be = dev_get_drvdata(&dev->dev); |
---|
266 | | - |
---|
267 | | - set_backend_state(be, XenbusStateClosed); |
---|
268 | | - |
---|
269 | | - unregister_hotplug_status_watch(be); |
---|
270 | | - if (be->vif) { |
---|
271 | | - kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE); |
---|
272 | | - xen_unregister_watchers(be->vif); |
---|
273 | | - xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status"); |
---|
274 | | - xenvif_free(be->vif); |
---|
275 | | - be->vif = NULL; |
---|
276 | | - } |
---|
277 | | - kfree(be->hotplug_script); |
---|
278 | | - kfree(be); |
---|
279 | | - dev_set_drvdata(&dev->dev, NULL); |
---|
280 | | - return 0; |
---|
281 | | -} |
---|
282 | | - |
---|
283 | | - |
---|
284 | | -/** |
---|
285 | | - * Entry point to this code when a new device is created. Allocate the basic |
---|
286 | | - * structures and switch to InitWait. |
---|
287 | | - */ |
---|
288 | | -static int netback_probe(struct xenbus_device *dev, |
---|
289 | | - const struct xenbus_device_id *id) |
---|
290 | | -{ |
---|
291 | | - const char *message; |
---|
292 | | - struct xenbus_transaction xbt; |
---|
293 | | - int err; |
---|
294 | | - int sg; |
---|
295 | | - const char *script; |
---|
296 | | - struct backend_info *be = kzalloc(sizeof(struct backend_info), |
---|
297 | | - GFP_KERNEL); |
---|
298 | | - if (!be) { |
---|
299 | | - xenbus_dev_fatal(dev, -ENOMEM, |
---|
300 | | - "allocating backend structure"); |
---|
301 | | - return -ENOMEM; |
---|
302 | | - } |
---|
303 | | - |
---|
304 | | - be->dev = dev; |
---|
305 | | - dev_set_drvdata(&dev->dev, be); |
---|
306 | | - |
---|
307 | | - be->state = XenbusStateInitialising; |
---|
308 | | - err = xenbus_switch_state(dev, XenbusStateInitialising); |
---|
309 | | - if (err) |
---|
310 | | - goto fail; |
---|
311 | | - |
---|
312 | | - sg = 1; |
---|
313 | | - |
---|
314 | | - do { |
---|
315 | | - err = xenbus_transaction_start(&xbt); |
---|
316 | | - if (err) { |
---|
317 | | - xenbus_dev_fatal(dev, err, "starting transaction"); |
---|
318 | | - goto fail; |
---|
319 | | - } |
---|
320 | | - |
---|
321 | | - err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", sg); |
---|
322 | | - if (err) { |
---|
323 | | - message = "writing feature-sg"; |
---|
324 | | - goto abort_transaction; |
---|
325 | | - } |
---|
326 | | - |
---|
327 | | - err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", |
---|
328 | | - "%d", sg); |
---|
329 | | - if (err) { |
---|
330 | | - message = "writing feature-gso-tcpv4"; |
---|
331 | | - goto abort_transaction; |
---|
332 | | - } |
---|
333 | | - |
---|
334 | | - err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv6", |
---|
335 | | - "%d", sg); |
---|
336 | | - if (err) { |
---|
337 | | - message = "writing feature-gso-tcpv6"; |
---|
338 | | - goto abort_transaction; |
---|
339 | | - } |
---|
340 | | - |
---|
341 | | - /* We support partial checksum setup for IPv6 packets */ |
---|
342 | | - err = xenbus_printf(xbt, dev->nodename, |
---|
343 | | - "feature-ipv6-csum-offload", |
---|
344 | | - "%d", 1); |
---|
345 | | - if (err) { |
---|
346 | | - message = "writing feature-ipv6-csum-offload"; |
---|
347 | | - goto abort_transaction; |
---|
348 | | - } |
---|
349 | | - |
---|
350 | | - /* We support rx-copy path. */ |
---|
351 | | - err = xenbus_printf(xbt, dev->nodename, |
---|
352 | | - "feature-rx-copy", "%d", 1); |
---|
353 | | - if (err) { |
---|
354 | | - message = "writing feature-rx-copy"; |
---|
355 | | - goto abort_transaction; |
---|
356 | | - } |
---|
357 | | - |
---|
358 | | - /* |
---|
359 | | - * We don't support rx-flip path (except old guests who don't |
---|
360 | | - * grok this feature flag). |
---|
361 | | - */ |
---|
362 | | - err = xenbus_printf(xbt, dev->nodename, |
---|
363 | | - "feature-rx-flip", "%d", 0); |
---|
364 | | - if (err) { |
---|
365 | | - message = "writing feature-rx-flip"; |
---|
366 | | - goto abort_transaction; |
---|
367 | | - } |
---|
368 | | - |
---|
369 | | - /* We support dynamic multicast-control. */ |
---|
370 | | - err = xenbus_printf(xbt, dev->nodename, |
---|
371 | | - "feature-multicast-control", "%d", 1); |
---|
372 | | - if (err) { |
---|
373 | | - message = "writing feature-multicast-control"; |
---|
374 | | - goto abort_transaction; |
---|
375 | | - } |
---|
376 | | - |
---|
377 | | - err = xenbus_printf(xbt, dev->nodename, |
---|
378 | | - "feature-dynamic-multicast-control", |
---|
379 | | - "%d", 1); |
---|
380 | | - if (err) { |
---|
381 | | - message = "writing feature-dynamic-multicast-control"; |
---|
382 | | - goto abort_transaction; |
---|
383 | | - } |
---|
384 | | - |
---|
385 | | - err = xenbus_transaction_end(xbt, 0); |
---|
386 | | - } while (err == -EAGAIN); |
---|
387 | | - |
---|
388 | | - if (err) { |
---|
389 | | - xenbus_dev_fatal(dev, err, "completing transaction"); |
---|
390 | | - goto fail; |
---|
391 | | - } |
---|
392 | | - |
---|
393 | | - /* |
---|
394 | | - * Split event channels support, this is optional so it is not |
---|
395 | | - * put inside the above loop. |
---|
396 | | - */ |
---|
397 | | - err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
398 | | - "feature-split-event-channels", |
---|
399 | | - "%u", separate_tx_rx_irq); |
---|
400 | | - if (err) |
---|
401 | | - pr_debug("Error writing feature-split-event-channels\n"); |
---|
402 | | - |
---|
403 | | - /* Multi-queue support: This is an optional feature. */ |
---|
404 | | - err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
405 | | - "multi-queue-max-queues", "%u", xenvif_max_queues); |
---|
406 | | - if (err) |
---|
407 | | - pr_debug("Error writing multi-queue-max-queues\n"); |
---|
408 | | - |
---|
409 | | - err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
410 | | - "feature-ctrl-ring", |
---|
411 | | - "%u", true); |
---|
412 | | - if (err) |
---|
413 | | - pr_debug("Error writing feature-ctrl-ring\n"); |
---|
414 | | - |
---|
415 | | - script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL); |
---|
416 | | - if (IS_ERR(script)) { |
---|
417 | | - err = PTR_ERR(script); |
---|
418 | | - xenbus_dev_fatal(dev, err, "reading script"); |
---|
419 | | - goto fail; |
---|
420 | | - } |
---|
421 | | - |
---|
422 | | - be->hotplug_script = script; |
---|
423 | | - |
---|
424 | | - |
---|
425 | | - /* This kicks hotplug scripts, so do it immediately. */ |
---|
426 | | - err = backend_create_xenvif(be); |
---|
427 | | - if (err) |
---|
428 | | - goto fail; |
---|
429 | | - |
---|
430 | | - return 0; |
---|
431 | | - |
---|
432 | | -abort_transaction: |
---|
433 | | - xenbus_transaction_end(xbt, 1); |
---|
434 | | - xenbus_dev_fatal(dev, err, "%s", message); |
---|
435 | | -fail: |
---|
436 | | - pr_debug("failed\n"); |
---|
437 | | - netback_remove(dev); |
---|
438 | | - return err; |
---|
439 | | -} |
---|
440 | | - |
---|
441 | 197 | |
---|
442 | 198 | /* |
---|
443 | 199 | * Handle the creation of the hotplug script environment. We add the script |
---|
.. | .. |
---|
485 | 241 | return err; |
---|
486 | 242 | } |
---|
487 | 243 | be->vif = vif; |
---|
| 244 | + vif->be = be; |
---|
488 | 245 | |
---|
489 | 246 | kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE); |
---|
490 | 247 | return 0; |
---|
.. | .. |
---|
636 | 393 | } |
---|
637 | 394 | } |
---|
638 | 395 | |
---|
| 396 | +static void read_xenbus_frontend_xdp(struct backend_info *be, |
---|
| 397 | + struct xenbus_device *dev) |
---|
| 398 | +{ |
---|
| 399 | + struct xenvif *vif = be->vif; |
---|
| 400 | + u16 headroom; |
---|
| 401 | + int err; |
---|
| 402 | + |
---|
| 403 | + err = xenbus_scanf(XBT_NIL, dev->otherend, |
---|
| 404 | + "xdp-headroom", "%hu", &headroom); |
---|
| 405 | + if (err != 1) { |
---|
| 406 | + vif->xdp_headroom = 0; |
---|
| 407 | + return; |
---|
| 408 | + } |
---|
| 409 | + if (headroom > XEN_NETIF_MAX_XDP_HEADROOM) |
---|
| 410 | + headroom = XEN_NETIF_MAX_XDP_HEADROOM; |
---|
| 411 | + vif->xdp_headroom = headroom; |
---|
| 412 | +} |
---|
| 413 | + |
---|
639 | 414 | /** |
---|
640 | 415 | * Callback received when the frontend's state changes. |
---|
641 | 416 | */ |
---|
.. | .. |
---|
660 | 435 | set_backend_state(be, XenbusStateConnected); |
---|
661 | 436 | break; |
---|
662 | 437 | |
---|
| 438 | + case XenbusStateReconfiguring: |
---|
| 439 | + read_xenbus_frontend_xdp(be, dev); |
---|
| 440 | + xenbus_switch_state(dev, XenbusStateReconfigured); |
---|
| 441 | + break; |
---|
| 442 | + |
---|
663 | 443 | case XenbusStateClosing: |
---|
664 | 444 | set_backend_state(be, XenbusStateClosing); |
---|
665 | 445 | break; |
---|
.. | .. |
---|
668 | 448 | set_backend_state(be, XenbusStateClosed); |
---|
669 | 449 | if (xenbus_dev_is_online(dev)) |
---|
670 | 450 | break; |
---|
671 | | - /* fall through if not online */ |
---|
| 451 | + fallthrough; /* if not online */ |
---|
672 | 452 | case XenbusStateUnknown: |
---|
673 | 453 | set_backend_state(be, XenbusStateClosed); |
---|
674 | 454 | device_unregister(&dev->dev); |
---|
.. | .. |
---|
1043 | 823 | xenvif_carrier_on(be->vif); |
---|
1044 | 824 | |
---|
1045 | 825 | unregister_hotplug_status_watch(be); |
---|
1046 | | - if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) { |
---|
1047 | | - err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, |
---|
1048 | | - NULL, hotplug_status_changed, |
---|
1049 | | - "%s/%s", dev->nodename, |
---|
1050 | | - "hotplug-status"); |
---|
1051 | | - if (err) |
---|
1052 | | - goto err; |
---|
| 826 | + err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL, |
---|
| 827 | + hotplug_status_changed, |
---|
| 828 | + "%s/%s", dev->nodename, "hotplug-status"); |
---|
| 829 | + if (!err) |
---|
1053 | 830 | be->have_hotplug_status_watch = 1; |
---|
1054 | | - } |
---|
1055 | 831 | |
---|
1056 | 832 | netif_tx_wake_all_queues(be->vif->dev); |
---|
1057 | 833 | |
---|
.. | .. |
---|
1197 | 973 | vif->ipv6_csum = !!xenbus_read_unsigned(dev->otherend, |
---|
1198 | 974 | "feature-ipv6-csum-offload", 0); |
---|
1199 | 975 | |
---|
| 976 | + read_xenbus_frontend_xdp(be, dev); |
---|
| 977 | + |
---|
1200 | 978 | return 0; |
---|
| 979 | +} |
---|
| 980 | + |
---|
| 981 | +static int netback_remove(struct xenbus_device *dev) |
---|
| 982 | +{ |
---|
| 983 | + struct backend_info *be = dev_get_drvdata(&dev->dev); |
---|
| 984 | + |
---|
| 985 | + unregister_hotplug_status_watch(be); |
---|
| 986 | + xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status"); |
---|
| 987 | + if (be->vif) { |
---|
| 988 | + kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE); |
---|
| 989 | + backend_disconnect(be); |
---|
| 990 | + xenvif_free(be->vif); |
---|
| 991 | + be->vif = NULL; |
---|
| 992 | + } |
---|
| 993 | + kfree(be->hotplug_script); |
---|
| 994 | + kfree(be); |
---|
| 995 | + dev_set_drvdata(&dev->dev, NULL); |
---|
| 996 | + return 0; |
---|
| 997 | +} |
---|
| 998 | + |
---|
| 999 | +/** |
---|
| 1000 | + * Entry point to this code when a new device is created. Allocate the basic |
---|
| 1001 | + * structures and switch to InitWait. |
---|
| 1002 | + */ |
---|
| 1003 | +static int netback_probe(struct xenbus_device *dev, |
---|
| 1004 | + const struct xenbus_device_id *id) |
---|
| 1005 | +{ |
---|
| 1006 | + const char *message; |
---|
| 1007 | + struct xenbus_transaction xbt; |
---|
| 1008 | + int err; |
---|
| 1009 | + int sg; |
---|
| 1010 | + const char *script; |
---|
| 1011 | + struct backend_info *be = kzalloc(sizeof(*be), GFP_KERNEL); |
---|
| 1012 | + |
---|
| 1013 | + if (!be) { |
---|
| 1014 | + xenbus_dev_fatal(dev, -ENOMEM, |
---|
| 1015 | + "allocating backend structure"); |
---|
| 1016 | + return -ENOMEM; |
---|
| 1017 | + } |
---|
| 1018 | + |
---|
| 1019 | + be->dev = dev; |
---|
| 1020 | + dev_set_drvdata(&dev->dev, be); |
---|
| 1021 | + |
---|
| 1022 | + sg = 1; |
---|
| 1023 | + |
---|
| 1024 | + do { |
---|
| 1025 | + err = xenbus_transaction_start(&xbt); |
---|
| 1026 | + if (err) { |
---|
| 1027 | + xenbus_dev_fatal(dev, err, "starting transaction"); |
---|
| 1028 | + goto fail; |
---|
| 1029 | + } |
---|
| 1030 | + |
---|
| 1031 | + err = xenbus_printf(xbt, dev->nodename, "feature-sg", "%d", sg); |
---|
| 1032 | + if (err) { |
---|
| 1033 | + message = "writing feature-sg"; |
---|
| 1034 | + goto abort_transaction; |
---|
| 1035 | + } |
---|
| 1036 | + |
---|
| 1037 | + err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", |
---|
| 1038 | + "%d", sg); |
---|
| 1039 | + if (err) { |
---|
| 1040 | + message = "writing feature-gso-tcpv4"; |
---|
| 1041 | + goto abort_transaction; |
---|
| 1042 | + } |
---|
| 1043 | + |
---|
| 1044 | + err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv6", |
---|
| 1045 | + "%d", sg); |
---|
| 1046 | + if (err) { |
---|
| 1047 | + message = "writing feature-gso-tcpv6"; |
---|
| 1048 | + goto abort_transaction; |
---|
| 1049 | + } |
---|
| 1050 | + |
---|
| 1051 | + /* We support partial checksum setup for IPv6 packets */ |
---|
| 1052 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1053 | + "feature-ipv6-csum-offload", |
---|
| 1054 | + "%d", 1); |
---|
| 1055 | + if (err) { |
---|
| 1056 | + message = "writing feature-ipv6-csum-offload"; |
---|
| 1057 | + goto abort_transaction; |
---|
| 1058 | + } |
---|
| 1059 | + |
---|
| 1060 | + /* We support rx-copy path. */ |
---|
| 1061 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1062 | + "feature-rx-copy", "%d", 1); |
---|
| 1063 | + if (err) { |
---|
| 1064 | + message = "writing feature-rx-copy"; |
---|
| 1065 | + goto abort_transaction; |
---|
| 1066 | + } |
---|
| 1067 | + |
---|
| 1068 | + /* we can adjust a headroom for netfront XDP processing */ |
---|
| 1069 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1070 | + "feature-xdp-headroom", "%d", |
---|
| 1071 | + provides_xdp_headroom); |
---|
| 1072 | + if (err) { |
---|
| 1073 | + message = "writing feature-xdp-headroom"; |
---|
| 1074 | + goto abort_transaction; |
---|
| 1075 | + } |
---|
| 1076 | + |
---|
| 1077 | + /* We don't support rx-flip path (except old guests who |
---|
| 1078 | + * don't grok this feature flag). |
---|
| 1079 | + */ |
---|
| 1080 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1081 | + "feature-rx-flip", "%d", 0); |
---|
| 1082 | + if (err) { |
---|
| 1083 | + message = "writing feature-rx-flip"; |
---|
| 1084 | + goto abort_transaction; |
---|
| 1085 | + } |
---|
| 1086 | + |
---|
| 1087 | + /* We support dynamic multicast-control. */ |
---|
| 1088 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1089 | + "feature-multicast-control", "%d", 1); |
---|
| 1090 | + if (err) { |
---|
| 1091 | + message = "writing feature-multicast-control"; |
---|
| 1092 | + goto abort_transaction; |
---|
| 1093 | + } |
---|
| 1094 | + |
---|
| 1095 | + err = xenbus_printf(xbt, dev->nodename, |
---|
| 1096 | + "feature-dynamic-multicast-control", |
---|
| 1097 | + "%d", 1); |
---|
| 1098 | + if (err) { |
---|
| 1099 | + message = "writing feature-dynamic-multicast-control"; |
---|
| 1100 | + goto abort_transaction; |
---|
| 1101 | + } |
---|
| 1102 | + |
---|
| 1103 | + err = xenbus_transaction_end(xbt, 0); |
---|
| 1104 | + } while (err == -EAGAIN); |
---|
| 1105 | + |
---|
| 1106 | + if (err) { |
---|
| 1107 | + xenbus_dev_fatal(dev, err, "completing transaction"); |
---|
| 1108 | + goto fail; |
---|
| 1109 | + } |
---|
| 1110 | + |
---|
| 1111 | + /* Split event channels support, this is optional so it is not |
---|
| 1112 | + * put inside the above loop. |
---|
| 1113 | + */ |
---|
| 1114 | + err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
| 1115 | + "feature-split-event-channels", |
---|
| 1116 | + "%u", separate_tx_rx_irq); |
---|
| 1117 | + if (err) |
---|
| 1118 | + pr_debug("Error writing feature-split-event-channels\n"); |
---|
| 1119 | + |
---|
| 1120 | + /* Multi-queue support: This is an optional feature. */ |
---|
| 1121 | + err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
| 1122 | + "multi-queue-max-queues", "%u", xenvif_max_queues); |
---|
| 1123 | + if (err) |
---|
| 1124 | + pr_debug("Error writing multi-queue-max-queues\n"); |
---|
| 1125 | + |
---|
| 1126 | + err = xenbus_printf(XBT_NIL, dev->nodename, |
---|
| 1127 | + "feature-ctrl-ring", |
---|
| 1128 | + "%u", true); |
---|
| 1129 | + if (err) |
---|
| 1130 | + pr_debug("Error writing feature-ctrl-ring\n"); |
---|
| 1131 | + |
---|
| 1132 | + backend_switch_state(be, XenbusStateInitWait); |
---|
| 1133 | + |
---|
| 1134 | + script = xenbus_read(XBT_NIL, dev->nodename, "script", NULL); |
---|
| 1135 | + if (IS_ERR(script)) { |
---|
| 1136 | + err = PTR_ERR(script); |
---|
| 1137 | + xenbus_dev_fatal(dev, err, "reading script"); |
---|
| 1138 | + goto fail; |
---|
| 1139 | + } |
---|
| 1140 | + |
---|
| 1141 | + be->hotplug_script = script; |
---|
| 1142 | + |
---|
| 1143 | + /* This kicks hotplug scripts, so do it immediately. */ |
---|
| 1144 | + err = backend_create_xenvif(be); |
---|
| 1145 | + if (err) |
---|
| 1146 | + goto fail; |
---|
| 1147 | + |
---|
| 1148 | + return 0; |
---|
| 1149 | + |
---|
| 1150 | +abort_transaction: |
---|
| 1151 | + xenbus_transaction_end(xbt, 1); |
---|
| 1152 | + xenbus_dev_fatal(dev, err, "%s", message); |
---|
| 1153 | +fail: |
---|
| 1154 | + pr_debug("failed\n"); |
---|
| 1155 | + netback_remove(dev); |
---|
| 1156 | + return err; |
---|
1201 | 1157 | } |
---|
1202 | 1158 | |
---|
1203 | 1159 | static const struct xenbus_device_id netback_ids[] = { |
---|
.. | .. |
---|
1211 | 1167 | .remove = netback_remove, |
---|
1212 | 1168 | .uevent = netback_uevent, |
---|
1213 | 1169 | .otherend_changed = frontend_changed, |
---|
| 1170 | + .allow_rebind = true, |
---|
1214 | 1171 | }; |
---|
1215 | 1172 | |
---|
1216 | 1173 | int xenvif_xenbus_init(void) |
---|