Browse Source

[undi] Clean up driver and device name information

Fix the <NULL> driver name reported by "ifstat" when using the undipci
driver (due to the unnecessary extra device node inserted as a child
of the PCI device).

Remove the "UNDI-" prefix from device names since the driver name is
also now visible via "ifstat", and tidy up the device name to match
the format used by standard PCI devices.

The output from "ifstat" now resembles:

  iPXE> ifstat
  net0: 52:54:00:12:34:56 using undipci on 0000:00:03.0

  iPXE> ifstat
  net0: 52:54:00:12:34:56 using undionly on 0000:00:03.0

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
6997d3c2fa

+ 1
- 11
src/arch/x86/drivers/net/undi.c View File

94
 		}
94
 		}
95
 	}
95
 	}
96
 
96
 
97
-	/* Add to device hierarchy */
98
-	snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
99
-		   "UNDI-%s", pci->dev.name );
100
-	memcpy ( &undi->dev.desc, &pci->dev.desc, sizeof ( undi->dev.desc ) );
101
-	undi->dev.parent = &pci->dev;
102
-	INIT_LIST_HEAD ( &undi->dev.children );
103
-	list_add ( &undi->dev.siblings, &pci->dev.children );
104
-
105
 	/* Create network device */
97
 	/* Create network device */
106
-	if ( ( rc = undinet_probe ( undi ) ) != 0 )
98
+	if ( ( rc = undinet_probe ( undi, &pci->dev ) ) != 0 )
107
 		goto err_undinet_probe;
99
 		goto err_undinet_probe;
108
 	
100
 	
109
 	return 0;
101
 	return 0;
110
 
102
 
111
  err_undinet_probe:
103
  err_undinet_probe:
112
 	undi_unload ( undi );
104
 	undi_unload ( undi );
113
-	list_del ( &undi->dev.siblings );
114
  err_find_rom:
105
  err_find_rom:
115
  err_load_pci:
106
  err_load_pci:
116
 	free ( undi );
107
 	free ( undi );
128
 
119
 
129
 	undinet_remove ( undi );
120
 	undinet_remove ( undi );
130
 	undi_unload ( undi );
121
 	undi_unload ( undi );
131
-	list_del ( &undi->dev.siblings );
132
 	free ( undi );
122
 	free ( undi );
133
 	pci_set_drvdata ( pci, NULL );
123
 	pci_set_drvdata ( pci, NULL );
134
 }
124
 }

+ 9
- 8
src/arch/x86/drivers/net/undinet.c View File

598
 /**
598
 /**
599
  * Check for devices with broken support for generating interrupts
599
  * Check for devices with broken support for generating interrupts
600
  *
600
  *
601
- * @v undi		UNDI device
601
+ * @v desc		Device description
602
  * @ret irq_is_broken	Interrupt support is broken; no interrupts are generated
602
  * @ret irq_is_broken	Interrupt support is broken; no interrupts are generated
603
  */
603
  */
