iPXE
ath9k_recv.c File Reference
#include <ipxe/io.h>
#include "ath9k.h"
#include "ar9003_mac.h"

Go to the source code of this file.

Macros

#define RX_FILTER_PRESERVE   (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)

Functions

 FILE_SECBOOT (FORBIDDEN)
static void ath_rx_buf_link (struct ath_softc *sc, struct ath_buf *bf)
static void ath_setdefantenna (struct ath_softc *sc, u32 antenna)
static void ath_opmode_init (struct ath_softc *sc)
int ath_rx_init (struct ath_softc *sc, int nbufs)
void ath_rx_cleanup (struct ath_softc *sc)
u32 ath_calcrxfilter (struct ath_softc *sc)
int ath_startrecv (struct ath_softc *sc)
int ath_stoprecv (struct ath_softc *sc)
void ath_flushrecv (struct ath_softc *sc)
static struct ath_bufath_get_next_rx_buf (struct ath_softc *sc, struct ath_rx_status *rs)
static int ath9k_rx_accept (struct ath_common *common, struct ath_rx_status *rx_stats, int *decrypt_error)
static int ath9k_process_rate (struct ath_common *common __unused, struct net80211_device *dev, struct ath_rx_status *rx_stats, int *rix)
static int ath9k_rx_iob_preprocess (struct ath_common *common, struct net80211_device *dev, struct ath_rx_status *rx_stats, int *rix, int *decrypt_error)
int ath_rx_tasklet (struct ath_softc *sc, int flush, int hp __unused)

Macro Definition Documentation

◆ RX_FILTER_PRESERVE

#define RX_FILTER_PRESERVE   (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)

Referenced by ath_calcrxfilter().

Function Documentation

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ ath_rx_buf_link()

void ath_rx_buf_link ( struct ath_softc * sc,
struct ath_buf * bf )
static

Definition at line 35 of file ath9k_recv.c.

36{
37 struct ath_hw *ah = sc->sc_ah;
39 struct ath_desc *ds;
40// struct io_buffer *iob;
41
43
44 ds = bf->bf_desc;
45 ds->ds_link = 0; /* link to null */
46 ds->ds_data = bf->bf_buf_addr;
47
48// /* virtual addr of the beginning of the buffer. */
49// iob = bf->bf_mpdu;
50// ds->ds_vdata = iob->data;
51
52 /*
53 * setup rx descriptors. The rx_bufsize here tells the hardware
54 * how much data it can DMA to us and that we are prepared
55 * to process
56 */
58 common->rx_bufsize,
59 0);
60
61 if (sc->rx.rxlink == NULL)
63 else
64 *sc->rx.rxlink = bf->bf_daddr;
65
66 sc->rx.rxlink = &ds->ds_link;
67}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
#define ATH_RXBUF_RESET(_bf)
Definition ath9k.h:82
void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds, u32 size, u32 flags)
void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp)
Definition ath9k_mac.c:521
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition hw.h:870
struct ib_cm_common common
Definition ib_mad.h:0
uint32_t ds
Definition librm.h:5
uint8_t ah
Definition registers.h:1
void * bf_desc
Definition ath9k.h:226
u32 bf_buf_addr
Definition ath9k.h:228
u32 bf_daddr
Definition ath9k.h:227
Definition hw.h:657
u32 * rxlink
Definition ath9k.h:300
struct ath_rx rx
Definition ath9k.h:476
struct ath_hw * sc_ah
Definition ath9k.h:455

References ah, ath9k_hw_common(), ath9k_hw_putrxbuf(), ath9k_hw_setuprxdesc(), ATH_RXBUF_RESET, ath_buf::bf_buf_addr, ath_buf::bf_daddr, ath_buf::bf_desc, common, ds, NULL, ath_softc::rx, ath_rx::rxlink, and ath_softc::sc_ah.

Referenced by ath_rx_tasklet(), and ath_startrecv().

◆ ath_setdefantenna()

void ath_setdefantenna ( struct ath_softc * sc,
u32 antenna )
static

Definition at line 69 of file ath9k_recv.c.

