diff mbox

[4/9] virtio: Teach virtio-net about DO_UPCAST

Message ID 3514a89848cd2a07ac988d819210c245ddea1094.1268765204.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela March 16, 2010, 6:51 p.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-net.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

Comments

Michael S. Tsirkin March 18, 2010, 7:29 a.m. UTC | #1
On Tue, Mar 16, 2010 at 07:51:20PM +0100, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Sent a replacement patch for this.

> ---
>  hw/virtio-net.c |   21 ++++++++-------------
>  1 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 5c0093e..c0537c8 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -61,14 +61,9 @@ typedef struct VirtIONet
>   * - we could suppress RX interrupt if we were so inclined.
>   */
> 
> -static VirtIONet *to_virtio_net(VirtIODevice *vdev)
> -{
> -    return (VirtIONet *)vdev;
> -}
> -
>  static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
>      struct virtio_net_config netcfg;
> 
>      netcfg.status = n->status;
> @@ -78,7 +73,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> 
>  static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
>      struct virtio_net_config netcfg;
> 
>      memcpy(&netcfg, config, sizeof(netcfg));
> @@ -105,7 +100,7 @@ static void virtio_net_set_link_status(VLANClientState *nc)
> 
>  static void virtio_net_reset(VirtIODevice *vdev)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
> 
>      /* Reset back to compatibility mode */
>      n->promisc = 1;
> @@ -149,7 +144,7 @@ static int peer_has_ufo(VirtIONet *n)
> 
>  static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
> 
>      features |= (1 << VIRTIO_NET_F_MAC);
> 
> @@ -192,7 +187,7 @@ static uint32_t virtio_net_bad_features(VirtIODevice *vdev)
> 
>  static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
> 
>      n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF));
> 
> @@ -315,7 +310,7 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
> 
>  static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
>      struct virtio_net_ctrl_hdr ctrl;
>      virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
>      VirtQueueElement elem;
> @@ -353,7 +348,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
> 
>  static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
> 
>      qemu_flush_queued_packets(&n->nic->nc);
> 
> @@ -665,7 +660,7 @@ static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)
> 
>  static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
>  {
> -    VirtIONet *n = to_virtio_net(vdev);
> +    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
> 
>      if (n->tx_timer_active) {
>          virtio_queue_set_notification(vq, 1);
> -- 
> 1.6.6.1
> 
>
diff mbox

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 5c0093e..c0537c8 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -61,14 +61,9 @@  typedef struct VirtIONet
  * - we could suppress RX interrupt if we were so inclined.
  */

-static VirtIONet *to_virtio_net(VirtIODevice *vdev)
-{
-    return (VirtIONet *)vdev;
-}
-
 static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
     struct virtio_net_config netcfg;

     netcfg.status = n->status;
@@ -78,7 +73,7 @@  static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)

 static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
     struct virtio_net_config netcfg;

     memcpy(&netcfg, config, sizeof(netcfg));
@@ -105,7 +100,7 @@  static void virtio_net_set_link_status(VLANClientState *nc)

 static void virtio_net_reset(VirtIODevice *vdev)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);

     /* Reset back to compatibility mode */
     n->promisc = 1;
@@ -149,7 +144,7 @@  static int peer_has_ufo(VirtIONet *n)

 static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);

     features |= (1 << VIRTIO_NET_F_MAC);

@@ -192,7 +187,7 @@  static uint32_t virtio_net_bad_features(VirtIODevice *vdev)

 static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);

     n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF));

@@ -315,7 +310,7 @@  static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,

 static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
     struct virtio_net_ctrl_hdr ctrl;
     virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
     VirtQueueElement elem;
@@ -353,7 +348,7 @@  static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)

 static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);

     qemu_flush_queued_packets(&n->nic->nc);

@@ -665,7 +660,7 @@  static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq)

 static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIONet *n = to_virtio_net(vdev);
+    VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);

     if (n->tx_timer_active) {
         virtio_queue_set_notification(vq, 1);