iPXE
Macros | Enumerations | Functions
ath9k_xmit.c File Reference
#include <ipxe/io.h>
#include "ath9k.h"
#include "ar9003_mac.h"

Go to the source code of this file.

Macros

#define BITS_PER_BYTE   8
 
#define OFDM_PLCP_BITS   22
 
#define HT_RC_2_STREAMS(_rc)   ((((_rc) & 0x78) >> 3) + 1)
 
#define L_STF   8
 
#define L_LTF   8
 
#define L_SIG   4
 
#define HT_SIG   8
 
#define HT_STF   4
 
#define HT_LTF(_ns)   (4 * (_ns))
 
#define SYMBOL_TIME(_ns)   ((_ns) << 2) /* ns * 4 us */
 
#define SYMBOL_TIME_HALFGI(_ns)   (((_ns) * 18 + 4) / 5) /* ns * 3.6 us */
 
#define NUM_SYMBOLS_PER_USEC(_usec)   (_usec >> 2)
 
#define NUM_SYMBOLS_PER_USEC_HALFGI(_usec)   (((_usec*5)-4)/18)
 
#define IS_HT_RATE(_rate)   ((_rate) & 0x80)
 

Enumerations

enum  { MCS_HT20, MCS_HT20_SGI, MCS_HT40, MCS_HT40_SGI }
 

Functions

static void ath_tx_send_normal (struct ath_softc *sc, struct ath_txq *txq, struct ath_atx_tid *tid, struct list_head *bf_head)
 
static void ath_tx_complete_buf (struct ath_softc *sc, struct ath_buf *bf, struct ath_txq *txq, struct list_head *bf_q, struct ath_tx_status *ts, int txok, int sendbar)
 
static void ath_tx_txqaddbuf (struct ath_softc *sc, struct ath_txq *txq, struct list_head *head)
 
static void ath_buf_set_rate (struct ath_softc *sc, struct ath_buf *bf, int len)
 
static void ath_tx_queue_tid (struct ath_txq *txq, struct ath_atx_tid *tid)
 
static struct ath_bufath_tx_get_buffer (struct ath_softc *sc)
 
static void ath_tx_return_buffer (struct ath_softc *sc, struct ath_buf *bf)
 
struct ath_txqath_txq_setup (struct ath_softc *sc, int qtype, int subtype)
 
void ath_draintxq (struct ath_softc *sc, struct ath_txq *txq, int retry_tx __unused)
 
int ath_drain_all_txq (struct ath_softc *sc, int retry_tx)
 
void ath_tx_cleanupq (struct ath_softc *sc, struct ath_txq *txq)
 
void ath_txq_schedule (struct ath_softc *sc __unused, struct ath_txq *txq)
 
static enum ath9k_pkt_type get_hw_packet_type (struct io_buffer *iob)
 
static int setup_tx_flags (struct io_buffer *iob __unused)
 
u8 ath_txchainmask_reduction (struct ath_softc *sc, u8 chainmask, u32 rate)
 
static struct ath_bufath_tx_setup_buffer (struct net80211_device *dev, struct ath_txq *txq, struct io_buffer *iob)
 
static void ath_tx_start_dma (struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_control *txctl)
 
int ath_tx_start (struct net80211_device *dev, struct io_buffer *iob, struct ath_tx_control *txctl)
 
static void ath_tx_complete (struct ath_softc *sc, struct io_buffer *iob, int tx_flags __unused, struct ath_tx_status *ts, struct ath_txq *txq)
 
static void ath_tx_processq (struct ath_softc *sc, struct ath_txq *txq)
 
static void ath_tx_complete_poll_work (struct ath_softc *sc)
 
void ath_tx_tasklet (struct ath_softc *sc)
 
int ath_tx_init (struct ath_softc *sc, int nbufs)
 
void ath_tx_cleanup (struct ath_softc *sc)
 

Macro Definition Documentation

◆ BITS_PER_BYTE

#define BITS_PER_BYTE   8

Definition at line 25 of file ath9k_xmit.c.

◆ OFDM_PLCP_BITS

#define OFDM_PLCP_BITS   22

Definition at line 26 of file ath9k_xmit.c.

◆ HT_RC_2_STREAMS

#define HT_RC_2_STREAMS (   _rc)    ((((_rc) & 0x78) >> 3) + 1)

Definition at line 27 of file ath9k_xmit.c.

◆ L_STF

#define L_STF   8

Definition at line 28 of file ath9k_xmit.c.

◆ L_LTF

#define L_LTF   8

Definition at line 29 of file ath9k_xmit.c.

◆ L_SIG

#define L_SIG   4

Definition at line 30 of file ath9k_xmit.c.

◆ HT_SIG

#define HT_SIG   8

Definition at line 31 of file ath9k_xmit.c.

◆ HT_STF

#define HT_STF   4

Definition at line 32 of file ath9k_xmit.c.

◆ HT_LTF

#define HT_LTF (   _ns)    (4 * (_ns))

Definition at line 33 of file ath9k_xmit.c.

◆ SYMBOL_TIME

#define SYMBOL_TIME (   _ns)    ((_ns) << 2) /* ns * 4 us */

Definition at line 34 of file ath9k_xmit.c.

◆ SYMBOL_TIME_HALFGI

#define SYMBOL_TIME_HALFGI (   _ns)    (((_ns) * 18 + 4) / 5) /* ns * 3.6 us */

Definition at line 35 of file ath9k_xmit.c.

◆ NUM_SYMBOLS_PER_USEC

#define NUM_SYMBOLS_PER_USEC (   _usec)    (_usec >> 2)

Definition at line 36 of file ath9k_xmit.c.

◆ NUM_SYMBOLS_PER_USEC_HALFGI

#define NUM_SYMBOLS_PER_USEC_HALFGI (   _usec)    (((_usec*5)-4)/18)

Definition at line 37 of file ath9k_xmit.c.

◆ IS_HT_RATE

#define IS_HT_RATE (   _rate)    ((_rate) & 0x80)

Definition at line 40 of file ath9k_xmit.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MCS_HT20 
MCS_HT20_SGI 
MCS_HT40 
MCS_HT40_SGI 

Definition at line 52 of file ath9k_xmit.c.

52  {
53  MCS_HT20,
55  MCS_HT40,
57 };

Function Documentation

◆ ath_tx_send_normal()

static void ath_tx_send_normal ( struct ath_softc sc,
struct ath_txq txq,
struct ath_atx_tid tid,
struct list_head bf_head 
)
static

Definition at line 363 of file ath9k_xmit.c.

366 {
367  struct ath_buf *bf;
368 
369  bf = list_first_entry(bf_head, struct ath_buf, list);
370  bf->bf_state.bf_type &= ~BUF_AMPDU;
371 
372  /* update starting sequence number for subsequent ADDBA request */
373  if (tid)
374  INCR(tid->seq_start, IEEE80211_SEQ_MAX);
375 
376  bf->bf_lastbf = bf;
377  ath_buf_set_rate(sc, bf, iob_len(bf->bf_mpdu) + FCS_LEN);
378  ath_tx_txqaddbuf(sc, txq, bf_head);
379 }
struct io_buffer * bf_mpdu
Definition: ath9k.h:224
struct ath_buf_state bf_state
Definition: ath9k.h:230
static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, int len)
Definition: ath9k_xmit.c:421
#define INCR(_l, _sz)
Definition: ath9k.h:46
struct ib_mad_tid tid
Definition: ib_mad.h:17
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define FCS_LEN
Definition: ath5k_desc.c:36
static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq, struct list_head *head)
Definition: ath9k_xmit.c:323
Definition: ath9k.h:219
u8 bf_type
Definition: ath9k.h:214
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
struct ath_buf * bf_lastbf
Definition: ath9k.h:221
struct list_head list
Definition: ath9k.h:220
#define IEEE80211_SEQ_MAX
Definition: ath9k.h:144

References ath_buf_set_rate(), ath_tx_txqaddbuf(), ath_buf::bf_lastbf, ath_buf::bf_mpdu, ath_buf::bf_state, ath_buf_state::bf_type, BUF_AMPDU, FCS_LEN, IEEE80211_SEQ_MAX, INCR, iob_len(), ath_buf::list, list_first_entry, and tid.

