qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: qemu-devel@nongnu.org
Cc: Mark McLoughlin <markmc@redhat.com>
Subject: [Qemu-devel] [PATCH 23/44] net: convert eepro100 to NICState
Date: Wed, 25 Nov 2009 18:49:16 +0000	[thread overview]
Message-ID: <1259174977-26212-24-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1259174977-26212-1-git-send-email-markmc@redhat.com>

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 hw/eepro100.c |   43 ++++++++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/hw/eepro100.c b/hw/eepro100.c
index 8734907..eb16a51 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -195,7 +195,7 @@ typedef struct {
     PCIDevice dev;
     uint8_t mult[8];            /* multicast mask array */
     int mmio_index;
-    VLANClientState *vc;
+    NICState *nic;
     NICConf conf;
     uint8_t scb_stat;           /* SCB stat/ack byte */
     uint8_t int_stat;           /* PCI interrupt status */
@@ -868,7 +868,7 @@ static void action_command(EEPRO100State *s)
                 }
             }
             TRACE(RXTX, logout("%p sending frame, len=%d,%s\n", s, size, nic_dump(buf, size)));
-            qemu_send_packet(s->vc, buf, size);
+            qemu_send_packet(&s->nic->nc, buf, size);
             s->statistics.tx_good_frames++;
             /* Transmit with bad status would raise an CX/TNO interrupt.
              * (82557 only). Emulation never has bad status. */
@@ -1599,21 +1599,21 @@ static void pci_mmio_map(PCIDevice * pci_dev, int region_num,
     }
 }
 
-static int nic_can_receive(VLANClientState *vc)
+static int nic_can_receive(VLANClientState *nc)
 {
-    EEPRO100State *s = vc->opaque;
+    EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
     TRACE(RXTX, logout("%p\n", s));
     return get_ru_state(s) == ru_ready;
     //~ return !eepro100_buffer_full(s);
 }
 
-static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
+static ssize_t nic_receive(VLANClientState *nc, const uint8_t * buf, size_t size)
 {
     /* TODO:
      * - Magic packets should set bit 30 in power management driver register.
      * - Interesting packets should set bit 29 in power management driver register.
      */
-    EEPRO100State *s = vc->opaque;
+    EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
     uint16_t rfd_status = 0xa000;
     static const uint8_t broadcast_macaddr[6] =
         { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -1779,11 +1779,11 @@ static const VMStateDescription vmstate_eepro100 = {
     }
 };
 
-static void nic_cleanup(VLANClientState *vc)
+static void nic_cleanup(VLANClientState *nc)
 {
-    EEPRO100State *s = vc->opaque;
+    EEPRO100State *s = DO_UPCAST(NICState, nc, nc)->opaque;
 
-    s->vc = NULL;
+    s->nic = NULL;
 }
 
 static int pci_nic_uninit(PCIDevice *pci_dev)
@@ -1793,10 +1793,18 @@ static int pci_nic_uninit(PCIDevice *pci_dev)
     cpu_unregister_io_memory(s->mmio_index);
     vmstate_unregister(s->vmstate, s);
     eeprom93xx_free(s->eeprom);
-    qemu_del_vlan_client(s->vc);
+    qemu_del_vlan_client(&s->nic->nc);
     return 0;
 }
 
+static NetClientInfo net_eepro100_info = {
+    .type = NET_CLIENT_TYPE_NIC,
+    .size = sizeof(NICState),
+    .can_receive = nic_can_receive,
+    .receive = nic_receive,
+    .cleanup = nic_cleanup,
+};
+
 static int nic_init(PCIDevice *pci_dev, uint32_t device)
 {
     EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
@@ -1829,27 +1837,24 @@ static int nic_init(PCIDevice *pci_dev, uint32_t device)
 
     nic_reset(s);
 
-    s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC,
-                                 s->conf.vlan, s->conf.peer,
-                                 pci_dev->qdev.info->name, pci_dev->qdev.id,
-                                 nic_can_receive, nic_receive, NULL, NULL,
-                                 nic_cleanup, s);
+    s->nic = qemu_new_nic(&net_eepro100_info, &s->conf,
+                          pci_dev->qdev.info->name, pci_dev->qdev.id, s);
 
