Patchwork [RESEND] pcnet: Do not receive external frames in loopback mode

login
register
mail settings
Submitter Jan Kiszka
Date Oct. 19, 2010, 3:03 p.m.
Message ID <4CBDB33C.60002@siemens.com>
Download mbox | patch
Permalink /patch/68345/
State New
Headers show

Comments

Jan Kiszka - Oct. 19, 2010, 3:03 p.m.
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.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/pcnet.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
Jan Kiszka - Nov. 17, 2010, 10:18 a.m.
Am 19.10.2010 17:03, Jan Kiszka wrote:
> 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.

> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/pcnet.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/pcnet.c b/hw/pcnet.c
> index b52935a..f970bda 100644
> --- a/hw/pcnet.c
> +++ b/hw/pcnet.c
> @@ -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
Anthony Liguori - Nov. 21, 2010, 3:18 p.m.
On 10/19/2010 10:03 AM, Jan Kiszka wrote:
> 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.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   hw/pcnet.c |    5 +++--
>   1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/pcnet.c b/hw/pcnet.c
> index b52935a..f970bda 100644
> --- a/hw/pcnet.c
> +++ b/hw/pcnet.c
> @@ -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
>

Patch

diff --git a/hw/pcnet.c b/hw/pcnet.c
index b52935a..f970bda 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -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