From nobody@FreeBSD.org  Wed Jul 10 10:35:59 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 99F0861C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jul 2013 10:35:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	by mx1.freebsd.org (Postfix) with ESMTP id 8D1151225
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jul 2013 10:35:59 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r6AAZwT0095917
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jul 2013 10:35:58 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r6AAZwST095906;
	Wed, 10 Jul 2013 10:35:58 GMT
	(envelope-from nobody)
Message-Id: <201307101035.r6AAZwST095906@oldred.freebsd.org>
Date: Wed, 10 Jul 2013 10:35:58 GMT
From: Meny Yossefi <menyy@mellanox.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Bad UDP checksum calc for fragmented packets
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         180430
>Category:       kern
>Synopsis:       [ofed] [patch] Bad UDP checksum calc for fragmented packets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jhb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 10 10:40:00 UTC 2013
>Closed-Date:    Wed Aug 07 18:02:03 UTC 2013
>Last-Modified:  Wed Aug 07 18:02:03 UTC 2013
>Originator:     Meny Yossefi
>Release:        9.1.0
>Organization:
Mellanox
>Environment:
FreeBSD r-sw-freebsd01.mtr.labs.mlnx 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
HW performs UDP checksum calculation and runs over the SW (tcp/ip stack) calculation.

In case of fragmented packets, HW calculation (For UDP csum) is wrong and packets get dropped on receiver side.

Solution: remove HW UDP csum calculation on fragmented packets.
>How-To-Repeat:
Send packets over MLNX interface with msg size larger than MTU.
>Fix:
HW will calculate UDP checksum only for un-fragmented packets.

Patch attached with submission follows:

--- ../clean_9.1.0/sys/ofed/drivers/net/mlx4/en_tx.c	2013-07-09 09:41:01.349506000 +0300
+++ ../9.1.0/sys/ofed/drivers/net/mlx4/en_tx.c	2013-07-09 10:56:18.910829000 +0300
@@ -780,8 +780,9 @@ retry:
 	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 						MLX4_WQE_CTRL_SOLICITED);
 	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
-		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
-							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
+		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
+		if ((mb->m_flags & M_FRAG) == 0)
+                        tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
 		priv->port_stats.tx_chksum_offload++;
 	}
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 10 10:59:03 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180430 

From: John Baldwin <jhb@freebsd.org>
To: bug-followup@freebsd.org,
 menyy@mellanox.com
Cc:  
Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragmented packets
Date: Fri, 19 Jul 2013 11:13:44 -0400

 Oops, my previous reply didn't make it to the PR itself.
 
 Is the problem that the hardware checksum overwrites arbitrary data in the 
 packet (at the location where the UDP header would be)?
 
 Also, I've looked at other drivers, and they all look at the CSUM_*
 flags to determine the right settings.  IP fragments will not have
 CSUM_UDP or CSUM_TCP set, so I think the more correct fix is this:
 
 Index: en_tx.c
 ===================================================================
 --- en_tx.c	(revision 253470)
 +++ en_tx.c	(working copy)
 @@ -780,8 +780,12 @@ retry:
  	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
  						MLX4_WQE_CTRL_SOLICITED);
  	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 -		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 -							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & CSUM_IP)
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP))
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
  		priv->port_stats.tx_chksum_offload++;
  	}
  
 
 -- 
 John Baldwin

From: Meny Yossefi <menyy@mellanox.com>
To: John Baldwin <jhb@freebsd.org>, "bug-followup@freebsd.org"
	<bug-followup@freebsd.org>
Cc:  
Subject: RE: kern/180430: [ofed] [patch] Bad UDP checksum calc for
 fragmented packets
Date: Mon, 22 Jul 2013 14:11:51 +0000

 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0C0DAMTLDAG01mtlcom_
 Content-Type: text/plain; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 Hi John,
 
 
 
 The problem is that the HW will only calculate csum for parts of the payloa=
 d, one fragment at a time,
 
 while the receiver side, in our case the tcp/ip stack, will expect to valid=
 ate the packet's payload as a whole.
 
 
 
 I agree with the change you offered, though one thing bothers me.
 
 This change will add two conditions to the send flow which will probably ha=
 ve an effect on performance.
 
 Maybe 'likely' can be useful here ?
 
 
 
 BTW, I'm not entirely sure, but I think the CSUM_IP flag is always set, so =
 maybe the first condition is not necessary.
 
 What do you think ?
 
 
 
 -Meny
 
 
 
 
 
 -----Original Message-----
 From: John Baldwin [mailto:jhb@freebsd.org]
 Sent: Friday, July 19, 2013 6:29 PM
 To: bug-followup@freebsd.org; Meny Yossefi
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets
 
 
 
 Oops, my previous reply didn't make it to the PR itself.
 
 
 
 Is the problem that the hardware checksum overwrites arbitrary data in the =
 packet (at the location where the UDP header would be)?
 
 
 
 Also, I've looked at other drivers, and they all look at the CSUM_* flags t=
 o determine the right settings.  IP fragments will not have CSUM_UDP or CSU=
 M_TCP set, so I think the more correct fix is this:
 
 
 
 Index: en_tx.c
 
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 
 --- en_tx.c           (revision 253470)
 
 +++ en_tx.c        (working copy)
 
 @@ -780,8 +780,12 @@ retry:
 
                tx_desc->ctrl.srcrb_flags =3D cpu_to_be32(MLX4_WQE_CTRL_CQ_U=
 PDATE |
 
                                                                            =
                     MLX4_WQE_CTRL_SOLICITED);
 
                if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 
 -                              tx_desc->ctrl.srcrb_flags |=3D cpu_to_be32(M=
 LX4_WQE_CTRL_IP_CSUM |
 
 -                                                                          =
                                     MLX4_WQE_CTRL_TCP_UDP_CSUM);
 
 +                             if (mb->m_pkthdr.csum_flags & CSUM_IP)
 
 +                                             tx_desc->ctrl.srcrb_flags |=
 =3D
 
 +                                                 cpu_to_be32(MLX4_WQE_CTRL=
 _IP_CSUM);
 
 +                             if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_=
 UDP))
 
 +                                             tx_desc->ctrl.srcrb_flags |=
 =3D
 
 +                                                 cpu_to_be32(MLX4_WQE_CTRL=
 _TCP_UDP_CSUM);
 
                                priv->port_stats.tx_chksum_offload++;
 
                }
 
 
 
 --
 
 John Baldwin
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0C0DAMTLDAG01mtlcom_
 Content-Type: text/html; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
 osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
 xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
 //www.w3.org/TR/REC-html40">
 <head>
 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
 >
 <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
 <style><!--
 /* Font Definitions */
 @font-face
 	{font-family:"Cambria Math";
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 @font-face
 	{font-family:Calibri;
 	panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 	{margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 a:link, span.MsoHyperlink
 	{mso-style-priority:99;
 	color:blue;
 	text-decoration:underline;}
 a:visited, span.MsoHyperlinkFollowed
 	{mso-style-priority:99;
 	color:purple;
 	text-decoration:underline;}
 p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
 	{mso-style-priority:99;
 	mso-style-link:"Plain Text Char";
 	margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 span.PlainTextChar
 	{mso-style-name:"Plain Text Char";
 	mso-style-priority:99;
 	mso-style-link:"Plain Text";
 	font-family:"Calibri","sans-serif";}
 .MsoChpDefault
 	{mso-style-type:export-only;
 	font-family:"Calibri","sans-serif";}
 @page WordSection1
 	{size:8.5in 11.0in;
 	margin:1.0in 1.0in 1.0in 1.0in;}
 div.WordSection1
 	{page:WordSection1;}
 --></style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
 </xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
 <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
 </head>
 <body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
 <div class=3D"WordSection1">
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Hi John, <o:p></o:p=
 ></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">The problem is that=
  the HW will only calculate csum for parts of the payload, one fragment at =
 a time,
 <o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">while the receiver =
 side, in our case the tcp/ip stack, will expect to validate the packet&#821=
 7;s payload as a whole.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">I agree with the ch=
 ange you offered, though one thing bothers me.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">This change will ad=
 d two conditions to the send flow which will probably have an effect on per=
 formance.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Maybe &#8216;likely=
 &#8217; can be useful here ?<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">BTW, I&#8217;m not =
 entirely sure, but I think the CSUM_IP flag is always set, so maybe the fir=
 st condition is not necessary.
 <o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">What do you think ?=
 <o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">-Meny <o:p></o:p></=
 span></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">-----Original Message-----<br>
 From: John Baldwin [mailto:jhb@freebsd.org] <br>
 Sent: Friday, July 19, 2013 6:29 PM<br>
 To: bug-followup@freebsd.org; Meny Yossefi<br>
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets</p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Oops, my previous reply didn't make it to the PR =
 itself.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Is the problem that the hardware checksum overwri=
 tes arbitrary data in the packet (at the location where the UDP header woul=
 d be)?<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Also, I've looked at other drivers, and they all =
 look at the CSUM_* flags to determine the right settings.&nbsp; IP fragment=
 s will not have CSUM_UDP or CSUM_TCP set, so I think the more correct fix i=
 s this:<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Index: en_tx.c<o:p></o:p></p>
 <p class=3D"MsoPlainText">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D<o:p></o:p></p>
 <p class=3D"MsoPlainText">--- en_tx.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp; (revision 253470)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&#43;&#43; en_tx.c&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp; (working copy)<o:p></o:p></p>
 <p class=3D"MsoPlainText">@@ -780,8 &#43;780,12 @@ retry:<o:p></o:p></p>
 <p class=3D"MsoPlainText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.srcrb_flags =3D cpu_to=
 _be32(MLX4_WQE_CTRL_CQ_UPDATE |<o:p></o:p></p>
 <p class=3D"MsoPlainText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MLX4_WQE_=
 CTRL_SOLICITED);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mb-&gt;m_pkthdr.csum_flags &amp; (C=
 SUM_IP|CSUM_TCP|CSUM_UDP)) {<o:p></o:p></p>
 <p class=3D"MsoPlainText">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.srcrb_=
 flags |=3D cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |<o:p></o:p></p>
 <p class=3D"MsoPlainText">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp; MLX4_WQE_CTRL_TCP_UDP_CSUM);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mb-&gt;m_pkthdr.csum_=
 flags &amp; CSUM_IP)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_d=
 esc-&gt;ctrl.srcrb_flags |=3D<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbs=
 p;&nbsp;&nbsp; cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mb-&gt;m_pkthdr.csum_=
 flags &amp; (CSUM_TCP|CSUM_UDP))<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_d=
 esc-&gt;ctrl.srcrb_flags |=3D<o:p></o:p></p>
 <p class=3D"MsoPlainText">&#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbs=
 p;&nbsp;&nbsp; cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; priv-&gt;port_stat=
 s.tx_chksum_offload&#43;&#43;;<o:p></o:p></p>
 <p class=3D"MsoPlainText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">--<o:p></o:p></p>
 <p class=3D"MsoPlainText">John Baldwin<o:p></o:p></p>
 </div>
 </body>
 </html>
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0C0DAMTLDAG01mtlcom_--

From: John Baldwin <jhb@freebsd.org>
To: Meny Yossefi <menyy@mellanox.com>
Cc: "bug-followup@freebsd.org" <bug-followup@freebsd.org>
Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragmented packets
Date: Mon, 22 Jul 2013 11:40:08 -0400

 On Monday, July 22, 2013 10:11:51 am Meny Yossefi wrote:
 > Hi John,
 > 
 > 
 > 
 > The problem is that the HW will only calculate csum for parts of the payload, one fragment at a time,
 > 
 > while the receiver side, in our case the tcp/ip stack, will expect to validate the packet's payload as a whole.
 
 Ok.
 
 > I agree with the change you offered, though one thing bothers me.
 > 
 > This change will add two conditions to the send flow which will probably have an effect on performance.
 > 
 > Maybe 'likely' can be useful here ?
 
 FreeBSD tends to not use likely/unlikely unless there is a demonstrable gain
 via benchmark measurements.  However, if the OFED code regularly uses it and
 you feel this is a case where you would normally use it, it can be added.
 
 > BTW, I'm not entirely sure, but I think the CSUM_IP flag is always set, so maybe the first condition is not necessary.
 > 
 > What do you think ?
 
 If the user uses ifconfig to disable checksum offload and force software
 checksums the flag will not be set.
 
 > -Meny
 > 
 > 
 > 
 > 
 > 
 > -----Original Message-----
 > From: John Baldwin [mailto:jhb@freebsd.org]
 > Sent: Friday, July 19, 2013 6:29 PM
 > To: bug-followup@freebsd.org; Meny Yossefi
 > Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragmented packets
 > 
 > 
 > 
 > Oops, my previous reply didn't make it to the PR itself.
 > 
 > 
 > 
 > Is the problem that the hardware checksum overwrites arbitrary data in the packet (at the location where the UDP header would be)?
 > 
 > 
 > 
 > Also, I've looked at other drivers, and they all look at the CSUM_* flags to determine the right settings.  IP fragments will not have CSUM_UDP or 
 CSUM_TCP set, so I think the more correct fix is this:
 > 
 > 
 > 
 > Index: en_tx.c
 > 
 > ===================================================================
 > 
 > --- en_tx.c           (revision 253470)
 > 
 > +++ en_tx.c        (working copy)
 > 
 > @@ -780,8 +780,12 @@ retry:
 > 
 >                tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 > 
 >                                                                                                MLX4_WQE_CTRL_SOLICITED);
 > 
 >                if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 > 
 > -                              tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 > 
 > -                                                                                                              MLX4_WQE_CTRL_TCP_UDP_CSUM);
 > 
 > +                             if (mb->m_pkthdr.csum_flags & CSUM_IP)
 > 
 > +                                             tx_desc->ctrl.srcrb_flags |=
 > 
 > +                                                 cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 > 
 > +                             if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP))
 > 
 > +                                             tx_desc->ctrl.srcrb_flags |=
 > 
 > +                                                 cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
 > 
 >                                priv->port_stats.tx_chksum_offload++;
 > 
 >                }
 > 
 > 
 > 
 > --
 > 
 > John Baldwin
 > 
 
 -- 
 John Baldwin

From: Meny Yossefi <menyy@mellanox.com>
To: John Baldwin <jhb@freebsd.org>
Cc: "bug-followup@freebsd.org" <bug-followup@freebsd.org>
Subject: RE: kern/180430: [ofed] [patch] Bad UDP checksum calc for
 fragmented packets
Date: Tue, 23 Jul 2013 14:01:23 +0000

 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0D893MTLDAG01mtlcom_
 Content-Type: text/plain; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 Let's stick with the FreeBSD standards (without the likely/unlikely)
 
 
 
 Let me just double check the CSUM flags work as expected.
 
 I'll get back to you as soon as I'm done.
 
 
 
 -Meny
 
 
 
 
 
 -----Original Message-----
 From: John Baldwin [mailto:jhb@freebsd.org]
 Sent: Monday, July 22, 2013 7:04 PM
 To: Meny Yossefi
 Cc: bug-followup@freebsd.org
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets
 
 
 
 On Monday, July 22, 2013 10:11:51 am Meny Yossefi wrote:
 
 > Hi John,
 
 >
 
 >
 
 >
 
 > The problem is that the HW will only calculate csum for parts of the
 
 > payload, one fragment at a time,
 
 >
 
 > while the receiver side, in our case the tcp/ip stack, will expect to val=
 idate the packet's payload as a whole.
 
 
 
 Ok.
 
 
 
 > I agree with the change you offered, though one thing bothers me.
 
 >
 
 > This change will add two conditions to the send flow which will probably =
 have an effect on performance.
 
 >
 
 > Maybe 'likely' can be useful here ?
 
 
 
 FreeBSD tends to not use likely/unlikely unless there is a demonstrable gai=
 n via benchmark measurements.  However, if the OFED code regularly uses it =
 and you feel this is a case where you would normally use it, it can be adde=
 d.
 
 
 
 > BTW, I'm not entirely sure, but I think the CSUM_IP flag is always set, s=
 o maybe the first condition is not necessary.
 
 >
 
 > What do you think ?
 
 
 
 If the user uses ifconfig to disable checksum offload and force software ch=
 ecksums the flag will not be set.
 
 
 
 > -Meny
 
 >
 
 >
 
 >
 
 >
 
 >
 
 > -----Original Message-----
 
 > From: John Baldwin [mailto:jhb@freebsd.org]
 
 > Sent: Friday, July 19, 2013 6:29 PM
 
 > To: bug-followup@freebsd.org<mailto:bug-followup@freebsd.org>; Meny Yosse=
 fi
 
 > Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for
 
 > fragmented packets
 
 >
 
 >
 
 >
 
 > Oops, my previous reply didn't make it to the PR itself.
 
 >
 
 >
 
 >
 
 > Is the problem that the hardware checksum overwrites arbitrary data in th=
 e packet (at the location where the UDP header would be)?
 
 >
 
 >
 
 >
 
 > Also, I've looked at other drivers, and they all look at the CSUM_*
 
 > flags to determine the right settings.  IP fragments will not have
 
 > CSUM_UDP or
 
 CSUM_TCP set, so I think the more correct fix is this:
 
 >
 
 >
 
 >
 
 > Index: en_tx.c
 
 >
 
 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 
 >
 
 > --- en_tx.c           (revision 253470)
 
 >
 
 > +++ en_tx.c        (working copy)
 
 >
 
 > @@ -780,8 +780,12 @@ retry:
 
 >
 
 >                tx_desc->ctrl.srcrb_flags =3D
 
 > cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 
 >
 
 >
 
 > MLX4_WQE_CTRL_SOLICITED);
 
 >
 
 >                if (mb->m_pkthdr.csum_flags &
 
 > (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 
 >
 
 > -                              tx_desc->ctrl.srcrb_flags |=3D cpu_to_be32=
 (MLX4_WQE_CTRL_IP_CSUM |
 
 >
 
 > -                                                                        =
                                       MLX4_WQE_CTRL_TCP_UDP_CSUM);
 
 >
 
 > +                             if (mb->m_pkthdr.csum_flags & CSUM_IP)
 
 >
 
 > +
 
 > + tx_desc->ctrl.srcrb_flags |=3D
 
 >
 
 > +
 
 > + cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 
 >
 
 > +                             if (mb->m_pkthdr.csum_flags &
 
 > + (CSUM_TCP|CSUM_UDP))
 
 >
 
 > +
 
 > + tx_desc->ctrl.srcrb_flags |=3D
 
 >
 
 > +
 
 > + cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
 
 >
 
 >                                priv->port_stats.tx_chksum_offload++;
 
 >
 
 >                }
 
 >
 
 >
 
 >
 
 > --
 
 >
 
 > John Baldwin
 
 >
 
 
 
 --
 
 John Baldwin
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0D893MTLDAG01mtlcom_
 Content-Type: text/html; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
 osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
 xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
 //www.w3.org/TR/REC-html40">
 <head>
 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
 >
 <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
 <style><!--
 /* Font Definitions */
 @font-face
 	{font-family:"Cambria Math";
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 @font-face
 	{font-family:Calibri;
 	panose-1:2 15 5 2 2 2 4 3 2 4;}
 @font-face
 	{font-family:Tahoma;
 	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 	{margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 a:link, span.MsoHyperlink
 	{mso-style-priority:99;
 	color:blue;
 	text-decoration:underline;}
 a:visited, span.MsoHyperlinkFollowed
 	{mso-style-priority:99;
 	color:purple;
 	text-decoration:underline;}
 p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
 	{mso-style-priority:99;
 	mso-style-link:"Plain Text Char";
 	margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 	{mso-style-priority:99;
 	mso-style-link:"Balloon Text Char";
 	margin:0in;
 	margin-bottom:.0001pt;
 	font-size:8.0pt;
 	font-family:"Tahoma","sans-serif";}
 span.PlainTextChar
 	{mso-style-name:"Plain Text Char";
 	mso-style-priority:99;
 	mso-style-link:"Plain Text";
 	font-family:"Calibri","sans-serif";}
 span.BalloonTextChar
 	{mso-style-name:"Balloon Text Char";
 	mso-style-priority:99;
 	mso-style-link:"Balloon Text";
 	font-family:"Tahoma","sans-serif";}
 .MsoChpDefault
 	{mso-style-type:export-only;
 	font-family:"Calibri","sans-serif";}
 @page WordSection1
 	{size:8.5in 11.0in;
 	margin:1.0in 1.0in 1.0in 1.0in;}
 div.WordSection1
 	{page:WordSection1;}
 --></style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
 </xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
 <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
 </head>
 <body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
 <div class=3D"WordSection1">
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Let's stick with th=
 e FreeBSD standards (without the likely/unlikely)<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Let me just double =
 check the CSUM flags work as expected.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">I&#8217;ll get back=
  to you as soon as I&#8217;m done.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">-Meny <o:p></o:p></=
 span></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">-----Original Message-----<br>
 From: John Baldwin [mailto:jhb@freebsd.org] <br>
 Sent: Monday, July 22, 2013 7:04 PM<br>
 To: Meny Yossefi<br>
 Cc: bug-followup@freebsd.org<br>
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets</p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">On Monday, July 22, 2013 10:11:51 am Meny Yossefi=
  wrote:<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Hi John,<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; The problem is that the HW will only calcula=
 te csum for parts of the
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; payload, one fragment at a time,<o:p></o:p><=
 /p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; while the receiver side, in our case the tcp=
 /ip stack, will expect to validate the packet's payload as a whole.<o:p></o=
 :p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Ok.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; I agree with the change you offered, though =
 one thing bothers me.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; This change will add two conditions to the s=
 end flow which will probably have an effect on performance.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Maybe 'likely' can be useful here ?<o:p></o:=
 p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">FreeBSD tends to not use likely/unlikely unless t=
 here is a demonstrable gain via benchmark measurements.&nbsp; However, if t=
 he OFED code regularly uses it and you feel this is a case where you would =
 normally use it, it can be added.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; BTW, I'm not entirely sure, but I think the =
 CSUM_IP flag is always set, so maybe the first condition is not necessary.<=
 o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; What do you think ?<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">If the user uses ifconfig to disable checksum off=
 load and force software checksums the flag will not be set.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; -Meny<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -----Original Message-----<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; From: John Baldwin [<a href=3D"mailto:jhb@fr=
 eebsd.org"><span style=3D"color:windowtext;text-decoration:none">mailto:jhb=
 @freebsd.org</span></a>]<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Sent: Friday, July 19, 2013 6:29 PM<o:p></o:=
 p></p>
 <p class=3D"MsoPlainText">&gt; To: <a href=3D"mailto:bug-followup@freebsd.o=
 rg"><span style=3D"color:windowtext;text-decoration:none">bug-followup@free=
 bsd.org</span></a>; Meny Yossefi<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Subject: Re: kern/180430: [ofed] [patch] Bad=
  UDP checksum calc for
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; fragmented packets<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Oops, my previous reply didn't make it to th=
 e PR itself.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Is the problem that the hardware checksum ov=
 erwrites arbitrary data in the packet (at the location where the UDP header=
  would be)?<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Also, I've looked at other drivers, and they=
  all look at the CSUM_*
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; flags to determine the right settings.&nbsp;=
  IP fragments will not have
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; CSUM_UDP or<o:p></o:p></p>
 <p class=3D"MsoPlainText">CSUM_TCP set, so I think the more correct fix is =
 this:<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Index: en_tx.c<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; --- en_tx.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp; (revision 253470)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&#43;&#43; en_tx.c&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp; (working copy)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; @@ -780,8 &#43;780,12 @@ retry:<o:p></o:p></=
 p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.srcrb_flags =
 =3D <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |<o:p></=
 o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; MLX4_WQE_CTRL_SOLICITED);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mb-&gt;m_pkthdr.csum_flag=
 s &amp; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; (CSUM_IP|CSUM_TCP|CSUM_UDP)) {<o:p></o:p></p=
 >
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.s=
 rcrb_flags |=3D cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp; MLX4_WQE_CTRL_TCP_UDP_CSUM);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mb-&gt;m_pkthdr.=
 csum_flags &amp; CSUM_IP)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
  <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; tx_desc-&gt;ctrl.srcrb_flags |=3D<o:p>=
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp; <o:p>
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);<o:=
 p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mb-&gt;m_pkthdr.=
 csum_flags &amp;
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; (CSUM_TCP|CSUM_UDP))<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
  <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; tx_desc-&gt;ctrl.srcrb_flags |=3D<o:p>=
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp; <o:p>
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM=
 );<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; priv-&gt=
 ;port_stats.tx_chksum_offload&#43;&#43;;<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; --<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; John Baldwin<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">--<o:p></o:p></p>
 <p class=3D"MsoPlainText">John Baldwin<o:p></o:p></p>
 </div>
 </body>
 </html>
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0D893MTLDAG01mtlcom_--

