[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Netra X1 boot getting closer



Diff below. Hope this is useful.

Richard

P.S. Sorry for slow turnaround. I had a few day job issues to sort out
:-(

Jeff Garzik writes:
 > Here is the patch I just checked in, which fixes some of the easier
 > issues.  If you could diff against this, that would be great.
 > -- 
 > Jeff Garzik      | Andre the Giant has a posse.
 > Building 1024    |
 > MandrakeSoft     |


--- linux-cvs/linux/drivers/net/dmfe.c	Sat Jun 30 13:10:18 2001
+++ drivers/net/dmfe.c	Wed Jul  4 01:12:53 2001
@@ -77,9 +77,11 @@
 #include <asm/io.h>
 #include <asm/dma.h>
 
+#if 0
 #if BITS_PER_LONG == 64
 #error FIXME: driver does not support 64-bit platforms
 #endif
+#endif
 
 
 /* Board/System/Debug information/definition ---------------- */
@@ -127,8 +129,8 @@
 #define DMFE_TXTH_1K	0xC000		/* TX TH 1K  byte */
 
 #define DMFE_TIMER_WUT  (jiffies + HZ * 1)/* timer wakeup time : 1 second */
-#define DMFE_TX_TIMEOUT (HZ * 1.5)	/* tx packet time-out time 1.5 s" */
-#define DMFE_TX_KICK 	(HZ * 0.5)	/* tx packet Kick-out time 0.5 s" */
+#define DMFE_TX_TIMEOUT ((unsigned long) (HZ * 1.5))	/* tx packet time-out time 1.5 s" */
+#define DMFE_TX_KICK 	((unsigned long) (HZ * 0.5))	/* tx packet Kick-out time 0.5 s" */
 
 #define DMFE_DBUG(dbug_now, msg, value) if (dmfe_debug || (dbug_now)) printk(KERN_ERR "<DMFE>: %s %lx\n", (msg), (long) (value))
 
@@ -161,18 +163,28 @@
 /* Structure/enum declaration ------------------------------- */
 struct tx_desc {
 	u32 tdes0, tdes1, tdes2, tdes3;
+#if __sparc_v9__
+	unsigned long tx_buf_ptr;
+	unsigned long next_tx_desc;
+#else
 	u32 tx_skb_ptr;
 	u32 tx_buf_ptr;
 	u32 next_tx_desc;
 	u32 reserved;
+#endif
 };
 
 struct rx_desc {
 	u32 rdes0, rdes1, rdes2, rdes3;
+#ifdef __sparc_v9__
+	unsigned long rx_skb_ptr;
+	unsigned long next_rx_desc;
+#else
 	u32 rx_skb_ptr;
 	u32 rx_buf_ptr;
 	u32 next_rx_desc;
 	u32 reserved;
+#endif
 };
 
 struct dmfe_board_info {
@@ -392,7 +404,7 @@
 				    const struct pci_device_id *ent)
 {
 	unsigned long pci_iobase;
-	u8 pci_irqline;
+	int pci_irqline;
 	struct dmfe_board_info *db;	/* board information structure */
 	int i;
 	struct net_device *dev;
@@ -852,11 +864,14 @@
 {
 	struct tx_desc *txptr;
 	unsigned long ioaddr = dev->base_addr;
+	u32 tdes0, tdes1;
 
 	txptr = db->tx_remove_ptr;
 	while(db->tx_packet_cnt) {
 		/* printk("<DMFE>: tdes0=%x\n", txptr->tdes0); */
-		if (txptr->tdes0 & 0x80000000)
+		tdes0 = le32_to_cpu(txptr->tdes0);
+		tdes1 = le32_to_cpu(txptr->tdes1);
+		if (tdes0 & 0x80000000)
 			break;
 
 		/* A packet sent completed */
@@ -864,29 +879,29 @@
 		db->stats.tx_packets++;
 
 		/* Transmit statistic counter */
-		if ( txptr->tdes0 != 0x7fffffff ) {
-			/* printk("<DMFE>: tdes0=%x\n", txptr->tdes0); */
-			db->stats.collisions += (txptr->tdes0 >> 3) & 0xf;
-			db->stats.tx_bytes += txptr->tdes1 & 0x7ff;
-			if (txptr->tdes0 & TDES0_ERR_MASK) {
+		if ( tdes0 != 0x7fffffff ) {
+			/* printk("<DMFE>: tdes0=%x\n", tdes0); */
+			db->stats.collisions += (tdes0 >> 3) & 0xf;
+			db->stats.tx_bytes += tdes1 & 0x7ff;
+			if (tdes0 & TDES0_ERR_MASK) {
 				db->stats.tx_errors++;
 
-				if (txptr->tdes0 & 0x0002) {	/* UnderRun */
+				if (tdes0 & 0x0002) {	/* UnderRun */
 					db->tx_fifo_underrun++;
 					if ( !(db->cr6_data & CR6_SFT) ) {
 						db->cr6_data = db->cr6_data | CR6_SFT;
 						update_cr6(db->cr6_data, db->ioaddr);
 					}
 				}
-				if (txptr->tdes0 & 0x0100)
+				if (tdes0 & 0x0100)
 					db->tx_excessive_collision++;
-				if (txptr->tdes0 & 0x0200)
+				if (tdes0 & 0x0200)
 					db->tx_late_collision++;
-				if (txptr->tdes0 & 0x0400)
+				if (tdes0 & 0x0400)
 					db->tx_no_carrier++;
-				if (txptr->tdes0 & 0x0800)
+				if (tdes0 & 0x0800)
 					db->tx_loss_carrier++;
-				if (txptr->tdes0 & 0x4000)
+				if (tdes0 & 0x4000)
 					db->tx_jabber_timeout++;
 			}
 		}
@@ -921,39 +936,41 @@
 	struct rx_desc *rxptr;
 	struct sk_buff *skb;
 	int rxlen;
+	u32 rdes0;
 
 	rxptr = db->rx_ready_ptr;
 
 	while(db->rx_avail_cnt) {
-		if (rxptr->rdes0 & 0x80000000)	/* packet owner check */
+		rdes0 = le32_to_cpu(rxptr->rdes0);
+		if (rdes0 & 0x80000000)	/* packet owner check */
 			break;
 
 		db->rx_avail_cnt--;
 		db->interval_rx_cnt++;
 
-		if ( (rxptr->rdes0 & 0x300) != 0x300) {
+		if ( (rdes0 & 0x300) != 0x300) {
 			/* A packet without First/Last flag */
 			/* reused this SKB */
-			DMFE_DBUG(0, "Reused SK buffer, rdes0", rxptr->rdes0);
+			DMFE_DBUG(0, "Reused SK buffer, rdes0 %x", rdes0);
 			dmfe_reused_skb(db, (struct sk_buff *) rxptr->rx_skb_ptr);
 		} else {
 			/* A packet with First/Last flag */
-			rxlen = ( (rxptr->rdes0 >> 16) & 0x3fff) - 4;
+			rxlen = ( (rdes0 >> 16) & 0x3fff) - 4;
 
 			/* error summary bit check */
-			if (rxptr->rdes0 & 0x8000) {
+			if (rdes0 & 0x8000) {
 				/* This is a error packet */
-				//printk("<DMFE>: rdes0: %lx\n", rxptr->rdes0);
+				//printk("<DMFE>: rdes0: %lx\n", rdes0);
 				db->stats.rx_errors++;
-				if (rxptr->rdes0 & 1)
+				if (rdes0 & 1)
 					db->stats.rx_fifo_errors++;
-				if (rxptr->rdes0 & 2)
+				if (rdes0 & 2)
 					db->stats.rx_crc_errors++;
-				if (rxptr->rdes0 & 0x80)
+				if (rdes0 & 0x80)
 					db->stats.rx_length_errors++;
 			}
 
-			if ( !(rxptr->rdes0 & 0x8000) ||
+			if ( !(rdes0 & 0x800) ||
 				((db->cr6_data & CR6_PM) && (rxlen>6)) ) {
 				skb = (struct sk_buff *) rxptr->rx_skb_ptr;
 
@@ -988,7 +1005,7 @@
 				}
 			} else {
 				/* Reuse SKB buffer when the packet is error */
-				DMFE_DBUG(0, "Reused SK buffer, rdes0", rxptr->rdes0);
+				DMFE_DBUG(0, "Reused SK buffer, rdes0 %x", rdes0);
 				dmfe_reused_skb(db, (struct sk_buff *) rxptr->rx_skb_ptr);
 			}
 		}
@@ -1259,8 +1276,8 @@
 {
 	struct rx_desc *rxptr = db->rx_insert_ptr;
 
-	if (!(rxptr->rdes0 & 0x80000000)) {
-		rxptr->rx_skb_ptr = (u32) skb;
+	if (!(le32_to_cpu(rxptr->rdes0) & 0x80000000)) {
+		rxptr->rx_skb_ptr = (unsigned long) skb;
 		rxptr->rdes2 = cpu_to_le32( pci_map_single(db->net_dev, skb->tail, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) );
 		rxptr->rdes0 = cpu_to_le32(0x80000000);
 		db->rx_avail_cnt++;
@@ -1292,7 +1309,7 @@
 	outl(db->first_tx_desc_dma, ioaddr + DCR4);     /* TX DESC address */
 
 	/* rx descriptor start pointer */
-	db->first_rx_desc = (struct rx_desc *) ( (u32) db->first_tx_desc + sizeof(struct rx_desc) * TX_DESC_CNT );
+	db->first_rx_desc = (struct rx_desc *) ( (unsigned long) db->first_tx_desc + sizeof(struct rx_desc) * TX_DESC_CNT );
 	db->first_rx_desc_dma = ( db->first_tx_desc_dma + sizeof(struct rx_desc) * TX_DESC_CNT);
 	db->rx_insert_ptr = db->first_rx_desc;
 	db->rx_ready_ptr = db->first_rx_desc;
@@ -1303,18 +1320,18 @@
 	tmp_buf_dma = db->buf_pool_dma_start;
 	tmp_tx_dma = db->first_tx_desc_dma;
 	for (tmp_tx = db->first_tx_desc, i = 0; i < TX_DESC_CNT; i++, tmp_tx++) {
-		tmp_tx->tx_buf_ptr = (u32) tmp_buf;
+		tmp_tx->tx_buf_ptr = (unsigned long) tmp_buf;
 		tmp_tx->tdes0 = cpu_to_le32(0);
 		tmp_tx->tdes1 = cpu_to_le32(0x81000000);	/* IC, chain */
 		tmp_tx->tdes2 = cpu_to_le32(tmp_buf_dma);
 		tmp_tx_dma += sizeof(struct tx_desc);
 		tmp_tx->tdes3 = cpu_to_le32(tmp_tx_dma);
-		tmp_tx->next_tx_desc = (u32) ((u32) tmp_tx + sizeof(struct tx_desc));
-		tmp_buf = (unsigned char *) ((u32) tmp_buf + TX_BUF_ALLOC);
+		tmp_tx->next_tx_desc = (unsigned long) ((unsigned long) tmp_tx + sizeof(struct tx_desc));
+		tmp_buf = (unsigned char *) ((unsigned long) tmp_buf + TX_BUF_ALLOC);
 		tmp_buf_dma = tmp_buf_dma + TX_BUF_ALLOC;
 	}
 	(--tmp_tx)->tdes3 = cpu_to_le32(db->first_tx_desc_dma);
-	tmp_tx->next_tx_desc = (u32) db->first_tx_desc;
+	tmp_tx->next_tx_desc = (unsigned long) db->first_tx_desc;
 
 	 /* Init Receive descriptor chain */
 	tmp_rx_dma=db->first_rx_desc_dma;
@@ -1323,10 +1340,10 @@
 		tmp_rx->rdes1 = cpu_to_le32(0x01000600);
 		tmp_rx_dma += sizeof(struct rx_desc);
 		tmp_rx->rdes3 = cpu_to_le32(tmp_rx_dma);
-		tmp_rx->next_rx_desc = (u32) ((u32) tmp_rx + sizeof(struct rx_desc));
+		tmp_rx->next_rx_desc = (unsigned long) ((unsigned long) tmp_rx + sizeof(struct rx_desc));
 	}
 	(--tmp_rx)->rdes3 = cpu_to_le32(db->first_rx_desc_dma);
-	tmp_rx->next_rx_desc = (u32) db->first_rx_desc;
+	tmp_rx->next_rx_desc = (unsigned long) db->first_rx_desc;
 
 	/* pre-allocated Rx buffer */
 	allocated_rx_buffer(db);
@@ -1470,7 +1487,7 @@
 	while(db->rx_avail_cnt < RX_DESC_CNT) {
 		if ( ( skb = dev_alloc_skb(RX_ALLOC_SIZE) ) == NULL )
 			break;
-		rxptr->rx_skb_ptr = (u32) skb; /* FIXME */
+		rxptr->rx_skb_ptr = (unsigned long) skb; /* FIXME */
 		rxptr->rdes2 = cpu_to_le32( pci_map_single(db->net_dev, skb->tail, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) );
 		rxptr->rdes0 = cpu_to_le32(0x80000000);
 		rxptr = (struct rx_desc *) rxptr->next_rx_desc;



Reply to: