|
@@ -194,7 +194,8 @@
|
|
|
/* Extended RX descriptor (16 bytes), the layout the e1000e/PCH parts use
|
|
/* Extended RX descriptor (16 bytes), the layout the e1000e/PCH parts use
|
|
|
* when RFCTL.EXTEN is set: the hardware overwrites the buffer address with
|
|
* when RFCTL.EXTEN is set: the hardware overwrites the buffer address with
|
|
|
* MRQ/RSS data and writes status/error, length and VLAN tag back at offsets
|
|
* MRQ/RSS data and writes status/error, length and VLAN tag back at offsets
|
|
|
- * 8, 12 and 14. The legacy 16-byte layout puts status at 12 instead. */
|
|
|
|
|
|
|
+ * 8, 12 and 14. The legacy 16-byte layout puts length at 8, checksum at
|
|
|
|
|
+ * 10, status at 12 and errors at 13 instead; `rx_ext` selects the decode. */
|
|
|
struct e1000e_rx_desc {
|
|
struct e1000e_rx_desc {
|
|
|
volatile unsigned int addr_lo;
|
|
volatile unsigned int addr_lo;
|
|
|
volatile unsigned int addr_hi;
|
|
volatile unsigned int addr_hi;
|
|
@@ -224,6 +225,10 @@ static struct e1000e_tx_desc *tx_ring;
|
|
|
static unsigned char *rx_bufs;
|
|
static unsigned char *rx_bufs;
|
|
|
static unsigned char *tx_bufs;
|
|
static unsigned char *tx_bufs;
|
|
|
static unsigned int rx_cur;
|
|
static unsigned int rx_cur;
|
|
|
|
|
+/* 1 when RFCTL.EXTEN stuck (PCH parts): status/error at offset 8, length
|
|
|
|
|
+ * at 12. 0 for MACs without RFCTL (QEMU's 82540EM reads it as zero):
|
|
|
|
|
+ * legacy write-back, length at 8, status at 12, errors at 13. */
|
|
|
|
|
+static int rx_ext;
|
|
|
static unsigned int tx_cur;
|
|
static unsigned int tx_cur;
|
|
|
static unsigned int tx_pending; /* bitmask: submitted, DD not seen yet */
|
|
static unsigned int tx_pending; /* bitmask: submitted, DD not seen yet */
|
|
|
static unsigned int tx_fail_run; /* consecutive TX timeouts */
|
|
static unsigned int tx_fail_run; /* consecutive TX timeouts */
|
|
@@ -1489,6 +1494,11 @@ static void rx_desc_config(void)
|
|
|
rfctl |= RFCTL_NFSW_DIS | RFCTL_NFSR_DIS |
|
|
rfctl |= RFCTL_NFSW_DIS | RFCTL_NFSR_DIS |
|
|
|
RFCTL_IPV6_EX_DIS | RFCTL_NEW_IPV6_EXT_DIS;
|
|
RFCTL_IPV6_EX_DIS | RFCTL_NEW_IPV6_EXT_DIS;
|
|
|
w32(REG_RFCTL, rfctl);
|
|
w32(REG_RFCTL, rfctl);
|
|
|
|
|
+ /* The 82540EM (QEMU's e1000) has no RFCTL: the write is ignored and
|
|
|
|
|
+ * the MAC keeps writing legacy descriptors. Decoding those with the
|
|
|
|
|
+ * extended layout reads the frame length as status, so DD looks clear
|
|
|
|
|
+ * for every even-length frame and the ring stalls full. */
|
|
|
|
|
+ rx_ext = (r32(REG_RFCTL) & RFCTL_EXTEN) ? 1 : 0;
|
|
|
|
|
|
|
|
/* No checksum offload: the stack verifies checksums, and the driver
|
|
/* No checksum offload: the stack verifies checksums, and the driver
|
|
|
* rejects any descriptor whose error byte is non-zero. With RXCSUM
|
|
* rejects any descriptor whose error byte is non-zero. With RXCSUM
|
|
@@ -1783,9 +1793,19 @@ static int e1000e_rx(unsigned char *buf, unsigned int maxlen)
|
|
|
unsigned int entry = rx_cur;
|
|
unsigned int entry = rx_cur;
|
|
|
struct e1000e_rx_desc *d = &rx_ring[entry];
|
|
struct e1000e_rx_desc *d = &rx_ring[entry];
|
|
|
unsigned int se = d->status_error;
|
|
unsigned int se = d->status_error;
|
|
|
- unsigned int status = se & 0xFFu;
|
|
|
|
|
- unsigned int errors = (se >> 24) & 0xFFu;
|
|
|
|
|
- unsigned int len;
|
|
|
|
|
|
|
+ unsigned int status, errors, len;
|
|
|
|
|
+
|
|
|
|
|
+ if (rx_ext) {
|
|
|
|
|
+ status = se & 0xFFu;
|
|
|
|
|
+ errors = (se >> 24) & 0xFFu;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ /* Legacy: se = length | csum << 16; status/errors
|
|
|
|
|
+ * are the low two bytes of the `length` field. */
|
|
|
|
|
+ unsigned int hi = d->length;
|
|
|
|
|
+
|
|
|
|
|
+ status = hi & 0xFFu;
|
|
|
|
|
+ errors = (hi >> 8) & 0xFFu;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (!(status & RX_DD))
|
|
if (!(status & RX_DD))
|
|
|
return -1; /* nothing pending */
|
|
return -1; /* nothing pending */
|
|
@@ -1795,7 +1815,7 @@ static int e1000e_rx(unsigned char *buf, unsigned int maxlen)
|
|
|
last_rx_errors = errors;
|
|
last_rx_errors = errors;
|
|
|
|
|
|
|
|
if ((status & RX_EOP) && errors == 0) {
|
|
if ((status & RX_EOP) && errors == 0) {
|
|
|
- len = d->length;
|
|
|
|
|
|
|
+ len = rx_ext ? d->length : (se & 0xFFFFu);
|
|
|
if (len >= 14 && len <= maxlen) {
|
|
if (len >= 14 && len <= maxlen) {
|
|
|
unsigned char *src = rx_bufs +
|
|
unsigned char *src = rx_bufs +
|
|
|
entry * E1000E_BUF;
|
|
entry * E1000E_BUF;
|