netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Bruce Allan <bruce.w.allan@intel.com>,
	netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 07/11] e1000e: cleanup Rx checksum offload code
Date: Tue,  3 Jan 2012 11:19:12 -0800	[thread overview]
Message-ID: <1325618356-2655-8-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1325618356-2655-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Bruce Allan <bruce.w.allan@intel.com>

1) cleanup whitespace in e1000_rx_checksum() function header comment
2) do not check hardware checksum when Rx checksum is disabled
3) reduce duplicated calls to le16_to_cpu() by just using it within
   e1000_rx_checksum() instead of in each call to the function

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 3911401..e01ffce 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -487,10 +487,10 @@ static void e1000_receive_skb(struct e1000_adapter *adapter,
 
 /**
  * e1000_rx_checksum - Receive Checksum Offload
- * @adapter:     board private structure
- * @status_err:  receive descriptor status and error fields
- * @csum:	receive descriptor csum field
- * @sk_buff:     socket buffer with received data
+ * @adapter: board private structure
+ * @status_err: receive descriptor status and error fields
+ * @csum: receive descriptor csum field
+ * @sk_buff: socket buffer with received data
  **/
 static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
 			      u32 csum, struct sk_buff *skb)
@@ -500,9 +500,14 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
 
 	skb_checksum_none_assert(skb);
 
+	/* Rx checksum disabled */
+	if (!(adapter->netdev->features & NETIF_F_RXCSUM))
+		return;
+
 	/* Ignore Checksum bit is set */
 	if (status & E1000_RXD_STAT_IXSM)
 		return;
+
 	/* TCP/UDP checksum error bit is set */
 	if (errors & E1000_RXD_ERR_TCPE) {
 		/* let the stack verify checksum errors */
@@ -524,7 +529,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
 		 * Hardware complements the payload checksum, so we undo it
 		 * and then put the value in host order for further stack use.
 		 */
-		__sum16 sum = (__force __sum16)htons(csum);
+		__sum16 sum = (__force __sum16)htons(le16_to_cpu(csum));
 		skb->csum = csum_unfold(~sum);
 		skb->ip_summed = CHECKSUM_COMPLETE;
 	}
@@ -957,8 +962,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
 
 		/* Receive Checksum Offload */
 		e1000_rx_checksum(adapter, staterr,
-				  le16_to_cpu(rx_desc->wb.lower.hi_dword.
-					      csum_ip.csum), skb);
+				  rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
 
 		e1000_receive_skb(adapter, netdev, skb, staterr,
 				  rx_desc->wb.upper.vlan);
@@ -1318,8 +1322,8 @@ copydone:
 		total_rx_bytes += skb->len;
 		total_rx_packets++;
 
-		e1000_rx_checksum(adapter, staterr, le16_to_cpu(
-			rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
+		e1000_rx_checksum(adapter, staterr,
+				  rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
 
 		if (rx_desc->wb.upper.header_status &
 			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
@@ -1491,8 +1495,7 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
 
 		/* Receive Checksum Offload XXX recompute due to CRC strip? */
 		e1000_rx_checksum(adapter, staterr,
-				  le16_to_cpu(rx_desc->wb.lower.hi_dword.
-					      csum_ip.csum), skb);
+				  rx_desc->wb.lower.hi_dword.csum_ip.csum, skb);
 
 		/* probably a little skewed due to removing CRC */
 		total_rx_bytes += skb->len;
-- 
1.7.7.4

  parent reply	other threads:[~2012-01-03 19:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 19:19 [net-next 00/11][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2012-01-03 19:19 ` [net-next 01/11] e1000: fix lockdep splat in shutdown handler Jeff Kirsher
2012-01-03 19:19 ` [net-next 02/11] igb: Add support for byte queue limits Jeff Kirsher
2012-01-03 19:19 ` [net-next 03/11] igb: add basic runtime PM support Jeff Kirsher
2012-01-03 19:19 ` [net-next 04/11] igb: reset PHY after recovering from PHY power down Jeff Kirsher
2012-01-03 19:19 ` [net-next 05/11] netdev: FCoE: Add new ndo_get_fcoe_hbainfo() call Jeff Kirsher
2012-01-03 20:07   ` David Miller
2012-01-03 20:53     ` Parikh, Neerav
2012-01-03 19:19 ` [net-next 06/11] ixgbe: FCoE: Add support for " Jeff Kirsher
2012-01-03 19:19 ` Jeff Kirsher [this message]
2012-01-03 20:08   ` [net-next 07/11] e1000e: cleanup Rx checksum offload code David Miller
2012-01-03 20:17     ` Allan, Bruce W
2012-01-03 21:00     ` Ben Hutchings
2012-01-03 21:15       ` David Miller
2012-01-03 21:24         ` Ben Hutchings
2012-01-03 22:02           ` David Miller
2012-01-03 19:19 ` [net-next 08/11] e1000e: add Receive Packet Steering (RPS) support Jeff Kirsher
2012-01-03 20:09   ` David Miller
2012-01-03 20:16     ` Allan, Bruce W
2012-01-03 20:27       ` David Miller
2012-01-03 20:28         ` Allan, Bruce W
2012-01-04  0:12           ` Joe Perches
2012-01-04  2:06             ` Harvey Harrison
2012-01-03 21:05   ` Ben Hutchings
2012-01-06 17:22     ` Allan, Bruce W
2012-01-06 17:31       ` Ben Hutchings
2012-01-03 19:19 ` [net-next 09/11] e1000e: re-enable alternate MAC address for all devices which support it Jeff Kirsher
2012-01-03 19:19 ` [net-next 10/11] e1000e: convert head, tail and itr_register offsets to __iomem pointers Jeff Kirsher
2012-01-03 19:19 ` [net-next 11/11] e1000e: pass pointer to ring struct instead of adapter struct Jeff Kirsher

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=1325618356-2655-8-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=bruce.w.allan@intel.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).