Skip to contentSkip to conversation

e1000e: A few fixes for RX data path

PATCH Applied Dmitry Fleytman 2 participants 13 messages Sep 15, 2016 – Sep 23, 2016

lore
Share & tools
lore
#0 lore raw

cover e1000e: A few fixes for RX data path

This series contains a few RX logic fixes for e1000e.

These fixes improve compliance to HW device specification and fix occasional interruptions of RX traffic with the latest linux driver.

Dmitry Fleytman (7):
e1000e: Flush all receive queues on receive enable
e1000e: Flush receive queue on link up
e1000e: Fix CTRL_EXT.EIAME behavior
e1000e: Fix PBACLR implementation
e1000e: Fix OTHER interupts processing for MSI-X
e1000e: Fix spurious RX TCP ACK interrupts
e1000e: Fix EIAC register implementation

 hw/net/e1000e.c      |  2 +-
 hw/net/e1000e_core.c | 30 +++++++++++++++++++-----------
 hw/net/e1000e_core.h |  3 +++
 hw/net/trace-events  |  2 +-
 4 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/7 e1000e: Flush receive queues on link up

---
 hw/net/e1000e_core.c | 3 +++
 1 file changed, 3 insertions(+)
hw/net/e1000e_core.c +3 -0
index ade4d25..a9603e0 100644
@@ -1807,6 +1807,7 @@ e1000e_core_set_link_status(E1000ECore *core)
                                    core->autoneg_timer);
         } else {
             e1000x_update_regs_on_link_up(core->mac, core->phy[0]);
+            e1000e_start_recv(core);
         }
     }
 
@@ -2187,6 +2188,8 @@ e1000e_autoneg_timer(void *opaque)
     E1000ECore *core = opaque;
     if (!qemu_get_queue(core->owner_nic)->link_down) {
         e1000x_update_regs_on_autoneg_done(core->mac, core->phy[0]);
+        e1000e_start_recv(core);
+
         e1000e_update_flowctl_status(core);
         /* signal link status change to the guest */
         e1000e_set_interrupt_cause(core, E1000_ICR_LSC);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/7 e1000e: Flush all receive queues on receive enable

In reply to Dmitry Fleytman

Before this patch first netdev queue only was flushed.

---
 hw/net/e1000e.c      | 2 +-
 hw/net/e1000e_core.c | 2 +-
 hw/net/e1000e_core.h | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)
hw/net/e1000e.c +1 -1
index bad43f4..4994e1c 100644
@@ -400,7 +400,7 @@ static void e1000e_write_config(PCIDevice *pci_dev, uint32_t address,
 
     if (range_covers_byte(address, len, PCI_COMMAND) &&
         (pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
-        qemu_flush_queued_packets(qemu_get_queue(s->nic));
+        e1000e_start_recv(&s->core);
     }
 }
 
hw/net/e1000e_core.c +1 -1
index badb1fe..ade4d25 100644
@@ -953,7 +953,7 @@ e1000e_has_rxbufs(E1000ECore *core, const E1000E_RingInfo *r,
                          core->rx_desc_buf_size;
 }
 
-static inline void
+void
 e1000e_start_recv(E1000ECore *core)
 {
     int i;
hw/net/e1000e_core.h +3 -0
index 5f413a9..1ff6978 100644
@@ -144,3 +144,6 @@ e1000e_receive(E1000ECore *core, const uint8_t *buf, size_t size);
 
 ssize_t
 e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt);
+
+void
+e1000e_start_recv(E1000ECore *core);
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/7 e1000e: Fix CTRL_EXT.EIAME behavior

In reply to Dmitry Fleytman

CTRL_EXT.EIAME bit controls clearing of IAM bits,
but current code clears IMS bits instead.

See spec. 10.2.2.5 Extended Device Control Register.

---
 hw/net/e1000e_core.c | 4 ++--
 hw/net/trace-events  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/net/e1000e_core.c +2 -2
index a9603e0..22765cb 100644
@@ -2008,8 +2008,8 @@ e1000e_msix_notify_one(E1000ECore *core, uint32_t cause, uint32_t int_cfg)
     }
 
     if (core->mac[CTRL_EXT] & E1000_CTRL_EXT_EIAME) {
-        trace_e1000e_irq_ims_clear_eiame(core->mac[IAM], cause);
-        e1000e_clear_ims_bits(core, core->mac[IAM] & cause);
+        trace_e1000e_irq_iam_clear_eiame(core->mac[IAM], cause);
+        core->mac[IAM] &= ~cause;
     }
 
     trace_e1000e_irq_icr_clear_eiac(core->mac[ICR], core->mac[EIAC]);
hw/net/trace-events +1 -1
index 8d38d77..aa83a7c 100644
@@ -223,7 +223,7 @@ e1000e_irq_icr_read_entry(uint32_t icr) "Starting ICR read. Current ICR: 0x%x"
 e1000e_irq_icr_read_exit(uint32_t icr) "Ending ICR read. Current ICR: 0x%x"
 e1000e_irq_icr_clear_zero_ims(void) "Clearing ICR on read due to zero IMS"
 e1000e_irq_icr_clear_iame(void) "Clearing ICR on read due to IAME"