Referenced by ath_tx_start_dma().

◆ ath_tx_complete_buf()

static void ath_tx_complete_buf ( struct ath_softc sc,
struct ath_buf bf,
struct ath_txq txq,
struct list_head bf_q,
struct ath_tx_status ts,
int  txok,
int  sendbar 
)
static

Definition at line 623 of file ath9k_xmit.c.

626 {
627  struct io_buffer *iob = bf->bf_mpdu;
628  int tx_flags = 0;
629 
630  if (sendbar)
631  tx_flags = ATH_TX_BAR;
632 
633  if (!txok) {
634  tx_flags |= ATH_TX_ERROR;
635 
636  if (bf_isxretried(bf))
637  tx_flags |= ATH_TX_XRETRY;
638  }
639 
640  bf->bf_buf_addr = 0;
641 
642  ath_tx_complete(sc, iob, tx_flags,
643  ts, txq);
644 
645  /* At this point, iob (bf->bf_mpdu) is consumed...make sure we don't
646  * accidentally reference it later.
647  */
648  bf->bf_mpdu = NULL;
649 
650  /*
651  * Return the list of ath_buf of this mpdu to free queue
652  */
653  list_splice_tail_init(bf_q, &sc->tx.txbuf);
654 }
struct io_buffer * bf_mpdu
Definition: ath9k.h:224
#define bf_isxretried(bf)
Definition: ath9k.h:101
#define ATH_TX_XRETRY
Definition: ath9k.h:273
static void ath_tx_complete(struct ath_softc *sc, struct io_buffer *iob, int tx_flags __unused, struct ath_tx_status *ts, struct ath_txq *txq)
Definition: ath9k_xmit.c:601
u32 bf_buf_addr
Definition: ath9k.h:227
#define list_splice_tail_init(list, entry)
Move all entries from one list into another list and reinitialise empty list.
Definition: list.h:299
struct ath_tx tx
Definition: ath9k.h:476
struct list_head txbuf
Definition: ath9k.h:284
#define ATH_TX_BAR
Definition: ath9k.h:274
#define ATH_TX_ERROR
Definition: ath9k.h:272
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A persistent I/O buffer.
Definition: iobuf.h:33

References ATH_TX_BAR, ath_tx_complete(), ATH_TX_ERROR, ATH_TX_XRETRY, ath_buf::bf_buf_addr, bf_isxretried, ath_buf::bf_mpdu, list_splice_tail_init, NULL, ath_softc::tx, and ath_tx::txbuf.

Referenced by ath_draintxq(), and ath_tx_processq().

◆ ath_tx_txqaddbuf()

static void ath_tx_txqaddbuf ( struct ath_softc sc,
struct ath_txq txq,
struct list_head head 
)
static

Definition at line 323 of file ath9k_xmit.c.

325 {
326  struct ath_hw *ah = sc->sc_ah;
327  struct ath_buf *bf;
328 
329  /*
330  * Insert the frame on the outbound list and
331  * pass it on to the hardware.
332  */
333 
334  if (list_empty(head))
335  return;
336 
337  bf = list_first_entry(head, struct ath_buf, list);
338 
339  DBGIO("ath9k: "
340  "qnum: %d, txq depth: %d\n", txq->axq_qnum, txq->axq_depth);
341 
343 
344  if (txq->axq_link == NULL) {
346  DBGIO("ath9k: TXDP[%d] = %llx (%p)\n",
347  txq->axq_qnum, ito64(bf->bf_daddr),
348  bf->bf_desc);
349  } else {
350  *txq->axq_link = bf->bf_daddr;
351  DBGIO("ath9k: "
352  "link[%d] (%p)=%llx (%p)\n",
353  txq->axq_qnum, txq->axq_link,
354  ito64(bf->bf_daddr), bf->bf_desc);
355  }
357  &txq->axq_link);
359 
360  txq->axq_depth++;
361 }
Definition: hw.h:656
void * bf_desc
Definition: ath9k.h:225
u32 * axq_link
Definition: ath9k.h:183
void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp)
Definition: ath9k_mac.c:50
uint8_t head
Head number.
Definition: int13.h:34
struct list_head axq_q
Definition: ath9k.h:184
#define ito64(x)
Definition: ath9k.h:37
void ath9k_hw_txstart(struct ath_hw *ah, u32 q)
Definition: ath9k_mac.c:55
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
u32 bf_daddr
Definition: ath9k.h:226
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define DBGIO(...)
Definition: compiler.h:549
Definition: ath9k.h:219
#define list_splice_tail_init(list, entry)
Move all entries from one list into another list and reinitialise empty list.
Definition: list.h:299
struct ath_buf * bf_lastbf
Definition: ath9k.h:221
struct list_head list
Definition: ath9k.h:220
u32 axq_qnum
Definition: ath9k.h:182
static void ath9k_hw_get_desc_link(struct ath_hw *ah, void *ds, u32 **link)
Definition: hw-ops.h:44
u32 axq_depth
Definition: ath9k.h:185
uint8_t ah
Definition: registers.h:85
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ah, ath9k_hw_get_desc_link(), ath9k_hw_puttxbuf(), ath9k_hw_txstart(), ath_txq::axq_depth, ath_txq::axq_link, ath_txq::axq_q, ath_txq::axq_qnum, ath_buf::bf_daddr, ath_buf::bf_desc, ath_buf::bf_lastbf, DBGIO, head, ito64, ath_buf::list, list_empty, list_first_entry, list_splice_tail_init, NULL, and ath_softc::sc_ah.

Referenced by ath_tx_send_normal().

◆ ath_buf_set_rate()

static void ath_buf_set_rate ( struct ath_softc sc,
struct ath_buf bf,
int  len 
)
static

Definition at line 421 of file ath9k_xmit.c.

