1/* $OpenBSD: if_upgt.c,v 1.35 2008/04/16 18:32:15 damien Exp $ */ |
2/* $FreeBSD: head/sys/dev/usb/wlan/if_upgt.c 246614 2013-02-10 10:36:16Z hselasky $ */ |
3 4/* 5 * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * --- 450 unchanged lines hidden (view full) --- 461} 462 463static int 464upgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 465{ 466 struct upgt_softc *sc = ifp->if_softc; 467 struct ieee80211com *ic = ifp->if_l2com; 468 struct ifreq *ifr = (struct ifreq *) data; |
469 int error; 470 int startall = 0; |
471 |
472 UPGT_LOCK(sc); 473 error = (sc->sc_flags & UPGT_FLAG_DETACHED) ? ENXIO : 0; 474 UPGT_UNLOCK(sc); 475 if (error) 476 return (error); 477 |
478 switch (cmd) { 479 case SIOCSIFFLAGS: 480 if (ifp->if_flags & IFF_UP) { 481 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 482 if ((ifp->if_flags ^ sc->sc_if_flags) & 483 (IFF_ALLMULTI | IFF_PROMISC)) 484 upgt_set_multi(sc); 485 } else { --- 1492 unchanged lines hidden (view full) --- 1978 STAILQ_INIT(&sc->sc_rx_active); 1979 STAILQ_INIT(&sc->sc_rx_inactive); 1980 1981 for (i = 0; i < UPGT_RX_MAXCOUNT; i++) { 1982 struct upgt_data *data = &sc->sc_rx_data[i]; 1983 data->buf = ((uint8_t *)sc->sc_rx_dma_buf) + (i * MCLBYTES); 1984 STAILQ_INSERT_TAIL(&sc->sc_rx_inactive, data, next); 1985 } |
1986 return (0); 1987} 1988 1989static int 1990upgt_detach(device_t dev) 1991{ 1992 struct upgt_softc *sc = device_get_softc(dev); 1993 struct ifnet *ifp = sc->sc_ifp; 1994 struct ieee80211com *ic = ifp->if_l2com; |
1995 unsigned int x; |
1996 |
1997 /* 1998 * Prevent further allocations from RX/TX/CMD 1999 * data lists and ioctls 2000 */ 2001 UPGT_LOCK(sc); 2002 sc->sc_flags |= UPGT_FLAG_DETACHED; |
2003 |
2004 STAILQ_INIT(&sc->sc_tx_active); 2005 STAILQ_INIT(&sc->sc_tx_inactive); 2006 STAILQ_INIT(&sc->sc_tx_pending); 2007 2008 STAILQ_INIT(&sc->sc_rx_active); 2009 STAILQ_INIT(&sc->sc_rx_inactive); 2010 UPGT_UNLOCK(sc); 2011 |
2012 upgt_stop(sc); 2013 2014 callout_drain(&sc->sc_led_ch); 2015 callout_drain(&sc->sc_watchdog_ch); 2016 |
2017 /* drain USB transfers */ 2018 for (x = 0; x != UPGT_N_XFERS; x++) 2019 usbd_transfer_drain(sc->sc_xfer[x]); |
2020 |
2021 /* free data buffers */ 2022 UPGT_LOCK(sc); |
2023 upgt_free_rx(sc); 2024 upgt_free_tx(sc); |
2025 UPGT_UNLOCK(sc); |
2026 |
2027 /* free USB transfers and some data buffers */ 2028 usbd_transfer_unsetup(sc->sc_xfer, UPGT_N_XFERS); 2029 2030 ieee80211_ifdetach(ic); |
2031 if_free(ifp); 2032 mtx_destroy(&sc->sc_mtx); 2033 2034 return (0); 2035} 2036 2037static void 2038upgt_free_rx(struct upgt_softc *sc) --- 11 unchanged lines hidden (view full) --- 2050static void 2051upgt_free_tx(struct upgt_softc *sc) 2052{ 2053 int i; 2054 2055 for (i = 0; i < UPGT_TX_MAXCOUNT; i++) { 2056 struct upgt_data *data = &sc->sc_tx_data[i]; 2057 |
2058 if (data->ni != NULL) 2059 ieee80211_free_node(data->ni); 2060 |
2061 data->buf = NULL; 2062 data->ni = NULL; 2063 } 2064} 2065 2066static void 2067upgt_abort_xfers_locked(struct upgt_softc *sc) 2068{ --- 353 unchanged lines hidden --- |