diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/hamachi.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/hamachi.c')
-rw-r--r-- | drivers/net/hamachi.c | 84 |
1 files changed, 3 insertions, 81 deletions
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index 49aac7027fbb..a09041aa8509 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c | |||
@@ -132,13 +132,8 @@ static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; | |||
132 | /* | 132 | /* |
133 | * RX_CHECKSUM turns on card-generated receive checksum generation for | 133 | * RX_CHECKSUM turns on card-generated receive checksum generation for |
134 | * TCP and UDP packets. Otherwise the upper layers do the calculation. | 134 | * TCP and UDP packets. Otherwise the upper layers do the calculation. |
135 | * TX_CHECKSUM won't do anything too useful, even if it works. There's no | ||
136 | * easy mechanism by which to tell the TCP/UDP stack that it need not | ||
137 | * generate checksums for this device. But if somebody can find a way | ||
138 | * to get that to work, most of the card work is in here already. | ||
139 | * 3/10/1999 Pete Wyckoff <wyckoff@ca.sandia.gov> | 135 | * 3/10/1999 Pete Wyckoff <wyckoff@ca.sandia.gov> |
140 | */ | 136 | */ |
141 | #undef TX_CHECKSUM | ||
142 | #define RX_CHECKSUM | 137 | #define RX_CHECKSUM |
143 | 138 | ||
144 | /* Operational parameters that usually are not changed. */ | 139 | /* Operational parameters that usually are not changed. */ |
@@ -630,11 +625,6 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev, | |||
630 | 625 | ||
631 | SET_NETDEV_DEV(dev, &pdev->dev); | 626 | SET_NETDEV_DEV(dev, &pdev->dev); |
632 | 627 | ||
633 | #ifdef TX_CHECKSUM | ||
634 | printk("check that skbcopy in ip_queue_xmit isn't happening\n"); | ||
635 | dev->hard_header_len += 8; /* for cksum tag */ | ||
636 | #endif | ||
637 | |||
638 | for (i = 0; i < 6; i++) | 628 | for (i = 0; i < 6; i++) |
639 | dev->dev_addr[i] = 1 ? read_eeprom(ioaddr, 4 + i) | 629 | dev->dev_addr[i] = 1 ? read_eeprom(ioaddr, 4 + i) |
640 | : readb(ioaddr + StationAddr + i); | 630 | : readb(ioaddr + StationAddr + i); |
@@ -937,11 +927,7 @@ static int hamachi_open(struct net_device *dev) | |||
937 | 927 | ||
938 | /* always 1, takes no more time to do it */ | 928 | /* always 1, takes no more time to do it */ |
939 | writew(0x0001, ioaddr + RxChecksum); | 929 | writew(0x0001, ioaddr + RxChecksum); |
940 | #ifdef TX_CHECKSUM | ||
941 | writew(0x0001, ioaddr + TxChecksum); | ||
942 | #else | ||
943 | writew(0x0000, ioaddr + TxChecksum); | 930 | writew(0x0000, ioaddr + TxChecksum); |
944 | #endif | ||
945 | writew(0x8000, ioaddr + MACCnfg); /* Soft reset the MAC */ | 931 | writew(0x8000, ioaddr + MACCnfg); /* Soft reset the MAC */ |
946 | writew(0x215F, ioaddr + MACCnfg); | 932 | writew(0x215F, ioaddr + MACCnfg); |
947 | writew(0x000C, ioaddr + FrameGap0); | 933 | writew(0x000C, ioaddr + FrameGap0); |
@@ -1004,7 +990,7 @@ static int hamachi_open(struct net_device *dev) | |||
1004 | init_timer(&hmp->timer); | 990 | init_timer(&hmp->timer); |
1005 | hmp->timer.expires = RUN_AT((24*HZ)/10); /* 2.4 sec. */ | 991 | hmp->timer.expires = RUN_AT((24*HZ)/10); /* 2.4 sec. */ |
1006 | hmp->timer.data = (unsigned long)dev; | 992 | hmp->timer.data = (unsigned long)dev; |
1007 | hmp->timer.function = &hamachi_timer; /* timer handler */ | 993 | hmp->timer.function = hamachi_timer; /* timer handler */ |
1008 | add_timer(&hmp->timer); | 994 | add_timer(&hmp->timer); |
1009 | 995 | ||
1010 | return 0; | 996 | return 0; |
@@ -1202,7 +1188,7 @@ static void hamachi_init_ring(struct net_device *dev) | |||
1202 | } | 1188 | } |
1203 | /* Fill in the Rx buffers. Handle allocation failure gracefully. */ | 1189 | /* Fill in the Rx buffers. Handle allocation failure gracefully. */ |
1204 | for (i = 0; i < RX_RING_SIZE; i++) { | 1190 | for (i = 0; i < RX_RING_SIZE; i++) { |
1205 | struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz); | 1191 | struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); |
1206 | hmp->rx_skbuff[i] = skb; | 1192 | hmp->rx_skbuff[i] = skb; |
1207 | if (skb == NULL) | 1193 | if (skb == NULL) |
1208 | break; | 1194 | break; |
@@ -1226,40 +1212,6 @@ static void hamachi_init_ring(struct net_device *dev) | |||
1226 | } | 1212 | } |
1227 | 1213 | ||
1228 | 1214 | ||
1229 | #ifdef TX_CHECKSUM | ||
1230 | #define csum_add(it, val) \ | ||
1231 | do { \ | ||
1232 | it += (u16) (val); \ | ||
1233 | if (it & 0xffff0000) { \ | ||
1234 | it &= 0xffff; \ | ||
1235 | ++it; \ | ||
1236 | } \ | ||
1237 | } while (0) | ||
1238 | /* printk("add %04x --> %04x\n", val, it); \ */ | ||
1239 | |||
1240 | /* uh->len already network format, do not swap */ | ||
1241 | #define pseudo_csum_udp(sum,ih,uh) do { \ | ||
1242 | sum = 0; \ | ||
1243 | csum_add(sum, (ih)->saddr >> 16); \ | ||
1244 | csum_add(sum, (ih)->saddr & 0xffff); \ | ||
1245 | csum_add(sum, (ih)->daddr >> 16); \ | ||
1246 | csum_add(sum, (ih)->daddr & 0xffff); \ | ||
1247 | csum_add(sum, cpu_to_be16(IPPROTO_UDP)); \ | ||
1248 | csum_add(sum, (uh)->len); \ | ||
1249 | } while (0) | ||
1250 | |||
1251 | /* swap len */ | ||
1252 | #define pseudo_csum_tcp(sum,ih,len) do { \ | ||
1253 | sum = 0; \ | ||
1254 | csum_add(sum, (ih)->saddr >> 16); \ | ||
1255 | csum_add(sum, (ih)->saddr & 0xffff); \ | ||
1256 | csum_add(sum, (ih)->daddr >> 16); \ | ||
1257 | csum_add(sum, (ih)->daddr & 0xffff); \ | ||
1258 | csum_add(sum, cpu_to_be16(IPPROTO_TCP)); \ | ||
1259 | csum_add(sum, htons(len)); \ | ||
1260 | } while (0) | ||
1261 | #endif | ||
1262 | |||
1263 | static netdev_tx_t hamachi_start_xmit(struct sk_buff *skb, | 1215 | static netdev_tx_t hamachi_start_xmit(struct sk_buff *skb, |
1264 | struct net_device *dev) | 1216 | struct net_device *dev) |
1265 | { | 1217 | { |
@@ -1292,36 +1244,6 @@ static netdev_tx_t hamachi_start_xmit(struct sk_buff *skb, | |||
1292 | 1244 | ||
1293 | hmp->tx_skbuff[entry] = skb; | 1245 | hmp->tx_skbuff[entry] = skb; |
1294 | 1246 | ||
1295 | #ifdef TX_CHECKSUM | ||
1296 | { | ||
1297 | /* tack on checksum tag */ | ||
1298 | u32 tagval = 0; | ||
1299 | struct ethhdr *eh = (struct ethhdr *)skb->data; | ||
1300 | if (eh->h_proto == cpu_to_be16(ETH_P_IP)) { | ||
1301 | struct iphdr *ih = (struct iphdr *)((char *)eh + ETH_HLEN); | ||
1302 | if (ih->protocol == IPPROTO_UDP) { | ||
1303 | struct udphdr *uh | ||
1304 | = (struct udphdr *)((char *)ih + ih->ihl*4); | ||
1305 | u32 offset = ((unsigned char *)uh + 6) - skb->data; | ||
1306 | u32 pseudo; | ||
1307 | pseudo_csum_udp(pseudo, ih, uh); | ||
1308 | pseudo = htons(pseudo); | ||
1309 | printk("udp cksum was %04x, sending pseudo %04x\n", | ||
1310 | uh->check, pseudo); | ||
1311 | uh->check = 0; /* zero out uh->check before card calc */ | ||
1312 | /* | ||
1313 | * start at 14 (skip ethhdr), store at offset (uh->check), | ||
1314 | * use pseudo value given. | ||
1315 | */ | ||
1316 | tagval = (14 << 24) | (offset << 16) | pseudo; | ||
1317 | } else if (ih->protocol == IPPROTO_TCP) { | ||
1318 | printk("tcp, no auto cksum\n"); | ||
1319 | } | ||
1320 | } | ||
1321 | *(u32 *)skb_push(skb, 8) = tagval; | ||
1322 | } | ||
1323 | #endif | ||
1324 | |||
1325 | hmp->tx_ring[entry].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, | 1247 | hmp->tx_ring[entry].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, |
1326 | skb->data, skb->len, PCI_DMA_TODEVICE)); | 1248 | skb->data, skb->len, PCI_DMA_TODEVICE)); |
1327 | 1249 | ||
@@ -1669,7 +1591,7 @@ static int hamachi_rx(struct net_device *dev) | |||
1669 | entry = hmp->dirty_rx % RX_RING_SIZE; | 1591 | entry = hmp->dirty_rx % RX_RING_SIZE; |
1670 | desc = &(hmp->rx_ring[entry]); | 1592 | desc = &(hmp->rx_ring[entry]); |
1671 | if (hmp->rx_skbuff[entry] == NULL) { | 1593 | if (hmp->rx_skbuff[entry] == NULL) { |
1672 | struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz); | 1594 | struct sk_buff *skb = dev_alloc_skb(hmp->rx_buf_sz + 2); |
1673 | 1595 | ||
1674 | hmp->rx_skbuff[entry] = skb; | 1596 | hmp->rx_skbuff[entry] = skb; |
1675 | if (skb == NULL) | 1597 | if (skb == NULL) |