422 {
423  struct ath_common *common = ath9k_hw_common(sc->sc_ah);
424  struct ath9k_11n_rate_series series[4];
425  const struct ath9k_legacy_rate *rate;
426  int i, flags = 0;
427  u8 rix = 0, ctsrate = 0;
428  int is_pspoll;
429 
430  memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
431 
432  is_pspoll = 0;
433 
434  /*
435  * We check if Short Preamble is needed for the CTS rate by
436  * checking the BSS's global flag.
437  * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
438  */
439  rate = &sc->rates[sc->hw_rix];
440  ctsrate = rate->hw_value;
441  if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
442  ctsrate |= rate->hw_value_short;
443 
444  for (i = 0; i < 4; i++) {
445  int is_40 __unused, is_sgi __unused, is_sp;
446  int phy;
447 
448  rix = sc->hw_rix;
449  series[i].Tries = ATH_TXMAXTRY;
450 
451  if (sc->sc_flags & SC_OP_PROTECT_ENABLE) {
452  series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
454  }
455 
456  is_sp = !!(rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
457 
458  /* legacy rates */
459  if ((sc->dev->channels + sc->dev->channel)->band == NET80211_BAND_2GHZ)
460  phy = CHANNEL_CCK;
461  else
462  phy = CHANNEL_OFDM;
463 
464  series[i].Rate = rate->hw_value;
465  if (rate->hw_value_short && (sc->sc_flags & SC_OP_PREAMBLE_SHORT)) {
467  series[i].Rate |= rate->hw_value_short;
468  } else {
469  is_sp = 0;
470  }
471 
472  if (bf->bf_state.bfs_paprd)
473  series[i].ChSel = common->tx_chainmask;
474  else
475  series[i].ChSel = ath_txchainmask_reduction(sc,
476  common->tx_chainmask, series[i].Rate);
477 
478  series[i].PktDuration = ath9k_hw_computetxtime(sc->sc_ah,
479  phy, rate->bitrate * 100, len, rix, is_sp);
480  }
481 
482  /* For AR5416 - RTS cannot be followed by a frame larger than 8K */
483  if (bf_isaggr(bf) && (len > sc->sc_ah->caps.rts_aggr_limit))
485 
486  /* ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive. */
489 
490  /* set dur_update_en for l-sig computation except for PS-Poll frames */
492  bf->bf_lastbf->bf_desc,
493  !is_pspoll, ctsrate,
494  0, series, 4, flags);
495 
496 }
#define ATH9K_RATESERIES_RTS_CTS
Definition: mac.h:651
u16 hw_value_short
Definition: ath9k.h:393
void * bf_desc
Definition: ath9k.h:225
u8 ath_txchainmask_reduction(struct ath_softc *sc, u8 chainmask, u32 rate)
Definition: ath9k_xmit.c:409
u8 channel
The channel currently in use, as an index into the channels array.
Definition: net80211.h:812
#define ATH9K_TXDESC_CTSENA
Definition: mac.h:251
struct ath_buf_state bf_state
Definition: ath9k.h:230
u16 rts_aggr_limit
Definition: hw.h:200
u8 bfs_paprd
Definition: ath9k.h:215
static void ath9k_hw_set11n_ratescenario(struct ath_hw *ah, void *ds, void *lastds, u32 durUpdateEn, u32 rtsctsRate, u32 rtsctsDuration, struct ath9k_11n_rate_series series[], u32 nseries, u32 flags)
Definition: hw-ops.h:87
#define ATH_TXMAXTRY
Definition: ath9k.h:126
#define SC_OP_PREAMBLE_SHORT
Definition: ath9k.h:367
#define bf_isaggr(bf)
Definition: ath9k.h:100
#define CHANNEL_CCK
Definition: ath5k.h:630
#define NET80211_BAND_2GHZ
The 2.4 GHz ISM band, unlicensed in most countries.
Definition: net80211.h:45
struct net80211_device * dev
Definition: ath9k.h:445
struct ath_hw * sc_ah
Definition: ath9k.h:454
u16 ath9k_hw_computetxtime(struct ath_hw *ah, u8 phy, int kbps, u32 frameLen, u16 rateix, int shortPreamble)
Definition: ath9k_hw.c:137
struct ath_buf * bf_lastbf
Definition: ath9k.h:221
#define ATH9K_TXDESC_RTSENA
Definition: mac.h:250
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:869
int hw_rix
Definition: ath9k.h:479
#define CHANNEL_OFDM
Definition: ath5k.h:631
struct ib_cm_common common
Definition: ib_mad.h:11
u32 sc_flags
Definition: ath9k.h:465
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
uint32_t len
Length.
Definition: ena.h:14
struct ath9k_hw_capabilities caps
Definition: hw.h:663
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition: net80211.h:806
struct ath9k_legacy_rate rates[NET80211_MAX_RATES]
Definition: ath9k.h:478
#define SC_OP_PROTECT_ENABLE
Definition: ath9k.h:368
uint8_t u8
Definition: stdint.h:19
void * memset(void *dest, int character, size_t len) __nonnull
uint8_t flags
Flags.
Definition: ena.h:18

References __unused, ath9k_hw_common(), ath9k_hw_computetxtime(), ath9k_hw_set11n_ratescenario(), ATH9K_RATESERIES_RTS_CTS, ATH9K_TXDESC_CTSENA, ATH9K_TXDESC_RTSENA, ath_txchainmask_reduction(), ATH_TXMAXTRY, ath_buf::bf_desc, bf_isaggr, ath_buf::bf_lastbf, ath_buf::bf_state, ath_buf_state::bfs_paprd, ath9k_legacy_rate::bitrate, ath_hw::caps, net80211_device::channel, CHANNEL_CCK, CHANNEL_OFDM, net80211_device::channels, ath9k_11n_rate_series::ChSel, common, ath_softc::dev, flags, ath9k_legacy_rate::flags, ath_softc::hw_rix, ath9k_legacy_rate::hw_value, ath9k_legacy_rate::hw_value_short, IEEE80211_TX_RC_USE_SHORT_PREAMBLE, len, memset(), NET80211_BAND_2GHZ, ath9k_11n_rate_series::PktDuration, ath9k_11n_rate_series::Rate, ath9k_11n_rate_series::RateFlags, ath_softc::rates, ath9k_hw_capabilities::rts_aggr_limit, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_PREAMBLE_SHORT, SC_OP_PROTECT_ENABLE, and ath9k_11n_rate_series::Tries.

Referenced by ath_tx_send_normal().

◆ ath_tx_queue_tid()

static void ath_tx_queue_tid ( struct ath_txq txq,
struct ath_atx_tid tid 
)
static

Definition at line 63 of file ath9k_xmit.c.

64 {
65  struct ath_atx_ac *ac = tid->ac;
66 
67  if (tid->paused)
68  return;
69 
70  if (tid->sched)
71  return;
72 
73  tid->sched = 1;
74  list_add_tail(&tid->list, &ac->tid_q);
75 
76  if (ac->sched)
77  return;
78 
79  ac->sched = 1;
80  list_add_tail(&ac->list, &txq->axq_acq);
81 }
struct ath_txq * txq
Definition: ath9k.h:198
struct ib_mad_tid tid
Definition: ib_mad.h:17
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
Definition: ath9k.h:200
int sched
Definition: ath9k.h:199
struct list_head axq_acq
Definition: ath9k.h:189
struct list_head tid_q
Definition: ath9k.h:201

References ath_txq::axq_acq, ath_atx_ac::list, list_add_tail, ath_atx_ac::sched, tid, ath_atx_ac::tid_q, and ath_atx_ac::txq.

Referenced by ath_txq_schedule().

◆ ath_tx_get_buffer()

static struct ath_buf* ath_tx_get_buffer ( struct ath_softc sc)
static

Definition at line 83 of file ath9k_xmit.c.

84 {
85  struct ath_buf *bf = NULL;
86 
87  if (list_empty(&sc->tx.txbuf)) {
88  return NULL;
89  }
90 
91  bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list);
92  list_del(&bf->list);
93 
94  return bf;
95 }
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
Definition: ath9k.h:219
struct list_head list
Definition: ath9k.h:220
struct ath_tx tx
Definition: ath9k.h:476
struct list_head txbuf
Definition: ath9k.h:284
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ath_buf::list, list_del, list_empty, list_first_entry, NULL, ath_softc::tx, and ath_tx::txbuf.

Referenced by ath_tx_setup_buffer().

◆ ath_tx_return_buffer()

static void ath_tx_return_buffer ( struct ath_softc sc,
struct ath_buf bf 
)
static

Definition at line 97 of file ath9k_xmit.c.

98 {
99  list_add_tail(&bf->list, &sc->tx.txbuf);
100 }
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
Definition: ath9k.h:220
struct ath_tx tx
Definition: ath9k.h:476
struct list_head txbuf
Definition: ath9k.h:284

References ath_buf::list, list_add_tail, ath_softc::tx, and ath_tx::txbuf.

Referenced by ath_draintxq(), and ath_tx_processq().

◆ ath_txq_setup()

struct ath_txq* ath_txq_setup ( struct ath_softc sc,
int  qtype,
int  subtype 
)

Definition at line 106 of file ath9k_xmit.c.

