[PATCH 4/6] tuntap: use common code for virtio_net_hdr and skb GSO conversion

2016-06-08 Thread Mike Rapoport
Replace open coded conversion between virtio_net_hdr to skb GSO info with
virtio_net_hdr_{from,to}_skb

Signed-off-by: Mike Rapoport 
---
 drivers/net/tun.c | 97 ---
 1 file changed, 21 insertions(+), 76 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index e16487c..8cc6bf4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1254,15 +1254,6 @@ 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) {
-   if (!skb_partial_csum_set(skb, tun16_to_cpu(tun, 
gso.csum_start),
- tun16_to_cpu(tun, gso.csum_offset))) {
-   this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
-   kfree_skb(skb);
-   return -EINVAL;
-   }
-   }
-
switch (tun->flags & TUN_TYPE_MASK) {
case IFF_TUN:
if (tun->flags & IFF_NO_PI) {
@@ -1289,37 +1280,11 @@ static ssize_t tun_get_user(struct tun_struct *tun, 
struct tun_file *tfile,
break;
}
 
-   if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
-   pr_debug("GSO!\n");
-   switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
-   case VIRTIO_NET_HDR_GSO_TCPV4:
-   skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
-   break;
-   case VIRTIO_NET_HDR_GSO_TCPV6:
-   skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
-   break;
-   case VIRTIO_NET_HDR_GSO_UDP:
-   skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-   break;
-   default:
-   this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
-   kfree_skb(skb);
-   return -EINVAL;
-   }
-
-   if (gso.gso_type & VIRTIO_NET_HDR_GSO_ECN)
-   skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
-
-   skb_shinfo(skb)->gso_size = tun16_to_cpu(tun, gso.gso_size);
-   if (skb_shinfo(skb)->gso_size == 0) {
-   this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
-   kfree_skb(skb);
-   return -EINVAL;
-   }
-
-   /* Header must be checked, and gso_segs computed. */
-   skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
-   skb_shinfo(skb)->gso_segs = 0;
+   err = virtio_net_hdr_to_skb(skb, &gso, tun_is_little_endian(tun));
+   if (err) {
+   this_cpu_inc(tun->pcpu_stats->rx_frame_errors);
+   kfree_skb(skb);
+   return -EINVAL;
}
 
/* copy skb_ubuf_info for callback when skb has no error */
@@ -1399,46 +1364,26 @@ static ssize_t tun_put_user(struct tun_struct *tun,
 
if (vnet_hdr_sz) {
struct virtio_net_hdr gso = { 0 }; /* no info leak */
+   int ret;
+
if (iov_iter_count(iter) < vnet_hdr_sz)
return -EINVAL;
 
-   if (skb_is_gso(skb)) {
+   ret = virtio_net_hdr_from_skb(skb, &gso,
+ tun_is_little_endian(tun));
+   if (ret) {
struct skb_shared_info *sinfo = skb_shinfo(skb);
-
-   /* This is a hint as to how much should be linear. */
-   gso.hdr_len = cpu_to_tun16(tun, skb_headlen(skb));
-   gso.gso_size = cpu_to_tun16(tun, sinfo->gso_size);
-   if (sinfo->gso_type & SKB_GSO_TCPV4)
-   gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
-   else if (sinfo->gso_type & SKB_GSO_TCPV6)
-   gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-   else if (sinfo->gso_type & SKB_GSO_UDP)
-   gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
-   else {
-   pr_err("unexpected GSO type: "
-  "0x%x, gso_size %d, hdr_len %d\n",
-  sinfo->gso_type, tun16_to_cpu(tun, 
gso.gso_size),
-  tun16_to_cpu(tun, gso.hdr_len));
-   print_hex_dump(KERN_ERR, "tun: ",
-  DUMP_PREFIX_NONE,
-  16, 1, skb->head,
-  min((int)tun16_to_cpu(tun, 
gso.hdr_len), 64), true);
-   WARN_ON_ONCE(1);
-   return -EINVAL;
-   

[PATCH 6/6] packet: use common code for virtio_net_hdr and skb GSO conversion

2016-06-08 Thread Mike Rapoport
Replace open coded conversion between virtio_net_hdr to skb GSO info with
virtio_net_hdr_from_skb

Signed-off-by: Mike Rapoport 
---
 net/packet/af_packet.c | 36 ++--
 1 file changed, 2 insertions(+), 34 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4040eb9..ec35aa9 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1978,40 +1978,8 @@ static int __packet_rcv_vnet(const struct sk_buff *skb,
 {
*vnet_hdr = (const struct virtio_net_hdr) { 0 };
 
-   if (skb_is_gso(skb)) {
-   struct skb_shared_info *sinfo = skb_shinfo(skb);
-
-   /* This is a hint as to how much should be linear. */
-   vnet_hdr->hdr_len =
-   __cpu_to_virtio16(vio_le(), skb_headlen(skb));
-   vnet_hdr->gso_size =
-   __cpu_to_virtio16(vio_le(), sinfo->gso_size);
-
-   if (sinfo->gso_type & SKB_GSO_TCPV4)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
-   else if (sinfo->gso_type & SKB_GSO_TCPV6)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-   else if (sinfo->gso_type & SKB_GSO_UDP)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
-   else if (sinfo->gso_type & SKB_GSO_FCOE)
-   return -EINVAL;
-   else
-   BUG();
-
-   if (sinfo->gso_type & SKB_GSO_TCP_ECN)
-   vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
-   } else
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
-
-   if (skb->ip_summed == CHECKSUM_PARTIAL) {
-   vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-   vnet_hdr->csum_start = __cpu_to_virtio16(vio_le(),
- skb_checksum_start_offset(skb));
-   vnet_hdr->csum_offset = __cpu_to_virtio16(vio_le(),
-skb->csum_offset);
-   } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
-   vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
-   } /* else everything is zero */
+   if (virtio_net_hdr_from_skb(skb, vnet_hdr, vio_le()))
+   BUG();
 
return 0;
 }
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 2/6] virtio_net: introduce virtio_net_hdr_{from,to}_skb

2016-06-08 Thread Mike Rapoport
The code for conversion between virtio_net_hdr and skb GSO info is
duplicated at several places. Let's put it to a common place to allow
reuse.

Signed-off-by: Mike Rapoport 
---
 include/linux/virtio_net.h | 101 +
 1 file changed, 101 insertions(+)
 create mode 100644 include/linux/virtio_net.h

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
new file mode 100644
index 000..1c912f8
--- /dev/null
+++ b/include/linux/virtio_net.h
@@ -0,0 +1,101 @@
+#ifndef _LINUX_VIRTIO_NET_H
+#define _LINUX_VIRTIO_NET_H
+
+#include 
+#include 
+
+static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
+   const struct virtio_net_hdr *hdr,
+   bool little_endian)
+{
+   unsigned short gso_type = 0;
+
+   if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+   switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
+   case VIRTIO_NET_HDR_GSO_TCPV4:
+   gso_type = SKB_GSO_TCPV4;
+   break;
+   case VIRTIO_NET_HDR_GSO_TCPV6:
+   gso_type = SKB_GSO_TCPV6;
+   break;
+   case VIRTIO_NET_HDR_GSO_UDP:
+   gso_type = SKB_GSO_UDP;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   if (hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
+   gso_type |= SKB_GSO_TCP_ECN;
+
+   if (hdr->gso_size == 0)
+   return -EINVAL;
+   }
+
+   if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
+   u16 start = __virtio16_to_cpu(little_endian, hdr->csum_start);
+   u16 off = __virtio16_to_cpu(little_endian, hdr->csum_offset);
+
+   if (!skb_partial_csum_set(skb, start, off))
+   return -EINVAL;
+   }
+
+   if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
+   u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size);
+
+   skb_shinfo(skb)->gso_size = gso_size;
+   skb_shinfo(skb)->gso_type = gso_type;
+
+   /* Header must be checked, and gso_segs computed. */
+   skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
+   skb_shinfo(skb)->gso_segs = 0;
+   }
+
+   return 0;
+}
+
+static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
+ struct virtio_net_hdr *hdr,
+ bool little_endian)
+{
+   memset(hdr, 0, sizeof(*hdr));
+
+   if (skb_is_gso(skb)) {
+   struct skb_shared_info *sinfo = skb_shinfo(skb);
+
+   /* This is a hint as to how much should be linear. */
+   hdr->hdr_len = __cpu_to_virtio16(little_endian,
+skb_headlen(skb));
+   hdr->gso_size = __cpu_to_virtio16(little_endian,
+ sinfo->gso_size);
+   if (sinfo->gso_type & SKB_GSO_TCPV4)
+   hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
+   else if (sinfo->gso_type & SKB_GSO_TCPV6)
+   hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+   else if (sinfo->gso_type & SKB_GSO_UDP)
+   hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
+   else
+   return -EINVAL;
+   if (sinfo->gso_type & SKB_GSO_TCP_ECN)
+   hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
+   } else
+   hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
+
+   if (skb->ip_summed == CHECKSUM_PARTIAL) {
+   hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
+   if (skb_vlan_tag_present(skb))
+   hdr->csum_start = __cpu_to_virtio16(little_endian,
+   skb_checksum_start_offset(skb) + VLAN_HLEN);
+   else
+   hdr->csum_start = __cpu_to_virtio16(little_endian,
+   skb_checksum_start_offset(skb));
+   hdr->csum_offset = __cpu_to_virtio16(little_endian,
+   skb->csum_offset);
+   } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
+   hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
+   } /* else everything is zero */
+
+   return 0;
+}
+
+#endif /* _LINUX_VIRTIO_BYTEORDER */
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 5/6] virtio_net: use common code for virtio_net_hdr and skb GSO conversion

2016-06-08 Thread Mike Rapoport
Replace open coded conversion between virtio_net_hdr to skb GSO info with
virtio_net_hdr_{from,to}_skb

Signed-off-by: Mike Rapoport 
---
 drivers/net/virtio_net.c | 78 +++-
 1 file changed, 10 insertions(+), 68 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e0638e5..9af0a98 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -479,51 +479,19 @@ static void receive_buf(struct virtnet_info *vi, struct 
receive_queue *rq,
stats->rx_packets++;
u64_stats_update_end(&stats->rx_syncp);
 
-   if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
-   pr_debug("Needs csum!\n");
-   if (!skb_partial_csum_set(skb,
- virtio16_to_cpu(vi->vdev, hdr->hdr.csum_start),
- virtio16_to_cpu(vi->vdev, hdr->hdr.csum_offset)))
-   goto frame_err;
-   } else if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID) {
+   if (hdr->hdr.flags & VIRTIO_NET_HDR_F_DATA_VALID)
skb->ip_summed = CHECKSUM_UNNECESSARY;
-   }
 
skb->protocol = eth_type_trans(skb, dev);
pr_debug("Receiving skb proto 0x%04x len %i type %i\n",
 ntohs(skb->protocol), skb->len, skb->pkt_type);
 
-   if (hdr->hdr.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
-   pr_debug("GSO!\n");
-   switch (hdr->hdr.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
-   case VIRTIO_NET_HDR_GSO_TCPV4:
-   skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
-   break;
-   case VIRTIO_NET_HDR_GSO_UDP:
-   skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
-   break;
-   case VIRTIO_NET_HDR_GSO_TCPV6:
-   skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
-   break;
-   default:
-   net_warn_ratelimited("%s: bad gso type %u.\n",
-dev->name, hdr->hdr.gso_type);
-   goto frame_err;
-   }
-
-   if (hdr->hdr.gso_type & VIRTIO_NET_HDR_GSO_ECN)
-   skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
-
-   skb_shinfo(skb)->gso_size = virtio16_to_cpu(vi->vdev,
-   hdr->hdr.gso_size);
-   if (skb_shinfo(skb)->gso_size == 0) {
-   net_warn_ratelimited("%s: zero gso size.\n", dev->name);
-   goto frame_err;
-   }
-
-   /* Header must be checked, and gso_segs computed. */
-   skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
-   skb_shinfo(skb)->gso_segs = 0;
+   if (virtio_net_hdr_to_skb(skb, &hdr->hdr,
+ virtio_is_little_endian(vi->vdev))) {
+   net_warn_ratelimited("%s: bad gso: type: %u, size: %u\n",
+dev->name, hdr->hdr.gso_type,
+hdr->hdr.gso_size);
+   goto frame_err;
}
 
napi_gro_receive(&rq->napi, skb);
@@ -868,35 +836,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff 
*skb)
else
hdr = skb_vnet_hdr(skb);
 
-   if (skb->ip_summed == CHECKSUM_PARTIAL) {
-   hdr->hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-   hdr->hdr.csum_start = cpu_to_virtio16(vi->vdev,
-   skb_checksum_start_offset(skb));
-   hdr->hdr.csum_offset = cpu_to_virtio16(vi->vdev,
-skb->csum_offset);
-   } else {
-   hdr->hdr.flags = 0;
-   hdr->hdr.csum_offset = hdr->hdr.csum_start = 0;
-   }
-
-   if (skb_is_gso(skb)) {
-   hdr->hdr.hdr_len = cpu_to_virtio16(vi->vdev, skb_headlen(skb));
-   hdr->hdr.gso_size = cpu_to_virtio16(vi->vdev,
-   skb_shinfo(skb)->gso_size);
-   if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
-   hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
-   else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
-   hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-   else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
-   hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
-   else
-   BUG();
-   if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
-   hdr->hdr.gso_type |= VIRTI

[PATCH 3/6] macvtap: use common code for virtio_net_hdr and skb GSO conversion

2016-06-08 Thread Mike Rapoport
Replace open coded conversion between virtio_net_hdr to skb GSO info with
virtio_net_hdr_{from,to}_skb

Signed-off-by: Mike Rapoport 
---
 drivers/net/macvtap.c | 95 ---
 1 file changed, 6 insertions(+), 89 deletions(-)

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index bd67209..95a1332 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -627,93 +627,6 @@ static inline struct sk_buff *macvtap_alloc_skb(struct 
sock *sk, size_t prepad,
return skb;
 }
 
-/*
- * macvtap_skb_from_vnet_hdr and macvtap_skb_to_vnet_hdr should
- * be shared with the tun/tap driver.
- */
-static int macvtap_skb_from_vnet_hdr(struct macvtap_queue *q,
-struct sk_buff *skb,
-struct virtio_net_hdr *vnet_hdr)
-{
-   unsigned short gso_type = 0;
-   if (vnet_hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
-   switch (vnet_hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
-   case VIRTIO_NET_HDR_GSO_TCPV4:
-   gso_type = SKB_GSO_TCPV4;
-   break;
-   case VIRTIO_NET_HDR_GSO_TCPV6:
-   gso_type = SKB_GSO_TCPV6;
-   break;
-   case VIRTIO_NET_HDR_GSO_UDP:
-   gso_type = SKB_GSO_UDP;
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   if (vnet_hdr->gso_type & VIRTIO_NET_HDR_GSO_ECN)
-   gso_type |= SKB_GSO_TCP_ECN;
-
-   if (vnet_hdr->gso_size == 0)
-   return -EINVAL;
-   }
-
-   if (vnet_hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
-   if (!skb_partial_csum_set(skb, macvtap16_to_cpu(q, 
vnet_hdr->csum_start),
- macvtap16_to_cpu(q, 
vnet_hdr->csum_offset)))
-   return -EINVAL;
-   }
-
-   if (vnet_hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
-   skb_shinfo(skb)->gso_size = macvtap16_to_cpu(q, 
vnet_hdr->gso_size);
-   skb_shinfo(skb)->gso_type = gso_type;
-
-   /* Header must be checked, and gso_segs computed. */
-   skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
-   skb_shinfo(skb)->gso_segs = 0;
-   }
-   return 0;
-}
-
-static void macvtap_skb_to_vnet_hdr(struct macvtap_queue *q,
-   const struct sk_buff *skb,
-   struct virtio_net_hdr *vnet_hdr)
-{
-   memset(vnet_hdr, 0, sizeof(*vnet_hdr));
-
-   if (skb_is_gso(skb)) {
-   struct skb_shared_info *sinfo = skb_shinfo(skb);
-
-   /* This is a hint as to how much should be linear. */
-   vnet_hdr->hdr_len = cpu_to_macvtap16(q, skb_headlen(skb));
-   vnet_hdr->gso_size = cpu_to_macvtap16(q, sinfo->gso_size);
-   if (sinfo->gso_type & SKB_GSO_TCPV4)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
-   else if (sinfo->gso_type & SKB_GSO_TCPV6)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-   else if (sinfo->gso_type & SKB_GSO_UDP)
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
-   else
-   BUG();
-   if (sinfo->gso_type & SKB_GSO_TCP_ECN)
-   vnet_hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN;
-   } else
-   vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE;
-
-   if (skb->ip_summed == CHECKSUM_PARTIAL) {
-   vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-   if (skb_vlan_tag_present(skb))
-   vnet_hdr->csum_start = cpu_to_macvtap16(q,
-   skb_checksum_start_offset(skb) + VLAN_HLEN);
-   else
-   vnet_hdr->csum_start = cpu_to_macvtap16(q,
-   skb_checksum_start_offset(skb));
-   vnet_hdr->csum_offset = cpu_to_macvtap16(q, skb->csum_offset);
-   } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
-   vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
-   } /* else everything is zero */
-}
-
 /* Neighbour code has some assumptions on HH_DATA_MOD alignment */
 #define MACVTAP_RESERVE HH_DATA_OFF(ETH_HLEN)
 
@@ -812,7 +725,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, 
struct msghdr *m,
skb->protocol = eth_hdr(skb)->h_proto;
 
if (vnet_hdr_len) {
-   err = macvtap_skb_from_vnet_hdr(q, skb, &vnet_hdr);
+   err = virtio_net_hdr_to_skb(skb, &vnet_hdr,
+   macvtap_is_little_endian(q));
if (err)
go

[PATCH 1/6] virtio_net: add _UAPI prefix to virtio_net header guards

2016-06-08 Thread Mike Rapoport
This gives better namespacing and prevents conflicts with no-uapi version
of virtio_net header that will be introduced in the following patch.

Signed-off-by: Mike Rapoport 
---
 include/uapi/linux/virtio_net.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index ec32293..75cf581 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -1,5 +1,5 @@
-#ifndef _LINUX_VIRTIO_NET_H
-#define _LINUX_VIRTIO_NET_H
+#ifndef _UAPI_LINUX_VIRTIO_NET_H
+#define _UAPI_LINUX_VIRTIO_NET_H
 /* This header is BSD licensed so anyone can use the definitions to implement
  * compatible drivers/servers.
  *
@@ -242,4 +242,4 @@ struct virtio_net_ctrl_mq {
 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS   5
 #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET0
 
-#endif /* _LINUX_VIRTIO_NET_H */
+#endif /* _UAPI_LINUX_VIRTIO_NET_H */
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 0/6] virtio_net: use common code for virtio_net_hdr and skb GSO conversion

2016-06-08 Thread Mike Rapoport
Hi,

This patches introduce virtio_net_hdr_{from,to}_skb functions for
conversion of GSO information between skb and virtio_net_hdr.

Mike Rapoport (6):
  virtio_net: add _UAPI prefix to virtio_net header guards
  virtio_net: introduce virtio_net_hdr_{from,to}_skb
  macvtap: use common code for virtio_net_hdr and skb GSO conversion
  tuntap: use common code for virtio_net_hdr and skb GSO conversion
  virtio_net: use common code for virtio_net_hdr and skb GSO conversion
  packet: use common code for virtio_net_hdr and skb GSO conversion

 drivers/net/macvtap.c   |  95 +++--
 drivers/net/tun.c   |  97 +-
 drivers/net/virtio_net.c|  78 ---
 include/linux/virtio_net.h  | 101 
 include/uapi/linux/virtio_net.h |   6 +--
 net/packet/af_packet.c  |  36 +-
 6 files changed, 143 insertions(+), 270 deletions(-)
 create mode 100644 include/linux/virtio_net.h

-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] tools/virtio/ringtest: add usage example to README

2016-06-05 Thread Mike Rapoport
Ping?

On Tue, May 24, 2016 at 03:41:04PM +0300, Mike Rapoport wrote:
> Michael,
> 
> Any updates on this?
> 
> On Wed, May 04, 2016 at 09:12:55AM +0300, Mike Rapoport wrote:
> > Having typical usage example in the README file is more convinient than in
> > the git history...
> > 
> > Signed-off-by: Mike Rapoport 
> > ---
> >  tools/virtio/ringtest/README | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/tools/virtio/ringtest/README b/tools/virtio/ringtest/README
> > index 34e94c4..d83707a 100644
> > --- a/tools/virtio/ringtest/README
> > +++ b/tools/virtio/ringtest/README
> > @@ -1,2 +1,6 @@
> >  Partial implementation of various ring layouts, useful to tune virtio 
> > design.
> >  Uses shared memory heavily.
> > +
> > +Typical use:
> > +
> > +# sh run-on-all.sh perf stat -r 10 --log-fd 1 -- ./ring
> > -- 
> > 1.9.1
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v3] tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu

2016-06-05 Thread Mike Rapoport
Ping?

On Tue, May 24, 2016 at 03:41:33PM +0300, Mike Rapoport wrote:
> Michael,
> 
> Any updates on this?
> 
> On Wed, May 04, 2016 at 01:15:50PM +0300, Mike Rapoport wrote:
> > /dev/cpu is only available on x86 with certain modules (e.g. msr) enabled.
> > Using lscpu to get processors count is more portable.
> > 
> > Signed-off-by: Mike Rapoport 
> > ---
> > v3: simplify by using lscpu -p=cpu 
> > v2: use lspcu instead of /proc/cpuinfo as per Cornelia's suggestion
> > 
> >  tools/virtio/ringtest/run-on-all.sh | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/virtio/ringtest/run-on-all.sh 
> > b/tools/virtio/ringtest/run-on-all.sh
> > index 52b0f71..2e69ca8 100755
> > --- a/tools/virtio/ringtest/run-on-all.sh
> > +++ b/tools/virtio/ringtest/run-on-all.sh
> > @@ -3,10 +3,10 @@
> >  #use last CPU for host. Why not the first?
> >  #many devices tend to use cpu0 by default so
> >  #it tends to be busier
> > -HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
> > +HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
> > 
> >  #run command on all cpus
> > -for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
> > +for cpu in $(seq 0 $HOST_AFFINITY)
> >  do
> > #Don't run guest and host on same CPU
> > #It actually works ok if using signalling
> > -- 
> > 1.9.1
> > 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH] tools/virtio/ringtest: add usage example to README

2016-05-24 Thread Mike Rapoport
Michael,

Any updates on this?

On Wed, May 04, 2016 at 09:12:55AM +0300, Mike Rapoport wrote:
> Having typical usage example in the README file is more convinient than in
> the git history...
> 
> Signed-off-by: Mike Rapoport 
> ---
>  tools/virtio/ringtest/README | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/virtio/ringtest/README b/tools/virtio/ringtest/README
> index 34e94c4..d83707a 100644
> --- a/tools/virtio/ringtest/README
> +++ b/tools/virtio/ringtest/README
> @@ -1,2 +1,6 @@
>  Partial implementation of various ring layouts, useful to tune virtio design.
>  Uses shared memory heavily.
> +
> +Typical use:
> +
> +# sh run-on-all.sh perf stat -r 10 --log-fd 1 -- ./ring
> -- 
> 1.9.1
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v3] tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu

2016-05-24 Thread Mike Rapoport
Michael,

Any updates on this?

On Wed, May 04, 2016 at 01:15:50PM +0300, Mike Rapoport wrote:
> /dev/cpu is only available on x86 with certain modules (e.g. msr) enabled.
> Using lscpu to get processors count is more portable.
> 
> Signed-off-by: Mike Rapoport 
> ---
> v3: simplify by using lscpu -p=cpu 
> v2: use lspcu instead of /proc/cpuinfo as per Cornelia's suggestion
> 
>  tools/virtio/ringtest/run-on-all.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virtio/ringtest/run-on-all.sh 
> b/tools/virtio/ringtest/run-on-all.sh
> index 52b0f71..2e69ca8 100755
> --- a/tools/virtio/ringtest/run-on-all.sh
> +++ b/tools/virtio/ringtest/run-on-all.sh
> @@ -3,10 +3,10 @@
>  #use last CPU for host. Why not the first?
>  #many devices tend to use cpu0 by default so
>  #it tends to be busier
> -HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
> +HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
> 
>  #run command on all cpus
> -for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
> +for cpu in $(seq 0 $HOST_AFFINITY)
>  do
>   #Don't run guest and host on same CPU
>   #It actually works ok if using signalling
> -- 
> 1.9.1
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v3] tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu

2016-05-04 Thread Mike Rapoport
/dev/cpu is only available on x86 with certain modules (e.g. msr) enabled.
Using lscpu to get processors count is more portable.

Signed-off-by: Mike Rapoport 
---
v3: simplify by using lscpu -p=cpu 
v2: use lspcu instead of /proc/cpuinfo as per Cornelia's suggestion

 tools/virtio/ringtest/run-on-all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virtio/ringtest/run-on-all.sh 
b/tools/virtio/ringtest/run-on-all.sh
index 52b0f71..2e69ca8 100755
--- a/tools/virtio/ringtest/run-on-all.sh
+++ b/tools/virtio/ringtest/run-on-all.sh
@@ -3,10 +3,10 @@
 #use last CPU for host. Why not the first?
 #many devices tend to use cpu0 by default so
 #it tends to be busier
-HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
+HOST_AFFINITY=$(lscpu -p=cpu | tail -1)
 
 #run command on all cpus
-for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
+for cpu in $(seq 0 $HOST_AFFINITY)
 do
#Don't run guest and host on same CPU
#It actually works ok if using signalling
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH v2] tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu

2016-05-04 Thread Mike Rapoport
/dev/cpu is only available on x86 with certain modules (e.g. msr) enabled.
Using lscpu to get processors count is more portable.

