qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: agraf@suse.de, clg@kaod.org, thuth@redhat.com,
	lvivier@redhat.com, aik@ozlabs.ru, mark.cave-ayland@ilande.co.uk,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 06/49] tests: rename target_big_endian() as qvirtio_is_big_endian()
Date: Wed, 26 Oct 2016 22:42:10 +1100	[thread overview]
Message-ID: <1477482173-8761-7-git-send-email-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <1477482173-8761-1-git-send-email-david@gibson.dropbear.id.au>

From: Laurent Vivier <lvivier@redhat.com>

Move the definition to libqos/virtio.h as it must be used
only with virtio functions.

Add a QVirtioDevice parameter as it will be needed to
know if the virtio device is using virtio 1.0 specification
and thus is always little-endian (to do)

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 tests/libqos/virtio-pci.c |  2 +-
 tests/libqos/virtio.h     |  6 ++++++
 tests/libqtest.h          | 10 ----------
 tests/virtio-blk-test.c   | 36 ++++++++++++++++++------------------
 4 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
index bbfed58..7aa29b1 100644
--- a/tests/libqos/virtio-pci.c
+++ b/tests/libqos/virtio-pci.c
@@ -86,7 +86,7 @@ static uint64_t qvirtio_pci_config_readq(QVirtioDevice *d, uint64_t addr)
     int i;
     uint64_t u64 = 0;
 