107 {
108  struct ath_hw *ah = sc->sc_ah;
109  struct ath9k_tx_queue_info qi;
110  static const int subtype_txq_to_hwq[] = {
112  };
113  int axq_qnum, i;
114 
115  memset(&qi, 0, sizeof(qi));
116  qi.tqi_subtype = subtype_txq_to_hwq[subtype];
117  qi.tqi_aifs = ATH9K_TXQ_USEDEFAULT;
118  qi.tqi_cwmin = ATH9K_TXQ_USEDEFAULT;
119  qi.tqi_cwmax = ATH9K_TXQ_USEDEFAULT;
120  qi.tqi_physCompBuf = 0;
121 
122  /*
123  * Enable interrupts only for EOL and DESC conditions.
124  * We mark tx descriptors to receive a DESC interrupt
125  * when a tx queue gets deep; otherwise waiting for the
126  * EOL to reap descriptors. Note that this is done to
127  * reduce interrupt load and this only defers reaping
128  * descriptors, never transmitting frames. Aside from
129  * reducing interrupts this also permits more concurrency.
130  * The only potential downside is if the tx queue backs
131  * up in which case the top half of the kernel may backup
132  * due to a lack of tx descriptors.
133  *
134  * The UAPSD queue is an exception, since we take a desc-
135  * based intr on the EOSP frames.
136  */
137  qi.tqi_qflags = TXQ_FLAG_TXEOLINT_ENABLE |
139 
140  axq_qnum = ath9k_hw_setuptxqueue(ah, qtype, &qi);
141  if (axq_qnum == -1) {
142  /*
143  * NB: don't print a message, this happens
144  * normally on parts with too few tx queues
145  */
146  return NULL;
147  }
148  if ((unsigned int)axq_qnum >= ARRAY_SIZE(sc->tx.txq)) {
149  DBG("ath9k: qnum %d out of range, max %zd!\n",
150  axq_qnum, ARRAY_SIZE(sc->tx.txq));
151  ath9k_hw_releasetxqueue(ah, axq_qnum);
152  return NULL;
153  }
154  if (!ATH_TXQ_SETUP(sc, axq_qnum)) {
155  struct ath_txq *txq = &sc->tx.txq[axq_qnum];
156 
157  txq->axq_qnum = axq_qnum;
158  txq->mac80211_qnum = -1;
159  txq->axq_link = NULL;
160  INIT_LIST_HEAD(&txq->axq_q);
161  INIT_LIST_HEAD(&txq->axq_acq);
162  txq->axq_depth = 0;
163  txq->axq_ampdu_depth = 0;
164  txq->axq_tx_inprogress = 0;
165  sc->tx.txqsetup |= 1<<axq_qnum;
166 
167  txq->txq_headidx = txq->txq_tailidx = 0;
168  for (i = 0; i < ATH_TXFIFO_DEPTH; i++)
169  INIT_LIST_HEAD(&txq->txq_fifo[i]);
171  }
172  return &sc->tx.txq[axq_qnum];
173 }
Definition: hw.h:656
u8 txq_headidx
Definition: ath9k.h:192
u32 * axq_link
Definition: ath9k.h:183
int mac80211_qnum
Definition: ath9k.h:181
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:62
u8 txq_tailidx
Definition: ath9k.h:193
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:285
struct list_head axq_q
Definition: ath9k.h:184
#define WME_AC_BE
Definition: common.h:34
u32 axq_ampdu_depth
Definition: ath9k.h:186
Definition: ath9k.h:180
int ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
Definition: ath9k_mac.c:259
u32 txqsetup
Definition: ath9k.h:283
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define ATH9K_TXQ_USEDEFAULT
Definition: mac.h:597
#define ATH_TXFIFO_DEPTH
Definition: ath9k.h:179
struct list_head txq_fifo[ATH_TXFIFO_DEPTH]
Definition: ath9k.h:190
uint8_t subtype
Slow protocols subtype.
Definition: eth_slow.h:12
int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type, const struct ath9k_tx_queue_info *qinfo)
Definition: ath9k_mac.c:216
u32 axq_qnum
Definition: ath9k.h:182
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
struct ath_tx tx
Definition: ath9k.h:476
struct list_head axq_acq
Definition: ath9k.h:189
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
u32 axq_depth
Definition: ath9k.h:185
uint8_t ah
Definition: registers.h:85
struct list_head txq_fifo_pending
Definition: ath9k.h:191
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int axq_tx_inprogress
Definition: ath9k.h:188
void * memset(void *dest, int character, size_t len) __nonnull

References ah, ARRAY_SIZE, ath9k_hw_releasetxqueue(), ath9k_hw_setuptxqueue(), ATH9K_TXQ_USEDEFAULT, ATH_TXFIFO_DEPTH, ATH_TXQ_AC_BE, ATH_TXQ_SETUP, ath_txq::axq_acq, ath_txq::axq_ampdu_depth, ath_txq::axq_depth, ath_txq::axq_link, ath_txq::axq_q, ath_txq::axq_qnum, ath_txq::axq_tx_inprogress, DBG, INIT_LIST_HEAD, ath_txq::mac80211_qnum, memset(), NULL, ath_softc::sc_ah, subtype, ath9k_tx_queue_info::tqi_aifs, ath9k_tx_queue_info::tqi_cwmax, ath9k_tx_queue_info::tqi_cwmin, ath9k_tx_queue_info::tqi_physCompBuf, ath9k_tx_queue_info::tqi_qflags, ath9k_tx_queue_info::tqi_subtype, ath_softc::tx, ath_tx::txq, ath_txq::txq_fifo, ath_txq::txq_fifo_pending, TXQ_FLAG_TXDESCINT_ENABLE, TXQ_FLAG_TXEOLINT_ENABLE, ath_txq::txq_headidx, ath_txq::txq_tailidx, ath_tx::txqsetup, and WME_AC_BE.

Referenced by ath9k_init_queues().

◆ ath_draintxq()

void ath_draintxq ( struct ath_softc sc,
struct ath_txq txq,
int retry_tx  __unused 
)

Definition at line 181 of file ath9k_xmit.c.

182 {
183  struct ath_buf *bf, *lastbf __unused;
184  struct list_head bf_head;
185  struct ath_tx_status ts;
186 
187  memset(&ts, 0, sizeof(ts));
188  INIT_LIST_HEAD(&bf_head);
189 
190  for (;;) {
191  if (list_empty(&txq->axq_q)) {
192  txq->axq_link = NULL;
193  break;
194  }
195  bf = list_first_entry(&txq->axq_q, struct ath_buf,
196  list);
197 
198  if (bf->bf_stale) {
199  list_del(&bf->list);
200 
201  ath_tx_return_buffer(sc, bf);
202  continue;
203  }
204 
205  lastbf = bf->bf_lastbf;
206 
207  list_cut_position(&bf_head, &txq->axq_q, &lastbf->list);
208 
209  txq->axq_depth--;
210  ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
211  }
212 
213  txq->axq_tx_inprogress = 0;
214 }
u32 * axq_link
Definition: ath9k.h:183
struct list_head axq_q
Definition: ath9k.h:184
A doubly-linked list entry (or list head)
Definition: list.h:18
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, struct ath_txq *txq, struct list_head *bf_q, struct ath_tx_status *ts, int txok, int sendbar)
Definition: ath9k_xmit.c:623
int bf_stale
Definition: ath9k.h:228
Definition: ath9k.h:219
struct ath_buf * bf_lastbf
Definition: ath9k.h:221
struct list_head list
Definition: ath9k.h:220
#define list_cut_position(new, list, entry)
Cut a list into two.
Definition: list.h:185
static void ath_tx_return_buffer(struct ath_softc *sc, struct ath_buf *bf)
Definition: ath9k_xmit.c:97
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
u32 axq_depth
Definition: ath9k.h:185
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int axq_tx_inprogress
Definition: ath9k.h:188
void * memset(void *dest, int character, size_t len) __nonnull

References __unused, ath_tx_complete_buf(), ath_tx_return_buffer(), ath_txq::axq_depth, ath_txq::axq_link, ath_txq::axq_q, ath_txq::axq_tx_inprogress, ath_buf::bf_lastbf, ath_buf::bf_stale, INIT_LIST_HEAD, ath_buf::list, list_cut_position, list_del, list_empty, list_first_entry, memset(), and NULL.

Referenced by ath_drain_all_txq().

◆ ath_drain_all_txq()

int ath_drain_all_txq ( struct ath_softc sc,
int  retry_tx 
)

Definition at line 216 of file ath9k_xmit.c.