70{
71 /* XXX block beacon interrupts */
72 ath9k_hw_setantenna(sc->sc_ah, antenna);
73 sc->rx.defant = antenna;
74 sc->rx.rxotherant = 0;
75}
void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna)
Definition ath9k_hw.c:1873
u8 rxotherant
Definition ath9k.h:299
u8 defant
Definition ath9k.h:298

References ath9k_hw_setantenna(), ath_rx::defant, ath_softc::rx, ath_rx::rxotherant, ath_softc::sc_ah, and u32.

Referenced by ath_rx_tasklet().

◆ ath_opmode_init()

void ath_opmode_init ( struct ath_softc * sc)
static

Definition at line 77 of file ath9k_recv.c.

78{
79 struct ath_hw *ah = sc->sc_ah;
81
82 u32 rfilt, mfilt[2];
83
84 /* configure rx filter */
85 rfilt = ath_calcrxfilter(sc);
87
88 /* configure bssid mask */
90
91 /* configure operational mode */
93
94 /* calculate and install multicast filter */
95 mfilt[0] = mfilt[1] = ~0;
96 ath9k_hw_setmcastfilter(ah, mfilt[0], mfilt[1]);
97}
void ath9k_hw_setopmode(struct ath_hw *ah)
Definition ath9k_hw.c:1955
void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1)
Definition ath9k_hw.c:1960
void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits)
Definition ath9k_hw.c:1895
u32 ath_calcrxfilter(struct ath_softc *sc)
Definition ath9k_recv.c:181
void ath_hw_setbssidmask(struct ath_common *common)
ath_hw_set_bssid_mask - filter out bssids we listen
Definition ath_hw.c:122
#define u32
Definition vga.h:21

References ah, ath9k_hw_common(), ath9k_hw_setmcastfilter(), ath9k_hw_setopmode(), ath9k_hw_setrxfilter(), ath_calcrxfilter(), ath_hw_setbssidmask(), common, ath_softc::sc_ah, and u32.

Referenced by ath_startrecv().

◆ ath_rx_init()

int ath_rx_init ( struct ath_softc * sc,
int nbufs )

Definition at line 99 of file ath9k_recv.c.

100{
101 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
102 struct io_buffer *iob;
103 struct ath_buf *bf;
104 int error = 0;
105
107
108 common->rx_bufsize = IEEE80211_MAX_MPDU_LEN / 2 +
110
111 DBG2("ath9k: cachelsz %d rxbufsize %d\n",
112 common->cachelsz, common->rx_bufsize);
113
114 /* Initialize rx descriptors */
115
116 error = ath_descdma_setup(sc, &sc->rx.rxdma, &sc->rx.rxbuf,
117 "rx", nbufs, 1, 0);
118 if (error != 0) {
119 DBG("ath9k: "
120 "failed to allocate rx descriptors: %d\n",
121 error);
122 goto err;
123 }
124
125 list_for_each_entry(bf, &sc->rx.rxbuf, list) {
126 iob = alloc_iob_raw ( common->rx_bufsize, common->cachelsz, 0 );
127 if (iob == NULL) {
128 error = -ENOMEM;
129 goto err;
130 }
131
132 bf->bf_mpdu = iob;
133 bf->bf_buf_addr = virt_to_bus ( iob->data );
134 }
135 sc->rx.rxlink = NULL;
136
137err:
138 if (error)
139 ath_rx_cleanup(sc);
140
141 return error;
142}
struct arbelprm_completion_with_error error
Definition arbel.h:1
#define SC_OP_RXFLUSH
Definition ath9k.h:370
#define IEEE80211_MAX_MPDU_LEN
Definition ath9k.h:149
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:181
void ath_rx_cleanup(struct ath_softc *sc)
Definition ath9k_recv.c:144
#define DBG2(...)
Definition compiler.h:515
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define ENOMEM
Not enough space.
Definition errno.h:535
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
struct io_buffer * alloc_iob_raw(size_t len, size_t align, size_t offset)
Allocate I/O buffer with specified alignment and offset.
Definition iobuf.c:49
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
struct list_head list
Definition ath9k.h:221
struct io_buffer * bf_mpdu
Definition ath9k.h:225
struct ath9k_hw_capabilities caps
Definition hw.h:664
struct list_head rxbuf
Definition ath9k.h:302
struct ath_descdma rxdma
Definition ath9k.h:303
u32 sc_flags
Definition ath9k.h:466
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53

