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 7 years ago
parent
commit
6997d3c2fa

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

@@ -94,23 +94,14 @@ static int undipci_probe ( struct pci_device *pci ) {
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 97
 	/* Create network device */
106
-	if ( ( rc = undinet_probe ( undi ) ) != 0 )
98
+	if ( ( rc = undinet_probe ( undi, &pci->dev ) ) != 0 )
107 99
 		goto err_undinet_probe;
108 100
 	
109 101
 	return 0;
110 102
 
111 103
  err_undinet_probe:
112 104
 	undi_unload ( undi );
113
-	list_del ( &undi->dev.siblings );
114 105
  err_find_rom:
115 106
  err_load_pci:
116 107
 	free ( undi );
@@ -128,7 +119,6 @@ static void undipci_remove ( struct pci_device *pci ) {
128 119
 
129 120
 	undinet_remove ( undi );
130 121
 	undi_unload ( undi );
131
-	list_del ( &undi->dev.siblings );
132 122
 	free ( undi );
133 123
 	pci_set_drvdata ( pci, NULL );
134 124
 }

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

@@ -598,19 +598,19 @@ static const struct undinet_irq_broken undinet_irq_broken_list[] = {
598 598
 /**
599 599
  * Check for devices with broken support for generating interrupts
600 600
  *
601
- * @v undi		UNDI device
601
+ * @v desc		Device description
602 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 605
 	const struct undinet_irq_broken *broken;
606 606
 	unsigned int i;
607 607
 
608 608
 	for ( i = 0 ; i < ( sizeof ( undinet_irq_broken_list ) /
609 609
 			    sizeof ( undinet_irq_broken_list[0] ) ) ; i++ ) {
610 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 614
 			return 1;
615 615
 		}
616 616
 	}
@@ -621,9 +621,10 @@ static int undinet_irq_is_broken ( struct undi_device *undi ) {
621 621
  * Probe UNDI device
622 622
  *
623 623
  * @v undi		UNDI device
624
+ * @v dev		Underlying generic device
624 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 628
 	struct net_device *netdev;
628 629
 	struct undi_nic *undinic;
629 630
 	struct s_PXENV_START_UNDI start_undi;
@@ -644,7 +645,7 @@ int undinet_probe ( struct undi_device *undi ) {
644 645
 	netdev_init ( netdev, &undinet_operations );
645 646
 	undinic = netdev->priv;
646 647
 	undi_set_drvdata ( undi, netdev );
647
-	netdev->dev = &undi->dev;
648
+	netdev->dev = dev;
648 649
 	memset ( undinic, 0, sizeof ( *undinic ) );
649 650
 	undinet_entry = undi->entry;
650 651
 	DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
@@ -733,7 +734,7 @@ int undinet_probe ( struct undi_device *undi ) {
733 734
 		       undinic );
734 735
 		undinic->hacks |= UNDI_HACK_EB54;
735 736
 	}
736
-	if ( undinet_irq_is_broken ( undi ) ) {
737
+	if ( undinet_irq_is_broken ( &dev->desc ) ) {
737 738
 		DBGC ( undinic, "UNDINIC %p forcing polling mode due to "
738 739
 		       "broken interrupts\n", undinic );
739 740
 		undinic->irq_supported = 0;

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

@@ -50,6 +50,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
50 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 57
  * Probe UNDI root bus
55 58
  *
@@ -60,6 +63,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
60 63
  */
61 64
 static int undibus_probe ( struct root_device *rootdev ) {
62 65
 	struct undi_device *undi = &preloaded_undi;
66
+	struct device *dev = &undibus_dev;
63 67
 	int rc;
64 68
 
65 69
 	/* Check for a valie preloaded UNDI device */
@@ -69,34 +73,32 @@ static int undibus_probe ( struct root_device *rootdev ) {
69 73
 	}
70 74
 
71 75
 	/* Add to device hierarchy */
72
-	undi->dev.driver_name = "undionly";
76
+	dev->driver_name = "undionly";
73 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 84
 			   PCI_SLOT ( undi->pci_busdevfn ),
82 85
 			   PCI_FUNC ( undi->pci_busdevfn ) );
83 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 94
 	/* Create network device */
93
-	if ( ( rc = undinet_probe ( undi ) ) != 0 )
95
+	if ( ( rc = undinet_probe ( undi, dev ) ) != 0 )
94 96
 		goto err;
95 97
 
96 98
 	return 0;
97 99
 
98 100
  err:
99
-	list_del ( &undi->dev.siblings );
101
+	list_del ( &dev->siblings );
100 102
 	return rc;
101 103
 }
102 104
 
@@ -107,9 +109,10 @@ static int undibus_probe ( struct root_device *rootdev ) {
107 109
  */
108 110
 static void undibus_remove ( struct root_device *rootdev __unused ) {
109 111
 	struct undi_device *undi = &preloaded_undi;
112
+	struct device *dev = &undibus_dev;
110 113
 
111 114
 	undinet_remove ( undi );
112
-	list_del ( &undi->dev.siblings );
115
+	list_del ( &dev->siblings );
113 116
 }
114 117
 
115 118
 /** UNDI bus root device driver */

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

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

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

@@ -10,8 +10,9 @@
10 10
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 11
 
12 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 16
 extern void undinet_remove ( struct undi_device *undi );
16 17
 
17 18
 #endif /* _UNDINET_H */

Loading…
Cancel
Save