Skip to contentSkip to conversation

Net patches

GIT PULL Applied Stefan Hajnoczi 2 participants 4 messages Jul 28, 2015

lore
Share & tools
lore
#0 lore raw

The following changes since commit f8787f8723eaca1be99e3b1873e54de163fffa93:

Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150727' into staging (2015-07-27 19:37:09 +0100)

are available in the git repository at:

git://github.com/stefanha/qemu.git tags/net-pull-request

for you to fetch changes up to 7bba83bf80eae9c9e323319ff40d0ca477b0a77a:

xen: Drop net_rx_ok (2015-07-28 11:35:54 +0100)

----------------------------------------------------------------
Pull request

These two .can_receive() are now reviewed. The net subsystem queue for 2.4 is now empty.

----------------------------------------------------------------

Fam Zheng (1):
xen: Drop net_rx_ok

Greg Ungerer (1):
hw/net: handle flow control in mcf_fec driver receiver

 hw/net/mcf_fec.c | 44 ++++++++++++++++++++++++++++++++++----------
 hw/net/xen_nic.c | 25 +------------------------
 2 files changed, 35 insertions(+), 34 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

[Qemu-devel] [PULL for-2.4 1/2] hw/net: handle flow control in mcf_fec driver receiver

From: Greg Ungerer <[email protected]>

The network mcf_fec driver emulated receive side method is not dealing with network queue flow control properly.

Modify the receive side to check if we have enough space in the descriptors to store the current packet. If not we process none of it and return 0. When the guest frees up some buffers through its descriptors we signal the qemu net layer to send more packets.

[Fixed coding style: 4-space indent and curly braces on if statement. --Stefan]

Message-id: [email protected]

---
 hw/net/mcf_fec.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)
hw/net/mcf_fec.c +34 -10
index 4e6939f..21928f9 100644
@@ -196,12 +196,14 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
 
 static void mcf_fec_enable_rx(mcf_fec_state *s)
 {
+    NetClientState *nc = qemu_get_queue(s->nic);
     mcf_fec_bd bd;
 
     mcf_fec_read_bd(&bd, s->rx_descriptor);
     s->rx_enabled = ((bd.flags & FEC_BD_E) != 0);
-    if (!s->rx_enabled)
-        DPRINTF("RX buffer full\n");
+    if (s->rx_enabled) {
+        qemu_flush_queued_packets(nc);
+    }
 }
 
 static void mcf_fec_reset(mcf_fec_state *s)
@@ -397,6 +399,32 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
     mcf_fec_update(s);
 }
 
+static int mcf_fec_have_receive_space(mcf_fec_state *s, size_t want)
+{
+    mcf_fec_bd bd;
+    uint32_t addr;
+
+    /* Walk descriptor list to determine if we have enough buffer */
+    addr = s->rx_descriptor;
+    while (want > 0) {
+        mcf_fec_read_bd(&bd, addr);
+        if ((bd.flags & FEC_BD_E) == 0) {
+            return 0;
+        }
+        if (want < s->emrbr) {
+            return 1;
+        }
+        want -= s->emrbr;
+        /* Advance to the next descriptor.  */
+        if ((bd.flags & FEC_BD_W) != 0) {
+            addr = s->erdsr;
+        } else {
+            addr += 8;
+        }
+    }
+    return 0;
+}
+
 static ssize_t mcf_fec_receive(NetClientState *nc, const uint8_t *buf, size_t size)
 {
     mcf_fec_state *s = qemu_get_nic_opaque(nc);
@@ -426,18 +454,14 @@ static ssize_t mcf_fec_receive(NetClientState *nc, const uint8_t *buf, size_t si
     if (size > (s->rcr >> 16)) {
         flags |= FEC_BD_LG;
     }
+    /* Check if we have enough space in current descriptors */
+    if (!mcf_fec_have_receive_space(s, size)) {
+        return 0;
+    }
     addr = s->rx_descriptor;
     retsize = size;
     while (size > 0) {
         mcf_fec_read_bd(&bd, addr);
-        if ((bd.flags & FEC_BD_E) == 0) {
-            /* No descriptors available.  Bail out.  */
-            /* FIXME: This is wrong.  We should probably either save the
-               remainder for when more RX buffers are available, or
-               flag an error.  */
-            fprintf(stderr, "mcf_fec: Lost end of frame\n");
-            break;
-        }
         buf_len = (size <= s->emrbr) ? size: s->emrbr;
         bd.length = buf_len;
         size -= buf_len;
Signature · 1 line
2.4.3
#2 lore raw

[Qemu-devel] [PULL for-2.4 2/2] xen: Drop net_rx_ok

In reply to Stefan Hajnoczi

From: Fam Zheng <[email protected]>

Let net_rx_packet() (which checks the same conditions) drops the packet if the device is not ready. Drop net_xen_info.can_receive and update the return value for the buffer full case.

We rely on the qemu_flush_queued_packets() in net_event() to wake up the peer when the buffer becomes available again.

Message-id: [email protected]

---
 hw/net/xen_nic.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
hw/net/xen_nic.c +1 -24
index 19ecfc4..d7cbfc1 100644
@@ -234,27 +234,6 @@ static void net_rx_response(struct XenNetDev *netdev,
 
 #define NET_IP_ALIGN 2
 
-static int net_rx_ok(NetClientState *nc)
-{
-    struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
-    RING_IDX rc, rp;
-
-    if (netdev->xendev.be_state != XenbusStateConnected) {
-        return 0;
-    }
-
-    rc = netdev->rx_ring.req_cons;
-    rp = netdev->rx_ring.sring->req_prod;
-    xen_rmb();
-
-    if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
-        xen_be_printf(&netdev->xendev, 2, "%s: no rx buffers (%d/%d)\n",
-                      __FUNCTION__, rc, rp);
-        return 0;
-    }
-    return 1;
-}
-
 static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size)
 {
     struct XenNetDev *netdev = qemu_get_nic_opaque(nc);
@@ -271,8 +250,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
     xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
 
     if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
-        xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
-        return -1;
+        return 0;
     }
     if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
         xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
@@ -304,7 +282,6 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
 static NetClientInfo net_xen_info = {
     .type = NET_CLIENT_OPTIONS_KIND_NIC,
     .size = sizeof(NICState),
-    .can_receive = net_rx_ok,
     .receive = net_rx_packet,
 };
 
Signature · 1 line
2.4.3
#3 lore raw
In reply to Stefan Hajnoczi
Quoted 10 lines · Stefan Hajnoczi

The following changes since commit f8787f8723eaca1be99e3b1873e54de163fffa93:

Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20150727' into staging (2015-07-27 19:37:09 +0100)

are available in the git repository at:

git://github.com/stefanha/qemu.git tags/net-pull-request

for you to fetch changes up to 7bba83bf80eae9c9e323319ff40d0ca477b0a77a:

Quoted 8 lines

xen: Drop net_rx_ok (2015-07-28 11:35:54 +0100)

----------------------------------------------------------------
Pull request

These two .can_receive() are now reviewed. The net subsystem queue for 2.4 is now empty.

----------------------------------------------------------------

Applied, thanks.

-- PMM