aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-05-18 13:33:03 +0100
committerMark McLoughlin <markmc@redhat.com>2009-06-09 11:38:49 +0100
commite3f5ec2b5e92706e3b807059f79b1fb5d936e567 (patch)
treee49989391834350755b1138d07ac3e464a5dbd6c /hw
parentcda9046ba7dbba45f3016e5d60caffa2d72960fa (diff)
net: pass VLANClientState* as first arg to receive handlers
Give static type checking a chance to catch errors. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/dp8393x.c12
-rw-r--r--hw/e1000.c8
-rw-r--r--hw/eepro100.c8
-rw-r--r--hw/etraxfs_eth.c6
-rw-r--r--hw/mcf_fec.c8
-rw-r--r--hw/mipsnet.c10
-rw-r--r--hw/musicpal.c6
-rw-r--r--hw/ne2000.c8
-rw-r--r--hw/pcnet.c10
-rw-r--r--hw/rtl8139.c14
-rw-r--r--hw/smc91c111.c8
-rw-r--r--hw/stellaris_enet.c12
-rw-r--r--hw/usb-net.c8
-rw-r--r--hw/virtio-net.c8
-rw-r--r--hw/xen_nic.c8
15 files changed, 67 insertions, 67 deletions
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index 1b48d9684e..de399837b9 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -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->vc->fd_can_read(s)) {
+ if (s->vc->can_receive(s->vc)) {
s->loopback_packet = 1;
- s->vc->receive(s, s->tx_buffer, tx_len);
+ s->vc->receive(s->vc, s->tx_buffer, tx_len);
}
} else {
/* Transmit packet */
@@ -676,9 +676,9 @@ static CPUWriteMemoryFunc *dp8393x_write[3] = {
dp8393x_writel,
};
-static int nic_can_receive(void *opaque)
+static int nic_can_receive(VLANClientState *vc)
{
- dp8393xState *s = opaque;
+ dp8393xState *s = vc->opaque;
if (!(s->regs[SONIC_CR] & SONIC_CR_RXEN))
return 0;
@@ -725,10 +725,10 @@ static int receive_filter(dp8393xState *s, const uint8_t * buf, int size)
return -1;
}
-static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
+static void nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size)
{
uint16_t data[10];
- dp8393xState *s = opaque;
+ dp8393xState *s = vc->opaque;
int packet_type;
uint32_t available, address;
int width, rx_len = size;
diff --git a/hw/e1000.c b/hw/e1000.c
index 20544d2943..6d3eb313ec 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -592,17 +592,17 @@ e1000_set_link_status(VLANClientState *vc)
}
static int
-e1000_can_receive(void *opaque)
+e1000_can_receive(VLANClientState *vc)
{
- E1000State *s = opaque;
+ E1000State *s = vc->opaque;
return (s->mac_reg[RCTL] & E1000_RCTL_EN);
}
static void
-e1000_receive(void *opaque, const uint8_t *buf, size_t size)
+e1000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- E1000State *s = opaque;
+ E1000State *s = vc->opaque;
struct e1000_rx_desc desc;
target_phys_addr_t base;
unsigned int n, rdt;
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 39e8fccfbc..3300fbe9ea 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1433,21 +1433,21 @@ static void pci_mmio_map(PCIDevice * pci_dev, int region_num,
}
}
-static int nic_can_receive(void *opaque)
+static int nic_can_receive(VLANClientState *vc)
{
- EEPRO100State *s = opaque;
+ EEPRO100State *s = vc->opaque;
logout("%p\n", s);
return get_ru_state(s) == ru_ready;
//~ return !eepro100_buffer_full(s);
}
-static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
+static void nic_receive(VLANClientState *vc, 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 = opaque;
+ EEPRO100State *s = vc->opaque;
uint16_t rfd_status = 0xa000;
static const uint8_t broadcast_macaddr[6] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index 2446f0dcb9..78af76b9bb 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -496,15 +496,15 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa)
return match;
}
-static int eth_can_receive(void *opaque)
+static int eth_can_receive(VLANClientState *vc)
{
return 1;
}
-static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
+static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
- struct fs_eth *eth = opaque;
+ struct fs_eth *eth = vc->opaque;
int use_ma0 = eth->regs[RW_REC_CTRL] & 1;
int use_ma1 = eth->regs[RW_REC_CTRL] & 2;
int r_bcast = eth->regs[RW_REC_CTRL] & 8;
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 0b0f17ade6..d2534d05fb 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -347,15 +347,15 @@ static void mcf_fec_write(void *opaque, target_phys_addr_t addr, uint32_t value)
mcf_fec_update(s);
}
-static int mcf_fec_can_receive(void *opaque)
+static int mcf_fec_can_receive(VLANClientState *vc)
{
- mcf_fec_state *s = (mcf_fec_state *)opaque;
+ mcf_fec_state *s = vc->opaque;
return s->rx_enabled;
}
-static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
+static void mcf_fec_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- mcf_fec_state *s = (mcf_fec_state *)opaque;
+ mcf_fec_state *s = vc->opaque;
mcf_fec_bd bd;
uint32_t flags = 0;
uint32_t addr;
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index a22f49aabc..e9128cbb34 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -66,23 +66,23 @@ static int mipsnet_buffer_full(MIPSnetState *s)
return 0;
}
-static int mipsnet_can_receive(void *opaque)
+static int mipsnet_can_receive(VLANClientState *vc)
{
- MIPSnetState *s = opaque;
+ MIPSnetState *s = vc->opaque;
if (s->busy)
return 0;
return !mipsnet_buffer_full(s);
}
-static void mipsnet_receive(void *opaque, const uint8_t *buf, size_t size)
+static void mipsnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- MIPSnetState *s = opaque;
+ MIPSnetState *s = vc->opaque;
#ifdef DEBUG_MIPSNET_RECEIVE
printf("mipsnet: receiving len=%d\n", size);
#endif
- if (!mipsnet_can_receive(opaque))
+ if (!mipsnet_can_receive(vc))
return;
s->busy = 1;
diff --git a/hw/musicpal.c b/hw/musicpal.c
index b7810ca7be..844edb8f37 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -557,14 +557,14 @@ static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc)
le32_to_cpus(&desc->next);
}
-static int eth_can_receive(void *opaque)
+static int eth_can_receive(VLANClientState *vc)
{
return 1;
}
-static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
+static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- mv88w8618_eth_state *s = opaque;
+ mv88w8618_eth_state *s = vc->opaque;
uint32_t desc_addr;
mv88w8618_rx_desc desc;
int i;
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 502c8ae664..c0fc34c4b2 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -213,9 +213,9 @@ static int ne2000_buffer_full(NE2000State *s)
return 0;
}
-static int ne2000_can_receive(void *opaque)
+static int ne2000_can_receive(VLANClientState *vc)
{
- NE2000State *s = opaque;
+ NE2000State *s = vc->opaque;
if (s->cmd & E8390_STOP)
return 1;
@@ -224,9 +224,9 @@ static int ne2000_can_receive(void *opaque)
#define MIN_BUF_SIZE 60
-static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
+static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- NE2000State *s = opaque;
+ NE2000State *s = vc->opaque;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 4defc437b3..a8297df2af 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1062,9 +1062,9 @@ static int pcnet_tdte_poll(PCNetState *s)
return !!(CSR_CXST(s) & 0x8000);
}
-static int pcnet_can_receive(void *opaque)
+static int pcnet_can_receive(VLANClientState *vc)
{
- PCNetState *s = opaque;
+ PCNetState *s = vc->opaque;
if (CSR_STOP(s) || CSR_SPND(s))
return 0;
@@ -1076,9 +1076,9 @@ static int pcnet_can_receive(void *opaque)
#define MIN_BUF_SIZE 60
-static void pcnet_receive(void *opaque, const uint8_t *buf, size_t size)
+static void pcnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- PCNetState *s = opaque;
+ PCNetState *s = vc->opaque;
int is_padr = 0, is_bcast = 0, is_ladr = 0;
uint8_t buf1[60];
int remaining;
@@ -1302,7 +1302,7 @@ static void pcnet_transmit(PCNetState *s)
if (BCR_SWSTYLE(s) == 1)
add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS);
s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC;
- pcnet_receive(s, s->buffer, s->xmit_pos);
+ pcnet_receive(s->vc, s->buffer, s->xmit_pos);
s->looptest = 0;
} else
if (s->vc)
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 14119d476e..8626d5e6b8 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -790,9 +790,9 @@ static inline target_phys_addr_t rtl8139_addr64(uint32_t low, uint32_t high)
#endif
}
-static int rtl8139_can_receive(void *opaque)
+static int rtl8139_can_receive(VLANClientState *vc)
{
- RTL8139State *s = opaque;
+ RTL8139State *s = vc->opaque;
int avail;
/* Receive (drop) packets if card is disabled. */
@@ -812,9 +812,9 @@ static int rtl8139_can_receive(void *opaque)
}
}
-static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int do_interrupt)
+static void rtl8139_do_receive(VLANClientState *vc, const uint8_t *buf, int size, int do_interrupt)
{
- RTL8139State *s = opaque;
+ RTL8139State *s = vc->opaque;
uint32_t packet_header = 0;
@@ -1158,9 +1158,9 @@ static void rtl8139_do_receive(void *opaque, const uint8_t *buf, int size, int d
}
}
-static void rtl8139_receive(void *opaque, const uint8_t *buf, size_t size)
+static void rtl8139_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- rtl8139_do_receive(opaque, buf, size, 1);
+ rtl8139_do_receive(vc, buf, size, 1);
}
static void rtl8139_reset_rxring(RTL8139State *s, uint32_t bufferSize)
@@ -1757,7 +1757,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, const uint8_t *buf, int size
if (TxLoopBack == (s->TxConfig & TxLoopBack))
{
DEBUG_PRINT(("RTL8139: +++ transmit loopback mode\n"));
- rtl8139_do_receive(s, buf, size, do_interrupt);
+ rtl8139_do_receive(s->vc, buf, size, do_interrupt);
}
else
{
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 6d1fbb32c2..383f0b7daa 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -591,9 +591,9 @@ static uint32_t smc91c111_readl(void *opaque, target_phys_addr_t offset)
return val;
}
-static int smc91c111_can_receive(void *opaque)
+static int smc91c111_can_receive(VLANClientState *vc)
{
- smc91c111_state *s = (smc91c111_state *)opaque;
+ smc91c111_state *s = vc->opaque;
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST))
return 1;
@@ -602,9 +602,9 @@ static int smc91c111_can_receive(void *opaque)
return 1;
}
-static void smc91c111_receive(void *opaque, const uint8_t *buf, size_t size)
+static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- smc91c111_state *s = (smc91c111_state *)opaque;
+ smc91c111_state *s = vc->opaque;
int status;
int packetsize;
uint32_t crc;
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index 3ee9a8832c..7f308290da 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -78,9 +78,9 @@ static void stellaris_enet_update(stellaris_enet_state *s)
}
/* TODO: Implement MAC address filtering. */
-static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size)
+static void stellaris_enet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- stellaris_enet_state *s = (stellaris_enet_state *)opaque;
+ stellaris_enet_state *s = vc->opaque;
int n;
uint8_t *p;
uint32_t crc;
@@ -118,9 +118,9 @@ static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t size
stellaris_enet_update(s);
}
-static int stellaris_enet_can_receive(void *opaque)
+static int stellaris_enet_can_receive(VLANClientState *vc)
{
- stellaris_enet_state *s = (stellaris_enet_state *)opaque;
+ stellaris_enet_state *s = vc->opaque;
if ((s->rctl & SE_RCTL_RXEN) == 0)
return 1;
@@ -128,9 +128,9 @@ static int stellaris_enet_can_receive(void *opaque)
return (s->np < 31);
}
-static uint32_t stellaris_enet_read(void *opaque, target_phys_addr_t offset)
+static uint32_t stellaris_enet_read(VLANClientState *vc, target_phys_addr_t offset)
{
- stellaris_enet_state *s = (stellaris_enet_state *)opaque;
+ stellaris_enet_state *s = vc->opaque;
uint32_t val;
switch (offset) {
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 693e9767d2..d8d5e773f5 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1369,9 +1369,9 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket *p)
return ret;
}
-static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
+static void usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- USBNetState *s = opaque;
+ USBNetState *s = vc->opaque;
struct rndis_packet_msg_type *msg;
if (s->rndis) {
@@ -1405,9 +1405,9 @@ static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
s->in_ptr = 0;
}
-static int usbnet_can_receive(void *opaque)
+static int usbnet_can_receive(VLANClientState *vc)
{
- USBNetState *s = opaque;
+ USBNetState *s = vc->opaque;
if (s->rndis && !s->rndis_state == RNDIS_DATA_INITIALIZED)
return 1;
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3ca93f5872..1ffebac222 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -288,9 +288,9 @@ static int do_virtio_net_can_receive(VirtIONet *n, int bufsize)
return 1;
}
-static int virtio_net_can_receive(void *opaque)
+static int virtio_net_can_receive(VLANClientState *vc)
{
- VirtIONet *n = opaque;
+ VirtIONet *n = vc->opaque;
return do_virtio_net_can_receive(n, VIRTIO_NET_MAX_BUFSIZE);
}
@@ -361,9 +361,9 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size)
return 0;
}
-static void virtio_net_receive(void *opaque, const uint8_t *buf, size_t size)
+static void virtio_net_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- VirtIONet *n = opaque;
+ VirtIONet *n = vc->opaque;
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
size_t hdr_len, offset, i;
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index 0643e57877..173e87a8ff 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,9 +243,9 @@ static int net_rx_ok(void *opaque)
return 1;
}
-static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
+static void 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;