References alloc_iob_raw(), ath9k_hw_common(), ath_descdma_setup(), ath_rx_cleanup(), ath_buf::bf_buf_addr, ath_buf::bf_mpdu, ath_hw::caps, common, io_buffer::data, DBG, DBG2, ENOMEM, error, IEEE80211_MAX_MPDU_LEN, ath_buf::list, list_for_each_entry, NULL, ath_softc::rx, ath9k_hw_capabilities::rx_status_len, ath_rx::rxbuf, ath_rx::rxdma, ath_rx::rxlink, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_RXFLUSH, and virt_to_bus().

Referenced by ath9k_init_device().

◆ ath_rx_cleanup()

void ath_rx_cleanup ( struct ath_softc * sc)

Definition at line 144 of file ath9k_recv.c.

145{
146 struct io_buffer *iob;
147 struct ath_buf *bf;
148
149 list_for_each_entry(bf, &sc->rx.rxbuf, list) {
150 iob = bf->bf_mpdu;
151 if (iob) {
152 free_iob(iob);
153 bf->bf_buf_addr = 0;
154 bf->bf_mpdu = NULL;
155 }
156 }
157
158 if (sc->rx.rxdma.dd_desc_len != 0)
159 ath_descdma_cleanup(sc, &sc->rx.rxdma, &sc->rx.rxbuf);
160}
void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd, struct list_head *head)
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
u32 dd_desc_len
Definition ath9k.h:109

References ath_descdma_cleanup(), ath_buf::bf_buf_addr, ath_buf::bf_mpdu, ath_descdma::dd_desc_len, free_iob(), ath_buf::list, list_for_each_entry, NULL, ath_softc::rx, ath_rx::rxbuf, and ath_rx::rxdma.

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

◆ ath_calcrxfilter()

u32 ath_calcrxfilter ( struct ath_softc * sc)

Definition at line 181 of file ath9k_recv.c.

182{
183#define RX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)
184
185 u32 rfilt;
186
190
191 return rfilt;
192
193#undef RX_FILTER_PRESERVE
194}
u32 ath9k_hw_getrxfilter(struct ath_hw *ah)
Definition ath9k_hw.c:1882
#define RX_FILTER_PRESERVE
@ ATH9K_RX_FILTER_BCAST
Definition mac.h:637
@ ATH9K_RX_FILTER_MCAST
Definition mac.h:636
@ ATH9K_RX_FILTER_UCAST
Definition mac.h:635
@ ATH9K_RX_FILTER_BEACON
Definition mac.h:639

References ath9k_hw_getrxfilter(), ATH9K_RX_FILTER_BCAST, ATH9K_RX_FILTER_BEACON, ATH9K_RX_FILTER_MCAST, ATH9K_RX_FILTER_UCAST, RX_FILTER_PRESERVE, ath_softc::sc_ah, and u32.

Referenced by ath_opmode_init().

◆ ath_startrecv()

int ath_startrecv ( struct ath_softc * sc)

Definition at line 196 of file ath9k_recv.c.

197{
198 struct ath_hw *ah = sc->sc_ah;
199 struct ath_buf *bf, *tbf;
200
201 if (list_empty(&sc->rx.rxbuf))
202 goto start_recv;
203
204 sc->rx.rxlink = NULL;
205 list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
206 ath_rx_buf_link(sc, bf);
207 }
208
209 /* We could have deleted elements so the list may be empty now */
210 if (list_empty(&sc->rx.rxbuf))
211 goto start_recv;
212
213 bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
216
217start_recv:
218 ath_opmode_init(sc);
220
221 return 0;
222}
#define SC_OP_OFFCHANNEL
Definition ath9k.h:367
void ath9k_hw_startpcureceive(struct ath_hw *ah, int is_scanning)
Definition ath9k_mac.c:526
static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
Definition ath9k_recv.c:35
static void ath_opmode_init(struct ath_softc *sc)
Definition ath9k_recv.c:77
static void ath9k_hw_rxena(struct ath_hw *ah)
Definition hw-ops.h:34
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition list.h:334
#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:459
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137