217 {
218  struct ath_hw *ah = sc->sc_ah;
219  struct ath_txq *txq;
220  int i, npend = 0;
221 
222  if (sc->sc_flags & SC_OP_INVALID)
223  return 1;
224 
226 
227  /* Check if any queue remains active */
228  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
229  if (!ATH_TXQ_SETUP(sc, i))
230  continue;
231 
232  npend += ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum);
233  }
234 
235  if (npend)
236  DBG("ath9k: Failed to stop TX DMA!\n");
237 
238  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
239  if (!ATH_TXQ_SETUP(sc, i))
240  continue;
241 
242  /*
243  * The caller will resume queues with ieee80211_wake_queues.
244  * Mark the queue as not stopped to prevent ath_tx_complete
245  * from waking the queue too early.
246  */
247  txq = &sc->tx.txq[i];
248  txq->stopped = 0;
249  ath_draintxq(sc, txq, retry_tx);
250  }
251 
252  return !npend;
253 }
Definition: hw.h:656
u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q)
Definition: ath9k_mac.c:62
int stopped
Definition: ath9k.h:187
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:62
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:285
Definition: ath9k.h:180
struct ath_hw * sc_ah
Definition: ath9k.h:454
void ath9k_hw_abort_tx_dma(struct ath_hw *ah)
Definition: ath9k_mac.c:129
u32 axq_qnum
Definition: ath9k.h:182
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:580
struct ath_tx tx
Definition: ath9k.h:476
void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, int retry_tx __unused)
Definition: ath9k_xmit.c:181
u32 sc_flags
Definition: ath9k.h:465
#define SC_OP_INVALID
Definition: ath9k.h:362
uint8_t ah
Definition: registers.h:85
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ah, ath9k_hw_abort_tx_dma(), ath9k_hw_numtxpending(), ATH9K_NUM_TX_QUEUES, ath_draintxq(), ATH_TXQ_SETUP, ath_txq::axq_qnum, DBG, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, ath_txq::stopped, ath_softc::tx, and ath_tx::txq.

Referenced by ath9k_stop(), ath_radio_disable(), ath_reset(), and ath_set_channel().

◆ ath_tx_cleanupq()

void ath_tx_cleanupq ( struct ath_softc sc,
struct ath_txq txq 
)

Definition at line 255 of file ath9k_xmit.c.

256 {
258  sc->tx.txqsetup &= ~(1<<txq->axq_qnum);
259 }
int ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q)
Definition: ath9k_mac.c:259
u32 txqsetup
Definition: ath9k.h:283
struct ath_hw * sc_ah
Definition: ath9k.h:454
u32 axq_qnum
Definition: ath9k.h:182
struct ath_tx tx
Definition: ath9k.h:476

References ath9k_hw_releasetxqueue(), ath_txq::axq_qnum, ath_softc::sc_ah, ath_softc::tx, and ath_tx::txqsetup.

Referenced by ath9k_deinit_softc(), and ath9k_init_softc().

◆ ath_txq_schedule()

void ath_txq_schedule ( struct ath_softc *sc  __unused,
struct ath_txq txq 
)

Definition at line 264 of file ath9k_xmit.c.

265 {
266  struct ath_atx_ac *ac, *ac_tmp, *last_ac;
267  struct ath_atx_tid *tid, *last_tid;
268 
269  if (list_empty(&txq->axq_acq) ||
271  return;
272 
273  ac = list_first_entry(&txq->axq_acq, struct ath_atx_ac, list);
274  last_ac = list_entry(txq->axq_acq.prev, struct ath_atx_ac, list);
275 
276  list_for_each_entry_safe(ac, ac_tmp, &txq->axq_acq, list) {
277  last_tid = list_entry(ac->tid_q.prev, struct ath_atx_tid, list);
278  list_del(&ac->list);
279  ac->sched = 0;
280 
281  while (!list_empty(&ac->tid_q)) {
283  list);
284  list_del(&tid->list);
285  tid->sched = 0;
286 
287  if (tid->paused)
288  continue;
289 
290  /*
291  * add tid to round-robin queue if more frames
292  * are pending for the tid
293  */
294  if (!list_empty(&tid->buf_q))
295  ath_tx_queue_tid(txq, tid);
296 
297  if (tid == last_tid ||
299  break;
300  }
301 
302  if (!list_empty(&ac->tid_q)) {
303  if (!ac->sched) {
304  ac->sched = 1;
305  list_add_tail(&ac->list, &txq->axq_acq);
306  }
307  }
308 
309  if (ac == last_ac ||
311  return;
312  }
313 }
#define ATH_AGGR_MIN_QDEPTH
Definition: ath9k.h:139
struct ib_mad_tid tid
Definition: ib_mad.h:17
static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid)
Definition: ath9k_xmit.c:63
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
u32 axq_ampdu_depth
Definition: ath9k.h:186
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
Definition: ath9k.h:200
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
struct list_head list
Definition: ath9k.h:234
int sched
Definition: ath9k.h:199
struct list_head axq_acq
Definition: ath9k.h:189
struct list_head * prev
Previous list entry.
Definition: list.h:22
struct list_head tid_q
Definition: ath9k.h:201
#define list_entry(list, type, member)
Get the container of a list entry.
Definition: list.h:321
struct ath_atx_ac * ac
Definition: ath9k.h:237

References ath_atx_tid::ac, ATH_AGGR_MIN_QDEPTH, ath_tx_queue_tid(), ath_txq::axq_acq, ath_txq::axq_ampdu_depth, ath_atx_ac::list, ath_atx_tid::list, list_add_tail, list_del, list_empty, list_entry, list_first_entry, list_for_each_entry_safe, list_head::prev, ath_atx_ac::sched, tid, and ath_atx_ac::tid_q.

Referenced by ath_tx_processq().

◆ get_hw_packet_type()

static enum ath9k_pkt_type get_hw_packet_type ( struct io_buffer iob)
static

Definition at line 381 of file ath9k_xmit.c.

382 {
383  struct ieee80211_frame *hdr;
384  enum ath9k_pkt_type htype;
385  u16 fc;
386 
387  hdr = (struct ieee80211_frame *)iob->data;
388  fc = hdr->fc;
389 
391  htype = ATH9K_PKT_TYPE_BEACON;
394  else
395  htype = ATH9K_PKT_TYPE_NORMAL;
396 
397  return htype;
398 }
uint16_t u16
Definition: stdint.h:21
struct golan_inbox_hdr hdr
Message header.
Definition: CIB_PRM.h:28
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
An 802.11 data or management frame without QoS or WDS header fields.
Definition: ieee80211.h:300
#define IEEE80211_FC_SUBTYPE
802.11 Frame Control field, Frame Subtype bitmask
Definition: ieee80211.h:110
#define IEEE80211_FC_TYPE
802.11 Frame Control field, Frame Type bitmask
Definition: ieee80211.h:97
#define IEEE80211_STYPE_PROBE_RESP
Subtype value for probe-response management frames.
Definition: ieee80211.h:157
void * data
Start of data.
Definition: iobuf.h:48
#define IEEE80211_STYPE_BEACON
Subtype value for beacon management frames.
Definition: ieee80211.h:168
ath9k_pkt_type
Definition: mac.h:604
#define IEEE80211_TYPE_MGMT
Type value for management (layer-2) frames.
Definition: ieee80211.h:100
if(natsemi->flags &NATSEMI_64BIT) return 1

References ATH9K_PKT_TYPE_BEACON, ATH9K_PKT_TYPE_NORMAL, ATH9K_PKT_TYPE_PROBE_RESP, io_buffer::data, fc, hdr, IEEE80211_FC_SUBTYPE, IEEE80211_FC_TYPE, IEEE80211_STYPE_BEACON, IEEE80211_STYPE_PROBE_RESP, IEEE80211_TYPE_MGMT, and if().

Referenced by ath_tx_setup_buffer().

◆ setup_tx_flags()

static int setup_tx_flags ( struct io_buffer *iob  __unused)
static

Definition at line 400 of file ath9k_xmit.c.

401 {
402  int flags = 0;
403 
405 
406  return flags;
407 }
#define ATH9K_TXDESC_INTREQ
Definition: mac.h:265
uint8_t flags
Flags.
Definition: ena.h:18

References ATH9K_TXDESC_INTREQ, and flags.

Referenced by ath_tx_setup_buffer().

◆ ath_txchainmask_reduction()

u8 ath_txchainmask_reduction ( struct ath_softc sc,
u8  chainmask,
u32  rate 
)

Definition at line 409 of file ath9k_xmit.c.

410 {
411  struct ath_hw *ah = sc->sc_ah;
412  struct ath9k_channel *curchan = ah->curchan;
413  if ((sc->sc_flags & SC_OP_ENABLE_APM) &&
414  (curchan->channelFlags & CHANNEL_5GHZ) &&
415  (chainmask == 0x7) && (rate < 0x90))
416  return 0x3;
417  else
418  return chainmask;
419 }
Definition: hw.h:656
u32 channelFlags
Definition: hw.h:350
struct ath_hw * sc_ah
Definition: ath9k.h:454
u32 sc_flags
Definition: ath9k.h:465
#define CHANNEL_5GHZ
Definition: ath5k.h:633
uint8_t ah
Definition: registers.h:85
#define SC_OP_ENABLE_APM
Definition: ath9k.h:376

References ah, CHANNEL_5GHZ, ath9k_channel::channelFlags, ath_softc::sc_ah, ath_softc::sc_flags, and SC_OP_ENABLE_APM.

Referenced by ath_buf_set_rate().

◆ ath_tx_setup_buffer()

static struct ath_buf* ath_tx_setup_buffer ( struct net80211_device dev,
struct ath_txq txq,
struct io_buffer iob 
)
static

Definition at line 498 of file ath9k_xmit.c.

501 {
502  struct ath_softc *sc = dev->priv;
503  struct ath_hw *ah = sc->sc_ah;
504  struct ath_buf *bf;
505  struct ath_desc *ds;
506  int frm_type;
507  static const enum ath9k_key_type net80211_keytype_to_ath[] = {
513  };
514 
515  bf = ath_tx_get_buffer(sc);
516  if (!bf) {
517  DBG("ath9k: TX buffers are full\n");
518  return NULL;
519  }
520 
521  ATH_TXBUF_RESET(bf);
522 
523  bf->bf_flags = setup_tx_flags(iob);
524  bf->bf_mpdu = iob;
525 
526  bf->bf_buf_addr = virt_to_bus(iob->data);
527 
528  frm_type = get_hw_packet_type(iob);
529 
530  ds = bf->bf_desc;
532 
534  ATH9K_TXKEYIX_INVALID, net80211_keytype_to_ath[dev->crypto->algorithm], bf->bf_flags);
535 
537  iob_len(iob), /* segment length */
538  1, /* first segment */
539  1, /* last segment */
540  ds, /* first descriptor */
541  bf->bf_buf_addr,
542  txq->axq_qnum);
543 
544 
545  return bf;
546 }
struct io_buffer * bf_mpdu
Definition: ath9k.h:224
Network protected with CCMP (AES-based system)
Definition: net80211.h:174
Definition: hw.h:656
void * bf_desc
Definition: ath9k.h:225
Dummy value used when the cryptosystem can't be detected.
Definition: net80211.h:177
static struct ath_buf * ath_tx_get_buffer(struct ath_softc *sc)
Definition: ath9k_xmit.c:83
#define ATH_TXBUF_RESET(_bf)
Definition: ath9k.h:73
static enum ath9k_pkt_type get_hw_packet_type(struct io_buffer *iob)
Definition: ath9k_xmit.c:381
Network protected with WEP (awful RC4-based system)
Definition: net80211.h:145
Definition: mac.h:240
struct net80211_device * dev
Definition: ath9k.h:445
u16 bf_flags
Definition: ath9k.h:229
enum net80211_crypto_alg algorithm
The cryptographic algorithm implemented.
Definition: net80211.h:692
static void ath9k_hw_set11n_txdesc(struct ath_hw *ah, void *ds, u32 pktLen, enum ath9k_pkt_type type, u32 txPower, u32 keyIx, enum ath9k_key_type keyType, u32 flags)
Definition: hw-ops.h:77
struct net80211_crypto * crypto
802.11 cryptosystem for our current network
Definition: net80211.h:940
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
ath9k_key_type
Definition: mac.h:664
struct ath_hw * sc_ah
Definition: ath9k.h:454
u32 bf_buf_addr
Definition: ath9k.h:227
#define FCS_LEN
Definition: ath5k_desc.c:36
void * priv
Driver private data.
Definition: net80211.h:798
Definition: ath9k.h:219
static void ath9k_hw_filltxdesc(struct ath_hw *ah, void *ds, u32 seglen, int is_firstseg, int is_lastseg, const void *ds0, u32 buf_addr, unsigned int qcu)
Definition: hw-ops.h:62
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
u32 axq_qnum
Definition: ath9k.h:182
No security, an "Open" network.
Definition: net80211.h:131
uint32_t ds
Definition: librm.h:254
static int setup_tx_flags(struct io_buffer *iob __unused)
Definition: ath9k_xmit.c:400
static void ath9k_hw_set_desc_link(struct ath_hw *ah, void *ds, u32 link)
Definition: hw-ops.h:38
void * data
Start of data.
Definition: iobuf.h:48
uint8_t ah
Definition: registers.h:85
Network protected with TKIP (better RC4-based system)
Definition: net80211.h:163
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ATH9K_TXKEYIX_INVALID
Definition: mac.h:204
#define MAX_RATE_POWER
Definition: hw.h:144

