linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets
@ 2015-03-01  4:33 Shrikrishna Khare
  2015-03-02  4:04 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Shrikrishna Khare @ 2015-03-01  4:33 UTC (permalink / raw)
  To: sbhatewara, pv-drivers, netdev, linux-kernel
  Cc: Shrikrishna Khare, Amitabha Banerjee

Allows for packet parsing to be done by the fast path. This performance
optimization already exists for IPv4. Add similar logic for IPv6.

Signed-off-by: Amitabha Banerjee <banerjeea@vmware.com>
Signed-off-by: Shrikrishna Khare <skhare@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 29 ++++++++++++++++++++---------
 drivers/net/vmxnet3/vmxnet3_int.h |  5 +++--
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 294214c..61c0840 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -819,6 +819,7 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 			   struct vmxnet3_adapter *adapter)
 {
 	struct Vmxnet3_TxDataDesc *tdd;
+	u8 protocol = 0;
 
 	if (ctx->mss) {	/* TSO */
 		ctx->eth_ip_hdr_size = skb_transport_offset(skb);
@@ -831,16 +832,25 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 			if (ctx->ipv4) {
 				const struct iphdr *iph = ip_hdr(skb);
 
-				if (iph->protocol == IPPROTO_TCP)
-					ctx->l4_hdr_size = tcp_hdrlen(skb);
-				else if (iph->protocol == IPPROTO_UDP)
-					ctx->l4_hdr_size = sizeof(struct udphdr);
-				else
-					ctx->l4_hdr_size = 0;
-			} else {
-				/* for simplicity, don't copy L4 headers */
+				protocol = iph->protocol;
+			} else if (ctx->ipv6) {
+				const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+
+				protocol = ipv6h->nexthdr;
+			}
+
+			switch (protocol) {
+			case IPPROTO_TCP:
+				ctx->l4_hdr_size = tcp_hdrlen(skb);
+				break;
+			case IPPROTO_UDP:
+				ctx->l4_hdr_size = sizeof(struct udphdr);
+				break;
+			default:
 				ctx->l4_hdr_size = 0;
+				break;
 			}
+
 			ctx->copy_size = min(ctx->eth_ip_hdr_size +
 					 ctx->l4_hdr_size, skb->len);
 		} else {
@@ -887,7 +897,7 @@ vmxnet3_prepare_tso(struct sk_buff *skb,
 		iph->check = 0;
 		tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
 						 IPPROTO_TCP, 0);
-	} else {
+	} else if (ctx->ipv6) {
 		struct ipv6hdr *iph = ipv6_hdr(skb);
 
 		tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
@@ -938,6 +948,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 	count = txd_estimate(skb);
 
 	ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP));
+	ctx.ipv6 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IPV6));
 
 	ctx.mss = skb_shinfo(skb)->gso_size;
 	if (ctx.mss) {
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index cd71c77..6bb769a 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.3.4.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.3.5.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01030400
+#define VMXNET3_DRIVER_VERSION_NUM      0x01030500
 
 #if defined(CONFIG_PCI_MSI)
 	/* RSS only makes sense if MSI-X is supported. */
@@ -211,6 +211,7 @@ struct vmxnet3_tq_driver_stats {
 
 struct vmxnet3_tx_ctx {
 	bool   ipv4;
+	bool   ipv6;
 	u16 mss;
 	u32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum
 				 * offloading
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets
  2015-03-01  4:33 [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets Shrikrishna Khare
@ 2015-03-02  4:04 ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-03-02  4:04 UTC (permalink / raw)
  To: skhare; +Cc: sbhatewara, pv-drivers, netdev, linux-kernel, banerjeea

From: Shrikrishna Khare <skhare@vmware.com>
Date: Sat, 28 Feb 2015 20:33:09 -0800

> Allows for packet parsing to be done by the fast path. This performance
> optimization already exists for IPv4. Add similar logic for IPv6.
> 
> Signed-off-by: Amitabha Banerjee <banerjeea@vmware.com>
> Signed-off-by: Shrikrishna Khare <skhare@vmware.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets
  2015-02-28 23:10 ` Sergei Shtylyov
@ 2015-03-01  3:16   ` Shrikrishna Khare
  0 siblings, 0 replies; 5+ messages in thread
From: Shrikrishna Khare @ 2015-03-01  3:16 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: sbhatewara, pv-drivers, netdev, linux-kernel, Amitabha Banerjee



On Sat, 28 Feb 2015, Sergei Shtylyov wrote:

> Hello.
> 
> On 02/28/2015 10:58 PM, Shrikrishna Khare wrote:
> 
> > Allows for packet parsing to be done by the fast path. This performance
> > optimization already exists for IPv4. Add similar logic for IPv6.
> 
> > Signed-off-by: Amitabha Banerjee <banerjeea@vmware.com>
> > Signed-off-by: Shrikrishna Khare <skhare@vmware.com>
> > ---
> >   drivers/net/vmxnet3/vmxnet3_drv.c | 26 ++++++++++++++++----------
> >   drivers/net/vmxnet3/vmxnet3_int.h |  5 +++--
> >   2 files changed, 19 insertions(+), 12 deletions(-)
> 
> > diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c
> > b/drivers/net/vmxnet3/vmxnet3_drv.c
> > index 294214c..9216e6a 100644
> > --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> > +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> [...]
> > @@ -831,16 +832,20 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct
> > vmxnet3_tx_queue *tq,
> >   			if (ctx->ipv4) {
> >   				const struct iphdr *iph = ip_hdr(skb);
> > 
> > -				if (iph->protocol == IPPROTO_TCP)
> > -					ctx->l4_hdr_size = tcp_hdrlen(skb);
> > -				else if (iph->protocol == IPPROTO_UDP)
> > -					ctx->l4_hdr_size = sizeof(struct
> > udphdr);
> > -				else
> > -					ctx->l4_hdr_size = 0;
> > -			} else {
> > -				/* for simplicity, don't copy L4 headers */
> > -				ctx->l4_hdr_size = 0;
> > +				protocol = iph->protocol;
> > +			} else if (ctx->ipv6) {
> > +				const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
> > +
> > +				protocol = ipv6h->nexthdr;
> >   			}
> > +
> > +			if (protocol == IPPROTO_TCP)
> > +				ctx->l4_hdr_size = tcp_hdrlen(skb);
> > +			else if (protocol == IPPROTO_UDP)
> > +				ctx->l4_hdr_size = sizeof(struct udphdr);
> > +			else
> > +				ctx->l4_hdr_size = 0;
> > +
> 
>    I think the above is asking to be a 'switch (protocol)' instead.
> 
> WBR, Sergei
> 
> 

Thanks for the review, Sergei. Would fix it, and resubmit the patch.

Thanks,
Shri

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets
  2015-02-28 19:58 Shrikrishna Khare
@ 2015-02-28 23:10 ` Sergei Shtylyov
  2015-03-01  3:16   ` Shrikrishna Khare
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2015-02-28 23:10 UTC (permalink / raw)
  To: Shrikrishna Khare, sbhatewara, pv-drivers, netdev, linux-kernel
  Cc: Amitabha Banerjee

Hello.

On 02/28/2015 10:58 PM, Shrikrishna Khare wrote:

> Allows for packet parsing to be done by the fast path. This performance
> optimization already exists for IPv4. Add similar logic for IPv6.

> Signed-off-by: Amitabha Banerjee <banerjeea@vmware.com>
> Signed-off-by: Shrikrishna Khare <skhare@vmware.com>
> ---
>   drivers/net/vmxnet3/vmxnet3_drv.c | 26 ++++++++++++++++----------
>   drivers/net/vmxnet3/vmxnet3_int.h |  5 +++--
>   2 files changed, 19 insertions(+), 12 deletions(-)

> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index 294214c..9216e6a 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
[...]
> @@ -831,16 +832,20 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
>   			if (ctx->ipv4) {
>   				const struct iphdr *iph = ip_hdr(skb);
>
> -				if (iph->protocol == IPPROTO_TCP)
> -					ctx->l4_hdr_size = tcp_hdrlen(skb);
> -				else if (iph->protocol == IPPROTO_UDP)
> -					ctx->l4_hdr_size = sizeof(struct udphdr);
> -				else
> -					ctx->l4_hdr_size = 0;
> -			} else {
> -				/* for simplicity, don't copy L4 headers */
> -				ctx->l4_hdr_size = 0;
> +				protocol = iph->protocol;
> +			} else if (ctx->ipv6) {
> +				const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
> +
> +				protocol = ipv6h->nexthdr;
>   			}
> +
> +			if (protocol == IPPROTO_TCP)
> +				ctx->l4_hdr_size = tcp_hdrlen(skb);
> +			else if (protocol == IPPROTO_UDP)
> +				ctx->l4_hdr_size = sizeof(struct udphdr);
> +			else
> +				ctx->l4_hdr_size = 0;
> +

    I think the above is asking to be a 'switch (protocol)' instead.

WBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets
@ 2015-02-28 19:58 Shrikrishna Khare
  2015-02-28 23:10 ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Shrikrishna Khare @ 2015-02-28 19:58 UTC (permalink / raw)
  To: sbhatewara, pv-drivers, netdev, linux-kernel
  Cc: Shrikrishna Khare, Amitabha Banerjee

Allows for packet parsing to be done by the fast path. This performance
optimization already exists for IPv4. Add similar logic for IPv6.

Signed-off-by: Amitabha Banerjee <banerjeea@vmware.com>
Signed-off-by: Shrikrishna Khare <skhare@vmware.com>
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 26 ++++++++++++++++----------
 drivers/net/vmxnet3/vmxnet3_int.h |  5 +++--
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 294214c..9216e6a 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -819,6 +819,7 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 			   struct vmxnet3_adapter *adapter)
 {
 	struct Vmxnet3_TxDataDesc *tdd;
+	u8 protocol = 0;
 
 	if (ctx->mss) {	/* TSO */
 		ctx->eth_ip_hdr_size = skb_transport_offset(skb);
@@ -831,16 +832,20 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 			if (ctx->ipv4) {
 				const struct iphdr *iph = ip_hdr(skb);
 
-				if (iph->protocol == IPPROTO_TCP)
-					ctx->l4_hdr_size = tcp_hdrlen(skb);
-				else if (iph->protocol == IPPROTO_UDP)
-					ctx->l4_hdr_size = sizeof(struct udphdr);
-				else
-					ctx->l4_hdr_size = 0;
-			} else {
-				/* for simplicity, don't copy L4 headers */
-				ctx->l4_hdr_size = 0;
+				protocol = iph->protocol;
+			} else if (ctx->ipv6) {
+				const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+
+				protocol = ipv6h->nexthdr;
 			}
+
+			if (protocol == IPPROTO_TCP)
+				ctx->l4_hdr_size = tcp_hdrlen(skb);
+			else if (protocol == IPPROTO_UDP)
+				ctx->l4_hdr_size = sizeof(struct udphdr);
+			else
+				ctx->l4_hdr_size = 0;
+
 			ctx->copy_size = min(ctx->eth_ip_hdr_size +
 					 ctx->l4_hdr_size, skb->len);
 		} else {
@@ -887,7 +892,7 @@ vmxnet3_prepare_tso(struct sk_buff *skb,
 		iph->check = 0;
 		tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
 						 IPPROTO_TCP, 0);
-	} else {
+	} else if (ctx->ipv6) {
 		struct ipv6hdr *iph = ipv6_hdr(skb);
 
 		tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
@@ -938,6 +943,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
 	count = txd_estimate(skb);
 
 	ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP));
+	ctx.ipv6 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IPV6));
 
 	ctx.mss = skb_shinfo(skb)->gso_size;
 	if (ctx.mss) {
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index cd71c77..6bb769a 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.3.4.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.3.5.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01030400
+#define VMXNET3_DRIVER_VERSION_NUM      0x01030500
 
 #if defined(CONFIG_PCI_MSI)
 	/* RSS only makes sense if MSI-X is supported. */
@@ -211,6 +211,7 @@ struct vmxnet3_tq_driver_stats {
 
 struct vmxnet3_tx_ctx {
 	bool   ipv4;
+	bool   ipv6;
 	u16 mss;
 	u32 eth_ip_hdr_size; /* only valid for pkts requesting tso or csum
 				 * offloading
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-02  4:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01  4:33 [PATCH net-next] Driver: Vmxnet3: Copy TCP header to mapped frame for IPv6 packets Shrikrishna Khare
2015-03-02  4:04 ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2015-02-28 19:58 Shrikrishna Khare
2015-02-28 23:10 ` Sergei Shtylyov
2015-03-01  3:16   ` Shrikrishna Khare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).