net: Remove VLANState

VLANState is no longer used and can be removed.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2012-07-24 16:35:11 +01:00
parent ec8b1f6cc8
commit a005d0732f
18 changed files with 31 additions and 137 deletions

View File

@ -899,7 +899,6 @@ void dp83932_init(NICInfo *nd, target_phys_addr_t base, int it_shift,
s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */ s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */
s->conf.macaddr = nd->macaddr; s->conf.macaddr = nd->macaddr;
s->conf.vlan = nd->vlan;
s->conf.peer = nd->netdev; s->conf.peer = nd->netdev;
s->nic = qemu_new_nic(&net_dp83932_info, &s->conf, nd->model, nd->name, s); s->nic = qemu_new_nic(&net_dp83932_info, &s->conf, nd->model, nd->name, s);

View File

@ -81,7 +81,7 @@ static void lan9215_init(uint32_t base, qemu_irq irq)
SysBusDevice *s; SysBusDevice *s;
/* This should be a 9215 but the 9118 is close enough */ /* This should be a 9215 but the 9118 is close enough */
if (nd_table[0].vlan) { if (nd_table[0].used) {
qemu_check_nic_model(&nd_table[0], "lan9118"); qemu_check_nic_model(&nd_table[0], "lan9118");
dev = qdev_create(NULL, "lan9118"); dev = qdev_create(NULL, "lan9118");
qdev_set_nic_properties(dev, &nd_table[0]); qdev_set_nic_properties(dev, &nd_table[0]);

View File

@ -284,7 +284,7 @@ static void highbank_init(ram_addr_t ram_size,
sysbus_create_simple("sysbus-ahci", 0xffe08000, pic[83]); sysbus_create_simple("sysbus-ahci", 0xffe08000, pic[83]);
if (nd_table[0].vlan) { if (nd_table[0].used) {
qemu_check_nic_model(&nd_table[0], "xgmac"); qemu_check_nic_model(&nd_table[0], "xgmac");
dev = qdev_create(NULL, "xgmac"); dev = qdev_create(NULL, "xgmac");
qdev_set_nic_properties(dev, &nd_table[0]); qdev_set_nic_properties(dev, &nd_table[0]);

View File

@ -493,7 +493,7 @@ static void integratorcp_init(ram_addr_t ram_size,
sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]);
sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]);
sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL); sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
if (nd_table[0].vlan) if (nd_table[0].used)
smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
sysbus_create_simple("pl110", 0xc0000000, pic[22]); sysbus_create_simple("pl110", 0xc0000000, pic[22]);

View File

@ -121,7 +121,7 @@ static void kzm_init(ram_addr_t ram_size,
imx_timerp_create(0x53f98000, qdev_get_gpio_in(dev, 27), ccm); imx_timerp_create(0x53f98000, qdev_get_gpio_in(dev, 27), ccm);
imx_timerg_create(0x53f90000, qdev_get_gpio_in(dev, 29), ccm); imx_timerg_create(0x53f90000, qdev_get_gpio_in(dev, 29), ccm);
if (nd_table[0].vlan) { if (nd_table[0].used) {
lan9118_init(&nd_table[0], 0xb6000000, qdev_get_gpio_in(dev, 52)); lan9118_init(&nd_table[0], 0xb6000000, qdev_get_gpio_in(dev, 52));
} }

View File

@ -236,7 +236,7 @@ static void mcf5208evb_init(ram_addr_t ram_size,
fprintf(stderr, "Too many NICs\n"); fprintf(stderr, "Too many NICs\n");
exit(1); exit(1);
} }
if (nd_table[0].vlan) if (nd_table[0].used)
mcf_fec_init(address_space_mem, &nd_table[0], mcf_fec_init(address_space_mem, &nd_table[0],
0xfc030000, pic + 36); 0xfc030000, pic + 36);

View File

@ -472,7 +472,6 @@ void mcf_fec_init(MemoryRegion *sysmem, NICInfo *nd,
memory_region_add_subregion(sysmem, base, &s->iomem); memory_region_add_subregion(sysmem, base, &s->iomem);
s->conf.macaddr = nd->macaddr; s->conf.macaddr = nd->macaddr;
s->conf.vlan = nd->vlan;
s->conf.peer = nd->netdev; s->conf.peer = nd->netdev;
s->nic = qemu_new_nic(&net_mcf_fec_info, &s->conf, nd->model, nd->name, s); s->nic = qemu_new_nic(&net_mcf_fec_info, &s->conf, nd->model, nd->name, s);

View File

@ -217,7 +217,7 @@ mips_mipssim_init (ram_addr_t ram_size,
if (serial_hds[0]) if (serial_hds[0])
serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]); serial_init(0x3f8, env->irq[4], 115200, serial_hds[0]);
if (nd_table[0].vlan) if (nd_table[0].used)
/* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */ /* MIPSnet uses the MIPS CPU INT0, which is interrupt 2. */
mipsnet_init(0x4200, env->irq[2], &nd_table[0]); mipsnet_init(0x4200, env->irq[2], &nd_table[0]);
} }

