diff options
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r-- | drivers/net/tg3.c | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 256969e1300c..9488f49ea569 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -40,16 +40,16 @@ | |||
40 | #include <linux/dma-mapping.h> | 40 | #include <linux/dma-mapping.h> |
41 | 41 | ||
42 | #include <net/checksum.h> | 42 | #include <net/checksum.h> |
43 | #include <net/ip.h> | ||
43 | 44 | ||
44 | #include <asm/system.h> | 45 | #include <asm/system.h> |
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include <asm/byteorder.h> | 47 | #include <asm/byteorder.h> |
47 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
48 | 49 | ||
49 | #ifdef CONFIG_SPARC64 | 50 | #ifdef CONFIG_SPARC |
50 | #include <asm/idprom.h> | 51 | #include <asm/idprom.h> |
51 | #include <asm/oplib.h> | 52 | #include <asm/prom.h> |
52 | #include <asm/pbm.h> | ||
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 55 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
@@ -3349,7 +3349,7 @@ static int tg3_rx(struct tg3 *tp, int budget) | |||
3349 | skb_reserve(copy_skb, 2); | 3349 | skb_reserve(copy_skb, 2); |
3350 | skb_put(copy_skb, len); | 3350 | skb_put(copy_skb, len); |
3351 | pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); | 3351 | pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); |
3352 | memcpy(copy_skb->data, skb->data, len); | 3352 | skb_copy_from_linear_data(skb, copy_skb->data, len); |
3353 | pci_dma_sync_single_for_device(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); | 3353 | pci_dma_sync_single_for_device(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); |
3354 | 3354 | ||
3355 | /* We'll reuse the original ring buffer. */ | 3355 | /* We'll reuse the original ring buffer. */ |
@@ -3908,20 +3908,20 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3908 | if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) | 3908 | if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) |
3909 | mss |= (skb_headlen(skb) - ETH_HLEN) << 9; | 3909 | mss |= (skb_headlen(skb) - ETH_HLEN) << 9; |
3910 | else { | 3910 | else { |
3911 | tcp_opt_len = ((skb->h.th->doff - 5) * 4); | 3911 | struct iphdr *iph = ip_hdr(skb); |
3912 | ip_tcp_len = (skb->nh.iph->ihl * 4) + | 3912 | |
3913 | sizeof(struct tcphdr); | 3913 | tcp_opt_len = tcp_optlen(skb); |
3914 | ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); | ||
3914 | 3915 | ||
3915 | skb->nh.iph->check = 0; | 3916 | iph->check = 0; |
3916 | skb->nh.iph->tot_len = htons(mss + ip_tcp_len + | 3917 | iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); |
3917 | tcp_opt_len); | ||
3918 | mss |= (ip_tcp_len + tcp_opt_len) << 9; | 3918 | mss |= (ip_tcp_len + tcp_opt_len) << 9; |
3919 | } | 3919 | } |
3920 | 3920 | ||
3921 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | | 3921 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | |
3922 | TXD_FLAG_CPU_POST_DMA); | 3922 | TXD_FLAG_CPU_POST_DMA); |
3923 | 3923 | ||
3924 | skb->h.th->check = 0; | 3924 | tcp_hdr(skb)->check = 0; |
3925 | 3925 | ||
3926 | } | 3926 | } |
3927 | else if (skb->ip_summed == CHECKSUM_PARTIAL) | 3927 | else if (skb->ip_summed == CHECKSUM_PARTIAL) |
@@ -4055,6 +4055,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev) | |||
4055 | mss = 0; | 4055 | mss = 0; |
4056 | if (skb->len > (tp->dev->mtu + ETH_HLEN) && | 4056 | if (skb->len > (tp->dev->mtu + ETH_HLEN) && |
4057 | (mss = skb_shinfo(skb)->gso_size) != 0) { | 4057 | (mss = skb_shinfo(skb)->gso_size) != 0) { |
4058 | struct iphdr *iph; | ||
4058 | int tcp_opt_len, ip_tcp_len, hdr_len; | 4059 | int tcp_opt_len, ip_tcp_len, hdr_len; |
4059 | 4060 | ||
4060 | if (skb_header_cloned(skb) && | 4061 | if (skb_header_cloned(skb) && |
@@ -4063,8 +4064,8 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev) | |||
4063 | goto out_unlock; | 4064 | goto out_unlock; |
4064 | } | 4065 | } |
4065 | 4066 | ||
4066 | tcp_opt_len = ((skb->h.th->doff - 5) * 4); | 4067 | tcp_opt_len = tcp_optlen(skb); |
4067 | ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); | 4068 | ip_tcp_len = ip_hdrlen(skb) + sizeof(struct tcphdr); |
4068 | 4069 | ||
4069 | hdr_len = ip_tcp_len + tcp_opt_len; | 4070 | hdr_len = ip_tcp_len + tcp_opt_len; |
4070 | if (unlikely((ETH_HLEN + hdr_len) > 80) && | 4071 | if (unlikely((ETH_HLEN + hdr_len) > 80) && |
@@ -4074,34 +4075,31 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev) | |||
4074 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | | 4075 | base_flags |= (TXD_FLAG_CPU_PRE_DMA | |
4075 | TXD_FLAG_CPU_POST_DMA); | 4076 | TXD_FLAG_CPU_POST_DMA); |
4076 | 4077 | ||
4077 | skb->nh.iph->check = 0; | 4078 | iph = ip_hdr(skb); |
4078 | skb->nh.iph->tot_len = htons(mss + hdr_len); | 4079 | iph->check = 0; |
4080 | iph->tot_len = htons(mss + hdr_len); | ||
4079 | if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { | 4081 | if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { |
4080 | skb->h.th->check = 0; | 4082 | tcp_hdr(skb)->check = 0; |
4081 | base_flags &= ~TXD_FLAG_TCPUDP_CSUM; | 4083 | base_flags &= ~TXD_FLAG_TCPUDP_CSUM; |
4082 | } | 4084 | } else |
4083 | else { | 4085 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, |
4084 | skb->h.th->check = | 4086 | iph->daddr, 0, |
4085 | ~csum_tcpudp_magic(skb->nh.iph->saddr, | 4087 | IPPROTO_TCP, |
4086 | skb->nh.iph->daddr, | 4088 | 0); |
4087 | 0, IPPROTO_TCP, 0); | ||
4088 | } | ||
4089 | 4089 | ||
4090 | if ((tp->tg3_flags2 & TG3_FLG2_HW_TSO) || | 4090 | if ((tp->tg3_flags2 & TG3_FLG2_HW_TSO) || |
4091 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) { | 4091 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) { |
4092 | if (tcp_opt_len || skb->nh.iph->ihl > 5) { | 4092 | if (tcp_opt_len || iph->ihl > 5) { |
4093 | int tsflags; | 4093 | int tsflags; |
4094 | 4094 | ||
4095 | tsflags = ((skb->nh.iph->ihl - 5) + | 4095 | tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2); |
4096 | (tcp_opt_len >> 2)); | ||
4097 | mss |= (tsflags << 11); | 4096 | mss |= (tsflags << 11); |
4098 | } | 4097 | } |
4099 | } else { | 4098 | } else { |
4100 | if (tcp_opt_len || skb->nh.iph->ihl > 5) { | 4099 | if (tcp_opt_len || iph->ihl > 5) { |
4101 | int tsflags; | 4100 | int tsflags; |
4102 | 4101 | ||
4103 | tsflags = ((skb->nh.iph->ihl - 5) + | 4102 | tsflags = (iph->ihl - 5) + (tcp_opt_len >> 2); |
4104 | (tcp_opt_len >> 2)); | ||
4105 | base_flags |= tsflags << 12; | 4103 | base_flags |= tsflags << 12; |
4106 | } | 4104 | } |
4107 | } | 4105 | } |
@@ -10988,24 +10986,20 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10988 | return err; | 10986 | return err; |
10989 | } | 10987 | } |
10990 | 10988 | ||
10991 | #ifdef CONFIG_SPARC64 | 10989 | #ifdef CONFIG_SPARC |
10992 | static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp) | 10990 | static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp) |
10993 | { | 10991 | { |
10994 | struct net_device *dev = tp->dev; | 10992 | struct net_device *dev = tp->dev; |
10995 | struct pci_dev *pdev = tp->pdev; | 10993 | struct pci_dev *pdev = tp->pdev; |
10996 | struct pcidev_cookie *pcp = pdev->sysdata; | 10994 | struct device_node *dp = pci_device_to_OF_node(pdev); |
10997 | 10995 | const unsigned char *addr; | |
10998 | if (pcp != NULL) { | 10996 | int len; |
10999 | unsigned char *addr; | 10997 | |
11000 | int len; | 10998 | addr = of_get_property(dp, "local-mac-address", &len); |
11001 | 10999 | if (addr && len == 6) { | |
11002 | addr = of_get_property(pcp->prom_node, "local-mac-address", | 11000 | memcpy(dev->dev_addr, addr, 6); |
11003 | &len); | 11001 | memcpy(dev->perm_addr, dev->dev_addr, 6); |
11004 | if (addr && len == 6) { | 11002 | return 0; |
11005 | memcpy(dev->dev_addr, addr, 6); | ||
11006 | memcpy(dev->perm_addr, dev->dev_addr, 6); | ||
11007 | return 0; | ||
11008 | } | ||
11009 | } | 11003 | } |
11010 | return -ENODEV; | 11004 | return -ENODEV; |
11011 | } | 11005 | } |
@@ -11026,7 +11020,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp) | |||
11026 | u32 hi, lo, mac_offset; | 11020 | u32 hi, lo, mac_offset; |
11027 | int addr_ok = 0; | 11021 | int addr_ok = 0; |
11028 | 11022 | ||
11029 | #ifdef CONFIG_SPARC64 | 11023 | #ifdef CONFIG_SPARC |
11030 | if (!tg3_get_macaddr_sparc(tp)) | 11024 | if (!tg3_get_macaddr_sparc(tp)) |
11031 | return 0; | 11025 | return 0; |
11032 | #endif | 11026 | #endif |