]> git.proxmox.com Git - qemu.git/commitdiff
net: remove VLANClientState members now in NetClientInfo
authorMark McLoughlin <markmc@redhat.com>
Wed, 25 Nov 2009 18:49:30 +0000 (18:49 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 3 Dec 2009 15:41:34 +0000 (09:41 -0600)
Add a NetClientInfo pointer to VLANClientState and use that
for the typecode and function pointers.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/dp8393x.c
hw/virtio-net.c
net.c
net.h
net/tap.c

index be9714dec10c59d31c0d8306cb1b0881438be972..e65e4d1535a0e9a0131e67ca267dddb0a32bf4f0 100644 (file)
@@ -407,9 +407,9 @@ static void do_transmit_packets(dp8393xState *s)
         if (s->regs[SONIC_RCR] & (SONIC_RCR_LB1 | SONIC_RCR_LB0)) {
             /* Loopback */
             s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
-            if (s->nic->nc.can_receive(&s->nic->nc)) {
+            if (s->nic->nc.info->can_receive(&s->nic->nc)) {
                 s->loopback_packet = 1;
-                s->nic->nc.receive(&s->nic->nc, s->tx_buffer, tx_len);
+                s->nic->nc.info->receive(&s->nic->nc, s->tx_buffer, tx_len);
             }
         } else {
             /* Transmit packet */
index 4f8d89e25655cd03052918d7780fc5a3820c55b8..2f201ffc76149737b7c0eb70860cc319baa18f5f 100644 (file)
@@ -129,7 +129,7 @@ static int peer_has_vnet_hdr(VirtIONet *n)
     if (!n->nic->nc.peer)
         return 0;
 
-    if (n->nic->nc.peer->type != NET_CLIENT_TYPE_TAP)
+    if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP)
         return 0;
 
     n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer);
diff --git a/net.c b/net.c
index d77320be86f1ea953b0e8a6bab7dc2626749a32b..a1ec2437fc8f36b0d0f6ddadffa02d5b40bfb027 100644 (file)
--- a/net.c
+++ b/net.c
@@ -229,19 +229,13 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
 
     vc = qemu_mallocz(info->size);
 
-    vc->type = info->type;
+    vc->info = info;
     vc->model = qemu_strdup(model);
     if (name) {
         vc->name = qemu_strdup(name);
     } else {
         vc->name = assign_name(vc, model);
     }
-    vc->can_receive = info->can_receive;
-    vc->receive = info->receive;
-    vc->receive_raw = info->receive_raw;
-    vc->receive_iov = info->receive_iov;
-    vc->cleanup = info->cleanup;
-    vc->link_status_changed = info->link_status_changed;
 
     if (vlan) {
         assert(!peer);
@@ -297,8 +291,8 @@ void qemu_del_vlan_client(VLANClientState *vc)
         }
     }
 
-    if (vc->cleanup) {
-        vc->cleanup(vc);
+    if (vc->info->cleanup) {
+        vc->info->cleanup(vc);
     }
 
     qemu_free(vc->name);
@@ -340,8 +334,8 @@ int qemu_can_send_packet(VLANClientState *sender)
     if (sender->peer) {
         if (sender->peer->receive_disabled) {
             return 0;
-        } else if (sender->peer->can_receive &&
-                   !sender->peer->can_receive(sender->peer)) {
+        } else if (sender->peer->info->can_receive &&
+                   !sender->peer->info->can_receive(sender->peer)) {
             return 0;
         } else {
             return 1;
@@ -358,7 +352,7 @@ int qemu_can_send_packet(VLANClientState *sender)
         }
 
         /* no can_receive() handler, they can always receive */
-        if (!vc->can_receive || vc->can_receive(vc)) {
+        if (!vc->info->can_receive || vc->info->can_receive(vc)) {
             return 1;
         }
     }
@@ -382,10 +376,10 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender,
         return 0;
     }
 
-    if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->receive_raw) {
-        ret = vc->receive_raw(vc, data, size);
+    if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
+        ret = vc->info->receive_raw(vc, data, size);
     } else {
-        ret = vc->receive(vc, data, size);
+        ret = vc->info->receive(vc, data, size);
     }
 
     if (ret == 0) {
@@ -422,10 +416,10 @@ static ssize_t qemu_vlan_deliver_packet(VLANClientState *sender,
             continue;
         }
 
-        if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->receive_raw) {
-            len = vc->receive_raw(vc, buf, size);
+        if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
+            len = vc->info->receive_raw(vc, buf, size);
         } else {
-            len = vc->receive(vc, buf, size);
+            len = vc->info->receive(vc, buf, size);
         }
 
         if (len == 0) {
@@ -530,7 +524,7 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov,
         offset += len;
     }
 
-    return vc->receive(vc, buffer, offset);
+    return vc->info->receive(vc, buffer, offset);
 }
 
 static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt)
@@ -555,8 +549,8 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
         return calc_iov_length(iov, iovcnt);
     }
 
-    if (vc->receive_iov) {
-        return vc->receive_iov(vc, iov, iovcnt);
+    if (vc->info->receive_iov) {
+        return vc->info->receive_iov(vc, iov, iovcnt);
     } else {
         return vc_sendv_compat(vc, iov, iovcnt);
     }
@@ -586,8 +580,8 @@ static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender,
 
         assert(!(flags & QEMU_NET_PACKET_FLAG_RAW));
 
-        if (vc->receive_iov) {
-            len = vc->receive_iov(vc, iov, iovcnt);
+        if (vc->info->receive_iov) {
+            len = vc->info->receive_iov(vc, iov, iovcnt);
         } else {
             len = vc_sendv_compat(vc, iov, iovcnt);
         }
@@ -1246,8 +1240,9 @@ done:
         monitor_printf(mon, "invalid link status '%s'; only 'up' or 'down' "
                        "valid\n", up_or_down);
 
-    if (vc->link_status_changed)
-        vc->link_status_changed(vc);
+    if (vc->info->link_status_changed) {
+        vc->info->link_status_changed(vc);
+    }
 }
 
 void net_cleanup(void)
diff --git a/net.h b/net.h
index 9185bcf794faedb87b267556a7d8bf5001f659c1..497a7373fa78d44fdb653ccdc274ac4f84af60ac 100644 (file)
--- a/net.h
+++ b/net.h
@@ -54,15 +54,7 @@ typedef struct NetClientInfo {
 } NetClientInfo;
 
 struct VLANClientState {
-    net_client_type type;
-    NetReceive *receive;
-    NetReceive *receive_raw;
-    NetReceiveIOV *receive_iov;
-    /* Packets may still be sent if this returns zero.  It's used to
-       rate-limit the slirp code.  */
-    NetCanReceive *can_receive;
-    NetCleanup *cleanup;
-    LinkStatusChanged *link_status_changed;
+    NetClientInfo *info;
     int link_down;
     QTAILQ_ENTRY(VLANClientState) next;
     struct VLANState *vlan;
index d34feecd741acad02680053029481dfe8aa9ece0..a327a9a6bf47c858f74cf8a04af5d219b827c873 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -214,7 +214,7 @@ int tap_has_ufo(VLANClientState *nc)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
 
-    assert(nc->type == NET_CLIENT_TYPE_TAP);
+    assert(nc->info->type == NET_CLIENT_TYPE_TAP);
 
     return s->has_ufo;
 }
@@ -223,7 +223,7 @@ int tap_has_vnet_hdr(VLANClientState *nc)
 {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);
 
-    assert(nc->type == NET_CLIENT_TYPE_TAP);
+    assert(nc->info->type == NET_CLIENT_TYPE_TAP);
 
     return s->has_vnet_hdr;
 }
@@ -234,7 +234,7 @@ void tap_using_vnet_hdr(VLANClientState *nc, int using_vnet_hdr)
 
     using_vnet_hdr = using_vnet_hdr != 0;
 
-    assert(nc->type == NET_CLIENT_TYPE_TAP);
+    assert(nc->info->type == NET_CLIENT_TYPE_TAP);
     assert(s->has_vnet_hdr == using_vnet_hdr);
 
     s->using_vnet_hdr = using_vnet_hdr;