[SLOF] [PATCH v1 09/27] virtio: add 64-bit virtio helpers for 1.0

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Thu Jan 14 21:58:28 AEDT 2016


Alexey Kardashevskiy <aik at ozlabs.ru> writes:

> On 01/13/2016 10:16 PM, Nikunj A Dadhania wrote:
>> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
>> ---
>>   lib/libvirtio/virtio.c | 18 ++++++++++++++++++
>>   lib/libvirtio/virtio.h |  2 ++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
>> index 77676c7..aa4a45b 100644
>> --- a/lib/libvirtio/virtio.c
>> +++ b/lib/libvirtio/virtio.c
>> @@ -81,6 +81,24 @@ struct virtio_dev_common {
>>   	le64 q_used;
>>   } __attribute__ ((packed));
>>
>> +void virtio_write64(void *addr, uint64_t val)
>> +{
>> +	uint32_t hi = (val >> 32) & 0xFFFFFFFF;
>> +	uint32_t lo = val & 0xFFFFFFFF;
>> +
>> +	ci_write_32(addr, cpu_to_le32(lo));
>> +	ci_write_32(addr + 4, cpu_to_le32(hi));
>> +}
>
>
> ci_write_64 and cpu_to_le64 are there, why these new helpers?

Thats not the same here if you notice. virtio needs the 64bit writes to
be broken to high and low and write 32bits.

>
>
>> +
>> +uint64_t virtio_read64(void *addr)
>> +{
>> +	uint64_t hi, lo;
>> +
>> +	lo = le32_to_cpu(ci_read_32(addr));
>> +	hi = le32_to_cpu(ci_read_32(addr + 4));
>> +	return (hi << 32) | lo;
>> +}
>> +
>>   static void virtio_process_cap(struct virtio_device *dev, uint8_t cap_ptr)
>>   {
>>   	struct virtio_cap *cap;
>> diff --git a/lib/libvirtio/virtio.h b/lib/libvirtio/virtio.h
>> index 537862b..aa75c2d 100644
>> --- a/lib/libvirtio/virtio.h
>> +++ b/lib/libvirtio/virtio.h
>> @@ -106,6 +106,8 @@ struct vqs {
>>   /* Parts of the virtqueue are aligned on a 4096 byte page boundary */
>>   #define VQ_ALIGN(addr)	(((addr) + 0xfff) & ~0xfff)
>>
>> +extern void virtio_write64(void *addr, uint64_t val);
>> +extern uint64_t virtio_read64(void *addr);
>>   extern unsigned long virtio_vring_size(unsigned int qsize);
>>   extern unsigned int virtio_get_qsize(struct virtio_device *dev, int queue);
>>   extern struct vring_desc *virtio_get_vring_desc(struct virtio_device *dev, int queue);
>>
>
>
> -- 
> Alexey



More information about the SLOF mailing list