From: Meny Yossefi <menyy@mellanox.com>
To: John Baldwin <jhb@freebsd.org>
Cc: "bug-followup@freebsd.org" <bug-followup@freebsd.org>
Subject: RE: kern/180430: [ofed] [patch] Bad UDP checksum calc for
 fragmented packets
Date: Wed, 24 Jul 2013 13:14:53 +0000

 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0EC13MTLDAG01mtlcom_
 Content-Type: text/plain; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 Hi John,
 
 Looks good.
 
 -Meny
 
 From: Meny Yossefi
 Sent: Tuesday, July 23, 2013 5:01 PM
 To: 'John Baldwin'
 Cc: 'bug-followup@freebsd.org'
 Subject: RE: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets
 
 
 Let's stick with the FreeBSD standards (without the likely/unlikely)
 
 
 
 Let me just double check the CSUM flags work as expected.
 
 I'll get back to you as soon as I'm done.
 
 
 
 -Meny
 
 
 
 
 
 -----Original Message-----
 From: John Baldwin [mailto:jhb@freebsd.org]
 Sent: Monday, July 22, 2013 7:04 PM
 To: Meny Yossefi
 Cc: bug-followup@freebsd.org<mailto:bug-followup@freebsd.org>
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets
 
 
 
 On Monday, July 22, 2013 10:11:51 am Meny Yossefi wrote:
 
 > Hi John,
 
 >
 
 >
 
 >
 
 > The problem is that the HW will only calculate csum for parts of the
 
 > payload, one fragment at a time,
 
 >
 
 > while the receiver side, in our case the tcp/ip stack, will expect to val=
 idate the packet's payload as a whole.
 
 
 
 Ok.
 
 
 
 > I agree with the change you offered, though one thing bothers me.
 
 >
 
 > This change will add two conditions to the send flow which will probably =
 have an effect on performance.
 
 >
 
 > Maybe 'likely' can be useful here ?
 
 
 
 FreeBSD tends to not use likely/unlikely unless there is a demonstrable gai=
 n via benchmark measurements.  However, if the OFED code regularly uses it =
 and you feel this is a case where you would normally use it, it can be adde=
 d.
 
 
 
 > BTW, I'm not entirely sure, but I think the CSUM_IP flag is always set, s=
 o maybe the first condition is not necessary.
 
 >
 
 > What do you think ?
 
 
 
 If the user uses ifconfig to disable checksum offload and force software ch=
 ecksums the flag will not be set.
 
 
 
 > -Meny
 
 >
 
 >
 
 >
 
 >
 
 >
 
 > -----Original Message-----
 
 > From: John Baldwin [mailto:jhb@freebsd.org]
 
 > Sent: Friday, July 19, 2013 6:29 PM
 
 > To: bug-followup@freebsd.org<mailto:bug-followup@freebsd.org>; Meny Yosse=
 fi
 
 > Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for
 
 > fragmented packets
 
 >
 
 >
 
 >
 
 > Oops, my previous reply didn't make it to the PR itself.
 
 >
 
 >
 
 >
 
 > Is the problem that the hardware checksum overwrites arbitrary data in th=
 e packet (at the location where the UDP header would be)?
 
 >
 
 >
 
 >
 
 > Also, I've looked at other drivers, and they all look at the CSUM_*
 
 > flags to determine the right settings.  IP fragments will not have
 
 > CSUM_UDP or
 
 CSUM_TCP set, so I think the more correct fix is this:
 
 >
 
 >
 
 >
 
 > Index: en_tx.c
 
 >
 
 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 
 >
 
 > --- en_tx.c           (revision 253470)
 
 >
 
 > +++ en_tx.c        (working copy)
 
 >
 
 > @@ -780,8 +780,12 @@ retry:
 
 >
 
 >                tx_desc->ctrl.srcrb_flags =3D
 
 > cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
 
 >
 
 >
 
 > MLX4_WQE_CTRL_SOLICITED);
 
 >
 
 >                if (mb->m_pkthdr.csum_flags &
 
 > (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 
 >
 
 > -                              tx_desc->ctrl.srcrb_flags |=3D cpu_to_be32=
 (MLX4_WQE_CTRL_IP_CSUM |
 
 >
 
 > -                                                                        =
                                       MLX4_WQE_CTRL_TCP_UDP_CSUM);
 
 >
 
 > +                             if (mb->m_pkthdr.csum_flags & CSUM_IP)
 
 >
 
 > +
 
 > + tx_desc->ctrl.srcrb_flags |=3D
 
 >
 
 > +
 
 > + cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 
 >
 
 > +                             if (mb->m_pkthdr.csum_flags &
 
 > + (CSUM_TCP|CSUM_UDP))
 
 >
 
 > +
 
 > + tx_desc->ctrl.srcrb_flags |=3D
 
 >
 
 > +
 
 > + cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
 
 >
 
 >                                priv->port_stats.tx_chksum_offload++;
 
 >
 
 >                }
 
 >
 
 >
 
 >
 
 > --
 
 >
 
 > John Baldwin
 
 >
 
 
 
 --
 
 John Baldwin
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0EC13MTLDAG01mtlcom_
 Content-Type: text/html; charset="us-ascii"
 Content-Transfer-Encoding: quoted-printable
 
 <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
 osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
 xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
 //www.w3.org/TR/REC-html40">
 <head>
 <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
 >
 <meta name=3D"Generator" content=3D"Microsoft Word 14 (filtered medium)">
 <style><!--
 /* Font Definitions */
 @font-face
 	{font-family:"Cambria Math";
 	panose-1:2 4 5 3 5 4 6 3 2 4;}
 @font-face
 	{font-family:Calibri;
 	panose-1:2 15 5 2 2 2 4 3 2 4;}
 @font-face
 	{font-family:Tahoma;
 	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
 	{margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 a:link, span.MsoHyperlink
 	{mso-style-priority:99;
 	color:blue;
 	text-decoration:underline;}
 a:visited, span.MsoHyperlinkFollowed
 	{mso-style-priority:99;
 	color:purple;
 	text-decoration:underline;}
 p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
 	{mso-style-priority:99;
 	mso-style-link:"Plain Text Char";
 	margin:0in;
 	margin-bottom:.0001pt;
 	font-size:11.0pt;
 	font-family:"Calibri","sans-serif";}
 p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
 	{mso-style-priority:99;
 	mso-style-link:"Balloon Text Char";
 	margin:0in;
 	margin-bottom:.0001pt;
 	font-size:8.0pt;
 	font-family:"Tahoma","sans-serif";}
 span.PlainTextChar
 	{mso-style-name:"Plain Text Char";
 	mso-style-priority:99;
 	mso-style-link:"Plain Text";
 	font-family:"Calibri","sans-serif";}
 span.BalloonTextChar
 	{mso-style-name:"Balloon Text Char";
 	mso-style-priority:99;
 	mso-style-link:"Balloon Text";
 	font-family:"Tahoma","sans-serif";}
 span.EmailStyle21
 	{mso-style-type:personal-reply;
 	font-family:"Calibri","sans-serif";
 	color:#1F497D;}
 .MsoChpDefault
 	{mso-style-type:export-only;
 	font-size:10.0pt;}
 @page WordSection1
 	{size:8.5in 11.0in;
 	margin:1.0in 1.0in 1.0in 1.0in;}
 div.WordSection1
 	{page:WordSection1;}
 --></style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
 </xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
 <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
 </head>
 <body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
 <div class=3D"WordSection1">
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D">Hi John, <o:p></o:p></=
 span></p>
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></spa=
 n></p>
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D">Looks good. <o:p></o:p=
 ></span></p>
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></spa=
 n></p>
 <div>
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D">-Meny <o:p></o:p></spa=
 n></p>
 </div>
 <p class=3D"MsoNormal"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></spa=
 n></p>
 <div>
 <div style=3D"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in =
 0in 0in">
 <p class=3D"MsoNormal"><b><span style=3D"font-size:10.0pt;font-family:&quot=
 ;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style=3D"font-s=
 ize:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Meny Yos=
 sefi
 <br>
 <b>Sent:</b> Tuesday, July 23, 2013 5:01 PM<br>
 <b>To:</b> 'John Baldwin'<br>
 <b>Cc:</b> 'bug-followup@freebsd.org'<br>
 <b>Subject:</b> RE: kern/180430: [ofed] [patch] Bad UDP checksum calc for f=
 ragmented packets<o:p></o:p></span></p>
 </div>
 </div>
 <p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Let's stick with th=
 e FreeBSD standards (without the likely/unlikely)<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">Let me just double =
 check the CSUM flags work as expected.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">I&#8217;ll get back=
  to you as soon as I&#8217;m done.<o:p></o:p></span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D"><o:p>&nbsp;</o:p></=
 span></p>
 <p class=3D"MsoPlainText"><span style=3D"color:#1F497D">-Meny <o:p></o:p></=
 span></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">-----Original Message-----<br>
 From: John Baldwin [<a href=3D"mailto:jhb@freebsd.org">mailto:jhb@freebsd.o=
 rg</a>] <br>
 Sent: Monday, July 22, 2013 7:04 PM<br>
 To: Meny Yossefi<br>
 Cc: <a href=3D"mailto:bug-followup@freebsd.org">bug-followup@freebsd.org</a=
 ><br>
 Subject: Re: kern/180430: [ofed] [patch] Bad UDP checksum calc for fragment=
 ed packets<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">On Monday, July 22, 2013 10:11:51 am Meny Yossefi=
  wrote:<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Hi John,<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; The problem is that the HW will only calcula=
 te csum for parts of the
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; payload, one fragment at a time,<o:p></o:p><=
 /p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; while the receiver side, in our case the tcp=
 /ip stack, will expect to validate the packet's payload as a whole.<o:p></o=
 :p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">Ok.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; I agree with the change you offered, though =
 one thing bothers me.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; This change will add two conditions to the s=
 end flow which will probably have an effect on performance.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Maybe 'likely' can be useful here ?<o:p></o:=
 p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">FreeBSD tends to not use likely/unlikely unless t=
 here is a demonstrable gain via benchmark measurements.&nbsp; However, if t=
 he OFED code regularly uses it and you feel this is a case where you would =
 normally use it, it can be added.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; BTW, I'm not entirely sure, but I think the =
 CSUM_IP flag is always set, so maybe the first condition is not necessary.<=
 o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; What do you think ?<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">If the user uses ifconfig to disable checksum off=
 load and force software checksums the flag will not be set.<o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">&gt; -Meny<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -----Original Message-----<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; From: John Baldwin [<a href=3D"mailto:jhb@fr=
 eebsd.org"><span style=3D"color:windowtext;text-decoration:none">mailto:jhb=
 @freebsd.org</span></a>]<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Sent: Friday, July 19, 2013 6:29 PM<o:p></o:=
 p></p>
 <p class=3D"MsoPlainText">&gt; To: <a href=3D"mailto:bug-followup@freebsd.o=
 rg"><span style=3D"color:windowtext;text-decoration:none">bug-followup@free=
 bsd.org</span></a>; Meny Yossefi<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Subject: Re: kern/180430: [ofed] [patch] Bad=
  UDP checksum calc for
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; fragmented packets<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Oops, my previous reply didn't make it to th=
 e PR itself.<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Is the problem that the hardware checksum ov=
 erwrites arbitrary data in the packet (at the location where the UDP header=
  would be)?<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Also, I've looked at other drivers, and they=
  all look at the CSUM_*
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; flags to determine the right settings.&nbsp;=
  IP fragments will not have
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; CSUM_UDP or<o:p></o:p></p>
 <p class=3D"MsoPlainText">CSUM_TCP set, so I think the more correct fix is =
 this:<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; Index: en_tx.c<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; --- en_tx.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp; (revision 253470)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&#43;&#43; en_tx.c&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp; (working copy)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; @@ -780,8 &#43;780,12 @@ retry:<o:p></o:p></=
 p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.srcrb_flags =
 =3D <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |<o:p></=
 o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; MLX4_WQE_CTRL_SOLICITED);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mb-&gt;m_pkthdr.csum_flag=
 s &amp; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; (CSUM_IP|CSUM_TCP|CSUM_UDP)) {<o:p></o:p></p=
 >
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx_desc-&gt;ctrl.s=
 rcrb_flags |=3D cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
 p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
 nbsp;&nbsp; MLX4_WQE_CTRL_TCP_UDP_CSUM);<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mb-&gt;m_pkthdr.=
 csum_flags &amp; CSUM_IP)<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
  <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; tx_desc-&gt;ctrl.srcrb_flags |=3D<o:p>=
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp; <o:p>
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);<o:=
 p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
 ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (mb-&gt;m_pkthdr.=
 csum_flags &amp;
 <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; (CSUM_TCP|CSUM_UDP))<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
  <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; tx_desc-&gt;ctrl.srcrb_flags |=3D<o:p>=
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp; <o:p>
 </o:p></p>
 <p class=3D"MsoPlainText">&gt; &#43; cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM=
 );<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; priv-&gt=
 ;port_stats.tx_chksum_offload&#43;&#43;;<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
 sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; --<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; John Baldwin<o:p></o:p></p>
 <p class=3D"MsoPlainText">&gt; <o:p></o:p></p>
 <p class=3D"MsoPlainText"><o:p>&nbsp;</o:p></p>
 <p class=3D"MsoPlainText">--<o:p></o:p></p>
 <p class=3D"MsoPlainText">John Baldwin<o:p></o:p></p>
 </div>
 </body>
 </html>
 
 --_000_F2E47A38E4D0B9499D76F2AB8901571A73A0EC13MTLDAG01mtlcom_--
