aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2007-12-23 15:01:04 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-12 17:33:03 -0500
commit6f35d5d51619a1aa463180154c2d3c18a63e3950 (patch)
treec02fdde82c990247d8a26741cc7f25e323be6f34
parent460c54b779fce3490ab70a84fd2ef59250ca3d57 (diff)
xircom_cb endianness fixes
* descriptors inside the rx and tx rings are l-e * don't cpu_to_le32() the argument of outl() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/tulip/xircom_cb.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 70befe33e454..8fc7274642eb 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -83,8 +83,8 @@ static int bufferoffsets[NUMDESCRIPTORS] = {128,2048,4096,6144};
83struct xircom_private { 83struct xircom_private {
84 /* Send and receive buffers, kernel-addressable and dma addressable forms */ 84 /* Send and receive buffers, kernel-addressable and dma addressable forms */
85 85
86 unsigned int *rx_buffer; 86 __le32 *rx_buffer;
87 unsigned int *tx_buffer; 87 __le32 *tx_buffer;
88 88
89 dma_addr_t rx_dma_handle; 89 dma_addr_t rx_dma_handle;
90 dma_addr_t tx_dma_handle; 90 dma_addr_t tx_dma_handle;
@@ -412,19 +412,20 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
412 /* FIXME: The specification tells us that the length we send HAS to be a multiple of 412 /* FIXME: The specification tells us that the length we send HAS to be a multiple of
413 4 bytes. */ 413 4 bytes. */
414 414
415 card->tx_buffer[4*desc+1] = skb->len; 415 card->tx_buffer[4*desc+1] = cpu_to_le32(skb->len);
416 if (desc == NUMDESCRIPTORS-1) 416 if (desc == NUMDESCRIPTORS - 1) /* bit 25: last descriptor of the ring */
417 card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */ 417 card->tx_buffer[4*desc+1] |= cpu_to_le32(1<<25);
418 418
419 card->tx_buffer[4*desc+1] |= 0xF0000000; 419 card->tx_buffer[4*desc+1] |= cpu_to_le32(0xF0000000);
420 /* 0xF0... means want interrupts*/ 420 /* 0xF0... means want interrupts*/
421 card->tx_skb[desc] = skb; 421 card->tx_skb[desc] = skb;
422 422
423 wmb(); 423 wmb();
424 /* This gives the descriptor to the card */ 424 /* This gives the descriptor to the card */
425 card->tx_buffer[4*desc] = 0x80000000; 425 card->tx_buffer[4*desc] = cpu_to_le32(0x80000000);
426 trigger_transmit(card); 426 trigger_transmit(card);
427 if (((int)card->tx_buffer[nextdescriptor*4])<0) { /* next descriptor is occupied... */ 427 if (card->tx_buffer[nextdescriptor*4] & cpu_to_le32(0x8000000)) {
428 /* next descriptor is occupied... */
428 netif_stop_queue(dev); 429 netif_stop_queue(dev);
429 } 430 }
430 card->transmit_used = nextdescriptor; 431 card->transmit_used = nextdescriptor;
@@ -590,8 +591,7 @@ descriptors and programs the addresses into the card.
590*/ 591*/
591static void setup_descriptors(struct xircom_private *card) 592static void setup_descriptors(struct xircom_private *card)
592{ 593{
593 unsigned int val; 594 u32 address;
594 unsigned int address;
595 int i; 595 int i;
596 enter("setup_descriptors"); 596 enter("setup_descriptors");
597 597
@@ -604,16 +604,16 @@ static void setup_descriptors(struct xircom_private *card)
604 for (i=0;i<NUMDESCRIPTORS;i++ ) { 604 for (i=0;i<NUMDESCRIPTORS;i++ ) {
605 605
606 /* Rx Descr0: It's empty, let the card own it, no errors -> 0x80000000 */ 606 /* Rx Descr0: It's empty, let the card own it, no errors -> 0x80000000 */
607 card->rx_buffer[i*4 + 0] = 0x80000000; 607 card->rx_buffer[i*4 + 0] = cpu_to_le32(0x80000000);
608 /* Rx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */ 608 /* Rx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */
609 card->rx_buffer[i*4 + 1] = 1536; 609 card->rx_buffer[i*4 + 1] = cpu_to_le32(1536);
610 if (i==NUMDESCRIPTORS-1) 610 if (i == NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */
611 card->rx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */ 611 card->rx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25);
612 612
613 /* Rx Descr2: address of the buffer 613 /* Rx Descr2: address of the buffer
614 we store the buffer at the 2nd half of the page */ 614 we store the buffer at the 2nd half of the page */
615 615
616 address = (unsigned long) card->rx_dma_handle; 616 address = card->rx_dma_handle;
617 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); 617 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
618 /* Rx Desc3: address of 2nd buffer -> 0 */ 618 /* Rx Desc3: address of 2nd buffer -> 0 */
619 card->rx_buffer[i*4 + 3] = 0; 619 card->rx_buffer[i*4 + 3] = 0;
@@ -621,9 +621,8 @@ static void setup_descriptors(struct xircom_private *card)
621 621
622 wmb(); 622 wmb();
623 /* Write the receive descriptor ring address to the card */ 623 /* Write the receive descriptor ring address to the card */
624 address = (unsigned long) card->rx_dma_handle; 624 address = card->rx_dma_handle;
625 val = cpu_to_le32(address); 625 outl(address, card->io_port + CSR3); /* Receive descr list address */
626 outl(val, card->io_port + CSR3); /* Receive descr list address */
627 626
628 627
629 /* transmit descriptors */ 628 /* transmit descriptors */
@@ -633,13 +632,13 @@ static void setup_descriptors(struct xircom_private *card)
633 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */ 632 /* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */
634 card->tx_buffer[i*4 + 0] = 0x00000000; 633 card->tx_buffer[i*4 + 0] = 0x00000000;
635 /* Tx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */ 634 /* Tx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */
636 card->tx_buffer[i*4 + 1] = 1536; 635 card->tx_buffer[i*4 + 1] = cpu_to_le32(1536);
637 if (i==NUMDESCRIPTORS-1) 636 if (i == NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */
638 card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */ 637 card->tx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25);
639 638
640 /* Tx Descr2: address of the buffer 639 /* Tx Descr2: address of the buffer
641 we store the buffer at the 2nd half of the page */ 640 we store the buffer at the 2nd half of the page */
642 address = (unsigned long) card->tx_dma_handle; 641 address = card->tx_dma_handle;
643 card->tx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); 642 card->tx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
644 /* Tx Desc3: address of 2nd buffer -> 0 */ 643 /* Tx Desc3: address of 2nd buffer -> 0 */
645 card->tx_buffer[i*4 + 3] = 0; 644 card->tx_buffer[i*4 + 3] = 0;
@@ -647,9 +646,8 @@ static void setup_descriptors(struct xircom_private *card)
647 646
648 wmb(); 647 wmb();
649 /* wite the transmit descriptor ring to the card */ 648 /* wite the transmit descriptor ring to the card */
650 address = (unsigned long) card->tx_dma_handle; 649 address = card->tx_dma_handle;
651 val =cpu_to_le32(address); 650 outl(address, card->io_port + CSR4); /* xmit descr list address */
652 outl(val, card->io_port + CSR4); /* xmit descr list address */
653 651
654 leave("setup_descriptors"); 652 leave("setup_descriptors");
655} 653}
@@ -1180,7 +1178,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1180 int status; 1178 int status;
1181 1179
1182 enter("investigate_read_descriptor"); 1180 enter("investigate_read_descriptor");
1183 status = card->rx_buffer[4*descnr]; 1181 status = le32_to_cpu(card->rx_buffer[4*descnr]);
1184 1182
1185 if ((status > 0)) { /* packet received */ 1183 if ((status > 0)) { /* packet received */
1186 1184
@@ -1210,7 +1208,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1210 1208
1211 out: 1209 out:
1212 /* give the buffer back to the card */ 1210 /* give the buffer back to the card */
1213 card->rx_buffer[4*descnr] = 0x80000000; 1211 card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
1214 trigger_receive(card); 1212 trigger_receive(card);
1215 } 1213 }
1216 1214
@@ -1226,7 +1224,7 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1226 1224
1227 enter("investigate_write_descriptor"); 1225 enter("investigate_write_descriptor");
1228 1226
1229 status = card->tx_buffer[4*descnr]; 1227 status = le32_to_cpu(card->tx_buffer[4*descnr]);
1230#if 0 1228#if 0
1231 if (status & 0x8000) { /* Major error */ 1229 if (status & 0x8000) { /* Major error */
1232 printk(KERN_ERR "Major transmit error status %x \n", status); 1230 printk(KERN_ERR "Major transmit error status %x \n", status);