title: how can I config virtio-net-pci to emulate a big endian linux for qemu-system-aarch64 running at a little endian
body: <p>I emulate big endian linux by qemu-system-aarch64 with '-device virtio-net-pci' running at a little endian, and get the following error when i run dpdk l3fwd example.</p>
  <pre><code>#./examples/dpdk-l3fwd --log-level=pmd,8 -l 0 -- -p 0xf -L --config=&quot;(0,0,0)&quot; --parse-ptype
  EAL: Detected CPU lcores: 8
  EAL: Detected NUMA nodes: 1
  EAL: Detected static linkage of DPDK
  EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
  EAL: Selected IOVA mode 'PA'
  EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:02.0 (socket 0)
  [  150.096996] igb_uio 0000:00:02.0: uio device registered with irq 44
  virtio_read_caps(): [98] skipping non VNDR cap id: 11
  virtio_read_caps(): [84] cfg type: 5, bar: 0, offset: 0000, len: 0
  virtio_read_caps(): [70] cfg type: 2, bar: 4, offset: 300000, len: 1048576
  get_cfg_addr(): invalid cap: overflows bar space: 4194304 &gt; 16384
  virtio_read_caps(): [60] cfg type: 4, bar: 4, offset: 200000, len: 1048576
  get_cfg_addr(): invalid cap: overflows bar space: 3145728 &gt; 16384
  virtio_read_caps(): [50] cfg type: 3, bar: 4, offset: 100000, len: 1048576
  get_cfg_addr(): invalid cap: overflows bar space: 2097152 &gt; 16384
  virtio_read_caps(): [40] cfg type: 1, bar: 4, offset: 0000, len: 1048576
  get_cfg_addr(): invalid cap: overflows bar space: 1048576 &gt; 16384
  virtio_read_caps(): no modern virtio pci device found.
  vtpci_init(): trying with legacy virtio pci.
  EAL: Cannot mmap IO port resource: No such device
  eth_virtio_pci_init(): Failed to init PCI device
  EAL: Requested device 0000:00:02.0 cannot be used
  EAL: Probe PCI driver: net_virtio (1af4:1000) device: 0000:00:03.0 (socket 0)
  virtio_read_caps(): failed to map pci device!
  vtpci_init(): trying with legacy virtio pci.
  vtpci_init(): skip kernel managed virtio device.
  eth_virtio_pci_init(): Failed to init PCI device
  EAL: Requested device 0000:00:03.0 cannot be used
  TELEMETRY: No legacy callbacks, legacy socket not created
  soft parse-ptype is enabled
  L3FWD: Missing 1 or more rule files, using default instead
  port 0 is not present on the board
  EAL: Error - exiting with code: 1
    Cause: check_port_config failed
  </code></pre>
  <p>I find that it read config with following code in function virtio_read_caps</p>
  <pre><code>        ret = rte_pci_read_config(pci_dev, &amp;cap, sizeof(cap), pos);
          if (ret != sizeof(cap)) {
              PMD_INIT_LOG(DEBUG,
                       &quot;failed to read pci cap at pos: %x ret %d&quot;,
                       pos, ret);
              break;
          }
  </code></pre>
  <p>with definition of virtio_pci_cap as follows,</p>
  <pre><code>struct virtio_pci_cap {
      uint8_t cap_vndr;       /* Generic PCI field: PCI_CAP_ID_VNDR */
      uint8_t cap_next;       /* Generic PCI field: next ptr. */
      uint8_t cap_len;        /* Generic PCI field: capability length */
      uint8_t cfg_type;       /* Identifies the structure. */
      uint8_t bar;            /* Where to find it. */
      uint8_t padding[3];     /* Pad to full dword. */
      uint32_t offset;        /* Offset within bar. */
      uint32_t length;        /* Length of the structure, in bytes. */
  };
  </code></pre>
  <p>so the <code>offset</code> and <code>length</code> is big-endian. but in <a href="https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html" rel="nofollow noreferrer">virtio-v1.1-cs01</a> section 2.4, i get</p>
  <pre><code>Note: The device configuration space uses the little-endian format for multi-byte fields.
  </code></pre>
  <p>I guess that causes the problem, but there's no further information when i google it. It confuses me. Is it true that dpdk net/virtio driver does't support big-endian?</p>