-    if (target_big_endian()) {
+    if (qvirtio_is_big_endian(d)) {
         for (i = 0; i < 8; ++i) {
             u64 |= (uint64_t)qpci_io_readb(dev->pdev,
                                 (void *)(uintptr_t)addr + i) << (7 - i) * 8;
diff --git a/tests/libqos/virtio.h b/tests/libqos/virtio.h
index ac4669a..3397a08 100644
--- a/tests/libqos/virtio.h
+++ b/tests/libqos/virtio.h
@@ -89,6 +89,12 @@ struct QVirtioBus {
     void (*virtqueue_kick)(QVirtioDevice *d, QVirtQueue *vq);
 };
 
+static inline bool qvirtio_is_big_endian(QVirtioDevice *d)
+{
+    /* FIXME: virtio 1.0 is always little-endian */
+    return qtest_big_endian(global_qtest);
+}
+
 static inline uint32_t qvring_size(uint32_t num, uint32_t align)
 {
     return ((sizeof(struct vring_desc) * num + sizeof(uint16_t) * (3 + num)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 4be1f77..0224f06 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -881,16 +881,6 @@ static inline int64_t clock_set(int64_t val)
     return qtest_clock_set(global_qtest, val);
 }
 
-/**
- * target_big_endian:
- *
- * Returns: True if the architecture under test has a big endian configuration.
- */
-static inline bool target_big_endian(void)
-{
-    return qtest_big_endian(global_qtest);
-}
-
 QDict *qmp_fd_receive(int fd);
 void qmp_fd_sendv(int fd, const char *fmt, va_list ap);
 void qmp_fd_send(int fd, const char *fmt, ...);
diff --git a/tests/virtio-blk-test.c b/tests/virtio-blk-test.c
index 9a6f2cf..79e21c5 100644
--- a/tests/virtio-blk-test.c
+++ b/tests/virtio-blk-test.c
@@ -117,23 +117,23 @@ static QVirtioPCIDevice *virtio_blk_pci_init(QPCIBus *bus, int slot)
     return dev;
 }
 
-static inline void virtio_blk_fix_request(QVirtioBlkReq *req)
+static inline void virtio_blk_fix_request(QVirtioDevice *d, QVirtioBlkReq *req)
 {
 #ifdef HOST_WORDS_BIGENDIAN
-    bool host_endian = true;
+    const bool host_is_big_endian = true;
 #else
-    bool host_endian = false;
+    const bool host_is_big_endian = false;
 #endif
 
-    if (target_big_endian() != host_endian) {
+    if (qvirtio_is_big_endian(d) != host_is_big_endian) {
         req->type = bswap32(req->type);
         req->ioprio = bswap32(req->ioprio);
         req->sector = bswap64(req->sector);
     }
 }
 
-static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioBlkReq *req,
-                                                            uint64_t data_size)
+static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioDevice *d,
+                                   QVirtioBlkReq *req, uint64_t data_size)
 {
     uint64_t addr;
     uint8_t status = 0xFF;
@@ -141,7 +141,7 @@ static uint64_t virtio_blk_request(QGuestAllocator *alloc, QVirtioBlkReq *req,
     g_assert_cmpuint(data_size % 512, ==, 0);
     addr = guest_alloc(alloc, sizeof(*req) + data_size);
 
-    virtio_blk_fix_request(req);
+    virtio_blk_fix_request(d, req);
 
     memwrite(addr, req, 16);
     memwrite(addr + 16, req->data, data_size);
@@ -182,7 +182,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc,
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, dev, &req, 512);
 
     g_free(req.data);
 
@@ -204,7 +204,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc,
     req.sector = 0;
     req.data = g_malloc0(512);
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, dev, &req, 512);
 
     g_free(req.data);
 
@@ -234,7 +234,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc,
         req.data = g_malloc0(512);
         strcpy(req.data, "TEST");
 
-        req_addr = virtio_blk_request(alloc, &req, 512);
+        req_addr = virtio_blk_request(alloc, dev, &req, 512);
 
         g_free(req.data);
 
@@ -254,7 +254,7 @@ static void test_basic(QVirtioDevice *dev, QGuestAllocator *alloc,
         req.sector = 1;
         req.data = g_malloc0(512);
 
-        req_addr = virtio_blk_request(alloc, &req, 512);
+        req_addr = virtio_blk_request(alloc, dev, &req, 512);
 
         g_free(req.data);
 
@@ -348,7 +348,7 @@ static void pci_indirect(void)
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -373,7 +373,7 @@ static void pci_indirect(void)
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -495,7 +495,7 @@ static void pci_msix(void)
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -518,7 +518,7 @@ static void pci_msix(void)
     req.sector = 0;
     req.data = g_malloc0(512);
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -600,7 +600,7 @@ static void pci_idx(void)
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -618,7 +618,7 @@ static void pci_idx(void)
     req.data = g_malloc0(512);
     strcpy(req.data, "TEST");
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
@@ -643,7 +643,7 @@ static void pci_idx(void)
     req.sector = 1;
     req.data = g_malloc0(512);
 
-    req_addr = virtio_blk_request(alloc, &req, 512);
+    req_addr = virtio_blk_request(alloc, &dev->vdev, &req, 512);
 
     g_free(req.data);
 
-- 
2.7.4

  parent reply	other threads:[~2016-10-26 11:43 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-26 11:42 [Qemu-devel] [PULL 00/49] ppc-for-2.8 queue 20161026 David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 01/49] pseries: Update SLOF firmware image to 20161019 David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 02/49] ppc/xics: Add xics to the monitor "info pic" command David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 03/49] tests: fix memory leak in virtio-scsi-test David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 04/49] tests: don't check if qtest_spapr_boot() returns NULL David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 05/49] tests: move QVirtioBus pointer into QVirtioDevice David Gibson
2016-10-26 11:42 ` David Gibson [this message]
2016-10-26 11:42 ` [Qemu-devel] [PULL 07/49] tests: use qtest_pc_boot()/qtest_shutdown() in virtio tests David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 08/49] tests: enable virtio tests on SPAPR David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 09/49] spapr_pci: advertise explicit numa IDs even when there's 1 node David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 10/49] nvram: Introduce helper functions for CHRP "system" and "free space" partitions David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 11/49] sparc: Use the new common NVRAM functions for system and free space partition David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 12/49] nvram: Move the remaining CHRP NVRAM related code to chrp_nvram.[ch] David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 13/49] nvram: Rename openbios_firmware_abi.h into sun_nvram.h David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 14/49] target-ppc: implement vnegw/d instructions David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 15/49] target-ppc: implement xxbr[qdwh] instruction David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 16/49] ppc/xics: add a xics_set_nr_servers common routine David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 17/49] ppc/xics: add a XICSState backlink in ICPState David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 18/49] ppc/xics: change the icp_ routines API to use an 'ICPState *' argument David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 19/49] ppc: fix MSR_ME handling for system reset interrupt David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 20/49] pseries: Remove unused callbacks from sPAPR VIO bus state David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 21/49] ppc: Fix single step with gdb stub David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 22/49] ppc: add skiboot firmware for the pnv platform David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 23/49] ppc/pnv: add skeleton PowerNV platform David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 24/49] ppc/pnv: add a PnvChip object David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 25/49] ppc/pnv: add a core mask to PnvChip David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 26/49] ppc/pnv: add a PIR handler " David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 27/49] ppc/pnv: add a PnvCore object David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 28/49] ppc/pnv: add XSCOM infrastructure David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 29/49] ppc/pnv: add XSCOM handlers to PnvCore David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 30/49] ppc/pnv: add a LPC controller David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 31/49] ppc/pnv: add a ISA bus David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 32/49] target-ppc: add vmul10[u, eu, cu, ecu]q instructions David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 33/49] pseries: Split device tree construction from device tree load David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 34/49] pseries: Remove rtas_addr and fdt_addr fields from machinestate David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 35/49] pseries: Make spapr_create_fdt_skel() get information from machine state David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 36/49] pseries: Move adding of fdt reserve map entries David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 37/49] pseries: Consolidate RTAS loading David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 38/49] pseries: Move construction of /interrupt-controller fdt node David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 39/49] pseries: Consolidate construction of /chosen device tree node David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 40/49] pseries: Consolidate construction of /rtas " David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 41/49] pseries: Move /event-sources construction to spapr_build_fdt() David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 42/49] pseries: Move /hypervisor node construction to fdt_build_fdt() David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 43/49] pseries: Consolidate construction of /vdevice device tree node David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 44/49] pseries: Remove spapr_create_fdt_skel() David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 45/49] spapr_ovec: initial implementation of option vector helpers David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 46/49] spapr_hcall: use spapr_ovec_* interfaces for CAS options David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 47/49] spapr: add option vector handling in CAS-generated resets David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 48/49] spapr: improve ibm, architecture-vec-5 property handling David Gibson
2016-10-26 11:42 ` [Qemu-devel] [PULL 49/49] adb: change handler only when recognized David Gibson
2016-10-27 13:06 ` [Qemu-devel] [PULL 00/49] ppc-for-2.8 queue 20161026 Peter Maydell
2016-10-27 13:34   ` David Gibson
2016-10-27 14:05     ` Peter Maydell
2016-10-27 14:25     ` Cédric Le Goater
2016-10-27 22:38       ` David Gibson
2016-10-27 13:52   ` Cédric Le Goater
2016-10-27 13:58     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477482173-8761-7-git-send-email-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=clg@kaod.org \
    --cc=lvivier@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).