Skip to content

Commit

Permalink
xircom_cb endianness fixes
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Al Viro authored and Jeff Garzik committed Jan 12, 2008
1 parent 460c54b commit 6f35d5d
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions drivers/net/tulip/xircom_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ static int bufferoffsets[NUMDESCRIPTORS] = {128,2048,4096,6144};
struct xircom_private {
/* Send and receive buffers, kernel-addressable and dma addressable forms */

unsigned int *rx_buffer;
unsigned int *tx_buffer;
__le32 *rx_buffer;
__le32 *tx_buffer;

dma_addr_t rx_dma_handle;
dma_addr_t tx_dma_handle;
Expand Down Expand Up @@ -412,19 +412,20 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* FIXME: The specification tells us that the length we send HAS to be a multiple of
4 bytes. */

card->tx_buffer[4*desc+1] = skb->len;
if (desc == NUMDESCRIPTORS-1)
card->tx_buffer[4*desc+1] |= (1<<25); /* bit 25: last descriptor of the ring */
card->tx_buffer[4*desc+1] = cpu_to_le32(skb->len);
if (desc == NUMDESCRIPTORS - 1) /* bit 25: last descriptor of the ring */
card->tx_buffer[4*desc+1] |= cpu_to_le32(1<<25);

card->tx_buffer[4*desc+1] |= 0xF0000000;
card->tx_buffer[4*desc+1] |= cpu_to_le32(0xF0000000);
/* 0xF0... means want interrupts*/
card->tx_skb[desc] = skb;

wmb();
/* This gives the descriptor to the card */
card->tx_buffer[4*desc] = 0x80000000;
card->tx_buffer[4*desc] = cpu_to_le32(0x80000000);
trigger_transmit(card);
if (((int)card->tx_buffer[nextdescriptor*4])<0) { /* next descriptor is occupied... */
if (card->tx_buffer[nextdescriptor*4] & cpu_to_le32(0x8000000)) {
/* next descriptor is occupied... */
netif_stop_queue(dev);
}
card->transmit_used = nextdescriptor;
Expand Down Expand Up @@ -590,8 +591,7 @@ descriptors and programs the addresses into the card.
*/
static void setup_descriptors(struct xircom_private *card)
{
unsigned int val;
unsigned int address;
u32 address;
int i;
enter("setup_descriptors");

Expand All @@ -604,26 +604,25 @@ static void setup_descriptors(struct xircom_private *card)
for (i=0;i<NUMDESCRIPTORS;i++ ) {

/* Rx Descr0: It's empty, let the card own it, no errors -> 0x80000000 */
card->rx_buffer[i*4 + 0] = 0x80000000;
card->rx_buffer[i*4 + 0] = cpu_to_le32(0x80000000);
/* Rx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */
card->rx_buffer[i*4 + 1] = 1536;
if (i==NUMDESCRIPTORS-1)
card->rx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */
card->rx_buffer[i*4 + 1] = cpu_to_le32(1536);
if (i == NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */
card->rx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25);

/* Rx Descr2: address of the buffer
we store the buffer at the 2nd half of the page */

address = (unsigned long) card->rx_dma_handle;
address = card->rx_dma_handle;
card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
/* Rx Desc3: address of 2nd buffer -> 0 */
card->rx_buffer[i*4 + 3] = 0;
}

wmb();
/* Write the receive descriptor ring address to the card */
address = (unsigned long) card->rx_dma_handle;
val = cpu_to_le32(address);
outl(val, card->io_port + CSR3); /* Receive descr list address */
address = card->rx_dma_handle;
outl(address, card->io_port + CSR3); /* Receive descr list address */


/* transmit descriptors */
Expand All @@ -633,23 +632,22 @@ static void setup_descriptors(struct xircom_private *card)
/* Tx Descr0: Empty, we own it, no errors -> 0x00000000 */
card->tx_buffer[i*4 + 0] = 0x00000000;
/* Tx Descr1: buffer 1 is 1536 bytes, buffer 2 is 0 bytes */
card->tx_buffer[i*4 + 1] = 1536;
if (i==NUMDESCRIPTORS-1)
card->tx_buffer[i*4 + 1] |= (1 << 25); /* bit 25 is "last descriptor" */
card->tx_buffer[i*4 + 1] = cpu_to_le32(1536);
if (i == NUMDESCRIPTORS - 1) /* bit 25 is "last descriptor" */
card->tx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25);

/* Tx Descr2: address of the buffer
we store the buffer at the 2nd half of the page */
address = (unsigned long) card->tx_dma_handle;
address = card->tx_dma_handle;
card->tx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]);
/* Tx Desc3: address of 2nd buffer -> 0 */
card->tx_buffer[i*4 + 3] = 0;
}

wmb();
/* wite the transmit descriptor ring to the card */
address = (unsigned long) card->tx_dma_handle;
val =cpu_to_le32(address);
outl(val, card->io_port + CSR4); /* xmit descr list address */
address = card->tx_dma_handle;
outl(address, card->io_port + CSR4); /* xmit descr list address */

leave("setup_descriptors");
}
Expand Down Expand Up @@ -1180,7 +1178,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
int status;

enter("investigate_read_descriptor");
status = card->rx_buffer[4*descnr];
status = le32_to_cpu(card->rx_buffer[4*descnr]);

if ((status > 0)) { /* packet received */

Expand Down Expand Up @@ -1210,7 +1208,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri

out:
/* give the buffer back to the card */
card->rx_buffer[4*descnr] = 0x80000000;
card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000);
trigger_receive(card);
}

Expand All @@ -1226,7 +1224,7 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p

enter("investigate_write_descriptor");

status = card->tx_buffer[4*descnr];
status = le32_to_cpu(card->tx_buffer[4*descnr]);
#if 0
if (status & 0x8000) { /* Major error */
printk(KERN_ERR "Major transmit error status %x \n", status);
Expand Down

0 comments on commit 6f35d5d

Please sign in to comment.