netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Jeff Garzik <jgarzik@pobox.com>, linux-driver@qlogic.com
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/3] qla3xxx: cleanup checksum offload code
Date: Wed, 30 May 2007 14:23:18 -0700	[thread overview]
Message-ID: <20070530212512.178720251@linux-foundation.org> (raw)
In-Reply-To: 20070530212316.407169588@linux-foundation.org

[-- Attachment #1: qla-csum.patch --]
[-- Type: text/plain, Size: 1988 bytes --]

The code for checksum is more complex than needed when dealing with VLAN's;
the higher layers already pass down the location of the IP header.

Compile tested only, no hardware available.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>

---
 drivers/net/qla3xxx.c |   37 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

--- a/drivers/net/qla3xxx.c	2007-05-30 14:09:25.000000000 -0700
+++ b/drivers/net/qla3xxx.c	2007-05-30 14:09:31.000000000 -0700
@@ -2433,37 +2433,22 @@ static int ql_get_seg_count(struct ql3_a
 	return -1;
 }
 
-static void ql_hw_csum_setup(struct sk_buff *skb,
+static void ql_hw_csum_setup(const struct sk_buff *skb,
 			     struct ob_mac_iocb_req *mac_iocb_ptr)
 {
-	struct ethhdr *eth;
-	struct iphdr *ip = NULL;
-	u8 offset = ETH_HLEN;
-
-	eth = (struct ethhdr *)(skb->data);
-
-	if (eth->h_proto == __constant_htons(ETH_P_IP)) {
-		ip = (struct iphdr *)&skb->data[ETH_HLEN];
-	} else if (eth->h_proto == htons(ETH_P_8021Q) &&
-		   ((struct vlan_ethhdr *)skb->data)->
-		   h_vlan_encapsulated_proto == __constant_htons(ETH_P_IP)) {
-		ip = (struct iphdr *)&skb->data[VLAN_ETH_HLEN];
-		offset = VLAN_ETH_HLEN;
-	}
-
-	if (ip) {
-		if (ip->protocol == IPPROTO_TCP) {
-			mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_TC | 
+	const struct iphdr *ip = ip_hdr(skb);
+
+	mac_iocb_ptr->ip_hdr_off = skb_network_offset(skb);
+	mac_iocb_ptr->ip_hdr_len = ip->ihl;
+
+	if (ip->protocol == IPPROTO_TCP) {
+		mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_TC |
 			OB_3032MAC_IOCB_REQ_IC;
-			mac_iocb_ptr->ip_hdr_off = offset;
-			mac_iocb_ptr->ip_hdr_len = ip->ihl;
-		} else if (ip->protocol == IPPROTO_UDP) {
-			mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_UC | 
+	} else {
+		mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_UC |
 			OB_3032MAC_IOCB_REQ_IC;
-			mac_iocb_ptr->ip_hdr_off = offset;
-			mac_iocb_ptr->ip_hdr_len = ip->ihl;
-		}
 	}
+
 }
 
 /*

-- 
Stephen Hemminger <shemminger@linux-foundation.org>


  parent reply	other threads:[~2007-05-30 21:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-30 21:23 [PATCH 0/3] qla3xxx checksum related patches Stephen Hemminger
2007-05-30 21:23 ` [PATCH 1/3] qla3xxx: device doesnt do hardware checksumming Stephen Hemminger
2007-06-03 15:46   ` Jeff Garzik
2007-05-30 21:23 ` Stephen Hemminger [this message]
2007-06-06 23:23   ` [PATCH 2/3] qla3xxx: cleanup checksum offload code Ron Mercer
2007-06-13 19:43   ` Jeff Garzik
2007-06-13 19:55     ` Ron Mercer
2007-06-13 20:04   ` Jeff Garzik
2007-05-30 21:23 ` [PATCH 3/3] qla3xxx: ethtool ops for controlling checksum Stephen Hemminger

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=20070530212512.178720251@linux-foundation.org \
    --to=shemminger@linux-foundation.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-driver@qlogic.com \
    --cc=netdev@vger.kernel.org \
    /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).