References ah, ath9k_hw_putrxbuf(), ath9k_hw_rxena(), ath9k_hw_startpcureceive(), ath_opmode_init(), ath_rx_buf_link(), ath_buf::bf_daddr, ath_buf::list, list_empty, list_first_entry, list_for_each_entry_safe, NULL, ath_softc::rx, ath_rx::rxbuf, ath_rx::rxlink, ath_softc::sc_ah, ath_softc::sc_flags, and SC_OP_OFFCHANNEL.

Referenced by ath9k_start(), ath_reset(), and ath_set_channel().

◆ ath_stoprecv()

int ath_stoprecv ( struct ath_softc * sc)

Definition at line 224 of file ath9k_recv.c.

225{
226 struct ath_hw *ah = sc->sc_ah;
227 int stopped, reset = 0;
228
231 stopped = ath9k_hw_stopdmarecv(ah, &reset);
232
233 sc->rx.rxlink = NULL;
234
235 if (!(ah->ah_flags & AH_UNPLUGGED) &&
236 !stopped) {
237 DBG("ath9k: "
238 "Could not stop RX, we could be "
239 "confusing the DMA engine when we start RX up\n");
240 }
241 return stopped && !reset;
242}
void ath9k_hw_abortpcurecv(struct ath_hw *ah)
Definition ath9k_mac.c:533
int ath9k_hw_stopdmarecv(struct ath_hw *ah, int *reset)
Definition ath9k_mac.c:538
#define AH_UNPLUGGED
Definition hw.h:655

References ah, AH_UNPLUGGED, ath9k_hw_abortpcurecv(), ath9k_hw_setrxfilter(), ath9k_hw_stopdmarecv(), DBG, NULL, ath_softc::rx, ath_rx::rxlink, and ath_softc::sc_ah.

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

◆ ath_flushrecv()

void ath_flushrecv ( struct ath_softc * sc)

Definition at line 244 of file ath9k_recv.c.

245{
246 sc->sc_flags |= SC_OP_RXFLUSH;
247 ath_rx_tasklet(sc, 1, 0);
249}
int ath_rx_tasklet(struct ath_softc *sc, int flush, int hp __unused)
Definition ath9k_recv.c:432

References ath_rx_tasklet(), ath_softc::sc_flags, and SC_OP_RXFLUSH.

Referenced by ath_radio_disable(), and ath_reset().

◆ ath_get_next_rx_buf()

struct ath_buf * ath_get_next_rx_buf ( struct ath_softc * sc,
struct ath_rx_status * rs )
static

Definition at line 251 of file ath9k_recv.c.

253{
254 struct ath_hw *ah = sc->sc_ah;
255 struct ath_desc *ds;
256 struct ath_buf *bf;
257 int ret;
258
259 if (list_empty(&sc->rx.rxbuf)) {
260 sc->rx.rxlink = NULL;
261 return NULL;
262 }
263
264 bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
265 ds = bf->bf_desc;
266
267 /*
268 * Must provide the virtual address of the current
269 * descriptor, the physical address, and the virtual
270 * address of the next descriptor in the h/w chain.
271 * This allows the HAL to look ahead to see if the
272 * hardware is done with a descriptor by checking the
273 * done bit in the following descriptor and the address
274 * of the current descriptor the DMA engine is working
275 * on. All this is necessary because of our use of
276 * a self-linked list to avoid rx overruns.
277 */
278 ret = ath9k_hw_rxprocdesc(ah, ds, rs, 0);
279 if (ret == -EINPROGRESS) {
280 struct ath_rx_status trs;
281 struct ath_buf *tbf;
282 struct ath_desc *tds;
283
284 memset(&trs, 0, sizeof(trs));
285 if ((&bf->list)->next == &sc->rx.rxbuf) {
286 sc->rx.rxlink = NULL;
287 return NULL;
288 }
289
290 tbf = list_entry(bf->list.next, struct ath_buf, list);
291
292 /*
293 * On some hardware the descriptor status words could
294 * get corrupted, including the done bit. Because of
295 * this, check if the next descriptor's done bit is
296 * set or not.
297 *
298 * If the next descriptor's done bit is set, the current
299 * descriptor has been corrupted. Force s/w to discard
300 * this descriptor and continue...
301 */
302
303 tds = tbf->bf_desc;
304 ret = ath9k_hw_rxprocdesc(ah, tds, &trs, 0);
305 if (ret == -EINPROGRESS)
306 return NULL;
307 }
308
309 if (!bf->bf_mpdu)
310 return bf;
311
312 return bf;
313}
int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds, struct ath_rx_status *rs, u64 tsf __unused)
Definition ath9k_mac.c:396
#define EINPROGRESS
Operation in progress.
Definition errno.h:419
void * memset(void *dest, int character, size_t len) __nonnull
#define list_entry(list, type, member)
Get the container of a list entry.
Definition list.h:322
struct list_head * next
Next list entry.
Definition list.h:21

