qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 05/13] net: add fd_readv() handler to qemu_new_vlan_


From: Mark McLoughlin
Subject: [Qemu-devel] [PATCH 05/13] net: add fd_readv() handler to qemu_new_vlan_client() args
Date: Tue, 19 May 2009 10:55:27 +0100

This, apparently, is the style we prefer - all VLANClientState
should be an argument to qemu_new_vlan_client().

Signed-off-by: Mark McLoughlin <address@hidden>
---
 hw/dp8393x.c        |    4 ++--
 hw/e1000.c          |    4 ++--
 hw/eepro100.c       |    2 +-
 hw/etraxfs_eth.c    |    2 +-
 hw/mcf_fec.c        |    2 +-
 hw/mipsnet.c        |    2 +-
 hw/musicpal.c       |    2 +-
 hw/ne2000.c         |    4 ++--
 hw/pcnet.c          |    2 +-
 hw/qdev.c           |    7 ++++---
 hw/rtl8139.c        |    2 +-
 hw/smc91c111.c      |    2 +-
 hw/stellaris_enet.c |    2 +-
 hw/usb-net.c        |    3 ++-
 hw/virtio-net.c     |    2 +-
 hw/xen_nic.c        |    4 ++--
 net.c               |   21 +++++++++++----------
 net.h               |    6 ++++--
 tap-win32.c         |    2 +-
 19 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index 4418409..c5efb3c 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -888,8 +888,8 @@ void dp83932_init(NICInfo *nd, target_phys_addr_t base, int 
it_shift,
     s->watchdog = qemu_new_timer(vm_clock, dp8393x_watchdog, s);
     s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
 
-    s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 nic_receive, nic_can_receive, nic_cleanup, s);
+    s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, 
nic_can_receive,
+                                 nic_receive, NULL, nic_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, nd->macaddr);
     qemu_register_reset(nic_reset, s);
diff --git a/hw/e1000.c b/hw/e1000.c
index c5eb546..fd13f64 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1099,8 +1099,8 @@ static void pci_e1000_init(PCIDevice *pci_dev)
     memset(&d->tx, 0, sizeof d->tx);
 
     d->vc = qdev_get_vlan_client(&d->dev.qdev,
-                                 e1000_receive, e1000_can_receive,
-                                 e1000_cleanup, d);
+                                 e1000_can_receive, e1000_receive,
+                                 NULL, e1000_cleanup, d);
     d->vc->link_status_changed = e1000_set_link_status;
 
     qemu_format_nic_info_str(d->vc, macaddr);
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 1689a3a..571ab94 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1766,7 +1766,7 @@ static void nic_init(PCIDevice *pci_dev, uint32_t device)
     nic_reset(s);
 
     s->vc = qdev_get_vlan_client(&d->dev.qdev,
-                                 nic_receive, nic_can_receive,
+                                 nic_can_receive, nic_receive, NULL,
                                  nic_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->macaddr);
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 68b8de3..bb61284 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -593,7 +593,7 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
        cpu_register_physical_memory (base, 0x5c, eth->ethregs);
 
        eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                      eth_receive, eth_can_receive,
+                                      eth_can_receive, eth_receive, NULL,
                                       eth_cleanup, eth);
        eth->vc->opaque = eth;
        eth->vc->link_status_changed = eth_set_link;
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 6c0acc5..86b3aaf 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -462,7 +462,7 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, 
qemu_irq *irq)
     cpu_register_physical_memory(base, 0x400, s->mmio_index);
 
     s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 mcf_fec_receive, mcf_fec_can_receive,
+                                 mcf_fec_can_receive, mcf_fec_receive, NULL,
                                  mcf_fec_cleanup, s);
     memcpy(s->macaddr, nd->macaddr, 6);
     qemu_format_nic_info_str(s->vc, s->macaddr);
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index e842984..82a8c93 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -262,7 +262,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
     s->irq = irq;
     if (nd && nd->vlan) {
         s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                     mipsnet_receive, mipsnet_can_receive,
+                                     mipsnet_can_receive, mipsnet_receive, 
NULL,
                                      mipsnet_cleanup, s);
     } else {
         s->vc = NULL;
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 87dda0c..f3c7f2c 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -753,7 +753,7 @@ static void mv88w8618_eth_init(SysBusDevice *dev)
 
     sysbus_init_irq(dev, &s->irq);
     s->vc = qdev_get_vlan_client(&dev->qdev,
-                                 eth_receive, eth_can_receive,
+                                 eth_can_receive, eth_receive, NULL,
                                  eth_cleanup, s);
     s->mmio_index = cpu_register_io_memory(0, mv88w8618_eth_readfn,
                                            mv88w8618_eth_writefn, s);
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 2af0d10..aea66b7 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -757,7 +757,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
     ne2000_reset(s);
 
     s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 ne2000_receive, ne2000_can_receive,
+                                 ne2000_can_receive, ne2000_receive, NULL,
                                  isa_ne2000_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->macaddr);
