aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/et131x/et1310_tx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/et131x/et1310_tx.c')
-rw-r--r--drivers/staging/et131x/et1310_tx.c1067
1 files changed, 237 insertions, 830 deletions
diff --git a/drivers/staging/et131x/et1310_tx.c b/drivers/staging/et131x/et1310_tx.c
index 30eaac4c8707..94f7752e2ccc 100644
--- a/drivers/staging/et131x/et1310_tx.c
+++ b/drivers/staging/et131x/et1310_tx.c
@@ -2,7 +2,7 @@
* Agere Systems Inc.
* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
* http://www.agere.com
*
@@ -19,7 +19,7 @@
* software indicates your acceptance of these terms and conditions. If you do
* not agree with these terms and conditions, do not use the software.
*
- * Copyright © 2005 Agere Systems Inc.
+ * Copyright © 2005 Agere Systems Inc.
* All rights reserved.
*
* Redistribution and use in source or binary forms, with or without
@@ -40,7 +40,7 @@
*
* Disclaimer
*
- * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
* USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
@@ -56,7 +56,6 @@
*/
#include "et131x_version.h"
-#include "et131x_debug.h"
#include "et131x_defs.h"
#include <linux/pci.h>
@@ -74,9 +73,9 @@
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
#include <asm/system.h>
-#include <asm/bitops.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
@@ -94,18 +93,14 @@
#include "et1310_tx.h"
-/* Data for debugging facilities */
-#ifdef CONFIG_ET131X_DEBUG
-extern dbg_info_t *et131x_dbginfo;
-#endif /* CONFIG_ET131X_DEBUG */
-static void et131x_update_tcb_list(struct et131x_adapter *pAdapter);
-static void et131x_check_send_wait_list(struct et131x_adapter *pAdapter);
-static inline void et131x_free_send_packet(struct et131x_adapter *pAdapter,
+static void et131x_update_tcb_list(struct et131x_adapter *etdev);
+static void et131x_check_send_wait_list(struct et131x_adapter *etdev);
+static inline void et131x_free_send_packet(struct et131x_adapter *etdev,
PMP_TCB pMpTcb);
static int et131x_send_packet(struct sk_buff *skb,
- struct et131x_adapter *pAdapter);
-static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb);
+ struct et131x_adapter *etdev);
+static int nic_send_packet(struct et131x_adapter *etdev, PMP_TCB pMpTcb);
/**
* et131x_tx_dma_memory_alloc
@@ -124,14 +119,11 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
int desc_size = 0;
TX_RING_t *tx_ring = &adapter->TxRing;
- DBG_ENTER(et131x_dbginfo);
-
/* Allocate memory for the TCB's (Transmit Control Block) */
- adapter->TxRing.MpTcbMem = (MP_TCB *) kcalloc(NUM_TCB, sizeof(MP_TCB),
+ adapter->TxRing.MpTcbMem = (MP_TCB *)kcalloc(NUM_TCB, sizeof(MP_TCB),
GFP_ATOMIC | GFP_DMA);
if (!adapter->TxRing.MpTcbMem) {
- DBG_ERROR(et131x_dbginfo, "Cannot alloc memory for TCBs\n");
- DBG_LEAVE(et131x_dbginfo);
+ dev_err(&adapter->pdev->dev, "Cannot alloc memory for TCBs\n");
return -ENOMEM;
}
@@ -143,8 +135,7 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
(PTX_DESC_ENTRY_t) pci_alloc_consistent(adapter->pdev, desc_size,
&tx_ring->pTxDescRingPa);
if (!adapter->TxRing.pTxDescRingVa) {
- DBG_ERROR(et131x_dbginfo, "Cannot alloc memory for Tx Ring\n");
- DBG_LEAVE(et131x_dbginfo);
+ dev_err(&adapter->pdev->dev, "Cannot alloc memory for Tx Ring\n");
return -ENOMEM;
}
@@ -169,9 +160,8 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
sizeof(TX_STATUS_BLOCK_t),
&tx_ring->pTxStatusPa);
if (!adapter->TxRing.pTxStatusPa) {
- DBG_ERROR(et131x_dbginfo,
- "Cannot alloc memory for Tx status block\n");
- DBG_LEAVE(et131x_dbginfo);
+ dev_err(&adapter->pdev->dev,
+ "Cannot alloc memory for Tx status block\n");
return -ENOMEM;
}
@@ -180,13 +170,11 @@ int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
NIC_MIN_PACKET_SIZE,
&tx_ring->pTxDummyBlkPa);
if (!adapter->TxRing.pTxDummyBlkPa) {
- DBG_ERROR(et131x_dbginfo,
- "Cannot alloc memory for Tx dummy buffer\n");
- DBG_LEAVE(et131x_dbginfo);
+ dev_err(&adapter->pdev->dev,
+ "Cannot alloc memory for Tx dummy buffer\n");
return -ENOMEM;
}
- DBG_LEAVE(et131x_dbginfo);
return 0;
}
@@ -200,8 +188,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
{
int desc_size = 0;
- DBG_ENTER(et131x_dbginfo);
-
if (adapter->TxRing.pTxDescRingVa) {
/* Free memory relating to Tx rings here */
adapter->TxRing.pTxDescRingVa -= adapter->TxRing.TxDescOffset;
@@ -238,32 +224,25 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
}
/* Free the memory for MP_TCB structures */
- if (adapter->TxRing.MpTcbMem) {
- kfree(adapter->TxRing.MpTcbMem);
- adapter->TxRing.MpTcbMem = NULL;
- }
-
- DBG_LEAVE(et131x_dbginfo);
+ kfree(adapter->TxRing.MpTcbMem);
}
/**
* ConfigTxDmaRegs - Set up the tx dma section of the JAGCore.
- * @adapter: pointer to our private adapter structure
+ * @etdev: pointer to our private adapter structure
*/
-void ConfigTxDmaRegs(struct et131x_adapter *pAdapter)
+void ConfigTxDmaRegs(struct et131x_adapter *etdev)
{
- struct _TXDMA_t __iomem *pTxDma = &pAdapter->CSRAddress->txdma;
-
- DBG_ENTER(et131x_dbginfo);
+ struct _TXDMA_t __iomem *txdma = &etdev->regs->txdma;
/* Load the hardware with the start of the transmit descriptor ring. */
- writel((uint32_t) (pAdapter->TxRing.pTxDescRingAdjustedPa >> 32),
- &pTxDma->pr_base_hi);
- writel((uint32_t) pAdapter->TxRing.pTxDescRingAdjustedPa,
- &pTxDma->pr_base_lo);
+ writel((uint32_t) (etdev->TxRing.pTxDescRingAdjustedPa >> 32),
+ &txdma->pr_base_hi);
+ writel((uint32_t) etdev->TxRing.pTxDescRingAdjustedPa,
+ &txdma->pr_base_lo);
/* Initialise the transmit DMA engine */
- writel(NUM_DESC_PER_RING_TX - 1, &pTxDma->pr_num_des.value);
+ writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des.value);
/* Load the completion writeback physical address
*
@@ -272,57 +251,44 @@ void ConfigTxDmaRegs(struct et131x_adapter *pAdapter)
* are ever returned, make sure the high part is retrieved here before
* storing the adjusted address.
*/
- writel(0, &pTxDma->dma_wb_base_hi);
- writel(pAdapter->TxRing.pTxStatusPa, &pTxDma->dma_wb_base_lo);
-
- memset(pAdapter->TxRing.pTxStatusVa, 0, sizeof(TX_STATUS_BLOCK_t));
+ writel(0, &txdma->dma_wb_base_hi);
+ writel(etdev->TxRing.pTxStatusPa, &txdma->dma_wb_base_lo);
- writel(0, &pTxDma->service_request.value);
- pAdapter->TxRing.txDmaReadyToSend.value = 0;
+ memset(etdev->TxRing.pTxStatusVa, 0, sizeof(TX_STATUS_BLOCK_t));
- DBG_LEAVE(et131x_dbginfo);
+ writel(0, &txdma->service_request);
+ etdev->TxRing.txDmaReadyToSend = 0;
}
/**
* et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310
- * @pAdapter: pointer to our adapter structure
+ * @etdev: pointer to our adapter structure
*/
-void et131x_tx_dma_disable(struct et131x_adapter *pAdapter)
+void et131x_tx_dma_disable(struct et131x_adapter *etdev)
{
- DBG_ENTER(et131x_dbginfo);
-
/* Setup the tramsmit dma configuration register */
- writel(0x101, &pAdapter->CSRAddress->txdma.csr.value);
-
- DBG_LEAVE(et131x_dbginfo);
+ writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT,
+ &etdev->regs->txdma.csr);
}
/**
* et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310.
- * @pAdapter: pointer to our adapter structure
+ * @etdev: pointer to our adapter structure
*
* Mainly used after a return to the D0 (full-power) state from a lower state.
*/
-void et131x_tx_dma_enable(struct et131x_adapter *pAdapter)
+void et131x_tx_dma_enable(struct et131x_adapter *etdev)
{
- DBG_ENTER(et131x_dbginfo);
-
- if (pAdapter->RegistryPhyLoopbk) {
- /* TxDMA is disabled for loopback operation. */
- writel(0x101, &pAdapter->CSRAddress->txdma.csr.value);
- } else {
- TXDMA_CSR_t csr = { 0 };
-
+ u32 csr = ET_TXDMA_SNGL_EPKT;
+ if (etdev->RegistryPhyLoopbk)
+ /* TxDMA is disabled for loopback operation. */
+ csr |= ET_TXDMA_CSR_HALT;
+ else
/* Setup the transmit dma configuration register for normal
* operation
*/
- csr.bits.sngl_epkt_mode = 1;
- csr.bits.halt = 0;
- csr.bits.cache_thrshld = pAdapter->RegistryDMACache;
- writel(csr.value, &pAdapter->CSRAddress->txdma.csr.value);
- }
-
- DBG_LEAVE(et131x_dbginfo);
+ csr |= PARM_DMA_CACHE_DEF << ET_TXDMA_CACHE_SHIFT;
+ writel(csr, &etdev->regs->txdma.csr);
}
/**
@@ -335,8 +301,6 @@ void et131x_init_send(struct et131x_adapter *adapter)
uint32_t TcbCount;
TX_RING_t *tx_ring;
- DBG_ENTER(et131x_dbginfo);
-
/* Setup some convenience pointers */
tx_ring = &adapter->TxRing;
pMpTcb = adapter->TxRing.MpTcbMem;
@@ -366,8 +330,6 @@ void et131x_init_send(struct et131x_adapter *adapter)
tx_ring->CurrSendTail = (PMP_TCB) NULL;
INIT_LIST_HEAD(&adapter->TxRing.SendWaitQueue);
-
- DBG_LEAVE(et131x_dbginfo);
}
/**
@@ -380,11 +342,9 @@ void et131x_init_send(struct et131x_adapter *adapter)
int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
{
int status = 0;
- struct et131x_adapter *pAdapter = NULL;
-
- DBG_TX_ENTER(et131x_dbginfo);
+ struct et131x_adapter *etdev = NULL;
- pAdapter = netdev_priv(netdev);
+ etdev = netdev_priv(netdev);
/* Send these packets
*
@@ -393,30 +353,29 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
*/
/* Queue is not empty or TCB is not available */
- if (!list_empty(&pAdapter->TxRing.SendWaitQueue) ||
- MP_TCB_RESOURCES_NOT_AVAILABLE(pAdapter)) {
+ if (!list_empty(&etdev->TxRing.SendWaitQueue) ||
+ MP_TCB_RESOURCES_NOT_AVAILABLE(etdev)) {
/* NOTE: If there's an error on send, no need to queue the
* packet under Linux; if we just send an error up to the
* netif layer, it will resend the skb to us.
*/
- DBG_VERBOSE(et131x_dbginfo, "TCB Resources Not Available\n");
status = -ENOMEM;
} else {
/* We need to see if the link is up; if it's not, make the
* netif layer think we're good and drop the packet
*/
- //if( MP_SHOULD_FAIL_SEND( pAdapter ) || pAdapter->DriverNoPhyAccess )
- if (MP_SHOULD_FAIL_SEND(pAdapter) || pAdapter->DriverNoPhyAccess
+ /*
+ * if( MP_SHOULD_FAIL_SEND( etdev ) ||
+ * etdev->DriverNoPhyAccess )
+ */
+ if (MP_SHOULD_FAIL_SEND(etdev) || etdev->DriverNoPhyAccess
|| !netif_carrier_ok(netdev)) {
- DBG_VERBOSE(et131x_dbginfo,
- "Can't Tx, Link is DOWN; drop the packet\n");
-
dev_kfree_skb_any(skb);
skb = NULL;
- pAdapter->net_stats.tx_dropped++;
+ etdev->net_stats.tx_dropped++;
} else {
- status = et131x_send_packet(skb, pAdapter);
+ status = et131x_send_packet(skb, etdev);
if (status == -ENOMEM) {
@@ -425,147 +384,113 @@ int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
* send an error up to the netif layer, it
* will resend the skb to us.
*/
- DBG_WARNING(et131x_dbginfo,
- "Resources problem, Queue tx packet\n");
} else if (status != 0) {
/* On any other error, make netif think we're
* OK and drop the packet
*/
- DBG_WARNING(et131x_dbginfo,
- "General error, drop packet\n");
-
dev_kfree_skb_any(skb);
skb = NULL;
-
- pAdapter->net_stats.tx_dropped++;
+ etdev->net_stats.tx_dropped++;
}
}
}
-
- DBG_TX_LEAVE(et131x_dbginfo);
return status;
}
/**
* et131x_send_packet - Do the work to send a packet
* @skb: the packet(s) to send
- * @pAdapter: a pointer to the device's private adapter structure
+ * @etdev: a pointer to the device's private adapter structure
*
* Return 0 in almost all cases; non-zero value in extreme hard failure only.
*
* Assumption: Send spinlock has been acquired
*/
static int et131x_send_packet(struct sk_buff *skb,
- struct et131x_adapter *pAdapter)
+ struct et131x_adapter *etdev)
{
int status = 0;
PMP_TCB pMpTcb = NULL;
- uint16_t *pShBufVa;
- unsigned long lockflags;
-
- DBG_TX_ENTER(et131x_dbginfo);
-
- /* Is our buffer scattered, or continuous? */
- if (skb_shinfo(skb)->nr_frags == 0) {
- DBG_TX(et131x_dbginfo, "Scattered buffer: NO\n");
- } else {
- DBG_TX(et131x_dbginfo, "Scattered buffer: YES, Num Frags: %d\n",
- skb_shinfo(skb)->nr_frags);
- }
+ uint16_t *shbufva;
+ unsigned long flags;
/* All packets must have at least a MAC address and a protocol type */
if (skb->len < ETH_HLEN) {
- DBG_ERROR(et131x_dbginfo,
- "Packet size < ETH_HLEN (14 bytes)\n");
- DBG_LEAVE(et131x_dbginfo);
return -EIO;
}
/* Get a TCB for this packet */
- spin_lock_irqsave(&pAdapter->TCBReadyQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBReadyQLock, flags);
- pMpTcb = pAdapter->TxRing.TCBReadyQueueHead;
+ pMpTcb = etdev->TxRing.TCBReadyQueueHead;
if (pMpTcb == NULL) {
- spin_unlock_irqrestore(&pAdapter->TCBReadyQLock, lockflags);
-
- DBG_WARNING(et131x_dbginfo, "Can't obtain a TCB\n");
- DBG_TX_LEAVE(et131x_dbginfo);
+ spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags);
return -ENOMEM;
}
- pAdapter->TxRing.TCBReadyQueueHead = pMpTcb->Next;
+ etdev->TxRing.TCBReadyQueueHead = pMpTcb->Next;
- if (pAdapter->TxRing.TCBReadyQueueHead == NULL) {
- pAdapter->TxRing.TCBReadyQueueTail = NULL;
- }
+ if (etdev->TxRing.TCBReadyQueueHead == NULL)
+ etdev->TxRing.TCBReadyQueueTail = NULL;
- spin_unlock_irqrestore(&pAdapter->TCBReadyQLock, lockflags);
+ spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags);
pMpTcb->PacketLength = skb->len;
pMpTcb->Packet = skb;
if ((skb->data != NULL) && ((skb->len - skb->data_len) >= 6)) {
- pShBufVa = (uint16_t *) skb->data;
+ shbufva = (uint16_t *) skb->data;
- if ((pShBufVa[0] == 0xffff) &&
- (pShBufVa[1] == 0xffff) && (pShBufVa[2] == 0xffff)) {
- MP_SET_FLAG(pMpTcb, fMP_DEST_BROAD);
- } else if ((pShBufVa[0] & 0x3) == 0x0001) {
- MP_SET_FLAG(pMpTcb, fMP_DEST_MULTI);
+ if ((shbufva[0] == 0xffff) &&
+ (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) {
+ pMpTcb->Flags |= fMP_DEST_BROAD;
+ } else if ((shbufva[0] & 0x3) == 0x0001) {
+ pMpTcb->Flags |= fMP_DEST_MULTI;
}
}
pMpTcb->Next = NULL;
/* Call the NIC specific send handler. */
- if (status == 0) {
- status = nic_send_packet(pAdapter, pMpTcb);
- }
+ if (status == 0)
+ status = nic_send_packet(etdev, pMpTcb);
if (status != 0) {
- spin_lock_irqsave(&pAdapter->TCBReadyQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBReadyQLock, flags);
- if (pAdapter->TxRing.TCBReadyQueueTail) {
- pAdapter->TxRing.TCBReadyQueueTail->Next = pMpTcb;
+ if (etdev->TxRing.TCBReadyQueueTail) {
+ etdev->TxRing.TCBReadyQueueTail->Next = pMpTcb;
} else {
/* Apparently ready Q is empty. */
- pAdapter->TxRing.TCBReadyQueueHead = pMpTcb;
+ etdev->TxRing.TCBReadyQueueHead = pMpTcb;
}
- pAdapter->TxRing.TCBReadyQueueTail = pMpTcb;
-
- spin_unlock_irqrestore(&pAdapter->TCBReadyQLock, lockflags);
-
- DBG_TX_LEAVE(et131x_dbginfo);
+ etdev->TxRing.TCBReadyQueueTail = pMpTcb;
+ spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags);
return status;
}
-
- DBG_ASSERT(pAdapter->TxRing.nBusySend <= NUM_TCB);
-
- DBG_TX_LEAVE(et131x_dbginfo);
+ WARN_ON(etdev->TxRing.nBusySend > NUM_TCB);
return 0;
}
/**
* nic_send_packet - NIC specific send handler for version B silicon.
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
* @pMpTcb: pointer to MP_TCB
*
* Returns 0 or errno.
*/
-static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
+static int nic_send_packet(struct et131x_adapter *etdev, PMP_TCB pMpTcb)
{
uint32_t loopIndex;
TX_DESC_ENTRY_t CurDesc[24];
uint32_t FragmentNumber = 0;
- uint32_t iThisCopy, iRemainder;
+ uint32_t thiscopy, remainder;
struct sk_buff *pPacket = pMpTcb->Packet;
uint32_t FragListCount = skb_shinfo(pPacket)->nr_frags + 1;
struct skb_frag_struct *pFragList = &skb_shinfo(pPacket)->frags[0];
- unsigned long lockflags1, lockflags2;
-
- DBG_TX_ENTER(et131x_dbginfo);
+ unsigned long flags;
/* Part of the optimizations of this send routine restrict us to
* sending 24 fragments at a pass. In practice we should never see
@@ -576,7 +501,6 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* although it is less efficient.
*/
if (FragListCount > 23) {
- DBG_TX_LEAVE(et131x_dbginfo);
return -EIO;
}
@@ -597,16 +521,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* doesn't seem to like large fragments.
*/
if ((pPacket->len - pPacket->data_len) <= 1514) {
- DBG_TX(et131x_dbginfo,
- "Got packet of length %d, "
- "filling desc entry %d, "
- "TCB: 0x%p\n",
- (pPacket->len - pPacket->data_len),
- pAdapter->TxRing.txDmaReadyToSend.bits.
- val, pMpTcb);
-
CurDesc[FragmentNumber].DataBufferPtrHigh = 0;
-
CurDesc[FragmentNumber].word2.bits.
length_in_bytes =
pPacket->len - pPacket->data_len;
@@ -620,22 +535,13 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* subsystem)
*/
CurDesc[FragmentNumber++].DataBufferPtrLow =
- pci_map_single(pAdapter->pdev,
+ pci_map_single(etdev->pdev,
pPacket->data,
pPacket->len -
pPacket->data_len,
PCI_DMA_TODEVICE);
} else {
- DBG_TX(et131x_dbginfo,
- "Got packet of length %d, "
- "filling desc entry %d, "
- "TCB: 0x%p\n",
- (pPacket->len - pPacket->data_len),
- pAdapter->TxRing.txDmaReadyToSend.bits.
- val, pMpTcb);
-
CurDesc[FragmentNumber].DataBufferPtrHigh = 0;
-
CurDesc[FragmentNumber].word2.bits.
length_in_bytes =
((pPacket->len - pPacket->data_len) / 2);
@@ -649,7 +555,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* subsystem)
*/
CurDesc[FragmentNumber++].DataBufferPtrLow =
- pci_map_single(pAdapter->pdev,
+ pci_map_single(etdev->pdev,
pPacket->data,
((pPacket->len -
pPacket->data_len) / 2),
@@ -669,7 +575,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* subsystem)
*/
CurDesc[FragmentNumber++].DataBufferPtrLow =
- pci_map_single(pAdapter->pdev,
+ pci_map_single(etdev->pdev,
pPacket->data +
((pPacket->len -
pPacket->data_len) / 2),
@@ -678,16 +584,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
PCI_DMA_TODEVICE);
}
} else {
- DBG_TX(et131x_dbginfo,
- "Got packet of length %d,"
- "filling desc entry %d\n"
- "TCB: 0x%p\n",
- pFragList[loopIndex].size,
- pAdapter->TxRing.txDmaReadyToSend.bits.val,
- pMpTcb);
-
CurDesc[FragmentNumber].DataBufferPtrHigh = 0;
-
CurDesc[FragmentNumber].word2.bits.length_in_bytes =
pFragList[loopIndex - 1].size;
@@ -698,7 +595,7 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
* addressable (as defined by the pci/dma subsystem)
*/
CurDesc[FragmentNumber++].DataBufferPtrLow =
- pci_map_page(pAdapter->pdev,
+ pci_map_page(etdev->pdev,
pFragList[loopIndex - 1].page,
pFragList[loopIndex - 1].page_offset,
pFragList[loopIndex - 1].size,
@@ -706,16 +603,14 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
}
}
- if (FragmentNumber == 0) {
- DBG_WARNING(et131x_dbginfo, "No. frags is 0\n");
+ if (FragmentNumber == 0)
return -EIO;
- }
- if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) {
- if (++pAdapter->TxRing.TxPacketsSinceLastinterrupt ==
- pAdapter->RegistryTxNumBuffers) {
+ if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS) {
+ if (++etdev->TxRing.TxPacketsSinceLastinterrupt ==
+ PARM_TX_NUM_BUFS_DEF) {
CurDesc[FragmentNumber - 1].word3.value = 0x5;
- pAdapter->TxRing.TxPacketsSinceLastinterrupt = 0;
+ etdev->TxRing.TxPacketsSinceLastinterrupt = 0;
} else {
CurDesc[FragmentNumber - 1].word3.value = 0x1;
}
@@ -725,529 +620,101 @@ static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
CurDesc[0].word3.bits.f = 1;
- pMpTcb->WrIndexStart = pAdapter->TxRing.txDmaReadyToSend;
+ pMpTcb->WrIndexStart = etdev->TxRing.txDmaReadyToSend;
pMpTcb->PacketStaleCount = 0;
- spin_lock_irqsave(&pAdapter->SendHWLock, lockflags1);
+ spin_lock_irqsave(&etdev->SendHWLock, flags);
- iThisCopy =
- NUM_DESC_PER_RING_TX - pAdapter->TxRing.txDmaReadyToSend.bits.val;
+ thiscopy = NUM_DESC_PER_RING_TX -
+ INDEX10(etdev->TxRing.txDmaReadyToSend);
- if (iThisCopy >= FragmentNumber) {
- iRemainder = 0;
- iThisCopy = FragmentNumber;
+ if (thiscopy >= FragmentNumber) {
+ remainder = 0;
+ thiscopy = FragmentNumber;
} else {
- iRemainder = FragmentNumber - iThisCopy;
+ remainder = FragmentNumber - thiscopy;
}
- memcpy(pAdapter->TxRing.pTxDescRingVa +
- pAdapter->TxRing.txDmaReadyToSend.bits.val, CurDesc,
- sizeof(TX_DESC_ENTRY_t) * iThisCopy);
+ memcpy(etdev->TxRing.pTxDescRingVa +
+ INDEX10(etdev->TxRing.txDmaReadyToSend), CurDesc,
+ sizeof(TX_DESC_ENTRY_t) * thiscopy);
- pAdapter->TxRing.txDmaReadyToSend.bits.val += iThisCopy;
+ add_10bit(&etdev->TxRing.txDmaReadyToSend, thiscopy);
- if ((pAdapter->TxRing.txDmaReadyToSend.bits.val == 0) ||
- (pAdapter->TxRing.txDmaReadyToSend.bits.val ==
- NUM_DESC_PER_RING_TX)) {
- if (pAdapter->TxRing.txDmaReadyToSend.bits.wrap) {
- pAdapter->TxRing.txDmaReadyToSend.value = 0;
- } else {
- pAdapter->TxRing.txDmaReadyToSend.value = 0x400;
- }
+ if (INDEX10(etdev->TxRing.txDmaReadyToSend)== 0 ||
+ INDEX10(etdev->TxRing.txDmaReadyToSend) == NUM_DESC_PER_RING_TX) {
+ etdev->TxRing.txDmaReadyToSend &= ~ET_DMA10_MASK;
+ etdev->TxRing.txDmaReadyToSend ^= ET_DMA10_WRAP;
}
- if (iRemainder) {
- memcpy(pAdapter->TxRing.pTxDescRingVa,
- CurDesc + iThisCopy,
- sizeof(TX_DESC_ENTRY_t) * iRemainder);
+ if (remainder) {
+ memcpy(etdev->TxRing.pTxDescRingVa,
+ CurDesc + thiscopy,
+ sizeof(TX_DESC_ENTRY_t) * remainder);
- pAdapter->TxRing.txDmaReadyToSend.bits.val += iRemainder;
+ add_10bit(&etdev->TxRing.txDmaReadyToSend, remainder);
}
- if (pAdapter->TxRing.txDmaReadyToSend.bits.val == 0) {
- if (pAdapter->TxRing.txDmaReadyToSend.value) {
- pMpTcb->WrIndex.value = NUM_DESC_PER_RING_TX - 1;
- } else {
- pMpTcb->WrIndex.value =
- 0x400 | (NUM_DESC_PER_RING_TX - 1);
- }
- } else {
- pMpTcb->WrIndex.value =
- pAdapter->TxRing.txDmaReadyToSend.value - 1;
- }
+ if (INDEX10(etdev->TxRing.txDmaReadyToSend) == 0) {
+ if (etdev->TxRing.txDmaReadyToSend)
+ pMpTcb->WrIndex = NUM_DESC_PER_RING_TX - 1;
+ else
+ pMpTcb->WrIndex= ET_DMA10_WRAP | (NUM_DESC_PER_RING_TX - 1);
+ } else
+ pMpTcb->WrIndex = etdev->TxRing.txDmaReadyToSend - 1;
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags2);
+ spin_lock(&etdev->TCBSendQLock);
- if (pAdapter->TxRing.CurrSendTail) {
- pAdapter->TxRing.CurrSendTail->Next = pMpTcb;
- } else {
- pAdapter->TxRing.CurrSendHead = pMpTcb;
- }
+ if (etdev->TxRing.CurrSendTail)
+ etdev->TxRing.CurrSendTail->Next = pMpTcb;
+ else
+ etdev->TxRing.CurrSendHead = pMpTcb;
- pAdapter->TxRing.CurrSendTail = pMpTcb;
+ etdev->TxRing.CurrSendTail = pMpTcb;
- DBG_ASSERT(pMpTcb->Next == NULL);
+ WARN_ON(pMpTcb->Next != NULL);
- pAdapter->TxRing.nBusySend++;
+ etdev->TxRing.nBusySend++;
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags2);
+ spin_unlock(&etdev->TCBSendQLock);
/* Write the new write pointer back to the device. */
- writel(pAdapter->TxRing.txDmaReadyToSend.value,
- &pAdapter->CSRAddress->txdma.service_request.value);
+ writel(etdev->TxRing.txDmaReadyToSend,
+ &etdev->regs->txdma.service_request);
/* For Gig only, we use Tx Interrupt coalescing. Enable the software
* timer to wake us up if this packet isn't followed by N more.
*/
- if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) {
- writel(pAdapter->RegistryTxTimeInterval * NANO_IN_A_MICRO,
- &pAdapter->CSRAddress->global.watchdog_timer);
+ if (etdev->linkspeed == TRUEPHY_SPEED_1000MBPS) {
+ writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO,
+ &etdev->regs->global.watchdog_timer);
}
+ spin_unlock_irqrestore(&etdev->SendHWLock, flags);
- spin_unlock_irqrestore(&pAdapter->SendHWLock, lockflags1);
-
- DBG_TX_LEAVE(et131x_dbginfo);
return 0;
}
-/*
- * NOTE: For now, keep this older version of NICSendPacket around for
- * reference, even though it's not used
- */
-#if 0
-
-/**
- * NICSendPacket - NIC specific send handler.
- * @pAdapter: pointer to our adapter
- * @pMpTcb: pointer to MP_TCB
- *
- * Returns 0 on succes, errno on failure.
- *
- * This version of the send routine is designed for version A silicon.
- * Assumption - Send spinlock has been acquired.
- */
-static int nic_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
-{
- uint32_t loopIndex, fragIndex, loopEnd;
- uint32_t iSplitFirstElement = 0;
- uint32_t SegmentSize = 0;
- TX_DESC_ENTRY_t CurDesc;
- TX_DESC_ENTRY_t *CurDescPostCopy = NULL;
- uint32_t SlotsAvailable;
- DMA10W_t ServiceComplete;
- unsigned int lockflags1, lockflags2;
- struct sk_buff *pPacket = pMpTcb->Packet;
- uint32_t FragListCount = skb_shinfo(pPacket)->nr_frags + 1;
- struct skb_frag_struct *pFragList = &skb_shinfo(pPacket)->frags[0];
-
- DBG_TX_ENTER(et131x_dbginfo);
-
- ServiceComplete.value =
- readl(&pAdapter->CSRAddress->txdma.NewServiceComplete.value);
-
- /*
- * Attempt to fix TWO hardware bugs:
- * 1) NEVER write an odd number of descriptors.
- * 2) If packet length is less than NIC_MIN_PACKET_SIZE, then pad the
- * packet to NIC_MIN_PACKET_SIZE bytes by adding a new last
- * descriptor IN HALF DUPLEX MODE ONLY
- * NOTE that (2) interacts with (1). If the packet is less than
- * NIC_MIN_PACKET_SIZE bytes then we will append a descriptor.
- * Therefore if it is even now, it will eventually end up odd, and
- * so will need adjusting.
- *
- * VLAN tags get involved since VLAN tags add another one or two
- * segments.
- */
- DBG_TX(et131x_dbginfo,
- "pMpTcb->PacketLength: %d\n", pMpTcb->PacketLength);
-
- if ((pAdapter->uiDuplexMode == 0)
- && (pMpTcb->PacketLength < NIC_MIN_PACKET_SIZE)) {
- DBG_TX(et131x_dbginfo,
- "HALF DUPLEX mode AND len < MIN_PKT_SIZE\n");
- if ((FragListCount & 0x1) == 0) {
- DBG_TX(et131x_dbginfo,
- "Even number of descs, split 1st elem\n");
- iSplitFirstElement = 1;
- //SegmentSize = pFragList[0].size / 2;
- SegmentSize = (pPacket->len - pPacket->data_len) / 2;
- }
- } else if (FragListCount & 0x1) {
- DBG_TX(et131x_dbginfo, "Odd number of descs, split 1st elem\n");
-
- iSplitFirstElement = 1;
- //SegmentSize = pFragList[0].size / 2;
- SegmentSize = (pPacket->len - pPacket->data_len) / 2;
- }
-
- spin_lock_irqsave(&pAdapter->SendHWLock, lockflags1);
-
- if (pAdapter->TxRing.txDmaReadyToSend.bits.serv_req_wrap ==
- ServiceComplete.bits.serv_cpl_wrap) {
- /* The ring hasn't wrapped. Slots available should be
- * (RING_SIZE) - the difference between the two pointers.
- */
- SlotsAvailable = NUM_DESC_PER_RING_TX -
- (pAdapter->TxRing.txDmaReadyToSend.bits.serv_req -
- ServiceComplete.bits.serv_cpl);
- } else {
- /* The ring has wrapped. Slots available should be the
- * difference between the two pointers.
- */
- SlotsAvailable = ServiceComplete.bits.serv_cpl -
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req;
- }
-
- if ((FragListCount + iSplitFirstElement) > SlotsAvailable) {
- DBG_WARNING(et131x_dbginfo,
- "Not Enough Space in Tx Desc Ring\n");
- spin_unlock_irqrestore(&pAdapter->SendHWLock, lockflags1);
- return -ENOMEM;
- }
-
- loopEnd = (FragListCount) + iSplitFirstElement;
- fragIndex = 0;
-
- DBG_TX(et131x_dbginfo,
- "TCB : 0x%p\n"
- "Packet (SKB) : 0x%p\t Packet->len: %d\t Packet->data_len: %d\n"
- "FragListCount : %d\t iSplitFirstElement: %d\t loopEnd:%d\n",
- pMpTcb,
- pPacket, pPacket->len, pPacket->data_len,
- FragListCount, iSplitFirstElement, loopEnd);
-
- for (loopIndex = 0; loopIndex < loopEnd; loopIndex++) {
- if (loopIndex > iSplitFirstElement) {
- fragIndex++;
- }
-
- DBG_TX(et131x_dbginfo,
- "In loop, loopIndex: %d\t fragIndex: %d\n", loopIndex,
- fragIndex);
-
- /* If there is something in this element, let's get a
- * descriptor from the ring and get the necessary data
- */
- DBG_TX(et131x_dbginfo,
- "Packet Length %d,"
- "filling desc entry %d\n",
- pPacket->len,
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req);
-
- // NOTE - Should we do a paranoia check here to make sure the fragment
- // actually has a length? It's HIGHLY unlikely the fragment would
- // contain no data...
- if (1) {
- // NOTE - Currently always getting 32-bit addrs, and dma_addr_t is
- // only 32-bit, so leave "high" ptr value out for now
- CurDesc.DataBufferPtrHigh = 0;
-
- CurDesc.word2.value = 0;
- CurDesc.word3.value = 0;
-
- if (fragIndex == 0) {
- if (iSplitFirstElement) {
- DBG_TX(et131x_dbginfo,
- "Split first element: YES\n");
-
- if (loopIndex == 0) {
- DBG_TX(et131x_dbginfo,
- "Got fragment of length %d, fragIndex: %d\n",
- pPacket->len -
- pPacket->data_len,
- fragIndex);
- DBG_TX(et131x_dbginfo,
- "SegmentSize: %d\n",
- SegmentSize);
-
- CurDesc.word2.bits.
- length_in_bytes =
- SegmentSize;
- CurDesc.DataBufferPtrLow =
- pci_map_single(pAdapter->
- pdev,
- pPacket->
- data,
- SegmentSize,
- PCI_DMA_TODEVICE);
- DBG_TX(et131x_dbginfo,
- "pci_map_single() returns: 0x%08x\n",
- CurDesc.
- DataBufferPtrLow);
- } else {
- DBG_TX(et131x_dbginfo,
- "Got fragment of length %d, fragIndex: %d\n",
- pPacket->len -
- pPacket->data_len,
- fragIndex);
- DBG_TX(et131x_dbginfo,
- "Leftover Size: %d\n",
- (pPacket->len -
- pPacket->data_len -
- SegmentSize));
-
- CurDesc.word2.bits.
- length_in_bytes =
- ((pPacket->len -
- pPacket->data_len) -
- SegmentSize);
- CurDesc.DataBufferPtrLow =
- pci_map_single(pAdapter->
- pdev,
- (pPacket->
- data +
- SegmentSize),
- (pPacket->
- len -
- pPacket->
- data_len -
- SegmentSize),
- PCI_DMA_TODEVICE);
- DBG_TX(et131x_dbginfo,
- "pci_map_single() returns: 0x%08x\n",
- CurDesc.
- DataBufferPtrLow);
- }
- } else {
- DBG_TX(et131x_dbginfo,
- "Split first element: NO\n");
-
- CurDesc.word2.bits.length_in_bytes =
- pPacket->len - pPacket->data_len;
-
- CurDesc.DataBufferPtrLow =
- pci_map_single(pAdapter->pdev,
- pPacket->data,
- (pPacket->len -
- pPacket->data_len),
- PCI_DMA_TODEVICE);
- DBG_TX(et131x_dbginfo,
- "pci_map_single() returns: 0x%08x\n",
- CurDesc.DataBufferPtrLow);
- }
- } else {
-
- CurDesc.word2.bits.length_in_bytes =
- pFragList[fragIndex - 1].size;
- CurDesc.DataBufferPtrLow =
- pci_map_page(pAdapter->pdev,
- pFragList[fragIndex - 1].page,
- pFragList[fragIndex -
- 1].page_offset,
- pFragList[fragIndex - 1].size,
- PCI_DMA_TODEVICE);
- DBG_TX(et131x_dbginfo,
- "pci_map_page() returns: 0x%08x\n",
- CurDesc.DataBufferPtrLow);
- }
-
- if (loopIndex == 0) {
- /* This is the first descriptor of the packet
- *
- * Set the "f" bit to indicate this is the
- * first descriptor in the packet.
- */
- DBG_TX(et131x_dbginfo,
- "This is our FIRST descriptor\n");
- CurDesc.word3.bits.f = 1;
-
- pMpTcb->WrIndexStart =
- pAdapter->TxRing.txDmaReadyToSend;
- }
-
- if ((loopIndex == (loopEnd - 1)) &&
- (pAdapter->uiDuplexMode ||
- (pMpTcb->PacketLength >= NIC_MIN_PACKET_SIZE))) {
- /* This is the Last descriptor of the packet */
- DBG_TX(et131x_dbginfo,
- "THIS is our LAST descriptor\n");
-
- if (pAdapter->uiLinkSpeed ==
- TRUEPHY_SPEED_1000MBPS) {
- if (++pAdapter->TxRing.
- TxPacketsSinceLastinterrupt >=
- pAdapter->RegistryTxNumBuffers) {
- CurDesc.word3.value = 0x5;
- pAdapter->TxRing.
- TxPacketsSinceLastinterrupt
- = 0;
- } else {
- CurDesc.word3.value = 0x1;
- }
- } else {
- CurDesc.word3.value = 0x5;
- }
-
- /* Following index will be used during freeing
- * of packet
- */
- pMpTcb->WrIndex =
- pAdapter->TxRing.txDmaReadyToSend;
- pMpTcb->PacketStaleCount = 0;
- }
-
- /* Copy the descriptor (filled above) into the
- * descriptor ring at the next free entry. Advance
- * the "next free entry" variable
- */
- memcpy(pAdapter->TxRing.pTxDescRingVa +
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req,
- &CurDesc, sizeof(TX_DESC_ENTRY_t));
-
- CurDescPostCopy =
- pAdapter->TxRing.pTxDescRingVa +
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req;
-
- DBG_TX(et131x_dbginfo,
- "CURRENT DESCRIPTOR\n"
- "\tAddress : 0x%p\n"
- "\tDataBufferPtrHigh : 0x%08x\n"
- "\tDataBufferPtrLow : 0x%08x\n"
- "\tword2 : 0x%08x\n"
- "\tword3 : 0x%08x\n",
- CurDescPostCopy,
- CurDescPostCopy->DataBufferPtrHigh,
- CurDescPostCopy->DataBufferPtrLow,
- CurDescPostCopy->word2.value,
- CurDescPostCopy->word3.value);
-
- if (++pAdapter->TxRing.txDmaReadyToSend.bits.serv_req >=
- NUM_DESC_PER_RING_TX) {
- if (pAdapter->TxRing.txDmaReadyToSend.bits.
- serv_req_wrap) {
- pAdapter->TxRing.txDmaReadyToSend.
- value = 0;
- } else {
- pAdapter->TxRing.txDmaReadyToSend.
- value = 0x400;
- }
- }
- }
- }
-
- if (pAdapter->uiDuplexMode == 0 &&
- pMpTcb->PacketLength < NIC_MIN_PACKET_SIZE) {
- // NOTE - Same 32/64-bit issue as above...
- CurDesc.DataBufferPtrHigh = 0x0;
- CurDesc.DataBufferPtrLow = pAdapter->TxRing.pTxDummyBlkPa;
- CurDesc.word2.value = 0;
-
- if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) {
- if (++pAdapter->TxRing.TxPacketsSinceLastinterrupt >=
- pAdapter->RegistryTxNumBuffers) {
- CurDesc.word3.value = 0x5;
- pAdapter->TxRing.TxPacketsSinceLastinterrupt =
- 0;
- } else {
- CurDesc.word3.value = 0x1;
- }
- } else {
- CurDesc.word3.value = 0x5;
- }
-
- CurDesc.word2.bits.length_in_bytes =
- NIC_MIN_PACKET_SIZE - pMpTcb->PacketLength;
-
- pMpTcb->WrIndex = pAdapter->TxRing.txDmaReadyToSend;
-
- memcpy(pAdapter->TxRing.pTxDescRingVa +
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req,
- &CurDesc, sizeof(TX_DESC_ENTRY_t));
-
- CurDescPostCopy =
- pAdapter->TxRing.pTxDescRingVa +
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req;
-
- DBG_TX(et131x_dbginfo,
- "CURRENT DESCRIPTOR\n"
- "\tAddress : 0x%p\n"
- "\tDataBufferPtrHigh : 0x%08x\n"
- "\tDataBufferPtrLow : 0x%08x\n"
- "\tword2 : 0x%08x\n"
- "\tword3 : 0x%08x\n",
- CurDescPostCopy,
- CurDescPostCopy->DataBufferPtrHigh,
- CurDescPostCopy->DataBufferPtrLow,
- CurDescPostCopy->word2.value,
- CurDescPostCopy->word3.value);
-
- if (++pAdapter->TxRing.txDmaReadyToSend.bits.serv_req >=
- NUM_DESC_PER_RING_TX) {
- if (pAdapter->TxRing.txDmaReadyToSend.bits.
- serv_req_wrap) {
- pAdapter->TxRing.txDmaReadyToSend.value = 0;
- } else {
- pAdapter->TxRing.txDmaReadyToSend.value = 0x400;
- }
- }
-
- DBG_TX(et131x_dbginfo, "Padding descriptor %d by %d bytes\n",
- //pAdapter->TxRing.txDmaReadyToSend.value,
- pAdapter->TxRing.txDmaReadyToSend.bits.serv_req,
- NIC_MIN_PACKET_SIZE - pMpTcb->PacketLength);
- }
-
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags2);
-
- if (pAdapter->TxRing.CurrSendTail) {
- pAdapter->TxRing.CurrSendTail->Next = pMpTcb;
- } else {
- pAdapter->TxRing.CurrSendHead = pMpTcb;
- }
-
- pAdapter->TxRing.CurrSendTail = pMpTcb;
-
- DBG_ASSERT(pMpTcb->Next == NULL);
-
- pAdapter->TxRing.nBusySend++;
-
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags2);
-
- /* Write the new write pointer back to the device. */
- writel(pAdapter->TxRing.txDmaReadyToSend.value,
- &pAdapter->CSRAddress->txdma.service_request.value);
-
-#ifdef CONFIG_ET131X_DEBUG
- DumpDeviceBlock(DBG_TX_ON, pAdapter, 1);
-#endif
-
- /* For Gig only, we use Tx Interrupt coalescing. Enable the software
- * timer to wake us up if this packet isn't followed by N more.
- */
- if (pAdapter->uiLinkSpeed == TRUEPHY_SPEED_1000MBPS) {
- writel(pAdapter->RegistryTxTimeInterval * NANO_IN_A_MICRO,
- &pAdapter->CSRAddress->global.watchdog_timer);
- }
-
- spin_unlock_irqrestore(&pAdapter->SendHWLock, lockflags1);
-
- DBG_TX_LEAVE(et131x_dbginfo);
- return 0;
-}
-
-#endif
/**
* et131x_free_send_packet - Recycle a MP_TCB, complete the packet if necessary
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
* @pMpTcb: pointer to MP_TCB
*
* Assumption - Send spinlock has been acquired
*/
-__inline void et131x_free_send_packet(struct et131x_adapter *pAdapter, PMP_TCB pMpTcb)
+inline void et131x_free_send_packet(struct et131x_adapter *etdev,
+ PMP_TCB pMpTcb)
{
- unsigned long lockflags;
+ unsigned long flags;
TX_DESC_ENTRY_t *desc = NULL;
- struct net_device_stats *stats = &pAdapter->net_stats;
+ struct net_device_stats *stats = &etdev->net_stats;
- if (MP_TEST_FLAG(pMpTcb, fMP_DEST_BROAD)) {
- atomic_inc(&pAdapter->Stats.brdcstxmt);
- } else if (MP_TEST_FLAG(pMpTcb, fMP_DEST_MULTI)) {
- atomic_inc(&pAdapter->Stats.multixmt);
- } else {
- atomic_inc(&pAdapter->Stats.unixmt);
- }
+ if (pMpTcb->Flags & fMP_DEST_BROAD)
+ atomic_inc(&etdev->Stats.brdcstxmt);
+ else if (pMpTcb->Flags & fMP_DEST_MULTI)
+ atomic_inc(&etdev->Stats.multixmt);
+ else
+ atomic_inc(&etdev->Stats.unixmt);
if (pMpTcb->Packet) {
stats->tx_bytes += pMpTcb->Packet->len;
@@ -1256,60 +723,23 @@ __inline void et131x_free_send_packet(struct et131x_adapter *pAdapter, PMP_TCB p
* corresponding to this packet and umap the fragments
* they point to
*/
- DBG_TX(et131x_dbginfo,
- "Unmap descriptors Here\n"
- "TCB : 0x%p\n"
- "TCB Next : 0x%p\n"
- "TCB PacketLength : %d\n"
- "TCB WrIndex.value : 0x%08x\n"
- "TCB WrIndex.bits.val : %d\n"
- "TCB WrIndex.value : 0x%08x\n"
- "TCB WrIndex.bits.val : %d\n",
- pMpTcb,
- pMpTcb->Next,
- pMpTcb->PacketLength,
- pMpTcb->WrIndexStart.value,
- pMpTcb->WrIndexStart.bits.val,
- pMpTcb->WrIndex.value,
- pMpTcb->WrIndex.bits.val);
-
do {
desc =
- (TX_DESC_ENTRY_t *) (pAdapter->TxRing.
- pTxDescRingVa +
- pMpTcb->WrIndexStart.bits.val);
-
- DBG_TX(et131x_dbginfo,
- "CURRENT DESCRIPTOR\n"
- "\tAddress : 0x%p\n"
- "\tDataBufferPtrHigh : 0x%08x\n"
- "\tDataBufferPtrLow : 0x%08x\n"
- "\tword2 : 0x%08x\n"
- "\tword3 : 0x%08x\n",
- desc,
- desc->DataBufferPtrHigh,
- desc->DataBufferPtrLow,
- desc->word2.value,
- desc->word3.value);
-
- pci_unmap_single(pAdapter->pdev,
+ (TX_DESC_ENTRY_t *) (etdev->TxRing.pTxDescRingVa +
+ INDEX10(pMpTcb->WrIndexStart));
+
+ pci_unmap_single(etdev->pdev,
desc->DataBufferPtrLow,
desc->word2.value, PCI_DMA_TODEVICE);
- if (++pMpTcb->WrIndexStart.bits.val >=
+ add_10bit(&pMpTcb->WrIndexStart, 1);
+ if (INDEX10(pMpTcb->WrIndexStart) >=
NUM_DESC_PER_RING_TX) {
- if (pMpTcb->WrIndexStart.bits.wrap) {
- pMpTcb->WrIndexStart.value = 0;
- } else {
- pMpTcb->WrIndexStart.value = 0x400;
- }
+ pMpTcb->WrIndexStart &= ~ET_DMA10_MASK;
+ pMpTcb->WrIndexStart ^= ET_DMA10_WRAP;
}
- }
- while (desc != (pAdapter->TxRing.pTxDescRingVa +
- pMpTcb->WrIndex.bits.val));
-
- DBG_TX(et131x_dbginfo,
- "Free Packet (SKB) : 0x%p\n", pMpTcb->Packet);
+ } while (desc != (etdev->TxRing.pTxDescRingVa +
+ INDEX10(pMpTcb->WrIndex)));
dev_kfree_skb_any(pMpTcb->Packet);
}
@@ -1317,206 +747,183 @@ __inline void et131x_free_send_packet(struct et131x_adapter *pAdapter, PMP_TCB p
memset(pMpTcb, 0, sizeof(MP_TCB));
/* Add the TCB to the Ready Q */
- spin_lock_irqsave(&pAdapter->TCBReadyQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBReadyQLock, flags);
- pAdapter->Stats.opackets++;
+ etdev->Stats.opackets++;
- if (pAdapter->TxRing.TCBReadyQueueTail) {
- pAdapter->TxRing.TCBReadyQueueTail->Next = pMpTcb;
+ if (etdev->TxRing.TCBReadyQueueTail) {
+ etdev->TxRing.TCBReadyQueueTail->Next = pMpTcb;
} else {
/* Apparently ready Q is empty. */
- pAdapter->TxRing.TCBReadyQueueHead = pMpTcb;
+ etdev->TxRing.TCBReadyQueueHead = pMpTcb;
}
- pAdapter->TxRing.TCBReadyQueueTail = pMpTcb;
+ etdev->TxRing.TCBReadyQueueTail = pMpTcb;
- spin_unlock_irqrestore(&pAdapter->TCBReadyQLock, lockflags);
-
- DBG_ASSERT(pAdapter->TxRing.nBusySend >= 0);
+ spin_unlock_irqrestore(&etdev->TCBReadyQLock, flags);
+ WARN_ON(etdev->TxRing.nBusySend < 0);
}
/**
* et131x_free_busy_send_packets - Free and complete the stopped active sends
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
*
* Assumption - Send spinlock has been acquired
*/
-void et131x_free_busy_send_packets(struct et131x_adapter *pAdapter)
+void et131x_free_busy_send_packets(struct et131x_adapter *etdev)
{
PMP_TCB pMpTcb;
- struct list_head *pEntry;
- unsigned long lockflags;
+ struct list_head *entry;
+ unsigned long flags;
uint32_t FreeCounter = 0;
- DBG_ENTER(et131x_dbginfo);
-
- while (!list_empty(&pAdapter->TxRing.SendWaitQueue)) {
- spin_lock_irqsave(&pAdapter->SendWaitLock, lockflags);
+ while (!list_empty(&etdev->TxRing.SendWaitQueue)) {
+ spin_lock_irqsave(&etdev->SendWaitLock, flags);
- pAdapter->TxRing.nWaitSend--;
- spin_unlock_irqrestore(&pAdapter->SendWaitLock, lockflags);
+ etdev->TxRing.nWaitSend--;
+ spin_unlock_irqrestore(&etdev->SendWaitLock, flags);
- pEntry = pAdapter->TxRing.SendWaitQueue.next;
+ entry = etdev->TxRing.SendWaitQueue.next;
}
- pAdapter->TxRing.nWaitSend = 0;
+ etdev->TxRing.nWaitSend = 0;
/* Any packets being sent? Check the first TCB on the send list */
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBSendQLock, flags);
- pMpTcb = pAdapter->TxRing.CurrSendHead;
+ pMpTcb = etdev->TxRing.CurrSendHead;
while ((pMpTcb != NULL) && (FreeCounter < NUM_TCB)) {
PMP_TCB pNext = pMpTcb->Next;
- pAdapter->TxRing.CurrSendHead = pNext;
+ etdev->TxRing.CurrSendHead = pNext;
- if (pNext == NULL) {
- pAdapter->TxRing.CurrSendTail = NULL;
- }
+ if (pNext == NULL)
+ etdev->TxRing.CurrSendTail = NULL;
- pAdapter->TxRing.nBusySend--;
+ etdev->TxRing.nBusySend--;
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
-
- DBG_VERBOSE(et131x_dbginfo, "pMpTcb = 0x%p\n", pMpTcb);
+ spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
FreeCounter++;
- MP_FREE_SEND_PACKET_FUN(pAdapter, pMpTcb);
+ et131x_free_send_packet(etdev, pMpTcb);
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBSendQLock, flags);
- pMpTcb = pAdapter->TxRing.CurrSendHead;
+ pMpTcb = etdev->TxRing.CurrSendHead;
}
- if (FreeCounter == NUM_TCB) {
- DBG_ERROR(et131x_dbginfo,
- "MpFreeBusySendPackets exitted loop for a bad reason\n");
- BUG();
- }
+ WARN_ON(FreeCounter == NUM_TCB);
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
+ spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
- pAdapter->TxRing.nBusySend = 0;
-
- DBG_LEAVE(et131x_dbginfo);
+ etdev->TxRing.nBusySend = 0;
}
/**
* et131x_handle_send_interrupt - Interrupt handler for sending processing
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
*
* Re-claim the send resources, complete sends and get more to send from
* the send wait queue.
*
* Assumption - Send spinlock has been acquired
*/
-void et131x_handle_send_interrupt(struct et131x_adapter *pAdapter)
+void et131x_handle_send_interrupt(struct et131x_adapter *etdev)
{
- DBG_TX_ENTER(et131x_dbginfo);
-
/* Mark as completed any packets which have been sent by the device. */
- et131x_update_tcb_list(pAdapter);
+ et131x_update_tcb_list(etdev);
/* If we queued any transmits because we didn't have any TCBs earlier,
* dequeue and send those packets now, as long as we have free TCBs.
*/
- et131x_check_send_wait_list(pAdapter);
-
- DBG_TX_LEAVE(et131x_dbginfo);
+ et131x_check_send_wait_list(etdev);
}
/**
* et131x_update_tcb_list - Helper routine for Send Interrupt handler
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
*
* Re-claims the send resources and completes sends. Can also be called as
* part of the NIC send routine when the "ServiceComplete" indication has
* wrapped.
*/
-static void et131x_update_tcb_list(struct et131x_adapter *pAdapter)
+static void et131x_update_tcb_list(struct et131x_adapter *etdev)
{
- unsigned long lockflags;
- DMA10W_t ServiceComplete;
+ unsigned long flags;
+ u32 ServiceComplete;
PMP_TCB pMpTcb;
+ u32 index;
- ServiceComplete.value =
- readl(&pAdapter->CSRAddress->txdma.NewServiceComplete.value);
+ ServiceComplete = readl(&etdev->regs->txdma.NewServiceComplete);
+ index = INDEX10(ServiceComplete);
/* Has the ring wrapped? Process any descriptors that do not have
* the same "wrap" indicator as the current completion indicator
*/
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+ spin_lock_irqsave(&etdev->TCBSendQLock, flags);
+
+ pMpTcb = etdev->TxRing.CurrSendHead;
- pMpTcb = pAdapter->TxRing.CurrSendHead;
while (pMpTcb &&
- ServiceComplete.bits.wrap != pMpTcb->WrIndex.bits.wrap &&
- ServiceComplete.bits.val < pMpTcb->WrIndex.bits.val) {
- pAdapter->TxRing.nBusySend--;
- pAdapter->TxRing.CurrSendHead = pMpTcb->Next;
- if (pMpTcb->Next == NULL) {
- pAdapter->TxRing.CurrSendTail = NULL;
- }
+ ((ServiceComplete ^ pMpTcb->WrIndex) & ET_DMA10_WRAP) &&
+ index < INDEX10(pMpTcb->WrIndex)) {
+ etdev->TxRing.nBusySend--;
+ etdev->TxRing.CurrSendHead = pMpTcb->Next;
+ if (pMpTcb->Next == NULL)
+ etdev->TxRing.CurrSendTail = NULL;
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
- MP_FREE_SEND_PACKET_FUN(pAdapter, pMpTcb);
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+ spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
+ et131x_free_send_packet(etdev, pMpTcb);
+ spin_lock_irqsave(&etdev->TCBSendQLock, flags);
/* Goto the next packet */
- pMpTcb = pAdapter->TxRing.CurrSendHead;
+ pMpTcb = etdev->TxRing.CurrSendHead;
}
while (pMpTcb &&
- ServiceComplete.bits.wrap == pMpTcb->WrIndex.bits.wrap &&
- ServiceComplete.bits.val > pMpTcb->WrIndex.bits.val) {
- pAdapter->TxRing.nBusySend--;
- pAdapter->TxRing.CurrSendHead = pMpTcb->Next;
- if (pMpTcb->Next == NULL) {
- pAdapter->TxRing.CurrSendTail = NULL;
- }
+ !((ServiceComplete ^ pMpTcb->WrIndex) & ET_DMA10_WRAP)
+ && index > (pMpTcb->WrIndex & ET_DMA10_MASK)) {
+ etdev->TxRing.nBusySend--;
+ etdev->TxRing.CurrSendHead = pMpTcb->Next;
+ if (pMpTcb->Next == NULL)
+ etdev->TxRing.CurrSendTail = NULL;
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
- MP_FREE_SEND_PACKET_FUN(pAdapter, pMpTcb);
- spin_lock_irqsave(&pAdapter->TCBSendQLock, lockflags);
+ spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
+ et131x_free_send_packet(etdev, pMpTcb);
+ spin_lock_irqsave(&etdev->TCBSendQLock, flags);
/* Goto the next packet */
- pMpTcb = pAdapter->TxRing.CurrSendHead;
+ pMpTcb = etdev->TxRing.CurrSendHead;
}
/* Wake up the queue when we hit a low-water mark */
- if (pAdapter->TxRing.nBusySend <= (NUM_TCB / 3)) {
- netif_wake_queue(pAdapter->netdev);
- }
+ if (etdev->TxRing.nBusySend <= (NUM_TCB / 3))
+ netif_wake_queue(etdev->netdev);
- spin_unlock_irqrestore(&pAdapter->TCBSendQLock, lockflags);
+ spin_unlock_irqrestore(&etdev->TCBSendQLock, flags);
}
/**
* et131x_check_send_wait_list - Helper routine for the interrupt handler
- * @pAdapter: pointer to our adapter
+ * @etdev: pointer to our adapter
*
* Takes packets from the send wait queue and posts them to the device (if
* room available).
*/
-static void et131x_check_send_wait_list(struct et131x_adapter *pAdapter)
+static void et131x_check_send_wait_list(struct et131x_adapter *etdev)
{
- unsigned long lockflags;
-
- spin_lock_irqsave(&pAdapter->SendWaitLock, lockflags);
-
- while (!list_empty(&pAdapter->TxRing.SendWaitQueue) &&
- MP_TCB_RESOURCES_AVAILABLE(pAdapter)) {
- struct list_head *pEntry;
+ unsigned long flags;
- DBG_VERBOSE(et131x_dbginfo, "Tx packets on the wait queue\n");
+ spin_lock_irqsave(&etdev->SendWaitLock, flags);
- pEntry = pAdapter->TxRing.SendWaitQueue.next;
+ while (!list_empty(&etdev->TxRing.SendWaitQueue) &&
+ MP_TCB_RESOURCES_AVAILABLE(etdev)) {
+ struct list_head *entry;
- pAdapter->TxRing.nWaitSend--;
+ entry = etdev->TxRing.SendWaitQueue.next;
- DBG_WARNING(et131x_dbginfo,
- "MpHandleSendInterrupt - sent a queued pkt. Waiting %d\n",
- pAdapter->TxRing.nWaitSend);
+ etdev->TxRing.nWaitSend--;
}
- spin_unlock_irqrestore(&pAdapter->SendWaitLock, lockflags);
+ spin_unlock_irqrestore(&etdev->SendWaitLock, flags);
}