Deleted Added
full compact
if_ath.c (248986) if_ath.c (248988)
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 248986 2013-04-01 20:44:21Z adrian $");
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 248988 2013-04-01 20:57:13Z adrian $");
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39

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

2507 * The descriptor is also copied but the link pointers and
2508 * the DMA segments aren't copied; this frame should thus
2509 * be again passed through the descriptor setup/chain routines
2510 * so the link is correct.
2511 *
2512 * The caller must free the buffer using ath_freebuf().
2513 */
2514struct ath_buf *
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39

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

2507 * The descriptor is also copied but the link pointers and
2508 * the DMA segments aren't copied; this frame should thus
2509 * be again passed through the descriptor setup/chain routines
2510 * so the link is correct.
2511 *
2512 * The caller must free the buffer using ath_freebuf().
2513 */
2514struct ath_buf *
2515ath_buf_clone(struct ath_softc *sc, const struct ath_buf *bf)
2515ath_buf_clone(struct ath_softc *sc, struct ath_buf *bf)
2516{
2517 struct ath_buf *tbf;
2518
2519 tbf = ath_getbuf(sc,
2520 (bf->bf_flags & ATH_BUF_MGMT) ?
2521 ATH_BUFTYPE_MGMT : ATH_BUFTYPE_NORMAL);
2522 if (tbf == NULL)
2523 return NULL; /* XXX failure? Why? */
2524
2525 /* Copy basics */
2526 tbf->bf_next = NULL;
2527 tbf->bf_nseg = bf->bf_nseg;
2528 tbf->bf_flags = bf->bf_flags & ATH_BUF_FLAGS_CLONE;
2529 tbf->bf_status = bf->bf_status;
2530 tbf->bf_m = bf->bf_m;
2516{
2517 struct ath_buf *tbf;
2518
2519 tbf = ath_getbuf(sc,
2520 (bf->bf_flags & ATH_BUF_MGMT) ?
2521 ATH_BUFTYPE_MGMT : ATH_BUFTYPE_NORMAL);
2522 if (tbf == NULL)
2523 return NULL; /* XXX failure? Why? */
2524
2525 /* Copy basics */
2526 tbf->bf_next = NULL;
2527 tbf->bf_nseg = bf->bf_nseg;
2528 tbf->bf_flags = bf->bf_flags & ATH_BUF_FLAGS_CLONE;
2529 tbf->bf_status = bf->bf_status;
2530 tbf->bf_m = bf->bf_m;
2531 /*
2532 * XXX Copy the node reference, the caller is responsible
2533 * for deleting the node reference before it frees its
2534 * buffer.
2535 *
2536 * XXX It's done like this so we don't call the net80211
2537 * code whilst having active TX queue locks held.
2538 */
2539 tbf->bf_node = bf->bf_node;
2540 /* will be setup by the chain/setup function */
2541 tbf->bf_lastds = NULL;
2542 /* for now, last == self */
2543 tbf->bf_last = tbf;
2544 tbf->bf_comp = bf->bf_comp;
2545
2546 /* NOTE: DMA segments will be setup by the setup/chain functions */
2547
2548 /* The caller has to re-init the descriptor + links */
2549
2531 tbf->bf_node = bf->bf_node;
2532 /* will be setup by the chain/setup function */
2533 tbf->bf_lastds = NULL;
2534 /* for now, last == self */
2535 tbf->bf_last = tbf;
2536 tbf->bf_comp = bf->bf_comp;
2537
2538 /* NOTE: DMA segments will be setup by the setup/chain functions */
2539
2540 /* The caller has to re-init the descriptor + links */
2541
2542 /*
2543 * Free the DMA mapping here, before we NULL the mbuf.
2544 * We must only call bus_dmamap_unload() once per mbuf chain
2545 * or behaviour is undefined.
2546 */
2547 if (bf->bf_m != NULL) {
2548 /*
2549 * XXX is this POSTWRITE call required?
2550 */
2551 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
2552 BUS_DMASYNC_POSTWRITE);
2553 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
2554 }
2555
2556 bf->bf_m = NULL;
2557 bf->bf_node = NULL;
2558
2550 /* Copy state */
2551 memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state));
2552
2553 return tbf;
2554}
2555
2556struct ath_buf *
2557ath_getbuf(struct ath_softc *sc, ath_buf_type_t btype)

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

