From ab5f3f84c4362c3014b1ecdb450f430d01b96f19 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:08 +0100 Subject: net: Drop vlan argument to qemu_new_net_client() Since hubs are now used to implement the 'vlan' feature and the vlan argument is always NULL, remove the argument entirely and update all net clients that use qemu_new_net_client(). Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 1 - 1 file changed, 1 deletion(-) (limited to 'net.h') diff --git a/net.h b/net.h index b0b8c7ab6b..e9c92b2c4d 100644 --- a/net.h +++ b/net.h @@ -79,7 +79,6 @@ struct VLANState { VLANState *qemu_find_vlan(int id, int allocate); VLANClientState *qemu_find_netdev(const char *id); VLANClientState *qemu_new_net_client(NetClientInfo *info, - VLANState *vlan, VLANClientState *peer, const char *model, const char *name); -- cgit v1.2.3 From 606c10e2bd5877e01f0ff1812d9abebf40fb522b Mon Sep 17 00:00:00 2001 From: Zhi Yong Wu Date: Tue, 24 Jul 2012 16:35:09 +0100 Subject: net: Convert qdev_prop_vlan to peer with hub Instead of using VLANState use net/hub.h to support the vlan qdev property. The vlan qdev property becomes an alias for the peer qdev property but is represented as a VLAN ID number. When a VLAN ID is selected the device will really peer with a hub port. Signed-off-by: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Reviewed-by: Laszlo Ersek --- net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net.h') diff --git a/net.h b/net.h index e9c92b2c4d..4bccead669 100644 --- a/net.h +++ b/net.h @@ -24,7 +24,7 @@ typedef struct NICConf { #define DEFINE_NIC_PROPERTIES(_state, _conf) \ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ - DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \ + DEFINE_PROP_VLAN("vlan", _state, _conf.peer), \ DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) -- cgit v1.2.3 From ec8b1f6cc8d0a5921fba93cd180b05328e537170 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:10 +0100 Subject: net: Remove vlan code from net.c The vlan implementation in net.c has been replaced by hubs so we can remove the code. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 1 - 1 file changed, 1 deletion(-) (limited to 'net.h') diff --git a/net.h b/net.h index 4bccead669..9393e4d48a 100644 --- a/net.h +++ b/net.h @@ -76,7 +76,6 @@ struct VLANState { NetQueue *send_queue; }; -VLANState *qemu_find_vlan(int id, int allocate); VLANClientState *qemu_find_netdev(const char *id); VLANClientState *qemu_new_net_client(NetClientInfo *info, VLANClientState *peer, -- cgit v1.2.3 From a005d0732fb1c8e419e506c94ea2527287fe4204 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:11 +0100 Subject: net: Remove VLANState VLANState is no longer used and can be removed. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'net.h') diff --git a/net.h b/net.h index 9393e4d48a..4e0217af78 100644 --- a/net.h +++ b/net.h @@ -17,7 +17,6 @@ struct MACAddr { typedef struct NICConf { MACAddr macaddr; - VLANState *vlan; VLANClientState *peer; int32_t bootindex; } NICConf; @@ -53,7 +52,6 @@ struct VLANClientState { NetClientInfo *info; int link_down; QTAILQ_ENTRY(VLANClientState) next; - struct VLANState *vlan; VLANClientState *peer; NetQueue *send_queue; char *model; @@ -69,13 +67,6 @@ typedef struct NICState { bool peer_deleted; } 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_new_net_client(NetClientInfo *info, VLANClientState *peer, @@ -120,7 +111,6 @@ struct NICInfo { char *model; char *name; char *devaddr; - VLANState *vlan; VLANClientState *netdev; int used; /* is this slot in nd_table[] being used? */ int instantiated; /* does this NICInfo correspond to an instantiated NIC? */ -- cgit v1.2.3 From 4e68f7a0819f179c2ff90a60611806c789911cc2 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:13 +0100 Subject: net: Rename VLANClientState to NetClientState The vlan feature is no longer part of net core. Rename VLANClientState to NetClientState because net clients are not explicitly associated with a vlan at all, instead they have a peer net client to which they are connected. This patch is a mechanical search-and-replace except for a few whitespace fixups where changing VLANClientState to NetClientState misaligned whitespace. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'net.h') diff --git a/net.h b/net.h index 4e0217af78..5857e870b0 100644 --- a/net.h +++ b/net.h @@ -17,7 +17,7 @@ struct MACAddr { typedef struct NICConf { MACAddr macaddr; - VLANClientState *peer; + NetClientState *peer; int32_t bootindex; } NICConf; @@ -27,14 +27,14 @@ typedef struct NICConf { DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \ DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) -/* VLANs support */ +/* Net clients */ -typedef void (NetPoll)(VLANClientState *, bool enable); -typedef int (NetCanReceive)(VLANClientState *); -typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); -typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); -typedef void (NetCleanup) (VLANClientState *); -typedef void (LinkStatusChanged)(VLANClientState *); +typedef void (NetPoll)(NetClientState *, bool enable); +typedef int (NetCanReceive)(NetClientState *); +typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); +typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int); +typedef void (NetCleanup) (NetClientState *); +typedef void (LinkStatusChanged)(NetClientState *); typedef struct NetClientInfo { NetClientOptionsKind type; @@ -48,11 +48,11 @@ typedef struct NetClientInfo { NetPoll *poll; } NetClientInfo; -struct VLANClientState { +struct NetClientState { NetClientInfo *info; int link_down; - QTAILQ_ENTRY(VLANClientState) next; - VLANClientState *peer; + QTAILQ_ENTRY(NetClientState) next; + NetClientState *peer; NetQueue *send_queue; char *model; char *name; @@ -61,39 +61,39 @@ struct VLANClientState { }; typedef struct NICState { - VLANClientState nc; + NetClientState nc; NICConf *conf; void *opaque; bool peer_deleted; } NICState; -VLANClientState *qemu_find_netdev(const char *id); -VLANClientState *qemu_new_net_client(NetClientInfo *info, - VLANClientState *peer, - const char *model, - const char *name); +NetClientState *qemu_find_netdev(const char *id); +NetClientState *qemu_new_net_client(NetClientInfo *info, + NetClientState *peer, + const char *model, + const char *name); NICState *qemu_new_nic(NetClientInfo *info, NICConf *conf, const char *model, const char *name, void *opaque); -void qemu_del_vlan_client(VLANClientState *vc); -VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, - const char *client_str); +void qemu_del_vlan_client(NetClientState *vc); +NetClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, + const char *client_str); typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); -int qemu_can_send_packet(VLANClientState *vc); -ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, +int qemu_can_send_packet(NetClientState *vc); +ssize_t qemu_sendv_packet(NetClientState *vc, const struct iovec *iov, int iovcnt); -ssize_t qemu_sendv_packet_async(VLANClientState *vc, const struct iovec *iov, +ssize_t qemu_sendv_packet_async(NetClientState *vc, const struct iovec *iov, int iovcnt, NetPacketSent *sent_cb); -void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_raw(VLANClientState *vc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf, +void qemu_send_packet(NetClientState *vc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_raw(NetClientState *vc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_async(NetClientState *vc, const uint8_t *buf, int size, NetPacketSent *sent_cb); -void qemu_purge_queued_packets(VLANClientState *vc); -void qemu_flush_queued_packets(VLANClientState *vc); -void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); +void qemu_purge_queued_packets(NetClientState *vc); +void qemu_flush_queued_packets(NetClientState *vc); +void qemu_format_nic_info_str(NetClientState *vc, uint8_t macaddr[6]); void qemu_macaddr_default_if_unset(MACAddr *macaddr); int qemu_show_nic_models(const char *arg, const char *const *models); void qemu_check_nic_model(NICInfo *nd, const char *model); @@ -111,7 +111,7 @@ struct NICInfo { char *model; char *name; char *devaddr; - VLANClientState *netdev; + NetClientState *netdev; int used; /* is this slot in nd_table[] being used? */ int instantiated; /* does this NICInfo correspond to an instantiated NIC? */ int nvectors; -- cgit v1.2.3 From 35277d14ece1a68dc45cbc8c5af8f469c5c49549 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:14 +0100 Subject: net: Rename vc local variables to nc Now that VLANClientState has been renamed to NetClientState all 'vc' local variables should be 'nc'. Much of the code already used 'nc' but there are places where 'vc' needs to be renamed. Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'net.h') diff --git a/net.h b/net.h index 5857e870b0..d368e24e15 100644 --- a/net.h +++ b/net.h @@ -77,23 +77,23 @@ NICState *qemu_new_nic(NetClientInfo *info, const char *model, const char *name, void *opaque); -void qemu_del_vlan_client(NetClientState *vc); +void qemu_del_vlan_client(NetClientState *nc); NetClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, const char *client_str); typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); -int qemu_can_send_packet(NetClientState *vc); -ssize_t qemu_sendv_packet(NetClientState *vc, const struct iovec *iov, +int qemu_can_send_packet(NetClientState *nc); +ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt); -ssize_t qemu_sendv_packet_async(NetClientState *vc, const struct iovec *iov, +ssize_t qemu_sendv_packet_async(NetClientState *nc, const struct iovec *iov, int iovcnt, NetPacketSent *sent_cb); -void qemu_send_packet(NetClientState *vc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_raw(NetClientState *vc, const uint8_t *buf, int size); -ssize_t qemu_send_packet_async(NetClientState *vc, const uint8_t *buf, +void qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size); +ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, int size, NetPacketSent *sent_cb); -void qemu_purge_queued_packets(NetClientState *vc); -void qemu_flush_queued_packets(NetClientState *vc); -void qemu_format_nic_info_str(NetClientState *vc, uint8_t macaddr[6]); +void qemu_purge_queued_packets(NetClientState *nc); +void qemu_flush_queued_packets(NetClientState *nc); +void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); void qemu_macaddr_default_if_unset(MACAddr *macaddr); int qemu_show_nic_models(const char *arg, const char *const *models); void qemu_check_nic_model(NICInfo *nd, const char *model); -- cgit v1.2.3 From b20c6b9e47772b9162ed194e7b2884afa6a354ab Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 24 Jul 2012 16:35:15 +0100 Subject: net: Rename qemu_del_vlan_client() to qemu_del_net_client() Another step in moving the vlan feature out of net core. Users only deal with NetClientState and therefore qemu_del_vlan_client() should be named qemu_del_net_client(). Signed-off-by: Stefan Hajnoczi Signed-off-by: Zhi Yong Wu Reviewed-by: Laszlo Ersek --- net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net.h') diff --git a/net.h b/net.h index d368e24e15..7e629d3aac 100644 --- a/net.h +++ b/net.h @@ -77,7 +77,7 @@ NICState *qemu_new_nic(NetClientInfo *info, const char *model, const char *name, void *opaque); -void qemu_del_vlan_client(NetClientState *nc); +void qemu_del_net_client(NetClientState *nc); NetClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id, const char *client_str); typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); -- cgit v1.2.3 From 1a8595931ac6ffb76c2e10675ba3a39e807f02fd Mon Sep 17 00:00:00 2001 From: Zhi Yong Wu Date: Tue, 24 Jul 2012 16:35:16 +0100 Subject: net: Make "info network" output more readable info Reviewed-by: Jan Kiszka Signed-off-by: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Reviewed-by: Laszlo Ersek --- net.h | 1 + 1 file changed, 1 insertion(+) (limited to 'net.h') diff --git a/net.h b/net.h index 7e629d3aac..adeef0c08d 100644 --- a/net.h +++ b/net.h @@ -100,6 +100,7 @@ void qemu_check_nic_model(NICInfo *nd, const char *model); int qemu_find_nic_model(NICInfo *nd, const char * const *models, const char *default_model); +void print_net_client(Monitor *mon, NetClientState *nc); void do_info_network(Monitor *mon); /* NIC info */ -- cgit v1.2.3 From 86a77c3858610a36f1409c657b1768727693d25b Mon Sep 17 00:00:00 2001 From: Zhi Yong Wu Date: Tue, 24 Jul 2012 16:35:17 +0100 Subject: net: cleanup deliver/deliver_iov func pointers Reviewed-by: Paolo Bonzini Signed-off-by: Zhi Yong Wu Signed-off-by: Stefan Hajnoczi Reviewed-by: Laszlo Ersek --- net.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'net.h') diff --git a/net.h b/net.h index adeef0c08d..29750567ed 100644 --- a/net.h +++ b/net.h @@ -100,6 +100,17 @@ void qemu_check_nic_model(NICInfo *nd, const char *model); int qemu_find_nic_model(NICInfo *nd, const char * const *models, const char *default_model); +ssize_t qemu_deliver_packet(NetClientState *sender, + unsigned flags, + const uint8_t *data, + size_t size, + void *opaque); +ssize_t qemu_deliver_packet_iov(NetClientState *sender, + unsigned flags, + const struct iovec *iov, + int iovcnt, + void *opaque); + void print_net_client(Monitor *mon, NetClientState *nc); void do_info_network(Monitor *mon); -- cgit v1.2.3