Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Feb 1996 09:31:17 -0800
From:      "Justin T. Gibbs" <gibbs@freefall.freebsd.org>
To:        current
Subject:   3c509 patches.
Message-ID:  <199602121731.JAA13159@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
These patches re-enable the watchdog timer and do some other
cleanup in how we access our ifp.  Can someone test these please
so I can commit them?  I have a 3c509, but no network at the
moment.

Thanks
--
Justin T. Gibbs
===========================================
  FreeBSD: Turning PCs into workstations
===========================================


Index: if_ep.c
===================================================================
RCS file: /usr/cvs/src/sys/i386/isa/if_ep.c,v
retrieving revision 1.40
diff -c -r1.40 if_ep.c
*** if_ep.c	1996/02/06 18:50:41	1.40
--- if_ep.c	1996/02/12 17:25:47
***************
*** 689,701 ****
      int s, pad;
  
      s = splimp();
!     if (sc->arpcom.ac_if.if_flags & IFF_OACTIVE) {
  	splx(s);
  	return;
      }
  startagain:
      /* Sneak a peek at the next packet */
!     m = sc->arpcom.ac_if.if_snd.ifq_head;
      if (m == 0) {
  	splx(s);
  	return;
--- 689,701 ----
      int s, pad;
  
      s = splimp();
!     if (ifp->if_flags & IFF_OACTIVE) {
  	splx(s);
  	return;
      }
  startagain:
      /* Sneak a peek at the next packet */
!     m = ifp->if_snd.ifq_head;
      if (m == 0) {
  	splx(s);
  	return;
***************
*** 712,730 ****
       */
      if (len + pad > ETHER_MAX_LEN) {
  	/* packet is obviously too large: toss it */
! 	++sc->arpcom.ac_if.if_oerrors;
! 	IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
  	m_freem(m);
  	goto readcheck;
      }
      if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
  	/* no room in FIFO */
  	outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
! 	sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
  	splx(s);
  	return;
      }
!     IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
  
      outw(BASE + EP_W1_TX_PIO_WR_1, len);
      outw(BASE + EP_W1_TX_PIO_WR_1, 0x0);	/* Second dword meaningless */
--- 712,730 ----
       */
      if (len + pad > ETHER_MAX_LEN) {
  	/* packet is obviously too large: toss it */
! 	++ifp->if_oerrors;
! 	IF_DEQUEUE(&ifp->if_snd, m);
  	m_freem(m);
  	goto readcheck;
      }
      if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) {
  	/* no room in FIFO */
  	outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4));
! 	ifp->if_flags |= IFF_OACTIVE;
  	splx(s);
  	return;
      }
!     IF_DEQUEUE(&ifp->if_snd, m);
  
      outw(BASE + EP_W1_TX_PIO_WR_1, len);
      outw(BASE + EP_W1_TX_PIO_WR_1, 0x0);	/* Second dword meaningless */
***************
*** 761,772 ****
  	outb(BASE + EP_W1_TX_PIO_WR_1, 0);	/* Padding */
  
  #if NBPFILTER > 0
!     if (sc->arpcom.ac_if.if_bpf) {
! 	bpf_mtap(&sc->arpcom.ac_if, top);
      }
  #endif
  
!     sc->arpcom.ac_if.if_opackets++;
      m_freem(top);
      /*
       * Every 1024*4 packets we increment the tx_rate if we haven't had
--- 761,773 ----
  	outb(BASE + EP_W1_TX_PIO_WR_1, 0);	/* Padding */
  
  #if NBPFILTER > 0
!     if (ifp->if_bpf) {
! 	bpf_mtap(ifp, top);
      }
  #endif
  
!     ifp->if_timer=2;
!     ifp->if_opackets++;
      m_freem(top);
      /*
       * Every 1024*4 packets we increment the tx_rate if we haven't had
***************
*** 786,792 ****
  	 * we check if we have packets left, in that case we prepare to come
  	 * back later
  	 */
! 	if (sc->arpcom.ac_if.if_snd.ifq_head) {
  	    outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH |
  		 sc->tx_start_thresh);
  	}
--- 787,793 ----
  	 * we check if we have packets left, in that case we prepare to come
  	 * back later
  	 */
! 	if (ifp->if_snd.ifq_head) {
  	    outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH |
  		 sc->tx_start_thresh);
  	}
***************
*** 802,811 ****
--- 803,815 ----
  {
      register int status;
      register struct ep_softc *sc = &ep_softc[unit];
+     struct ifnet *ifp;
      int x;
  
      x=splbio();
  
+     ifp = &sc->arpcom.ac_if;
+ 
      outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
  
  rescan:
***************
*** 821,839 ****
  	}
  	if (status & S_TX_AVAIL) {
  	    /* we need ACK */
! 	    sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  	    GO_WINDOW(1);
  	    inw(BASE + EP_W1_FREE_TX);
! 	    epstart(&sc->arpcom.ac_if);
  	}
  	if (status & S_CARD_FAILURE) {
  #ifdef EP_LOCAL_STATS
  	    printf("\nep%d:\n\tStatus: %x\n", unit, status);
  	    GO_WINDOW(4);
  	    printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
  	    printf("\tStat: %x\n", sc->stat);
  	    printf("\tIpackets=%d, Opackets=%d\n",
! 		sc->arpcom.ac_if.if_ipackets, sc->arpcom.ac_if.if_opackets);
  	    printf("\tNOF=%d, NOMB=%d, BPFD=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
  		   sc->rx_no_first, sc->rx_no_mbuf, sc->rx_bpf_disc, sc->rx_overrunf,
  		   sc->rx_overrunl, sc->tx_underrun);
--- 825,845 ----
  	}
  	if (status & S_TX_AVAIL) {
  	    /* we need ACK */
! 	    ifp->if_timer=0;
! 	    ifp->if_flags &= ~IFF_OACTIVE;
  	    GO_WINDOW(1);
  	    inw(BASE + EP_W1_FREE_TX);
! 	    epstart(ifp);
  	}
  	if (status & S_CARD_FAILURE) {
+ 	    ifp->if_timer=0;
  #ifdef EP_LOCAL_STATS
  	    printf("\nep%d:\n\tStatus: %x\n", unit, status);
  	    GO_WINDOW(4);
  	    printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG));
  	    printf("\tStat: %x\n", sc->stat);
  	    printf("\tIpackets=%d, Opackets=%d\n",
! 		ifp->if_ipackets, ifp->if_opackets);
  	    printf("\tNOF=%d, NOMB=%d, BPFD=%d, RXOF=%d, RXOL=%d, TXU=%d\n",
  		   sc->rx_no_first, sc->rx_no_mbuf, sc->rx_bpf_disc, sc->rx_overrunf,
  		   sc->rx_overrunl, sc->tx_underrun);
***************
*** 842,848 ****
  #ifdef DIAGNOSTIC
  	    printf("ep%d: Status: %x (input buffer overflow)\n", unit, status);
  #else
! 	    ++sc->arpcom.ac_if.if_ierrors;
  #endif
  
  #endif
--- 848,854 ----
  #ifdef DIAGNOSTIC
  	    printf("ep%d: Status: %x (input buffer overflow)\n", unit, status);
  #else
! 	    ++ifp->if_ierrors;
  #endif
  
  #endif
***************
*** 851,856 ****
--- 857,863 ----
  	    return;
  	}
  	if (status & S_TX_COMPLETE) {
+ 	    ifp->if_timer=0;
  	    /* we  need ACK. we do it at the end */
  	    /*
  	     * We need to read TX_STATUS until we get a 0 status in order to
***************
*** 871,895 ****
  		    } else {
  			if (status & TXS_JABBER);
  			else	/* TXS_MAX_COLLISION - we shouldn't get here */
! 			    ++sc->arpcom.ac_if.if_collisions;
  		    }
! 		    ++sc->arpcom.ac_if.if_oerrors;
  		    outw(BASE + EP_COMMAND, TX_ENABLE);
  		    /*
  		     * To have a tx_avail_int but giving the chance to the
  		     * Reception
  		     */
! 		    if (sc->arpcom.ac_if.if_snd.ifq_head) {
  			outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
  		    }
  		}
  		outb(BASE + EP_W1_TX_STATUS, 0x0);	/* pops up the next
  							 * status */
  	    }			/* while */
! 	    sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  	    GO_WINDOW(1);
  	    inw(BASE + EP_W1_FREE_TX);
! 	    epstart(&sc->arpcom.ac_if);
  	}			/* end TX_COMPLETE */
      }
  
--- 878,902 ----
  		    } else {
  			if (status & TXS_JABBER);
  			else	/* TXS_MAX_COLLISION - we shouldn't get here */
! 			    ++ifp->if_collisions;
  		    }
