Fix NE2000 driver:
Fixed typo in ne2000.h, thinko re n2k_inb() usage, don't try to do anything in eth_stop() if eth_init() was not called. Simplified RX path in order to avoid timeouts on really really fast NE2000 cards (read: qemu with internal tftp), NetLoop() is clever enough to cope with 1 packet per eth_rx(). Signed-off-by: Vlad Lungu <vlad@comsys.ro>
This commit is contained in:
		
							parent
							
								
									07dd6eb040
								
							
						
					
					
						commit
						ff285ca07e
					
				| 
						 | 
					@ -755,7 +755,7 @@ static void pcnet_reset_8390(void)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD);
 | 
						n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	n2k_outb(n2k_inb(nic_base + PCNET_RESET), PCNET_RESET);
 | 
						n2k_outb(n2k_inb(PCNET_RESET), PCNET_RESET);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < 100; i++) {
 | 
						for (i = 0; i < 100; i++) {
 | 
				
			||||||
		if ((r = (n2k_inb(EN0_ISR) & ENISR_RESET)) != 0)
 | 
							if ((r = (n2k_inb(EN0_ISR) & ENISR_RESET)) != 0)
 | 
				
			||||||
| 
						 | 
					@ -833,6 +833,7 @@ static int plen[NB];
 | 
				
			||||||
static int nrx = 0;
 | 
					static int nrx = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int pkey = -1;
 | 
					static int pkey = -1;
 | 
				
			||||||
 | 
					static int initialized=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void uboot_push_packet_len(int len) {
 | 
					void uboot_push_packet_len(int len) {
 | 
				
			||||||
	PRINTK("pushed len = %d, nrx = %d\n", len, nrx);
 | 
						PRINTK("pushed len = %d, nrx = %d\n", len, nrx);
 | 
				
			||||||
| 
						 | 
					@ -846,7 +847,12 @@ void uboot_push_packet_len(int len) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	plen[nrx] = len;
 | 
						plen[nrx] = len;
 | 
				
			||||||
	dp83902a_recv(&pbuf[nrx*2000], len);
 | 
						dp83902a_recv(&pbuf[nrx*2000], len);
 | 
				
			||||||
 | 
					/*Just pass it to the upper layer*/
 | 
				
			||||||
 | 
						NetReceive(&pbuf[nrx*2000], plen[nrx]);
 | 
				
			||||||
 | 
					/*eth_rx() was gutted, so this is not needed anymore*/
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
	nrx++;
 | 
						nrx++;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void uboot_push_tx_done(int key, int val) {
 | 
					void uboot_push_tx_done(int key, int val) {
 | 
				
			||||||
| 
						 | 
					@ -903,37 +909,21 @@ int eth_init(bd_t *bd) {
 | 
				
			||||||
	if (dp83902a_init() == false)
 | 
						if (dp83902a_init() == false)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	dp83902a_start(dev_addr);
 | 
						dp83902a_start(dev_addr);
 | 
				
			||||||
 | 
						initialized=1;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void eth_halt() {
 | 
					void eth_halt() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PRINTK("### eth_halt\n");
 | 
						PRINTK("### eth_halt\n");
 | 
				
			||||||
 | 
						if(initialized)
 | 
				
			||||||
	dp83902a_stop();
 | 
							dp83902a_stop();
 | 
				
			||||||
 | 
						initialized=0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int eth_rx() {
 | 
					int eth_rx() {
 | 
				
			||||||
	int j, tmo;
 | 
					dp83902a_poll();
 | 
				
			||||||
 | 
					return 1;
 | 
				
			||||||
	PRINTK("### eth_rx\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	tmo = get_timer (0) + TOUT * CFG_HZ;
 | 
					 | 
				
			||||||
	while(1) {
 | 
					 | 
				
			||||||
		dp83902a_poll();
 | 
					 | 
				
			||||||
		if (nrx > 0) {
 | 
					 | 
				
			||||||
			for(j=0; j<nrx; j++) {
 | 
					 | 
				
			||||||
				NetReceive(&pbuf[j*2000], plen[j]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			nrx = 0;
 | 
					 | 
				
			||||||
			return 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (get_timer (0) >= tmo) {
 | 
					 | 
				
			||||||
			printf("timeout during rx\n");
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int eth_send(volatile void *packet, int length) {
 | 
					int eth_send(volatile void *packet, int length) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ are GPL, so this is, of course, GPL.
 | 
				
			||||||
 this file might be covered by the GNU General Public License.
 | 
					 this file might be covered by the GNU General Public License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
 | 
					 Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
 | 
				
			||||||
 at http://sources.redhat.com/ecos/ecos-license/ */
 | 
					 at http://sources.redhat.com/ecos/ecos-license/
 | 
				
			||||||
 -------------------------------------------
 | 
					 -------------------------------------------
 | 
				
			||||||
####ECOSGPLCOPYRIGHTEND####
 | 
					####ECOSGPLCOPYRIGHTEND####
 | 
				
			||||||
####BSDCOPYRIGHTBEGIN####
 | 
					####BSDCOPYRIGHTBEGIN####
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue