summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/realtek.c
Commit message (Collapse)AuthorAgeFilesLines
* [mii] Separate concepts of MII interface and MII deviceMichael Brown2018-04-191-8/+15
| | | | | | | | | | | | | We currently have no generic concept of a PHY address, since all existing implementations simply hardcode the PHY address within the MII access methods. A bit-bashing MII interface will need to be provided with an explicit PHY address in order to generate the correct waveform. Allow for this by separating out the concept of a MII device (i.e. a specific PHY address attached to a particular MII interface). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Do not attempt to access EEPROM on RTL8169 chipsMichael Brown2015-04-211-2/+3
| | | | | | | | | | | | | | | | | On some RTL8169 onboard NICs (observed with a Lenovo ThinkPad 11e), the EEPROM is not merely not present: any attempt to read from the non-existent EEPROM will crash and reboot the system. The equivalent code to read from the EEPROM was removed from the Linux r8169 driver in 2009 with a comment suggesting that it was similarly found to be unreliable on some systems. Fix by accessing the EEPROM only on RTL8139 NICs, and assuming that the MAC address will always be correctly preset on RTL8169 NICs. Reported-by: Evan Prohaska <eprohaska@edkey.org> Tested-by: Evan Prohaska <eprohaska@edkey.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Relicense files under GPL2_OR_LATER_OR_UBDLMichael Brown2015-03-021-1/+5
| | | | | | | Relicense files for which I am the sole author (as identified by util/relicense.pl). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Check for ioremap() failuresMichael Brown2014-07-161-0/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Clear bit 24 of RCRMichael Brown2014-03-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | On an Asus Z87-K motherboard with an onboard 8168 NIC, booting into Windows 7 and then warm rebooting into iPXE results in a broken RX datapath: packets can be transmitted successfully but garbage is received. A cold reboot clears the problem. A dump of the PHY registers reveals only one difference: in the failure case the bits ADVERTISE_PAUSE_CAP and ADVERTISE_PAUSE_ASYM are cleared. Explicitly setting these bits does not fix the problem. A dump of the MAC registers reveals a few differences, of which the most obvious culprit is the undocumented bit 24 of the Receive Configuration Register (RCR), which is set in the failure case. Explicitly clearing this bit does fix the problem. Reported-by: Sebastian Nielsen <ipxe@sebbe.eu> Reported-by: Oliver Rath <rath@mglug.de> Debugged-by: Sebastian Nielsen <ipxe@sebbe.eu> Tested-by: Sebastian Nielsen <ipxe@sebbe.eu> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Add ability to dump all internal registersMichael Brown2014-03-201-0/+27
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Dump all MII register contents when link status changesMichael Brown2014-03-101-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Include link status register details in debug messagesMichael Brown2014-03-041-2/+26
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Report RX error detail in debug messagesMichael Brown2013-07-151-3/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Fix reopening of legacy-mode 8139 NICMichael Brown2013-05-261-3/+5
| | | | | | | | | | | | | | | realtek_destroy_ring() currently does nothing if the card is operating in legacy (pre-RTL8139C+) mode. In particular, the producer and consumer counters are incorrectly left holding their current values. Virtual hardware (e.g. the emulated RTL8139 in qemu and similar VMs) is tolerant of this behaviour, but real hardware will fail to transmit if the descriptors are not used in the correct order. Fix by resetting the producer and consumer counters in realtek_destroy_ring() even if the card is operating in legacy mode. Reported-by: Gelip <mrgelip@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Defer packets when no transmit descriptors are availableMichael Brown2013-05-011-3/+3
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Ensure EEPROM writes reach chip before starting udelay()Michael Brown2013-05-011-0/+3
| | | | | | | | | | | | | | | On some systems, it appears to be possible for writes to the EEPROM registers to be delayed for long enough that the EEPROM's setup and hold times are violated, resulting in invalid data being read from the EEPROM. Fix by inserting a PCI read cycle immediately after writes to RTL_9346CR, to ensure that the write has completed before starting the udelay() used to time the SPI bus transitions. Reported-by: Gelip <mrgelip@gmail.com> Tested-by: Gelip <mrgelip@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Allow reaction time between writing RTL_CAPR and reading RTL_CRMichael Brown2013-04-301-0/+3
| | | | | | | | | | | | | | Some older RTL8139 chips seem to not immediately update the RTL_CR.BUFE bit in response to a write to RTL_CAPR. This results in iPXE seeing a spurious zero-length received packet, and thereafter being out of sync with the hardware's RX ring offset. Fix by inserting an extra PCI read cycle after writing to RTL_CAPR, to give the chip time to react before we next read RTL_CR. Reported-by: Gelip <mrgelip@gmail.com> Tested-by: Gelip <mrgelip@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Use ID word to detect EEPROM presenceMichael Brown2013-04-281-16/+36
| | | | | | | | | | | | | | | | | Some onboard RTL8169 NICs seem to leave the EEPROM pins disconnected. The existing is_valid_ether_addr() test will not necessarily catch this, since it expects a missing EEPROM to show up as a MAC address of 00:00:00:00:00:00 or ff:ff:ff:ff:ff:ff. When the EEPROM pins are floating the MAC address may read as e.g. 00:00:00:00:0f:00, which will not be detected as invalid. Check the ID word in the first two bytes of the EEPROM (which should have the value 0x8129 for all RTL8139 and RTL8169 chips), and use this to determine whether or not an EEPROM is present. Reported-by: Carl Karsten <carl@nextdayvideo.com> Tested-by: Carl Karsten <carl@nextdayvideo.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Print bad MAC address in debug message when inferring no EEPROMMichael Brown2013-04-271-1/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Force EEPROM CS low before disabling EEPROM access modeMichael Brown2012-08-241-1/+29
| | | | | | | | | | | | | Some RTL8169 cards seem to drive the EEPROM CS line high (i.e. active) when 9346CR.EEM is set to "normal operating mode", with the result that the CS line is never deasserted. The symptom of this is that the first read from the EEPROM will work, while all subsequent reads will return garbage data. Reported-by: Thomas Miletich <thomas.miletich@gmail.com> Debugged-by: Thomas Miletich <thomas.miletich@gmail.com> Tested-by: Thomas Miletich <thomas.miletich@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Forcibly enable advertisement of 1000Mbps speedsMichael Brown2012-08-231-7/+72
| | | | | | | | | | | Some RTL8169 cards (observed with an RTL8169SC) power up advertising only 100Mbps, despite being capable of 1000Mbps. Forcibly enable advertisement of 1000Mbps on any RTL8169-like card. This change relies on the assumption that the CTRL1000 register will not exist on 100Mbps-only RTL8169 cards such as the RTL8101. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Enable DAC only when built as a 64-bit binaryMichael Brown2012-08-231-2/+7
| | | | | | | | | | | | | | | | | Some RTL8169 cards (observed with an RTL8169SC) crash and burn if DAC is enabled, even if only 32-bit addresses are used. Observed behaviour includes system lockups and repeated transmission of garbage data onto the wire. This seems to be a known problem. The Linux r8169 driver disables DAC by default and provides a "use_dac" module parameter. There appears to be no known test for determining whether or not DAC will work. As a workaround, enable DAC only if we are built as as 64-bit binary. This at least eliminates the problem in the common case of a 32-bit build, which will never use 64-bit addresses anyway. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Use read-modify-write to check for C+ Command registerMichael Brown2012-08-231-3/+4
| | | | | | | Some bits in the C+ Command register are always one. Testing for the presence of the register must allow for this. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Use explicit value for TCR.MXDMAMichael Brown2012-08-231-0/+7
| | | | | | | | | | Some RTL8169 cards (observed with an RTL8169SC) power up with TCR.MXDMA set to 16 bytes. While this does not prevent proper operation, it almost certainly degrades performance. Fix by explicitly setting TCR.MXDMA to "unlimited". Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Use explicit values for RCR.RXFTH and RCR.MXDMAMichael Brown2012-08-231-2/+4
| | | | | | | | Some RTL8169 cards (observed with an RTL8169SC) power up with invalid values in RCR.RXFTH and RCR.MXDMA, causing receive DMA to fail. Fix by setting explicit values for both fields. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Always set high dword of ring address registersMichael Brown2012-08-231-4/+2Star
| | | | | | | | | | Some RTL8169 cards (observed with an RTL8169SC) power up with garbage values in the ring address registers, and do not clear the registers on reset. Fix by always setting the high dword of the ring address registers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Add missing iounmap()Michael Brown2012-07-191-0/+2
| | | | | Reported-by: Thomas Miletich <thomas.miletich@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Add missing cpu_to_le16()Michael Brown2012-06-271-1/+1
| | | | | Reported-by: Thomas Miletich <thomas.miletich@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Support RTL8139 cards within generic Realtek driverMichael Brown2012-04-281-36/+315
| | | | | | | | | | | | | | | | RTL8139C+ cards use essentially the same datapath as RTL8169, which is zerocopy and 64-bit capable. Older RTL8139 cards use a single receive ring buffer rather than a descriptor ring, but still share substantial amounts of functionality with RTL8169. Include support for RTL8139 cards within the generic Realtek driver, since there is no way to differentiate between RTL8139 and RTL8139C+ cards based on the PCI IDs alone. Many thanks to all the people who worked on the rtl8139 driver over the years. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Update link state when device is openedMichael Brown2012-04-231-0/+3
| | | | | | | | | | | | | The link state is currently set at probe time, and updated only when the device is polled. This results in the user seeing a misleading stale "Link: down" message, if autonegotiation did not complete within the short timespan of the probe routine. Fix by updating the link state when the device is opened, so that the message that ends up being displayed to the user reflects the real link state at device open time. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [realtek] Replace driver for Realtek Gigabit NICsMichael Brown2012-04-181-0/+779
Tested-by: Thomas Miletich <thomas.miletich@gmail.com> Debugged-by: Thomas Miletich <thomas.miletich@gmail.com> Tested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>