Deleted Added
sdiff udiff text old ( 288049 ) new ( 288051 )
full compact
1/* $OpenBSD: if_rsu.c,v 1.17 2013/04/15 09:23:01 mglocker Exp $ */
2
3/*-
4 * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18#include <sys/cdefs.h>
19__FBSDID("$FreeBSD: head/sys/dev/usb/wlan/if_rsu.c 288049 2015-09-20 22:52:40Z adrian $");
20
21/*
22 * Driver for Realtek RTL8188SU/RTL8191SU/RTL8192SU.
23 *
24 * TODO:
25 * o 11n support
26 * o h/w crypto
27 * o hostap / ibss / mesh

--- 475 unchanged lines hidden (view full) ---

503{
504 struct rsu_softc *sc = device_get_softc(self);
505 struct ieee80211com *ic = &sc->sc_ic;
506
507 RSU_LOCK(sc);
508 rsu_stop(sc);
509 RSU_UNLOCK(sc);
510 usbd_transfer_unsetup(sc->sc_xfer, RSU_N_TRANSFER);
511 ieee80211_ifdetach(ic);
512
513 taskqueue_drain_timeout(taskqueue_thread, &sc->calib_task);
514
515 /* Free Tx/Rx buffers. */
516 rsu_free_tx_list(sc);
517 rsu_free_rx_list(sc);
518
519 mbufq_drain(&sc->sc_snd);
520 mtx_destroy(&sc->sc_mtx);
521
522 return (0);
523}
524
525static usb_error_t
526rsu_do_request(struct rsu_softc *sc, struct usb_device_request *req,
527 void *data)

--- 226 unchanged lines hidden (view full) ---

754static struct rsu_data *
755rsu_getbuf(struct rsu_softc *sc)
756{
757 struct rsu_data *bf;
758
759 RSU_ASSERT_LOCKED(sc);
760
761 bf = _rsu_getbuf(sc);
762 return (bf);
763}
764
765static void
766rsu_freebuf(struct rsu_softc *sc, struct rsu_data *bf)
767{
768
769 RSU_ASSERT_LOCKED(sc);

--- 1222 unchanged lines hidden (view full) ---

1992
1993 RSU_LOCK(sc);
1994 if (!sc->sc_running) {
1995 RSU_UNLOCK(sc);
1996 return (ENXIO);
1997 }
1998 error = mbufq_enqueue(&sc->sc_snd, m);
1999 if (error) {
2000 RSU_UNLOCK(sc);
2001 return (error);
2002 }
2003 rsu_start(sc);
2004 RSU_UNLOCK(sc);
2005
2006 return (0);
2007}
2008
2009static void
2010rsu_start(struct rsu_softc *sc)
2011{
2012 struct ieee80211_node *ni;
2013 struct rsu_data *bf;
2014 struct mbuf *m;
2015
2016 RSU_ASSERT_LOCKED(sc);
2017
2018 while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
2019 bf = rsu_getbuf(sc);
2020 if (bf == NULL) {
2021 mbufq_prepend(&sc->sc_snd, m);
2022 break;
2023 }
2024
2025 ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
2026 m->m_pkthdr.rcvif = NULL;
2027
2028 if (rsu_tx_start(sc, ni, m, bf) != 0) {
2029 if_inc_counter(ni->ni_vap->iv_ifp,
2030 IFCOUNTER_OERRORS, 1);
2031 rsu_freebuf(sc, bf);
2032 ieee80211_free_node(ni);
2033 break;
2034 }
2035 }
2036}

--- 509 unchanged lines hidden (view full) ---

2546 struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2547 uint8_t macaddr[IEEE80211_ADDR_LEN];
2548 struct r92s_set_pwr_mode cmd;
2549 int error;
2550 int i;
2551
2552 RSU_ASSERT_LOCKED(sc);
2553
2554 /* Init host async commands ring. */
2555 sc->cmdq.cur = sc->cmdq.next = sc->cmdq.queued = 0;
2556
2557 /* Power on adapter. */
2558 if (sc->cut == 1)
2559 rsu_power_on_acut(sc);
2560 else
2561 rsu_power_on_bcut(sc);

--- 93 unchanged lines hidden (view full) ---

2655 sc->sc_calibrating = 0;
2656 taskqueue_cancel_timeout(taskqueue_thread, &sc->calib_task, NULL);
2657
2658 /* Power off adapter. */
2659 rsu_power_off(sc);
2660
2661 for (i = 0; i < RSU_N_TRANSFER; i++)
2662 usbd_transfer_stop(sc->sc_xfer[i]);
2663}
2664
2665/*
2666 * Note: usb_pause_mtx() actually releases the mutex before calling pause(),
2667 * which breaks any kind of driver serialisation.
2668 */
2669static void
2670rsu_ms_delay(struct rsu_softc *sc, int ms)
2671{
2672
2673 //usb_pause_mtx(&sc->sc_mtx, hz / 1000);
2674 DELAY(ms * 1000);
2675}