-    qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
-    TRACE(OTHER, logout("%s\n", s->vc->info_str));
+    qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+    TRACE(OTHER, logout("%s\n", s->nic->nc.info_str));
 
     qemu_register_reset(nic_reset, s);
 
     s->vmstate = qemu_malloc(sizeof(vmstate_eepro100));
     memcpy(s->vmstate, &vmstate_eepro100, sizeof(vmstate_eepro100));
-    s->vmstate->name = s->vc->model;
+    s->vmstate->name = s->nic->nc.model;
     vmstate_register(-1, s->vmstate, s);
 
     if (!pci_dev->qdev.hotplugged) {
         static int loaded = 0;
         if (!loaded) {
             char fname[32];
-            snprintf(fname, sizeof(fname), "pxe-%s.bin", s->vc->model);
+            snprintf(fname, sizeof(fname), "pxe-%s.bin", s->nic->nc.model);
             rom_add_option(fname);
             loaded = 1;
         }
-- 
1.6.5.2

  parent reply	other threads:[~2009-11-25 18:52 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 18:48 [Qemu-devel] [PATCH 00/44] Fix announce_self(), misc net fixes and cleanups Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 01/44] net: move slirp code from net.c to net/slirp.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 02/44] net: move vde code from net.c to net/vde.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 03/44] net: move socket backend code from net.c to net/socket.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 04/44] net: move dump backend code from net.c to net/dump.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 05/44] net: clean up includes in net.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 06/44] net: remove NICInfo::vc Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 07/44] net: remove NICInfo::private Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 08/44] net: introduce NetClientInfo Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client() Mark McLoughlin
2009-11-25 20:36   ` Blue Swirl
2009-11-26 18:06     ` Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 10/44] qdev: move DO_UPCAST() into osdep.h Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 11/44] net: convert tap to NetClientInfo Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 12/44] net: convert tap-win32 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 13/44] net: convert slirp " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 14/44] net: convert vde " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 15/44] net: convert socket " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 16/44] net: convert dump " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 17/44] net: introduce NICState and qemu_new_nic() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 18/44] net: convert virtio to NICState Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 19/44] net: convert e1000 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 20/44] net: convert rtl8139 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 21/44] net: convert ne2000 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 22/44] net: convert pcnet " Mark McLoughlin
2009-11-25 18:49 ` Mark McLoughlin [this message]
2009-11-25 18:49 ` [Qemu-devel] [PATCH 24/44] net: convert dp8393x " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 25/44] net: convert etrax " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 26/44] net: convert LAN9118 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 27/44] net: convert mcf_fec " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 28/44] net: convert mipsnet " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 29/44] net: convert musicpal " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 30/44] net: convert smc91c111 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 31/44] net: convert stellaris " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 32/44] net: convert usb-net " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 33/44] net: convert xilinx_ethlite " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 34/44] net: move parse_macaddr() to net/util.[ch] Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 35/44] net: convert xen to NICState Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 36/44] net: remove qemu_new_vlan_client() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 37/44] net: remove VLANClientState members now in NetClientInfo Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 38/44] net: add qemu_foreach_nic() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 39/44] net: fix qemu_announce_self() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 40/44] net: print correct error for '-netdev ""' Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 41/44] net: fix TAP networking on host kernels without IFF_VNET_HDR support Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 42/44] net: check for TUNSETOFFLOAD support before trying to enable offload features Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 43/44] net: initialize vnet_hdr in net_init_tap() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 44/44] net: fix vnet_hdr handling in solaris tap code Mark McLoughlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1259174977-26212-24-git-send-email-markmc@redhat.com \
    --to=markmc@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).