From owner-FreeBSD-users-jp@jp.FreeBSD.org Fri Sep 20 23:26:33 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g8KEQXW50485;
	Fri, 20 Sep 2002 23:26:33 +0900 (JST)
	(envelope-from owner-FreeBSD-users-jp@jp.FreeBSD.org)
Received: from smtp1.att.ne.jp (smtp1.att.ne.jp [165.76.15.137])
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) with ESMTP/inet id g8KEQW350480
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Fri, 20 Sep 2002 23:26:33 +0900 (JST)
	(envelope-from zodiac@zam.att.ne.jp)
Received: from prospector (94.105.111.219.dy.excite.co.jp [219.111.105.94])
	by smtp1.att.ne.jp (Postfix) with ESMTP id D5AEC154F8
	for <FreeBSD-users-jp@jp.FreeBSD.org>; Fri, 20 Sep 2002 23:26:30 +0900 (JST)
From: Takashi Oono <zodiac@zam.att.ne.jp>
To: FreeBSD-users-jp@jp.FreeBSD.org
Message-Id: <20020920231145.7ED9.ZODIAC@zam.att.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-2022-JP"
Content-Transfer-Encoding: 7bit
X-Mailer: Becky! ver. 2.00.07
Reply-To: FreeBSD-users-jp@jp.FreeBSD.org
Precedence: list
Date: Fri, 20 Sep 2002 23:26:30 +0900
X-Sequence: FreeBSD-users-jp 70905
Subject: [FreeBSD-users-jp 70905] if_nge DEVICE_POLLING
 =?ISO-2022-JP?B?GyRCQlAxfiVRJUMlQRsoQg==?= 
Errors-To: owner-FreeBSD-users-jp@jp.FreeBSD.org
Sender: owner-FreeBSD-users-jp@jp.FreeBSD.org
X-Originator: zodiac@zam.att.ne.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+020902

