Lines 384-389
Link Here
|
384 |
} |
384 |
} |
385 |
|
385 |
|
386 |
WPI_LOCK_INIT(sc); |
386 |
WPI_LOCK_INIT(sc); |
|
|
387 |
WPI_TXQ_LOCK_INIT(sc); |
387 |
|
388 |
|
388 |
/* Allocate DMA memory for firmware transfers. */ |
389 |
/* Allocate DMA memory for firmware transfers. */ |
389 |
if ((error = wpi_alloc_fwmem(sc)) != 0) { |
390 |
if ((error = wpi_alloc_fwmem(sc)) != 0) { |
Lines 679-684
Link Here
|
679 |
if_free(ifp); |
680 |
if_free(ifp); |
680 |
|
681 |
|
681 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
682 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
|
|
683 |
WPI_TXQ_LOCK_DESTROY(sc); |
682 |
WPI_LOCK_DESTROY(sc); |
684 |
WPI_LOCK_DESTROY(sc); |
683 |
return 0; |
685 |
return 0; |
684 |
} |
686 |
} |
Lines 2151-2156
Link Here
|
2151 |
sc->rxq.update = 0; |
2153 |
sc->rxq.update = 0; |
2152 |
wpi_update_rx_ring(sc); |
2154 |
wpi_update_rx_ring(sc); |
2153 |
} |
2155 |
} |
|
|
2156 |
WPI_TXQ_LOCK(sc); |
2154 |
for (qid = 0; qid < WPI_DRV_NTXQUEUES; qid++) { |
2157 |
for (qid = 0; qid < WPI_DRV_NTXQUEUES; qid++) { |
2155 |
struct wpi_tx_ring *ring = &sc->txq[qid]; |
2158 |
struct wpi_tx_ring *ring = &sc->txq[qid]; |
2156 |
|
2159 |
|
Lines 2159-2164
Link Here
|
2159 |
wpi_update_tx_ring(sc, ring); |
2162 |
wpi_update_tx_ring(sc, ring); |
2160 |
} |
2163 |
} |
2161 |
} |
2164 |
} |
|
|
2165 |
WPI_TXQ_UNLOCK(sc); |
2162 |
|
2166 |
|
2163 |
WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ); |
2167 |
WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ); |
2164 |
} |
2168 |
} |
Lines 2220-2230
Link Here
|
2220 |
wpi_nic_unlock(sc); |
2224 |
wpi_nic_unlock(sc); |
2221 |
/* Dump driver status (TX and RX rings) while we're here. */ |
2225 |
/* Dump driver status (TX and RX rings) while we're here. */ |
2222 |
printf("driver status:\n"); |
2226 |
printf("driver status:\n"); |
|
|
2227 |
WPI_TXQ_LOCK(sc); |
2223 |
for (i = 0; i < WPI_DRV_NTXQUEUES; i++) { |
2228 |
for (i = 0; i < WPI_DRV_NTXQUEUES; i++) { |
2224 |
struct wpi_tx_ring *ring = &sc->txq[i]; |
2229 |
struct wpi_tx_ring *ring = &sc->txq[i]; |
2225 |
printf(" tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n", |
2230 |
printf(" tx ring %2d: qid=%-2d cur=%-3d queued=%-3d\n", |
2226 |
i, ring->qid, ring->cur, ring->queued); |
2231 |
i, ring->qid, ring->cur, ring->queued); |
2227 |
} |
2232 |
} |
|
|
2233 |
WPI_TXQ_UNLOCK(sc); |
2228 |
printf(" rx ring: cur=%d\n", sc->rxq.cur); |
2234 |
printf(" rx ring: cur=%d\n", sc->rxq.cur); |
2229 |
} |
2235 |
} |
2230 |
|
2236 |
|
Lines 2302-2309
Link Here
|
2302 |
|
2308 |
|
2303 |
WPI_LOCK_ASSERT(sc); |
2309 |
WPI_LOCK_ASSERT(sc); |
2304 |
|
2310 |
|
|
|
2311 |
WPI_TXQ_LOCK(sc); |
2312 |
|
2305 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); |
2313 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); |
2306 |
|
2314 |
|
|
|
2315 |
if (sc->txq_active == 0) { |
2316 |
/* wpi_stop() was called */ |
2317 |
error = ENETDOWN; |
2318 |
goto fail; |
2319 |
} |
2320 |
|
2307 |
wh = mtod(buf->m, struct ieee80211_frame *); |
2321 |
wh = mtod(buf->m, struct ieee80211_frame *); |
2308 |
hdrlen = ieee80211_anyhdrsize(wh); |
2322 |
hdrlen = ieee80211_anyhdrsize(wh); |
2309 |
totlen = buf->m->m_pkthdr.len; |
2323 |
totlen = buf->m->m_pkthdr.len; |
Lines 2336-2343
Link Here
|
2336 |
if (error != 0 && error != EFBIG) { |
2350 |
if (error != 0 && error != EFBIG) { |
2337 |
device_printf(sc->sc_dev, |
2351 |
device_printf(sc->sc_dev, |
2338 |
"%s: can't map mbuf (error %d)\n", __func__, error); |
2352 |
"%s: can't map mbuf (error %d)\n", __func__, error); |
2339 |
m_freem(buf->m); |
2353 |
goto fail; |
2340 |
return error; |
|
|
2341 |
} |
2354 |
} |
2342 |
if (error != 0) { |
2355 |
if (error != 0) { |
2343 |
/* Too many DMA segments, linearize mbuf. */ |
2356 |
/* Too many DMA segments, linearize mbuf. */ |
Lines 2345-2352
Link Here
|
2345 |
if (m1 == NULL) { |
2358 |
if (m1 == NULL) { |
2346 |
device_printf(sc->sc_dev, |
2359 |
device_printf(sc->sc_dev, |
2347 |
"%s: could not defrag mbuf\n", __func__); |
2360 |
"%s: could not defrag mbuf\n", __func__); |
2348 |
m_freem(buf->m); |
2361 |
error = ENOBUFS; |
2349 |
return ENOBUFS; |
2362 |
goto fail; |
2350 |
} |
2363 |
} |
2351 |
buf->m = m1; |
2364 |
buf->m = m1; |
2352 |
|
2365 |
|
Lines 2356-2363
Link Here
|
2356 |
device_printf(sc->sc_dev, |
2369 |
device_printf(sc->sc_dev, |
2357 |
"%s: can't map mbuf (error %d)\n", __func__, |
2370 |
"%s: can't map mbuf (error %d)\n", __func__, |
2358 |
error); |
2371 |
error); |
2359 |
m_freem(buf->m); |
2372 |
goto fail; |
2360 |
return error; |
|
|
2361 |
} |
2373 |
} |
2362 |
} |
2374 |
} |
2363 |
|
2375 |
|
Lines 2400-2406
Link Here
|
2400 |
|
2412 |
|
2401 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
2413 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
2402 |
|
2414 |
|
|
|
2415 |
WPI_TXQ_UNLOCK(sc); |
2416 |
|
2403 |
return 0; |
2417 |
return 0; |
|
|
2418 |
|
2419 |
fail: m_freem(buf->m); |
2420 |
|
2421 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__); |
2422 |
|
2423 |
WPI_TXQ_UNLOCK(sc); |
2424 |
|
2425 |
return error; |
2404 |
} |
2426 |
} |
2405 |
|
2427 |
|
2406 |
/* |
2428 |
/* |
Lines 2867-2874
Link Here
|
2867 |
bus_addr_t paddr; |
2889 |
bus_addr_t paddr; |
2868 |
int totlen, error; |
2890 |
int totlen, error; |
2869 |
|
2891 |
|
|
|
2892 |
WPI_TXQ_LOCK(sc); |
2893 |
|
2870 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); |
2894 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); |
2871 |
|
2895 |
|
|
|
2896 |
if (sc->txq_active == 0) { |
2897 |
/* wpi_stop() was called */ |
2898 |
error = 0; |
2899 |
goto fail; |
2900 |
} |
2901 |
|
2872 |
if (async == 0) |
2902 |
if (async == 0) |
2873 |
WPI_LOCK_ASSERT(sc); |
2903 |
WPI_LOCK_ASSERT(sc); |
2874 |
|
2904 |
|
Lines 2888-2904
Link Here
|
2888 |
|
2918 |
|
2889 |
if (size > sizeof cmd->data) { |
2919 |
if (size > sizeof cmd->data) { |
2890 |
/* Command is too large to fit in a descriptor. */ |
2920 |
/* Command is too large to fit in a descriptor. */ |
2891 |
if (totlen > MCLBYTES) |
2921 |
if (totlen > MCLBYTES) { |
2892 |
return EINVAL; |
2922 |
error = EINVAL; |
|
|
2923 |
goto fail; |
2924 |
} |
2893 |
m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE); |
2925 |
m = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUMPAGESIZE); |
2894 |
if (m == NULL) |
2926 |
if (m == NULL) { |
2895 |
return ENOMEM; |
2927 |
error = ENOMEM; |
|
|
2928 |
goto fail; |
2929 |
} |
2896 |
cmd = mtod(m, struct wpi_tx_cmd *); |
2930 |
cmd = mtod(m, struct wpi_tx_cmd *); |
2897 |
error = bus_dmamap_load(ring->data_dmat, data->map, cmd, |
2931 |
error = bus_dmamap_load(ring->data_dmat, data->map, cmd, |
2898 |
totlen, wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); |
2932 |
totlen, wpi_dma_map_addr, &paddr, BUS_DMA_NOWAIT); |
2899 |
if (error != 0) { |
2933 |
if (error != 0) { |
2900 |
m_freem(m); |
2934 |
m_freem(m); |
2901 |
return error; |
2935 |
goto fail; |
2902 |
} |
2936 |
} |
2903 |
data->m = m; |
2937 |
data->m = m; |
2904 |
} else { |
2938 |
} else { |
Lines 2932-2937
Link Here
|
2932 |
|
2966 |
|
2933 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
2967 |
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); |
2934 |
|
2968 |
|
|
|
2969 |
WPI_TXQ_UNLOCK(sc); |
2970 |
|
2935 |
if (async) { |
2971 |
if (async) { |
2936 |
sc->flags &= ~WPI_FLAG_BUSY; |
2972 |
sc->flags &= ~WPI_FLAG_BUSY; |
2937 |
return 0; |
2973 |
return 0; |
Lines 2938-2943
Link Here
|
2938 |
} |
2974 |
} |
2939 |
|
2975 |
|
2940 |
return mtx_sleep(cmd, &sc->sc_mtx, PCATCH, "wpicmd", hz); |
2976 |
return mtx_sleep(cmd, &sc->sc_mtx, PCATCH, "wpicmd", hz); |
|
|
2977 |
|
2978 |
fail: DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__); |
2979 |
|
2980 |
WPI_TXQ_UNLOCK(sc); |
2981 |
|
2982 |
return error; |
2941 |
} |
2983 |
} |
2942 |
|
2984 |
|
2943 |
/* |
2985 |
/* |
Lines 4817-4822
Link Here
|
4817 |
} |
4859 |
} |
4818 |
|
4860 |
|
4819 |
/* Configure adapter now that it is ready. */ |
4861 |
/* Configure adapter now that it is ready. */ |
|
|
4862 |
sc->txq_active = 1; |
4820 |
if ((error = wpi_config(sc)) != 0) { |
4863 |
if ((error = wpi_config(sc)) != 0) { |
4821 |
device_printf(sc->sc_dev, |
4864 |
device_printf(sc->sc_dev, |
4822 |
"%s: could not configure device, error %d\n", __func__, |
4865 |
"%s: could not configure device, error %d\n", __func__, |
Lines 4859-4864
Link Here
|
4859 |
|
4902 |
|
4860 |
WPI_LOCK_ASSERT(sc); |
4903 |
WPI_LOCK_ASSERT(sc); |
4861 |
|
4904 |
|
|
|
4905 |
WPI_TXQ_LOCK(sc); |
4906 |
sc->txq_active = 0; |
4907 |
WPI_TXQ_UNLOCK(sc); |
4908 |
|
4862 |
sc->sc_scan_timer = 0; |
4909 |
sc->sc_scan_timer = 0; |
4863 |
sc->sc_tx_timer = 0; |
4910 |
sc->sc_tx_timer = 0; |
4864 |
callout_stop(&sc->watchdog_to); |
4911 |
callout_stop(&sc->watchdog_to); |