@@ -821,7 +821,7 @@ static void pci_ne2000_init(PCIDevice *pci_dev)
     qdev_get_macaddr(&d->dev.qdev, s->macaddr);
     ne2000_reset(s);
     s->vc = qdev_get_vlan_client(&d->dev.qdev,
-                                 ne2000_receive, ne2000_can_receive,
+                                 ne2000_can_receive, ne2000_receive, NULL,
                                  ne2000_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->macaddr);
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 1f8e04b..848d21b 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1952,7 +1952,7 @@ static void pcnet_common_init(DeviceState *dev, 
PCNetState *s,
 
     qdev_get_macaddr(dev, s->macaddr);
     s->vc = qdev_get_vlan_client(dev,
-                                 pcnet_receive, pcnet_can_receive,
+                                 pcnet_can_receive, pcnet_receive, NULL,
                                  cleanup, s);
     pcnet_h_reset(s);
     register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, s);
diff --git a/hw/qdev.c b/hw/qdev.c
index 9ed6f85..923a08e 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -233,15 +233,16 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, 
qemu_irq pin)
 }
 
 VLANClientState *qdev_get_vlan_client(DeviceState *dev,
-                                      IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
+                                      IOReadHandler *fd_read,
+                                      IOReadvHandler *fd_readv,
                                       NetCleanup *cleanup,
                                       void *opaque)
 {
     NICInfo *nd = dev->nd;
     assert(nd);
-    return qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                fd_read, fd_can_read, cleanup, opaque);
+    return qemu_new_vlan_client(nd->vlan, nd->model, nd->name, fd_can_read,
+                                fd_read, fd_readv, cleanup, opaque);
 }
 
 
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index d99f35c..ab68bda 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3475,7 +3475,7 @@ static void pci_rtl8139_init(PCIDevice *dev)
     qdev_get_macaddr(&dev->qdev, s->macaddr);
     rtl8139_reset(s);
     s->vc = qdev_get_vlan_client(&dev->qdev,
-                                 rtl8139_receive, rtl8139_can_receive,
+                                 rtl8139_can_receive, rtl8139_receive, NULL,
                                  rtl8139_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->macaddr);
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 38cbd01..b20d535 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -711,7 +711,7 @@ static void smc91c111_init1(SysBusDevice *dev)
     smc91c111_reset(s);
 
     s->vc = qdev_get_vlan_client(&dev->qdev,
-                                 smc91c111_receive, smc91c111_can_receive,
+                                 smc91c111_can_receive, smc91c111_receive, 
NULL,
                                  smc91c111_cleanup, s);
     qemu_format_nic_info_str(s->vc, s->macaddr);
     /* ??? Save/restore.  */
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index 36fabd3..8b7df09 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -405,8 +405,8 @@ static void stellaris_enet_init(SysBusDevice *dev)
     qdev_get_macaddr(&dev->qdev, s->macaddr);
 
     s->vc = qdev_get_vlan_client(&dev->qdev,
-                                 stellaris_enet_receive,
                                  stellaris_enet_can_receive,
+                                 stellaris_enet_receive, NULL,
                                  stellaris_enet_cleanup, s);
     qemu_format_nic_info_str(s->vc, s->macaddr);
 
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 9e64425..fda0aa5 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1458,8 +1458,9 @@ USBDevice *usb_net_init(NICInfo *nd)
     pstrcpy(s->dev.devname, sizeof(s->dev.devname),
                     "QEMU USB Network Interface");
     s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 usbnet_receive,
                                  usbnet_can_receive,
+                                 usbnet_receive,
+                                 NULL,
                                  usbnet_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->mac);
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 60aa6da..5613308 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -606,8 +606,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev)
     qdev_get_macaddr(dev, n->mac);
     n->status = VIRTIO_NET_S_LINK_UP;
     n->vc = qdev_get_vlan_client(dev,
-                                 virtio_net_receive,
                                  virtio_net_can_receive,
+                                 virtio_net_receive, NULL,
                                  virtio_net_cleanup, n);
     n->vc->link_status_changed = virtio_net_set_link_status;
 
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index 2364e82..920b227 100644
--- a/hw/xen_nic.c
+++ b/hw/xen_nic.c
@@ -303,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);
 
