Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Mar 1995 16:40:26 -0500 (GMT-0500)
From:      "Serge A. Babkin" <babkin@hq.icb.chel.su>
To:        davidg@Root.COM
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Another fix for 3C509
Message-ID:  <199503272140.QAA06364@hq.icb.chel.su>
In-Reply-To: <199503270447.UAA04338@corbin.Root.COM> from "David Greenman" at Mar 26, 95 08:47:35 pm

next in thread | previous in thread | raw e-mail | index | archive | help
I have made another changes for 3C509 driver. In short the changes are:

1. Connector is now selected by the following algorithm:

	If none of LINK* flags set 
		use value from EEPROM
	else
		LINK0 - AUI * highest priority
		LINK1 - BNC
		LINK2 - UTP * lowest priority

2. Eventually is doesn't complains about card failures.

Apply this diff after my previous one:


*** 1.4	1995/03/27 03:17:07
--- if_ep.c	1995/03/27 11:20:12
***************
*** 38,44 ****
   */
  
  /*
!  *  March 24 1995
   *
   *  Promiscuous mode added and interrupt logic slightly changed
   *  to reduce the number of adapter failures. Transceiver select
--- 38,44 ----
   */
  
  /*
!  *  March 27 1995
   *
   *  Promiscuous mode added and interrupt logic slightly changed
   *  to reduce the number of adapter failures. Transceiver select
***************
*** 435,440 ****
--- 435,444 ----
      while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS);
  
      GO_WINDOW(0);
+     outw(BASE + EP_COMMAND, STOP_TRANSCEIVER);
+     GO_WINDOW(4);
+     outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP);
+     GO_WINDOW(0);
  
      /* Disable the card */
      outw(BASE + EP_W0_CONFIG_CTRL, 0);
***************
*** 463,519 ****
  
      outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
  
! 	if(ep_ftst(F_PROMISC))
  		outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
  		 FIL_GROUP | FIL_BRDCST | FIL_ALL);
  	else
  		outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
  		 FIL_GROUP | FIL_BRDCST);
  
- 	/*
- 	 * you can `ifconfig ep0 (bnc|aui)' to get the following
- 	 * behaviour:
- 	 *	bnc	disable AUI/UTP. enable BNC.
- 	 *	aui	disable BNC. enable AUI. if the card has a UTP
- 	 *		connector, that is enabled too. not sure, but it
- 	 * 		seems you have to be careful to not plug things
- 	 *		into both AUI & UTP.
- 	 */
- 
  	 /*
  	  * S.B.
  	  *
  	  * Now behavior was slightly changed:
  	  * connector specified in the EEPROM is used
! 	  * anyway (if present on card or AUI if not).
  	  *
  	  */
  
!     GO_WINDOW(0);
!     j = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
!     GO_WINDOW(1);
!     switch(j) {
! 	case ACF_CONNECTOR_UTP:
! 	    if(sc->ep_connectors & UTP) {
! 		GO_WINDOW(4);
! 		outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
! 		GO_WINDOW(1);
! 	    }
! 	    break;
! 	case ACF_CONNECTOR_BNC:
! 	    if(sc->ep_connectors & BNC) {
! 		outw(BASE + EP_COMMAND, START_TRANSCEIVER);
! 		DELAY(1000);
! 	    }
! 	    break;
! 	case ACF_CONNECTOR_AUI:
! 	    /* nothing to do */
! 	    break;
! 	default:
! 	    printf("ep%d: strange connector type in EEPROM: assuming AUI\n",
! 		unit);
! 	    break;
  	}
  
      outw(BASE + EP_COMMAND, RX_ENABLE);
      outw(BASE + EP_COMMAND, TX_ENABLE);
--- 467,533 ----
  
      outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS);
  
! 	if(ifp->if_flags & IFF_PROMISC)
  		outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
  		 FIL_GROUP | FIL_BRDCST | FIL_ALL);
  	else
  		outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
  		 FIL_GROUP | FIL_BRDCST);
  
  	 /*
  	  * S.B.
  	  *
  	  * Now behavior was slightly changed:
+ 	  *
+ 	  * if any of flags link[0-2] is used and its connector is
+ 	  * physically present the following connectors are used:
+ 	  *
+ 	  *   link0 - AUI * highest precedence
+ 	  *   link1 - BNC
+ 	  *   link2 - UTP * lowest precedence
+ 	  *
+ 	  * If none of them is specified then
  	  * connector specified in the EEPROM is used
! 	  * (if present on card or AUI if not).
  	  *
  	  */
  
