diff options
author | Ayaz Abdulla <aabdulla@nvidia.com> | 2005-10-26 00:51:24 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-26 00:51:24 -0400 |
commit | ac9c18974f7d08cdedfb1e9599faa8c851c7cef9 (patch) | |
tree | 802058729c3d2401ec73c580c670d8b924b17954 /drivers/net | |
parent | 9789089703c244ad766a13f441936736b6b1e709 (diff) |
[netdrvr forcedeth] scatter gather and segmentation offload support
also:
- eliminate use of pointless get_nvpriv() wrapper,
and use netdev_priv() directly.
- use NETDEV_TX_xxx return codes
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/forcedeth.c | 249 |
1 files changed, 162 insertions, 87 deletions
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index e5f480203675..22aec6ed80f5 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -96,6 +96,7 @@ | |||
96 | * 0.42: 06 Aug 2005: Fix lack of link speed initialization | 96 | * 0.42: 06 Aug 2005: Fix lack of link speed initialization |
97 | * in the second (and later) nv_open call | 97 | * in the second (and later) nv_open call |
98 | * 0.43: 10 Aug 2005: Add support for tx checksum. | 98 | * 0.43: 10 Aug 2005: Add support for tx checksum. |
99 | * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation. | ||
99 | * | 100 | * |
100 | * Known bugs: | 101 | * Known bugs: |
101 | * We suspect that on some hardware no TX done interrupts are generated. | 102 | * We suspect that on some hardware no TX done interrupts are generated. |
@@ -107,7 +108,7 @@ | |||
107 | * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few | 108 | * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few |
108 | * superfluous timer interrupts from the nic. | 109 | * superfluous timer interrupts from the nic. |
109 | */ | 110 | */ |
110 | #define FORCEDETH_VERSION "0.43" | 111 | #define FORCEDETH_VERSION "0.44" |
111 | #define DRV_NAME "forcedeth" | 112 | #define DRV_NAME "forcedeth" |
112 | 113 | ||
113 | #include <linux/module.h> | 114 | #include <linux/module.h> |
@@ -340,6 +341,8 @@ typedef union _ring_type { | |||
340 | /* error and valid are the same for both */ | 341 | /* error and valid are the same for both */ |
341 | #define NV_TX2_ERROR (1<<30) | 342 | #define NV_TX2_ERROR (1<<30) |
342 | #define NV_TX2_VALID (1<<31) | 343 | #define NV_TX2_VALID (1<<31) |
344 | #define NV_TX2_TSO (1<<28) | ||
345 | #define NV_TX2_TSO_SHIFT 14 | ||
343 | #define NV_TX2_CHECKSUM_L3 (1<<27) | 346 | #define NV_TX2_CHECKSUM_L3 (1<<27) |
344 | #define NV_TX2_CHECKSUM_L4 (1<<26) | 347 | #define NV_TX2_CHECKSUM_L4 (1<<26) |
345 | 348 | ||
@@ -542,7 +545,7 @@ static inline struct fe_priv *get_nvpriv(struct net_device *dev) | |||
542 | 545 | ||
543 | static inline u8 __iomem *get_hwbase(struct net_device *dev) | 546 | static inline u8 __iomem *get_hwbase(struct net_device *dev) |
544 | { | 547 | { |
545 | return get_nvpriv(dev)->base; | 548 | return ((struct fe_priv *)netdev_priv(dev))->base; |
546 | } | 549 | } |
547 | 550 | ||
548 | static inline void pci_push(u8 __iomem *base) | 551 | static inline void pci_push(u8 __iomem *base) |
@@ -631,7 +634,7 @@ static int mii_rw(struct net_device *dev, int addr, int miireg, int value) | |||
631 | 634 | ||
632 | static int phy_reset(struct net_device *dev) | 635 | static int phy_reset(struct net_device *dev) |
633 | { | 636 | { |
634 | struct fe_priv *np = get_nvpriv(dev); | 637 | struct fe_priv *np = netdev_priv(dev); |
635 | u32 miicontrol; | 638 | u32 miicontrol; |
636 | unsigned int tries = 0; | 639 | unsigned int tries = 0; |
637 | 640 | ||
@@ -734,7 +737,7 @@ static int phy_init(struct net_device *dev) | |||
734 | 737 | ||
735 | static void nv_start_rx(struct net_device *dev) | 738 | static void nv_start_rx(struct net_device *dev) |
736 | { | 739 | { |
737 | struct fe_priv *np = get_nvpriv(dev); | 740 | struct fe_priv *np = netdev_priv(dev); |
738 | u8 __iomem *base = get_hwbase(dev); | 741 | u8 __iomem *base = get_hwbase(dev); |
739 | 742 | ||
740 | dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name); | 743 | dprintk(KERN_DEBUG "%s: nv_start_rx\n", dev->name); |
@@ -790,7 +793,7 @@ static void nv_stop_tx(struct net_device *dev) | |||
790 | 793 | ||
791 | static void nv_txrx_reset(struct net_device *dev) | 794 | static void nv_txrx_reset(struct net_device *dev) |
792 | { | 795 | { |
793 | struct fe_priv *np = get_nvpriv(dev); | 796 | struct fe_priv *np = netdev_priv(dev); |
794 | u8 __iomem *base = get_hwbase(dev); | 797 | u8 __iomem *base = get_hwbase(dev); |
795 | 798 | ||
796 | dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name); | 799 | dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name); |
@@ -809,7 +812,7 @@ static void nv_txrx_reset(struct net_device *dev) | |||
809 | */ | 812 | */ |
810 | static struct net_device_stats *nv_get_stats(struct net_device *dev) | 813 | static struct net_device_stats *nv_get_stats(struct net_device *dev) |
811 | { | 814 | { |
812 | struct fe_priv *np = get_nvpriv(dev); | 815 | struct fe_priv *np = netdev_priv(dev); |
813 | 816 | ||
814 | /* It seems that the nic always generates interrupts and doesn't | 817 | /* It seems that the nic always generates interrupts and doesn't |
815 | * accumulate errors internally. Thus the current values in np->stats | 818 | * accumulate errors internally. Thus the current values in np->stats |
@@ -825,7 +828,7 @@ static struct net_device_stats *nv_get_stats(struct net_device *dev) | |||
825 | */ | 828 | */ |
826 | static int nv_alloc_rx(struct net_device *dev) | 829 | static int nv_alloc_rx(struct net_device *dev) |
827 | { | 830 | { |
828 | struct fe_priv *np = get_nvpriv(dev); | 831 | struct fe_priv *np = netdev_priv(dev); |
829 | unsigned int refill_rx = np->refill_rx; | 832 | unsigned int refill_rx = np->refill_rx; |
830 | int nr; | 833 | int nr; |
831 | 834 | ||
@@ -869,7 +872,7 @@ static int nv_alloc_rx(struct net_device *dev) | |||
869 | static void nv_do_rx_refill(unsigned long data) | 872 | static void nv_do_rx_refill(unsigned long data) |
870 | { | 873 | { |
871 | struct net_device *dev = (struct net_device *) data; | 874 | struct net_device *dev = (struct net_device *) data; |
872 | struct fe_priv *np = get_nvpriv(dev); | 875 | struct fe_priv *np = netdev_priv(dev); |
873 | 876 | ||
874 | disable_irq(dev->irq); | 877 | disable_irq(dev->irq); |
875 | if (nv_alloc_rx(dev)) { | 878 | if (nv_alloc_rx(dev)) { |
@@ -883,7 +886,7 @@ static void nv_do_rx_refill(unsigned long data) | |||
883 | 886 | ||
884 | static void nv_init_rx(struct net_device *dev) | 887 | static void nv_init_rx(struct net_device *dev) |
885 | { | 888 | { |
886 | struct fe_priv *np = get_nvpriv(dev); | 889 | struct fe_priv *np = netdev_priv(dev); |
887 | int i; | 890 | int i; |
888 | 891 | ||
889 | np->cur_rx = RX_RING; | 892 | np->cur_rx = RX_RING; |
@@ -897,15 +900,17 @@ static void nv_init_rx(struct net_device *dev) | |||
897 | 900 | ||
898 | static void nv_init_tx(struct net_device *dev) | 901 | static void nv_init_tx(struct net_device *dev) |
899 | { | 902 | { |
900 | struct fe_priv *np = get_nvpriv(dev); | 903 | struct fe_priv *np = netdev_priv(dev); |
901 | int i; | 904 | int i; |
902 | 905 | ||
903 | np->next_tx = np->nic_tx = 0; | 906 | np->next_tx = np->nic_tx = 0; |
904 | for (i = 0; i < TX_RING; i++) | 907 | for (i = 0; i < TX_RING; i++) { |
905 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) | 908 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) |
906 | np->tx_ring.orig[i].FlagLen = 0; | 909 | np->tx_ring.orig[i].FlagLen = 0; |
907 | else | 910 | else |
908 | np->tx_ring.ex[i].FlagLen = 0; | 911 | np->tx_ring.ex[i].FlagLen = 0; |
912 | np->tx_skbuff[i] = NULL; | ||
913 | } | ||
909 | } | 914 | } |
910 | 915 | ||
911 | static int nv_init_ring(struct net_device *dev) | 916 | static int nv_init_ring(struct net_device *dev) |
@@ -915,21 +920,44 @@ static int nv_init_ring(struct net_device *dev) | |||
915 | return nv_alloc_rx(dev); | 920 | return nv_alloc_rx(dev); |
916 | } | 921 | } |
917 | 922 | ||
923 | static void nv_release_txskb(struct net_device *dev, unsigned int skbnr) | ||
924 | { | ||
925 | struct fe_priv *np = netdev_priv(dev); | ||
926 | struct sk_buff *skb = np->tx_skbuff[skbnr]; | ||
927 | unsigned int j, entry, fragments; | ||
928 | |||
929 | dprintk(KERN_INFO "%s: nv_release_txskb for skbnr %d, skb %p\n", | ||
930 | dev->name, skbnr, np->tx_skbuff[skbnr]); | ||
931 | |||
932 | entry = skbnr; | ||
933 | if ((fragments = skb_shinfo(skb)->nr_frags) != 0) { | ||
934 | for (j = fragments; j >= 1; j--) { | ||
935 | skb_frag_t *frag = &skb_shinfo(skb)->frags[j-1]; | ||
936 | pci_unmap_page(np->pci_dev, np->tx_dma[entry], | ||
937 | frag->size, | ||
938 | PCI_DMA_TODEVICE); | ||
939 | entry = (entry - 1) % TX_RING; | ||
940 | } | ||
941 | } | ||
942 | pci_unmap_single(np->pci_dev, np->tx_dma[entry], | ||
943 | skb->len - skb->data_len, | ||
944 | PCI_DMA_TODEVICE); | ||
945 | dev_kfree_skb_irq(skb); | ||
946 | np->tx_skbuff[skbnr] = NULL; | ||
947 | } | ||
948 | |||
918 | static void nv_drain_tx(struct net_device *dev) | 949 | static void nv_drain_tx(struct net_device *dev) |
919 | { | 950 | { |
920 | struct fe_priv *np = get_nvpriv(dev); | 951 | struct fe_priv *np = netdev_priv(dev); |
921 | int i; | 952 | unsigned int i; |
953 | |||
922 | for (i = 0; i < TX_RING; i++) { | 954 | for (i = 0; i < TX_RING; i++) { |
923 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) | 955 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) |
924 | np->tx_ring.orig[i].FlagLen = 0; | 956 | np->tx_ring.orig[i].FlagLen = 0; |
925 | else | 957 | else |
926 | np->tx_ring.ex[i].FlagLen = 0; | 958 | np->tx_ring.ex[i].FlagLen = 0; |
927 | if (np->tx_skbuff[i]) { | 959 | if (np->tx_skbuff[i]) { |
928 | pci_unmap_single(np->pci_dev, np->tx_dma[i], | 960 | nv_release_txskb(dev, i); |
929 | np->tx_skbuff[i]->len, | ||
930 | PCI_DMA_TODEVICE); | ||
931 | dev_kfree_skb(np->tx_skbuff[i]); | ||
932 | np->tx_skbuff[i] = NULL; | ||
933 | np->stats.tx_dropped++; | 961 | np->stats.tx_dropped++; |
934 | } | 962 | } |
935 | } | 963 | } |
@@ -937,7 +965,7 @@ static void nv_drain_tx(struct net_device *dev) | |||
937 | 965 | ||
938 | static void nv_drain_rx(struct net_device *dev) | 966 | static void nv_drain_rx(struct net_device *dev) |
939 | { | 967 | { |
940 | struct fe_priv *np = get_nvpriv(dev); | 968 | struct fe_priv *np = netdev_priv(dev); |
941 | int i; | 969 | int i; |
942 | for (i = 0; i < RX_RING; i++) { | 970 | for (i = 0; i < RX_RING; i++) { |
943 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) | 971 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) |
@@ -967,29 +995,69 @@ static void drain_ring(struct net_device *dev) | |||
967 | */ | 995 | */ |
968 | static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) | 996 | static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) |
969 | { | 997 | { |
970 | struct fe_priv *np = get_nvpriv(dev); | 998 | struct fe_priv *np = netdev_priv(dev); |
971 | int nr = np->next_tx % TX_RING; | 999 | u32 tx_flags_extra = (np->desc_ver == DESC_VER_1 ? NV_TX_LASTPACKET : NV_TX2_LASTPACKET); |
972 | u32 tx_checksum = (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0); | 1000 | unsigned int fragments = skb_shinfo(skb)->nr_frags; |
1001 | unsigned int nr = (np->next_tx + fragments) % TX_RING; | ||
1002 | unsigned int i; | ||
1003 | |||
1004 | spin_lock_irq(&np->lock); | ||
1005 | |||
1006 | if ((np->next_tx - np->nic_tx + fragments) > TX_LIMIT_STOP) { | ||
1007 | spin_unlock_irq(&np->lock); | ||
1008 | netif_stop_queue(dev); | ||
1009 | return NETDEV_TX_BUSY; | ||
1010 | } | ||
973 | 1011 | ||
974 | np->tx_skbuff[nr] = skb; | 1012 | np->tx_skbuff[nr] = skb; |
975 | np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len, | 1013 | |
976 | PCI_DMA_TODEVICE); | 1014 | if (fragments) { |
1015 | dprintk(KERN_DEBUG "%s: nv_start_xmit: buffer contains %d fragments\n", dev->name, fragments); | ||
1016 | /* setup descriptors in reverse order */ | ||
1017 | for (i = fragments; i >= 1; i--) { | ||
1018 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i-1]; | ||
1019 | np->tx_dma[nr] = pci_map_page(np->pci_dev, frag->page, frag->page_offset, frag->size, | ||
1020 | PCI_DMA_TODEVICE); | ||
977 | 1021 | ||
978 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) | 1022 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { |
1023 | np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); | ||
1024 | np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (frag->size-1) | np->tx_flags | tx_flags_extra); | ||
1025 | } else { | ||
1026 | np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32; | ||
1027 | np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF; | ||
1028 | np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (frag->size-1) | np->tx_flags | tx_flags_extra); | ||
1029 | } | ||
1030 | |||
1031 | nr = (nr - 1) % TX_RING; | ||
1032 | |||
1033 | if (np->desc_ver == DESC_VER_1) | ||
1034 | tx_flags_extra &= ~NV_TX_LASTPACKET; | ||
1035 | else | ||
1036 | tx_flags_extra &= ~NV_TX2_LASTPACKET; | ||
1037 | } | ||
1038 | } | ||
1039 | |||
1040 | #ifdef NETIF_F_TSO | ||
1041 | if (skb_shinfo(skb)->tso_size) | ||
1042 | tx_flags_extra |= NV_TX2_TSO | (skb_shinfo(skb)->tso_size << NV_TX2_TSO_SHIFT); | ||
1043 | else | ||
1044 | #endif | ||
1045 | tx_flags_extra |= (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0); | ||
1046 | |||
1047 | np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len-skb->data_len, | ||
1048 | PCI_DMA_TODEVICE); | ||
1049 | |||
1050 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { | ||
979 | np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); | 1051 | np->tx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->tx_dma[nr]); |
980 | else { | 1052 | np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-skb->data_len-1) | np->tx_flags | tx_flags_extra); |
1053 | } else { | ||
981 | np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32; | 1054 | np->tx_ring.ex[nr].PacketBufferHigh = cpu_to_le64(np->tx_dma[nr]) >> 32; |
982 | np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF; | 1055 | np->tx_ring.ex[nr].PacketBufferLow = cpu_to_le64(np->tx_dma[nr]) & 0x0FFFFFFFF; |
983 | } | 1056 | np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-skb->data_len-1) | np->tx_flags | tx_flags_extra); |
1057 | } | ||
984 | 1058 | ||
985 | spin_lock_irq(&np->lock); | 1059 | dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission. tx_flags_extra: %x\n", |
986 | wmb(); | 1060 | dev->name, np->next_tx, tx_flags_extra); |
987 | if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) | ||
988 | np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags | tx_checksum); | ||
989 | else | ||
990 | np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags | tx_checksum); | ||
991 | dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission\n", | ||
992 | dev->name, np->next_tx); | ||
993 | { | 1061 | { |
994 | int j; | 1062 | int j; |
995 | for (j=0; j<64; j++) { | 1063 | for (j=0; j<64; j++) { |
@@ -1000,15 +1068,13 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1000 | dprintk("\n"); | 1068 | dprintk("\n"); |
1001 | } | 1069 | } |
1002 | 1070 | ||
1003 | np->next_tx++; | 1071 | np->next_tx += 1 + fragments; |
1004 | 1072 | ||
1005 | dev->trans_start = jiffies; | 1073 | dev->trans_start = jiffies; |
1006 | if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP) | ||
1007 | netif_stop_queue(dev); | ||
1008 | spin_unlock_irq(&np->lock); | 1074 | spin_unlock_irq(&np->lock); |
1009 | writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); | 1075 | writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl); |
1010 | pci_push(get_hwbase(dev)); | 1076 | pci_push(get_hwbase(dev)); |
1011 | return 0; | 1077 | return NETDEV_TX_OK; |
1012 | } | 1078 | } |
1013 | 1079 | ||
1014 | /* | 1080 | /* |
@@ -1018,9 +1084,10 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1018 | */ | 1084 | */ |
1019 | static void nv_tx_done(struct net_device *dev) | 1085 | static void nv_tx_done(struct net_device *dev) |
1020 | { | 1086 | { |
1021 | struct fe_priv *np = get_nvpriv(dev); | 1087 | struct fe_priv *np = netdev_priv(dev); |
1022 | u32 Flags; | 1088 | u32 Flags; |
1023 | int i; | 1089 | unsigned int i; |
1090 | struct sk_buff *skb; | ||
1024 | 1091 | ||
1025 | while (np->nic_tx != np->next_tx) { | 1092 | while (np->nic_tx != np->next_tx) { |
1026 | i = np->nic_tx % TX_RING; | 1093 | i = np->nic_tx % TX_RING; |
@@ -1035,35 +1102,38 @@ static void nv_tx_done(struct net_device *dev) | |||
1035 | if (Flags & NV_TX_VALID) | 1102 | if (Flags & NV_TX_VALID) |
1036 | break; | 1103 | break; |
1037 | if (np->desc_ver == DESC_VER_1) { | 1104 | if (np->desc_ver == DESC_VER_1) { |
1038 | if (Flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION| | 1105 | if (Flags & NV_TX_LASTPACKET) { |
1039 | NV_TX_UNDERFLOW|NV_TX_ERROR)) { | 1106 | skb = np->tx_skbuff[i]; |
1040 | if (Flags & NV_TX_UNDERFLOW) | 1107 | if (Flags & (NV_TX_RETRYERROR|NV_TX_CARRIERLOST|NV_TX_LATECOLLISION| |
1041 | np->stats.tx_fifo_errors++; | 1108 | NV_TX_UNDERFLOW|NV_TX_ERROR)) { |
1042 | if (Flags & NV_TX_CARRIERLOST) | 1109 | if (Flags & NV_TX_UNDERFLOW) |
1043 | np->stats.tx_carrier_errors++; | 1110 | np->stats.tx_fifo_errors++; |
1044 | np->stats.tx_errors++; | 1111 | if (Flags & NV_TX_CARRIERLOST) |
1045 | } else { | 1112 | np->stats.tx_carrier_errors++; |
1046 | np->stats.tx_packets++; | 1113 | np->stats.tx_errors++; |
1047 | np->stats.tx_bytes += np->tx_skbuff[i]->len; | 1114 | } else { |
1115 | np->stats.tx_packets++; | ||
1116 | np->stats.tx_bytes += skb->len; | ||
1117 | } | ||
1118 | nv_release_txskb(dev, i); | ||
1048 | } | 1119 | } |
1049 | } else { | 1120 | } else { |
1050 | if (Flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION| | 1121 | if (Flags & NV_TX2_LASTPACKET) { |
1051 | NV_TX2_UNDERFLOW|NV_TX2_ERROR)) { | 1122 | skb = np->tx_skbuff[i]; |
1052 | if (Flags & NV_TX2_UNDERFLOW) | 1123 | if (Flags & (NV_TX2_RETRYERROR|NV_TX2_CARRIERLOST|NV_TX2_LATECOLLISION| |
1053 | np->stats.tx_fifo_errors++; | 1124 | NV_TX2_UNDERFLOW|NV_TX2_ERROR)) { |
1054 | if (Flags & NV_TX2_CARRIERLOST) | 1125 | if (Flags & NV_TX2_UNDERFLOW) |
1055 | np->stats.tx_carrier_errors++; | 1126 | np->stats.tx_fifo_errors++; |
1056 | np->stats.tx_errors++; | 1127 | if (Flags & NV_TX2_CARRIERLOST) |
1057 | } else { | 1128 | np->stats.tx_carrier_errors++; |
1058 | np->stats.tx_packets++; | 1129 | np->stats.tx_errors++; |
1059 | np->stats.tx_bytes += np->tx_skbuff[i]->len; | 1130 | } else { |
1131 | np->stats.tx_packets++; | ||
1132 | np->stats.tx_bytes += skb->len; | ||
1133 | } | ||
1134 | nv_release_txskb(dev, i); | ||
1060 | } | 1135 | } |
1061 | } | 1136 | } |
1062 | pci_unmap_single(np->pci_dev, np->tx_dma[i], | ||
1063 | np->tx_skbuff[i]->len, | ||
1064 | PCI_DMA_TODEVICE); | ||
1065 | dev_kfree_skb_irq(np->tx_skbuff[i]); | ||
1066 | np->tx_skbuff[i] = NULL; | ||
1067 | np->nic_tx++; | 1137 | np->nic_tx++; |
1068 | } | 1138 | } |
1069 | if (np->next_tx - np->nic_tx < TX_LIMIT_START) | 1139 | if (np->next_tx - np->nic_tx < TX_LIMIT_START) |
@@ -1076,7 +1146,7 @@ static void nv_tx_done(struct net_device *dev) | |||
1076 | */ | 1146 | */ |
1077 | static void nv_tx_timeout(struct net_device *dev) | 1147 | static void nv_tx_timeout(struct net_device *dev) |
1078 | { | 1148 | { |
1079 | struct fe_priv *np = get_nvpriv(dev); | 1149 | struct fe_priv *np = netdev_priv(dev); |
1080 | u8 __iomem *base = get_hwbase(dev); | 1150 | u8 __iomem *base = get_hwbase(dev); |
1081 | 1151 | ||
1082 | printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name, | 1152 | printk(KERN_INFO "%s: Got tx_timeout. irq: %08x\n", dev->name, |
@@ -1209,7 +1279,7 @@ static int nv_getlen(struct net_device *dev, void *packet, int datalen) | |||
1209 | 1279 | ||
1210 | static void nv_rx_process(struct net_device *dev) | 1280 | static void nv_rx_process(struct net_device *dev) |
1211 | { | 1281 | { |
1212 | struct fe_priv *np = get_nvpriv(dev); | 1282 | struct fe_priv *np = netdev_priv(dev); |
1213 | u32 Flags; | 1283 | u32 Flags; |
1214 | 1284 | ||
1215 | for (;;) { | 1285 | for (;;) { |
@@ -1364,7 +1434,7 @@ static void set_bufsize(struct net_device *dev) | |||
1364 | */ | 1434 | */ |
1365 | static int nv_change_mtu(struct net_device *dev, int new_mtu) | 1435 | static int nv_change_mtu(struct net_device *dev, int new_mtu) |
1366 | { | 1436 | { |
1367 | struct fe_priv *np = get_nvpriv(dev); | 1437 | struct fe_priv *np = netdev_priv(dev); |
1368 | int old_mtu; | 1438 | int old_mtu; |
1369 | 1439 | ||
1370 | if (new_mtu < 64 || new_mtu > np->pkt_limit) | 1440 | if (new_mtu < 64 || new_mtu > np->pkt_limit) |
@@ -1449,7 +1519,7 @@ static void nv_copy_mac_to_hw(struct net_device *dev) | |||
1449 | */ | 1519 | */ |
1450 | static int nv_set_mac_address(struct net_device *dev, void *addr) | 1520 | static int nv_set_mac_address(struct net_device *dev, void *addr) |
1451 | { | 1521 | { |
1452 | struct fe_priv *np = get_nvpriv(dev); | 1522 | struct fe_priv *np = netdev_priv(dev); |
1453 | struct sockaddr *macaddr = (struct sockaddr*)addr; | 1523 | struct sockaddr *macaddr = (struct sockaddr*)addr; |
1454 | 1524 | ||
1455 | if(!is_valid_ether_addr(macaddr->sa_data)) | 1525 | if(!is_valid_ether_addr(macaddr->sa_data)) |
@@ -1484,7 +1554,7 @@ static int nv_set_mac_address(struct net_device *dev, void *addr) | |||
1484 | */ | 1554 | */ |
1485 | static void nv_set_multicast(struct net_device *dev) | 1555 | static void nv_set_multicast(struct net_device *dev) |
1486 | { | 1556 | { |
1487 | struct fe_priv *np = get_nvpriv(dev); | 1557 | struct fe_priv *np = netdev_priv(dev); |
1488 | u8 __iomem *base = get_hwbase(dev); | 1558 | u8 __iomem *base = get_hwbase(dev); |
1489 | u32 addr[2]; | 1559 | u32 addr[2]; |
1490 | u32 mask[2]; | 1560 | u32 mask[2]; |
@@ -1544,7 +1614,7 @@ static void nv_set_multicast(struct net_device *dev) | |||
1544 | 1614 | ||
1545 | static int nv_update_linkspeed(struct net_device *dev) | 1615 | static int nv_update_linkspeed(struct net_device *dev) |
1546 | { | 1616 | { |
1547 | struct fe_priv *np = get_nvpriv(dev); | 1617 | struct fe_priv *np = netdev_priv(dev); |
1548 | u8 __iomem *base = get_hwbase(dev); | 1618 | u8 __iomem *base = get_hwbase(dev); |
1549 | int adv, lpa; | 1619 | int adv, lpa; |
1550 | int newls = np->linkspeed; | 1620 | int newls = np->linkspeed; |
@@ -1714,7 +1784,7 @@ static void nv_link_irq(struct net_device *dev) | |||
1714 | static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs) | 1784 | static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs) |
1715 | { | 1785 | { |
1716 | struct net_device *dev = (struct net_device *) data; | 1786 | struct net_device *dev = (struct net_device *) data; |
1717 | struct fe_priv *np = get_nvpriv(dev); | 1787 | struct fe_priv *np = netdev_priv(dev); |
1718 | u8 __iomem *base = get_hwbase(dev); | 1788 | u8 __iomem *base = get_hwbase(dev); |
1719 | u32 events; | 1789 | u32 events; |
1720 | int i; | 1790 | int i; |
@@ -1786,7 +1856,7 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs) | |||
1786 | static void nv_do_nic_poll(unsigned long data) | 1856 | static void nv_do_nic_poll(unsigned long data) |
1787 | { | 1857 | { |
1788 | struct net_device *dev = (struct net_device *) data; | 1858 | struct net_device *dev = (struct net_device *) data; |
1789 | struct fe_priv *np = get_nvpriv(dev); | 1859 | struct fe_priv *np = netdev_priv(dev); |
1790 | u8 __iomem *base = get_hwbase(dev); | 1860 | u8 __iomem *base = get_hwbase(dev); |
1791 | 1861 | ||
1792 | disable_irq(dev->irq); | 1862 | disable_irq(dev->irq); |
@@ -1810,7 +1880,7 @@ static void nv_poll_controller(struct net_device *dev) | |||
1810 | 1880 | ||
1811 | static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1881 | static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1812 | { | 1882 | { |
1813 | struct fe_priv *np = get_nvpriv(dev); | 1883 | struct fe_priv *np = netdev_priv(dev); |
1814 | strcpy(info->driver, "forcedeth"); | 1884 | strcpy(info->driver, "forcedeth"); |
1815 | strcpy(info->version, FORCEDETH_VERSION); | 1885 | strcpy(info->version, FORCEDETH_VERSION); |
1816 | strcpy(info->bus_info, pci_name(np->pci_dev)); | 1886 | strcpy(info->bus_info, pci_name(np->pci_dev)); |
@@ -1818,7 +1888,7 @@ static void nv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | |||
1818 | 1888 | ||
1819 | static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) | 1889 | static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) |
1820 | { | 1890 | { |
1821 | struct fe_priv *np = get_nvpriv(dev); | 1891 | struct fe_priv *np = netdev_priv(dev); |
1822 | wolinfo->supported = WAKE_MAGIC; | 1892 | wolinfo->supported = WAKE_MAGIC; |
1823 | 1893 | ||
1824 | spin_lock_irq(&np->lock); | 1894 | spin_lock_irq(&np->lock); |
@@ -1829,7 +1899,7 @@ static void nv_get_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) | |||
1829 | 1899 | ||
1830 | static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) | 1900 | static int nv_set_wol(struct net_device *dev, struct ethtool_wolinfo *wolinfo) |
1831 | { | 1901 | { |
1832 | struct fe_priv *np = get_nvpriv(dev); | 1902 | struct fe_priv *np = netdev_priv(dev); |
1833 | u8 __iomem *base = get_hwbase(dev); | 1903 | u8 __iomem *base = get_hwbase(dev); |
1834 | 1904 | ||
1835 | spin_lock_irq(&np->lock); | 1905 | spin_lock_irq(&np->lock); |
@@ -2030,7 +2100,7 @@ static int nv_get_regs_len(struct net_device *dev) | |||
2030 | 2100 | ||
2031 | static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) | 2101 | static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) |
2032 | { | 2102 | { |
2033 | struct fe_priv *np = get_nvpriv(dev); | 2103 | struct fe_priv *np = netdev_priv(dev); |
2034 | u8 __iomem *base = get_hwbase(dev); | 2104 | u8 __iomem *base = get_hwbase(dev); |
2035 | u32 *rbuf = buf; | 2105 | u32 *rbuf = buf; |
2036 | int i; | 2106 | int i; |
@@ -2044,7 +2114,7 @@ static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void | |||
2044 | 2114 | ||
2045 | static int nv_nway_reset(struct net_device *dev) | 2115 | static int nv_nway_reset(struct net_device *dev) |
2046 | { | 2116 | { |
2047 | struct fe_priv *np = get_nvpriv(dev); | 2117 | struct fe_priv *np = netdev_priv(dev); |
2048 | int ret; | 2118 | int ret; |
2049 | 2119 | ||
2050 | spin_lock_irq(&np->lock); | 2120 | spin_lock_irq(&np->lock); |
@@ -2079,7 +2149,7 @@ static struct ethtool_ops ops = { | |||
2079 | 2149 | ||
2080 | static int nv_open(struct net_device *dev) | 2150 | static int nv_open(struct net_device *dev) |
2081 | { | 2151 | { |
2082 | struct fe_priv *np = get_nvpriv(dev); | 2152 | struct fe_priv *np = netdev_priv(dev); |
2083 | u8 __iomem *base = get_hwbase(dev); | 2153 | u8 __iomem *base = get_hwbase(dev); |
2084 | int ret, oom, i; | 2154 | int ret, oom, i; |
2085 | 2155 | ||
@@ -2215,7 +2285,7 @@ out_drain: | |||
2215 | 2285 | ||
2216 | static int nv_close(struct net_device *dev) | 2286 | static int nv_close(struct net_device *dev) |
2217 | { | 2287 | { |
2218 | struct fe_priv *np = get_nvpriv(dev); | 2288 | struct fe_priv *np = netdev_priv(dev); |
2219 | u8 __iomem *base; | 2289 | u8 __iomem *base; |
2220 | 2290 | ||
2221 | spin_lock_irq(&np->lock); | 2291 | spin_lock_irq(&np->lock); |
@@ -2271,7 +2341,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2271 | if (!dev) | 2341 | if (!dev) |
2272 | goto out; | 2342 | goto out; |
2273 | 2343 | ||
2274 | np = get_nvpriv(dev); | 2344 | np = netdev_priv(dev); |
2275 | np->pci_dev = pci_dev; | 2345 | np->pci_dev = pci_dev; |
2276 | spin_lock_init(&np->lock); | 2346 | spin_lock_init(&np->lock); |
2277 | SET_MODULE_OWNER(dev); | 2347 | SET_MODULE_OWNER(dev); |
@@ -2323,6 +2393,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2323 | if (pci_set_dma_mask(pci_dev, 0x0000007fffffffffULL)) { | 2393 | if (pci_set_dma_mask(pci_dev, 0x0000007fffffffffULL)) { |
2324 | printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", | 2394 | printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", |
2325 | pci_name(pci_dev)); | 2395 | pci_name(pci_dev)); |
2396 | } else { | ||
2397 | dev->features |= NETIF_F_HIGHDMA; | ||
2326 | } | 2398 | } |
2327 | np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; | 2399 | np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; |
2328 | } else if (id->driver_data & DEV_HAS_LARGEDESC) { | 2400 | } else if (id->driver_data & DEV_HAS_LARGEDESC) { |
@@ -2341,8 +2413,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2341 | 2413 | ||
2342 | if (id->driver_data & DEV_HAS_CHECKSUM) { | 2414 | if (id->driver_data & DEV_HAS_CHECKSUM) { |
2343 | np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; | 2415 | np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; |
2344 | dev->features |= NETIF_F_HW_CSUM; | 2416 | dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; |
2345 | } | 2417 | #ifdef NETIF_F_TSO |
2418 | dev->features |= NETIF_F_TSO; | ||
2419 | #endif | ||
2420 | } | ||
2346 | 2421 | ||
2347 | err = -ENOMEM; | 2422 | err = -ENOMEM; |
2348 | np->base = ioremap(addr, NV_PCI_REGSZ); | 2423 | np->base = ioremap(addr, NV_PCI_REGSZ); |
@@ -2422,9 +2497,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2422 | np->wolenabled = 0; | 2497 | np->wolenabled = 0; |
2423 | 2498 | ||
2424 | if (np->desc_ver == DESC_VER_1) { | 2499 | if (np->desc_ver == DESC_VER_1) { |
2425 | np->tx_flags = NV_TX_LASTPACKET|NV_TX_VALID; | 2500 | np->tx_flags = NV_TX_VALID; |
2426 | } else { | 2501 | } else { |
2427 | np->tx_flags = NV_TX2_LASTPACKET|NV_TX2_VALID; | 2502 | np->tx_flags = NV_TX2_VALID; |
2428 | } | 2503 | } |
2429 | np->irqmask = NVREG_IRQMASK_WANTED; | 2504 | np->irqmask = NVREG_IRQMASK_WANTED; |
2430 | if (id->driver_data & DEV_NEED_TIMERIRQ) | 2505 | if (id->driver_data & DEV_NEED_TIMERIRQ) |
@@ -2513,7 +2588,7 @@ out: | |||
2513 | static void __devexit nv_remove(struct pci_dev *pci_dev) | 2588 | static void __devexit nv_remove(struct pci_dev *pci_dev) |
2514 | { | 2589 | { |
2515 | struct net_device *dev = pci_get_drvdata(pci_dev); | 2590 | struct net_device *dev = pci_get_drvdata(pci_dev); |
2516 | struct fe_priv *np = get_nvpriv(dev); | 2591 | struct fe_priv *np = netdev_priv(dev); |
2517 | 2592 | ||
2518 | unregister_netdev(dev); | 2593 | unregister_netdev(dev); |
2519 | 2594 | ||