Skip to contentSkip to conversation

xen: Drop net_rx_ok

PATCH Applied Fam Zheng 3 participants 3 messages Jul 28, 2015

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v3 1/1 xen: Drop net_rx_ok

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.

---

v3: Drop log. [Wen]

v2:
Fix return value of net_rx_packet to keep the semantics when ring buffer is full. [Stefan]
Update commit message accordingly.

---
 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
#1 lore raw
Quoted 13 lines · Fam Zheng

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.

---

v3: Drop log. [Wen]

Quoted 7 lines

v2:
Fix return value of net_rx_packet to keep the semantics when ring buffer is full. [Stefan]
Update commit message accordingly.

---
 hw/net/xen_nic.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

#2 lore raw
In reply to Fam Zheng
Quoted 13 lines · Fam Zheng

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.

---

v3: Drop log. [Wen]

Quoted 7 lines

v2:
Fix return value of net_rx_packet to keep the semantics when ring buffer is full. [Stefan]
Update commit message accordingly.

---
 hw/net/xen_nic.c | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan