Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Apr 2002 17:28:24 +0200 (CEST)
From:      dirkx@covalent.net
To:        freebsd-hackers@FreeBSD.ORG
Cc:        yen_cw@myson.com.tw
Subject:   Myson / if_my.c for FreeBSD
Message-ID:  <Pine.OSX.4.43.0204151721250.500-100000@mobile.webweaving.org>

next in thread | raw e-mail | index | archive | help

Attached is a short diff which makes the freebsd5 drivers from

	http://www.myson.com.tw/mtd/803_drivers.htm.
->
	http://www.myson.com.tw/mtd/driver/803/mtd80x-freebsd.tgz.TGZ
->
	MD5 (mtd80x-freebsd.tgz.TGZ) = 52348a57543f90c501337bf73c4257fb

function on freebsd-CURRENT. Attached patch has worked fine for the last
couple of week under moderate server usage. As I've no understanding of
all this new kernel locking thing - feel free to set me right as how to
really do it! (I just looked at a few of the other if_*.c and mimiced
the changes - YMMV :-).

Thanks !

Dw.
-- 
Dirk-Willem van Gulik / dirkx(a)apache.org

diff -c3 freebsd/freebsd5/if_my.c /sys/pci/if_my.c
	 FreeBSD 5.0-CURRENT #11

*** if_my.c	Mon Apr 15 17:12:02 2002
--- /sys/pci/if_my.c	Mon Apr 15 17:10:03 2002
***************
*** 1004,1010 ****
  static int my_attach(dev)
  device_t dev;
  {
!    int s, i;
     u_char eaddr[ETHER_ADDR_LEN];
     u_int32_t command, iobase;
     struct my_softc *sc;
--- 1004,1010 ----
  static int my_attach(dev)
  device_t dev;
  {
!    int i;
     u_char eaddr[ETHER_ADDR_LEN];
     u_int32_t command, iobase;
     struct my_softc *sc;
***************
*** 1016,1023 ****
     u_int16_t phy_vid, phy_did, phy_sts=0;
     int rid, unit, error = 0;

-    s = splimp();
-

     sc = device_get_softc(dev);
     unit = device_get_unit(dev);
--- 1016,1021 ----
***************
*** 1250,1257 ****

     ifmedia_init(&sc->ifmedia, 0, my_ifmedia_upd, my_ifmedia_sts);

-
-
     my_getmode_mii(sc);
     my_autoneg_mii(sc, MY_FLAG_FORCEDELAY, 1);

--- 1248,1253 ----
***************
*** 1263,1271 ****
      * Call MI attach routines.
      */

!
!    if_attach(ifp);
!
     ether_ifattach(ifp, ETHER_BPF_SUPPORTED);

  #if NBPFILTER > 0
--- 1259,1265 ----
      * Call MI attach routines.
      */

!    // if_attach(ifp);
     ether_ifattach(ifp, ETHER_BPF_SUPPORTED);

  #if NBPFILTER > 0
***************
*** 1282,1288 ****
  fail:
     MY_UNLOCK(sc);
     mtx_destroy(&sc->my_mtx);
-    splx(s);
     return(error);
  }

--- 1276,1281 ----
***************
*** 1292,1300 ****
  {
  	struct my_softc 	*sc;
  	struct ifnet		*ifp;
- 	int			s;
-
- 	s = splimp();

  	sc = device_get_softc(dev);

--- 1285,1290 ----
***************
*** 1319,1325 ****
  	free(sc, M_DEVBUF);

  	MY_UNLOCK(sc);
- 	splx(s);
  	mtx_destroy(&sc->my_mtx);

  	return(0);
--- 1309,1314 ----
***************
*** 1380,1388 ****
     {
        cd->my_rx_chain[i].my_ptr = (struct my_desc *)&ld->my_rx_list[i];

!       if (my_newbuf(sc, &cd->my_rx_chain[i]) == ENOBUFS)
  	return(ENOBUFS);
!
        if (i == (MY_RX_LIST_CNT - 1))
        {
  	 cd->my_rx_chain[i].my_nextdesc = &cd->my_rx_chain[0];
--- 1369,1378 ----
     {
        cd->my_rx_chain[i].my_ptr = (struct my_desc *)&ld->my_rx_list[i];

!       if (my_newbuf(sc, &cd->my_rx_chain[i]) == ENOBUFS) {
!         MY_UNLOCK(sc);
  	return(ENOBUFS);
!       }
        if (i == (MY_RX_LIST_CNT - 1))
        {
  	 cd->my_rx_chain[i].my_nextdesc = &cd->my_rx_chain[0];
***************
*** 1419,1424 ****
--- 1409,1415 ----
     {
        printf("my%d: no memory for rx list -- packet dropped!\n",
  	      sc->my_unit);
+       MY_UNLOCK(sc);
        return(ENOBUFS);
     }

***************
*** 1428,1433 ****
--- 1419,1425 ----
        printf("my%d: no memory for rx list -- packet dropped!\n",
  	      sc->my_unit);
        m_freem(m_new);
+       MY_UNLOCK(sc);
        return(ENOBUFS);
     }

***************
*** 1557,1565 ****
     /* Clear the timeout timer. */
     ifp->if_timer = 0;

!    if (sc->my_cdata.my_tx_head == NULL)
       return;
!
     /*
      * Go through our tx list and free mbufs for those
      * frames that have been transmitted.
--- 1549,1558 ----
     /* Clear the timeout timer. */
     ifp->if_timer = 0;

!    if (sc->my_cdata.my_tx_head == NULL) {
!      MY_UNLOCK(sc);
       return;
!    }
     /*
      * Go through our tx list and free mbufs for those
      * frames that have been transmitted.
***************
*** 1756,1761 ****
--- 1749,1755 ----
     if (m_new == NULL)
     {
        printf("my%d: no memory for tx list", sc->my_unit);
+       MY_UNLOCK(sc);
        return(1);
     }

***************
*** 1766,1771 ****
--- 1760,1766 ----
        {
  	 m_freem(m_new);
  	 printf("my%d: no memory for tx list", sc->my_unit);
+          MY_UNLOCK(sc);
  	 return(1);
        }
     }
***************
*** 1905,1911 ****
  {
     struct my_softc *sc = xsc;
     struct ifnet *ifp = &sc->arpcom.ac_if;
-    int s;
     u_int16_t phy_bmcr = 0;

     MY_LOCK(sc);
--- 1900,1905 ----
***************
*** 1916,1923 ****
       return;
      }

-    s = splimp();
-
     if (sc->my_pinfo != NULL)
       phy_bmcr = my_phy_readreg(sc, PHY_BMCR);

--- 1910,1915 ----
***************
*** 1952,1958 ****
        printf("my%d: initialization failed: no memory for rx buffers\n",
  	      sc->my_unit);
        my_stop(sc);
-       (void)splx(s);

        MY_UNLOCK(sc);

--- 1944,1949 ----
***************
*** 2007,2014 ****
     ifp->if_flags |= IFF_RUNNING;
     ifp->if_flags &= ~IFF_OACTIVE;

-    (void)splx(s);
-
     MY_UNLOCK(sc);

     return;
--- 1998,2003 ----
***************
*** 2133,2141 ****
  {
     struct my_softc *sc = ifp->if_softc;
     struct ifreq *ifr = (struct ifreq *)data;
!    int s, error = 0;
!
!    s = splimp();

     MY_LOCK(sc);

--- 2122,2128 ----
  {
     struct my_softc *sc = ifp->if_softc;
     struct ifreq *ifr = (struct ifreq *)data;
!    int error = 0;

     MY_LOCK(sc);

***************
*** 2169,2176 ****

     MY_UNLOCK(sc);

-    (void)splx(s);
-
     return(error);
  }

--- 2156,2161 ----
***************
*** 2206,2212 ****
     if (ifp->if_snd.ifq_head != NULL)
       my_start(ifp);

!    MY_LOCK(sc);

     return;
  }
--- 2191,2197 ----
     if (ifp->if_snd.ifq_head != NULL)
       my_start(ifp);

!    MY_UNLOCK(sc);

     return;
  }


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSX.4.43.0204151721250.500-100000>