aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sk98lin/skge.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sk98lin/skge.c')
-rw-r--r--drivers/net/sk98lin/skge.c174
1 files changed, 41 insertions, 133 deletions
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 08906ef3ff7e..107c5d97546c 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -101,7 +101,6 @@
101 * "h/skgeinit.h" 101 * "h/skgeinit.h"
102 * "h/skaddr.h" 102 * "h/skaddr.h"
103 * "h/skgesirq.h" 103 * "h/skgesirq.h"
104 * "h/skcsum.h"
105 * "h/skrlmt.h" 104 * "h/skrlmt.h"
106 * 105 *
107 ******************************************************************************/ 106 ******************************************************************************/
@@ -113,6 +112,7 @@
113#include <linux/init.h> 112#include <linux/init.h>
114#include <linux/proc_fs.h> 113#include <linux/proc_fs.h>
115#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h>
116 116
117#include "h/skdrv1st.h" 117#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 118#include "h/skdrv2nd.h"
@@ -622,11 +622,6 @@ SK_BOOL DualNet;
622 return(-EAGAIN); 622 return(-EAGAIN);
623 } 623 }
624 624
625 SkCsSetReceiveFlags(pAC,
626 SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
627 &pAC->CsOfs1, &pAC->CsOfs2, 0);
628 pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
629
630 BoardInitMem(pAC); 625 BoardInitMem(pAC);
631 /* tschilling: New common function with minimum size check. */ 626 /* tschilling: New common function with minimum size check. */
632 DualNet = SK_FALSE; 627 DualNet = SK_FALSE;
@@ -844,7 +839,7 @@ uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
844 /* set the pointers right */ 839 /* set the pointers right */
845 pDescr->VNextRxd = VNextDescr & 0xffffffffULL; 840 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
846 pDescr->pNextRxd = pNextDescr; 841 pDescr->pNextRxd = pNextDescr;
847 pDescr->TcpSumStarts = pAC->CsOfs; 842 pDescr->TcpSumStarts = 0;
848 843
849 /* advance one step */ 844 /* advance one step */
850 pPrevDescr = pDescr; 845 pPrevDescr = pDescr;
@@ -1526,8 +1521,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1526 TXD *pOldTxd; 1521 TXD *pOldTxd;
1527 unsigned long Flags; 1522 unsigned long Flags;
1528 SK_U64 PhysAddr; 1523 SK_U64 PhysAddr;
1529 int Protocol;
1530 int IpHeaderLength;
1531 int BytesSend = pMessage->len; 1524 int BytesSend = pMessage->len;
1532 1525
1533 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X")); 1526 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
@@ -1600,8 +1593,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1600 pTxd->pMBuf = pMessage; 1593 pTxd->pMBuf = pMessage;
1601 1594
1602 if (pMessage->ip_summed == CHECKSUM_HW) { 1595 if (pMessage->ip_summed == CHECKSUM_HW) {
1603 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1596 u16 hdrlen = pMessage->h.raw - pMessage->data;
1604 if ((Protocol == C_PROTO_ID_UDP) && 1597 u16 offset = hdrlen + pMessage->csum;
1598
1599 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1605 (pAC->GIni.GIChipRev == 0) && 1600 (pAC->GIni.GIChipRev == 0) &&
1606 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1601 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1607 pTxd->TBControl = BMU_TCP_CHECK; 1602 pTxd->TBControl = BMU_TCP_CHECK;
@@ -1609,14 +1604,9 @@ struct sk_buff *pMessage) /* pointer to send-message */
1609 pTxd->TBControl = BMU_UDP_CHECK; 1604 pTxd->TBControl = BMU_UDP_CHECK;
1610 } 1605 }
1611 1606
1612 IpHeaderLength = (SK_U8)pMessage->data[C_OFFSET_IPHEADER]; 1607 pTxd->TcpSumOfs = 0;
1613 IpHeaderLength = (IpHeaderLength & 0xf) * 4; 1608 pTxd->TcpSumSt = hdrlen;
1614 pTxd->TcpSumOfs = 0; /* PH-Checksum already calculated */ 1609 pTxd->TcpSumWr = offset;
1615 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength +
1616 (Protocol == C_PROTO_ID_UDP ?
1617 C_OFFSET_UDPHEADER_UDPCS :
1618 C_OFFSET_TCPHEADER_TCPCS);
1619 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
1620 1610
1621 pTxd->TBControl |= BMU_OWN | BMU_STF | 1611 pTxd->TBControl |= BMU_OWN | BMU_STF |
1622 BMU_SW | BMU_EOF | 1612 BMU_SW | BMU_EOF |
@@ -1679,11 +1669,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1679 TXD *pTxdLst; 1669 TXD *pTxdLst;
1680 int CurrFrag; 1670 int CurrFrag;
1681 int BytesSend; 1671 int BytesSend;
1682 int IpHeaderLength;
1683 int Protocol;
1684 skb_frag_t *sk_frag; 1672 skb_frag_t *sk_frag;
1685 SK_U64 PhysAddr; 1673 SK_U64 PhysAddr;
1686 unsigned long Flags; 1674 unsigned long Flags;
1675 SK_U32 Control;
1687 1676
1688 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); 1677 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
1689#ifndef USE_TX_COMPLETE 1678#ifndef USE_TX_COMPLETE
@@ -1706,7 +1695,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1706 pTxdFst = pTxd; 1695 pTxdFst = pTxd;
1707 pTxdLst = pTxd; 1696 pTxdLst = pTxd;
1708 BytesSend = 0; 1697 BytesSend = 0;
1709 Protocol = 0;
1710 1698
1711 /* 1699 /*
1712 ** Map the first fragment (header) into the DMA-space 1700 ** Map the first fragment (header) into the DMA-space
@@ -1724,32 +1712,31 @@ struct sk_buff *pMessage) /* pointer to send-message */
1724 ** Does the HW need to evaluate checksum for TCP or UDP packets? 1712 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1725 */ 1713 */
1726 if (pMessage->ip_summed == CHECKSUM_HW) { 1714 if (pMessage->ip_summed == CHECKSUM_HW) {
1727 pTxd->TBControl = BMU_STF | BMU_STFWD | skb_headlen(pMessage); 1715 u16 hdrlen = pMessage->h.raw - pMessage->data;
1716 u16 offset = hdrlen + pMessage->csum;
1717
1718 Control = BMU_STFWD;
1719
1728 /* 1720 /*
1729 ** We have to use the opcode for tcp here, because the 1721 ** We have to use the opcode for tcp here, because the
1730 ** opcode for udp is not working in the hardware yet 1722 ** opcode for udp is not working in the hardware yet
1731 ** (Revision 2.0) 1723 ** (Revision 2.0)
1732 */ 1724 */
1733 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1725 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1734 if ((Protocol == C_PROTO_ID_UDP) &&
1735 (pAC->GIni.GIChipRev == 0) && 1726 (pAC->GIni.GIChipRev == 0) &&
1736 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1727 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1737 pTxd->TBControl |= BMU_TCP_CHECK; 1728 Control |= BMU_TCP_CHECK;
1738 } else { 1729 } else {
1739 pTxd->TBControl |= BMU_UDP_CHECK; 1730 Control |= BMU_UDP_CHECK;
1740 } 1731 }
1741 1732
1742 IpHeaderLength = ((SK_U8)pMessage->data[C_OFFSET_IPHEADER] & 0xf)*4; 1733 pTxd->TcpSumOfs = 0;
1743 pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */ 1734 pTxd->TcpSumSt = hdrlen;
1744 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength + 1735 pTxd->TcpSumWr = offset;
1745 (Protocol == C_PROTO_ID_UDP ? 1736 } else
1746 C_OFFSET_UDPHEADER_UDPCS : 1737 Control = BMU_CHECK | BMU_SW;
1747 C_OFFSET_TCPHEADER_TCPCS); 1738
1748 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength; 1739 pTxd->TBControl = BMU_STF | Control | skb_headlen(pMessage);
1749 } else {
1750 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_STF |
1751 skb_headlen(pMessage);
1752 }
1753 1740
1754 pTxd = pTxd->pNextTxd; 1741 pTxd = pTxd->pNextTxd;
1755 pTxPort->TxdRingFree--; 1742 pTxPort->TxdRingFree--;
@@ -1773,40 +1760,18 @@ struct sk_buff *pMessage) /* pointer to send-message */
1773 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); 1760 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
1774 pTxd->pMBuf = pMessage; 1761 pTxd->pMBuf = pMessage;
1775 1762
1776 /* 1763 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
1777 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1778 */
1779 if (pMessage->ip_summed == CHECKSUM_HW) {
1780 pTxd->TBControl = BMU_OWN | BMU_SW | BMU_STFWD;
1781 /*
1782 ** We have to use the opcode for tcp here because the
1783 ** opcode for udp is not working in the hardware yet
1784 ** (revision 2.0)
1785 */
1786 if ((Protocol == C_PROTO_ID_UDP) &&
1787 (pAC->GIni.GIChipRev == 0) &&
1788 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1789 pTxd->TBControl |= BMU_TCP_CHECK;
1790 } else {
1791 pTxd->TBControl |= BMU_UDP_CHECK;
1792 }
1793 } else {
1794 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_OWN;
1795 }
1796 1764
1797 /* 1765 /*
1798 ** Do we have the last fragment? 1766 ** Do we have the last fragment?
1799 */ 1767 */
1800 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) { 1768 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) {
1801#ifdef USE_TX_COMPLETE 1769#ifdef USE_TX_COMPLETE
1802 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF | sk_frag->size; 1770 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF;
1803#else 1771#else
1804 pTxd->TBControl |= BMU_EOF | sk_frag->size; 1772 pTxd->TBControl |= BMU_EOF;
1805#endif 1773#endif
1806 pTxdFst->TBControl |= BMU_OWN | BMU_SW; 1774 pTxdFst->TBControl |= BMU_OWN | BMU_SW;
1807
1808 } else {
1809 pTxd->TBControl |= sk_frag->size;
1810 } 1775 }
1811 pTxdLst = pTxd; 1776 pTxdLst = pTxd;
1812 pTxd = pTxd->pNextTxd; 1777 pTxd = pTxd->pNextTxd;
@@ -2053,7 +2018,6 @@ SK_U32 Control; /* control field of descriptor */
2053struct sk_buff *pMsg; /* pointer to message holding frame */ 2018struct sk_buff *pMsg; /* pointer to message holding frame */
2054struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */ 2019struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */
2055int FrameLength; /* total length of received frame */ 2020int FrameLength; /* total length of received frame */
2056int IpFrameLength;
2057SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */ 2021SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */
2058SK_EVPARA EvPara; /* an event parameter union */ 2022SK_EVPARA EvPara; /* an event parameter union */
2059unsigned long Flags; /* for spin lock */ 2023unsigned long Flags; /* for spin lock */
@@ -2066,10 +2030,6 @@ SK_BOOL IsMc;
2066SK_BOOL IsBadFrame; /* Bad frame */ 2030SK_BOOL IsBadFrame; /* Bad frame */
2067 2031
2068SK_U32 FrameStat; 2032SK_U32 FrameStat;
2069unsigned short Csum1;
2070unsigned short Csum2;
2071unsigned short Type;
2072int Result;
2073SK_U64 PhysAddr; 2033SK_U64 PhysAddr;
2074 2034
2075rx_start: 2035rx_start:
@@ -2198,8 +2158,8 @@ rx_start:
2198 (dma_addr_t) PhysAddr, 2158 (dma_addr_t) PhysAddr,
2199 FrameLength, 2159 FrameLength,
2200 PCI_DMA_FROMDEVICE); 2160 PCI_DMA_FROMDEVICE);
2201 eth_copy_and_sum(pNewMsg, pMsg->data, 2161 memcpy(pNewMsg->data, pMsg, FrameLength);
2202 FrameLength, 0); 2162
2203 pci_dma_sync_single_for_device(pAC->PciDev, 2163 pci_dma_sync_single_for_device(pAC->PciDev,
2204 (dma_addr_t) PhysAddr, 2164 (dma_addr_t) PhysAddr,
2205 FrameLength, 2165 FrameLength,
@@ -2227,69 +2187,16 @@ rx_start:
2227 2187
2228 /* set length in message */ 2188 /* set length in message */
2229 skb_put(pMsg, FrameLength); 2189 skb_put(pMsg, FrameLength);
2230 /* hardware checksum */ 2190 } /* frame > SK_COPY_TRESHOLD */
2231 Type = ntohs(*((short*)&pMsg->data[12]));
2232 2191
2233#ifdef USE_SK_RX_CHECKSUM 2192#ifdef USE_SK_RX_CHECKSUM
2234 if (Type == 0x800) { 2193 pMsg->csum = pRxd->TcpSums;
2235 Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff); 2194 pMsg->ip_summed = CHECKSUM_HW;
2236 Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2237 IpFrameLength = (int) ntohs((unsigned short)
2238 ((unsigned short *) pMsg->data)[8]);
2239
2240 /*
2241 * Test: If frame is padded, a check is not possible!
2242 * Frame not padded? Length difference must be 14 (0xe)!
2243 */
2244 if ((FrameLength - IpFrameLength) != 0xe) {
2245 /* Frame padded => TCP offload not possible! */
2246 pMsg->ip_summed = CHECKSUM_NONE;
2247 } else {
2248 /* Frame not padded => TCP offload! */
2249 if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2250 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2251 (pAC->ChipsetType)) {
2252 Result = SkCsGetReceiveInfo(pAC,
2253 &pMsg->data[14],
2254 Csum1, Csum2, pRxPort->PortIndex);
2255 if (Result ==
2256 SKCS_STATUS_IP_FRAGMENT ||
2257 Result ==
2258 SKCS_STATUS_IP_CSUM_OK ||
2259 Result ==
2260 SKCS_STATUS_TCP_CSUM_OK ||
2261 Result ==
2262 SKCS_STATUS_UDP_CSUM_OK) {
2263 pMsg->ip_summed =
2264 CHECKSUM_UNNECESSARY;
2265 }
2266 else if (Result ==
2267 SKCS_STATUS_TCP_CSUM_ERROR ||
2268 Result ==
2269 SKCS_STATUS_UDP_CSUM_ERROR ||
2270 Result ==
2271 SKCS_STATUS_IP_CSUM_ERROR_UDP ||
2272 Result ==
2273 SKCS_STATUS_IP_CSUM_ERROR_TCP ||
2274 Result ==
2275 SKCS_STATUS_IP_CSUM_ERROR ) {
2276 /* HW Checksum error */
2277 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2278 SK_DBGCAT_DRV_RX_PROGRESS,
2279 ("skge: CRC error. Frame dropped!\n"));
2280 goto rx_failed;
2281 } else {
2282 pMsg->ip_summed =
2283 CHECKSUM_NONE;
2284 }
2285 }/* checksumControl calculation valid */
2286 } /* Frame length check */
2287 } /* IP frame */
2288#else 2195#else
2289 pMsg->ip_summed = CHECKSUM_NONE; 2196 pMsg->ip_summed = CHECKSUM_NONE;
2290#endif 2197#endif
2291 } /* frame > SK_COPY_TRESHOLD */ 2198
2292 2199
2293 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); 2200 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2294 ForRlmt = SK_RLMT_RX_PROTOCOL; 2201 ForRlmt = SK_RLMT_RX_PROTOCOL;
2295#if 0 2202#if 0
@@ -4945,7 +4852,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4945 dev->irq = pdev->irq; 4852 dev->irq = pdev->irq;
4946 error = SkGeInitPCI(pAC); 4853 error = SkGeInitPCI(pAC);
4947 if (error) { 4854 if (error) {
4948 printk("SKGE: PCI setup failed: %i\n", error); 4855 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
4949 goto out_free_netdev; 4856 goto out_free_netdev;
4950 } 4857 }
4951 4858
@@ -4981,7 +4888,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4981 4888
4982 /* Register net device */ 4889 /* Register net device */
4983 if (register_netdev(dev)) { 4890 if (register_netdev(dev)) {
4984 printk(KERN_ERR "SKGE: Could not register device.\n"); 4891 printk(KERN_ERR "sk98lin: Could not register device.\n");
4985 goto out_free_resources; 4892 goto out_free_resources;
4986 } 4893 }
4987 4894
@@ -5000,8 +4907,8 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5000 4907
5001 SkGeYellowLED(pAC, pAC->IoBase, 1); 4908 SkGeYellowLED(pAC, pAC->IoBase, 1);
5002 4909
5003
5004 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); 4910 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
4911 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5005 4912
5006 SkGeProcCreate(dev); 4913 SkGeProcCreate(dev);
5007 4914
@@ -5047,13 +4954,14 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5047#endif 4954#endif
5048 4955
5049 if (register_netdev(dev)) { 4956 if (register_netdev(dev)) {
5050 printk(KERN_ERR "SKGE: Could not register device.\n"); 4957 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
5051 free_netdev(dev); 4958 free_netdev(dev);
5052 pAC->dev[1] = pAC->dev[0]; 4959 pAC->dev[1] = pAC->dev[0];
5053 } else { 4960 } else {
5054 SkGeProcCreate(dev); 4961 SkGeProcCreate(dev);
5055 memcpy(&dev->dev_addr, 4962 memcpy(&dev->dev_addr,
5056 &pAC->Addr.Net[1].CurrentMacAddress, 6); 4963 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4964 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5057 4965
5058 printk("%s: %s\n", dev->name, pAC->DeviceStr); 4966 printk("%s: %s\n", dev->name, pAC->DeviceStr);
5059 printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); 4967 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");