Ver código fonte

[r8169] Remove driver cfg lookup, use pci_device_id->driver_data instead

This patch removes the cfg lookup made in the r8169 driver and
replaces it with equivalent information found in the driver_data field
of the pci_device_id structure.

Signed-off-by: Andrei Faur <da3drus@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Andrei Faur 14 anos atrás
pai
commit
f658d7daba
2 arquivos alterados com 11 adições e 66 exclusões
  1. 11
    65
      src/drivers/net/r8169.c
  2. 0
    1
      src/drivers/net/r8169.h

+ 11
- 65
src/drivers/net/r8169.c Ver arquivo

@@ -1817,52 +1817,6 @@ rtl8169_free_rx_resources ( struct rtl8169_private *tp )
1817 1817
 	}
1818 1818
 }
1819 1819
 
1820
-/**
1821
-    FIXME: Because iPXE's pci_device_id structure does not contain a
1822
-    field to contain arbitrary data, we need the following table to
1823
-    associate PCI IDs with nic variants, because a lot of driver
1824
-    routines depend on knowing which kind of variant they are dealing
1825
-    with. --mdc
1826
- **/
1827
-
1828
-#define _R(VENDOR,DEVICE,INDEX) \
1829
-	{ .vendor = VENDOR, .device = DEVICE, .index = INDEX }
1830
-
1831
-static const struct {
1832
-	uint16_t vendor;
1833
-	uint16_t device;
1834
-	int index;
1835
-} nic_variant_table[] = {
1836
-	_R(0x10ec, 0x8129, RTL_CFG_0),
1837
-	_R(0x10ec, 0x8136, RTL_CFG_2),
1838
-	_R(0x10ec, 0x8167, RTL_CFG_0),
1839
-	_R(0x10ec, 0x8168, RTL_CFG_1),
1840
-	_R(0x10ec, 0x8169, RTL_CFG_0),
1841
-	_R(0x1186, 0x4300, RTL_CFG_0),
1842
-	_R(0x1259, 0xc107, RTL_CFG_0),
1843
-	_R(0x16ec, 0x0116, RTL_CFG_0),
1844
-	_R(0x1737, 0x1032, RTL_CFG_0),
1845
-	_R(0x0001, 0x8168, RTL_CFG_2),
1846
-};
1847
-#undef _R
1848
-
1849
-static int
1850
-rtl8169_get_nic_variant ( uint16_t vendor, uint16_t device )
1851
-{
1852
-	u32 i;
1853
-
1854
-	DBGP ( "rtl8169_get_nic_variant\n" );
1855
-
1856
-	for (i = 0; i < ARRAY_SIZE(nic_variant_table); i++) {
1857
-		if ( ( nic_variant_table[i].vendor == vendor ) &&
1858
-		     ( nic_variant_table[i].device == device ) ) {
1859
-			return ( nic_variant_table[i].index );
1860
-		}
1861
-	}
1862
-	DBG ( "No matching NIC variant found!\n" );
1863
-	return ( RTL_CFG_0 );
1864
-}
1865
-
1866 1820
 static void rtl8169_irq_enable ( struct rtl8169_private *tp )
1867 1821
 {
1868 1822
 	void *ioaddr = tp->mmio_addr;
@@ -2103,19 +2057,12 @@ rtl8169_probe ( struct pci_device *pdev, const struct pci_device_id *ent )
2103 2057
 	struct rtl8169_private *tp;
2104 2058
 	void *ioaddr;
2105 2059
 
2106
-	/** FIXME: This lookup is necessary because iPXE does not have a "data"
2107
-	    element in the structure pci_device_id which can pass an arbitrary
2108
-	    piece of data to the driver.  It might be useful to add it. Then we
2109
-	    could just use ent->data instead of having to look up cfg_index.
2110
-	**/
2111
-	int cfg_index = rtl8169_get_nic_variant ( ent->vendor, ent->device );
2112
-	const struct rtl_cfg_info *cfg = rtl_cfg_infos + cfg_index;
2060
+	const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
2113 2061
 
2114 2062
 	DBGP ( "rtl8169_probe\n" );
2115 2063
 
2116 2064
 	DBG ( "ent->vendor = %#04x, ent->device = %#04x\n", ent->vendor, ent->device );
2117 2065
 
2118
-	DBG ( "cfg_index = %d\n", cfg_index );
2119 2066
 	DBG ( "cfg->intr_event = %#04x\n", cfg->intr_event );
2120 2067
 
2121 2068
 	rc = -ENOMEM;
@@ -2144,7 +2091,6 @@ rtl8169_probe ( struct pci_device *pdev, const struct pci_device_id *ent )
2144 2091
 	tp->pci_dev    = pdev;
2145 2092
 	tp->irqno      = pdev->irq;
2146 2093
 	tp->netdev     = netdev;
2147
-	tp->cfg_index  = cfg_index;
2148 2094
 	tp->intr_event = cfg->intr_event;
2149 2095
 	tp->cp_cmd     = PCIMulRW;
2150 2096
 
@@ -2257,16 +2203,16 @@ rtl8169_remove ( struct pci_device *pdev )
2257 2203
 }
