Skip to contentSkip to conversation

pcnet: Do not receive external frames in loopback mode

PATCH RESEND Applied Jan Kiszka 2 participants 3 messages Oct 19, 2010 – Nov 21, 2010

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH RESEND 1/1 pcnet: Do not receive external frames in loopback mode

While not explicitly stated in the spec, it was observed on real systems that enabling loopback testing on the pcnet controller disables reception of external frames. And some legacy software relies on it, so provide this behavior.

---
 hw/pcnet.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
hw/pcnet.c +3 -2
index b52935a..f970bda 100644
@@ -1048,9 +1048,10 @@ ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
     int crc_err = 0;
     int size = size_;
 
-    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
+    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
+        (CSR_LOOP(s) && !s->looptest)) {
         return -1;
-
+    }
 #ifdef PCNET_DEBUG
     printf("pcnet_receive size=%d\n", size);
 #endif
Signature · 1 line
1.7.1
author
#1 lore raw
Quoted 4 lines · Jan Kiszka

While not explicitly stated in the spec, it was observed on real systems that enabling loopback testing on the pcnet controller disables reception of external frames. And some legacy software relies on it, so provide this behavior.

Ping.

Quoted 23 lines
---
 hw/pcnet.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
hw/pcnet.c +3 -2
index b52935a..f970bda 100644
@@ -1048,9 +1048,10 @@ ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
     int crc_err = 0;
     int size = size_;
 
-    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
+    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
+        (CSR_LOOP(s) && !s->looptest)) {
         return -1;
-
+    }
 #ifdef PCNET_DEBUG
     printf("pcnet_receive size=%d\n", size);
 #endif
#2 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka

While not explicitly stated in the spec, it was observed on real systems that enabling loopback testing on the pcnet controller disables reception of external frames. And some legacy software relies on it, so provide this behavior.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 22 lines
---
  hw/pcnet.c |    5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
hw/pcnet.c +3 -2
index b52935a..f970bda 100644
@@ -1048,9 +1048,10 @@ ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
      int crc_err = 0;
      int size = size_;
 
-    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
+    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
+        (CSR_LOOP(s)&&  !s->looptest)) {
          return -1;
-
+    }
  #ifdef PCNET_DEBUG
      printf("pcnet_receive size=%d\n", size);
  #endif