!     if(ifp->if_flags & IFF_LINK0 && sc->ep_connectors & AUI) {
! 	/* nothing */
!     } else if(ifp->if_flags & IFF_LINK1 && sc->ep_connectors & BNC) {
! 	outw(BASE + EP_COMMAND, START_TRANSCEIVER);
! 	DELAY(1000);
!     } else if(ifp->if_flags & IFF_LINK2 && sc->ep_connectors & UTP) {
! 	GO_WINDOW(4);
! 	outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
! 	GO_WINDOW(1);
!     } else {
! 	GO_WINDOW(0);
! 	j = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS;
! 	GO_WINDOW(1);
! 	switch(j) {
! 	    case ACF_CONNECTOR_UTP:
! 		if(sc->ep_connectors & UTP) {
! 		    GO_WINDOW(4);
! 		    outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP);
! 		    GO_WINDOW(1);
! 		}
! 		break;
! 	    case ACF_CONNECTOR_BNC:
! 		if(sc->ep_connectors & BNC) {
! 		    outw(BASE + EP_COMMAND, START_TRANSCEIVER);
! 		    DELAY(1000);
! 		}
! 		break;
! 	    case ACF_CONNECTOR_AUI:
! 		/* nothing to do */
! 		break;
! 	    default:
! 		printf("ep%d: strange connector type in EEPROM: assuming AUI\n",
! 		    unit);
! 		break;
  	}
+     }
  
      outw(BASE + EP_COMMAND, RX_ENABLE);
      outw(BASE + EP_COMMAND, TX_ENABLE);
***************
*** 679,697 ****
      struct mbuf *m;
  
  rescan:
-     /* outw(BASE + EP_COMMAND, SET_INTR_MASK);	/* disable all Ints */
  
      while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
  	if (status & (S_RX_COMPLETE | S_RX_EARLY)) {
- 	    /* we just need ACK for RX_EARLY */
- 	    if (status & S_RX_EARLY)
- 		outw(BASE + EP_COMMAND, C_RX_EARLY);
  	    epread(sc);
  	    continue;
  	}
  	if (status & S_TX_AVAIL) {
  	    /* we need ACK */
- 	    outw(BASE + EP_COMMAND, C_TX_AVAIL);
  	    sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  	    epstart(&sc->arpcom.ac_if);
  	}
--- 693,710 ----
      struct mbuf *m;
  
  rescan:
  
      while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) {
+ 
+ 	/* first acknowledge all interrupt sources */
+ 	outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK));
+ 
  	if (status & (S_RX_COMPLETE | S_RX_EARLY)) {
  	    epread(sc);
  	    continue;
  	}
  	if (status & S_TX_AVAIL) {
  	    /* we need ACK */
  	    sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  	    epstart(&sc->arpcom.ac_if);
  	}
***************
*** 750,757 ****
  	    }			/* while */
  	}			/* end TX_COMPLETE */
      }
-     /* re-enable ints */
-     /* outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS); */
  
      outw(BASE + EP_COMMAND, C_INTR_LATCH);	/* ACK int Latch */
  
--- 763,768 ----
***************
*** 1053,1059 ****
--- 1064,1077 ----
  	    epstop(ifp->if_unit);
  	    epmbufempty(sc);
  	    break;
+ 	} else {
+ 	    /* reinitialize card on any parameter change */
+ 	    epinit(ifp->if_unit);
+ 	    break;
  	}
+ 
+ 	/* NOTREACHED */
+ 
  	if (ifp->if_flags & IFF_UP && (ifp->if_flags & IFF_RUNNING) == 0)
  	    epinit(ifp->if_unit);
  
*** 1.3	1995/03/24 12:39:37
--- if_epreg.h	1995/03/27 11:20:27
***************
*** 31,37 ****
  
   */
  /*
!  *  March 24 1995
   *
   *  Promiscuous mode added and interrupt logic slightly changed
   *  to reduce the number of adapter failures. Transceiver select
--- 31,37 ----
  
   */
  /*
!  *  March 27 1995
   *
   *  Promiscuous mode added and interrupt logic slightly changed
   *  to reduce the number of adapter failures. Transceiver select
***************
*** 298,303 ****
--- 298,304 ----
  #define C_RX_EARLY	(u_short) (ACK_INTR|0x20)
  #define C_INT_RQD		(u_short) (ACK_INTR|0x40)
  #define C_UPD_STATS	(u_short) (ACK_INTR|0x80)
+ #define C_MASK	(u_short) 0xFF /* mask of C_* */
  
  /*
   * Status register. All windows.
***************
*** 325,330 ****
--- 326,332 ----
  #define S_RX_EARLY		(u_short) (0x20)
  #define S_INT_RQD		(u_short) (0x40)
  #define S_UPD_STATS		(u_short) (0x80)
+ #define S_MASK	(u_short) 0xFF /* mask of S_* */
  #define S_5_INTS                (S_CARD_FAILURE|S_TX_COMPLETE|\
  				 S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
  #define S_COMMAND_IN_PROGRESS	(u_short) (0x1000)


		Serge Babkin

! (babkin@hq.icb.chel.su)
! Headquarter of Joint Stock Bank "Chelindbank"
! Chelyabinsk, Russia



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