[http] Fix HTTP SAN booting

Commit 501527d ("[http] Treat any unexpected connection close as an
error") introduced a regression causing HTTP SAN booting to fail.  At
the end of the response to the HEAD request, the call to http_done()
would erroneously believe that the server had disconnected in the
middle of the HTTP headers.

Fix by treating the header block from a HEAD request as a trailer
block.  This fixes the problem and also simplifies the logic in
http_rx_header().

Reported-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
[tg3] Fix driver for BCM5719, BCM5720, BCM5764M, BCM57762

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[realtek] Always set high dword of ring address registers

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] Use explicit values for RCR.RXFTH and RCR.MXDMA

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] Use explicit value for TCR.MXDMA

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 read-modify-write to check for C+ Command register

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] Enable DAC only when built as a 64-bit binary

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>
[mii] Add separate mii_restart() function

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[realtek] Forcibly enable advertisement of 1000Mbps speeds

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>
[bitbash] Add optional open() and close() methods for bit-bashing interfaces

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[realtek] Force EEPROM CS low before disabling EEPROM access mode

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>
[tls] Disambiguate most error causes

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Display commands for dependency generation when building with V=1

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[build] Add missing #include <config/local/sideband.h>

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[ethernet] Expose eth_broadcast as a global constant

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[retry] Expose retry_poll() to explicitly poll all running timers

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[malloc] Allow allocation of memory with a specified alignment offset

Allow for allocation of memory blocks having a specified offset from a
specified physical alignment, such as being 12 bytes before a 2kB
boundary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[iobuf] Allow allocation of I/O buffers with a specified alignment offset

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[infiniband] Allow queue pairs to have a custom allocator for receive iobufs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
[infiniband] Use explicit "source" and "dest" address vector parameter names

Signed-off-by: Michael Brown <mcb30@ipxe.org>