State-Changed-From-To: open->patched 
State-Changed-By: jhb 
State-Changed-When: Thu Jul 25 16:34:38 UTC 2013 
State-Changed-Why:  
Fix committed to HEAD, thanks! 


Responsible-Changed-From-To: freebsd-net->jhb 
Responsible-Changed-By: jhb 
Responsible-Changed-When: Thu Jul 25 16:34:38 UTC 2013 
Responsible-Changed-Why:  
Fix committed to HEAD, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180430 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/180430: commit references a PR
Date: Thu, 25 Jul 2013 16:34:41 +0000 (UTC)

 Author: jhb
 Date: Thu Jul 25 16:34:34 2013
 New Revision: 253653
 URL: http://svnweb.freebsd.org/changeset/base/253653
 
 Log:
   Avoid trashing IP fragments:
   - Only enable UDP/TCP hardware checksums if CSUM_UDP or CSUM_TCP is set.
   - Only enable IP hardware checksums if CSUM_IP is set.
   
   PR:		kern/180430
   Submitted by:	Meny Yossefi <menyy@mellanox.com>
   MFC after:	1 week
 
 Modified:
   head/sys/ofed/drivers/net/mlx4/en_tx.c
 
 Modified: head/sys/ofed/drivers/net/mlx4/en_tx.c
 ==============================================================================
 --- head/sys/ofed/drivers/net/mlx4/en_tx.c	Thu Jul 25 16:04:55 2013	(r253652)
 +++ head/sys/ofed/drivers/net/mlx4/en_tx.c	Thu Jul 25 16:34:34 2013	(r253653)
 @@ -780,8 +780,12 @@ retry:
  	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
  						MLX4_WQE_CTRL_SOLICITED);
  	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 -		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 -							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & CSUM_IP)
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP))
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
  		priv->port_stats.tx_chksum_offload++;
  	}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/180430: commit references a PR