View File

@ -283,7 +283,7 @@ void mips_r4k_init (ram_addr_t ram_size,
isa_vga_init(isa_bus); isa_vga_init(isa_bus);
if (nd_table[0].vlan) if (nd_table[0].used)
isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]); isa_ne2000_init(isa_bus, 0x300, 9, &nd_table[0]);
ide_drive_get(hd, MAX_IDE_BUS); ide_drive_get(hd, MAX_IDE_BUS);

View File

@ -126,7 +126,7 @@ static void openrisc_sim_init(ram_addr_t ram_size,
serial_mm_init(get_system_memory(), 0x90000000, 0, cpu->env.irq[2], serial_mm_init(get_system_memory(), 0x90000000, 0, cpu->env.irq[2],
115200, serial_hds[0], DEVICE_NATIVE_ENDIAN); 115200, serial_hds[0], DEVICE_NATIVE_ENDIAN);
if (nd_table[0].vlan) { if (nd_table[0].used) {
openrisc_sim_net_init(get_system_memory(), 0x92000000, openrisc_sim_net_init(get_system_memory(), 0x92000000,
0x92000400, cpu->env.irq[4], nd_table); 0x92000400, cpu->env.irq[4], nd_table);
} }

View File

@ -1195,13 +1195,6 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v
assert_no_error(errp); assert_no_error(errp);
} }
void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value)
{
Error *errp = NULL;
object_property_set_int(OBJECT(dev), value ? value->id : -1, name, &errp);
assert_no_error(errp);
}
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value) void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
{ {
Error *errp = NULL; Error *errp = NULL;

View File

@ -320,8 +320,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
{ {
qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a); qdev_prop_set_macaddr(dev, "mac", nd->macaddr.a);
if (nd->vlan)
qdev_prop_set_vlan(dev, "vlan", nd->vlan);
if (nd->netdev) if (nd->netdev)
qdev_prop_set_netdev(dev, "netdev", nd->netdev); qdev_prop_set_netdev(dev, "netdev", nd->netdev);
if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED && if (nd->nvectors != DEV_NVECTORS_UNSPECIFIED &&

View File

@ -321,7 +321,6 @@ void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value); void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value);
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value); void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT; int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) QEMU_WARN_UNUSED_RESULT;
void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value); void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value);
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value); void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);

View File

@ -427,7 +427,7 @@ static void vexpress_common_init(const VEDBoardInfo *daughterboard,
memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram); memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram);
/* 0x4e000000 LAN9118 Ethernet */ /* 0x4e000000 LAN9118 Ethernet */
if (nd_table[0].vlan) { if (nd_table[0].used) {
lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]); lan9118_init(&nd_table[0], map[VE_ETHERNET], pic[15]);
} }

View File

@ -201,7 +201,7 @@ static void lx_init(const LxBoardDesc *board,
memory_region_init(system_io, "lx60.io", 224 * 1024 * 1024); memory_region_init(system_io, "lx60.io", 224 * 1024 * 1024);
memory_region_add_subregion(system_memory, 0xf0000000, system_io); memory_region_add_subregion(system_memory, 0xf0000000, system_io);
lx60_fpga_init(system_io, 0x0d020000); lx60_fpga_init(system_io, 0x0d020000);
if (nd_table[0].vlan) { if (nd_table[0].used) {
lx60_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, lx60_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000,
xtensa_get_extint(env, 1), nd_table); xtensa_get_extint(env, 1), nd_table);
} }