$B=i$a$^$7$F(B $BBgLn$H?=$7$^$9!#(B

NS DP83820$BMQ%I%i%$%P(B if_nge$B$r(BDEVICE_POLLING$B$KBP1~$5$;$k%Q%C%A$r(B
$B:n$C$F$_$^$7$?!#(B

$B<{MW$,$"$k$+J,$+$j$^$;$s$,8x3+$7$F$_$^$9!#(B
FreeBSD 4.7-RC$B>e$G:n$C$F$"$j$^$9$,!"(B4.6R$BJU$j$G$bEv$?$k$H;W$$$^$9!#(B

*** if_nge.c.old	Fri Sep 20 11:16:33 2002
--- if_nge.c	Fri Sep 20 12:15:54 2002
***************
*** 1380,1385 ****
--- 1380,1393 ----
  		struct mbuf		*m0 = NULL;
  		u_int32_t		extsts;
  
+ #ifdef DEVICE_POLLING
+ 		if (ifp->if_ipending & IFF_POLLING) {
+ 			if (sc->rxcycles <= 0)
+ 				break;
+ 			sc->rxcycles--;
+ 		}
+ #endif /* DEVICE_POLLING */
+ 
  		cur_rx = &sc->nge_ldata->nge_rx_list[i];
  		rxstat = cur_rx->nge_rxstat;
  		extsts = cur_rx->nge_extsts;
***************
*** 1584,1589 ****
--- 1592,1645 ----
  	return;
  }
  
+ #ifdef DEVICE_POLLING
+ static poll_handler_t nge_poll;
+ 
+ static void
+ nge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+ {
+ 	struct  nge_softc *sc = ifp->if_softc;
+ 
+ 	if (cmd == POLL_DEREGISTER) {	/* final call, enable interrupts */
+ 		CSR_WRITE_4(sc, NGE_IER, 1);
+ 		return;
+ 	}
+ 
+ 	/*
+ 	 * On the nge, reading the status register also clears it.
+ 	 * So before returning to intr mode we must make sure that all
+ 	 * possible pending sources of interrupts have been served.
+ 	 * In practice this means run to completion the *eof routines,
+ 	 * and then call the interrupt routine
+ 	 */
+ 	sc->rxcycles = count;
+ 	nge_rxeof(sc);
+ 	nge_txeof(sc);
+ 	if (ifp->if_snd.ifq_head != NULL)
+ 		nge_start(ifp);
+ 
+ 	if (sc->rxcycles > 0 || cmd == POLL_AND_CHECK_STATUS) {
+ 		u_int32_t	status;
+ 
+ 		/* Reading the ISR register clears all interrupts. */
+ 		status = CSR_READ_4(sc, NGE_ISR);
+ 
+ 		if (status & (NGE_ISR_RX_ERR|NGE_ISR_RX_OFLOW))
+ 			nge_rxeof(sc);
+ 
+ 		if (status & (NGE_ISR_RX_IDLE))
+ 			NGE_SETBIT(sc, NGE_CSR, NGE_CSR_RX_ENABLE);
+ 
+ 		if (status & NGE_ISR_SYSERR) {
+ 			nge_reset(sc);
+ 			nge_init(sc);
+ 		}
+ 	}
+ }
+ #endif /* DEVICE_POLLING */
+ 
+ 
+ 
  static void nge_intr(arg)
  	void			*arg;
  {
***************
*** 1594,1599 ****
--- 1650,1665 ----
  	sc = arg;
  	ifp = &sc->arpcom.ac_if;
  
+ #ifdef DEVICE_POLLING
+ 	if (ifp->if_ipending & IFF_POLLING)
+ 		return;
+ 	if (ether_poll_register(nge_poll, ifp)) { /* ok, disable interrupts */
+ 		CSR_WRITE_4(sc, NGE_IER, 0);
+ 		nge_poll(ifp, 0, 1);
+ 		return;
+ 	}
+ #endif /* DEVICE_POLLING */
+ 
  	/* Supress unwanted interrupts */
  	if (!(ifp->if_flags & IFF_UP)) {
  		nge_stop(sc);
***************
*** 1957,1962 ****
--- 2023,2037 ----
  	 * Enable interrupts.
  	 */
  	CSR_WRITE_4(sc, NGE_IMR, NGE_INTRS);
+ #ifdef DEVICE_POLLING
+ 	/*
+ 	 * ... only enable interrupts if we are not polling, make sure
+ 	 * they are off otherwise.
+ 	 */
+ 	if (ifp->if_ipending & IFF_POLLING)
+ 		CSR_WRITE_4(sc, NGE_IER, 0);
+ 	else
+ #endif /* DEVICE_POLLING */
  	CSR_WRITE_4(sc, NGE_IER, 1);
  
  	/* Enable receiver and transmitter. */
***************
*** 2210,2215 ****
--- 2285,2293 ----
  	}
  
  	untimeout(nge_tick, sc, sc->nge_stat_ch);
+ #ifdef DEVICE_POLLING
+ 	ether_poll_deregister(ifp);
+ #endif
  	CSR_WRITE_4(sc, NGE_IER, 0);
  	CSR_WRITE_4(sc, NGE_IMR, 0);
  	NGE_SETBIT(sc, NGE_CSR, NGE_CSR_TX_DISABLE|NGE_CSR_RX_DISABLE);


*** if_ngereg.h.old	Fri Sep 20 11:55:10 2002
--- if_ngereg.h	Fri Sep 20 11:56:22 2002
***************
*** 664,669 ****
--- 664,672 ----
  	SLIST_HEAD(__nge_jinusehead, nge_jpool_entry)	nge_jinuse_listhead;
  	u_int8_t		nge_tbi;
  	struct ifmedia		nge_ifmedia;
+ #ifdef DEVICE_POLLING
+ 	int			rxcycles;
+ #endif
  };
  
  /*



----------------------------------------------------------
 $BBgLn(B $B9b;L(B (Takashi Oono)    zodiac@zam.att.ne.jp
----------------------------------------------------------