604
-static int undinet_irq_is_broken ( struct undi_device *undi ) {
604
+static int undinet_irq_is_broken ( struct device_description *desc ) {
605
 	const struct undinet_irq_broken *broken;
605
 	const struct undinet_irq_broken *broken;
606
 	unsigned int i;
606
 	unsigned int i;
607
 
607
 
608
 	for ( i = 0 ; i < ( sizeof ( undinet_irq_broken_list ) /
608
 	for ( i = 0 ; i < ( sizeof ( undinet_irq_broken_list ) /
609
 			    sizeof ( undinet_irq_broken_list[0] ) ) ; i++ ) {
609
 			    sizeof ( undinet_irq_broken_list[0] ) ) ; i++ ) {
610
 		broken = &undinet_irq_broken_list[i];
610
 		broken = &undinet_irq_broken_list[i];
611
-		if ( ( undi->dev.desc.bus_type == BUS_TYPE_PCI ) &&
612
-		     ( undi->dev.desc.vendor == broken->pci_vendor ) &&
613
-		     ( undi->dev.desc.device == broken->pci_device ) ) {
611
+		if ( ( desc->bus_type == BUS_TYPE_PCI ) &&
612
+		     ( desc->vendor == broken->pci_vendor ) &&
613
+		     ( desc->device == broken->pci_device ) ) {
614
 			return 1;
614
 			return 1;
615
 		}
615
 		}
616
 	}
616
 	}
621
  * Probe UNDI device
621
  * Probe UNDI device
622
  *
622
  *
623
  * @v undi		UNDI device
623
  * @v undi		UNDI device
624
+ * @v dev		Underlying generic device
624
  * @ret rc		Return status code
625
  * @ret rc		Return status code
625
  */
626
  */
626
-int undinet_probe ( struct undi_device *undi ) {
627
+int undinet_probe ( struct undi_device *undi, struct device *dev ) {
627
 	struct net_device *netdev;
628
 	struct net_device *netdev;
628
 	struct undi_nic *undinic;
629
 	struct undi_nic *undinic;
629
 	struct s_PXENV_START_UNDI start_undi;
630
 	struct s_PXENV_START_UNDI start_undi;
644
 	netdev_init ( netdev, &undinet_operations );
645
 	netdev_init ( netdev, &undinet_operations );
645
 	undinic = netdev->priv;
646
 	undinic = netdev->priv;
646
 	undi_set_drvdata ( undi, netdev );
647
 	undi_set_drvdata ( undi, netdev );
647
-	netdev->dev = &undi->dev;
648
+	netdev->dev = dev;
648
 	memset ( undinic, 0, sizeof ( *undinic ) );
649
 	memset ( undinic, 0, sizeof ( *undinic ) );
649
 	undinet_entry = undi->entry;
650
 	undinet_entry = undi->entry;
650
 	DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
651
 	DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
733
 		       undinic );
734
 		       undinic );
734
 		undinic->hacks |= UNDI_HACK_EB54;
735
 		undinic->hacks |= UNDI_HACK_EB54;
735
 	}
736
 	}
736
-	if ( undinet_irq_is_broken ( undi ) ) {
737
+	if ( undinet_irq_is_broken ( &dev->desc ) ) {
737
 		DBGC ( undinic, "UNDINIC %p forcing polling mode due to "
738
 		DBGC ( undinic, "UNDINIC %p forcing polling mode due to "
738
 		       "broken interrupts\n", undinic );
739
 		       "broken interrupts\n", undinic );
739
 		undinic->irq_supported = 0;
740
 		undinic->irq_supported = 0;

+ 20
- 17
src/arch/x86/drivers/net/undionly.c View File

50
  * addition to the UNDI driver, build e.g. "bin/undi.dsk".
50
  * addition to the UNDI driver, build e.g. "bin/undi.dsk".
51
  */
51
  */
52
 
52
 
53
+/** UNDI root bus device */
54
+static struct device undibus_dev;
55
+
53
 /**
56
 /**
54
  * Probe UNDI root bus
57
  * Probe UNDI root bus
55
  *
58
  *
60
  */
63
  */
61
 static int undibus_probe ( struct root_device *rootdev ) {
64
 static int undibus_probe ( struct root_device *rootdev ) {
62
 	struct undi_device *undi = &preloaded_undi;
65
 	struct undi_device *undi = &preloaded_undi;
66
+	struct device *dev = &undibus_dev;
63
 	int rc;
67
 	int rc;
64
 
68
 
65
 	/* Check for a valie preloaded UNDI device */
69
 	/* Check for a valie preloaded UNDI device */
69
 	}
73
 	}
70
 
74
 
71
 	/* Add to device hierarchy */
75
 	/* Add to device hierarchy */
72
-	undi->dev.driver_name = "undionly";
76
+	dev->driver_name = "undionly";
73
 	if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
77
 	if ( undi->pci_busdevfn != UNDI_NO_PCI_BUSDEVFN ) {
74
-		undi->dev.desc.bus_type = BUS_TYPE_PCI;
75
-		undi->dev.desc.location = undi->pci_busdevfn;
76
-		undi->dev.desc.vendor = undi->pci_vendor;
77
-		undi->dev.desc.device = undi->pci_device;
78
-		snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
79
-			   "UNDI-PCI%02x:%02x.%x",
80
-			   PCI_BUS ( undi->pci_busdevfn ),
78
+		dev->desc.bus_type = BUS_TYPE_PCI;
79
+		dev->desc.location = undi->pci_busdevfn;
80
+		dev->desc.vendor = undi->pci_vendor;
81
+		dev->desc.device = undi->pci_device;
82
+		snprintf ( dev->name, sizeof ( dev->name ),
83
+			   "0000:%02x:%02x.%x", PCI_BUS ( undi->pci_busdevfn ),
81
 			   PCI_SLOT ( undi->pci_busdevfn ),
84
 			   PCI_SLOT ( undi->pci_busdevfn ),
82
 			   PCI_FUNC ( undi->pci_busdevfn ) );
85
 			   PCI_FUNC ( undi->pci_busdevfn ) );
83
 	} else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
86
 	} else if ( undi->isapnp_csn != UNDI_NO_ISAPNP_CSN ) {
84
-		undi->dev.desc.bus_type = BUS_TYPE_ISAPNP;
85
-		snprintf ( undi->dev.name, sizeof ( undi->dev.name ),
86
-			   "UNDI-ISAPNP" );
87
+		dev->desc.bus_type = BUS_TYPE_ISAPNP;
88
+		snprintf ( dev->name, sizeof ( dev->name ), "ISAPNP" );
87
 	}
89
 	}
88
-	undi->dev.parent = &rootdev->dev;
89
-	list_add ( &undi->dev.siblings, &rootdev->dev.children);
90
-	INIT_LIST_HEAD ( &undi->dev.children );
90
+	dev->parent = &rootdev->dev;
91
+	list_add ( &dev->siblings, &rootdev->dev.children);
92
+	INIT_LIST_HEAD ( &dev->children );
91
 
93
 
92
 	/* Create network device */
94
 	/* Create network device */
93
-	if ( ( rc = undinet_probe ( undi ) ) != 0 )
95
+	if ( ( rc = undinet_probe ( undi, dev ) ) != 0 )
94
 		goto err;
96
 		goto err;
95
 
97
 
96
 	return 0;
98
 	return 0;
97
 
99
 
98
  err:
100
  err:
99
-	list_del ( &undi->dev.siblings );
101
+	list_del ( &dev->siblings );
100
 	return rc;
102
 	return rc;
101
 }
103
 }
102
 
104
 
107
  */
109
  */
108
 static void undibus_remove ( struct root_device *rootdev __unused ) {
110
 static void undibus_remove ( struct root_device *rootdev __unused ) {
109
 	struct undi_device *undi = &preloaded_undi;
111
 	struct undi_device *undi = &preloaded_undi;
112
+	struct device *dev = &undibus_dev;
110
 
113
 
111
 	undinet_remove ( undi );
114
 	undinet_remove ( undi );
112
-	list_del ( &undi->dev.siblings );
115
+	list_del ( &dev->siblings );
113
 }
116
 }
114
 
117
 
115
 /** UNDI bus root device driver */
118
 /** UNDI bus root device driver */

+ 0
- 2
src/arch/x86/include/undi.h View File

53
 	 */
53
 	 */
54
 	UINT16_t flags;
54
 	UINT16_t flags;
55
 
55
 
56
-	/** Generic device */
57
-	struct device dev;
58
 	/** Driver-private data
56
 	/** Driver-private data
59
 	 *
57
 	 *
60
 	 * Use undi_set_drvdata() and undi_get_drvdata() to access this
58
 	 * Use undi_set_drvdata() and undi_get_drvdata() to access this

+ 2
- 1
src/arch/x86/include/undinet.h View File

10
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
 
11
 
12
 struct undi_device;
12
 struct undi_device;
13
+struct device;
13
 
14
 
14
-extern int undinet_probe ( struct undi_device *undi );
15
+extern int undinet_probe ( struct undi_device *undi, struct device *dev );
15
 extern void undinet_remove ( struct undi_device *undi );
16
 extern void undinet_remove ( struct undi_device *undi );
16
 
17
 
17
 #endif /* _UNDINET_H */
18
 #endif /* _UNDINET_H */

Loading…
Cancel
Save