References ah, ath9k_hw_rxprocdesc(), ath_buf::bf_desc, ath_buf::bf_mpdu, ds, EINPROGRESS, ath_buf::list, list_empty, list_entry, list_first_entry, memset(), list_head::next, NULL, ath_softc::rx, ath_rx::rxbuf, ath_rx::rxlink, and ath_softc::sc_ah.

Referenced by ath_rx_tasklet().

◆ ath9k_rx_accept()

int ath9k_rx_accept ( struct ath_common * common,
struct ath_rx_status * rx_stats,
int * decrypt_error )
static

Definition at line 316 of file ath9k_recv.c.

319{
320 struct ath_hw *ah = common->ah;
321 u8 rx_status_len = ah->caps.rx_status_len;
322
323
324 if (!rx_stats->rs_datalen)
325 return 0;
326 /*
327 * rs_status follows rs_datalen so if rs_datalen is too large
328 * we can take a hint that hardware corrupted it, so ignore
329 * those frames.
330 */
331 if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len))
332 return 0;
333
334 /* Only use error bits from the last fragment */
335 if (rx_stats->rs_more)
336 return 1;
337
338 /*
339 * The rx_stats->rs_status will not be set until the end of the
340 * chained descriptors so it can be ignored if rs_more is set. The
341 * rs_more will be false at the last element of the chained
342 * descriptors.
343 */
344 if (rx_stats->rs_status != 0) {
345 if (rx_stats->rs_status & ATH9K_RXERR_PHY)
346 return 0;
347
348 if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
349 *decrypt_error = 1;
350 }
351 /*
352 * Reject error frames with the exception of
353 * decryption and MIC failures. For monitor mode,
354 * we also ignore the CRC error.
355 */
356 if (ah->is_monitoring) {
357 if (rx_stats->rs_status &
360 return 0;
361 } else {
362 if (rx_stats->rs_status &
364 return 0;
365 }
366 }
367 }
368 return 1;
369}
#define u8
Definition igbvf_osdep.h:40
#define ATH9K_RXERR_DECRYPT
Definition mac.h:193
#define ATH9K_RXERR_MIC
Definition mac.h:194
#define ATH9K_RXERR_CRC
Definition mac.h:190
#define ATH9K_RXERR_PHY
Definition mac.h:191
u8 rs_more
Definition mac.h:146
u8 rs_status
Definition mac.h:140
u16 rs_datalen
Definition mac.h:139

References ah, ATH9K_RXERR_CRC, ATH9K_RXERR_DECRYPT, ATH9K_RXERR_MIC, ATH9K_RXERR_PHY, common, ath_rx_status::rs_datalen, ath_rx_status::rs_more, ath_rx_status::rs_status, and u8.

Referenced by ath9k_rx_iob_preprocess().

◆ ath9k_process_rate()

int ath9k_process_rate ( struct ath_common *common __unused,
struct net80211_device * dev,
struct ath_rx_status * rx_stats,
int * rix )
static

