[dpdk-dev] [ [PATCH v2] 05/13] virtio: change io_base datatype from uint32_t to uint64_type

Santosh Shukla sshukla at mvista.com
Wed Dec 16 15:01:57 CET 2015


On Wed, Dec 16, 2015 at 7:18 PM, Yuanhan Liu
<yuanhan.liu at linux.intel.com> wrote:
> On Mon, Dec 14, 2015 at 06:30:24PM +0530, Santosh Shukla wrote:
>> In x86 case io_base to store ioport address not more than 65535 ioports. i.e..0
>> to ffff but in non-x86 case in particular arm64 it need to store more than 32
>> bit address so changing io_base datatype from 32 to 64.
>>
>> Signed-off-by: Santosh Shukla <sshukla at mvista.com>
>> ---
>>  drivers/net/virtio/virtio_ethdev.c |    2 +-
>>  drivers/net/virtio/virtio_pci.h    |    4 ++--
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
>> index d928339..620e0d4 100644
>> --- a/drivers/net/virtio/virtio_ethdev.c
>> +++ b/drivers/net/virtio/virtio_ethdev.c
>> @@ -1291,7 +1291,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
>>               return -1;
>>
>>       hw->use_msix = virtio_has_msix(&pci_dev->addr);
>> -     hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr;
>> +     hw->io_base = (uint64_t)(uintptr_t)pci_dev->mem_resource[0].addr;
>
> I'd suggest to move the io_base assignment (and cast) into virtio_ioport_init()
> so that we could do the correct cast there, say cast it to uint32_t for
> X86, and uint64_t for others.
>

Ok.

This was deliberately done considering your 1.0 virtio spec patch do
care for uint64_t types and in arm64 case, If I plan to use those
future patches, IMO it make more sense to me keep it in uint64_t way;

Also in x86 case max address could of type 0x1000-101f and so forth;
changing data-type to uint64_t default wont effect such address,
right? And hw->io_base by looking at virtio_pci.h function like
inb/outb etc.. takes io_base address as unsigned long types which is
arch dependent; i.e.. 4 byte for 32 bit and 8 for 64 bit so the lower
level rd/wr apis are taking care of data-types accordingly.
>         --yliu
>
>>
>>       /* Reset the device although not necessary at startup */
>>       vtpci_reset(hw);
>> diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
>> index 3f4ff80..f3e4178 100644
>> --- a/drivers/net/virtio/virtio_pci.h
>> +++ b/drivers/net/virtio/virtio_pci.h
>> @@ -169,7 +169,7 @@ struct virtqueue;
>>
>>  struct virtio_hw {
>>       struct virtqueue *cvq;
>> -     uint32_t    io_base;
>> +     uint64_t    io_base;
>>       uint32_t    guest_features;
>>       uint32_t    max_tx_queues;
>>       uint32_t    max_rx_queues;
>> @@ -231,7 +231,7 @@ outl_p(unsigned int data, unsigned int port)
>>  #endif
>>
>>  #define VIRTIO_PCI_REG_ADDR(hw, reg) \
>> -     (unsigned short)((hw)->io_base + (reg))
>> +     (unsigned long)((hw)->io_base + (reg))
>>
>>  #define VIRTIO_READ_REG_1(hw, reg) \
>>       inb((VIRTIO_PCI_REG_ADDR((hw), (reg))))
>> --
>> 1.7.9.5


More information about the dev mailing list