Browse Source

[pcnet32] Fix received packet corruption

The pcnet32 driver mismanages its RX buffers, with the result that
packets get corrupted if more than one packet arrives between calls to
poll().

Originally-fixed-by: Bill Lortz <Bill.Lortz@premier.org>
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
Tested-by: Stefan Hajnoczi <stefanha@gmail.com>
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
5538a38b9c
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      src/drivers/net/pcnet32.c

+ 3
- 3
src/drivers/net/pcnet32.c View File

@@ -216,8 +216,8 @@ struct {
216 216
 	__attribute__ ((aligned(16)));
217 217
 	struct pcnet32_rx_head rx_ring[RX_RING_SIZE]
218 218
 	__attribute__ ((aligned(16)));
219
-	unsigned char txb[PKT_BUF_SZ * TX_RING_SIZE];
220
-	unsigned char rxb[RX_RING_SIZE * PKT_BUF_SZ];
219
+	unsigned char txb[TX_RING_SIZE][PKT_BUF_SZ];
220
+	unsigned char rxb[RX_RING_SIZE][PKT_BUF_SZ];
221 221
 } pcnet32_bufs __shared;
222 222
 
223 223
 /* May need to be moved to mii.h */
@@ -588,7 +588,7 @@ static void pcnet32_transmit(struct nic *nic __unused, const char *d,	/* Destina
588 588
 
589 589
 	status = 0x8300;
590 590
 	/* point to the current txb incase multiple tx_rings are used */
591
-	ptxb = pcnet32_bufs.txb + (lp->cur_tx * PKT_BUF_SZ);
591
+	ptxb = pcnet32_bufs.txb[lp->cur_tx];
592 592
 
593 593
 	/* copy the packet to ring buffer */
594 594
 	memcpy(ptxb, d, ETH_ALEN);	/* dst */

Loading…
Cancel
Save