Definition at line 371 of file ath9k_recv.c.

375{
376 struct ath_softc *sc = (struct ath_softc *)dev->priv;
377 int band;
378 int i = 0;
379
380 band = (dev->channels + sc->dev->channel)->band;
381
382 for (i = 0; i < sc->hwinfo->nr_rates[band]; i++) {
383 if (sc->rates[i].hw_value == rx_stats->rs_rate) {
384 *rix = i;
385 return 0;
386 }
387 if (sc->rates[i].hw_value_short == rx_stats->rs_rate) {
388 *rix = i;
389 return 0;
390 }
391 }
392
393 /*
394 * No valid hardware bitrate found -- we should not get here
395 * because hardware has already validated this frame as OK.
396 */
397 DBG("ath9k: "
398 "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
399 rx_stats->rs_rate);
400
401 return -EINVAL;
402}
#define EINVAL
Invalid argument.
Definition errno.h:429
u8 rs_rate
Definition mac.h:144
struct net80211_device * dev
Definition ath9k.h:446
struct net80211_channel channels[NET80211_MAX_CHANNELS]
A list of all possible channels we might use.
Definition net80211.h:806
void * priv
Driver private data.
Definition net80211.h:798

References __unused, net80211_device::channel, net80211_device::channels, common, DBG, ath_softc::dev, EINVAL, ath9k_legacy_rate::hw_value, ath9k_legacy_rate::hw_value_short, ath_softc::hwinfo, net80211_hw_info::nr_rates, net80211_device::priv, ath_softc::rates, and ath_rx_status::rs_rate.

Referenced by ath9k_rx_iob_preprocess().

◆ ath9k_rx_iob_preprocess()

int ath9k_rx_iob_preprocess ( struct ath_common * common,
struct net80211_device * dev,
struct ath_rx_status * rx_stats,
int * rix,
int * decrypt_error )
static

Definition at line 409 of file ath9k_recv.c.

414{
415 /*
416 * everything but the rate is checked here, the rate check is done
417 * separately to avoid doing two lookups for a rate for each frame.
418 */
419 if (!ath9k_rx_accept(common, rx_stats, decrypt_error))
420 return -EINVAL;
421
422 /* Only use status info from the last fragment */
423 if (rx_stats->rs_more)
424 return 0;
425
426 if (ath9k_process_rate(common, dev, rx_stats, rix))
427 return -EINVAL;
428
429 return 0;
430}
static int ath9k_process_rate(struct ath_common *common __unused, struct net80211_device *dev, struct ath_rx_status *rx_stats, int *rix)
Definition ath9k_recv.c:371
static int ath9k_rx_accept(struct ath_common *common, struct ath_rx_status *rx_stats, int *decrypt_error)
Definition ath9k_recv.c:316

References ath9k_process_rate(), ath9k_rx_accept(), common, ath_softc::dev, EINVAL, and ath_rx_status::rs_more.

Referenced by ath_rx_tasklet().

◆ ath_rx_tasklet()

int ath_rx_tasklet ( struct ath_softc * sc,
int flush,
int hp __unused )

Definition at line 432 of file ath9k_recv.c.

433{
434 struct ath_buf *bf;
435 struct io_buffer *iob = NULL, *requeue_iob;
436 struct ath_hw *ah = sc->sc_ah;
438 /*
439 * The hw can technically differ from common->hw when using ath9k
440 * virtual wiphy so to account for that we iterate over the active
441 * wiphys and find the appropriate wiphy and therefore hw.
442 */
443 struct net80211_device *dev = sc->dev;
444 int retval;
445 int decrypt_error = 0;
446 struct ath_rx_status rs;
447 int rix = 0;
448
449 do {
450 /* If handling rx interrupt and flush is in progress => exit */
451 if ((sc->sc_flags & SC_OP_RXFLUSH) && (flush == 0))
452 break;
453
454 memset(&rs, 0, sizeof(rs));
455 bf = ath_get_next_rx_buf(sc, &rs);
456
457 if (!bf)
458 break;
459
460 iob = bf->bf_mpdu;
461 if (!iob)
462 continue;
463
464 /*
465 * If we're asked to flush receive queue, directly
466 * chain it back at the queue without processing it.
467 */
468 if (flush)
469 goto requeue_drop_frag;
470
472 &rix, &decrypt_error);
473 if (retval)
474 goto requeue_drop_frag;
475
476 /* Ensure we always have an iob to requeue once we are done
477 * processing the current buffer's iob */
478 requeue_iob = alloc_iob_raw ( common->rx_bufsize,
479 common->cachelsz, 0 );
480
481 /* If there is no memory we ignore the current RX'd frame,
482 * tell hardware it can give us a new frame using the old
483 * iob and put it at the tail of the sc->rx.rxbuf list for
484 * processing. */
485 if (!requeue_iob)
486 goto requeue_drop_frag;
487
488 iob_put(iob, rs.rs_datalen + ah->caps.rx_status_len);
489 if (ah->caps.rx_status_len)
490 iob_pull(iob, ah->caps.rx_status_len);
491
492 /* We will now give hardware our shiny new allocated iob */
493 bf->bf_mpdu = requeue_iob;
494 bf->bf_buf_addr = virt_to_bus ( requeue_iob->data );
495
496 /*
497 * change the default rx antenna if rx diversity chooses the
498 * other antenna 3 times in a row.
499 */
500 if (sc->rx.defant != rs.rs_antenna) {
501 if (++sc->rx.rxotherant >= 3)
502 ath_setdefantenna(sc, rs.rs_antenna);
503 } else {
504 sc->rx.rxotherant = 0;
505 }
506
507 DBGIO("ath9k: rx %d bytes, signal %d, bitrate %d, hw_value %d\n", rs.rs_datalen,
508 rs.rs_rssi, sc->rates[rix].bitrate, rs.rs_rate);
509
510 net80211_rx(dev, iob, rs.rs_rssi,
511 sc->rates[rix].bitrate);
512
513requeue_drop_frag:
514 list_del(&bf->list);
515 list_add_tail(&bf->list, &sc->rx.rxbuf);
516 ath_rx_buf_link(sc, bf);
518 } while (1);
519
520 return 0;
521}
unsigned long retval
Definition xen.h:46
static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
Definition ath9k_recv.c:69
static struct ath_buf * ath_get_next_rx_buf(struct ath_softc *sc, struct ath_rx_status *rs)
Definition ath9k_recv.c:251
static int ath9k_rx_iob_preprocess(struct ath_common *common, struct net80211_device *dev, struct ath_rx_status *rx_stats, int *rix, int *decrypt_error)
Definition ath9k_recv.c:409
#define DBGIO(...)
Definition compiler.h:549
void net80211_rx(struct net80211_device *dev, struct io_buffer *iob, int signal, u16 rate)
Handle receipt of 802.11 frame.
Definition net80211.c:2690
#define iob_put(iobuf, len)
Definition iobuf.h:125
#define iob_pull(iobuf, len)
Definition iobuf.h:107
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition list.h:94
#define list_del(list)
Delete an entry from a list.
Definition list.h:120
struct ath9k_legacy_rate rates[NET80211_MAX_RATES]
Definition ath9k.h:479
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787

References __unused, ah, alloc_iob_raw(), ath9k_hw_common(), ath9k_hw_rxena(), ath9k_rx_iob_preprocess(), ath_get_next_rx_buf(), ath_rx_buf_link(), ath_setdefantenna(), ath_buf::bf_buf_addr, ath_buf::bf_mpdu, ath9k_legacy_rate::bitrate, common, DBGIO, ath_rx::defant, ath_softc::dev, iob_pull, iob_put, ath_buf::list, list_add_tail, list_del, memset(), net80211_rx(), NULL, ath_softc::rates, retval, ath_rx_status::rs_antenna, ath_rx_status::rs_datalen, ath_rx_status::rs_rate, ath_rx_status::rs_rssi, ath_softc::rx, ath_rx::rxbuf, ath_rx::rxotherant, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_RXFLUSH, and virt_to_bus().

Referenced by ath9k_tasklet(), and ath_flushrecv().