[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SiS900 NIC driver
From: |
Thomas Schwinge |
Subject: |
SiS900 NIC driver |
Date: |
Thu, 26 Jan 2006 07:41:23 -0500 |
User-agent: |
Mutt/1.5.6+20040907i |
Hi!
Before we can apply the SiS900 NIC driver patch to the gnumach-1-branch a
few things need to be explained to me.
I took some time and reworked that patch
<URL:http://svn.debian.org/wsvn/pkg-hurd/gnumach/trunk/debian/patches/12_sis900.patch?op=file>,
using Linux 2.2.26's sis900.c as the base.
My current version of sis900.c is attached.
Now, please explain the following changes:
--- sis900.c.linux-2.2.26 2006-01-26 12:02:20.000000000 +0100
+++ sis900.c 2006-01-26 13:12:10.000000000 +0100
[...]
@@ -194,10 +221,17 @@
{
[...]
int found = 0;
struct pci_dev * pci_dev = NULL;
[...]
if (!pci_present())
return -ENODEV;
+#ifndef MACH
while ((pci_dev = pci_find_class (PCI_CLASS_NETWORK_ETHERNET << 8,
pci_dev)) != NULL) {
/* pci_dev contains all ethernet devices */
u32 pci_io_base;
@@ -231,13 +265,77 @@
}
net_dev = NULL;
}
+#else
+ for (; pci_index < 0xff; pci_index++) {
+ u16 vendor, device, pci_command;
+ struct mac_chip_info *mac;
+
+ if (pcibios_find_class (PCI_CLASS_NETWORK_ETHERNET << 8,
pci_index,
+ &pci_bus, &pci_device_fn) != PCIBIOS_SUCCESSFUL)
+ break;
+
+ pcibios_read_config_word(pci_bus, pci_device_fn, PCI_VENDOR_ID,
&vendor);
+ pcibios_read_config_word(pci_bus, pci_device_fn, PCI_DEVICE_ID,
&device);
+
+ for (mac = mac_chip_table; mac->vendor_id; mac++) {
+ if (vendor == mac->vendor_id && device ==
mac->device_id)
+ break;
+ }
+
+ /* pci_dev does not match any of our cards */
+ if (mac->vendor_id == 0)
+ continue;
+
+ {
+ u32 pci_ioaddr;
+ u8 pci_irq_line;
+
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_INTERRUPT_LINE,
&pci_irq_line);
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_0,
&pci_ioaddr);
+ ioaddr = pci_ioaddr & ~3;
+ irq = pci_irq_line;
+
+ if ((mac->flags & PCI_USES_IO) &&
+ check_region (pci_ioaddr, mac->io_size))
+ continue;
+
+ pcibios_read_config_word(pci_bus, pci_device_fn,
+ PCI_COMMAND, &pci_command);
+
+ {
+ u8 lat;
+
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_LATENCY_TIMER, &lat);
+ if (lat < 16) {
+ printk("PCI: Increasing latency timer
of device %02x:%02x to 64\n",
+ pci_bus, pci_device_fn);
+ pcibios_write_config_byte(pci_bus,
pci_device_fn, PCI_LATENCY_TIMER, 64);
+ }
+ }
+ net_dev = mac->probe (mac, ioaddr, irq, pci_index,
+ pci_device_fn, pci_bus, net_dev);
+ if (net_dev != NULL)
+ found++;
+ net_dev = NULL;
+ }
+ }
+#endif
return found ? 0 : -ENODEV;
}
Why can't we use the standard Linux code?
[...]
@@ -331,7 +457,18 @@
outl(EEREQ, ee_addr);
while(waittime < 2000) {
if(inl(ee_addr) & EEGNT) {
+#ifndef MACH
ret = sis900_get_mac_addr(pci_dev, net_dev);
+#else
+ /* get MAC address from EEPROM */
+ {
+ int i;
+ for (i = 0; i < 3; i++)
+ ((u16 *)(net_dev->dev_addr))[i] =
+ read_eeprom(ioaddr, i+EEPROMMACAddr);
+ }
+ ret = 1;
+#endif
Introduced by Andreas B. Mundt. Why?
[...]
@@ -499,8 +682,10 @@
if( status & MII_STAT_LINK ){
while (poll_bit) {
+#ifndef MACH
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(0);
+#endif
poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy,
MII_STATUS) & poll_bit);
if (jiffies >= timeout) {
printk(KERN_WARNING "%s: reset phy and link
down\n", net_dev->name);
Why don't we want this?
[...]
@@ -606,7 +795,11 @@
outl(0, ee_addr);
eeprom_delay();
+#ifndef MACH
outl(EECLK, ee_addr);
+#else
+ outl(EECS, ee_addr);
+#endif
eeprom_delay();
Introduced by Andreas B. Mundt. Why?
@@ -633,7 +826,9 @@
/* Terminate the EEPROM access. */
outl(0, ee_addr);
eeprom_delay();
+#ifndef MACH
outl(EECLK, ee_addr);
+#endif
Introduced by Andreas B. Mundt. Why?
[...]
@@ -1246,6 +1472,10 @@
net_dev->trans_start = jiffies;
+#ifdef MACH
+ { int i; for (i = 0; i < 100000; i++); } /* GRUIIIIIK */
+#endif
+
Uhm?
@@ -1310,7 +1540,11 @@
}
} while (1);
+#ifndef MACH
if (sis900_debug > 3)
+#else
+ if (sis900_debug > 4)
+#endif
printk(KERN_INFO "%s: exiting interrupt, "
"interrupt status = 0x%#8.8x.\n",
net_dev->name, inl(ioaddr + isr));
@@ -1332,7 +1566,11 @@
unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC;
u32 rx_status = sis_priv->rx_ring[entry].cmdsts;
+#ifndef MACH
if (sis900_debug > 3)
+#else
+ if (sis900_debug > 4)
+#endif
printk(KERN_INFO "sis900_rx, cur_rx:%4.4d, dirty_rx:%4.4d "
"status:0x%8.8x\n",
sis_priv->cur_rx, sis_priv->dirty_rx, rx_status);
@@ -1344,7 +1582,11 @@
if (rx_status &
(ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
/* corrupted packet received */
+#ifndef MACH
if (sis900_debug > 3)
+#else
+ if (sis900_debug > 4)
+#endif
printk(KERN_INFO "%s: Corrupted packet "
"received, buffer status = 0x%8.8x.\n",
net_dev->name, rx_status);
Why are those changes needed?
@@ -1382,7 +1624,9 @@
if ((rx_status & BCAST) == MCAST)
sis_priv->stats.multicast++;
net_dev->last_rx = jiffies;
+#ifndef MACH
sis_priv->stats.rx_bytes += rx_size;
+#endif
sis_priv->stats.rx_packets++;
/* refill the Rx buffer, what if there is not enought
memory for
@@ -1467,7 +1711,11 @@
if (tx_status & (ABORT | UNDERRUN | OWCOLL)) {
/* packet unsuccessfully transmitted */
+#ifndef MACH
if (sis900_debug > 3)
+#else
+ if (sis900_debug > 4)
+#endif
printk(KERN_INFO "%s: Transmit "
"error, Tx status %8.8x.\n",
net_dev->name, tx_status);
@@ -1483,11 +1731,17 @@
} else {
/* packet successfully transmitted */
sis_priv->stats.collisions += (tx_status & COLCNT) >>
16;
+#ifndef MACH
sis_priv->stats.tx_bytes += tx_status & DSIZE;
+#endif
sis_priv->stats.tx_packets++;
}
[...]
Regards,
Thomas
sis900.c
Description: Text Data
- SiS900 NIC driver,
Thomas Schwinge <=