References ah, net80211_crypto::algorithm, ath9k_hw_filltxdesc(), ath9k_hw_set11n_txdesc(), ath9k_hw_set_desc_link(), ATH9K_KEY_TYPE_AES, ATH9K_KEY_TYPE_CLEAR, ATH9K_KEY_TYPE_TKIP, ATH9K_KEY_TYPE_WEP, ATH9K_TXKEYIX_INVALID, ath_tx_get_buffer(), ATH_TXBUF_RESET, ath_txq::axq_qnum, ath_buf::bf_buf_addr, ath_buf::bf_desc, ath_buf::bf_flags, ath_buf::bf_mpdu, net80211_device::crypto, io_buffer::data, DBG, ath_softc::dev, ds, FCS_LEN, get_hw_packet_type(), iob_len(), MAX_RATE_POWER, NET80211_CRYPT_CCMP, NET80211_CRYPT_NONE, NET80211_CRYPT_TKIP, NET80211_CRYPT_UNKNOWN, NET80211_CRYPT_WEP, NULL, net80211_device::priv, ath_softc::sc_ah, setup_tx_flags(), and virt_to_bus().

Referenced by ath_tx_start().

◆ ath_tx_start_dma()

static void ath_tx_start_dma ( struct ath_softc sc,
struct ath_buf bf,
struct ath_tx_control txctl 
)
static

Definition at line 549 of file ath9k_xmit.c.

551 {
552  struct list_head bf_head;
553  struct ath_atx_tid *tid = NULL;
554 
555  INIT_LIST_HEAD(&bf_head);
556  list_add_tail(&bf->list, &bf_head);
557 
558  bf->bf_state.bfs_paprd = txctl->paprd;
559 
560  if (txctl->paprd)
562 
563  ath9k_hw_set_clrdmask(sc->sc_ah, bf->bf_desc, 1);
564 
565  ath_tx_send_normal(sc, txctl->txq, tid, &bf_head);
566 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
static void ath9k_hw_set_clrdmask(struct ath_hw *ah, void *ds, int val)
Definition: hw-ops.h:121
void * bf_desc
Definition: ath9k.h:225
struct ath_buf_state bf_state
Definition: ath9k.h:230
struct ath_txq * txq
Definition: ath9k.h:266
u8 bfs_paprd
Definition: ath9k.h:215
struct ib_mad_tid tid
Definition: ib_mad.h:17
A doubly-linked list entry (or list head)
Definition: list.h:18
struct ath_hw * sc_ah
Definition: ath9k.h:454
unsigned long bfs_paprd_timestamp
Definition: ath9k.h:216
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct list_head list
Definition: ath9k.h:220
static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq, struct ath_atx_tid *tid, struct list_head *bf_head)
Definition: ath9k_xmit.c:363
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ath9k_hw_set_clrdmask(), ath_tx_send_normal(), ath_buf::bf_desc, ath_buf::bf_state, ath_buf_state::bfs_paprd, ath_buf_state::bfs_paprd_timestamp, currticks(), INIT_LIST_HEAD, ath_buf::list, list_add_tail, NULL, ath_tx_control::paprd, ath_softc::sc_ah, TICKS_PER_SEC, tid, and ath_tx_control::txq.

Referenced by ath_tx_start().

◆ ath_tx_start()

int ath_tx_start ( struct net80211_device dev,
struct io_buffer iob,
struct ath_tx_control txctl 
)

Definition at line 569 of file ath9k_xmit.c.

571 {
572  struct ath_softc *sc = dev->priv;
573  struct ath_txq *txq = txctl->txq;
574  struct ath_buf *bf;
575  int q;
576 
577  /*
578  * At this point, the vif, hw_key and sta pointers in the tx control
579  * info are no longer valid (overwritten by the ath_frame_info data.
580  */
581 
582  bf = ath_tx_setup_buffer(dev, txctl->txq, iob);
583  if (!bf)
584  return -ENOMEM;
585 
586  q = 0;
587  if (txq == sc->tx.txq_map[q] &&
588  ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
589  txq->stopped = 1;
590  }
591 
592  ath_tx_start_dma(sc, bf, txctl);
593 
594  return 0;
595 }
int pending_frames
Definition: ath9k.h:194
int stopped
Definition: ath9k.h:187
struct ath_txq * txq
Definition: ath9k.h:266
static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_control *txctl)
Definition: ath9k_xmit.c:549
struct net80211_device * dev
Definition: ath9k.h:445
#define ENOMEM
Not enough space.
Definition: errno.h:534
Definition: ath9k.h:180
void * priv
Driver private data.
Definition: net80211.h:798
Definition: ath9k.h:219
struct ath_tx tx
Definition: ath9k.h:476
#define ATH_MAX_QDEPTH
Definition: ath9k.h:125
struct ath_txq * txq_map[WME_NUM_AC]
Definition: ath9k.h:287
static struct ath_buf * ath_tx_setup_buffer(struct net80211_device *dev, struct ath_txq *txq, struct io_buffer *iob)
Definition: ath9k_xmit.c:498

References ATH_MAX_QDEPTH, ath_tx_setup_buffer(), ath_tx_start_dma(), ath_softc::dev, ENOMEM, ath_txq::pending_frames, net80211_device::priv, ath_txq::stopped, ath_softc::tx, ath_tx_control::txq, and ath_tx::txq_map.

Referenced by ath9k_tx().

◆ ath_tx_complete()

static void ath_tx_complete ( struct ath_softc sc,
struct io_buffer iob,
int tx_flags  __unused,
struct ath_tx_status ts,
struct ath_txq txq 
)
static

Definition at line 601 of file ath9k_xmit.c.

603 {
604  struct net80211_device *dev = sc->dev;
605  int q, padpos __unused, padsize __unused;
606 
607  DBGIO("ath9k: TX complete: iob: %p\n", iob);
608 
609  q = 0;
610  if (txq == sc->tx.txq_map[q]) {
611  if (--txq->pending_frames < 0)
612  txq->pending_frames = 0;
613 
614  if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
615  txq->stopped = 0;
616  }
617  }
618 
619  net80211_tx_complete(dev, iob, ts->ts_longretry,
620  (ts->ts_status & ATH9K_TXERR_MASK) ? EIO : 0);
621 }
u8 ts_longretry
Definition: mac.h:117
int pending_frames
Definition: ath9k.h:194
u8 ts_status
Definition: mac.h:113
int stopped
Definition: ath9k.h:187
#define ATH9K_TXERR_MASK
Definition: mac.h:89
struct net80211_device * dev
Definition: ath9k.h:445
#define DBGIO(...)
Definition: compiler.h:549
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
struct ath_tx tx
Definition: ath9k.h:476
void net80211_tx_complete(struct net80211_device *dev, struct io_buffer *iob, int retries, int rc)
Indicate the completed transmission of a packet.
Definition: net80211.c:2808
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define ATH_MAX_QDEPTH
Definition: ath9k.h:125
#define EIO
Input/output error.
Definition: errno.h:433
struct ath_txq * txq_map[WME_NUM_AC]
Definition: ath9k.h:287

References __unused, ATH9K_TXERR_MASK, ATH_MAX_QDEPTH, DBGIO, ath_softc::dev, EIO, net80211_tx_complete(), ath_txq::pending_frames, ath_txq::stopped, ath_tx_status::ts_longretry, ath_tx_status::ts_status, ath_softc::tx, and ath_tx::txq_map.

Referenced by ath_tx_complete_buf().

◆ ath_tx_processq()

static void ath_tx_processq ( struct ath_softc sc,
struct ath_txq txq 
)
static

Definition at line 656 of file ath9k_xmit.c.

657 {
658  struct ath_hw *ah = sc->sc_ah;
659  struct ath_buf *bf, *lastbf, *bf_held = NULL;
660  struct list_head bf_head;
661  struct ath_desc *ds;
662  struct ath_tx_status ts;
663  int txok;
664  int status;
665 
666  DBGIO("ath9k: tx queue %d (%x), link %p\n",
667  txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
668  txq->axq_link);
669 
670  for (;;) {
671  if (list_empty(&txq->axq_q)) {
672  txq->axq_link = NULL;
673  if (sc->sc_flags & SC_OP_TXAGGR)
674  ath_txq_schedule(sc, txq);
675  break;
676  }
677  bf = list_first_entry(&txq->axq_q, struct ath_buf, list);
678 
679  /*
680  * There is a race condition that a BH gets scheduled
681  * after sw writes TxE and before hw re-load the last
682  * descriptor to get the newly chained one.
683  * Software must keep the last DONE descriptor as a
684  * holding descriptor - software does so by marking
685  * it with the STALE flag.
686  */
687  bf_held = NULL;
688  if (bf->bf_stale) {
689  bf_held = bf;
690  if (list_is_last(&bf_held->list, &txq->axq_q)) {
691  break;
692  } else {
693  bf = list_entry(bf_held->list.next,
694  struct ath_buf, list);
695  }
696  }
697 
698  lastbf = bf->bf_lastbf;
699  ds = lastbf->bf_desc;
700 
701  memset(&ts, 0, sizeof(ts));
702  status = ath9k_hw_txprocdesc(ah, ds, &ts);
703  if (status == -EINPROGRESS) {
704  break;
705  }
706 
707  /*
708  * Remove ath_buf's of the same transmit unit from txq,
709  * however leave the last descriptor back as the holding
710  * descriptor for hw.
711  */
712  lastbf->bf_stale = 1;
713  INIT_LIST_HEAD(&bf_head);
714  if (!list_is_singular(&lastbf->list))
715  list_cut_position(&bf_head,
716  &txq->axq_q, lastbf->list.prev);
717 
718  txq->axq_depth--;
719  txok = !(ts.ts_status & ATH9K_TXERR_MASK);
720  txq->axq_tx_inprogress = 0;
721  if (bf_held)
722  list_del(&bf_held->list);
723 
724  if (bf_held)
725  ath_tx_return_buffer(sc, bf_held);
726 
727  /*
728  * This frame is sent out as a single frame.
729  * Use hardware retry status for this frame.
730  */
731  if (ts.ts_status & ATH9K_TXERR_XRETRY)
732  bf->bf_state.bf_type |= BUF_XRETRY;
733 
734  ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
735 
736  if (sc->sc_flags & SC_OP_TXAGGR)
737  ath_txq_schedule(sc, txq);
738  }
739 }
Definition: hw.h:656
void * bf_desc
Definition: ath9k.h:225
struct ath_buf_state bf_state
Definition: ath9k.h:230
struct list_head * next
Next list entry.
Definition: list.h:20
u32 * axq_link
Definition: ath9k.h:183
#define ATH9K_TXERR_MASK
Definition: mac.h:89
u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q)
Definition: mac.h:240
struct list_head axq_q
Definition: ath9k.h:184
A doubly-linked list entry (or list head)
Definition: list.h:18
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
uint8_t status
Status.
Definition: ena.h:16
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, struct ath_txq *txq, struct list_head *bf_q, struct ath_tx_status *ts, int txok, int sendbar)
Definition: ath9k_xmit.c:623
int bf_stale
Definition: ath9k.h:228
struct ath_hw * sc_ah
Definition: ath9k.h:454
#define DBGIO(...)
Definition: compiler.h:549
Definition: ath9k.h:219
#define EINPROGRESS
Operation in progress.
Definition: errno.h:418
u8 bf_type
Definition: ath9k.h:214
#define SC_OP_TXAGGR
Definition: ath9k.h:365
struct ath_buf * bf_lastbf
Definition: ath9k.h:221
struct list_head list
Definition: ath9k.h:220
u32 axq_qnum
Definition: ath9k.h:182
#define list_cut_position(new, list, entry)
Cut a list into two.
Definition: list.h:185
void ath_txq_schedule(struct ath_softc *sc __unused, struct ath_txq *txq)
Definition: ath9k_xmit.c:264
uint32_t ds
Definition: librm.h:254
u32 sc_flags
Definition: ath9k.h:465
static void ath_tx_return_buffer(struct ath_softc *sc, struct ath_buf *bf)
Definition: ath9k_xmit.c:97
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
#define list_is_singular(list)
Test whether a list has just one entry.
Definition: list.h:149
u32 axq_depth
Definition: ath9k.h:185
struct list_head * prev
Previous list entry.
Definition: list.h:22
static int ath9k_hw_txprocdesc(struct ath_hw *ah, void *ds, struct ath_tx_status *ts)
Definition: hw-ops.h:71
uint8_t ah
Definition: registers.h:85
#define list_entry(list, type, member)
Get the container of a list entry.
Definition: list.h:321
#define ATH9K_TXERR_XRETRY
Definition: mac.h:83
#define list_is_last(list, head)
Test whether an entry is the last entry in list.
Definition: list.h:163
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int axq_tx_inprogress
Definition: ath9k.h:188
void * memset(void *dest, int character, size_t len) __nonnull