Signed-off-by: Mike Rapoport 
---
v2: use lspcu instead of /proc/cpuinfo as per Cornelia's suggestion

 tools/virtio/ringtest/run-on-all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virtio/ringtest/run-on-all.sh 
b/tools/virtio/ringtest/run-on-all.sh
index 52b0f71..0177d50 100755
--- a/tools/virtio/ringtest/run-on-all.sh
+++ b/tools/virtio/ringtest/run-on-all.sh
@@ -3,10 +3,10 @@
 #use last CPU for host. Why not the first?
 #many devices tend to use cpu0 by default so
 #it tends to be busier
-HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
+HOST_AFFINITY=$(lscpu -p | tail -n 1 | cut -d',' -f1)
 
 #run command on all cpus
-for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
+for cpu in $(seq 0 $HOST_AFFINITY)
 do
#Don't run guest and host on same CPU
#It actually works ok if using signalling
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] tools/virtio/ringtest: fix run-on-all.sh to work without /dev/cpu

2016-05-04 Thread Mike Rapoport
/dev/cpu is only available on x86 with certain modules (e.g. msr) enabled.
Using /proc/cpuinfo to get processors count is more portable.

Signed-off-by: Mike Rapoport 
---
 tools/virtio/ringtest/run-on-all.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virtio/ringtest/run-on-all.sh 
b/tools/virtio/ringtest/run-on-all.sh
index 52b0f71..38ccfa3 100755
--- a/tools/virtio/ringtest/run-on-all.sh
+++ b/tools/virtio/ringtest/run-on-all.sh
@@ -3,10 +3,10 @@
 #use last CPU for host. Why not the first?
 #many devices tend to use cpu0 by default so
 #it tends to be busier
-HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
+HOST_AFFINITY=$(($(grep -c processor /proc/cpuinfo) - 1))
 
 #run command on all cpus
-for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
+for cpu in $(seq 0 $HOST_AFFINITY)
 do
#Don't run guest and host on same CPU
#It actually works ok if using signalling
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] tools/virtio/ringtest: add usage example to README

2016-05-04 Thread Mike Rapoport
Having typical usage example in the README file is more convinient than in
the git history...

Signed-off-by: Mike Rapoport 
---
 tools/virtio/ringtest/README | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/virtio/ringtest/README b/tools/virtio/ringtest/README
index 34e94c4..d83707a 100644
--- a/tools/virtio/ringtest/README
+++ b/tools/virtio/ringtest/README
@@ -1,2 +1,6 @@
 Partial implementation of various ring layouts, useful to tune virtio design.
 Uses shared memory heavily.
+
+Typical use:
+
+# sh run-on-all.sh perf stat -r 10 --log-fd 1 -- ./ring
-- 
1.9.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] virtio-gpu: fix compilation warnings

2015-09-02 Thread Mike Rapoport
Update snprintf format in virtgpu_fence.c and virtgpu_debugfs.c to fix the
following compilation warnings:

C [M]  drivers/gpu/drm/virtio/virtgpu_fence.o
drivers/gpu/drm/virtio/virtgpu_fence.c: In function ‘virtio_timeline_value_str’ 
:
drivers/gpu/drm/virtio/virtgpu_fence.c:64:2: warning: format ‘%lu’ expects 
argument of type ‘long unsigned int’, but argument 4 has type ‘long long int’ 
[-Wformat=]
  snprintf(str, size, "%lu", atomic64_read(&fence->drv->last_seq));
  ^
  CC [M]  drivers/gpu/drm/virtio/virtgpu_debugfs.o
drivers/gpu/drm/virtio/virtgpu_debugfs.c: In function 
‘virtio_gpu_debugfs_irq_info’:
drivers/gpu/drm/virtio/virtgpu_debugfs.c:39:6: warning: format ‘%ld’ expects 
argument of type ‘long int’, but argument 3 has type ‘long long int’ [-Wformat=]
  vgdev->fence_drv.sync_seq);
  ^

Signed-off-by: Mike Rapoport 
---
 drivers/gpu/drm/virtio/virtgpu_debugfs.c | 2 +-
 drivers/gpu/drm/virtio/virtgpu_fence.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_debugfs.c 
b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
index db8b491..d87b27c 100644
--- a/drivers/gpu/drm/virtio/virtgpu_debugfs.c
+++ b/drivers/gpu/drm/virtio/virtgpu_debugfs.c
@@ -34,7 +34,7 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
struct drm_info_node *node = (struct drm_info_node *) m->private;
struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
 
-   seq_printf(m, "fence %ld %lld\n",
+   seq_printf(m, "fence %lld %lld\n",
   atomic64_read(&vgdev->fence_drv.last_seq),
   vgdev->fence_drv.sync_seq);
return 0;
diff --git a/drivers/gpu/drm/virtio/virtgpu_fence.c 
b/drivers/gpu/drm/virtio/virtgpu_fence.c
index 1da6326..98dd385 100644
--- a/drivers/gpu/drm/virtio/virtgpu_fence.c
+++ b/drivers/gpu/drm/virtio/virtgpu_fence.c
@@ -61,7 +61,7 @@ static void virtio_timeline_value_str(struct fence *f, char 
*str, int size)
 {
struct virtio_gpu_fence *fence = to_virtio_fence(f);
 
-   snprintf(str, size, "%lu", atomic64_read(&fence->drv->last_seq));
+   snprintf(str, size, "%llu", atomic64_read(&fence->drv->last_seq));
 }
 
 static const struct fence_ops virtio_fence_ops = {
-- 
1.8.3.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization