From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9lVR-0006Oy-8R for qemu-devel@nongnu.org; Mon, 29 Jun 2015 22:42:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z9lVM-0005u5-92 for qemu-devel@nongnu.org; Mon, 29 Jun 2015 22:42:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z9lVM-0005tr-3t for qemu-devel@nongnu.org; Mon, 29 Jun 2015 22:42:36 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7E20BA2C28 for ; Tue, 30 Jun 2015 02:42:35 +0000 (UTC) From: Fam Zheng Date: Tue, 30 Jun 2015 10:42:37 +0800 Message-Id: <1435632157-9275-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH] xen: Drop net_rx_ok List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, Stefan Hajnoczi This is necessary because once we return false from .can_receive, we need to flush the queue when the .can_receive conditions become true again, (for example when more buffer is available). We can rely on net_rx_packet (which checks the same conditions) to drop the packet if the device is not ready, so drop net_xen_info.can_receive. Signed-off-by: Fam Zheng --- hw/net/xen_nic.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 19ecfc4..da9edc0 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -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); @@ -304,7 +283,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, }; -- 2.4.4