Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/rtwn/usb/rtwn_usb_attach.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
static void rtwn_usb_free_list(struct rtwn_softc *, | static void rtwn_usb_free_list(struct rtwn_softc *, | ||||
struct rtwn_data data[], int); | struct rtwn_data data[], int); | ||||
static void rtwn_usb_free_rx_list(struct rtwn_softc *); | static void rtwn_usb_free_rx_list(struct rtwn_softc *); | ||||
static void rtwn_usb_free_tx_list(struct rtwn_softc *); | static void rtwn_usb_free_tx_list(struct rtwn_softc *); | ||||
static void rtwn_usb_reset_lists(struct rtwn_softc *, | static void rtwn_usb_reset_lists(struct rtwn_softc *, | ||||
struct ieee80211vap *); | struct ieee80211vap *); | ||||
static void rtwn_usb_reset_tx_list(struct rtwn_usb_softc *, | static void rtwn_usb_reset_tx_list(struct rtwn_usb_softc *, | ||||
rtwn_datahead *, struct ieee80211vap *); | rtwn_datahead *, struct ieee80211vap *); | ||||
static void rtwn_usb_reset_rx_list(struct rtwn_usb_softc *); | |||||
static void rtwn_usb_start_xfers(struct rtwn_softc *); | static void rtwn_usb_start_xfers(struct rtwn_softc *); | ||||
static void rtwn_usb_abort_xfers(struct rtwn_softc *); | static void rtwn_usb_abort_xfers(struct rtwn_softc *); | ||||
static int rtwn_usb_fw_write_block(struct rtwn_softc *, | static int rtwn_usb_fw_write_block(struct rtwn_softc *, | ||||
const uint8_t *, uint16_t, int); | const uint8_t *, uint16_t, int); | ||||
static void rtwn_usb_drop_incorrect_tx(struct rtwn_softc *); | static void rtwn_usb_drop_incorrect_tx(struct rtwn_softc *); | ||||
static void rtwn_usb_attach_methods(struct rtwn_softc *); | static void rtwn_usb_attach_methods(struct rtwn_softc *); | ||||
static void rtwn_usb_sysctlattach(struct rtwn_softc *); | |||||
#define RTWN_CONFIG_INDEX 0 | #define RTWN_CONFIG_INDEX 0 | ||||
static int | static int | ||||
rtwn_usb_match(device_t self) | rtwn_usb_match(device_t self) | ||||
{ | { | ||||
struct usb_attach_arg *uaa = device_get_ivars(self); | struct usb_attach_arg *uaa = device_get_ivars(self); | ||||
Show All 34 Lines | |||||
} | } | ||||
static int | static int | ||||
rtwn_usb_alloc_rx_list(struct rtwn_softc *sc) | rtwn_usb_alloc_rx_list(struct rtwn_softc *sc) | ||||
{ | { | ||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | ||||
int error, i; | int error, i; | ||||
/* XXX recheck */ | |||||
error = rtwn_usb_alloc_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT, | error = rtwn_usb_alloc_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT, | ||||
sc->rx_dma_size + 1024); | uc->uc_rx_buf_size * RTWN_USB_RXBUFSZ_UNIT); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
STAILQ_INIT(&uc->uc_rx_active); | STAILQ_INIT(&uc->uc_rx_active); | ||||
STAILQ_INIT(&uc->uc_rx_inactive); | STAILQ_INIT(&uc->uc_rx_inactive); | ||||
for (i = 0; i < RTWN_USB_RX_LIST_COUNT; i++) | for (i = 0; i < RTWN_USB_RX_LIST_COUNT; i++) | ||||
STAILQ_INSERT_HEAD(&uc->uc_rx_inactive, &uc->uc_rx[i], next); | STAILQ_INSERT_HEAD(&uc->uc_rx_inactive, &uc->uc_rx[i], next); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
rtwn_usb_free_rx_list(struct rtwn_softc *sc) | rtwn_usb_free_rx_list(struct rtwn_softc *sc) | ||||
{ | { | ||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | ||||
rtwn_usb_free_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT); | rtwn_usb_free_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT); | ||||
uc->uc_rx_stat_len = 0; | |||||
uc->uc_rx_off = 0; | |||||
STAILQ_INIT(&uc->uc_rx_active); | STAILQ_INIT(&uc->uc_rx_active); | ||||
STAILQ_INIT(&uc->uc_rx_inactive); | STAILQ_INIT(&uc->uc_rx_inactive); | ||||
} | } | ||||
static void | static void | ||||
rtwn_usb_free_tx_list(struct rtwn_softc *sc) | rtwn_usb_free_tx_list(struct rtwn_softc *sc) | ||||
{ | { | ||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | ||||
Show All 9 Lines | |||||
rtwn_usb_reset_lists(struct rtwn_softc *sc, struct ieee80211vap *vap) | rtwn_usb_reset_lists(struct rtwn_softc *sc, struct ieee80211vap *vap) | ||||
{ | { | ||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | ||||
RTWN_ASSERT_LOCKED(sc); | RTWN_ASSERT_LOCKED(sc); | ||||
rtwn_usb_reset_tx_list(uc, &uc->uc_tx_active, vap); | rtwn_usb_reset_tx_list(uc, &uc->uc_tx_active, vap); | ||||
rtwn_usb_reset_tx_list(uc, &uc->uc_tx_pending, vap); | rtwn_usb_reset_tx_list(uc, &uc->uc_tx_pending, vap); | ||||
if (vap == NULL) | if (vap == NULL) { | ||||
rtwn_usb_reset_rx_list(uc); | |||||
sc->qfullmsk = 0; | sc->qfullmsk = 0; | ||||
} | } | ||||
} | |||||
static void | static void | ||||
rtwn_usb_reset_tx_list(struct rtwn_usb_softc *uc, | rtwn_usb_reset_tx_list(struct rtwn_usb_softc *uc, | ||||
rtwn_datahead *head, struct ieee80211vap *vap) | rtwn_datahead *head, struct ieee80211vap *vap) | ||||
{ | { | ||||
struct rtwn_vap *uvp = RTWN_VAP(vap); | struct rtwn_vap *uvp = RTWN_VAP(vap); | ||||
struct rtwn_data *dp, *tmp; | struct rtwn_data *dp, *tmp; | ||||
int id; | int id; | ||||
Show All 16 Lines | if (vap == NULL || (dp->ni == NULL && | ||||
STAILQ_REMOVE(head, dp, rtwn_data, next); | STAILQ_REMOVE(head, dp, rtwn_data, next); | ||||
STAILQ_INSERT_TAIL(&uc->uc_tx_inactive, dp, next); | STAILQ_INSERT_TAIL(&uc->uc_tx_inactive, dp, next); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
rtwn_usb_reset_rx_list(struct rtwn_usb_softc *uc) | |||||
{ | |||||
int i; | |||||
for (i = 0; i < RTWN_USB_RX_LIST_COUNT; i++) { | |||||
struct rtwn_data *dp = &uc->uc_rx[i]; | |||||
if (dp->m != NULL) { | |||||
m_freem(dp->m); | |||||
dp->m = NULL; | |||||
} | |||||
} | |||||
uc->uc_rx_stat_len = 0; | |||||
uc->uc_rx_off = 0; | |||||
} | |||||
static void | |||||
rtwn_usb_start_xfers(struct rtwn_softc *sc) | rtwn_usb_start_xfers(struct rtwn_softc *sc) | ||||
{ | { | ||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | ||||
usbd_transfer_start(uc->uc_xfer[RTWN_BULK_RX]); | usbd_transfer_start(uc->uc_xfer[RTWN_BULK_RX]); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | rtwn_usb_attach_methods(struct rtwn_softc *sc) | ||||
sc->sc_drop_incorrect_tx = rtwn_usb_drop_incorrect_tx; | sc->sc_drop_incorrect_tx = rtwn_usb_drop_incorrect_tx; | ||||
sc->sc_beacon_update_begin = rtwn_nop_softc_vap; | sc->sc_beacon_update_begin = rtwn_nop_softc_vap; | ||||
sc->sc_beacon_update_end = rtwn_nop_softc_vap; | sc->sc_beacon_update_end = rtwn_nop_softc_vap; | ||||
sc->sc_beacon_unload = rtwn_nop_softc_int; | sc->sc_beacon_unload = rtwn_nop_softc_int; | ||||
sc->bcn_check_interval = 100; | sc->bcn_check_interval = 100; | ||||
} | } | ||||
static void | |||||
rtwn_usb_sysctlattach(struct rtwn_softc *sc) | |||||
{ | |||||
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc); | |||||
struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->sc_dev); | |||||
struct sysctl_oid *tree = device_get_sysctl_tree(sc->sc_dev); | |||||
char str[64]; | |||||
int ret; | |||||
ret = snprintf(str, sizeof(str), | |||||
"Rx buffer size, 512-byte units [%d...%d]", | |||||
RTWN_USB_RXBUFSZ_MIN, RTWN_USB_RXBUFSZ_MAX); | |||||
KASSERT(ret > 0, ("ret (%d) <= 0!\n", ret)); | |||||
(void) ret; | |||||
uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_DEF; | |||||
SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, | |||||
"rx_buf_size", CTLFLAG_RDTUN, &uc->uc_rx_buf_size, | |||||
uc->uc_rx_buf_size, str); | |||||
if (uc->uc_rx_buf_size < RTWN_USB_RXBUFSZ_MIN) | |||||
uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MIN; | |||||
if (uc->uc_rx_buf_size > RTWN_USB_RXBUFSZ_MAX) | |||||
uc->uc_rx_buf_size = RTWN_USB_RXBUFSZ_MAX; | |||||
} | |||||
static int | static int | ||||
rtwn_usb_attach(device_t self) | rtwn_usb_attach(device_t self) | ||||
{ | { | ||||
struct usb_attach_arg *uaa = device_get_ivars(self); | struct usb_attach_arg *uaa = device_get_ivars(self); | ||||
struct rtwn_usb_softc *uc = device_get_softc(self); | struct rtwn_usb_softc *uc = device_get_softc(self); | ||||
struct rtwn_softc *sc = &uc->uc_sc; | struct rtwn_softc *sc = &uc->uc_sc; | ||||
struct ieee80211com *ic = &sc->sc_ic; | struct ieee80211com *ic = &sc->sc_ic; | ||||
int error; | int error; | ||||
device_set_usb_desc(self); | device_set_usb_desc(self); | ||||
uc->uc_udev = uaa->device; | uc->uc_udev = uaa->device; | ||||
sc->sc_dev = self; | sc->sc_dev = self; | ||||
ic->ic_name = device_get_nameunit(self); | ic->ic_name = device_get_nameunit(self); | ||||
/* Need to be initialized early. */ | /* Need to be initialized early. */ | ||||
rtwn_sysctlattach(sc); | rtwn_sysctlattach(sc); | ||||
rtwn_usb_sysctlattach(sc); | |||||
mtx_init(&sc->sc_mtx, ic->ic_name, MTX_NETWORK_LOCK, MTX_DEF); | mtx_init(&sc->sc_mtx, ic->ic_name, MTX_NETWORK_LOCK, MTX_DEF); | ||||
rtwn_usb_attach_methods(sc); | rtwn_usb_attach_methods(sc); | ||||
rtwn_usb_attach_private(uc, USB_GET_DRIVER_INFO(uaa)); | rtwn_usb_attach_private(uc, USB_GET_DRIVER_INFO(uaa)); | ||||
error = rtwn_usb_setup_endpoints(uc); | error = rtwn_usb_setup_endpoints(uc); | ||||
if (error != 0) | if (error != 0) | ||||
goto detach; | goto detach; | ||||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |