diff options
Diffstat (limited to 'drivers/net/ns83820.c')
-rw-r--r-- | drivers/net/ns83820.c | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c index 2fcc181a8624..c336b46bd332 100644 --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _VERSION "0.20" | 1 | #define VERSION "0.22" |
2 | /* ns83820.c by Benjamin LaHaise with contributions. | 2 | /* ns83820.c by Benjamin LaHaise with contributions. |
3 | * | 3 | * |
4 | * Questions/comments/discussion to linux-ns83820@kvack.org. | 4 | * Questions/comments/discussion to linux-ns83820@kvack.org. |
@@ -63,9 +63,11 @@ | |||
63 | * - fix missed txok introduced during performance | 63 | * - fix missed txok introduced during performance |
64 | * tuning | 64 | * tuning |
65 | * 0.20 - fix stupid RFEN thinko. i am such a smurf. | 65 | * 0.20 - fix stupid RFEN thinko. i am such a smurf. |
66 | * | ||
67 | * 20040828 0.21 - add hardware vlan accleration | 66 | * 20040828 0.21 - add hardware vlan accleration |
68 | * by Neil Horman <nhorman@redhat.com> | 67 | * by Neil Horman <nhorman@redhat.com> |
68 | * 20050406 0.22 - improved DAC ifdefs from Andi Kleen | ||
69 | * - removal of dead code from Adrian Bunk | ||
70 | * - fix half duplex collision behaviour | ||
69 | * Driver Overview | 71 | * Driver Overview |
70 | * =============== | 72 | * =============== |
71 | * | 73 | * |
@@ -129,18 +131,6 @@ static int lnksts = 0; /* CFG_LNKSTS bit polarity */ | |||
129 | #undef Dprintk | 131 | #undef Dprintk |
130 | #define Dprintk dprintk | 132 | #define Dprintk dprintk |
131 | 133 | ||
132 | #if defined(CONFIG_HIGHMEM64G) || defined(__ia64__) | ||
133 | #define USE_64BIT_ADDR "+" | ||
134 | #endif | ||
135 | |||
136 | #if defined(USE_64BIT_ADDR) | ||
137 | #define VERSION _VERSION USE_64BIT_ADDR | ||
138 | #define TRY_DAC 1 | ||
139 | #else | ||
140 | #define VERSION _VERSION | ||
141 | #define TRY_DAC 0 | ||
142 | #endif | ||
143 | |||
144 | /* tunables */ | 134 | /* tunables */ |
145 | #define RX_BUF_SIZE 1500 /* 8192 */ | 135 | #define RX_BUF_SIZE 1500 /* 8192 */ |
146 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 136 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
@@ -386,22 +376,16 @@ static int lnksts = 0; /* CFG_LNKSTS bit polarity */ | |||
386 | #define LINK_DOWN 0x02 | 376 | #define LINK_DOWN 0x02 |
387 | #define LINK_UP 0x04 | 377 | #define LINK_UP 0x04 |
388 | 378 | ||
389 | #ifdef USE_64BIT_ADDR | 379 | #define HW_ADDR_LEN sizeof(dma_addr_t) |
390 | #define HW_ADDR_LEN 8 | ||
391 | #define desc_addr_set(desc, addr) \ | 380 | #define desc_addr_set(desc, addr) \ |
392 | do { \ | 381 | do { \ |
393 | u64 __addr = (addr); \ | 382 | ((desc)[0] = cpu_to_le32(addr)); \ |
394 | (desc)[0] = cpu_to_le32(__addr); \ | 383 | if (HW_ADDR_LEN == 8) \ |
395 | (desc)[1] = cpu_to_le32(__addr >> 32); \ | 384 | (desc)[1] = cpu_to_le32(((u64)addr) >> 32); \ |
396 | } while(0) | 385 | } while(0) |
397 | #define desc_addr_get(desc) \ | 386 | #define desc_addr_get(desc) \ |
398 | (((u64)le32_to_cpu((desc)[1]) << 32) \ | 387 | (le32_to_cpu((desc)[0]) | \ |
399 | | le32_to_cpu((desc)[0])) | 388 | (HW_ADDR_LEN == 8 ? ((dma_addr_t)le32_to_cpu((desc)[1]))<<32 : 0)) |
400 | #else | ||
401 | #define HW_ADDR_LEN 4 | ||
402 | #define desc_addr_set(desc, addr) ((desc)[0] = cpu_to_le32(addr)) | ||
403 | #define desc_addr_get(desc) (le32_to_cpu((desc)[0])) | ||
404 | #endif | ||
405 | 389 | ||
406 | #define DESC_LINK 0 | 390 | #define DESC_LINK 0 |
407 | #define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4) | 391 | #define DESC_BUFPTR (DESC_LINK + HW_ADDR_LEN/4) |
@@ -727,11 +711,23 @@ static void fastcall phy_intr(struct net_device *ndev) | |||
727 | speed = ((cfg / CFG_SPDSTS0) & 3); | 711 | speed = ((cfg / CFG_SPDSTS0) & 3); |
728 | fullduplex = (cfg & CFG_DUPSTS); | 712 | fullduplex = (cfg & CFG_DUPSTS); |
729 | 713 | ||
730 | if (fullduplex) | 714 | if (fullduplex) { |
731 | new_cfg |= CFG_SB; | 715 | new_cfg |= CFG_SB; |
716 | writel(readl(dev->base + TXCFG) | ||
717 | | TXCFG_CSI | TXCFG_HBI, | ||
718 | dev->base + TXCFG); | ||
719 | writel(readl(dev->base + RXCFG) | RXCFG_RX_FD, | ||
720 | dev->base + RXCFG); | ||
721 | } else { | ||
722 | writel(readl(dev->base + TXCFG) | ||
723 | & ~(TXCFG_CSI | TXCFG_HBI), | ||
724 | dev->base + TXCFG); | ||
725 | writel(readl(dev->base + RXCFG) & ~(RXCFG_RX_FD), | ||
726 | dev->base + RXCFG); | ||
727 | } | ||
732 | 728 | ||
733 | if ((cfg & CFG_LNKSTS) && | 729 | if ((cfg & CFG_LNKSTS) && |
734 | ((new_cfg ^ dev->CFG_cache) & CFG_MODE_1000)) { | 730 | ((new_cfg ^ dev->CFG_cache) != 0)) { |
735 | writel(new_cfg, dev->base + CFG); | 731 | writel(new_cfg, dev->base + CFG); |
736 | dev->CFG_cache = new_cfg; | 732 | dev->CFG_cache = new_cfg; |
737 | } | 733 | } |
@@ -1189,7 +1185,6 @@ again: | |||
1189 | 1185 | ||
1190 | for (;;) { | 1186 | for (;;) { |
1191 | volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); | 1187 | volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); |
1192 | u32 residue = 0; | ||
1193 | 1188 | ||
1194 | dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, | 1189 | dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, |
1195 | (unsigned long long)buf); | 1190 | (unsigned long long)buf); |
@@ -1199,17 +1194,11 @@ again: | |||
1199 | desc_addr_set(desc + DESC_BUFPTR, buf); | 1194 | desc_addr_set(desc + DESC_BUFPTR, buf); |
1200 | desc[DESC_EXTSTS] = cpu_to_le32(extsts); | 1195 | desc[DESC_EXTSTS] = cpu_to_le32(extsts); |
1201 | 1196 | ||
1202 | cmdsts = ((nr_frags|residue) ? CMDSTS_MORE : do_intr ? CMDSTS_INTR : 0); | 1197 | cmdsts = ((nr_frags) ? CMDSTS_MORE : do_intr ? CMDSTS_INTR : 0); |
1203 | cmdsts |= (desc == first_desc) ? 0 : CMDSTS_OWN; | 1198 | cmdsts |= (desc == first_desc) ? 0 : CMDSTS_OWN; |
1204 | cmdsts |= len; | 1199 | cmdsts |= len; |
1205 | desc[DESC_CMDSTS] = cpu_to_le32(cmdsts); | 1200 | desc[DESC_CMDSTS] = cpu_to_le32(cmdsts); |
1206 | 1201 | ||
1207 | if (residue) { | ||
1208 | buf += len; | ||
1209 | len = residue; | ||
1210 | continue; | ||
1211 | } | ||
1212 | |||
1213 | if (!nr_frags) | 1202 | if (!nr_frags) |
1214 | break; | 1203 | break; |
1215 | 1204 | ||
@@ -1841,7 +1830,8 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_ | |||
1841 | int using_dac = 0; | 1830 | int using_dac = 0; |
1842 | 1831 | ||
1843 | /* See if we can set the dma mask early on; failure is fatal. */ | 1832 | /* See if we can set the dma mask early on; failure is fatal. */ |
1844 | if (TRY_DAC && !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) { | 1833 | if (sizeof(dma_addr_t) == 8 && |
1834 | !pci_set_dma_mask(pci_dev, 0xffffffffffffffffULL)) { | ||
1845 | using_dac = 1; | 1835 | using_dac = 1; |
1846 | } else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) { | 1836 | } else if (!pci_set_dma_mask(pci_dev, 0xffffffff)) { |
1847 | using_dac = 0; | 1837 | using_dac = 0; |
@@ -1972,9 +1962,8 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_ | |||
1972 | /* When compiled with 64 bit addressing, we must always enable | 1962 | /* When compiled with 64 bit addressing, we must always enable |
1973 | * the 64 bit descriptor format. | 1963 | * the 64 bit descriptor format. |
1974 | */ | 1964 | */ |
1975 | #ifdef USE_64BIT_ADDR | 1965 | if (sizeof(dma_addr_t) == 8) |
1976 | dev->CFG_cache |= CFG_M64ADDR; | 1966 | dev->CFG_cache |= CFG_M64ADDR; |
1977 | #endif | ||
1978 | if (using_dac) | 1967 | if (using_dac) |
1979 | dev->CFG_cache |= CFG_T64ADDR; | 1968 | dev->CFG_cache |= CFG_T64ADDR; |
1980 | 1969 | ||