You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ath5k_desc.c 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
  3. * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
  4. * Copyright (c) 2007-2008 Pavel Roskin <proski@gnu.org>
  5. *
  6. * Lightly modified for iPXE, July 2009, by Joshua Oreman <oremanj@rwcr.net>.
  7. *
  8. * Permission to use, copy, modify, and distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. *
  20. */
  21. FILE_LICENCE ( MIT );
  22. /******************************\
  23. Hardware Descriptor Functions
  24. \******************************/
  25. #include "ath5k.h"
  26. #include "reg.h"
  27. #include "base.h"
  28. /*
  29. * TX Descriptors
  30. */
  31. #define FCS_LEN 4
  32. /*
  33. * Initialize the 2-word tx control descriptor on 5210/5211
  34. */
  35. static int
  36. ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
  37. unsigned int pkt_len, unsigned int hdr_len, enum ath5k_pkt_type type,
  38. unsigned int tx_power __unused, unsigned int tx_rate0, unsigned int tx_tries0,
  39. unsigned int key_index __unused, unsigned int antenna_mode, unsigned int flags,
  40. unsigned int rtscts_rate __unused, unsigned int rtscts_duration)
  41. {
  42. u32 frame_type;
  43. struct ath5k_hw_2w_tx_ctl *tx_ctl;
  44. unsigned int frame_len;
  45. tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
  46. /*
  47. * Validate input
  48. * - Zero retries don't make sense.
  49. * - A zero rate will put the HW into a mode where it continously sends
  50. * noise on the channel, so it is important to avoid this.
  51. */
  52. if (tx_tries0 == 0) {
  53. DBG("ath5k: zero retries\n");
  54. return -EINVAL;
  55. }
  56. if (tx_rate0 == 0) {
  57. DBG("ath5k: zero rate\n");
  58. return -EINVAL;
  59. }
  60. /* Clear descriptor */
  61. memset(&desc->ud.ds_tx5210, 0, sizeof(struct ath5k_hw_5210_tx_desc));
  62. /* Setup control descriptor */
  63. /* Verify and set frame length */
  64. frame_len = pkt_len + FCS_LEN;
  65. if (frame_len & ~AR5K_2W_TX_DESC_CTL0_FRAME_LEN)
  66. return -EINVAL;
  67. tx_ctl->tx_control_0 = frame_len & AR5K_2W_TX_DESC_CTL0_FRAME_LEN;
  68. /* Verify and set buffer length */
  69. if (pkt_len & ~AR5K_2W_TX_DESC_CTL1_BUF_LEN)
  70. return -EINVAL;
  71. tx_ctl->tx_control_1 = pkt_len & AR5K_2W_TX_DESC_CTL1_BUF_LEN;
  72. /*
  73. * Verify and set header length
  74. * XXX: I only found that on 5210 code, does it work on 5211 ?
  75. */
  76. if (ah->ah_version == AR5K_AR5210) {
  77. if (hdr_len & ~AR5K_2W_TX_DESC_CTL0_HEADER_LEN)
  78. return -EINVAL;
  79. tx_ctl->tx_control_0 |=
  80. AR5K_REG_SM(hdr_len, AR5K_2W_TX_DESC_CTL0_HEADER_LEN);
  81. }
  82. /*Diferences between 5210-5211*/
  83. if (ah->ah_version == AR5K_AR5210) {
  84. switch (type) {
  85. case AR5K_PKT_TYPE_BEACON:
  86. case AR5K_PKT_TYPE_PROBE_RESP:
  87. frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_NO_DELAY;
  88. break;
  89. case AR5K_PKT_TYPE_PIFS:
  90. frame_type = AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS;
  91. break;
  92. default:
  93. frame_type = type /*<< 2 ?*/;
  94. break;
  95. }
  96. tx_ctl->tx_control_0 |=
  97. AR5K_REG_SM(frame_type, AR5K_2W_TX_DESC_CTL0_FRAME_TYPE) |
  98. AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
  99. } else {
  100. tx_ctl->tx_control_0 |=
  101. AR5K_REG_SM(tx_rate0, AR5K_2W_TX_DESC_CTL0_XMIT_RATE) |
  102. AR5K_REG_SM(antenna_mode,
  103. AR5K_2W_TX_DESC_CTL0_ANT_MODE_XMIT);
  104. tx_ctl->tx_control_1 |=
  105. AR5K_REG_SM(type, AR5K_2W_TX_DESC_CTL1_FRAME_TYPE);
  106. }
  107. #define _TX_FLAGS(_c, _flag) \
  108. if (flags & AR5K_TXDESC_##_flag) { \
  109. tx_ctl->tx_control_##_c |= \
  110. AR5K_2W_TX_DESC_CTL##_c##_##_flag; \
  111. }
  112. _TX_FLAGS(0, CLRDMASK);
  113. _TX_FLAGS(0, VEOL);
  114. _TX_FLAGS(0, INTREQ);
  115. _TX_FLAGS(0, RTSENA);
  116. _TX_FLAGS(1, NOACK);
  117. #undef _TX_FLAGS
  118. /*
  119. * RTS/CTS Duration [5210 ?]
  120. */
  121. if ((ah->ah_version == AR5K_AR5210) &&
  122. (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)))
  123. tx_ctl->tx_control_1 |= rtscts_duration &
  124. AR5K_2W_TX_DESC_CTL1_RTS_DURATION;
  125. return 0;
  126. }
  127. /*
  128. * Initialize the 4-word tx control descriptor on 5212
  129. */
  130. static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah,
  131. struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len __unused,
  132. enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0,
  133. unsigned int tx_tries0, unsigned int key_index __unused,
  134. unsigned int antenna_mode, unsigned int flags,
  135. unsigned int rtscts_rate,
  136. unsigned int rtscts_duration)
  137. {
  138. struct ath5k_hw_4w_tx_ctl *tx_ctl;
  139. unsigned int frame_len;
  140. tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
  141. /*
  142. * Validate input
  143. * - Zero retries don't make sense.
  144. * - A zero rate will put the HW into a mode where it continously sends
  145. * noise on the channel, so it is important to avoid this.
  146. */
  147. if (tx_tries0 == 0) {
  148. DBG("ath5k: zero retries\n");
  149. return -EINVAL;
  150. }
  151. if (tx_rate0 == 0) {
  152. DBG("ath5k: zero rate\n");
  153. return -EINVAL;
  154. }
  155. tx_power += ah->ah_txpower.txp_offset;
  156. if (tx_power > AR5K_TUNE_MAX_TXPOWER)
  157. tx_power = AR5K_TUNE_MAX_TXPOWER;
  158. /* Clear descriptor */
  159. memset(&desc->ud.ds_tx5212, 0, sizeof(struct ath5k_hw_5212_tx_desc));
  160. /* Setup control descriptor */
  161. /* Verify and set frame length */
  162. frame_len = pkt_len + FCS_LEN;
  163. if (frame_len & ~AR5K_4W_TX_DESC_CTL0_FRAME_LEN)
  164. return -EINVAL;
  165. tx_ctl->tx_control_0 = frame_len & AR5K_4W_TX_DESC_CTL0_FRAME_LEN;
  166. /* Verify and set buffer length */
  167. if (pkt_len & ~AR5K_4W_TX_DESC_CTL1_BUF_LEN)
  168. return -EINVAL;
  169. tx_ctl->tx_control_1 = pkt_len & AR5K_4W_TX_DESC_CTL1_BUF_LEN;
  170. tx_ctl->tx_control_0 |=
  171. AR5K_REG_SM(tx_power, AR5K_4W_TX_DESC_CTL0_XMIT_POWER) |
  172. AR5K_REG_SM(antenna_mode, AR5K_4W_TX_DESC_CTL0_ANT_MODE_XMIT);
  173. tx_ctl->tx_control_1 |= AR5K_REG_SM(type,
  174. AR5K_4W_TX_DESC_CTL1_FRAME_TYPE);
  175. tx_ctl->tx_control_2 = AR5K_REG_SM(tx_tries0 + AR5K_TUNE_HWTXTRIES,
  176. AR5K_4W_TX_DESC_CTL2_XMIT_TRIES0);
  177. tx_ctl->tx_control_3 = tx_rate0 & AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
  178. #define _TX_FLAGS(_c, _flag) \
  179. if (flags & AR5K_TXDESC_##_flag) { \
  180. tx_ctl->tx_control_##_c |= \
  181. AR5K_4W_TX_DESC_CTL##_c##_##_flag; \
  182. }
  183. _TX_FLAGS(0, CLRDMASK);
  184. _TX_FLAGS(0, VEOL);
  185. _TX_FLAGS(0, INTREQ);
  186. _TX_FLAGS(0, RTSENA);
  187. _TX_FLAGS(0, CTSENA);
  188. _TX_FLAGS(1, NOACK);
  189. #undef _TX_FLAGS
  190. /*
  191. * RTS/CTS
  192. */
  193. if (flags & (AR5K_TXDESC_RTSENA | AR5K_TXDESC_CTSENA)) {
  194. if ((flags & AR5K_TXDESC_RTSENA) &&
  195. (flags & AR5K_TXDESC_CTSENA))
  196. return -EINVAL;
  197. tx_ctl->tx_control_2 |= rtscts_duration &
  198. AR5K_4W_TX_DESC_CTL2_RTS_DURATION;
  199. tx_ctl->tx_control_3 |= AR5K_REG_SM(rtscts_rate,
  200. AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE);
  201. }
  202. return 0;
  203. }
  204. /*
  205. * Proccess the tx status descriptor on 5210/5211
  206. */
  207. static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah __unused,
  208. struct ath5k_desc *desc, struct ath5k_tx_status *ts)
  209. {
  210. struct ath5k_hw_2w_tx_ctl *tx_ctl;
  211. struct ath5k_hw_tx_status *tx_status;
  212. tx_ctl = &desc->ud.ds_tx5210.tx_ctl;
  213. tx_status = &desc->ud.ds_tx5210.tx_stat;
  214. /* No frame has been send or error */
  215. if ((tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE) == 0)
  216. return -EINPROGRESS;
  217. /*
  218. * Get descriptor status
  219. */
  220. ts->ts_tstamp = AR5K_REG_MS(tx_status->tx_status_0,
  221. AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
  222. ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
  223. AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
  224. ts->ts_longretry = AR5K_REG_MS(tx_status->tx_status_0,
  225. AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
  226. /*TODO: ts->ts_virtcol + test*/
  227. ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
  228. AR5K_DESC_TX_STATUS1_SEQ_NUM);
  229. ts->ts_rssi = AR5K_REG_MS(tx_status->tx_status_1,
  230. AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
  231. ts->ts_antenna = 1;
  232. ts->ts_status = 0;
  233. ts->ts_rate[0] = AR5K_REG_MS(tx_ctl->tx_control_0,
  234. AR5K_2W_TX_DESC_CTL0_XMIT_RATE);
  235. ts->ts_retry[0] = ts->ts_longretry;
  236. ts->ts_final_idx = 0;
  237. if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
  238. if (tx_status->tx_status_0 &
  239. AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
  240. ts->ts_status |= AR5K_TXERR_XRETRY;
  241. if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
  242. ts->ts_status |= AR5K_TXERR_FIFO;
  243. if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FILTERED)
  244. ts->ts_status |= AR5K_TXERR_FILT;
  245. }
  246. return 0;
  247. }
  248. /*
  249. * Proccess a tx status descriptor on 5212
  250. */
  251. static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah __unused,
  252. struct ath5k_desc *desc, struct ath5k_tx_status *ts)
  253. {
  254. struct ath5k_hw_4w_tx_ctl *tx_ctl;
  255. struct ath5k_hw_tx_status *tx_status;
  256. tx_ctl = &desc->ud.ds_tx5212.tx_ctl;
  257. tx_status = &desc->ud.ds_tx5212.tx_stat;
  258. /* No frame has been send or error */
  259. if (!(tx_status->tx_status_1 & AR5K_DESC_TX_STATUS1_DONE))
  260. return -EINPROGRESS;
  261. /*
  262. * Get descriptor status
  263. */
  264. ts->ts_tstamp = AR5K_REG_MS(tx_status->tx_status_0,
  265. AR5K_DESC_TX_STATUS0_SEND_TIMESTAMP);
  266. ts->ts_shortretry = AR5K_REG_MS(tx_status->tx_status_0,
  267. AR5K_DESC_TX_STATUS0_SHORT_RETRY_COUNT);
  268. ts->ts_longretry = AR5K_REG_MS(tx_status->tx_status_0,
  269. AR5K_DESC_TX_STATUS0_LONG_RETRY_COUNT);
  270. ts->ts_seqnum = AR5K_REG_MS(tx_status->tx_status_1,
  271. AR5K_DESC_TX_STATUS1_SEQ_NUM);
  272. ts->ts_rssi = AR5K_REG_MS(tx_status->tx_status_1,
  273. AR5K_DESC_TX_STATUS1_ACK_SIG_STRENGTH);
  274. ts->ts_antenna = (tx_status->tx_status_1 &
  275. AR5K_DESC_TX_STATUS1_XMIT_ANTENNA) ? 2 : 1;
  276. ts->ts_status = 0;
  277. ts->ts_final_idx = AR5K_REG_MS(tx_status->tx_status_1,
  278. AR5K_DESC_TX_STATUS1_FINAL_TS_INDEX);
  279. ts->ts_retry[0] = ts->ts_longretry;
  280. ts->ts_rate[0] = tx_ctl->tx_control_3 &
  281. AR5K_4W_TX_DESC_CTL3_XMIT_RATE0;
  282. /* TX error */
  283. if (!(tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FRAME_XMIT_OK)) {
  284. if (tx_status->tx_status_0 &
  285. AR5K_DESC_TX_STATUS0_EXCESSIVE_RETRIES)
  286. ts->ts_status |= AR5K_TXERR_XRETRY;
  287. if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FIFO_UNDERRUN)
  288. ts->ts_status |= AR5K_TXERR_FIFO;
  289. if (tx_status->tx_status_0 & AR5K_DESC_TX_STATUS0_FILTERED)
  290. ts->ts_status |= AR5K_TXERR_FILT;
  291. }
  292. return 0;
  293. }
  294. /*
  295. * RX Descriptors
  296. */
  297. /*
  298. * Initialize an rx control descriptor
  299. */
  300. static int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah __unused,
  301. struct ath5k_desc *desc,
  302. u32 size, unsigned int flags)
  303. {
  304. struct ath5k_hw_rx_ctl *rx_ctl;
  305. rx_ctl = &desc->ud.ds_rx.rx_ctl;
  306. /*
  307. * Clear the descriptor
  308. * If we don't clean the status descriptor,
  309. * while scanning we get too many results,
  310. * most of them virtual, after some secs
  311. * of scanning system hangs. M.F.
  312. */
  313. memset(&desc->ud.ds_rx, 0, sizeof(struct ath5k_hw_all_rx_desc));
  314. /* Setup descriptor */
  315. rx_ctl->rx_control_1 = size & AR5K_DESC_RX_CTL1_BUF_LEN;
  316. if (rx_ctl->rx_control_1 != size)
  317. return -EINVAL;
  318. if (flags & AR5K_RXDESC_INTREQ)
  319. rx_ctl->rx_control_1 |= AR5K_DESC_RX_CTL1_INTREQ;
  320. return 0;
  321. }
  322. /*
  323. * Proccess the rx status descriptor on 5210/5211
  324. */
  325. static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah __unused,
  326. struct ath5k_desc *desc, struct ath5k_rx_status *rs)
  327. {
  328. struct ath5k_hw_rx_status *rx_status;
  329. rx_status = &desc->ud.ds_rx.u.rx_stat;
  330. /* No frame received / not ready */
  331. if (!(rx_status->rx_status_1 & AR5K_5210_RX_DESC_STATUS1_DONE))
  332. return -EINPROGRESS;
  333. /*
  334. * Frame receive status
  335. */
  336. rs->rs_datalen = rx_status->rx_status_0 &
  337. AR5K_5210_RX_DESC_STATUS0_DATA_LEN;
  338. rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
  339. AR5K_5210_RX_DESC_STATUS0_RECEIVE_SIGNAL);
  340. rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
  341. AR5K_5210_RX_DESC_STATUS0_RECEIVE_RATE);
  342. rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
  343. AR5K_5210_RX_DESC_STATUS0_RECEIVE_ANTENNA);
  344. rs->rs_more = !!(rx_status->rx_status_0 &
  345. AR5K_5210_RX_DESC_STATUS0_MORE);
  346. /* TODO: this timestamp is 13 bit, later on we assume 15 bit */
  347. rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
  348. AR5K_5210_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
  349. rs->rs_status = 0;
  350. rs->rs_phyerr = 0;
  351. rs->rs_keyix = AR5K_RXKEYIX_INVALID;
  352. /*
  353. * Receive/descriptor errors
  354. */
  355. if (!(rx_status->rx_status_1 &
  356. AR5K_5210_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
  357. if (rx_status->rx_status_1 &
  358. AR5K_5210_RX_DESC_STATUS1_CRC_ERROR)
  359. rs->rs_status |= AR5K_RXERR_CRC;
  360. if (rx_status->rx_status_1 &
  361. AR5K_5210_RX_DESC_STATUS1_FIFO_OVERRUN)
  362. rs->rs_status |= AR5K_RXERR_FIFO;
  363. if (rx_status->rx_status_1 &
  364. AR5K_5210_RX_DESC_STATUS1_PHY_ERROR) {
  365. rs->rs_status |= AR5K_RXERR_PHY;
  366. rs->rs_phyerr |= AR5K_REG_MS(rx_status->rx_status_1,
  367. AR5K_5210_RX_DESC_STATUS1_PHY_ERROR);
  368. }
  369. if (rx_status->rx_status_1 &
  370. AR5K_5210_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
  371. rs->rs_status |= AR5K_RXERR_DECRYPT;
  372. }
  373. return 0;
  374. }
  375. /*
  376. * Proccess the rx status descriptor on 5212
  377. */
  378. static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah __unused,
  379. struct ath5k_desc *desc, struct ath5k_rx_status *rs)
  380. {
  381. struct ath5k_hw_rx_status *rx_status;
  382. struct ath5k_hw_rx_error *rx_err;
  383. rx_status = &desc->ud.ds_rx.u.rx_stat;
  384. /* Overlay on error */
  385. rx_err = &desc->ud.ds_rx.u.rx_err;
  386. /* No frame received / not ready */
  387. if (!(rx_status->rx_status_1 & AR5K_5212_RX_DESC_STATUS1_DONE))
  388. return -EINPROGRESS;
  389. /*
  390. * Frame receive status
  391. */
  392. rs->rs_datalen = rx_status->rx_status_0 &
  393. AR5K_5212_RX_DESC_STATUS0_DATA_LEN;
  394. rs->rs_rssi = AR5K_REG_MS(rx_status->rx_status_0,
  395. AR5K_5212_RX_DESC_STATUS0_RECEIVE_SIGNAL);
  396. rs->rs_rate = AR5K_REG_MS(rx_status->rx_status_0,
  397. AR5K_5212_RX_DESC_STATUS0_RECEIVE_RATE);
  398. rs->rs_antenna = AR5K_REG_MS(rx_status->rx_status_0,
  399. AR5K_5212_RX_DESC_STATUS0_RECEIVE_ANTENNA);
  400. rs->rs_more = !!(rx_status->rx_status_0 &
  401. AR5K_5212_RX_DESC_STATUS0_MORE);
  402. rs->rs_tstamp = AR5K_REG_MS(rx_status->rx_status_1,
  403. AR5K_5212_RX_DESC_STATUS1_RECEIVE_TIMESTAMP);
  404. rs->rs_status = 0;
  405. rs->rs_phyerr = 0;
  406. rs->rs_keyix = AR5K_RXKEYIX_INVALID;
  407. /*
  408. * Receive/descriptor errors
  409. */
  410. if (!(rx_status->rx_status_1 &
  411. AR5K_5212_RX_DESC_STATUS1_FRAME_RECEIVE_OK)) {
  412. if (rx_status->rx_status_1 &
  413. AR5K_5212_RX_DESC_STATUS1_CRC_ERROR)
  414. rs->rs_status |= AR5K_RXERR_CRC;
  415. if (rx_status->rx_status_1 &
  416. AR5K_5212_RX_DESC_STATUS1_PHY_ERROR) {
  417. rs->rs_status |= AR5K_RXERR_PHY;
  418. rs->rs_phyerr |= AR5K_REG_MS(rx_err->rx_error_1,
  419. AR5K_RX_DESC_ERROR1_PHY_ERROR_CODE);
  420. }
  421. if (rx_status->rx_status_1 &
  422. AR5K_5212_RX_DESC_STATUS1_DECRYPT_CRC_ERROR)
  423. rs->rs_status |= AR5K_RXERR_DECRYPT;
  424. if (rx_status->rx_status_1 &
  425. AR5K_5212_RX_DESC_STATUS1_MIC_ERROR)
  426. rs->rs_status |= AR5K_RXERR_MIC;
  427. }
  428. return 0;
  429. }
  430. /*
  431. * Init function pointers inside ath5k_hw struct
  432. */
  433. int ath5k_hw_init_desc_functions(struct ath5k_hw *ah)
  434. {
  435. if (ah->ah_version != AR5K_AR5210 &&
  436. ah->ah_version != AR5K_AR5211 &&
  437. ah->ah_version != AR5K_AR5212)
  438. return -ENOTSUP;
  439. if (ah->ah_version == AR5K_AR5212) {
  440. ah->ah_setup_rx_desc = ath5k_hw_setup_rx_desc;
  441. ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc;
  442. ah->ah_proc_tx_desc = ath5k_hw_proc_4word_tx_status;
  443. } else {
  444. ah->ah_setup_rx_desc = ath5k_hw_setup_rx_desc;
  445. ah->ah_setup_tx_desc = ath5k_hw_setup_2word_tx_desc;
  446. ah->ah_proc_tx_desc = ath5k_hw_proc_2word_tx_status;
  447. }
  448. if (ah->ah_version == AR5K_AR5212)
  449. ah->ah_proc_rx_desc = ath5k_hw_proc_5212_rx_status;
  450. else if (ah->ah_version <= AR5K_AR5211)
  451. ah->ah_proc_rx_desc = ath5k_hw_proc_5210_rx_status;
  452. return 0;
  453. }