References ah, ath9k_hw_gettxbuf(), ath9k_hw_txprocdesc(), ATH9K_TXERR_MASK, ATH9K_TXERR_XRETRY, ath_tx_complete_buf(), ath_tx_return_buffer(), ath_txq_schedule(), ath_txq::axq_depth, ath_txq::axq_link, ath_txq::axq_q, ath_txq::axq_qnum, ath_txq::axq_tx_inprogress, ath_buf::bf_desc, ath_buf::bf_lastbf, ath_buf::bf_stale, ath_buf::bf_state, ath_buf_state::bf_type, BUF_XRETRY, DBGIO, ds, EINPROGRESS, INIT_LIST_HEAD, ath_buf::list, list_cut_position, list_del, list_empty, list_entry, list_first_entry, list_is_last, list_is_singular, memset(), list_head::next, NULL, list_head::prev, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_TXAGGR, status, and ath_tx_status::ts_status.

Referenced by ath_tx_tasklet().

◆ ath_tx_complete_poll_work()

static void ath_tx_complete_poll_work ( struct ath_softc sc)
static

Definition at line 741 of file ath9k_xmit.c.

742 {
743  struct ath_txq *txq;
744  int i;
745  int needreset = 0;
746 
747  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
748  if (ATH_TXQ_SETUP(sc, i)) {
749  txq = &sc->tx.txq[i];
750  if (txq->axq_depth) {
751  if (txq->axq_tx_inprogress) {
752  needreset = 1;
753  break;
754  } else {
755  txq->axq_tx_inprogress = 1;
756  }
757  }
758  }
759 
760  if (needreset) {
761  DBG("ath9k: "
762  "tx hung, resetting the chip\n");
763  ath_reset(sc, 1);
764  }
765 
767 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
unsigned long tx_complete_work_timer
Definition: ath9k.h:485
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:62
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:285
Definition: ath9k.h:180
#define ATH_TX_COMPLETE_POLL_INT
Definition: ath9k.h:171
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:580
struct ath_tx tx
Definition: ath9k.h:476
int ath_reset(struct ath_softc *sc, int retry_tx)
Definition: ath9k_main.c:511
u32 axq_depth
Definition: ath9k.h:185
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
int axq_tx_inprogress
Definition: ath9k.h:188

References ATH9K_NUM_TX_QUEUES, ath_reset(), ATH_TX_COMPLETE_POLL_INT, ATH_TXQ_SETUP, ath_txq::axq_depth, ath_txq::axq_tx_inprogress, currticks(), DBG, TICKS_PER_SEC, ath_softc::tx, ath_softc::tx_complete_work_timer, and ath_tx::txq.

Referenced by ath_tx_init().

◆ ath_tx_tasklet()

void ath_tx_tasklet ( struct ath_softc sc)

Definition at line 771 of file ath9k_xmit.c.

772 {
773  int i;
774  u32 qcumask = ((1 << ATH9K_NUM_TX_QUEUES) - 1);
775 
776  ath9k_hw_gettxintrtxqs(sc->sc_ah, &qcumask);
777 
778  for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
779  if (ATH_TXQ_SETUP(sc, i) && (qcumask & (1 << i)))
780  ath_tx_processq(sc, &sc->tx.txq[i]);
781  }
782 }
#define ATH_TXQ_SETUP(sc, i)
Definition: ath9k.h:62
struct ath_txq txq[ATH9K_NUM_TX_QUEUES]
Definition: ath9k.h:285
struct ath_hw * sc_ah
Definition: ath9k.h:454
void ath9k_hw_gettxintrtxqs(struct ath_hw *ah, u32 *txqs)
Definition: ath9k_mac.c:156
static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
Definition: ath9k_xmit.c:656
#define ATH9K_NUM_TX_QUEUES
Definition: mac.h:580
struct ath_tx tx
Definition: ath9k.h:476
uint32_t u32
Definition: stdint.h:23

References ath9k_hw_gettxintrtxqs(), ATH9K_NUM_TX_QUEUES, ath_tx_processq(), ATH_TXQ_SETUP, ath_softc::sc_ah, ath_softc::tx, and ath_tx::txq.

Referenced by ath9k_tasklet().

◆ ath_tx_init()

int ath_tx_init ( struct ath_softc sc,
int  nbufs 
)

Definition at line 788 of file ath9k_xmit.c.

789 {
790  int error = 0;
791 
792  error = ath_descdma_setup(sc, &sc->tx.txdma, &sc->tx.txbuf,
793  "tx", nbufs, 1, 1);
794  if (error != 0) {
795  DBG("ath9k: "
796  "Failed to allocate tx descriptors: %d\n", error);
797  goto err;
798  }
799 
801 
802 err:
803  if (error != 0)
804  ath_tx_cleanup(sc);
805 
806  return error;
807 }
struct ath_descdma txdma
Definition: ath9k.h:286
struct arbelprm_completion_with_error error
Definition: arbel.h:12
int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head, const char *name, int nbuf, int ndesc, int is_tx)
Definition: ath9k_init.c:180
void(* tx_complete_work)(struct ath_softc *sc)
Definition: ath9k.h:484
static void ath_tx_complete_poll_work(struct ath_softc *sc)
Definition: ath9k_xmit.c:741
void ath_tx_cleanup(struct ath_softc *sc)
Definition: ath9k_xmit.c:809
struct ath_tx tx
Definition: ath9k.h:476
struct list_head txbuf
Definition: ath9k.h:284
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498

References ath_descdma_setup(), ath_tx_cleanup(), ath_tx_complete_poll_work(), DBG, error, ath_softc::tx, ath_softc::tx_complete_work, ath_tx::txbuf, and ath_tx::txdma.

Referenced by ath9k_init_device().

◆ ath_tx_cleanup()

void ath_tx_cleanup ( struct ath_softc sc)

Definition at line 809 of file ath9k_xmit.c.

810 {
811  if (sc->tx.txdma.dd_desc_len != 0)
812  ath_descdma_cleanup(sc, &sc->tx.txdma, &sc->tx.txbuf);
813 }
struct ath_descdma txdma
Definition: ath9k.h:286
void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head)
struct ath_tx tx
Definition: ath9k.h:476
struct list_head txbuf
Definition: ath9k.h:284
u32 dd_desc_len
Definition: ath9k.h:108

References ath_descdma_cleanup(), ath_descdma::dd_desc_len, ath_softc::tx, ath_tx::txbuf, and ath_tx::txdma.

Referenced by ath9k_deinit_device(), ath9k_init_device(), and ath_tx_init().