diff --git a/net.c b/net.c
index b506ccb..409205a 100644
--- a/net.c
+++ b/net.c
@@ -332,8 +332,9 @@ static char *assign_name(VLANClientState *vc1, const char 
*model)
 VLANClientState *qemu_new_vlan_client(VLANState *vlan,
                                       const char *model,
                                       const char *name,
-                                      IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
+                                      IOReadHandler *fd_read,
+                                      IOReadvHandler *fd_readv,
                                       NetCleanup *cleanup,
                                       void *opaque)
 {
@@ -344,8 +345,9 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
         vc->name = strdup(name);
     else
         vc->name = assign_name(vc, model);
-    vc->fd_read = fd_read;
     vc->fd_can_read = fd_can_read;
+    vc->fd_read = fd_read;
+    vc->fd_readv = fd_readv;
     vc->cleanup = cleanup;
     vc->opaque = opaque;
     vc->vlan = vlan;
@@ -592,7 +594,7 @@ static int net_slirp_init(VLANState *vlan, const char 
*model, const char *name)
         slirp_inited = 1;
         slirp_init(slirp_restrict, slirp_ip);
     }
-    slirp_vc = qemu_new_vlan_client(vlan, model, name,
+    slirp_vc = qemu_new_vlan_client(vlan, model, name, NULL,
                                     slirp_receive, NULL, net_slirp_cleanup, 
NULL);
     slirp_vc->info_str[0] = '\0';
     slirp_in_use = 1;
@@ -870,9 +872,8 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
 
     s = qemu_mallocz(sizeof(TAPState));
     s->fd = fd;
-    s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive,
-                                 NULL, tap_cleanup, s);
-    s->vc->fd_readv = tap_receive_iov;
+    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, tap_receive,
+                                 tap_receive_iov, tap_cleanup, s);
     qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s);
     snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
     return s;
@@ -1198,7 +1199,7 @@ static int net_vde_init(VLANState *vlan, const char 
*model,
         free(s);
         return -1;
     }
-    s->vc = qemu_new_vlan_client(vlan, model, name, vde_from_qemu,
+    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_from_qemu,
                                  NULL, vde_cleanup, s);
     qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
     snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",
@@ -1436,7 +1437,7 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState 
*vlan,
     s = qemu_mallocz(sizeof(NetSocketState));
     s->fd = fd;
 
-    s->vc = qemu_new_vlan_client(vlan, model, name, net_socket_receive_dgram,
+    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, 
net_socket_receive_dgram,
                                  NULL, net_socket_cleanup, s);
     qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);
 
@@ -1464,7 +1465,7 @@ static NetSocketState 
*net_socket_fd_init_stream(VLANState *vlan,
     NetSocketState *s;
     s = qemu_mallocz(sizeof(NetSocketState));
     s->fd = fd;
-    s->vc = qemu_new_vlan_client(vlan, model, name, net_socket_receive,
+    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, net_socket_receive,
                                  NULL, net_socket_cleanup, s);
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
              "socket: fd=%d", fd);
@@ -1743,7 +1744,7 @@ static int net_dump_init(VLANState *vlan, const char 
*device,
         return -1;
     }
 
-    s->pcap_vc = qemu_new_vlan_client(vlan, device, name, dump_receive, NULL,
+    s->pcap_vc = qemu_new_vlan_client(vlan, device, name, NULL, dump_receive, 
NULL,
                                       net_dump_cleanup, s);
     snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),
              "dump to %s (len=%d)", filename, len);
diff --git a/net.h b/net.h
index 41a3082..a312ee5 100644
--- a/net.h
+++ b/net.h
@@ -51,8 +51,9 @@ VLANState *qemu_find_vlan(int id);
 VLANClientState *qemu_new_vlan_client(VLANState *vlan,
                                       const char *model,
                                       const char *name,
-                                      IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
+                                      IOReadHandler *fd_read,
+                                      IOReadvHandler *fd_readv,
                                       NetCleanup *cleanup,
                                       void *opaque);
 void qemu_del_vlan_client(VLANClientState *vc);
@@ -129,8 +130,9 @@ void net_host_device_remove(Monitor *mon, int vlan_id, 
const char *device);
 
 void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
 VLANClientState *qdev_get_vlan_client(DeviceState *dev,
-                                      IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
+                                      IOReadHandler *fd_read,
+                                      IOReadvHandler *fd_readv,
                                       NetCleanup *cleanup,
                                       void *opaque);
 
diff --git a/tap-win32.c b/tap-win32.c
index 3ff957f..008158d 100644
--- a/tap-win32.c
+++ b/tap-win32.c
@@ -684,7 +684,7 @@ int tap_win32_init(VLANState *vlan, const char *model,
         return -1;
     }
 
-    s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive,
+    s->vc = qemu_new_vlan_client(vlan, model, name, NULL, tap_receive,
                                  NULL, tap_cleanup, s);
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-- 
1.6.0.6





reply via email to

[Prev in Thread] Current Thread [Next in Thread]