125
net.c
View File

@ -47,7 +47,6 @@
# define CONFIG_NET_BRIDGE # define CONFIG_NET_BRIDGE
#endif #endif
static QTAILQ_HEAD(, VLANState) vlans;
static QTAILQ_HEAD(, VLANClientState) non_vlan_clients; static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
int default_net = 1; int default_net = 1;
@ -252,11 +251,7 @@ NICState *qemu_new_nic(NetClientInfo *info,
static void qemu_cleanup_vlan_client(VLANClientState *vc) static void qemu_cleanup_vlan_client(VLANClientState *vc)
{ {
if (vc->vlan) { QTAILQ_REMOVE(&non_vlan_clients, vc, next);
QTAILQ_REMOVE(&vc->vlan->clients, vc, next);
} else {
QTAILQ_REMOVE(&non_vlan_clients, vc, next);
}
if (vc->info->cleanup) { if (vc->info->cleanup) {
vc->info->cleanup(vc); vc->info->cleanup(vc);
@ -265,13 +260,11 @@ static void qemu_cleanup_vlan_client(VLANClientState *vc)
static void qemu_free_vlan_client(VLANClientState *vc) static void qemu_free_vlan_client(VLANClientState *vc)
{ {
if (!vc->vlan) { if (vc->send_queue) {
if (vc->send_queue) { qemu_del_net_queue(vc->send_queue);
qemu_del_net_queue(vc->send_queue); }
} if (vc->peer) {
if (vc->peer) { vc->peer->peer = NULL;
vc->peer->peer = NULL;
}
} }
g_free(vc->name); g_free(vc->name);
g_free(vc->model); g_free(vc->model);
@ -281,7 +274,7 @@ static void qemu_free_vlan_client(VLANClientState *vc)
void qemu_del_vlan_client(VLANClientState *vc) void qemu_del_vlan_client(VLANClientState *vc)
{ {
/* If there is a peer NIC, delete and cleanup client, but do not free. */ /* If there is a peer NIC, delete and cleanup client, but do not free. */
if (!vc->vlan && vc->peer && vc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { if (vc->peer && vc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = DO_UPCAST(NICState, nc, vc->peer); NICState *nic = DO_UPCAST(NICState, nc, vc->peer);
if (nic->peer_deleted) { if (nic->peer_deleted) {
return; return;
@ -297,7 +290,7 @@ void qemu_del_vlan_client(VLANClientState *vc)
} }
/* If this is a peer NIC and peer has already been deleted, free it now. */ /* If this is a peer NIC and peer has already been deleted, free it now. */
if (!vc->vlan && vc->peer && vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { if (vc->peer && vc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = DO_UPCAST(NICState, nc, vc); NICState *nic = DO_UPCAST(NICState, nc, vc);
if (nic->peer_deleted) { if (nic->peer_deleted) {
qemu_free_vlan_client(vc->peer); qemu_free_vlan_client(vc->peer);
@ -311,52 +304,25 @@ void qemu_del_vlan_client(VLANClientState *vc)
void qemu_foreach_nic(qemu_nic_foreach func, void *opaque) void qemu_foreach_nic(qemu_nic_foreach func, void *opaque)
{ {
VLANClientState *nc; VLANClientState *nc;
VLANState *vlan;
QTAILQ_FOREACH(nc, &non_vlan_clients, next) { QTAILQ_FOREACH(nc, &non_vlan_clients, next) {
if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) { if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
func(DO_UPCAST(NICState, nc, nc), opaque); func(DO_UPCAST(NICState, nc, nc), opaque);
} }
} }
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(nc, &vlan->clients, next) {
if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
func(DO_UPCAST(NICState, nc, nc), opaque);
}
}
}
} }
int qemu_can_send_packet(VLANClientState *sender) int qemu_can_send_packet(VLANClientState *sender)
{ {
VLANState *vlan = sender->vlan; if (!sender->peer) {
VLANClientState *vc;
if (sender->peer) {
if (sender->peer->receive_disabled) {
return 0;
} else if (sender->peer->info->can_receive &&
!sender->peer->info->can_receive(sender->peer)) {
return 0;
} else {
return 1;
}
}
if (!sender->vlan) {
return 1; return 1;
} }
QTAILQ_FOREACH(vc, &vlan->clients, next) { if (sender->peer->receive_disabled) {
if (vc == sender) { return 0;
continue; } else if (sender->peer->info->can_receive &&
} !sender->peer->info->can_receive(sender->peer)) {
return 0;
/* no can_receive() handler, they can always receive */
if (vc->info->can_receive && !vc->info->can_receive(vc)) {
return 0;
}
} }
return 1; return 1;
} }
@ -393,34 +359,18 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender,
void qemu_purge_queued_packets(VLANClientState *vc) void qemu_purge_queued_packets(VLANClientState *vc)
{ {
NetQueue *queue; if (!vc->peer) {
if (!vc->peer && !vc->vlan) {
return; return;
} }
if (vc->peer) { qemu_net_queue_purge(vc->peer->send_queue, vc);
queue = vc->peer->send_queue;
} else {
queue = vc->vlan->send_queue;
}
qemu_net_queue_purge(queue, vc);
} }
void qemu_flush_queued_packets(VLANClientState *vc) void qemu_flush_queued_packets(VLANClientState *vc)
{ {
NetQueue *queue;
vc->receive_disabled = 0; vc->receive_disabled = 0;
if (vc->vlan) { qemu_net_queue_flush(vc->send_queue);
queue = vc->vlan->send_queue;
} else {
queue = vc->send_queue;
}
qemu_net_queue_flush(queue);
} }
static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender, static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender,
@ -435,15 +385,11 @@ static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender,
hex_dump(stdout, buf, size); hex_dump(stdout, buf, size);
#endif #endif
if (sender->link_down || (!sender->peer && !sender->vlan)) { if (sender->link_down || !sender->peer) {
return size; return size;
} }
if (sender->peer) { queue = sender->peer->send_queue;
queue = sender->peer->send_queue;
} else {
queue = sender->vlan->send_queue;
}
return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb); return qemu_net_queue_send(queue, sender, flags, buf, size, sent_cb);
} }
@ -503,15 +449,11 @@ ssize_t qemu_sendv_packet_async(VLANClientState *sender,
{ {
NetQueue *queue; NetQueue *queue;
if (sender->link_down || (!sender->peer && !sender->vlan)) { if (sender->link_down || !sender->peer) {
return iov_size(iov, iovcnt); return iov_size(iov, iovcnt);
} }
if (sender->peer) { queue = sender->peer->send_queue;
queue = sender->peer->send_queue;
} else {
queue = sender->vlan->send_queue;
}
return qemu_net_queue_send_iov(queue, sender, return qemu_net_queue_send_iov(queue, sender,
QEMU_NET_PACKET_FLAG_NONE, QEMU_NET_PACKET_FLAG_NONE,
@ -921,18 +863,9 @@ static void print_net_client(Monitor *mon, VLANClientState *vc)
void do_info_network(Monitor *mon) void do_info_network(Monitor *mon)
{ {
VLANState *vlan;
VLANClientState *vc, *peer; VLANClientState *vc, *peer;
NetClientOptionsKind type; NetClientOptionsKind type;
QTAILQ_FOREACH(vlan, &vlans, next) {
monitor_printf(mon, "VLAN %d devices:\n", vlan->id);
QTAILQ_FOREACH(vc, &vlan->clients, next) {
monitor_printf(mon, " ");
print_net_client(mon, vc);
}
}
monitor_printf(mon, "Devices not on any VLAN:\n"); monitor_printf(mon, "Devices not on any VLAN:\n");
QTAILQ_FOREACH(vc, &non_vlan_clients, next) { QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
peer = vc->peer; peer = vc->peer;
@ -951,16 +884,8 @@ void do_info_network(Monitor *mon)
void qmp_set_link(const char *name, bool up, Error **errp) void qmp_set_link(const char *name, bool up, Error **errp)
{ {
VLANState *vlan;
VLANClientState *vc = NULL; VLANClientState *vc = NULL;
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH(vc, &vlan->clients, next) {
if (strcmp(vc->name, name) == 0) {
goto done;
}
}
}
QTAILQ_FOREACH(vc, &non_vlan_clients, next) { QTAILQ_FOREACH(vc, &non_vlan_clients, next) {
if (!strcmp(vc->name, name)) { if (!strcmp(vc->name, name)) {
goto done; goto done;
@ -993,15 +918,8 @@ done:
void net_cleanup(void) void net_cleanup(void)
{ {
VLANState *vlan;
VLANClientState *vc, *next_vc; VLANClientState *vc, *next_vc;
QTAILQ_FOREACH(vlan, &vlans, next) {
QTAILQ_FOREACH_SAFE(vc, &vlan->clients, next, next_vc) {
qemu_del_vlan_client(vc);
}
}
QTAILQ_FOREACH_SAFE(vc, &non_vlan_clients, next, next_vc) { QTAILQ_FOREACH_SAFE(vc, &non_vlan_clients, next, next_vc) {
qemu_del_vlan_client(vc); qemu_del_vlan_client(vc);
} }
@ -1090,7 +1008,6 @@ int net_init_clients(void)
#endif #endif
} }
QTAILQ_INIT(&vlans);
QTAILQ_INIT(&non_vlan_clients); QTAILQ_INIT(&non_vlan_clients);
if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1) if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, 1) == -1)

10
net.h
View File

@ -17,7 +17,6 @@ struct MACAddr {
typedef struct NICConf { typedef struct NICConf {
MACAddr macaddr; MACAddr macaddr;
VLANState *vlan;
VLANClientState *peer; VLANClientState *peer;
int32_t bootindex; int32_t bootindex;
} NICConf; } NICConf;
@ -53,7 +52,6 @@ struct VLANClientState {
NetClientInfo *info; NetClientInfo *info;
int link_down; int link_down;
QTAILQ_ENTRY(VLANClientState) next; QTAILQ_ENTRY(VLANClientState) next;
struct VLANState *vlan;
VLANClientState *peer; VLANClientState *peer;
NetQueue *send_queue; NetQueue *send_queue;
char *model; char *model;
@ -69,13 +67,6 @@ typedef struct NICState {
bool peer_deleted; bool peer_deleted;
} NICState; } NICState;
struct VLANState {
int id;
QTAILQ_HEAD(, VLANClientState) clients;
QTAILQ_ENTRY(VLANState) next;
NetQueue *send_queue;
};
VLANClientState *qemu_find_netdev(const char *id); VLANClientState *qemu_find_netdev(const char *id);
VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANClientState *qemu_new_net_client(NetClientInfo *info,
VLANClientState *peer, VLANClientState *peer,
@ -120,7 +111,6 @@ struct NICInfo {
char *model; char *model;
char *name; char *name;
char *devaddr; char *devaddr;
VLANState *vlan;
VLANClientState *netdev; VLANClientState *netdev;
int used; /* is this slot in nd_table[] being used? */ int used; /* is this slot in nd_table[] being used? */
int instantiated; /* does this NICInfo correspond to an instantiated NIC? */ int instantiated; /* does this NICInfo correspond to an instantiated NIC? */

View File

@ -234,7 +234,6 @@ typedef struct TextConsole TextConsole;
typedef TextConsole QEMUConsole; typedef TextConsole QEMUConsole;
typedef struct CharDriverState CharDriverState; typedef struct CharDriverState CharDriverState;
typedef struct MACAddr MACAddr; typedef struct MACAddr MACAddr;
typedef struct VLANState VLANState;
typedef struct VLANClientState VLANClientState; typedef struct VLANClientState VLANClientState;
typedef struct i2c_bus i2c_bus; typedef struct i2c_bus i2c_bus;
typedef struct ISABus ISABus; typedef struct ISABus ISABus;