-e1000e_irq_ims_clear_eiame(uint32_t iam, uint32_t cause) "Clearing IMS due to EIAME, IAM: 0x%X, cause: 0x%X"
+e1000e_irq_iam_clear_eiame(uint32_t iam, uint32_t cause) "Clearing IMS due to EIAME, IAM: 0x%X, cause: 0x%X"
 e1000e_irq_icr_clear_eiac(uint32_t icr, uint32_t eiac) "Clearing ICR bits due to EIAC, ICR: 0x%X, EIAC: 0x%X"
 e1000e_irq_ims_clear_set_imc(uint32_t val) "Clearing IMS bits due to IMC write 0x%x"
 e1000e_irq_fire_delayed_interrupts(void) "Firing delayed interrupts"
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/7 e1000e: Fix PBACLR implementation

In reply to Dmitry Fleytman

This patch fixes incorrect check for
interrypt type being used.

PBSCLR register is valid for MSI-X only.

See spec. 10.2.3.13 MSI—X PBA Clear

---
 hw/net/e1000e_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000e_core.c +1 -1
index 22765cb..c38ed10 100644
@@ -2347,7 +2347,7 @@ e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
 
     core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
 
-    if (msix_enabled(core->owner)) {
+    if (!msix_enabled(core->owner)) {
         return;
     }
 
Signature · 1 line
2.7.4
#8 lore raw

PATCH 5/7 e1000e: Fix OTHER interrupts processing for MSI-X

In reply to Dmitry Fleytman

Interrupt mask for legacy OTHER causes should
not apply to MSI-X OTHER cause.

---
 hw/net/e1000e_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000e_core.c +1 -1
index c38ed10..e70e669 100644
@@ -2131,7 +2131,7 @@ e1000e_update_interrupt_state(E1000ECore *core)
 
     /* Set ICR[OTHER] for MSI-X */
     if (is_msix) {
-        if (core->mac[ICR] & core->mac[IMS] & E1000_ICR_OTHER_CAUSES) {
+        if (core->mac[ICR] & E1000_ICR_OTHER_CAUSES) {
             core->mac[ICR] |= E1000_ICR_OTHER;
             trace_e1000e_irq_add_msi_other(core->mac[ICR]);
         }
Signature · 1 line
2.7.4
#9 lore raw

PATCH 6/7 e1000e: Fix spurious RX TCP ACK interrupts

In reply to Dmitry Fleytman

Do not raise ACK interrupts when
RFCTL.ACKDIS bit is set (see spec. 10.2.5.16).

---
 hw/net/e1000e_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/e1000e_core.c +2 -1
index e70e669..f4ec79f 100644
@@ -1710,7 +1710,8 @@ e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt)
         }
 
         /* Perform ACK receive detection */
-        if (e1000e_is_tcp_ack(core, core->rx_pkt)) {
+        if  (!(core->mac[RFCTL] & E1000_RFCTL_ACK_DIS) &&
+             (e1000e_is_tcp_ack(core, core->rx_pkt))) {
             n |= E1000_ICS_ACK;
         }
 
Signature · 1 line
2.7.4
#10 lore raw

PATCH 7/7 e1000e: Fix EIAC register implementation

In reply to Dmitry Fleytman

This patch fixes 2 issues:

1. Bits set in EIAC register should be cleared from IMS when EIAM is not used.
2. Only bit that corresonds to the interrupt being raised should be cleared.

See spec. 10.2.4.7 Interrupt Auto Clear

---
 hw/net/e1000e_core.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
hw/net/e1000e_core.c +9 -5
index f4ec79f..3c38980 100644
@@ -2015,13 +2015,17 @@ e1000e_msix_notify_one(E1000ECore *core, uint32_t cause, uint32_t int_cfg)
 
     trace_e1000e_irq_icr_clear_eiac(core->mac[ICR], core->mac[EIAC]);
 
-    if (core->mac[EIAC] & E1000_ICR_OTHER) {
-        effective_eiac = (core->mac[EIAC] & E1000_EIAC_MASK) |
-                         E1000_ICR_OTHER_CAUSES;
-    } else {
-        effective_eiac = core->mac[EIAC] & E1000_EIAC_MASK;
+    effective_eiac = core->mac[EIAC] & cause;
+
+    if (effective_eiac == E1000_ICR_OTHER) {
+        effective_eiac |= E1000_ICR_OTHER_CAUSES;
     }
+
     core->mac[ICR] &= ~effective_eiac;
+
+    if (!(core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) {
+        core->mac[IMS] &= ~effective_eiac;
+    }
 }
 
 static void
Signature · 1 line
2.7.4
#11 lore raw
In reply to Dmitry Fleytman

Hi qemu-devel,

Ping.

~Dmitry

Quoted 26 lines · Dmitry Fleytman

This series contains a few RX logic fixes for e1000e.

These fixes improve compliance to HW device specification and fix occasional interruptions of RX traffic with the latest linux driver.

Dmitry Fleytman (7):
e1000e: Flush all receive queues on receive enable
e1000e: Flush receive queue on link up
e1000e: Fix CTRL_EXT.EIAME behavior
e1000e: Fix PBACLR implementation
e1000e: Fix OTHER interupts processing for MSI-X
e1000e: Fix spurious RX TCP ACK interrupts
e1000e: Fix EIAC register implementation

hw/net/e1000e.c      |  2 +-
hw/net/e1000e_core.c | 30 +++++++++++++++++++-----------
hw/net/e1000e_core.h |  3 +++
hw/net/trace-events  |  2 +-
4 files changed, 24 insertions(+), 13 deletions(-)
Signature · 1 line
2.7.4
#5 lore raw

Re: [Qemu-devel] [PATCH 4/7] e1000e: Fix PBACLR implementation

In reply to Dmitry Fleytman
Quoted 17 lines · Dmitry Fleytman

This patch fixes incorrect check for
interrypt type being used.

PBSCLR register is valid for MSI-X only.

See spec. 10.2.3.13 MSI—X PBA Clear

---
  hw/net/e1000e_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000e_core.c +0 -0
index 22765cb..c38ed10 100644

hw/net/e1000e_core.c e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val) · line 2353

Quoted 8 lines
hw/net/e1000e_core.c +1 -1
@@ -2347,7 +2347,7 @@ e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
 
      core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
 
-    if (msix_enabled(core->owner)) {
+    if (!msix_enabled(core->owner)) {
          return;
      }
 

Spec also said "writing 0b has no effect". So we'd better implement this behavior too?

#6 lore raw

Re: [Qemu-devel] [PATCH 4/7] e1000e: Fix PBACLR implementation

Quoted 18 lines · Jason Wang
Quoted 12 lines · Dmitry Fleytman

This patch fixes incorrect check for
interrypt type being used.

PBSCLR register is valid for MSI-X only.

See spec. 10.2.3.13 MSI—X PBA Clear

---
 hw/net/e1000e_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

hw/net/e1000e_core.c e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val) · line 2352

Quoted 11 lines
hw/net/e1000e_core.c +1 -0
index 22765cb..c38ed10 100644
@@ -2347,7 +2347,7 @@ e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
       core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
 -    if (msix_enabled(core->owner)) {
+    if (!msix_enabled(core->owner)) {
         return;
     }
 

Spec also said "writing 0b has no effect". So we'd better implement this behavior too?

Hi Jason,

Not sure I understand you correctly.

With current implementation, writing 0b does nothing except that it changes value of PBACLR being read.

I just verified that physical device behaves exactly like this.

Is this what you meant?

~Dmitry

#7 lore raw

Re: [Qemu-devel] [PATCH 4/7] e1000e: Fix PBACLR implementation

Quoted 34 lines · Dmitry Fleytman
Quoted 17 lines · Jason Wang
Quoted 12 lines · Dmitry Fleytman

This patch fixes incorrect check for
interrypt type being used.

PBSCLR register is valid for MSI-X only.

See spec. 10.2.3.13 MSI—X PBA Clear

---
  hw/net/e1000e_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

hw/net/e1000e_core.c e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val) · line 2352

Quoted 11 lines
hw/net/e1000e_core.c +1 -0
index 22765cb..c38ed10 100644
@@ -2347,7 +2347,7 @@ e1000e_set_pbaclr(E1000ECore *core, int index, uint32_t val)
        core->mac[PBACLR] = val & E1000_PBACLR_VALID_MASK;
  -    if (msix_enabled(core->owner)) {
+    if (!msix_enabled(core->owner)) {
          return;
      }
 

Spec also said "writing 0b has no effect". So we'd better implement this behavior too?

Hi Jason,

Not sure I understand you correctly.

Quoted 9 lines

With current implementation, writing 0b does nothing except that it changes value of PBACLR being read.

I just verified that physical device behaves exactly like this.

Is this what you meant?

~Dmitry

Yes, then it looks fine to me.

Thanks

Applied
#12 lore raw
In reply to Dmitry Fleytman
Quoted 15 lines · Dmitry Fleytman

This series contains a few RX logic fixes for e1000e.

These fixes improve compliance to HW device specification and fix occasional interruptions of RX traffic with the latest linux driver.

Dmitry Fleytman (7):
e1000e: Flush all receive queues on receive enable
e1000e: Flush receive queue on link up
e1000e: Fix CTRL_EXT.EIAME behavior
e1000e: Fix PBACLR implementation
e1000e: Fix OTHER interupts processing for MSI-X
e1000e: Fix spurious RX TCP ACK interrupts
e1000e: Fix EIAC register implementation

Quoted 6 lines
  hw/net/e1000e.c      |  2 +-
  hw/net/e1000e_core.c | 30 +++++++++++++++++++-----------
  hw/net/e1000e_core.h |  3 +++
  hw/net/trace-events  |  2 +-
  4 files changed, 24 insertions(+), 13 deletions(-)

Applied, thanks.