]> err.no Git - linux-2.6/blobdiff - drivers/net/spider_net.c
Pull thinkpad into release branch
[linux-2.6] / drivers / net / spider_net.c
index 4d180072de4d7fff8b0708666b4154011de431ae..82d837ab4db9bd54840d548d694fea291e5791ae 100644 (file)
@@ -500,6 +500,20 @@ spider_net_enable_rxdmac(struct spider_net_card *card)
                             SPIDER_NET_DMA_RX_VALUE);
 }
 
+/**
+ * spider_net_disable_rxdmac - disables the receive DMA controller
+ * @card: card structure
+ *
+ * spider_net_disable_rxdmac terminates processing on the DMA controller
+ * by turing off the DMA controller, with the force-end flag set.
+ */
+static inline void
+spider_net_disable_rxdmac(struct spider_net_card *card)
+{
+       spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
+                            SPIDER_NET_DMA_RX_FEND_VALUE);
+}
+
 /**
  * spider_net_refill_rx_chain - refills descriptors/skbs in the rx chains
  * @card: card structure
@@ -655,20 +669,6 @@ write_hash:
        }
 }
 
-/**
- * spider_net_disable_rxdmac - disables the receive DMA controller
- * @card: card structure
- *
- * spider_net_disable_rxdmac terminates processing on the DMA controller by
- * turing off DMA and issueing a force end
- */
-static void
-spider_net_disable_rxdmac(struct spider_net_card *card)
-{
-       spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
-                            SPIDER_NET_DMA_RX_FEND_VALUE);
-}
-
 /**
  * spider_net_prepare_tx_descr - fill tx descriptor with skb data
  * @card: card structure
@@ -716,7 +716,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
        hwdescr->data_status = 0;
 
        hwdescr->dmac_cmd_status =
-                       SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
+                       SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_TXFRMTL;
        spin_unlock_irqrestore(&chain->lock, flags);
 
        if (skb->ip_summed == CHECKSUM_PARTIAL)
@@ -1187,6 +1187,7 @@ spider_net_decode_one_descr(struct spider_net_card *card)
        struct spider_net_descr_chain *chain = &card->rx_chain;
        struct spider_net_descr *descr = chain->tail;
        struct spider_net_hw_descr *hwdescr = descr->hwdescr;
+       u32 hw_buf_addr;
        int status;
 
        status = spider_net_get_descr_status(hwdescr);
@@ -1200,7 +1201,9 @@ spider_net_decode_one_descr(struct spider_net_card *card)
        chain->tail = descr->next;
 
        /* unmap descriptor */
-       pci_unmap_single(card->pdev, hwdescr->buf_addr,
+       hw_buf_addr = hwdescr->buf_addr;
+       hwdescr->buf_addr = 0xffffffff;
+       pci_unmap_single(card->pdev, hw_buf_addr,
                        SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
 
        if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
@@ -1232,10 +1235,10 @@ spider_net_decode_one_descr(struct spider_net_card *card)
                goto bad_desc;
        }
 
-       if (hwdescr->dmac_cmd_status & 0xfcf4) {
+       if (hwdescr->dmac_cmd_status & SPIDER_NET_DESCR_BAD_STATUS) {
                dev_err(&card->netdev->dev, "bad status, cmd_status=x%08x\n",
                               hwdescr->dmac_cmd_status);
-               pr_err("buf_addr=x%08x\n", hwdescr->buf_addr);
+               pr_err("buf_addr=x%08x\n", hw_buf_addr);
                pr_err("buf_size=x%08x\n", hwdescr->buf_size);
                pr_err("next_descr_addr=x%08x\n", hwdescr->next_descr_addr);
                pr_err("result_size=x%08x\n", hwdescr->result_size);
@@ -1282,7 +1285,6 @@ spider_net_poll(struct net_device *netdev, int *budget)
        int packets_to_do, packets_done = 0;
        int no_more_packets = 0;
 
-       spider_net_cleanup_tx_ring(card);
        packets_to_do = min(*budget, netdev->quota);
 
        while (packets_to_do) {
@@ -1307,6 +1309,8 @@ spider_net_poll(struct net_device *netdev, int *budget)
        spider_net_refill_rx_chain(card);
        spider_net_enable_rxdmac(card);
 
+       spider_net_cleanup_tx_ring(card);
+
        /* if all packets are in the stack, enable interrupts and return 0 */
        /* if not, return 1 */
        if (no_more_packets) {
@@ -1443,6 +1447,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
        error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS);
        error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS);
 
+       error_reg1 &= SPIDER_NET_INT1_MASK_VALUE;
+       error_reg2 &= SPIDER_NET_INT2_MASK_VALUE;
+
        /* check GHIINT0STS ************************************/
        if (status_reg)
                for (i = 0; i < 32; i++)
@@ -1672,6 +1679,7 @@ spider_net_interrupt(int irq, void *ptr)
        u32 status_reg;
 
        status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS);
+       status_reg &= SPIDER_NET_INT0_MASK_VALUE;
 
        if (!status_reg)
                return IRQ_NONE;
@@ -1712,6 +1720,38 @@ spider_net_poll_controller(struct net_device *netdev)
 }
 #endif /* CONFIG_NET_POLL_CONTROLLER */
 
+/**
+ * spider_net_enable_interrupts - enable interrupts
+ * @card: card structure
+ *
+ * spider_net_enable_interrupt enables several interrupts
+ */
+static void 
+spider_net_enable_interrupts(struct spider_net_card *card)
+{
+       spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK,
+                            SPIDER_NET_INT0_MASK_VALUE);
+       spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK,
+                            SPIDER_NET_INT1_MASK_VALUE);
+       spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK,
+                            SPIDER_NET_INT2_MASK_VALUE);
+}
+
+/**
+ * spider_net_disable_interrupts - disable interrupts
+ * @card: card structure
+ *
+ * spider_net_disable_interrupts disables all the interrupts
+ */
+static void 
+spider_net_disable_interrupts(struct spider_net_card *card)
+{
+       spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);
+       spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);
+       spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
+       spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0);
+}
+
 /**
  * spider_net_init_card - initializes the card
  * @card: card structure
@@ -1732,6 +1772,7 @@ spider_net_init_card(struct spider_net_card *card)
        spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
                spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4);
 
+       spider_net_disable_interrupts(card);
 }
 
 /**
@@ -1819,14 +1860,6 @@ spider_net_enable_card(struct spider_net_card *card)
        spider_net_write_reg(card, SPIDER_NET_GMACOPEMD,
                             SPIDER_NET_OPMODE_VALUE);
 
-       /* set interrupt mask registers */
-       spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK,
-                            SPIDER_NET_INT0_MASK_VALUE);
-       spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK,
-                            SPIDER_NET_INT1_MASK_VALUE);
-       spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK,
-                            SPIDER_NET_INT2_MASK_VALUE);
-
        spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
                             SPIDER_NET_GDTBSTA);
 }
@@ -2003,6 +2036,8 @@ spider_net_open(struct net_device *netdev)
        netif_carrier_on(netdev);
        netif_poll_enable(netdev);
 
+       spider_net_enable_interrupts(card);
+
        return 0;
 
 register_int_failed:
@@ -2175,11 +2210,7 @@ spider_net_stop(struct net_device *netdev)
        del_timer_sync(&card->tx_timer);
        del_timer_sync(&card->aneg_timer);
 
-       /* disable/mask all interrupts */
-       spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0);
-       spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0);
-       spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0);
-       spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0);
+       spider_net_disable_interrupts(card);
 
        free_irq(netdev->irq, netdev);