[PULL 11/23] dp8393x: Clear descriptor in_use field to release packet

Jason Wang posted 23 patches 5 years, 2 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Wen Congyang <wencongyang2@huawei.com>, Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Jason Wang <jasowang@redhat.com>, Alistair Francis <alistair@alistair23.me>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Xie Changlong <xiechanglong.d@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PULL 11/23] dp8393x: Clear descriptor in_use field to release packet
Posted by Jason Wang 5 years, 2 months ago
From: Finn Thain <fthain@telegraphics.com.au>

When the SONIC receives a packet into the last available descriptor, it
retains ownership of that descriptor for as long as necessary.

Section 3.4.7 of the datasheet says,

    When the system appends more descriptors, the SONIC releases ownership
    of the descriptor after writing 0000h to the RXpkt.in_use field.

The packet can now be processed by the host, so raise a PKTRX interrupt,
just like the normal case.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/dp8393x.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c
index 22b4d36..08194a4 100644
--- a/hw/net/dp8393x.c
+++ b/hw/net/dp8393x.c
@@ -811,7 +811,17 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf,
             return -1;
         }
         /* Link has been updated by host */
+
+        /* Clear in_use */
+        size = sizeof(uint16_t) * width;
+        address = dp8393x_crda(s) + sizeof(uint16_t) * 6 * width;
+        dp8393x_put(s, width, 0, 0);
+        address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED,
+                         (uint8_t *)s->data, size, 1);
+
+        /* Move to next descriptor */
         s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA];
+        s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX;
     }
 
     /* Save current position */
-- 
2.5.0