Re: 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. - Can you show actual board vendor name of that card? (to denote quirks in sources) - Is that card recognized properly on supported OS, i.e. MS Windows? - If yes, does it work with Windows default driver or vendor's driver? - If it works on Windows, what does the device manager show, especially PCI vendor and product IDs? If the board vendor intentionally sets its PCI vendor ID to 0x0001, we can add such odd ID into rtk_pci_devs[] in if_rtk_pci.c. But if it's caused by broken EEPROM or bad drivers which badly overwrite EEPROM data, we should not accept random ID numbers. --- Izumi Tsutsui
Re: Patch to add support for crazy Realtek 8139-based cards
Hello, On Wed, 16 Nov 2011 19:12:29 +0100 Just a Normal Person tail...@gmail.com wrote: 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.0 +0100 +++ sys/dev/pci/if_rtk_pci.c 2011-11-15 22:17:28.0 +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 *** Did anyone look at this who is familiar with the hardware? It looks sane enough to me and should probably be committed although I have only one non-crazy rtk to test it on. have fun Michael
Re: Patch to add support for crazy Realtek 8139-based cards
On Thu, Nov 17, 2011 at 09:16:08PM -0500, Michael wrote: *** Cut here *** Did anyone look at this who is familiar with the hardware? It looks sane enough to me and should probably be committed although I have only one non-crazy rtk to test it on. I don't like doing wild card matches like this. It should at the very least being restricted to exactly the known broken instance. Joerg
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.0 +0100 +++ sys/dev/pci/if_rtk_pci.c 2011-11-15 22:17:28.0 +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