tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Patch to add support for crazy Realtek 8139-based cards



Very recently I have managed to get my hands on a pretty odd RTL8139
card which does not identify with the system well, because it reports
0x0001 as vendor ID. On Linux it worked because Linux already detects
such cards, while NetBSD doesn't.

Instead of trying to find the card by checking its vendor and product,
we check the Product ID which is always equal to 0x8139 in these bogus
cards, the SubVendor ID and the SubSystem ID.

Attached is a pretty easy fix but it made the network in that computer
work very well.

*** Cut here ***

--- sys/dev/pci/if_rtk_pci.c.orig 2011-11-15 21:35:05.000000000 +0100
+++ sys/dev/pci/if_rtk_pci.c 2011-11-15 22:17:28.000000000 +0100
@@ -121,12 +121,23 @@
rtk_pci_lookup(const struct pci_attach_args *pa)
{
int i;
+ pcireg_t reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);

for (i = 0; i < __arraycount(rtk_pci_devs); i++) {
- if (PCI_VENDOR(pa->pa_id) != rtk_pci_devs[i].rtk_vid)
- continue;
- if (PCI_PRODUCT(pa->pa_id) == rtk_pci_devs[i].rtk_did)
+
+ if ((PCI_VENDOR(pa->pa_id) == rtk_pci_devs[i].rtk_vid) &&
+ (PCI_PRODUCT(pa->pa_id) == rtk_pci_devs[i].rtk_did))
return &rtk_pci_devs[i];
+
+// Detect crazy RTL8139-based cards
+// These report a bogus vendor ID like 0x0001 but the subsys id and
subsys vendor are reliable
+
+ if(PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_REALTEK_RT8139)
+ {
+ {
+ if(PCI_SUBSYS_VENDOR(reg) == rtk_pci_devs[i].rtk_vid &&
+ PCI_SUBSYS_ID(reg) == rtk_pci_devs[i].rtk_did)
+ return &rtk_pci_devs[i];
+ }
}

return NULL;

*** Cut here ***

Giuseppe Gatta


Home | Main Index | Thread Index | Old Index