Patchwork [09/10] Compile virtio-net only once

login
register
mail settings
Submitter Blue Swirl
Date March 26, 2010, 7:04 p.m.
Message ID <f43fc5581003261204x1aef484cv83e8c186ed219914@mail.gmail.com>
Download mbox | patch
Permalink /patch/48719/
State New
Headers show

Comments

Blue Swirl - March 26, 2010, 7:04 p.m.
Replace access macros with direct accesses.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 Makefile.objs   |    2 +-
 Makefile.target |    2 +-
 hw/virtio-net.c |   14 +++++++-------
 3 files changed, 9 insertions(+), 9 deletions(-)

         n->promisc = on;
@@ -253,7 +253,7 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
     n->mac_table.multi_overflow = 0;
     memset(n->mac_table.macs, 0, MAC_TABLE_ENTRIES * ETH_ALEN);

-    mac_data.entries = ldl_le_p(elem->out_sg[1].iov_base);
+    mac_data.entries = le32_to_cpu(*(uint32_t *)elem->out_sg[1].iov_base);

     if (sizeof(mac_data.entries) +
         (mac_data.entries * ETH_ALEN) > elem->out_sg[1].iov_len)
@@ -269,7 +269,7 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,

     n->mac_table.first_multi = n->mac_table.in_use;

-    mac_data.entries = ldl_le_p(elem->out_sg[2].iov_base);
+    mac_data.entries = le32_to_cpu(*(uint32_t *)elem->out_sg[2].iov_base);

     if (sizeof(mac_data.entries) +
         (mac_data.entries * ETH_ALEN) > elem->out_sg[2].iov_len)
@@ -299,7 +299,7 @@ static int virtio_net_handle_vlan_table(VirtIONet
*n, uint8_t cmd,
         return VIRTIO_NET_ERR;
     }

-    vid = lduw_le_p(elem->out_sg[1].iov_base);
+    vid = le32_to_cpu(*(uint32_t *)elem->out_sg[1].iov_base);

     if (vid >= MAX_VLAN)
         return VIRTIO_NET_ERR;
@@ -333,8 +333,8 @@ static void virtio_net_handle_ctrl(VirtIODevice
*vdev, VirtQueue *vq)
             exit(1);
         }

-        ctrl.class = ldub_p(elem.out_sg[0].iov_base);
-        ctrl.cmd = ldub_p(elem.out_sg[0].iov_base + sizeof(ctrl.class));
+        ctrl.class = *(uint8_t *)elem.out_sg[0].iov_base;
+        ctrl.cmd = *(uint8_t *)(elem.out_sg[0].iov_base + sizeof(ctrl.class));

         if (ctrl.class == VIRTIO_NET_CTRL_RX_MODE)
             status = virtio_net_handle_rx_mode(n, ctrl.cmd, &elem);
@@ -343,7 +343,7 @@ static void virtio_net_handle_ctrl(VirtIODevice
*vdev, VirtQueue *vq)
         else if (ctrl.class == VIRTIO_NET_CTRL_VLAN)
             status = virtio_net_handle_vlan_table(n, ctrl.cmd, &elem);

-        stb_p(elem.in_sg[elem.in_num - 1].iov_base, status);
+        *(uint8_t *)elem.in_sg[elem.in_num - 1].iov_base = status;

         virtqueue_push(vq, &elem, sizeof(status));
         virtio_notify(vdev, vq);

Patch

diff --git a/Makefile.objs b/Makefile.objs
index 7973ab2..cad6490 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -128,7 +128,7 @@  user-obj-y += cutils.o cache-utils.o

 hw-obj-y =
 hw-obj-y += loader.o
-hw-obj-y += virtio.o virtio-console.o virtio-pci.o virtio-serial-bus.o
+hw-obj-y += virtio.o virtio-console.o virtio-pci.o virtio-net.o
virtio-serial-bus.o
 hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o
 hw-obj-y += watchdog.o
 hw-obj-$(CONFIG_ISA_MMIO) += isa_mmio.o
diff --git a/Makefile.target b/Makefile.target
index 285c805..e43e138 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -165,7 +165,7 @@  obj-y = vl.o monitor.o machine.o gdbstub.o
 obj-y += qemu-timer.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
-obj-y += virtio-blk.o virtio-balloon.o virtio-net.o
+obj-y += virtio-blk.o virtio-balloon.o
 obj-y += rwhandler.o
 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
 LIBS+=-lz
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index be33c68..5f04b6f 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -217,7 +217,7 @@  static int virtio_net_handle_rx_mode(VirtIONet *n,
uint8_t cmd,
         exit(1);
     }

-    on = ldub_p(elem->out_sg[1].iov_base);
+    on = *(uint8_t *)elem->out_sg[1].iov_base;

     if (cmd == VIRTIO_NET_CTRL_RX_MODE_PROMISC)