ethinter.c,v

来自「TCP-IP红宝书源代码」· C,V 代码 · 共 161 行

C,V
161
字号
head	1.2;
access;
symbols;
locks
	dls:1.2; strict;
comment	@ * @;


1.2
date	94.01.07.04.14.16;	author dls;	state Dist;
branches;
next	1.1;

1.1
date	94.01.07.03.10.26;	author dls;	state Old;
branches;
next	;


desc
@@


1.2
log
@*** empty log message ***
@
text
@/* ethinter.c - ethinter */

#include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <network.h>

#define PRINTERRORS

/*------------------------------------------------------------------------
 *  ethinter - ethernet interrupt processing procedure
 *
 *   Interrupts are disabled before this routine is called
 *------------------------------------------------------------------------
 */
INTPROC ethinter(etptr)
struct	etblk	*etptr;
{
	register struct le_device *le;
	struct	netif	*pni = &nif[etptr->etintf];
	struct	le_md	*pmd;
	struct	bre	*pbre;
	short		csr;
	int		i, j, oldprio;

	le = etptr->etle;
	le->le_rap = LE_CSR0;

	/* see if a hardware error has occurred */
	if ( ((csr = le->le_rdp)&LE_ERR) != 0) {
#ifdef PRINTERRORS
		if (csr&LE_BABL)
			printcsr0(le,"LEerr: Babbling xmitter");
		if (csr&LE_CERR)
			printcsr0(le,"LEerr: Collision error");
		if (csr&LE_MISS)
			printcsr0(le,"LEerr: Missed packet");
#endif	PRINTERRORS
		if (csr&LE_BABL)
			pni->ni_oerrors++;
		else
			pni->ni_ierrors++;
		/* reset the interrupt */
		le->le_csr = LE_BABL|LE_CERR|LE_MISS|LE_MERR|LE_INEA;
	}
 	if ( ((csr = le->le_rdp) & LE_TINT) != 0) {
		/* reset the interrupt */
		le->le_csr = LE_TINT|LE_INEA;

		pbre = &etptr->etbrt[0];
		pmd  = pbre->pmd;
		if ( (pmd->lmd_flags&LMD_ERR) == 0)
			etptr->etxpending--;
		else if (etptr->etwtry-- > 0) { /* retry on error */
			pmd->lmd_flags = LMD_OWN;
			pmd->lmd_bcnt  = 0;
			pmd->lmd_flags = LMD_OWN | LMD_STP | LMD_ENP;
			le->le_csr = LE_TDMD | LE_INEA;
		} else
			etptr->etxpending--;
	}

	/* check to see if a receive has completed */
	if (le->le_rdp & LE_RINT) {
	/* the chip won't tell us which buffer it filled in */
	/* But, etnextbuf always points to the next buf after */
	/* the last buffer we examined */

	/* reset the interrupt */
	le->le_csr = LE_RINT | LE_INEA;

	if (etptr->etrpending)
		goto out;
	etptr->etrpending++;
	oldprio = getprio(currpid);
	if (oldprio < NETIPRI)
		oldprio = chprio(currpid, NETIPRI);

	pbre = &etptr->etbrr[etptr->etnextbuf];
	pmd  = pbre->pmd;
	while(((pmd->lmd_flags&LMD_OWN) == 0) && (pbre->flags == 0)) {
		if ((pmd->lmd_flags&LMD_ERR) == 0) {
			pbre->flags = 1;
			ethdemux(etptr);
		} else {	/* error, so retry operation */
			pmd->lmd_flags = LMD_OWN;
			pmd->lmd_bcnt  = 0;
		}
		etptr->etnextbuf = (etptr->etnextbuf + 1) % EP_NUMRCV;
		pbre = &etptr->etbrr[etptr->etnextbuf];
		pmd  = pbre->pmd;
	}
	etptr->etrpending--;
	chprio(currpid, oldprio);
	}
out:
	ethwstrt(etptr);
}
@


1.1
log
@Initial revision
@
text
@d8 2
d69 3
a71 1
/*
a73 1
*/
d81 7
a87 12
	for (i=0; i<EP_NUMRCV; ++i) {
		if (((pmd->lmd_flags&LMD_OWN) == 0) && (pbre->flags == 0)) {
			if ((pmd->lmd_flags&LMD_ERR) == 0) {
				pbre->flags = 1;
				ethdemux(etptr);
			} else {	/* error, so retry operation */
				pmd->lmd_flags = LMD_OWN;
				pmd->lmd_bcnt  = 0;
			}
			etptr->etnextbuf = (etptr->etnextbuf + 1) % EP_NUMRCV;
			pbre = &etptr->etbrr[etptr->etnextbuf];
			pmd  = pbre->pmd;
d89 3
a96 3
	/* reset the interrupt */
	le->le_csr = LE_RINT | LE_INEA;

@

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?