4215 * buffer on the list is now not involved in a halted TX DMA queue, waiting
4216 * for restart (eg for TDMA.)
4217 *
4218 * The caller must free the mbuf and recycle the node reference.
4219 */
4220void
4221ath_freebuf(struct ath_softc *sc, struct ath_buf *bf)
4222{
2559 /* Copy state */
2560 memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state));
2561
2562 return tbf;
2563}
2564
2565struct ath_buf *
2566ath_getbuf(struct ath_softc *sc, ath_buf_type_t btype)

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

4224 * buffer on the list is now not involved in a halted TX DMA queue, waiting
4225 * for restart (eg for TDMA.)
4226 *
4227 * The caller must free the mbuf and recycle the node reference.
4228 */
4229void
4230ath_freebuf(struct ath_softc *sc, struct ath_buf *bf)
4231{
4223 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
4224 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_POSTWRITE);
4225
4226 KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__));
4227 KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__));
4228
4229 /*
4230 * If this buffer is busy, push it onto the holding queue
4231 */
4232 if (bf->bf_flags & ATH_BUF_BUSY) {
4233 ATH_TXBUF_LOCK(sc);

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

4251 * It recycles a single ath_buf.
4252 */
4253void
4254ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status)
4255{
4256 struct ieee80211_node *ni = bf->bf_node;
4257 struct mbuf *m0 = bf->bf_m;
4258
4232 KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__));
4233 KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__));
4234
4235 /*
4236 * If this buffer is busy, push it onto the holding queue
4237 */
4238 if (bf->bf_flags & ATH_BUF_BUSY) {
4239 ATH_TXBUF_LOCK(sc);

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

4257 * It recycles a single ath_buf.
4258 */
4259void
4260ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status)
4261{
4262 struct ieee80211_node *ni = bf->bf_node;
4263 struct mbuf *m0 = bf->bf_m;
4264
4265 /*
4266 * Make sure that we only sync/unload if there's an mbuf.
4267 * If not (eg we cloned a buffer), the unload will have already
4268 * occured.
4269 */
4270 if (bf->bf_m != NULL) {
4271 bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap,
4272 BUS_DMASYNC_POSTWRITE);
4273 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
4274 }
4275
4259 bf->bf_node = NULL;
4260 bf->bf_m = NULL;
4261
4262 /* Free the buffer, it's not needed any longer */
4263 ath_freebuf(sc, bf);
4264
4265 if (ni != NULL) {
4266 /*
4267 * Do any callback and reclaim the node reference.
4268 */
4269 if (m0->m_flags & M_TXCB)
4270 ieee80211_process_callback(ni, m0, status);
4271 ieee80211_free_node(ni);
4272 }
4276 bf->bf_node = NULL;
4277 bf->bf_m = NULL;
4278
4279 /* Free the buffer, it's not needed any longer */
4280 ath_freebuf(sc, bf);
4281
4282 if (ni != NULL) {
4283 /*
4284 * Do any callback and reclaim the node reference.
4285 */
4286 if (m0->m_flags & M_TXCB)
4287 ieee80211_process_callback(ni, m0, status);
4288 ieee80211_free_node(ni);
4289 }
4273 m_freem(m0);
4274
4290
4275 /*
4276 * XXX the buffer used to be freed -after-, but the DMA map was
4277 * freed where ath_freebuf() now is. I've no idea what this
4278 * will do.
4279 */
4291 /* Finally, we don't need this mbuf any longer */
4292 m_freem(m0);
4280}
4281
4282static struct ath_buf *
4283ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq)
4284{
4285 struct ath_buf *bf;
4286
4287 ATH_TXQ_LOCK_ASSERT(txq);

--- 1653 unchanged lines hidden ---
4293}
4294
4295static struct ath_buf *
4296ath_tx_draintxq_get_one(struct ath_softc *sc, struct ath_txq *txq)
4297{
4298 struct ath_buf *bf;
4299
4300 ATH_TXQ_LOCK_ASSERT(txq);

--- 1653 unchanged lines hidden ---