aboutsummaryrefslogtreecommitdiff
path: root/hw/xen_nic.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2009-06-10 18:05:55 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-10 18:08:35 -0500
commitf8e76fbf5190575c0f927fe3c5b0ec6934c6c3fc (patch)
treec67bf81b0bfa6b897f4fb7a236962a85819e15f7 /hw/xen_nic.c
parentb319820d4099ec6b98c9c260e06d519fc41d544c (diff)
parent4ffb17f5c3244e405198ae285ffbb20a62e0d4b3 (diff)
Merge branch 'net-queue'
* net-queue: (28 commits) virtio-net: Increase filter and control limits virtio-net: Add new RX filter controls virtio-net: MAC filter optimization virtio-net: Fix MAC filter overflow handling virtio-net: reorganize receive_filter() virtio-net: Use a byte to store RX mode flags virtio-net: Add version_id 7 placeholder for vnet header support virtio-net: implement rx packet queueing net: make use of async packet sending API in tap client net: add qemu_send_packet_async() net: split out packet queueing and flushing into separate functions net: return status from qemu_deliver_packet() net: add return value to packet receive handler net: pass VLANClientState* as first arg to receive handlers net: re-name vc->fd_read() to vc->receive() net: add fd_readv() handler to qemu_new_vlan_client() args net: only read from tapfd when we can send net: vlan clients with no fd_can_read() can always receive net: move the tap buffer into TAPState net: factor tap_read_packet() out of tap_send() ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/xen_nic.c')
-rw-r--r--hw/xen_nic.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index 4206132aea..9a3c870c2d 100644
--- a/hw/xen_nic.c
+++ b/hw/xen_nic.c
@@ -223,9 +223,9 @@ static void net_rx_response(struct XenNetDev *netdev,
#define NET_IP_ALIGN 2
-static int net_rx_ok(void *opaque)
+static int net_rx_ok(VLANClientState *vc)
{
- struct XenNetDev *netdev = opaque;
+ struct XenNetDev *netdev = vc->opaque;
RING_IDX rc, rp;
if (netdev->xendev.be_state != XenbusStateConnected)
@@ -243,15 +243,15 @@ static int net_rx_ok(void *opaque)
return 1;
}
-static void net_rx_packet(void *opaque, const uint8_t *buf, int size)
+static ssize_t net_rx_packet(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- struct XenNetDev *netdev = opaque;
+ struct XenNetDev *netdev = vc->opaque;
netif_rx_request_t rxreq;
RING_IDX rc, rp;
void *page;
if (netdev->xendev.be_state != XenbusStateConnected)
- return;
+ return -1;
rc = netdev->rx_ring.req_cons;
rp = netdev->rx_ring.sring->req_prod;
@@ -259,12 +259,12 @@ static void net_rx_packet(void *opaque, const uint8_t *buf, int size)
if (rc == rp || RING_REQUEST_CONS_OVERFLOW(&netdev->rx_ring, rc)) {
xen_be_printf(&netdev->xendev, 2, "no buffer, drop packet\n");
- return;
+ return -1;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
- xen_be_printf(&netdev->xendev, 0, "packet too big (%d > %ld)",
- size, XC_PAGE_SIZE - NET_IP_ALIGN);
- return;
+ xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
+ (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
+ return -1;
}
memcpy(&rxreq, RING_GET_REQUEST(&netdev->rx_ring, rc), sizeof(rxreq));
@@ -277,11 +277,13 @@ static void net_rx_packet(void *opaque, const uint8_t *buf, int size)
xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
rxreq.gref);
net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
- return;
+ return -1;
}
memcpy(page + NET_IP_ALIGN, buf, size);
xc_gnttab_munmap(netdev->xendev.gnttabdev, page, 1);
net_rx_response(netdev, &rxreq, NETIF_RSP_OKAY, NET_IP_ALIGN, size, 0);
+
+ return size;
}
/* ------------------------------------------------------------- */
@@ -301,8 +303,8 @@ static int net_init(struct XenDevice *xendev)
vlan = qemu_find_vlan(netdev->xendev.dev);
netdev->vs = qemu_new_vlan_client(vlan, "xen", NULL,
- net_rx_packet, net_rx_ok, NULL,
- netdev);
+ net_rx_ok, net_rx_packet, NULL,
+ NULL, netdev);
snprintf(netdev->vs->info_str, sizeof(netdev->vs->info_str),
"nic: xenbus vif macaddr=%s", netdev->mac);