]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix e100 for big-endian machines
authorAndrew Morton <akpm@digeo.com>
Sun, 2 Mar 2003 12:36:31 +0000 (04:36 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Sun, 2 Mar 2003 12:36:31 +0000 (04:36 -0800)
Patch from Anton Blanchard <anton@samba.org>

e100 is performing a header checksum calculation which is

a) duplication of the core kernel's calculation of the same and

b) incorrect on big-endian machines.

This fix has been tested on ia32 and pppc64 and acked by davem, jgarzik
and Scott Feldman

drivers/net/e100/e100.h
drivers/net/e100/e100_main.c

index 766ea9a216db7a010c0cafaf674eacd10e4c2209..761628d8b586ad15e214c25fbc86c207a37c60a1 100644 (file)
@@ -706,8 +706,6 @@ typedef enum _non_tx_cmd_state_t {
 #define IPCB_INSERTVLAN_ENABLE                 BIT_1
 #define IPCB_IP_ACTIVATION_DEFAULT      IPCB_HARDWAREPARSING_ENABLE
 
-#define FOLD_CSUM(_XSUM)  ((((_XSUM << 16) | (_XSUM >> 16)) + _XSUM) >> 16)
-
 /* Transmit Buffer Descriptor (TBD)*/
 typedef struct _tbd_t {
        u32 tbd_buf_addr;       /* Physical Transmit Buffer Address */
index 08c7df15f2d3fcd44e01eb91db325b4af8c27a0b..523e83f771dad14a7c08ea788136be3527572c7c 100644 (file)
@@ -2070,32 +2070,6 @@ e100_refresh_txthld(struct e100_private *bdp)
        }                       /* end underrun check */
 }
 
-/**
- * e100_pseudo_hdr_csum - compute IP pseudo-header checksum
- * @ip: points to the header of the IP packet
- *
- * Return the 16 bit checksum of the IP pseudo-header.,which is computed
- * on the fields: IP src, IP dst, next protocol, payload length.
- * The checksum vaule is returned in network byte order.
- */
-static inline u16
-e100_pseudo_hdr_csum(const struct iphdr *ip)
-{
-       u32 pseudo = 0;
-       u32 payload_len = 0;
-
-       payload_len = ntohs(ip->tot_len) - (ip->ihl * 4);
-
-       pseudo += htons(payload_len);
-       pseudo += (ip->protocol << 8);
-       pseudo += ip->saddr & 0x0000ffff;
-       pseudo += (ip->saddr & 0xffff0000) >> 16;
-       pseudo += ip->daddr & 0x0000ffff;
-       pseudo += (ip->daddr & 0xffff0000) >> 16;
-
-       return FOLD_CSUM(pseudo);
-}
-
 /**
  * e100_prepare_xmit_buff - prepare a buffer for transmission
  * @bdp: atapter's private data struct
@@ -2140,27 +2114,13 @@ e100_prepare_xmit_buff(struct e100_private *bdp, struct sk_buff *skb)
 
                if ((ip->protocol == IPPROTO_TCP) ||
                    (ip->protocol == IPPROTO_UDP)) {
-                       u16 *chksum;
-
                        tcb->tcbu.ipcb.ip_activation_high =
                                IPCB_HARDWAREPARSING_ENABLE;
                        tcb->tcbu.ipcb.ip_schedule |=
                                IPCB_TCPUDP_CHECKSUM_ENABLE;
 
-                       if (ip->protocol == IPPROTO_TCP) {
-                               struct tcphdr *tcp;
-
-                               tcp = (struct tcphdr *) ((u32 *) ip + ip->ihl);
-                               chksum = &(tcp->check);
+                       if (ip->protocol == IPPROTO_TCP)
                                tcb->tcbu.ipcb.ip_schedule |= IPCB_TCP_PACKET;
-                       } else {
-                               struct udphdr *udp;
-
-                               udp = (struct udphdr *) ((u32 *) ip + ip->ihl);
-                               chksum = &(udp->check);
-                       }
-
-                       *chksum = e100_pseudo_hdr_csum(ip);
                }
        }