Displaying 20 results from an estimated 106 matches for "__virtio16_to_cpu".
2015 Sep 24
2
[PATCH v2] Fix AF_PACKET ABI breakage in 4.2
...-endian.
>
What about introducing dedicated accessors as it is done in many other
locations where we do virtio byteswap ? Something like:
static inline bool packet_is_little_endian(void)
{
return virtio_legacy_is_little_endian();
}
static inline u16 packet16_to_cpu(__virtio16 val)
{
return __virtio16_to_cpu(packet_is_little_endian(), val);
}
static inline __virtio16 cpu_to_packet16(u16 val)
{
return __cpu_to_virtio16(packet_is_little_endian(), val);
}
It results in prettier code IMHO. Have a look at drivers/net/tun.c or
drivers/vhost/vhost.c.
> This restores the ABI to match 4.1 and earlier ker...
2015 Sep 24
2
[PATCH v2] Fix AF_PACKET ABI breakage in 4.2
...-endian.
>
What about introducing dedicated accessors as it is done in many other
locations where we do virtio byteswap ? Something like:
static inline bool packet_is_little_endian(void)
{
return virtio_legacy_is_little_endian();
}
static inline u16 packet16_to_cpu(__virtio16 val)
{
return __virtio16_to_cpu(packet_is_little_endian(), val);
}
static inline __virtio16 cpu_to_packet16(u16 val)
{
return __cpu_to_virtio16(packet_is_little_endian(), val);
}
It results in prettier code IMHO. Have a look at drivers/net/tun.c or
drivers/vhost/vhost.c.
> This restores the ABI to match 4.1 and earlier ker...
2015 Sep 24
0
[PATCH v2] Fix AF_PACKET ABI breakage in 4.2
...ccessors as it is done in many other
> locations where we do virtio byteswap ? Something like:
>
> static inline bool packet_is_little_endian(void)
> {
> return virtio_legacy_is_little_endian();
> }
>
> static inline u16 packet16_to_cpu(__virtio16 val)
> {
> return __virtio16_to_cpu(packet_is_little_endian(), val);
> }
>
> static inline __virtio16 cpu_to_packet16(u16 val)
> {
> return __cpu_to_virtio16(packet_is_little_endian(), val);
> }
>
> It results in prettier code IMHO. Have a look at drivers/net/tun.c or
> drivers/vhost/vhost.c.
>
>...
2015 Sep 24
1
[PATCH v2] Fix AF_PACKET ABI breakage in 4.2
...GET_PBDQC_FROM_RB(x) ((struct tpacket_kbdq_core *)(&(x)->prb_bdqc))
> @@ -2680,15 +2682,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
> goto out_unlock;
>
> if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
> - (__virtio16_to_cpu(false, vnet_hdr.csum_start) +
> - __virtio16_to_cpu(false, vnet_hdr.csum_offset) + 2 >
> - __virtio16_to_cpu(false, vnet_hdr.hdr_len)))
> - vnet_hdr.hdr_len = __cpu_to_virtio16(false,
> - __virtio16_to_cpu(false, vnet_hdr.csum_start) +
> - __virtio16_to_cpu(f...
2015 Sep 24
1
[PATCH v2] Fix AF_PACKET ABI breakage in 4.2
...GET_PBDQC_FROM_RB(x) ((struct tpacket_kbdq_core *)(&(x)->prb_bdqc))
> @@ -2680,15 +2682,15 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
> goto out_unlock;
>
> if ((vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
> - (__virtio16_to_cpu(false, vnet_hdr.csum_start) +
> - __virtio16_to_cpu(false, vnet_hdr.csum_offset) + 2 >
> - __virtio16_to_cpu(false, vnet_hdr.hdr_len)))
> - vnet_hdr.hdr_len = __cpu_to_virtio16(false,
> - __virtio16_to_cpu(false, vnet_hdr.csum_start) +
> - __virtio16_to_cpu(f...
2014 Oct 23
0
[PATCH RFC] tun: fix sparse warnings for virtio headers
...+1043,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EFAULT;
if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
- gso.csum_start + gso.csum_offset + 2 > gso.hdr_len)
- gso.hdr_len = gso.csum_start + gso.csum_offset + 2;
+ __virtio16_to_cpu(false, gso.csum_start) + __virtio16_to_cpu(false, gso.csum_offset) + 2 > __virtio16_to_cpu(false, gso.hdr_len))
+ gso.hdr_len = __cpu_to_virtio16(false, __virtio16_to_cpu(false, gso.csum_start) + __virtio16_to_cpu(false, gso.csum_offset) + 2);
- if (gso.hdr_len > len)
+ if (__virtio16_t...
2014 Oct 23
0
[PATCH RFC] tun: fix sparse warnings for virtio headers
...+1043,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
return -EFAULT;
if ((gso.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) &&
- gso.csum_start + gso.csum_offset + 2 > gso.hdr_len)
- gso.hdr_len = gso.csum_start + gso.csum_offset + 2;
+ __virtio16_to_cpu(false, gso.csum_start) + __virtio16_to_cpu(false, gso.csum_offset) + 2 > __virtio16_to_cpu(false, gso.hdr_len))
+ gso.hdr_len = __cpu_to_virtio16(false, __virtio16_to_cpu(false, gso.csum_start) + __virtio16_to_cpu(false, gso.csum_offset) + 2);
- if (gso.hdr_len > len)
+ if (__virtio16_t...
2015 Apr 23
16
[PATCH v5 0/8] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness. It is compatible with modern virtio and can be
fully compiled out through kernel config.
FWIW, I could flawlessly kexec/reboot guests from ppc64 to ppc64le and back.
I could also migrate from a ppc64 to a ppc64le host and back. No regressions
on x86 as expected. My experimental QEMU tree
2015 Apr 23
16
[PATCH v5 0/8] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness. It is compatible with modern virtio and can be
fully compiled out through kernel config.
FWIW, I could flawlessly kexec/reboot guests from ppc64 to ppc64le and back.
I could also migrate from a ppc64 to a ppc64le host and back. No regressions
on x86 as expected. My experimental QEMU tree
2023 Jan 31
1
[PATCH v2 2/7] vdpa: conditionally read STATUS in config space
...g, u64 features,
sizeof(config->mac), config->mac);
}
+static int vdpa_dev_net_status_config_fill(struct sk_buff *msg, u64 features,
+ const struct virtio_net_config *config)
+{
+ u16 val_u16;
+
+ if ((features & BIT_ULL(VIRTIO_NET_F_STATUS)) == 0)
+ return 0;
+
+ val_u16 = __virtio16_to_cpu(true, config->status);
+ return nla_put_u16(msg, VDPA_ATTR_DEV_NET_STATUS, val_u16);
+}
+
static int vdpa_dev_net_config_fill(struct vdpa_device *vdev, struct sk_buff *msg)
{
struct virtio_net_config config = {};
u64 features_device;
- u16 val_u16;
vdev->config->get_config(vdev,...
2015 Apr 02
9
[PATCH v2 0/7] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness. It is a complete rework of my initial post.
Patches 1 to 5 are preliminary work: we move the endianness check out of all
memory accessors to separate functions.
Patch 6 changes the semantics of the accessors so that they have explicit big
endian support.
Patch 7 brings the cross-endian
2015 Apr 02
9
[PATCH v2 0/7] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness. It is a complete rework of my initial post.
Patches 1 to 5 are preliminary work: we move the endianness check out of all
memory accessors to separate functions.
Patch 6 changes the semantics of the accessors so that they have explicit big
endian support.
Patch 7 brings the cross-endian
2015 Apr 24
27
[PATCH v6 0/8] vhost: support for cross endian guests
Only cosmetic and documentation changes since v5.
---
Greg Kurz (8):
virtio: introduce virtio_is_little_endian() helper
tun: add tun_is_little_endian() helper
macvtap: introduce macvtap_is_little_endian() helper
vringh: introduce vringh_is_little_endian() helper
vhost: introduce vhost_is_little_endian() helper
virtio: add explicit big-endian support to memory
2015 Apr 24
27
[PATCH v6 0/8] vhost: support for cross endian guests
Only cosmetic and documentation changes since v5.
---
Greg Kurz (8):
virtio: introduce virtio_is_little_endian() helper
tun: add tun_is_little_endian() helper
macvtap: introduce macvtap_is_little_endian() helper
vringh: introduce vringh_is_little_endian() helper
vhost: introduce vhost_is_little_endian() helper
virtio: add explicit big-endian support to memory
2015 Apr 07
13
[PATCH v3 0/7] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness.
Patches 1-6 remain the same as the previous post. Patch 7 was heavily changed
according to MST's comments.
---
Greg Kurz (7):
virtio: introduce virtio_is_little_endian() helper
tun: add tun_is_little_endian() helper
macvtap: introduce macvtap_is_little_endian()
2015 Apr 07
13
[PATCH v3 0/7] vhost: support for cross endian guests
Hi,
This patchset allows vhost to be used with legacy virtio when guest and host
have a different endianness.
Patches 1-6 remain the same as the previous post. Patch 7 was heavily changed
according to MST's comments.
---
Greg Kurz (7):
virtio: introduce virtio_is_little_endian() helper
tun: add tun_is_little_endian() helper
macvtap: introduce macvtap_is_little_endian()
2014 Nov 24
2
[PATCH v3 04/41] virtio: memory access APIs
...dian-ness and act accordingly.
>
> > diff --git a/include/linux/virtio_byteorder.h b/include/linux/virtio_byteorder.h
> > new file mode 100644
> > index 0000000..824ed0b
> > --- /dev/null
> > +++ b/include/linux/virtio_byteorder.h
>
> > +static inline u16 __virtio16_to_cpu(bool little_endian, __virtio16 val)
> > +{
> > + if (little_endian)
> > + return le16_to_cpu((__force __le16)val);
> > + else
> > + return (__force u16)val;
> > +}
>
> What's wrong with just using le16-to_cpu() ....
2014 Nov 24
2
[PATCH v3 04/41] virtio: memory access APIs
...dian-ness and act accordingly.
>
> > diff --git a/include/linux/virtio_byteorder.h b/include/linux/virtio_byteorder.h
> > new file mode 100644
> > index 0000000..824ed0b
> > --- /dev/null
> > +++ b/include/linux/virtio_byteorder.h
>
> > +static inline u16 __virtio16_to_cpu(bool little_endian, __virtio16 val)
> > +{
> > + if (little_endian)
> > + return le16_to_cpu((__force __le16)val);
> > + else
> > + return (__force u16)val;
> > +}
>
> What's wrong with just using le16-to_cpu() ....
2020 Jul 15
2
[PATCH RFC don't apply] vdpa_sim: endian-ness for config space
...s-endian support */
+static inline bool vdpasim_is_little_endian(struct vdpasim *vdpasim)
+{
+ return virtio_legacy_is_little_endian() ||
+ (vdpasim->features & (1ULL << VIRTIO_F_VERSION_1));
+}
+
+static inline u16 vdpasim16_to_cpu(struct vdpasim *vdpasim, __virtio16 val)
+{
+ return __virtio16_to_cpu(vdpasim_is_little_endian(vdpasim), val);
+}
+
+static inline __virtio16 cpu_to_vdpasim16(struct vdpasim *vdpasim, u16 val)
+{
+ return __cpu_to_virtio16(vdpasim_is_little_endian(vdpasim), val);
+}
+
static struct vdpasim *vdpasim_dev;
static struct vdpasim *vdpa_to_sim(struct vdpa_device *vdpa)...
2020 Jul 15
2
[PATCH RFC don't apply] vdpa_sim: endian-ness for config space
...s-endian support */
+static inline bool vdpasim_is_little_endian(struct vdpasim *vdpasim)
+{
+ return virtio_legacy_is_little_endian() ||
+ (vdpasim->features & (1ULL << VIRTIO_F_VERSION_1));
+}
+
+static inline u16 vdpasim16_to_cpu(struct vdpasim *vdpasim, __virtio16 val)
+{
+ return __virtio16_to_cpu(vdpasim_is_little_endian(vdpasim), val);
+}
+
+static inline __virtio16 cpu_to_vdpasim16(struct vdpasim *vdpasim, u16 val)
+{
+ return __cpu_to_virtio16(vdpasim_is_little_endian(vdpasim), val);
+}
+
static struct vdpasim *vdpasim_dev;
static struct vdpasim *vdpa_to_sim(struct vdpa_device *vdpa)...