net: introduce qemu_get_nic()
To support multiqueue, this patch introduces a helper qemu_get_nic() to get
NICState from a NetClientState. The following patches would refactor this helper
to support multiqueue.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 22d24ae..b825e83 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -786,7 +786,7 @@
static int rtl8139_can_receive(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
int avail;
/* Receive (drop) packets if card is disabled. */
@@ -808,7 +808,7 @@
static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t size_, int do_interrupt)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
/* size is the length of the buffer passed to the driver */
int size = size_;
const uint8_t *dot1q_buf = NULL;
@@ -3429,7 +3429,7 @@
static void rtl8139_cleanup(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
s->nic = NULL;
}
@@ -3451,7 +3451,7 @@
static void rtl8139_set_link_status(NetClientState *nc)
{
- RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+ RTL8139State *s = qemu_get_nic_opaque(nc);
if (nc->link_down) {
s->BasicModeStatus &= ~0x04;