src/dpdk/drivers/net/virtio/virtio_pci.c
static void
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
		       void *dst, int length)
{
	struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
#ifdef RTE_ARCH_PPC_64
	int size;

	while (length > 0) {
		if (length >= 4) {
			size = 4;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
			*(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
		} else if (length >= 2) {
			size = 2;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
			*(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
		} else {
			size = 1;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
		}

		dst = (char *)dst + size;
		offset += size;
		length -= size;
	}
#else
	rte_pci_ioport_read(VTPCI_IO(hw), dst, length,
		VIRTIO_PCI_CONFIG(dev) + offset);
#endif
}
/*
 * Since we are in legacy mode:
 * http://ozlabs.org/~rusty/virtio-spec/virtio-0.9.5.pdf
 *
 * "Note that this is possible because while the virtio header is PCI (i.e.
 * little) endian, the device-specific region is encoded in the native endian of
 * the guest (where such distinction is applicable)."
 *
 * For powerpc which supports both, qemu supposes that cpu is big endian and
 * enforces this for the virtio-net stuff.
 */


"Note that this is possible because while the virtio header is PCI  endian, the device-specific region is encoded in the native endian of
the guest (where such distinction is applicable)."

For powerpc which supports both, qemu supposes that cpu is big endian and
enforces this for the virtio-net stuff.
" Note that this is possible because while the virtio header is PCI endian the device - specific region is encoded in the native endian of the guest ( where such distinction is applicable ) . " For powerpc which supports both qemu supposes that cpu is big endian and enforces this for the virtio - net stuff .
static void
legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
		       void *dst, int length)
{
	struct virtio_pci_dev *dev = virtio_pci_get_dev(hw);
#ifdef RTE_ARCH_PPC_64
	int size;
	while (length > 0) {
		if (length >= 4) {
			size = 4;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
			*(uint32_t *)dst = rte_be_to_cpu_32(*(uint32_t *)dst);
		} else if (length >= 2) {
			size = 2;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
			*(uint16_t *)dst = rte_be_to_cpu_16(*(uint16_t *)dst);
		} else {
			size = 1;
			rte_pci_ioport_read(VTPCI_IO(hw), dst, size,
				VIRTIO_PCI_CONFIG(dev) + offset);
		}
		dst = (char *)dst + size;
		offset += size;
		length -= size;
	}
#else
	rte_pci_ioport_read(VTPCI_IO(hw), dst, length,
		VIRTIO_PCI_CONFIG(dev) + offset);
#endif
}
static void legacy_read_dev_config ( struct virtio_hw * hw , size_t offset , void * dst , int length ) { struct virtio_pci_dev * dev = virtio_pci_get_dev ( hw ) ; #ifdef RTE_ARCH_PPC_64 int size ; while ( length > 0 ) { if ( length >= 4 ) { size = 4 ; rte_pci_ioport_read ( VTPCI_IO ( hw ) , dst , size , VIRTIO_PCI_CONFIG ( dev ) + offset ) ; * ( uint32_t * ) dst = rte_be_to_cpu_32 ( * ( uint32_t * ) dst ) ; } else if ( length >= 2 ) { size = 2 ; rte_pci_ioport_read ( VTPCI_IO ( hw ) , dst , size , VIRTIO_PCI_CONFIG ( dev ) + offset ) ; * ( uint16_t * ) dst = rte_be_to_cpu_16 ( * ( uint16_t * ) dst ) ; } else { size = 1 ; rte_pci_ioport_read ( VTPCI_IO ( hw ) , dst , size , VIRTIO_PCI_CONFIG ( dev ) + offset ) ; } dst = ( char * ) dst + size ; offset += size ; length -= size ; } #else rte_pci_ioport_read ( VTPCI_IO ( hw ) , dst , length , VIRTIO_PCI_CONFIG ( dev ) + offset ) ; #endif }
Since we are in legacy mode:
 http://ozlabs.org/~rusty/virtio-spec/virtio-0.9.5.pdf
Since we are in legacy mode : http : // ozlabs . org / ~rusty / virtio - spec / virtio - 0 . 9 . 5 . pdf