Date: Tue,  6 Aug 2013 19:24:21 +0000 (UTC)

 Author: jhb
 Date: Tue Aug  6 19:23:57 2013
 New Revision: 254006
 URL: http://svnweb.freebsd.org/changeset/base/254006
 
 Log:
   MFC 253048,253423,253449,253653,253774,253785:
   - Allow mlx4 devices to switch between Ethernet and Infiniband:
     - Fix sysfs attribute handling by using sysctl_handle_string() and
       properly handling trailing newlines in attribute values.
     - Remove check forbidding requests that would result in one port being
       set to Ethernet and the subsequent port being set to IB.
   - Avoid trashing IP fragments by correctly managing hardware checksumming.
   - Fix panics when downing or unloading the mlx4 driver.
   
   PR:		kern/179999, kern/174213, kern/180430, kern/180791
 
 Modified:
   stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
   stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
   stable/9/sys/ofed/drivers/net/mlx4/main.c
   stable/9/sys/ofed/include/linux/sysfs.h
 Directory Properties:
   stable/9/sys/   (props changed)
 
 Modified: stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c
 ==============================================================================
 --- stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c	Tue Aug  6 19:14:02 2013	(r254005)
 +++ stable/9/sys/ofed/drivers/net/mlx4/en_netdev.c	Tue Aug  6 19:23:57 2013	(r254006)
 @@ -43,6 +43,7 @@
  #include <net/if_vlan_var.h>
  #include <sys/sockio.h>
  
 +static void mlx4_en_init_locked(struct mlx4_en_priv *priv);
  static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv);
  
  static void mlx4_en_vlan_rx_add_vid(void *arg, struct net_device *dev, u16 vid)
 @@ -495,11 +496,6 @@ static void mlx4_en_do_get_stats(struct 
  
  		queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY);
  	}
 -	if (mdev->mac_removed[MLX4_MAX_PORTS + 1 - priv->port]) {
 -		panic("mlx4_en_do_get_stats: Unexpected mac removed for %d\n",
 -		    priv->port);
 -		mdev->mac_removed[MLX4_MAX_PORTS + 1 - priv->port] = 0;
 -	}
  	mutex_unlock(&mdev->state_lock);
  }
  
 @@ -688,8 +684,8 @@ int mlx4_en_start_port(struct net_device
  	mlx4_en_set_multicast(dev);
  
  	/* Enable the queues. */
 -	atomic_clear_int(&dev->if_drv_flags, IFF_DRV_OACTIVE);
 -	atomic_set_int(&dev->if_drv_flags, IFF_DRV_RUNNING);
 +	dev->if_drv_flags &= ~IFF_DRV_OACTIVE;
 +	dev->if_drv_flags |= IFF_DRV_RUNNING;
  
  	callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT,
  	    mlx4_en_watchdog_timeout, priv);
 @@ -761,7 +757,7 @@ void mlx4_en_stop_port(struct net_device
  
  	callout_stop(&priv->watchdog_timer);
  
 -	atomic_clear_int(&dev->if_drv_flags, IFF_DRV_RUNNING);
 +	dev->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
  }
  
  static void mlx4_en_restart(struct work_struct *work)
 @@ -802,19 +798,30 @@ mlx4_en_init(void *arg)
  {
  	struct mlx4_en_priv *priv;
  	struct mlx4_en_dev *mdev;
 +
 +	priv = arg;
 +	mdev = priv->mdev;
 +	mutex_lock(&mdev->state_lock);
 +	mlx4_en_init_locked(priv);
 +	mutex_unlock(&mdev->state_lock);
 +}
 +
 +static void
 +mlx4_en_init_locked(struct mlx4_en_priv *priv)
 +{
 +
 +	struct mlx4_en_dev *mdev;
  	struct ifnet *dev;
  	int i;
  
 -	priv = arg;
  	dev = priv->dev;
  	mdev = priv->mdev;
 -	mutex_lock(&mdev->state_lock);
  	if (dev->if_drv_flags & IFF_DRV_RUNNING)
  		mlx4_en_stop_port(dev);
  
  	if (!mdev->device_up) {
  		en_err(priv, "Cannot open - device down/disabled\n");
 -		goto out;
 +		return;
  	}
  
  	/* Reset HW statistics and performance counters */
 @@ -835,9 +842,6 @@ mlx4_en_init(void *arg)
  	mlx4_en_set_default_moderation(priv);
  	if (mlx4_en_start_port(dev))
  		en_err(priv, "Failed starting port:%d\n", priv->port);
 -
 -out:
 -	mutex_unlock(&mdev->state_lock);
  }
  
  void mlx4_en_free_resources(struct mlx4_en_priv *priv)
 @@ -927,9 +931,14 @@ void mlx4_en_destroy_netdev(struct net_d
  	if (priv->sysctl)
  		sysctl_ctx_free(&priv->conf_ctx);
  
 +	mutex_lock(&mdev->state_lock);
 +	mlx4_en_stop_port(dev);
 +	mutex_unlock(&mdev->state_lock);
 +
  	cancel_delayed_work(&priv->stats_task);
  	/* flush any pending task for this netdev */
  	flush_workqueue(mdev->workqueue);
 +	callout_drain(&priv->watchdog_timer);
  
  	/* Detach the netdev so tasks would not attempt to access it */
  	mutex_lock(&mdev->state_lock);
 @@ -1091,31 +1100,32 @@ static int mlx4_en_ioctl(struct ifnet *d
  		error = -mlx4_en_change_mtu(dev, ifr->ifr_mtu);
  		break;
  	case SIOCSIFFLAGS:
 +		mutex_lock(&mdev->state_lock);
  		if (dev->if_flags & IFF_UP) {
 -			if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0) {
 -				mutex_lock(&mdev->state_lock);
 +			if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0)
  				mlx4_en_start_port(dev);
 -				mutex_unlock(&mdev->state_lock);
 -			} else
 +			else
  				mlx4_en_set_multicast(dev);
  		} else {
 -			mutex_lock(&mdev->state_lock);
  			if (dev->if_drv_flags & IFF_DRV_RUNNING) {
  				mlx4_en_stop_port(dev);
  				if_link_state_change(dev, LINK_STATE_DOWN);
  			}
 -			mutex_unlock(&mdev->state_lock);
  		}
 +		mutex_unlock(&mdev->state_lock);
  		break;
  	case SIOCADDMULTI:
  	case SIOCDELMULTI:
 +		mutex_lock(&mdev->state_lock);
  		mlx4_en_set_multicast(dev);
 +		mutex_unlock(&mdev->state_lock);
  		break;
  	case SIOCSIFMEDIA:
  	case SIOCGIFMEDIA:
  		error = ifmedia_ioctl(dev, ifr, &priv->media, command);
  		break;
  	case SIOCSIFCAP:
 +		mutex_lock(&mdev->state_lock);
  		mask = ifr->ifr_reqcap ^ dev->if_capenable;
  		if (mask & IFCAP_HWCSUM)
  			dev->if_capenable ^= IFCAP_HWCSUM;
 @@ -1130,7 +1140,8 @@ static int mlx4_en_ioctl(struct ifnet *d
  		if (mask & IFCAP_WOL_MAGIC)
  			dev->if_capenable ^= IFCAP_WOL_MAGIC;
  		if (dev->if_drv_flags & IFF_DRV_RUNNING)
 -			mlx4_en_init(priv);
 +			mlx4_en_init_locked(priv);
 +		mutex_unlock(&mdev->state_lock);
  		VLAN_CAPABILITIES(dev);
  		break;
  	default:
 
 Modified: stable/9/sys/ofed/drivers/net/mlx4/en_tx.c
 ==============================================================================
 --- stable/9/sys/ofed/drivers/net/mlx4/en_tx.c	Tue Aug  6 19:14:02 2013	(r254005)
 +++ stable/9/sys/ofed/drivers/net/mlx4/en_tx.c	Tue Aug  6 19:23:57 2013	(r254006)
 @@ -780,8 +780,12 @@ retry:
  	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
  						MLX4_WQE_CTRL_SOLICITED);
  	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 -		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 -							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & CSUM_IP)
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP))
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
  		priv->port_stats.tx_chksum_offload++;
  	}
  
 
 Modified: stable/9/sys/ofed/drivers/net/mlx4/main.c
 ==============================================================================
 --- stable/9/sys/ofed/drivers/net/mlx4/main.c	Tue Aug  6 19:14:02 2013	(r254005)
 +++ stable/9/sys/ofed/drivers/net/mlx4/main.c	Tue Aug  6 19:23:57 2013	(r254006)
 @@ -209,9 +209,6 @@ int mlx4_check_port_params(struct mlx4_d
  					 "on this HCA, aborting.\n");
  				return -EINVAL;
  			}
 -			if (port_type[i] == MLX4_PORT_TYPE_ETH &&
 -			    port_type[i + 1] == MLX4_PORT_TYPE_IB)
 -				return -EINVAL;
  		}
  	}
  
 
 Modified: stable/9/sys/ofed/include/linux/sysfs.h
 ==============================================================================
 --- stable/9/sys/ofed/include/linux/sysfs.h	Tue Aug  6 19:14:02 2013	(r254005)
 +++ stable/9/sys/ofed/include/linux/sysfs.h	Tue Aug  6 19:23:57 2013	(r254006)
 @@ -75,39 +75,42 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
  	struct kobject *kobj;
  	struct attribute *attr;
  	const struct sysfs_ops *ops;
 -	void *buf;
 +	char *buf;
  	int error;
  	ssize_t len;
  
  	kobj = arg1;
  	attr = (struct attribute *)arg2;
 -	buf = (void *)get_zeroed_page(GFP_KERNEL);
 -	len = 1;	/* Copy out a NULL byte at least. */
  	if (kobj->ktype == NULL || kobj->ktype->sysfs_ops == NULL)
  		return (ENODEV);
 -	ops = kobj->ktype->sysfs_ops;
 +	buf = (char *)get_zeroed_page(GFP_KERNEL);
  	if (buf == NULL)
  		return (ENOMEM);
 +	ops = kobj->ktype->sysfs_ops;
  	if (ops->show) {
  		len = ops->show(kobj, attr, buf);
  		/*
 -		 * It's valid not to have a 'show' so we just return 1 byte
 -		 * of NULL.
 +		 * It's valid to not have a 'show' so just return an
 +		 * empty string.
  	 	 */
  		if (len < 0) {
  			error = -len;
 -			len = 1;
  			if (error != EIO)
  				goto out;
  		}
 +
 +		/* Trim trailing newline. */
 +		len--;
 +		buf[len] = '\0';
  	}
 -	error = SYSCTL_OUT(req, buf, len);
 -	if (error || !req->newptr || ops->store == NULL)
 -		goto out;
 -	error = SYSCTL_IN(req, buf, PAGE_SIZE);
 -	if (error)
 +
 +	/* Leave one trailing byte to append a newline. */
 +	error = sysctl_handle_string(oidp, buf, PAGE_SIZE - 1, req);
 +	if (error != 0 || req->newptr == NULL || ops->store == NULL)
  		goto out;
 -	len = ops->store(kobj, attr, buf, req->newlen);
 +	len = strlcat(buf, "\n", PAGE_SIZE);
 +	KASSERT(len < PAGE_SIZE, ("new attribute truncated"));
 +	len = ops->store(kobj, attr, buf, len);
  	if (len < 0)
  		error = -len;
  out:
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/180430: commit references a PR
Date: Tue,  6 Aug 2013 20:04:59 +0000 (UTC)

 Author: jhb
 Date: Tue Aug  6 20:04:44 2013
 New Revision: 254007
 URL: http://svnweb.freebsd.org/changeset/base/254007
 
 Log:
   MFC 253048,253423,253449,253653,253774,253785:
   - Allow mlx4 devices to switch between Ethernet and Infiniband:
     - Fix sysfs attribute handling by using sysctl_handle_string() and
       properly handling trailing newlines in attribute values.
     - Remove check forbidding requests that would result in one port being
       set to Ethernet and the subsequent port being set to IB.
   - Avoid trashing IP fragments by correctly managing hardware checksumming.
   - Fix panics when downing or unloading the mlx4 driver.
   
   PR:		kern/179999, kern/174213, kern/180430, kern/180791
   Approved by:	re (kib)
 
 Modified:
   releng/9.2/sys/ofed/drivers/net/mlx4/en_netdev.c
   releng/9.2/sys/ofed/drivers/net/mlx4/en_tx.c
   releng/9.2/sys/ofed/drivers/net/mlx4/main.c
   releng/9.2/sys/ofed/include/linux/sysfs.h
 Directory Properties:
   releng/9.2/sys/   (props changed)
 
 Modified: releng/9.2/sys/ofed/drivers/net/mlx4/en_netdev.c
 ==============================================================================
 --- releng/9.2/sys/ofed/drivers/net/mlx4/en_netdev.c	Tue Aug  6 19:23:57 2013	(r254006)
 +++ releng/9.2/sys/ofed/drivers/net/mlx4/en_netdev.c	Tue Aug  6 20:04:44 2013	(r254007)
 @@ -43,6 +43,7 @@
  #include <net/if_vlan_var.h>
  #include <sys/sockio.h>
  
 +static void mlx4_en_init_locked(struct mlx4_en_priv *priv);
  static void mlx4_en_sysctl_stat(struct mlx4_en_priv *priv);
  
  static void mlx4_en_vlan_rx_add_vid(void *arg, struct net_device *dev, u16 vid)
 @@ -495,11 +496,6 @@ static void mlx4_en_do_get_stats(struct 
  
  		queue_delayed_work(mdev->workqueue, &priv->stats_task, STATS_DELAY);
  	}
 -	if (mdev->mac_removed[MLX4_MAX_PORTS + 1 - priv->port]) {
 -		panic("mlx4_en_do_get_stats: Unexpected mac removed for %d\n",
 -		    priv->port);
 -		mdev->mac_removed[MLX4_MAX_PORTS + 1 - priv->port] = 0;
 -	}
  	mutex_unlock(&mdev->state_lock);
  }
  
 @@ -688,8 +684,8 @@ int mlx4_en_start_port(struct net_device
  	mlx4_en_set_multicast(dev);
  
  	/* Enable the queues. */
 -	atomic_clear_int(&dev->if_drv_flags, IFF_DRV_OACTIVE);
 -	atomic_set_int(&dev->if_drv_flags, IFF_DRV_RUNNING);
 +	dev->if_drv_flags &= ~IFF_DRV_OACTIVE;
 +	dev->if_drv_flags |= IFF_DRV_RUNNING;
  
  	callout_reset(&priv->watchdog_timer, MLX4_EN_WATCHDOG_TIMEOUT,
  	    mlx4_en_watchdog_timeout, priv);
 @@ -761,7 +757,7 @@ void mlx4_en_stop_port(struct net_device
  
  	callout_stop(&priv->watchdog_timer);
  
 -	atomic_clear_int(&dev->if_drv_flags, IFF_DRV_RUNNING);
 +	dev->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
  }
  
  static void mlx4_en_restart(struct work_struct *work)
 @@ -802,19 +798,30 @@ mlx4_en_init(void *arg)
  {
  	struct mlx4_en_priv *priv;
  	struct mlx4_en_dev *mdev;
 +
 +	priv = arg;
 +	mdev = priv->mdev;
 +	mutex_lock(&mdev->state_lock);
 +	mlx4_en_init_locked(priv);
 +	mutex_unlock(&mdev->state_lock);
 +}
 +
 +static void
 +mlx4_en_init_locked(struct mlx4_en_priv *priv)
 +{
 +
 +	struct mlx4_en_dev *mdev;
  	struct ifnet *dev;
  	int i;
  
 -	priv = arg;
  	dev = priv->dev;
  	mdev = priv->mdev;
 -	mutex_lock(&mdev->state_lock);
  	if (dev->if_drv_flags & IFF_DRV_RUNNING)
  		mlx4_en_stop_port(dev);
  
  	if (!mdev->device_up) {
  		en_err(priv, "Cannot open - device down/disabled\n");
 -		goto out;
 +		return;
  	}
  
  	/* Reset HW statistics and performance counters */
 @@ -835,9 +842,6 @@ mlx4_en_init(void *arg)
  	mlx4_en_set_default_moderation(priv);
  	if (mlx4_en_start_port(dev))
  		en_err(priv, "Failed starting port:%d\n", priv->port);
 -
 -out:
 -	mutex_unlock(&mdev->state_lock);
  }
  
  void mlx4_en_free_resources(struct mlx4_en_priv *priv)
 @@ -927,9 +931,14 @@ void mlx4_en_destroy_netdev(struct net_d
  	if (priv->sysctl)
  		sysctl_ctx_free(&priv->conf_ctx);
  
 +	mutex_lock(&mdev->state_lock);
 +	mlx4_en_stop_port(dev);
 +	mutex_unlock(&mdev->state_lock);
 +
  	cancel_delayed_work(&priv->stats_task);
  	/* flush any pending task for this netdev */
  	flush_workqueue(mdev->workqueue);
 +	callout_drain(&priv->watchdog_timer);
  
  	/* Detach the netdev so tasks would not attempt to access it */
  	mutex_lock(&mdev->state_lock);
 @@ -1091,31 +1100,32 @@ static int mlx4_en_ioctl(struct ifnet *d
  		error = -mlx4_en_change_mtu(dev, ifr->ifr_mtu);
  		break;
  	case SIOCSIFFLAGS:
 +		mutex_lock(&mdev->state_lock);
  		if (dev->if_flags & IFF_UP) {
 -			if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0) {
 -				mutex_lock(&mdev->state_lock);
 +			if ((dev->if_drv_flags & IFF_DRV_RUNNING) == 0)
  				mlx4_en_start_port(dev);
 -				mutex_unlock(&mdev->state_lock);
 -			} else
 +			else
  				mlx4_en_set_multicast(dev);
  		} else {
 -			mutex_lock(&mdev->state_lock);
  			if (dev->if_drv_flags & IFF_DRV_RUNNING) {
  				mlx4_en_stop_port(dev);
  				if_link_state_change(dev, LINK_STATE_DOWN);
  			}
 -			mutex_unlock(&mdev->state_lock);
  		}
 +		mutex_unlock(&mdev->state_lock);
  		break;
  	case SIOCADDMULTI:
  	case SIOCDELMULTI:
 +		mutex_lock(&mdev->state_lock);
  		mlx4_en_set_multicast(dev);
 +		mutex_unlock(&mdev->state_lock);
  		break;
  	case SIOCSIFMEDIA:
  	case SIOCGIFMEDIA:
  		error = ifmedia_ioctl(dev, ifr, &priv->media, command);
  		break;
  	case SIOCSIFCAP:
 +		mutex_lock(&mdev->state_lock);
  		mask = ifr->ifr_reqcap ^ dev->if_capenable;
  		if (mask & IFCAP_HWCSUM)
  			dev->if_capenable ^= IFCAP_HWCSUM;
 @@ -1130,7 +1140,8 @@ static int mlx4_en_ioctl(struct ifnet *d
  		if (mask & IFCAP_WOL_MAGIC)
  			dev->if_capenable ^= IFCAP_WOL_MAGIC;
  		if (dev->if_drv_flags & IFF_DRV_RUNNING)
 -			mlx4_en_init(priv);
 +			mlx4_en_init_locked(priv);
 +		mutex_unlock(&mdev->state_lock);
  		VLAN_CAPABILITIES(dev);
  		break;
  	default:
 
 Modified: releng/9.2/sys/ofed/drivers/net/mlx4/en_tx.c
 ==============================================================================
 --- releng/9.2/sys/ofed/drivers/net/mlx4/en_tx.c	Tue Aug  6 19:23:57 2013	(r254006)
 +++ releng/9.2/sys/ofed/drivers/net/mlx4/en_tx.c	Tue Aug  6 20:04:44 2013	(r254007)
 @@ -780,8 +780,12 @@ retry:
  	tx_desc->ctrl.srcrb_flags = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE |
  						MLX4_WQE_CTRL_SOLICITED);
  	if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP)) {
 -		tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
 -							 MLX4_WQE_CTRL_TCP_UDP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & CSUM_IP)
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
 +		if (mb->m_pkthdr.csum_flags & (CSUM_TCP|CSUM_UDP))
 +			tx_desc->ctrl.srcrb_flags |=
 +			    cpu_to_be32(MLX4_WQE_CTRL_TCP_UDP_CSUM);
  		priv->port_stats.tx_chksum_offload++;
  	}
  
 
 Modified: releng/9.2/sys/ofed/drivers/net/mlx4/main.c
 ==============================================================================
 --- releng/9.2/sys/ofed/drivers/net/mlx4/main.c	Tue Aug  6 19:23:57 2013	(r254006)
 +++ releng/9.2/sys/ofed/drivers/net/mlx4/main.c	Tue Aug  6 20:04:44 2013	(r254007)
 @@ -209,9 +209,6 @@ int mlx4_check_port_params(struct mlx4_d
  					 "on this HCA, aborting.\n");
  				return -EINVAL;
  			}
 -			if (port_type[i] == MLX4_PORT_TYPE_ETH &&
 -			    port_type[i + 1] == MLX4_PORT_TYPE_IB)
 -				return -EINVAL;
  		}
  	}
  
 
 Modified: releng/9.2/sys/ofed/include/linux/sysfs.h
 ==============================================================================
 --- releng/9.2/sys/ofed/include/linux/sysfs.h	Tue Aug  6 19:23:57 2013	(r254006)
 +++ releng/9.2/sys/ofed/include/linux/sysfs.h	Tue Aug  6 20:04:44 2013	(r254007)
 @@ -75,39 +75,42 @@ sysctl_handle_attr(SYSCTL_HANDLER_ARGS)
  	struct kobject *kobj;
  	struct attribute *attr;
  	const struct sysfs_ops *ops;
 -	void *buf;
 +	char *buf;
  	int error;
  	ssize_t len;
  
  	kobj = arg1;
  	attr = (struct attribute *)arg2;
 -	buf = (void *)get_zeroed_page(GFP_KERNEL);
 -	len = 1;	/* Copy out a NULL byte at least. */
  	if (kobj->ktype == NULL || kobj->ktype->sysfs_ops == NULL)
  		return (ENODEV);
 -	ops = kobj->ktype->sysfs_ops;
 +	buf = (char *)get_zeroed_page(GFP_KERNEL);
  	if (buf == NULL)
  		return (ENOMEM);
 +	ops = kobj->ktype->sysfs_ops;
  	if (ops->show) {
  		len = ops->show(kobj, attr, buf);
  		/*
 -		 * It's valid not to have a 'show' so we just return 1 byte
 -		 * of NULL.
 +		 * It's valid to not have a 'show' so just return an
 +		 * empty string.
  	 	 */
  		if (len < 0) {
  			error = -len;
 -			len = 1;
  			if (error != EIO)
  				goto out;
  		}
 +
 +		/* Trim trailing newline. */
 +		len--;
 +		buf[len] = '\0';
  	}
 -	error = SYSCTL_OUT(req, buf, len);
 -	if (error || !req->newptr || ops->store == NULL)
 -		goto out;
 -	error = SYSCTL_IN(req, buf, PAGE_SIZE);
 -	if (error)
 +
 +	/* Leave one trailing byte to append a newline. */
 +	error = sysctl_handle_string(oidp, buf, PAGE_SIZE - 1, req);
 +	if (error != 0 || req->newptr == NULL || ops->store == NULL)
  		goto out;
 -	len = ops->store(kobj, attr, buf, req->newlen);
 +	len = strlcat(buf, "\n", PAGE_SIZE);
 +	KASSERT(len < PAGE_SIZE, ("new attribute truncated"));
 +	len = ops->store(kobj, attr, buf, len);
  	if (len < 0)
  		error = -len;
  out:
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: jhb 
State-Changed-When: Wed Aug 7 18:01:50 UTC 2013 
State-Changed-Why:  
Merge 9 and 9.2. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=180430 
>Unformatted:
