aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/forcedeth.c
diff options
context:
space:
mode:
authorManfred Spraul <manfred@colorfullife.com>2005-09-21 23:22:10 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-09-21 23:22:10 -0400
commit8a4ae7f2e24bf99b61082ca45de8e54e70300b9d (patch)
tree560df923cbd6dcee66352e1d55c8b170ebd57b36 /drivers/net/forcedeth.c
parent9a01c16bd49071b2e7904d222cae71d5f8bf6bb5 (diff)
forcedeth: add hardware tx checksumming
Recent forcedeth nics support checksum offloading for tx. The attached patch, written by Ayaz Abdulla, adds the support to the driver. It also cleans up the handling of the three dma ring entry formats that are supported by the driver. Signed-off-By: Manfred Spraul <manfred@colorfullife.com> Signed-off-By: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/forcedeth.c')
-rw-r--r--drivers/net/forcedeth.c71
1 files changed, 44 insertions, 27 deletions
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 6e042ecf6965..e5f480203675 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -95,6 +95,7 @@
95 * of nv_remove 95 * of nv_remove
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 * 99 *
99 * Known bugs: 100 * Known bugs:
100 * We suspect that on some hardware no TX done interrupts are generated. 101 * We suspect that on some hardware no TX done interrupts are generated.
@@ -106,7 +107,7 @@
106 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 107 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
107 * superfluous timer interrupts from the nic. 108 * superfluous timer interrupts from the nic.
108 */ 109 */
109#define FORCEDETH_VERSION "0.41" 110#define FORCEDETH_VERSION "0.43"
110#define DRV_NAME "forcedeth" 111#define DRV_NAME "forcedeth"
111 112
112#include <linux/module.h> 113#include <linux/module.h>
@@ -145,6 +146,7 @@
145#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */ 146#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */
146#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */ 147#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */
147#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */ 148#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */
149#define DEV_HAS_CHECKSUM 0x0010 /* device supports tx and rx checksum offloads */
148 150
149enum { 151enum {
150 NvRegIrqStatus = 0x000, 152 NvRegIrqStatus = 0x000,
@@ -241,6 +243,9 @@ enum {
241#define NVREG_TXRXCTL_IDLE 0x0008 243#define NVREG_TXRXCTL_IDLE 0x0008
242#define NVREG_TXRXCTL_RESET 0x0010 244#define NVREG_TXRXCTL_RESET 0x0010
243#define NVREG_TXRXCTL_RXCHECK 0x0400 245#define NVREG_TXRXCTL_RXCHECK 0x0400
246#define NVREG_TXRXCTL_DESC_1 0
247#define NVREG_TXRXCTL_DESC_2 0x02100
248#define NVREG_TXRXCTL_DESC_3 0x02200
244 NvRegMIIStatus = 0x180, 249 NvRegMIIStatus = 0x180,
245#define NVREG_MIISTAT_ERROR 0x0001 250#define NVREG_MIISTAT_ERROR 0x0001
246#define NVREG_MIISTAT_LINKCHANGE 0x0008 251#define NVREG_MIISTAT_LINKCHANGE 0x0008
@@ -335,6 +340,8 @@ typedef union _ring_type {
335/* error and valid are the same for both */ 340/* error and valid are the same for both */
336#define NV_TX2_ERROR (1<<30) 341#define NV_TX2_ERROR (1<<30)
337#define NV_TX2_VALID (1<<31) 342#define NV_TX2_VALID (1<<31)
343#define NV_TX2_CHECKSUM_L3 (1<<27)
344#define NV_TX2_CHECKSUM_L4 (1<<26)
338 345
339#define NV_RX_DESCRIPTORVALID (1<<16) 346#define NV_RX_DESCRIPTORVALID (1<<16)
340#define NV_RX_MISSEDFRAME (1<<17) 347#define NV_RX_MISSEDFRAME (1<<17)
@@ -417,14 +424,14 @@ typedef union _ring_type {
417 424
418/* 425/*
419 * desc_ver values: 426 * desc_ver values:
420 * This field has two purposes: 427 * The nic supports three different descriptor types:
421 * - Newer nics uses a different ring layout. The layout is selected by 428 * - DESC_VER_1: Original
422 * comparing np->desc_ver with DESC_VER_xy. 429 * - DESC_VER_2: support for jumbo frames.
423 * - It contains bits that are forced on when writing to NvRegTxRxControl. 430 * - DESC_VER_3: 64-bit format.
424 */ 431 */
425#define DESC_VER_1 0x0 432#define DESC_VER_1 1
426#define DESC_VER_2 (0x02100|NVREG_TXRXCTL_RXCHECK) 433#define DESC_VER_2 2
427#define DESC_VER_3 (0x02200|NVREG_TXRXCTL_RXCHECK) 434#define DESC_VER_3 3
428 435
429/* PHY defines */ 436/* PHY defines */
430#define PHY_OUI_MARVELL 0x5043 437#define PHY_OUI_MARVELL 0x5043
@@ -491,6 +498,7 @@ struct fe_priv {
491 u32 orig_mac[2]; 498 u32 orig_mac[2];
492 u32 irqmask; 499 u32 irqmask;
493 u32 desc_ver; 500 u32 desc_ver;
501 u32 txrxctl_bits;
494 502
495 void __iomem *base; 503 void __iomem *base;
496 504
@@ -786,10 +794,10 @@ static void nv_txrx_reset(struct net_device *dev)
786 u8 __iomem *base = get_hwbase(dev); 794 u8 __iomem *base = get_hwbase(dev);
787 795
788 dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name); 796 dprintk(KERN_DEBUG "%s: nv_txrx_reset\n", dev->name);
789 writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->desc_ver, base + NvRegTxRxControl); 797 writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->txrxctl_bits, base + NvRegTxRxControl);
790 pci_push(base); 798 pci_push(base);
791 udelay(NV_TXRX_RESET_DELAY); 799 udelay(NV_TXRX_RESET_DELAY);
792 writel(NVREG_TXRXCTL_BIT2 | np->desc_ver, base + NvRegTxRxControl); 800 writel(NVREG_TXRXCTL_BIT2 | np->txrxctl_bits, base + NvRegTxRxControl);
793 pci_push(base); 801 pci_push(base);
794} 802}
795 803
@@ -961,6 +969,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
961{ 969{
962 struct fe_priv *np = get_nvpriv(dev); 970 struct fe_priv *np = get_nvpriv(dev);
963 int nr = np->next_tx % TX_RING; 971 int nr = np->next_tx % TX_RING;
972 u32 tx_checksum = (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0);
964 973
965 np->tx_skbuff[nr] = skb; 974 np->tx_skbuff[nr] = skb;
966 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len, 975 np->tx_dma[nr] = pci_map_single(np->pci_dev, skb->data,skb->len,
@@ -976,10 +985,10 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
976 spin_lock_irq(&np->lock); 985 spin_lock_irq(&np->lock);
977 wmb(); 986 wmb();
978 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) 987 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2)
979 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags ); 988 np->tx_ring.orig[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags | tx_checksum);
980 else 989 else
981 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags ); 990 np->tx_ring.ex[nr].FlagLen = cpu_to_le32( (skb->len-1) | np->tx_flags | tx_checksum);
982 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission.\n", 991 dprintk(KERN_DEBUG "%s: nv_start_xmit: packet packet %d queued for transmission\n",
983 dev->name, np->next_tx); 992 dev->name, np->next_tx);
984 { 993 {
985 int j; 994 int j;
@@ -997,7 +1006,7 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
997 if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP) 1006 if (np->next_tx - np->nic_tx >= TX_LIMIT_STOP)
998 netif_stop_queue(dev); 1007 netif_stop_queue(dev);
999 spin_unlock_irq(&np->lock); 1008 spin_unlock_irq(&np->lock);
1000 writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl); 1009 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
1001 pci_push(get_hwbase(dev)); 1010 pci_push(get_hwbase(dev));
1002 return 0; 1011 return 0;
1003} 1012}
@@ -1408,7 +1417,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu)
1408 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT), 1417 writel( ((RX_RING-1) << NVREG_RINGSZ_RXSHIFT) + ((TX_RING-1) << NVREG_RINGSZ_TXSHIFT),
1409 base + NvRegRingSizes); 1418 base + NvRegRingSizes);
1410 pci_push(base); 1419 pci_push(base);
1411 writel(NVREG_TXRXCTL_KICK|np->desc_ver, get_hwbase(dev) + NvRegTxRxControl); 1420 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
1412 pci_push(base); 1421 pci_push(base);
1413 1422
1414 /* restart rx engine */ 1423 /* restart rx engine */
@@ -2115,9 +2124,9 @@ static int nv_open(struct net_device *dev)
2115 /* 5) continue setup */ 2124 /* 5) continue setup */
2116 writel(np->linkspeed, base + NvRegLinkSpeed); 2125 writel(np->linkspeed, base + NvRegLinkSpeed);
2117 writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3); 2126 writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3);
2118 writel(np->desc_ver, base + NvRegTxRxControl); 2127 writel(np->txrxctl_bits, base + NvRegTxRxControl);
2119 pci_push(base); 2128 pci_push(base);
2120 writel(NVREG_TXRXCTL_BIT1|np->desc_ver, base + NvRegTxRxControl); 2129 writel(NVREG_TXRXCTL_BIT1|np->txrxctl_bits, base + NvRegTxRxControl);
2121 reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31, 2130 reg_delay(dev, NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31, NVREG_UNKSETUP5_BIT31,
2122 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, 2131 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
2123 KERN_INFO "open: SetupReg5, Bit 31 remained off\n"); 2132 KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
@@ -2315,18 +2324,26 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2315 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", 2324 printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n",
2316 pci_name(pci_dev)); 2325 pci_name(pci_dev));
2317 } 2326 }
2327 np->txrxctl_bits = NVREG_TXRXCTL_DESC_3;
2318 } else if (id->driver_data & DEV_HAS_LARGEDESC) { 2328 } else if (id->driver_data & DEV_HAS_LARGEDESC) {
2319 /* packet format 2: supports jumbo frames */ 2329 /* packet format 2: supports jumbo frames */
2320 np->desc_ver = DESC_VER_2; 2330 np->desc_ver = DESC_VER_2;
2331 np->txrxctl_bits = NVREG_TXRXCTL_DESC_2;
2321 } else { 2332 } else {
2322 /* original packet format */ 2333 /* original packet format */
2323 np->desc_ver = DESC_VER_1; 2334 np->desc_ver = DESC_VER_1;
2335 np->txrxctl_bits = NVREG_TXRXCTL_DESC_1;
2324 } 2336 }
2325 2337
2326 np->pkt_limit = NV_PKTLIMIT_1; 2338 np->pkt_limit = NV_PKTLIMIT_1;
2327 if (id->driver_data & DEV_HAS_LARGEDESC) 2339 if (id->driver_data & DEV_HAS_LARGEDESC)
2328 np->pkt_limit = NV_PKTLIMIT_2; 2340 np->pkt_limit = NV_PKTLIMIT_2;
2329 2341
2342 if (id->driver_data & DEV_HAS_CHECKSUM) {
2343 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2344 dev->features |= NETIF_F_HW_CSUM;
2345 }
2346
2330 err = -ENOMEM; 2347 err = -ENOMEM;
2331 np->base = ioremap(addr, NV_PCI_REGSZ); 2348 np->base = ioremap(addr, NV_PCI_REGSZ);
2332 if (!np->base) 2349 if (!np->base)
@@ -2527,35 +2544,35 @@ static struct pci_device_id pci_tbl[] = {
2527 }, 2544 },
2528 { /* nForce3 Ethernet Controller */ 2545 { /* nForce3 Ethernet Controller */
2529 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4), 2546 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_4),
2530 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2547 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2531 }, 2548 },
2532 { /* nForce3 Ethernet Controller */ 2549 { /* nForce3 Ethernet Controller */
2533 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5), 2550 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_5),
2534 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2551 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2535 }, 2552 },
2536 { /* nForce3 Ethernet Controller */ 2553 { /* nForce3 Ethernet Controller */
2537 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6), 2554 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_6),
2538 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2555 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2539 }, 2556 },
2540 { /* nForce3 Ethernet Controller */ 2557 { /* nForce3 Ethernet Controller */
2541 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7), 2558 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_7),
2542 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC, 2559 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM,
2543 }, 2560 },
2544 { /* CK804 Ethernet Controller */ 2561 { /* CK804 Ethernet Controller */
2545 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8), 2562 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_8),
2546 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2563 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2547 }, 2564 },
2548 { /* CK804 Ethernet Controller */ 2565 { /* CK804 Ethernet Controller */
2549 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9), 2566 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_9),
2550 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2567 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2551 }, 2568 },
2552 { /* MCP04 Ethernet Controller */ 2569 { /* MCP04 Ethernet Controller */
2553 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10), 2570 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_10),
2554 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2571 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2555 }, 2572 },
2556 { /* MCP04 Ethernet Controller */ 2573 { /* MCP04 Ethernet Controller */
2557 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11), 2574 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_11),
2558 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2575 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2559 }, 2576 },
2560 { /* MCP51 Ethernet Controller */ 2577 { /* MCP51 Ethernet Controller */
2561 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12), 2578 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12),
@@ -2567,11 +2584,11 @@ static struct pci_device_id pci_tbl[] = {
2567 }, 2584 },
2568 { /* MCP55 Ethernet Controller */ 2585 { /* MCP55 Ethernet Controller */
2569 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 2586 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
2570 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2587 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2571 }, 2588 },
2572 { /* MCP55 Ethernet Controller */ 2589 { /* MCP55 Ethernet Controller */
2573 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 2590 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
2574 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA, 2591 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA,
2575 }, 2592 },
2576 {0,}, 2593 {0,},
2577}; 2594};