2258 2204
 
2259 2205
 static struct pci_device_id rtl8169_nics[] = {
2260
-	PCI_ROM(0x10ec, 0x8129, "rtl8169-0x8129", "rtl8169-0x8129", 0),
2261
-	PCI_ROM(0x10ec, 0x8136, "rtl8169-0x8136", "rtl8169-0x8136", 0),
2262
-	PCI_ROM(0x10ec, 0x8167, "rtl8169-0x8167", "rtl8169-0x8167", 0),
2263
-	PCI_ROM(0x10ec, 0x8168, "rtl8169-0x8168", "rtl8169-0x8168", 0),
2264
-	PCI_ROM(0x10ec, 0x8169, "rtl8169-0x8169", "rtl8169-0x8169", 0),
2265
-	PCI_ROM(0x1186, 0x4300, "rtl8169-0x4300", "rtl8169-0x4300", 0),
2266
-	PCI_ROM(0x1259, 0xc107, "rtl8169-0xc107", "rtl8169-0xc107", 0),
2267
-	PCI_ROM(0x16ec, 0x0116, "rtl8169-0x0116", "rtl8169-0x0116", 0),
2268
-	PCI_ROM(0x1737, 0x1032, "rtl8169-0x1032", "rtl8169-0x1032", 0),
2269
-	PCI_ROM(0x0001, 0x8168, "rtl8169-0x8168", "rtl8169-0x8168", 0),
2206
+	PCI_ROM(0x10ec, 0x8129, "rtl8169-0x8129", "rtl8169-0x8129", RTL_CFG_0),
2207
+	PCI_ROM(0x10ec, 0x8136, "rtl8169-0x8136", "rtl8169-0x8136", RTL_CFG_2),
2208
+	PCI_ROM(0x10ec, 0x8167, "rtl8169-0x8167", "rtl8169-0x8167", RTL_CFG_0),
2209
+	PCI_ROM(0x10ec, 0x8168, "rtl8169-0x8168", "rtl8169-0x8168", RTL_CFG_1),
2210
+	PCI_ROM(0x10ec, 0x8169, "rtl8169-0x8169", "rtl8169-0x8169", RTL_CFG_0),
2211
+	PCI_ROM(0x1186, 0x4300, "rtl8169-0x4300", "rtl8169-0x4300", RTL_CFG_0),
2212
+	PCI_ROM(0x1259, 0xc107, "rtl8169-0xc107", "rtl8169-0xc107", RTL_CFG_0),
2213
+	PCI_ROM(0x16ec, 0x0116, "rtl8169-0x0116", "rtl8169-0x0116", RTL_CFG_0),
2214
+	PCI_ROM(0x1737, 0x1032, "rtl8169-0x1032", "rtl8169-0x1032", RTL_CFG_0),
2215
+	PCI_ROM(0x0001, 0x8168, "rtl8169-0x8168", "rtl8169-0x8168", RTL_CFG_2),
2270 2216
 };
2271 2217
 
2272 2218
 struct pci_driver rtl8169_driver __pci_driver = {

+ 0
- 1
src/drivers/net/r8169.h Ver arquivo

@@ -440,7 +440,6 @@ struct rtl8169_private {
440 440
 
441 441
 	int chipset;
442 442
 	int mac_version;
443
-	int cfg_index;
444 443
 	u16 intr_event;
445 444
 
446 445
 	struct io_buffer *tx_iobuf[NUM_TX_DESC];

Carregando…
Cancelar
Salvar