LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
To: ML netdev <netdev@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Wang, Qi" <qi.wang@intel.com>,
	"Wang, Yong Y" <yong.y.wang@intel.com>,
	Andrew <andrew.chih.howe.khor@intel.com>,
	Intel OTC <joel.clark@intel.com>,
	"Ewe, Kok Howg" <kok.howg.ewe@intel.com>
Subject: [PATCH] pch_gbe: Fix the issue that the receiving data is not normal.
Date: Mon, 24 Jan 2011 13:43:31 +0900	[thread overview]
Message-ID: <4D3D0373.30003@dsn.okisemi.com> (raw)

This PCH_GBE driver had an issue that the receiving data is not normal.
This driver had not removed correctly the padding data 
which the DMA include in receiving data. 

This patch fixed this issue.

Signed-off-by: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
---
 drivers/net/pch_gbe/pch_gbe_main.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index 03a1d28..1bf2626 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -29,6 +29,7 @@ const char pch_driver_version[] = DRV_VERSION;
 #define PCH_GBE_SHORT_PKT		64
 #define DSC_INIT16			0xC000
 #define PCH_GBE_DMA_ALIGN		0
+#define PCH_GBE_DMA_PADDING		2
 #define PCH_GBE_WATCHDOG_PERIOD		(1 * HZ)	/* watchdog time */
 #define PCH_GBE_COPYBREAK_DEFAULT	256
 #define PCH_GBE_PCI_BAR			1
@@ -1422,8 +1423,8 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
 			pr_err("Receive CRC Error\n");
 		} else {
 			/* get receive length */
-			/* length convert[-3], padding[-2] */
-			length = (rx_desc->rx_words_eob) - 3 - 2;
+			/* length convert[-3] */
+			length = (rx_desc->rx_words_eob) - 3;
 
 			/* Decide the data conversion method */
 			if (!adapter->rx_csum) {
@@ -1443,12 +1444,11 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
 			if (skb_copy_flag) {	/* recycle  skb */
 				struct sk_buff *new_skb;
 				new_skb =
-				    netdev_alloc_skb(netdev,
-						     length + NET_IP_ALIGN);
+				    netdev_alloc_skb(netdev, length);
 				if (new_skb) {
 					if (!skb_padding_flag) {
 						skb_reserve(new_skb,
-								NET_IP_ALIGN);
+							PCH_GBE_DMA_PADDING);
 					}
 					memcpy(new_skb->data, skb->data,
 						length);
@@ -1465,12 +1465,15 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter,
 			}
 			if (skb_padding_flag) {
 				memcpy(&tmp_packet[0], &skb->data[0], ETH_HLEN);
-				memcpy(&skb->data[NET_IP_ALIGN], &tmp_packet[0],
-					ETH_HLEN);
-				skb_reserve(skb, NET_IP_ALIGN);
-
+				memcpy(&skb->data[PCH_GBE_DMA_PADDING],
+				       &tmp_packet[0], ETH_HLEN);
+				skb_reserve(skb, PCH_GBE_DMA_PADDING);
+				/* The length includes padding length */
+				length = length - PCH_GBE_DMA_PADDING;
 			}
 
+			/* The length includes FCS length */
+			length = length - ETH_FCS_LEN;
 			/* update status of driver */
 			adapter->stats.rx_bytes += length;
 			adapter->stats.rx_packets++;
-- 
1.6.2.5

             reply	other threads:[~2011-01-24  4:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24  4:43 Toshiharu Okada [this message]
2011-01-25 21:32 ` David Miller
2011-01-27  8:45   ` Toshiharu Okada
2011-02-08  8:24 Toshiharu Okada
2011-02-09  0:35 ` David Miller
2011-02-09  4:58   ` Toshiharu Okada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D3D0373.30003@dsn.okisemi.com \
    --to=toshiharu-linux@dsn.okisemi.com \
    --cc=andrew.chih.howe.khor@intel.com \
    --cc=joel.clark@intel.com \
    --cc=kok.howg.ewe@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=qi.wang@intel.com \
    --cc=yong.y.wang@intel.com \
    --subject='Re: [PATCH] pch_gbe: Fix the issue that the receiving data is not normal.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).