@@ -195,185 +195,6 @@ static void xenvif_debugfs_delif(struct xenvif *vif)
195195}
196196#endif /* CONFIG_DEBUG_FS */
197197
198- static int netback_remove (struct xenbus_device * dev )
199- {
200- struct backend_info * be = dev_get_drvdata (& dev -> dev );
201-
202- set_backend_state (be , XenbusStateClosed );
203-
204- unregister_hotplug_status_watch (be );
205- if (be -> vif ) {
206- kobject_uevent (& dev -> dev .kobj , KOBJ_OFFLINE );
207- xen_unregister_watchers (be -> vif );
208- xenbus_rm (XBT_NIL , dev -> nodename , "hotplug-status" );
209- xenvif_free (be -> vif );
210- be -> vif = NULL ;
211- }
212- kfree (be -> hotplug_script );
213- kfree (be );
214- dev_set_drvdata (& dev -> dev , NULL );
215- return 0 ;
216- }
217-
218-
219- /**
220- * Entry point to this code when a new device is created. Allocate the basic
221- * structures and switch to InitWait.
222- */
223- static int netback_probe (struct xenbus_device * dev ,
224- const struct xenbus_device_id * id )
225- {
226- const char * message ;
227- struct xenbus_transaction xbt ;
228- int err ;
229- int sg ;
230- const char * script ;
231- struct backend_info * be = kzalloc (sizeof (struct backend_info ),
232- GFP_KERNEL );
233- if (!be ) {
234- xenbus_dev_fatal (dev , - ENOMEM ,
235- "allocating backend structure" );
236- return - ENOMEM ;
237- }
238-
239- be -> dev = dev ;
240- dev_set_drvdata (& dev -> dev , be );
241-
242- be -> state = XenbusStateInitialising ;
243- err = xenbus_switch_state (dev , XenbusStateInitialising );
244- if (err )
245- goto fail ;
246-
247- sg = 1 ;
248-
249- do {
250- err = xenbus_transaction_start (& xbt );
251- if (err ) {
252- xenbus_dev_fatal (dev , err , "starting transaction" );
253- goto fail ;
254- }
255-
256- err = xenbus_printf (xbt , dev -> nodename , "feature-sg" , "%d" , sg );
257- if (err ) {
258- message = "writing feature-sg" ;
259- goto abort_transaction ;
260- }
261-
262- err = xenbus_printf (xbt , dev -> nodename , "feature-gso-tcpv4" ,
263- "%d" , sg );
264- if (err ) {
265- message = "writing feature-gso-tcpv4" ;
266- goto abort_transaction ;
267- }
268-
269- err = xenbus_printf (xbt , dev -> nodename , "feature-gso-tcpv6" ,
270- "%d" , sg );
271- if (err ) {
272- message = "writing feature-gso-tcpv6" ;
273- goto abort_transaction ;
274- }
275-
276- /* We support partial checksum setup for IPv6 packets */
277- err = xenbus_printf (xbt , dev -> nodename ,
278- "feature-ipv6-csum-offload" ,
279- "%d" , 1 );
280- if (err ) {
281- message = "writing feature-ipv6-csum-offload" ;
282- goto abort_transaction ;
283- }
284-
285- /* We support rx-copy path. */
286- err = xenbus_printf (xbt , dev -> nodename ,
287- "feature-rx-copy" , "%d" , 1 );
288- if (err ) {
289- message = "writing feature-rx-copy" ;
290- goto abort_transaction ;
291- }
292-
293- /*
294- * We don't support rx-flip path (except old guests who don't
295- * grok this feature flag).
296- */
297- err = xenbus_printf (xbt , dev -> nodename ,
298- "feature-rx-flip" , "%d" , 0 );
299- if (err ) {
300- message = "writing feature-rx-flip" ;
301- goto abort_transaction ;
302- }
303-
304- /* We support dynamic multicast-control. */
305- err = xenbus_printf (xbt , dev -> nodename ,
306- "feature-multicast-control" , "%d" , 1 );
307- if (err ) {
308- message = "writing feature-multicast-control" ;
309- goto abort_transaction ;
310- }
311-
312- err = xenbus_printf (xbt , dev -> nodename ,
313- "feature-dynamic-multicast-control" ,
314- "%d" , 1 );
315- if (err ) {
316- message = "writing feature-dynamic-multicast-control" ;
317- goto abort_transaction ;
318- }
319-
320- err = xenbus_transaction_end (xbt , 0 );
321- } while (err == - EAGAIN );
322-
323- if (err ) {
324- xenbus_dev_fatal (dev , err , "completing transaction" );
325- goto fail ;
326- }
327-
328- /*
329- * Split event channels support, this is optional so it is not
330- * put inside the above loop.
331- */
332- err = xenbus_printf (XBT_NIL , dev -> nodename ,
333- "feature-split-event-channels" ,
334- "%u" , separate_tx_rx_irq );
335- if (err )
336- pr_debug ("Error writing feature-split-event-channels\n" );
337-
338- /* Multi-queue support: This is an optional feature. */
339- err = xenbus_printf (XBT_NIL , dev -> nodename ,
340- "multi-queue-max-queues" , "%u" , xenvif_max_queues );
341- if (err )
342- pr_debug ("Error writing multi-queue-max-queues\n" );
343-
344- err = xenbus_printf (XBT_NIL , dev -> nodename ,
345- "feature-ctrl-ring" ,
346- "%u" , true);
347- if (err )
348- pr_debug ("Error writing feature-ctrl-ring\n" );
349-
350- script = xenbus_read (XBT_NIL , dev -> nodename , "script" , NULL );
351- if (IS_ERR (script )) {
352- err = PTR_ERR (script );
353- xenbus_dev_fatal (dev , err , "reading script" );
354- goto fail ;
355- }
356-
357- be -> hotplug_script = script ;
358-
359-
360- /* This kicks hotplug scripts, so do it immediately. */
361- err = backend_create_xenvif (be );
362- if (err )
363- goto fail ;
364-
365- return 0 ;
366-
367- abort_transaction :
368- xenbus_transaction_end (xbt , 1 );
369- xenbus_dev_fatal (dev , err , "%s" , message );
370- fail :
371- pr_debug ("failed\n" );
372- netback_remove (dev );
373- return err ;
374- }
375-
376-
377198/*
378199 * Handle the creation of the hotplug script environment. We add the script
379200 * and vif variables to the environment, for the benefit of the vif-* hotplug
@@ -1128,6 +949,180 @@ static int read_xenbus_vif_flags(struct backend_info *be)
1128949 return 0 ;
1129950}
1130951
952+ static int netback_remove (struct xenbus_device * dev )
953+ {
954+ struct backend_info * be = dev_get_drvdata (& dev -> dev );
955+
956+ set_backend_state (be , XenbusStateClosed );
957+
958+ unregister_hotplug_status_watch (be );
959+ if (be -> vif ) {
960+ kobject_uevent (& dev -> dev .kobj , KOBJ_OFFLINE );
961+ xen_unregister_watchers (be -> vif );
962+ xenbus_rm (XBT_NIL , dev -> nodename , "hotplug-status" );
963+ xenvif_free (be -> vif );
964+ be -> vif = NULL ;
965+ }
966+ kfree (be -> hotplug_script );
967+ kfree (be );
968+ dev_set_drvdata (& dev -> dev , NULL );
969+ return 0 ;
970+ }
971+
972+ /**
973+ * Entry point to this code when a new device is created. Allocate the basic
974+ * structures and switch to InitWait.
975+ */
976+ static int netback_probe (struct xenbus_device * dev ,
977+ const struct xenbus_device_id * id )
978+ {
979+ const char * message ;
980+ struct xenbus_transaction xbt ;
981+ int err ;
982+ int sg ;
983+ const char * script ;
984+ struct backend_info * be = kzalloc (sizeof (* be ), GFP_KERNEL );
985+
986+ if (!be ) {
987+ xenbus_dev_fatal (dev , - ENOMEM ,
988+ "allocating backend structure" );
989+ return - ENOMEM ;
990+ }
991+
992+ be -> dev = dev ;
993+ dev_set_drvdata (& dev -> dev , be );
994+
995+ be -> state = XenbusStateInitialising ;
996+ err = xenbus_switch_state (dev , XenbusStateInitialising );
997+ if (err )
998+ goto fail ;
999+
1000+ sg = 1 ;
1001+
1002+ do {
1003+ err = xenbus_transaction_start (& xbt );
1004+ if (err ) {
1005+ xenbus_dev_fatal (dev , err , "starting transaction" );
1006+ goto fail ;
1007+ }
1008+
1009+ err = xenbus_printf (xbt , dev -> nodename , "feature-sg" , "%d" , sg );
1010+ if (err ) {
1011+ message = "writing feature-sg" ;
1012+ goto abort_transaction ;
1013+ }
1014+
1015+ err = xenbus_printf (xbt , dev -> nodename , "feature-gso-tcpv4" ,
1016+ "%d" , sg );
1017+ if (err ) {
1018+ message = "writing feature-gso-tcpv4" ;
1019+ goto abort_transaction ;
1020+ }
1021+
1022+ err = xenbus_printf (xbt , dev -> nodename , "feature-gso-tcpv6" ,
1023+ "%d" , sg );
1024+ if (err ) {
1025+ message = "writing feature-gso-tcpv6" ;
1026+ goto abort_transaction ;
1027+ }
1028+
1029+ /* We support partial checksum setup for IPv6 packets */
1030+ err = xenbus_printf (xbt , dev -> nodename ,
1031+ "feature-ipv6-csum-offload" ,
1032+ "%d" , 1 );
1033+ if (err ) {
1034+ message = "writing feature-ipv6-csum-offload" ;
1035+ goto abort_transaction ;
1036+ }
1037+
1038+ /* We support rx-copy path. */
1039+ err = xenbus_printf (xbt , dev -> nodename ,
1040+ "feature-rx-copy" , "%d" , 1 );
1041+ if (err ) {
1042+ message = "writing feature-rx-copy" ;
1043+ goto abort_transaction ;
1044+ }
1045+
1046+ /* We don't support rx-flip path (except old guests who
1047+ * don't grok this feature flag).
1048+ */
1049+ err = xenbus_printf (xbt , dev -> nodename ,
1050+ "feature-rx-flip" , "%d" , 0 );
1051+ if (err ) {
1052+ message = "writing feature-rx-flip" ;
1053+ goto abort_transaction ;
1054+ }
1055+
1056+ /* We support dynamic multicast-control. */
1057+ err = xenbus_printf (xbt , dev -> nodename ,
1058+ "feature-multicast-control" , "%d" , 1 );
1059+ if (err ) {
1060+ message = "writing feature-multicast-control" ;
1061+ goto abort_transaction ;
1062+ }
1063+
1064+ err = xenbus_printf (xbt , dev -> nodename ,
1065+ "feature-dynamic-multicast-control" ,
1066+ "%d" , 1 );
1067+ if (err ) {
1068+ message = "writing feature-dynamic-multicast-control" ;
1069+ goto abort_transaction ;
1070+ }
1071+
1072+ err = xenbus_transaction_end (xbt , 0 );
1073+ } while (err == - EAGAIN );
1074+
1075+ if (err ) {
1076+ xenbus_dev_fatal (dev , err , "completing transaction" );
1077+ goto fail ;
1078+ }
1079+
1080+ /* Split event channels support, this is optional so it is not
1081+ * put inside the above loop.
1082+ */
1083+ err = xenbus_printf (XBT_NIL , dev -> nodename ,
1084+ "feature-split-event-channels" ,
1085+ "%u" , separate_tx_rx_irq );
1086+ if (err )
1087+ pr_debug ("Error writing feature-split-event-channels\n" );
1088+
1089+ /* Multi-queue support: This is an optional feature. */
1090+ err = xenbus_printf (XBT_NIL , dev -> nodename ,
1091+ "multi-queue-max-queues" , "%u" , xenvif_max_queues );
1092+ if (err )
1093+ pr_debug ("Error writing multi-queue-max-queues\n" );
1094+
1095+ err = xenbus_printf (XBT_NIL , dev -> nodename ,
1096+ "feature-ctrl-ring" ,
1097+ "%u" , true);
1098+ if (err )
1099+ pr_debug ("Error writing feature-ctrl-ring\n" );
1100+
1101+ script = xenbus_read (XBT_NIL , dev -> nodename , "script" , NULL );
1102+ if (IS_ERR (script )) {
1103+ err = PTR_ERR (script );
1104+ xenbus_dev_fatal (dev , err , "reading script" );
1105+ goto fail ;
1106+ }
1107+
1108+ be -> hotplug_script = script ;
1109+
1110+ /* This kicks hotplug scripts, so do it immediately. */
1111+ err = backend_create_xenvif (be );
1112+ if (err )
1113+ goto fail ;
1114+
1115+ return 0 ;
1116+
1117+ abort_transaction :
1118+ xenbus_transaction_end (xbt , 1 );
1119+ xenbus_dev_fatal (dev , err , "%s" , message );
1120+ fail :
1121+ pr_debug ("failed\n" );
1122+ netback_remove (dev );
1123+ return err ;
1124+ }
1125+
11311126static const struct xenbus_device_id netback_ids [] = {
11321127 { "vif" },
11331128 { "" }
0 commit comments