! 		    ++ifp->if_oerrors;
  		    outw(BASE + EP_COMMAND, TX_ENABLE);
  		    /*
  		     * To have a tx_avail_int but giving the chance to the
  		     * Reception
  		     */
! 		    if (ifp->if_snd.ifq_head) {
  			outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8);
  		    }
  		}
  		outb(BASE + EP_W1_TX_STATUS, 0x0);	/* pops up the next
  							 * status */
  	    }			/* while */
! 	    ifp->if_flags &= ~IFF_OACTIVE;
  	    GO_WINDOW(1);
  	    inw(BASE + EP_W1_FREE_TX);
! 	    epstart(ifp);
  	}			/* end TX_COMPLETE */
      }
  
***************
*** 910,927 ****
  {
      struct ether_header *eh;
      struct mbuf *top, *mcur, *m;
      int lenthisone;
  
      short rx_fifo2, status;
      register short delta;
      register short rx_fifo;
  
      status = inw(BASE + EP_W1_RX_STATUS);
  
  read_again:
  
      if (status & ERR_RX) {
! 	++sc->arpcom.ac_if.if_ierrors;
  	if (status & ERR_RX_OVERRUN) {
  	    /*
  	     * we can think the rx latency is actually greather than we
--- 917,936 ----
  {
      struct ether_header *eh;
      struct mbuf *top, *mcur, *m;
+     struct ifnet *ifp;
      int lenthisone;
  
      short rx_fifo2, status;
      register short delta;
      register short rx_fifo;
  
+     ifp = &sc->arpcom.ac_if;
      status = inw(BASE + EP_W1_RX_STATUS);
  
  read_again:
  
      if (status & ERR_RX) {
! 	++ifp->if_ierrors;
  	if (status & ERR_RX_OVERRUN) {
  	    /*
  	     * we can think the rx latency is actually greather than we
***************
*** 1078,1092 ****
      if (delta < MIN_RX_EARLY_THRESHF)
  	delta = MIN_RX_EARLY_THRESHF;
      sc->rx_early_thresh = delta;
!     ++sc->arpcom.ac_if.if_ipackets;
      ep_fset(F_RX_FIRST);
      ep_frst(F_RX_TRAILER);
      top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
      top->m_pkthdr.len = sc->cur_len;
  
  #if NBPFILTER > 0
!     if (sc->arpcom.ac_if.if_bpf) {
! 	bpf_mtap(&sc->arpcom.ac_if, top);
  
  	/*
  	 * Note that the interface cannot be in promiscuous mode if there are
--- 1087,1101 ----
      if (delta < MIN_RX_EARLY_THRESHF)
  	delta = MIN_RX_EARLY_THRESHF;
      sc->rx_early_thresh = delta;
!     ++ifp->if_ipackets;
      ep_fset(F_RX_FIRST);
      ep_frst(F_RX_TRAILER);
      top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
      top->m_pkthdr.len = sc->cur_len;
  
  #if NBPFILTER > 0
!     if (ifp->if_bpf) {
! 	bpf_mtap(ifp, top);
  
  	/*
  	 * Note that the interface cannot be in promiscuous mode if there are
***************
*** 1094,1100 ****
  	 * check if this packet is really ours.
  	 */
  	eh = mtod(top, struct ether_header *);
! 	if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) &&
  	    (eh->ether_dhost[0] & 1) == 0 &&
  	    bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
  		 sizeof(eh->ether_dhost)) != 0 &&
--- 1103,1109 ----
  	 * check if this packet is really ours.
  	 */
  	eh = mtod(top, struct ether_header *);
! 	if ((ifp->if_flags & IFF_PROMISC) &&
  	    (eh->ether_dhost[0] & 1) == 0 &&
  	    bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
  		 sizeof(eh->ether_dhost)) != 0 &&
***************
*** 1118,1124 ****
  
      eh = mtod(top, struct ether_header *);
      m_adj(top, sizeof(struct ether_header));
!     ether_input(&sc->arpcom.ac_if, eh, top);
      if (!sc->mb[sc->next_mb])
  	epmbuffill((caddr_t) sc, 0);
      sc->top = 0;
--- 1127,1133 ----
  
      eh = mtod(top, struct ether_header *);
      m_adj(top, sizeof(struct ether_header));
!     ether_input(ifp, eh, top);
      if (!sc->mb[sc->next_mb])
  	epmbuffill((caddr_t) sc, 0);
      sc->top = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199602121731.JAA13159>