Lines Matching +full:suppress +full:- +full:preamble

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
98 (((sc->malo_debug & MALO_DEBUG_RECV) && \
99 ((sc->malo_debug & MALO_DEBUG_RECV_ALL) || !IEEE80211_IS_MGMT_BEACON(wh))))
101 (sc->malo_debug & MALO_DEBUG_XMIT)
103 if (sc->malo_debug & (m)) \
152 return bus_space_read_4(sc->malo_io0t, sc->malo_io0h, off); in malo_bar0_read4()
161 bus_space_write_4(sc->malo_io0t, sc->malo_io0h, off, val); in malo_bar0_write4()
167 struct ieee80211com *ic = &sc->malo_ic; in malo_attach()
173 callout_init_mtx(&sc->malo_watchdog_timer, &sc->malo_mtx, 0); in malo_attach()
174 mbufq_init(&sc->malo_snd, ifqmaxlen); in malo_attach()
176 mh = malo_hal_attach(sc->malo_dev, devid, in malo_attach()
177 sc->malo_io1h, sc->malo_io1t, sc->malo_dmat); in malo_attach()
179 device_printf(sc->malo_dev, "unable to attach HAL\n"); in malo_attach()
183 sc->malo_mh = mh; in malo_attach()
187 * firmware; we'll re-load firmware as needed so setting up in malo_attach()
190 error = malo_hal_fwload(mh, "malo8335-h", "malo8335-m"); in malo_attach()
192 device_printf(sc->malo_dev, "unable to setup firmware\n"); in malo_attach()
196 error = malo_hal_gethwspecs(mh, &sc->malo_hwspecs); in malo_attach()
198 device_printf(sc->malo_dev, "unable to fetch h/w specs\n"); in malo_attach()
208 sc->malo_hwspecs.hwversion, in malo_attach()
209 sc->malo_hwspecs.hostinterface, sc->malo_hwspecs.maxnum_wcb, in malo_attach()
210 sc->malo_hwspecs.maxnum_mcaddr, sc->malo_hwspecs.maxnum_tx_wcb, in malo_attach()
211 sc->malo_hwspecs.regioncode, sc->malo_hwspecs.num_antenna, in malo_attach()
212 sc->malo_hwspecs.fw_releasenum, sc->malo_hwspecs.wcbbase0, in malo_attach()
213 sc->malo_hwspecs.rxdesc_read, sc->malo_hwspecs.rxdesc_write, in malo_attach()
214 sc->malo_hwspecs.ul_fw_awakecookie, in malo_attach()
215 sc->malo_hwspecs.wcbbase[0], sc->malo_hwspecs.wcbbase[1], in malo_attach()
216 sc->malo_hwspecs.wcbbase[2], sc->malo_hwspecs.wcbbase[3]); in malo_attach()
224 sc->malo_txantenna = 0x2; /* h/w default */ in malo_attach()
225 sc->malo_rxantenna = 0xffff; /* h/w default */ in malo_attach()
234 device_printf(sc->malo_dev, in malo_attach()
242 sc->malo_tq = taskqueue_create_fast("malo_taskq", M_NOWAIT, in malo_attach()
243 taskqueue_thread_enqueue, &sc->malo_tq); in malo_attach()
244 taskqueue_start_threads(&sc->malo_tq, 1, PI_NET, in malo_attach()
245 "%s taskq", device_get_nameunit(sc->malo_dev)); in malo_attach()
247 NET_TASK_INIT(&sc->malo_rxtask, 0, malo_rx_proc, sc); in malo_attach()
248 TASK_INIT(&sc->malo_txtask, 0, malo_tx_proc, sc); in malo_attach()
250 ic->ic_softc = sc; in malo_attach()
251 ic->ic_name = device_get_nameunit(sc->malo_dev); in malo_attach()
253 ic->ic_phytype = IEEE80211_T_OFDM; in malo_attach()
254 ic->ic_opmode = IEEE80211_M_STA; in malo_attach()
255 ic->ic_caps = in malo_attach()
259 | IEEE80211_C_SHPREAMBLE /* short preamble supported */ in malo_attach()
264 IEEE80211_ADDR_COPY(ic->ic_macaddr, sc->malo_hwspecs.macaddr); in malo_attach()
272 ic->ic_headroom = sizeof(struct malo_txrec) - in malo_attach()
278 ic->ic_vap_create = malo_vap_create; in malo_attach()
279 ic->ic_vap_delete = malo_vap_delete; in malo_attach()
280 ic->ic_raw_xmit = malo_raw_xmit; in malo_attach()
281 ic->ic_updateslot = malo_updateslot; in malo_attach()
282 ic->ic_scan_start = malo_scan_start; in malo_attach()
283 ic->ic_scan_end = malo_scan_end; in malo_attach()
284 ic->ic_set_channel = malo_set_channel; in malo_attach()
285 ic->ic_parent = malo_parent; in malo_attach()
286 ic->ic_transmit = malo_transmit; in malo_attach()
288 sc->malo_invalid = 0; /* ready to go, enable int handling */ in malo_attach()
291 &sc->malo_tx_th.wt_ihdr, sizeof(sc->malo_tx_th), in malo_attach()
293 &sc->malo_rx_th.wr_ihdr, sizeof(sc->malo_rx_th), in malo_attach()
311 sc->malo_invalid = 1; in malo_attach()
322 struct malo_softc *sc = ic->ic_softc; in malo_vap_create()
326 if (!TAILQ_EMPTY(&ic->ic_vaps)) { in malo_vap_create()
327 device_printf(sc->malo_dev, "multiple vaps not supported\n"); in malo_vap_create()
338 device_printf(sc->malo_dev, "%s mode not supported\n", in malo_vap_create()
343 vap = &mvp->malo_vap; in malo_vap_create()
347 mvp->malo_newstate = vap->iv_newstate; in malo_vap_create()
348 vap->iv_newstate = malo_newstate; in malo_vap_create()
353 ic->ic_opmode = opmode; in malo_vap_create()
370 struct malo_hal *mh = sc->malo_mh; in malo_intr()
373 if (sc->malo_invalid) { in malo_intr()
390 __func__, status, sc->malo_imask); in malo_intr()
393 taskqueue_enqueue(sc->malo_tq, &sc->malo_rxtask); in malo_intr()
395 taskqueue_enqueue(sc->malo_tq, &sc->malo_txtask); in malo_intr()
404 sc->malo_stats.mst_rx_badtkipicv++; in malo_intr()
407 if (((status | sc->malo_imask) ^ sc->malo_imask) != 0) in malo_intr()
422 *paddr = segs->ds_addr; in malo_load_cb()
438 dd->dd_name = name; in malo_desc_setup()
439 dd->dd_desc_len = nbuf * ndesc * descsize; in malo_desc_setup()
444 error = bus_dma_tag_create(bus_get_dma_tag(sc->malo_dev),/* parent */ in malo_desc_setup()
449 dd->dd_desc_len, /* maxsize */ in malo_desc_setup()
451 dd->dd_desc_len, /* maxsegsize */ in malo_desc_setup()
455 &dd->dd_dmat); in malo_desc_setup()
457 device_printf(sc->malo_dev, "cannot allocate %s DMA tag\n", in malo_desc_setup()
458 dd->dd_name); in malo_desc_setup()
463 error = bus_dmamem_alloc(dd->dd_dmat, (void**) &dd->dd_desc, in malo_desc_setup()
464 BUS_DMA_NOWAIT | BUS_DMA_COHERENT, &dd->dd_dmamap); in malo_desc_setup()
466 device_printf(sc->malo_dev, in malo_desc_setup()
468 "error %u\n", nbuf * ndesc, dd->dd_name, error); in malo_desc_setup()
472 error = bus_dmamap_load(dd->dd_dmat, dd->dd_dmamap, in malo_desc_setup()
473 dd->dd_desc, dd->dd_desc_len, in malo_desc_setup()
474 malo_load_cb, &dd->dd_desc_paddr, BUS_DMA_NOWAIT); in malo_desc_setup()
476 device_printf(sc->malo_dev, in malo_desc_setup()
478 dd->dd_name, error); in malo_desc_setup()
482 ds = dd->dd_desc; in malo_desc_setup()
483 memset(ds, 0, dd->dd_desc_len); in malo_desc_setup()
485 "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n", in malo_desc_setup()
486 __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, in malo_desc_setup()
487 (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); in malo_desc_setup()
491 bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); in malo_desc_setup()
493 bus_dma_tag_destroy(dd->dd_dmat); in malo_desc_setup()
499 ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
508 error = malo_desc_setup(sc, "rx", &sc->malo_rxdma, in malo_rxdma_setup()
520 device_printf(sc->malo_dev, in malo_rxdma_setup()
524 sc->malo_rxdma.dd_bufptr = bf; in malo_rxdma_setup()
526 STAILQ_INIT(&sc->malo_rxbuf); in malo_rxdma_setup()
527 ds = sc->malo_rxdma.dd_desc; in malo_rxdma_setup()
529 bf->bf_desc = ds; in malo_rxdma_setup()
530 bf->bf_daddr = DS2PHYS(&sc->malo_rxdma, ds); in malo_rxdma_setup()
531 error = bus_dmamap_create(sc->malo_dmat, BUS_DMA_NOWAIT, in malo_rxdma_setup()
532 &bf->bf_dmamap); in malo_rxdma_setup()
534 device_printf(sc->malo_dev, in malo_rxdma_setup()
540 STAILQ_INSERT_TAIL(&sc->malo_rxbuf, bf, bf_list); in malo_rxdma_setup()
552 error = malo_desc_setup(sc, "tx", &txq->dma, in malo_txdma_setup()
562 device_printf(sc->malo_dev, "malloc of %u tx buffers failed\n", in malo_txdma_setup()
566 txq->dma.dd_bufptr = bf; in malo_txdma_setup()
568 STAILQ_INIT(&txq->free); in malo_txdma_setup()
569 txq->nfree = 0; in malo_txdma_setup()
570 ds = txq->dma.dd_desc; in malo_txdma_setup()
572 bf->bf_desc = ds; in malo_txdma_setup()
573 bf->bf_daddr = DS2PHYS(&txq->dma, ds); in malo_txdma_setup()
574 error = bus_dmamap_create(sc->malo_dmat, BUS_DMA_NOWAIT, in malo_txdma_setup()
575 &bf->bf_dmamap); in malo_txdma_setup()
577 device_printf(sc->malo_dev, in malo_txdma_setup()
582 STAILQ_INSERT_TAIL(&txq->free, bf, bf_list); in malo_txdma_setup()
583 txq->nfree++; in malo_txdma_setup()
592 bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); in malo_desc_cleanup()
593 bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); in malo_desc_cleanup()
594 bus_dma_tag_destroy(dd->dd_dmat); in malo_desc_cleanup()
604 STAILQ_FOREACH(bf, &sc->malo_rxbuf, bf_list) { in malo_rxdma_cleanup()
605 if (bf->bf_m != NULL) { in malo_rxdma_cleanup()
606 m_freem(bf->bf_m); in malo_rxdma_cleanup()
607 bf->bf_m = NULL; in malo_rxdma_cleanup()
609 if (bf->bf_dmamap != NULL) { in malo_rxdma_cleanup()
610 bus_dmamap_destroy(sc->malo_dmat, bf->bf_dmamap); in malo_rxdma_cleanup()
611 bf->bf_dmamap = NULL; in malo_rxdma_cleanup()
614 STAILQ_INIT(&sc->malo_rxbuf); in malo_rxdma_cleanup()
615 if (sc->malo_rxdma.dd_bufptr != NULL) { in malo_rxdma_cleanup()
616 free(sc->malo_rxdma.dd_bufptr, M_MALODEV); in malo_rxdma_cleanup()
617 sc->malo_rxdma.dd_bufptr = NULL; in malo_rxdma_cleanup()
619 if (sc->malo_rxdma.dd_desc_len != 0) in malo_rxdma_cleanup()
620 malo_desc_cleanup(sc, &sc->malo_rxdma); in malo_rxdma_cleanup()
629 STAILQ_FOREACH(bf, &txq->free, bf_list) { in malo_txdma_cleanup()
630 if (bf->bf_m != NULL) { in malo_txdma_cleanup()
631 m_freem(bf->bf_m); in malo_txdma_cleanup()
632 bf->bf_m = NULL; in malo_txdma_cleanup()
634 ni = bf->bf_node; in malo_txdma_cleanup()
635 bf->bf_node = NULL; in malo_txdma_cleanup()
642 if (bf->bf_dmamap != NULL) { in malo_txdma_cleanup()
643 bus_dmamap_destroy(sc->malo_dmat, bf->bf_dmamap); in malo_txdma_cleanup()
644 bf->bf_dmamap = NULL; in malo_txdma_cleanup()
647 STAILQ_INIT(&txq->free); in malo_txdma_cleanup()
648 txq->nfree = 0; in malo_txdma_cleanup()
649 if (txq->dma.dd_bufptr != NULL) { in malo_txdma_cleanup()
650 free(txq->dma.dd_bufptr, M_MALODEV); in malo_txdma_cleanup()
651 txq->dma.dd_bufptr = NULL; in malo_txdma_cleanup()
653 if (txq->dma.dd_desc_len != 0) in malo_txdma_cleanup()
654 malo_desc_cleanup(sc, &txq->dma); in malo_txdma_cleanup()
663 malo_txdma_cleanup(sc, &sc->malo_txq[i]); in malo_dma_cleanup()
680 error = malo_txdma_setup(sc, &sc->malo_txq[i]); in malo_dma_setup()
687 malo_txq_init(sc, &sc->malo_txq[i], i); in malo_dma_setup()
698 malo_bar0_write4(sc, sc->malo_hwspecs.rxdesc_read, in malo_hal_set_rxtxdma()
699 sc->malo_hwdma.rxdesc_read); in malo_hal_set_rxtxdma()
700 malo_bar0_write4(sc, sc->malo_hwspecs.rxdesc_write, in malo_hal_set_rxtxdma()
701 sc->malo_hwdma.rxdesc_read); in malo_hal_set_rxtxdma()
705 sc->malo_hwspecs.wcbbase[i], sc->malo_hwdma.wcbbase[i]); in malo_hal_set_rxtxdma()
720 sc->malo_hwdma.rxdesc_read = sc->malo_rxdma.dd_desc_paddr; in malo_setup_hwdma()
723 txq = &sc->malo_txq[i]; in malo_setup_hwdma()
724 sc->malo_hwdma.wcbbase[i] = txq->dma.dd_desc_paddr; in malo_setup_hwdma()
726 sc->malo_hwdma.maxnum_txwcb = malo_txbuf; in malo_setup_hwdma()
727 sc->malo_hwdma.maxnum_wcb = MALO_NUM_TX_QUEUES; in malo_setup_hwdma()
741 txq->qnum = qnum; in malo_txq_init()
742 txq->txpri = 0; /* XXX */ in malo_txq_init()
744 STAILQ_FOREACH(bf, &txq->free, bf_list) { in malo_txq_init()
745 bf->bf_txq = txq; in malo_txq_init()
747 ds = bf->bf_desc; in malo_txq_init()
750 bn = STAILQ_FIRST(&txq->free); in malo_txq_init()
751 ds->physnext = htole32(bn->bf_daddr); in malo_txq_init()
753 STAILQ_INIT(&txq->active); in malo_txq_init()
775 bf = STAILQ_FIRST(&txq->free); in malo_getbuf()
777 STAILQ_REMOVE_HEAD(&txq->free, bf_list); in malo_getbuf()
778 txq->nfree--; in malo_getbuf()
783 "%s: out of xmit buffers on q %d\n", __func__, txq->qnum); in malo_getbuf()
784 sc->malo_stats.mst_tx_qstop++; in malo_getbuf()
799 error = bus_dmamap_load_mbuf_sg(sc->malo_dmat, bf->bf_dmamap, m0, in malo_tx_dmasetup()
800 bf->bf_segs, &bf->bf_nseg, in malo_tx_dmasetup()
804 bf->bf_nseg = MALO_TXDESC + 1; in malo_tx_dmasetup()
806 sc->malo_stats.mst_tx_busdma++; in malo_tx_dmasetup()
815 sc->malo_stats.mst_tx_linear++; in malo_tx_dmasetup()
819 sc->malo_stats.mst_tx_nombuf++; in malo_tx_dmasetup()
823 error = bus_dmamap_load_mbuf_sg(sc->malo_dmat, bf->bf_dmamap, m0, in malo_tx_dmasetup()
824 bf->bf_segs, &bf->bf_nseg, in malo_tx_dmasetup()
827 sc->malo_stats.mst_tx_busdma++; in malo_tx_dmasetup()
831 KASSERT(bf->bf_nseg <= MALO_TXDESC, in malo_tx_dmasetup()
832 ("too many segments after defrag; nseg %u", bf->bf_nseg)); in malo_tx_dmasetup()
833 } else if (bf->bf_nseg == 0) { /* null packet, discard */ in malo_tx_dmasetup()
834 sc->malo_stats.mst_tx_nodata++; in malo_tx_dmasetup()
839 __func__, m0, m0->m_pkthdr.len); in malo_tx_dmasetup()
840 bus_dmamap_sync(sc->malo_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE); in malo_tx_dmasetup()
841 bf->bf_m = m0; in malo_tx_dmasetup()
850 const struct malo_rxdesc *ds = bf->bf_desc; in malo_printrxbuf()
851 uint32_t status = le32toh(ds->status); in malo_printrxbuf()
855 " RATE:%02x QOS:%04x\n", ix, ds, (uintmax_t)bf->bf_daddr, in malo_printrxbuf()
856 le32toh(ds->physnext), le32toh(ds->physbuffdata), in malo_printrxbuf()
857 ds->rxcontrol, in malo_printrxbuf()
858 ds->rxcontrol != MALO_RXD_CTRL_DRIVER_OWN ? in malo_printrxbuf()
860 ds->status, le16toh(ds->pktlen), ds->snr, ds->nf, ds->channel, in malo_printrxbuf()
861 ds->rate, le16toh(ds->qosctrl)); in malo_printrxbuf()
867 const struct malo_txdesc *ds = bf->bf_desc; in malo_printtxbuf()
868 uint32_t status = le32toh(ds->status); in malo_printtxbuf()
871 printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr); in malo_printtxbuf()
873 le32toh(ds->physnext), in malo_printtxbuf()
874 le32toh(ds->pktptr), le16toh(ds->pktlen), status, in malo_printtxbuf()
878 ds->datarate, ds->txpriority, le16toh(ds->qosctrl), in malo_printtxbuf()
879 le32toh(ds->sap_pktinfo), le16toh(ds->format)); in malo_printtxbuf()
925 __func__, txq->qnum); in malo_tx_processq()
928 bf = STAILQ_FIRST(&txq->active); in malo_tx_processq()
933 ds = bf->bf_desc; in malo_tx_processq()
936 if (ds->status & htole32(MALO_TXD_STATUS_FW_OWNED)) { in malo_tx_processq()
940 STAILQ_REMOVE_HEAD(&txq->active, bf_list); in malo_tx_processq()
944 if (sc->malo_debug & MALO_DEBUG_XMIT_DESC) in malo_tx_processq()
945 malo_printtxbuf(bf, txq->qnum, nreaped); in malo_tx_processq()
947 ni = bf->bf_node; in malo_tx_processq()
949 status = le32toh(ds->status); in malo_tx_processq()
951 uint16_t format = le16toh(ds->format); in malo_tx_processq()
955 sc->malo_stats.mst_ant_tx[txant]++; in malo_tx_processq()
957 sc->malo_stats.mst_tx_retries++; in malo_tx_processq()
959 sc->malo_stats.mst_tx_mretries++; in malo_tx_processq()
960 malo_updatetxrate(ni, ds->datarate); in malo_tx_processq()
961 sc->malo_stats.mst_tx_rate = ds->datarate; in malo_tx_processq()
964 sc->malo_stats.mst_tx_linkerror++; in malo_tx_processq()
966 sc->malo_stats.mst_tx_xretries++; in malo_tx_processq()
968 sc->malo_stats.mst_tx_aging++; in malo_tx_processq()
971 m_adj(bf->bf_m, sizeof(uint16_t)); in malo_tx_processq()
972 ieee80211_tx_complete(ni, bf->bf_m, in malo_tx_processq()
975 m_freem(bf->bf_m); in malo_tx_processq()
977 ds->status = htole32(MALO_TXD_STATUS_IDLE); in malo_tx_processq()
978 ds->pktlen = htole32(0); in malo_tx_processq()
980 bus_dmamap_sync(sc->malo_dmat, bf->bf_dmamap, in malo_tx_processq()
982 bus_dmamap_unload(sc->malo_dmat, bf->bf_dmamap); in malo_tx_processq()
983 bf->bf_m = NULL; in malo_tx_processq()
984 bf->bf_node = NULL; in malo_tx_processq()
987 STAILQ_INSERT_TAIL(&txq->free, bf, bf_list); in malo_tx_processq()
988 txq->nfree++; in malo_tx_processq()
1009 if (!STAILQ_EMPTY(&sc->malo_txq[i].active)) in malo_tx_proc()
1010 nreaped += malo_tx_processq(sc, &sc->malo_txq[i]); in malo_tx_proc()
1014 sc->malo_timer = 0; in malo_tx_proc()
1027 struct ieee80211com *ic = &sc->malo_ic; in malo_tx_start()
1028 struct ieee80211vap *vap = ni->ni_vap; in malo_tx_start()
1035 iswep = wh->i_fc[1] & IEEE80211_FC1_PROTECTED; in malo_tx_start()
1037 pktlen = m0->m_pkthdr.len; in malo_tx_start()
1073 pktlen = m0->m_pkthdr.len; in malo_tx_start()
1080 sc->malo_tx_th.wt_flags = 0; /* XXX */ in malo_tx_start()
1082 sc->malo_tx_th.wt_flags |= IEEE80211_RADIOTAP_F_WEP; in malo_tx_start()
1083 sc->malo_tx_th.wt_txpower = ni->ni_txpower; in malo_tx_start()
1084 sc->malo_tx_th.wt_antenna = sc->malo_txantenna; in malo_tx_start()
1091 * we present a 2-byte payload length followed by a in malo_tx_start()
1092 * 4-address header (w/o QoS), followed (optionally) by in malo_tx_start()
1095 * prepend in-place by the setup of ic_headroom in in malo_tx_start()
1099 const int space = sizeof(struct malo_txrec) - hdrlen; in malo_tx_start()
1102 device_printf(sc->malo_dev, in malo_tx_start()
1105 space, M_LEADINGSPACE(m0), m0->m_flags, m0->m_len); in malo_tx_start()
1107 mtod(m0, const uint8_t *), m0->m_len, 0, -1); in malo_tx_start()
1115 if (wh != (struct ieee80211_frame *) &tr->wh) in malo_tx_start()
1116 ovbcopy(wh, &tr->wh, hdrlen); in malo_tx_start()
1123 tr->fwlen = htole16(pktlen - hdrlen); in malo_tx_start()
1132 bf->bf_node = ni; /* NB: held reference */ in malo_tx_start()
1133 m0 = bf->bf_m; /* NB: may have changed */ in malo_tx_start()
1135 wh = (struct ieee80211_frame *)&tr->wh; in malo_tx_start()
1140 ds = bf->bf_desc; in malo_tx_start()
1141 txq = bf->bf_txq; in malo_tx_start()
1143 ds->qosctrl = qos; /* NB: already little-endian */ in malo_tx_start()
1144 ds->pktptr = htole32(bf->bf_segs[0].ds_addr); in malo_tx_start()
1145 ds->pktlen = htole16(bf->bf_segs[0].ds_len); in malo_tx_start()
1147 ds->datarate = IEEE80211_IS_DATA(wh) ? 1 : 0; in malo_tx_start()
1148 ds->sap_pktinfo = 0; in malo_tx_start()
1149 ds->format = 0; in malo_tx_start()
1154 switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { in malo_tx_start()
1156 sc->malo_stats.mst_tx_mgmt++; in malo_tx_start()
1159 ds->txpriority = 1; in malo_tx_start()
1162 ds->txpriority = txq->qnum; in malo_tx_start()
1165 device_printf(sc->malo_dev, "bogus frame type 0x%x (%s)\n", in malo_tx_start()
1166 wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK, __func__); in malo_tx_start()
1176 m0->m_len - sizeof(uint16_t), ds->datarate, -1); in malo_tx_start()
1181 ds->status |= htole32(1); in malo_tx_start()
1182 ds->status |= htole32(MALO_TXD_STATUS_FW_OWNED); in malo_tx_start()
1183 STAILQ_INSERT_TAIL(&txq->active, bf, bf_list); in malo_tx_start()
1186 sc->malo_timer = 5; in malo_tx_start()
1194 struct malo_softc *sc = ic->ic_softc; in malo_transmit()
1198 if (!sc->malo_running) { in malo_transmit()
1202 error = mbufq_enqueue(&sc->malo_snd, m); in malo_transmit()
1216 struct malo_txq *txq = &sc->malo_txq[0]; in malo_start()
1223 if (!sc->malo_running || sc->malo_invalid) in malo_start()
1226 while ((m = mbufq_dequeue(&sc->malo_snd)) != NULL) { in malo_start()
1227 ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; in malo_start()
1230 mbufq_prepend(&sc->malo_snd, m); in malo_start()
1231 sc->malo_stats.mst_tx_qstop++; in malo_start()
1238 if_inc_counter(ni->ni_vap->iv_ifp, in malo_start()
1241 bf->bf_m = NULL; in malo_start()
1242 bf->bf_node = NULL; in malo_start()
1244 STAILQ_INSERT_HEAD(&txq->free, bf, bf_list); in malo_start()
1258 malo_hal_txstart(sc->malo_mh, 0/*XXX*/); in malo_start()
1276 malo_hal_txstart(sc->malo_mh, 0/*XXX*/); in malo_start()
1285 callout_reset(&sc->malo_watchdog_timer, hz, malo_watchdog, sc); in malo_watchdog()
1286 if (sc->malo_timer == 0 || --sc->malo_timer > 0) in malo_watchdog()
1289 if (sc->malo_running && !sc->malo_invalid) { in malo_watchdog()
1290 device_printf(sc->malo_dev, "watchdog timeout\n"); in malo_watchdog()
1294 counter_u64_add(sc->malo_ic.ic_oerrors, 1); in malo_watchdog()
1295 sc->malo_stats.mst_watchdog++; in malo_watchdog()
1303 struct ieee80211com *ic = &sc->malo_ic; in malo_hal_reset()
1304 struct malo_hal *mh = sc->malo_mh; in malo_hal_reset()
1309 * firmware could override rx/tx dma registers so we re-set in malo_hal_reset()
1316 malo_hal_setantenna(mh, MHA_ANTENNATYPE_RX, sc->malo_rxantenna); in malo_hal_reset()
1317 malo_hal_setantenna(mh, MHA_ANTENNATYPE_TX, sc->malo_txantenna); in malo_hal_reset()
1319 malo_chan_set(sc, ic->ic_curchan); in malo_hal_reset()
1336 sc->malo_stats.mst_rx_nombuf++; /* XXX */ in malo_getrxmbuf()
1339 error = bus_dmamap_load(sc->malo_dmat, bf->bf_dmamap, in malo_getrxmbuf()
1343 device_printf(sc->malo_dev, in malo_getrxmbuf()
1348 bf->bf_data = paddr; in malo_getrxmbuf()
1349 bus_dmamap_sync(sc->malo_dmat, bf->bf_dmamap, BUS_DMASYNC_PREWRITE); in malo_getrxmbuf()
1359 ds = bf->bf_desc; in malo_rxbuf_init()
1360 if (bf->bf_m == NULL) { in malo_rxbuf_init()
1361 bf->bf_m = malo_getrxmbuf(sc, bf); in malo_rxbuf_init()
1362 if (bf->bf_m == NULL) { in malo_rxbuf_init()
1364 ds->rxcontrol = MALO_RXD_CTRL_OS_OWN; in malo_rxbuf_init()
1374 ds->qosctrl = 0; in malo_rxbuf_init()
1375 ds->snr = 0; in malo_rxbuf_init()
1376 ds->status = MALO_RXD_STATUS_IDLE; in malo_rxbuf_init()
1377 ds->channel = 0; in malo_rxbuf_init()
1378 ds->pktlen = htole16(MALO_RXSIZE); in malo_rxbuf_init()
1379 ds->nf = 0; in malo_rxbuf_init()
1380 ds->physbuffdata = htole32(bf->bf_data); in malo_rxbuf_init()
1382 ds->rxcontrol = MALO_RXD_CTRL_DRIVER_OWN; in malo_rxbuf_init()
1398 if (sc->malo_recvsetup == 1) { in malo_startrecv()
1404 STAILQ_FOREACH(bf, &sc->malo_rxbuf, bf_list) { in malo_startrecv()
1413 ds = prev->bf_desc; in malo_startrecv()
1414 ds->physnext = htole32(bf->bf_daddr); in malo_startrecv()
1419 ds = prev->bf_desc; in malo_startrecv()
1420 ds->physnext = in malo_startrecv()
1421 htole32(STAILQ_FIRST(&sc->malo_rxbuf)->bf_daddr); in malo_startrecv()
1424 sc->malo_recvsetup = 1; in malo_startrecv()
1434 struct malo_hal *mh = sc->malo_mh; in malo_init_locked()
1449 device_printf(sc->malo_dev, in malo_init_locked()
1459 device_printf(sc->malo_dev, in malo_init_locked()
1468 sc->malo_imask = MALO_A2HRIC_BIT_RX_RDY in malo_init_locked()
1477 sc->malo_running = 1; in malo_init_locked()
1478 malo_hal_intrset(mh, sc->malo_imask); in malo_init_locked()
1479 callout_reset(&sc->malo_watchdog_timer, hz, malo_watchdog, sc); in malo_init_locked()
1486 struct ieee80211com *ic = &sc->malo_ic; in malo_init()
1492 if (sc->malo_running) in malo_init()
1506 if (ctx->nmc == MALO_HAL_MCAST_MAX) in malo_copy_maddr()
1509 IEEE80211_ADDR_COPY(ctx->macs + (ctx->nmc * IEEE80211_ADDR_LEN), in malo_copy_maddr()
1511 ctx->nmc++; in malo_copy_maddr()
1523 struct ieee80211com *ic = &sc->malo_ic; in malo_setmcastfilter()
1527 if (ic->ic_opmode == IEEE80211_M_MONITOR || ic->ic_allmulti > 0 || in malo_setmcastfilter()
1528 ic->ic_promisc > 0) in malo_setmcastfilter()
1532 TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) in malo_setmcastfilter()
1533 if_foreach_llmaddr(vap->iv_ifp, malo_copy_maddr, &ctx); in malo_setmcastfilter()
1535 malo_hal_setmcast(sc->malo_mh, ctx.nmc, ctx.macs); in malo_setmcastfilter()
1548 struct ieee80211com *ic = &sc->malo_ic; in malo_mode_init()
1549 struct malo_hal *mh = sc->malo_mh; in malo_mode_init()
1551 malo_hal_setpromisc(mh, ic->ic_promisc > 0); in malo_mode_init()
1570 bf = STAILQ_FIRST(&txq->active); in malo_tx_draintxq()
1575 STAILQ_REMOVE_HEAD(&txq->active, bf_list); in malo_tx_draintxq()
1578 if (sc->malo_debug & MALO_DEBUG_RESET) { in malo_tx_draintxq()
1579 struct ieee80211com *ic = &sc->malo_ic; in malo_tx_draintxq()
1581 mtod(bf->bf_m, const struct malo_txrec *); in malo_tx_draintxq()
1582 malo_printtxbuf(bf, txq->qnum, ix); in malo_tx_draintxq()
1583 ieee80211_dump_pkt(ic, (const uint8_t *)&tr->wh, in malo_tx_draintxq()
1584 bf->bf_m->m_len - sizeof(tr->fwlen), 0, -1); in malo_tx_draintxq()
1587 bus_dmamap_unload(sc->malo_dmat, bf->bf_dmamap); in malo_tx_draintxq()
1588 ni = bf->bf_node; in malo_tx_draintxq()
1589 bf->bf_node = NULL; in malo_tx_draintxq()
1596 m_freem(bf->bf_m); in malo_tx_draintxq()
1597 bf->bf_m = NULL; in malo_tx_draintxq()
1600 STAILQ_INSERT_TAIL(&txq->free, bf, bf_list); in malo_tx_draintxq()
1601 txq->nfree++; in malo_tx_draintxq()
1609 struct malo_hal *mh = sc->malo_mh; in malo_stop()
1613 __func__, sc->malo_invalid, sc->malo_running); in malo_stop()
1617 if (!sc->malo_running) in malo_stop()
1629 sc->malo_running = 0; in malo_stop()
1630 callout_stop(&sc->malo_watchdog_timer); in malo_stop()
1631 sc->malo_timer = 0; in malo_stop()
1639 malo_tx_draintxq(sc, &sc->malo_txq[i]); in malo_stop()
1645 struct malo_softc *sc = ic->ic_softc; in malo_parent()
1649 if (ic->ic_nrunning > 0) { in malo_parent()
1654 * However trying to re-init the interface in malo_parent()
1659 if (!sc->malo_running && !sc->malo_invalid) { in malo_parent()
1669 } else if (sc->malo_running) in malo_parent()
1680 * like slot time and preamble.
1685 struct malo_softc *sc = ic->ic_softc; in malo_updateslot()
1686 struct malo_hal *mh = sc->malo_mh; in malo_updateslot()
1689 /* NB: can be called early; suppress needless cmds */ in malo_updateslot()
1690 if (!sc->malo_running) in malo_updateslot()
1695 __func__, ic->ic_curchan->ic_freq, ic->ic_curchan->ic_flags, in malo_updateslot()
1696 ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long", ic->ic_flags); in malo_updateslot()
1698 if (ic->ic_flags & IEEE80211_F_SHSLOT) in malo_updateslot()
1704 device_printf(sc->malo_dev, "setting %s slot failed\n", in malo_updateslot()
1705 ic->ic_flags & IEEE80211_F_SHSLOT ? "short" : "long"); in malo_updateslot()
1711 struct ieee80211com *ic = vap->iv_ic; in malo_newstate()
1712 struct malo_softc *sc = ic->ic_softc; in malo_newstate()
1713 struct malo_hal *mh = sc->malo_mh; in malo_newstate()
1716 DPRINTF(sc, MALO_DEBUG_STATE, "%s: %s -> %s\n", __func__, in malo_newstate()
1717 ieee80211_state_name[vap->iv_state], in malo_newstate()
1723 error = MALO_VAP(vap)->malo_newstate(vap, nstate, arg); in malo_newstate()
1727 if (nstate == IEEE80211_S_RUN && vap->iv_state != IEEE80211_S_RUN) { in malo_newstate()
1728 struct ieee80211_node *ni = vap->iv_bss; in malo_newstate()
1729 enum ieee80211_phymode mode = ieee80211_chan2mode(ni->ni_chan); in malo_newstate()
1730 const struct ieee80211_txparam *tp = &vap->iv_txparms[mode]; in malo_newstate()
1735 if_name(vap->iv_ifp), __func__, vap->iv_flags, in malo_newstate()
1736 ni->ni_intval, ether_sprintf(ni->ni_bssid), ni->ni_capinfo, in malo_newstate()
1737 ieee80211_chan2ieee(ic, ic->ic_curchan), in malo_newstate()
1738 ni->ni_associd, mode, tp->ucastrate); in malo_newstate()
1741 (ic->ic_flags & IEEE80211_F_SHPREAMBLE) ? in malo_newstate()
1743 malo_hal_setassocid(sc->malo_mh, ni->ni_bssid, ni->ni_associd); in malo_newstate()
1745 tp->ucastrate == IEEE80211_FIXED_RATE_NONE ? in malo_newstate()
1746 0 : malo_fix2rate(tp->ucastrate)); in malo_newstate()
1755 struct ieee80211com *ic = ni->ni_ic; in malo_raw_xmit()
1756 struct malo_softc *sc = ic->ic_softc; in malo_raw_xmit()
1760 if (!sc->malo_running || sc->malo_invalid) { in malo_raw_xmit()
1769 * cannot just force that here because we may receive non-mgt frames. in malo_raw_xmit()
1771 txq = &sc->malo_txq[0]; in malo_raw_xmit()
1782 bf->bf_m = NULL; in malo_raw_xmit()
1783 bf->bf_node = NULL; in malo_raw_xmit()
1785 STAILQ_INSERT_HEAD(&txq->free, bf, bf_list); in malo_raw_xmit()
1786 txq->nfree++; in malo_raw_xmit()
1803 malo_hal_txstart(sc->malo_mh, 0/*XXX*/); in malo_raw_xmit()
1812 struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(sc->malo_dev); in malo_sysctlattach()
1813 struct sysctl_oid *tree = device_get_sysctl_tree(sc->malo_dev); in malo_sysctlattach()
1815 sc->malo_debug = malo_debug; in malo_sysctlattach()
1817 "debug", CTLFLAG_RW, &sc->malo_debug, 0, in malo_sysctlattach()
1826 device_printf(sc->malo_dev, in malo_announce()
1828 sc->malo_hwspecs.hwversion, in malo_announce()
1829 (sc->malo_hwspecs.fw_releasenum >> 24) & 0xff, in malo_announce()
1830 (sc->malo_hwspecs.fw_releasenum >> 16) & 0xff, in malo_announce()
1831 (sc->malo_hwspecs.fw_releasenum >> 8) & 0xff, in malo_announce()
1832 (sc->malo_hwspecs.fw_releasenum >> 0) & 0xff, in malo_announce()
1833 sc->malo_hwspecs.regioncode); in malo_announce()
1836 device_printf(sc->malo_dev, in malo_announce()
1839 device_printf(sc->malo_dev, in malo_announce()
1849 hc->channel = chan->ic_ieee; in malo_mapchan()
1851 *(uint32_t *)&hc->flags = 0; in malo_mapchan()
1853 hc->flags.freqband = MALO_FREQ_BAND_2DOT4GHZ; in malo_mapchan()
1865 struct malo_hal *mh = sc->malo_mh; in malo_chan_set()
1869 __func__, chan->ic_freq, chan->ic_flags); in malo_chan_set()
1883 sc->malo_tx_th.wt_chan_freq = htole16(chan->ic_freq); in malo_chan_set()
1884 sc->malo_rx_th.wr_chan_freq = htole16(chan->ic_freq); in malo_chan_set()
1886 sc->malo_tx_th.wt_chan_flags = htole16(IEEE80211_CHAN_G); in malo_chan_set()
1887 sc->malo_rx_th.wr_chan_flags = htole16(IEEE80211_CHAN_G); in malo_chan_set()
1889 sc->malo_tx_th.wt_chan_flags = htole16(IEEE80211_CHAN_B); in malo_chan_set()
1890 sc->malo_rx_th.wr_chan_flags = htole16(IEEE80211_CHAN_B); in malo_chan_set()
1892 sc->malo_curchan = hchan; in malo_chan_set()
1893 malo_hal_intrset(mh, sc->malo_imask); in malo_chan_set()
1901 struct malo_softc *sc = ic->ic_softc; in malo_scan_start()
1909 struct malo_softc *sc = ic->ic_softc; in malo_scan_end()
1917 struct malo_softc *sc = ic->ic_softc; in malo_set_channel()
1919 (void) malo_chan_set(sc, ic->ic_curchan); in malo_set_channel()
1926 struct ieee80211com *ic = &sc->malo_ic; in malo_rx_proc()
1939 sc->malo_hwspecs.rxdesc_read, in malo_rx_proc()
1940 malo_bar0_read4(sc, sc->malo_hwspecs.rxdesc_read), in malo_rx_proc()
1941 sc->malo_hwspecs.rxdesc_write, in malo_rx_proc()
1942 malo_bar0_read4(sc, sc->malo_hwspecs.rxdesc_write)); in malo_rx_proc()
1944 readptr = malo_bar0_read4(sc, sc->malo_hwspecs.rxdesc_read); in malo_rx_proc()
1945 writeptr = malo_bar0_read4(sc, sc->malo_hwspecs.rxdesc_write); in malo_rx_proc()
1949 bf = sc->malo_rxnext; in malo_rx_proc()
1950 for (ntodo = malo_rxquota; ntodo > 0 && readptr != writeptr; ntodo--) { in malo_rx_proc()
1952 bf = STAILQ_FIRST(&sc->malo_rxbuf); in malo_rx_proc()
1955 ds = bf->bf_desc; in malo_rx_proc()
1956 if (bf->bf_m == NULL) { in malo_rx_proc()
1959 * will be no buffer; try again to re-populate it. in malo_rx_proc()
1971 if (ds->rxcontrol != MALO_RXD_CTRL_DMA_OWN) in malo_rx_proc()
1974 readptr = le32toh(ds->physnext); in malo_rx_proc()
1977 if (sc->malo_debug & MALO_DEBUG_RECV_DESC) in malo_rx_proc()
1980 status = ds->status; in malo_rx_proc()
1982 counter_u64_add(ic->ic_ierrors, 1); in malo_rx_proc()
1988 len = le16toh(ds->pktlen); in malo_rx_proc()
1989 bus_dmamap_sync(sc->malo_dmat, bf->bf_dmamap, in malo_rx_proc()
1997 m = bf->bf_m; in malo_rx_proc()
2005 rssi = 2 * ((int) ds->snr - ds->nf); /* NB: .5 dBm */ in malo_rx_proc()
2009 pktlen = hdrlen + (len - off); in malo_rx_proc()
2012 * IEEE80211_MIN_LEN because there is a 4-address frame at in malo_rx_proc()
2021 counter_u64_add(ic->ic_ierrors, 1); in malo_rx_proc()
2026 * re-setup the rx descriptor using the replacement dma in malo_rx_proc()
2029 bf->bf_m = mnew; in malo_rx_proc()
2030 m->m_data += off - hdrlen; in malo_rx_proc()
2031 m->m_pkthdr.len = m->m_len = pktlen; in malo_rx_proc()
2041 *(uint16_t *)ieee80211_getqos(wh) = ds->qosctrl; in malo_rx_proc()
2043 sc->malo_rx_th.wr_flags = 0; in malo_rx_proc()
2044 sc->malo_rx_th.wr_rate = ds->rate; in malo_rx_proc()
2045 sc->malo_rx_th.wr_antsignal = rssi; in malo_rx_proc()
2046 sc->malo_rx_th.wr_antnoise = ds->nf; in malo_rx_proc()
2051 len, ds->rate, rssi); in malo_rx_proc()
2058 (void) ieee80211_input(ni, m, rssi, ds->nf); in malo_rx_proc()
2061 (void) ieee80211_input_all(ic, m, rssi, ds->nf); in malo_rx_proc()
2068 malo_bar0_write4(sc, sc->malo_hwspecs.rxdesc_read, readptr); in malo_rx_proc()
2069 sc->malo_rxnext = bf; in malo_rx_proc()
2071 if (mbufq_first(&sc->malo_snd) != NULL) in malo_rx_proc()
2084 malo_tx_cleanupq(sc, &sc->malo_txq[i]); in malo_tx_cleanup()
2090 struct ieee80211com *ic = &sc->malo_ic; in malo_detach()
2094 if (sc->malo_tq != NULL) { in malo_detach()
2095 taskqueue_drain(sc->malo_tq, &sc->malo_rxtask); in malo_detach()
2096 taskqueue_drain(sc->malo_tq, &sc->malo_txtask); in malo_detach()
2097 taskqueue_free(sc->malo_tq); in malo_detach()
2098 sc->malo_tq = NULL; in malo_detach()
2114 callout_drain(&sc->malo_watchdog_timer); in malo_detach()
2117 malo_hal_detach(sc->malo_mh); in malo_detach()
2118 mbufq_drain(&sc->malo_snd); in malo_detach()
2142 if (sc->malo_ic.ic_nrunning > 0) in malo_resume()