diff --git a/sys/dev/athn/athn.c b/sys/dev/athn/athn.c index d8829b61ea0c98..885177e929e77f 100644 --- a/sys/dev/athn/athn.c +++ b/sys/dev/athn/athn.c @@ -117,8 +117,9 @@ void athn_disable_interrupts(struct athn_softc *); void athn_init_qos(struct athn_softc *); int athn_hw_reset(struct athn_softc *, struct ieee80211_channel *, struct ieee80211_channel *, int); -struct ieee80211_node *athn_node_alloc(struct ieee80211com *); -void athn_newassoc(struct ieee80211com *, struct ieee80211_node *, +struct ieee80211_node *athn_node_alloc(struct ieee80211vap *vap, + const uint8_t mac[IEEE80211_ADDR_LEN]); +void athn_newassoc(struct ieee80211_node *, int); int athn_media_change(struct ifnet *); void athn_next_scan(void *); @@ -249,47 +250,52 @@ athn_attach(struct athn_softc *sc) // struct ifnet *ifp = &ic->ic_if; struct ifnet *ifp = NULL; int error; + struct athn_usb_softc *usc = (struct athn_usb_softc *)sc; + //mtx_lock(&sc->sc_mtx); +// /* Read hardware revision. */ + printf("przed chipid \n"); + //athn_get_chipid(sc); +printf("po chipid \n"); + // if ((error = athn_reset_power_on(sc)) != 0) { + // // TOTO missing field 'dv_xname' in 'struct device' + // // printf("%s: could not reset chip\n", sc->sc_dev.dv_xname); + // return (error); + // } - /* Read hardware revision. */ - athn_get_chipid(sc); - - if ((error = athn_reset_power_on(sc)) != 0) { - // TOTO missing field 'dv_xname' in 'struct device' - // printf("%s: could not reset chip\n", sc->sc_dev.dv_xname); - return (error); - } - - if ((error = athn_set_power_awake(sc)) != 0) { - // TOTO missing field 'dv_xname' in 'struct device' - // printf("%s: could not wakeup chip\n", sc->sc_dev.dv_xname); - return (error); - } + // if ((error = athn_set_power_awake(sc)) != 0) { + // // TOTO missing field 'dv_xname' in 'struct device' + // // printf("%s: could not wakeup chip\n", sc->sc_dev.dv_xname); + // return (error); + // } - if (AR_SREV_5416(sc) || AR_SREV_9160(sc)) - error = ar5416_attach(sc); - else if (AR_SREV_9280(sc)) - error = ar9280_attach(sc); - else if (AR_SREV_9285(sc)) - error = ar9285_attach(sc); -#if NATHN_USB > 0 - else if (AR_SREV_9271(sc)) - error = ar9285_attach(sc); -#endif - else if (AR_SREV_9287(sc)) - error = ar9287_attach(sc); - else if (AR_SREV_9380(sc) || AR_SREV_9485(sc)) - error = ar9380_attach(sc); - else - error = ENOTSUP; +// if (AR_SREV_5416(sc) || AR_SREV_9160(sc)) +// error = ar5416_attach(sc); +// else if (AR_SREV_9280(sc)) +// error = ar9280_attach(sc); +// else if (AR_SREV_9285(sc)) +// error = ar9285_attach(sc); +// #if NATHN_USB > 0 +// else if (AR_SREV_9271(sc)) +// error = ar9285_attach(sc); +// #endif +// else if (AR_SREV_9287(sc)) +// error = ar9287_attach(sc); +// else if (AR_SREV_9380(sc) || AR_SREV_9485(sc)) +// error = ar9380_attach(sc); +// else +// error = ENOTSUP; +// if (error != 0) { +// // TOTO missing field 'dv_xname' in 'struct device' +// // printf("%s: could not attach chip\n", sc->sc_dev.dv_xname); +// return (error); +// } + error = ar9285_attach(sc); if (error != 0) { - // TOTO missing field 'dv_xname' in 'struct device' - // printf("%s: could not attach chip\n", sc->sc_dev.dv_xname); return (error); } - /* We can put the chip in sleep state now. */ - athn_set_power_sleep(sc); - + // athn_set_power_sleep(sc); +//mtx_unlock(&sc->sc_mtx); if (!(sc->flags & ATHN_FLAG_USB)) { error = sc->ops.dma_alloc(sc); if (error != 0) { @@ -389,22 +395,36 @@ athn_attach(struct athn_softc *sc) IEEE80211_C_PMGT; /* Power saving supported. */ athn_config_ht(sc); - + uint8_t bands[IEEE80211_MODE_BYTES]; + memset(bands, 0, sizeof(bands)); /* Set supported rates. */ if (sc->flags & ATHN_FLAG_11G) { + printf("ATHN_FLAG_11G"); // TODO missing ieee80211_std_rateset_11b in ieee80211.c // ic->ic_sup_rates[IEEE80211_MODE_11B] = // ieee80211_std_rateset_11b; // ic->ic_sup_rates[IEEE80211_MODE_11G] = // ieee80211_std_rateset_11g; + setbit(bands, IEEE80211_MODE_11B); + setbit(bands, IEEE80211_MODE_11G); + setbit(bands, IEEE80211_MODE_11NG); + ieee80211_add_channel_list_2ghz(ic->ic_channels, IEEE80211_CHAN_MAX, &ic->ic_nchans, + athn_5ghz_chans, 14, bands, 0); } if (sc->flags & ATHN_FLAG_11A) { + printf("ATHN_FLAG_11A"); + setbit(bands, IEEE80211_MODE_11A); + setbit(bands, IEEE80211_MODE_11NA); + ieee80211_add_channel_list_5ghz(ic->ic_channels, IEEE80211_CHAN_MAX, &ic->ic_nchans, + athn_5ghz_chans, nitems(athn_5ghz_chans), bands, 0); // ic->ic_sup_rates[IEEE80211_MODE_11A] = // ieee80211_std_rateset_11a; } + + /* Get the list of authorized/supported channels. */ - athn_get_chanlist(sc); + //athn_get_chanlist(sc); /* IBSS channel undefined for now. */ // TODO missing 'ic_ibss_chan' in 'struct ieee80211com' @@ -422,13 +442,14 @@ athn_attach(struct athn_softc *sc) // TODO missing members in 'struct ieee80211com' // if_attach(ifp); - // ieee80211_ifattach(ifp); - // ic->ic_node_alloc = athn_node_alloc; - // ic->ic_newassoc = athn_newassoc; + printf("to tutaj"); + ieee80211_ifattach(ic); + ic->ic_node_alloc = athn_node_alloc; + ic->ic_newassoc = athn_newassoc; ic->ic_updateslot = athn_updateslot; - // ic->ic_updateedca = athn_updateedca; - // ic->ic_set_key = athn_set_key; - // ic->ic_delete_key = athn_delete_key; + //ic->ic_updateedca = athn_updateedca; + //ic->ic_set_key = athn_set_key; + //ic->ic_delete_key = athn_delete_key; /* Override 802.11 state transition machine. */ // sc->sc_newstate = ic->ic_newstate; @@ -449,6 +470,7 @@ athn_detach(struct athn_softc *sc) // struct ifnet *ifp = &sc->sc_ic.ic_if; struct ifnet *ifp = NULL; int qid; + struct ieee80211com *ic = &sc->sc_ic; #if OpenBSD_ONLY timeout_del(&sc->scan_to); timeout_del(&sc->calib_to); @@ -466,7 +488,7 @@ athn_detach(struct athn_softc *sc) free(sc->eep, M_DEVBUF); // TODO - // ieee80211_ifdetach(ifp); + ieee80211_ifdetach(ic); #if OpenBSD_IEEE80211_API if_detach(ifp); #endif @@ -2549,7 +2571,8 @@ athn_hw_reset(struct athn_softc *sc, struct ieee80211_channel *c, } struct ieee80211_node * -athn_node_alloc(struct ieee80211com *ic) +athn_node_alloc(struct ieee80211vap *vap, + const uint8_t mac[IEEE80211_ADDR_LEN]) { struct athn_node *an; @@ -2561,13 +2584,16 @@ athn_node_alloc(struct ieee80211com *ic) ieee80211_ra_node_init(&an->rn); return (struct ieee80211_node *)an; #endif - return NULL; + an = malloc(sizeof(struct athn_node), M_80211_NODE, M_NOWAIT | M_ZERO); + if (an == NULL) + return NULL; + return (struct ieee80211_node *)an; } void -athn_newassoc(struct ieee80211com *ic, struct ieee80211_node *ni, int isnew) +athn_newassoc(struct ieee80211_node *ni, int isnew) { - struct athn_softc *sc = ic->ic_softc; + struct athn_softc *sc = ni->ni_ic->ic_softc; struct athn_node *an = (void *)ni; struct ieee80211_rateset *rs = &ni->ni_rates; uint8_t rate; @@ -2735,7 +2761,7 @@ athn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) /* Fake a join to initialize the Tx rate. */ // TODO no member named 'ic_bss' in 'struct ieee80211com' - athn_newassoc(ic, ic->ic_bss, 1); + athn_newassoc(ic->ic_bss, 1); athn_set_bss(sc, ic->ic_bss); athn_disable_interrupts(sc); @@ -2906,12 +2932,11 @@ athn_updateslot(struct ieee80211com *ic) struct athn_softc *sc = ic->ic_softc; int slot; -#if OpenBSD_IEEE80211_API - slot = (ic->ic_flags & IEEE80211_F_SHSLOT) ? - IEEE80211_DUR_DS_SHSLOT : IEEE80211_DUR_DS_SLOT; + + slot = IEEE80211_GET_SLOTTIME(ic); AR_WRITE(sc, AR_D_GBL_IFS_SLOT, slot * athn_clock_rate(sc)); AR_WRITE_BARRIER(sc); - +#if OpenBSD_IEEE80211_API // TODO no member named 'ic_bss' in 'struct ieee80211com' // athn_setacktimeout(sc, ic->ic_bss->ni_chan, slot); // athn_setctstimeout(sc, ic->ic_bss->ni_chan, slot); diff --git a/sys/dev/athn/if_athn_usb.c b/sys/dev/athn/if_athn_usb.c index a527f9d3e40844..6f96a7546a8966 100644 --- a/sys/dev/athn/if_athn_usb.c +++ b/sys/dev/athn/if_athn_usb.c @@ -486,8 +486,8 @@ athn_usb_detach(device_t self) { struct athn_usb_softc *usc = device_get_softc(self); struct athn_softc *sc = &usc->sc_sc; - - if (usc->sc_athn_attached) +//mtx_lock(&sc->sc_mtx); + if (usc->sc_athn_attached) athn_detach(sc); /* Wait for all async commands to complete. */ @@ -504,6 +504,7 @@ athn_usb_detach(device_t self) athn_usb_free_rx_list(usc); athn_usb_unload_firmware(); + //mtx_unlock(&sc->sc_mtx); printf("athn_usb_detach called \n"); return (0); } @@ -653,14 +654,12 @@ athn_usb_attachhook(device_t self) #endif /* We're now ready to attach the bus agnostic driver. */ -#if OpenBSD_IEEE80211_API // TODO: MichalP needs proper FreeBSD adaptation because this uses code that is // stubbed and/or commented error = athn_attach(sc); if (error != 0) { return; } -#endif usc->sc_athn_attached = 1; #if OpenBSD_IEEE80211_API @@ -1315,9 +1314,11 @@ athn_usb_verify_fw(struct athn_usb_softc *usc) if (data == NULL) { device_printf(sc->sc_dev, "%s: no tx cmd buffers\n", __func__); + mtx_unlock(&usc->sc_sc.sc_mtx); return; } STAILQ_REMOVE_HEAD(&usc->sc_cmd_inactive, next); + mtx_unlock(&usc->sc_sc.sc_mtx); } int @@ -1541,8 +1542,9 @@ athn_usb_wmi_xcmd(struct athn_usb_softc *usc, uint16_t cmd_id, void *ibuf, usc->wait_cmd_id = cmd_id; usc->obuf = obuf; STAILQ_INSERT_TAIL(&usc->sc_cmd_pending, data, next); + mtx_lock(&usc->sc_sc.sc_mtx); usbd_transfer_start(usc->sc_xfer[ATHN_BULK_CMD]); - + mtx_unlock(&usc->sc_sc.sc_mtx); /* * Wait for WMI command complete interrupt. In case it does not fire * wait until the USB transfer times out to avoid racing the transfer.