xmit.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef B43legacy_XMIT_H_
  3. #define B43legacy_XMIT_H_
  4. #include "main.h"
  5. #define _b43legacy_declare_plcp_hdr(size) \
  6. struct b43legacy_plcp_hdr##size { \
  7. union { \
  8. __le32 data; \
  9. __u8 raw[size]; \
  10. } __packed; \
  11. } __packed
  12. /* struct b43legacy_plcp_hdr4 */
  13. _b43legacy_declare_plcp_hdr(4);
  14. /* struct b43legacy_plcp_hdr6 */
  15. _b43legacy_declare_plcp_hdr(6);
  16. #undef _b43legacy_declare_plcp_hdr
  17. /* TX header for v3 firmware */
  18. struct b43legacy_txhdr_fw3 {
  19. __le32 mac_ctl; /* MAC TX control */
  20. __le16 mac_frame_ctl; /* Copy of the FrameControl */
  21. __le16 tx_fes_time_norm; /* TX FES Time Normal */
  22. __le16 phy_ctl; /* PHY TX control */
  23. __u8 iv[16]; /* Encryption IV */
  24. __u8 tx_receiver[6]; /* TX Frame Receiver address */
  25. __le16 tx_fes_time_fb; /* TX FES Time Fallback */
  26. struct b43legacy_plcp_hdr4 rts_plcp_fb; /* RTS fallback PLCP */
  27. __le16 rts_dur_fb; /* RTS fallback duration */
  28. struct b43legacy_plcp_hdr4 plcp_fb; /* Fallback PLCP */
  29. __le16 dur_fb; /* Fallback duration */
  30. PAD_BYTES(2);
  31. __le16 cookie;
  32. __le16 unknown_scb_stuff;
  33. struct b43legacy_plcp_hdr6 rts_plcp; /* RTS PLCP */
  34. __u8 rts_frame[18]; /* The RTS frame (if used) */
  35. struct b43legacy_plcp_hdr6 plcp;
  36. } __packed;
  37. /* MAC TX control */
  38. #define B43legacy_TX4_MAC_KEYIDX 0x0FF00000 /* Security key index */
  39. #define B43legacy_TX4_MAC_KEYIDX_SHIFT 20
  40. #define B43legacy_TX4_MAC_KEYALG 0x00070000 /* Security key algorithm */
  41. #define B43legacy_TX4_MAC_KEYALG_SHIFT 16
  42. #define B43legacy_TX4_MAC_LIFETIME 0x00001000
  43. #define B43legacy_TX4_MAC_FRAMEBURST 0x00000800
  44. #define B43legacy_TX4_MAC_SENDCTS 0x00000400
  45. #define B43legacy_TX4_MAC_AMPDU 0x00000300
  46. #define B43legacy_TX4_MAC_AMPDU_SHIFT 8
  47. #define B43legacy_TX4_MAC_CTSFALLBACKOFDM 0x00000200
  48. #define B43legacy_TX4_MAC_FALLBACKOFDM 0x00000100
  49. #define B43legacy_TX4_MAC_5GHZ 0x00000080
  50. #define B43legacy_TX4_MAC_IGNPMQ 0x00000020
  51. #define B43legacy_TX4_MAC_HWSEQ 0x00000010 /* Use Hardware Seq No */
  52. #define B43legacy_TX4_MAC_STMSDU 0x00000008 /* Start MSDU */
  53. #define B43legacy_TX4_MAC_SENDRTS 0x00000004
  54. #define B43legacy_TX4_MAC_LONGFRAME 0x00000002
  55. #define B43legacy_TX4_MAC_ACK 0x00000001
  56. /* Extra Frame Types */
  57. #define B43legacy_TX4_EFT_FBOFDM 0x0001 /* Data frame fb rate type */
  58. #define B43legacy_TX4_EFT_RTSOFDM 0x0004 /* RTS/CTS rate type */
  59. #define B43legacy_TX4_EFT_RTSFBOFDM 0x0010 /* RTS/CTS fallback rate type */
  60. /* PHY TX control word */
  61. #define B43legacy_TX4_PHY_ENC 0x0003 /* Data frame encoding */
  62. #define B43legacy_TX4_PHY_ENC_CCK 0x0000 /* CCK */
  63. #define B43legacy_TX4_PHY_ENC_OFDM 0x0001 /* Data frame rate type */
  64. #define B43legacy_TX4_PHY_SHORTPRMBL 0x0010 /* Use short preamble */
  65. #define B43legacy_TX4_PHY_ANT 0x03C0 /* Antenna selection */
  66. #define B43legacy_TX4_PHY_ANT0 0x0000 /* Use antenna 0 */
  67. #define B43legacy_TX4_PHY_ANT1 0x0100 /* Use antenna 1 */
  68. #define B43legacy_TX4_PHY_ANTLAST 0x0300 /* Use last used antenna */
  69. int b43legacy_generate_txhdr(struct b43legacy_wldev *dev,
  70. u8 *txhdr,
  71. const unsigned char *fragment_data,
  72. unsigned int fragment_len,
  73. struct ieee80211_tx_info *info,
  74. u16 cookie);
  75. /* Transmit Status */
  76. struct b43legacy_txstatus {
  77. u16 cookie; /* The cookie from the txhdr */
  78. u16 seq; /* Sequence number */
  79. u8 phy_stat; /* PHY TX status */
  80. u8 frame_count; /* Frame transmit count */
  81. u8 rts_count; /* RTS transmit count */
  82. u8 supp_reason; /* Suppression reason */
  83. /* flags */
  84. u8 pm_indicated;/* PM mode indicated to AP */
  85. u8 intermediate;/* Intermediate status notification */
  86. u8 for_ampdu; /* Status is for an AMPDU (afterburner) */
  87. u8 acked; /* Wireless ACK received */
  88. };
  89. /* txstatus supp_reason values */
  90. enum {
  91. B43legacy_TXST_SUPP_NONE, /* Not suppressed */
  92. B43legacy_TXST_SUPP_PMQ, /* Suppressed due to PMQ entry */
  93. B43legacy_TXST_SUPP_FLUSH, /* Suppressed due to flush request */
  94. B43legacy_TXST_SUPP_PREV, /* Previous fragment failed */
  95. B43legacy_TXST_SUPP_CHAN, /* Channel mismatch */
  96. B43legacy_TXST_SUPP_LIFE, /* Lifetime expired */
  97. B43legacy_TXST_SUPP_UNDER, /* Buffer underflow */
  98. B43legacy_TXST_SUPP_ABNACK, /* Afterburner NACK */
  99. };
  100. /* Transmit Status as received through DMA/PIO on old chips */
  101. struct b43legacy_hwtxstatus {
  102. PAD_BYTES(4);
  103. __le16 cookie;
  104. u8 flags;
  105. u8 count;
  106. PAD_BYTES(2);
  107. __le16 seq;
  108. u8 phy_stat;
  109. PAD_BYTES(1);
  110. } __packed;
  111. /* Receive header for v3 firmware. */
  112. struct b43legacy_rxhdr_fw3 {
  113. __le16 frame_len; /* Frame length */
  114. PAD_BYTES(2);
  115. __le16 phy_status0; /* PHY RX Status 0 */
  116. __u8 jssi; /* PHY RX Status 1: JSSI */
  117. __u8 sig_qual; /* PHY RX Status 1: Signal Quality */
  118. PAD_BYTES(2); /* PHY RX Status 2 */
  119. __le16 phy_status3; /* PHY RX Status 3 */
  120. __le16 mac_status; /* MAC RX status */
  121. __le16 mac_time;
  122. __le16 channel;
  123. } __packed;
  124. /* PHY RX Status 0 */
  125. #define B43legacy_RX_PHYST0_GAINCTL 0x4000 /* Gain Control */
  126. #define B43legacy_RX_PHYST0_PLCPHCF 0x0200
  127. #define B43legacy_RX_PHYST0_PLCPFV 0x0100
  128. #define B43legacy_RX_PHYST0_SHORTPRMBL 0x0080 /* Recvd with Short Preamble */
  129. #define B43legacy_RX_PHYST0_LCRS 0x0040
  130. #define B43legacy_RX_PHYST0_ANT 0x0020 /* Antenna */
  131. #define B43legacy_RX_PHYST0_UNSRATE 0x0010
  132. #define B43legacy_RX_PHYST0_CLIP 0x000C
  133. #define B43legacy_RX_PHYST0_CLIP_SHIFT 2
  134. #define B43legacy_RX_PHYST0_FTYPE 0x0003 /* Frame type */
  135. #define B43legacy_RX_PHYST0_CCK 0x0000 /* Frame type: CCK */
  136. #define B43legacy_RX_PHYST0_OFDM 0x0001 /* Frame type: OFDM */
  137. #define B43legacy_RX_PHYST0_PRE_N 0x0002 /* Pre-standard N-PHY frame */
  138. #define B43legacy_RX_PHYST0_STD_N 0x0003 /* Standard N-PHY frame */
  139. /* PHY RX Status 2 */
  140. #define B43legacy_RX_PHYST2_LNAG 0xC000 /* LNA Gain */
  141. #define B43legacy_RX_PHYST2_LNAG_SHIFT 14
  142. #define B43legacy_RX_PHYST2_PNAG 0x3C00 /* PNA Gain */
  143. #define B43legacy_RX_PHYST2_PNAG_SHIFT 10
  144. #define B43legacy_RX_PHYST2_FOFF 0x03FF /* F offset */
  145. /* PHY RX Status 3 */
  146. #define B43legacy_RX_PHYST3_DIGG 0x1800 /* DIG Gain */
  147. #define B43legacy_RX_PHYST3_DIGG_SHIFT 11
  148. #define B43legacy_RX_PHYST3_TRSTATE 0x0400 /* TR state */
  149. /* MAC RX Status */
  150. #define B43legacy_RX_MAC_BEACONSENT 0x00008000 /* Beacon send flag */
  151. #define B43legacy_RX_MAC_KEYIDX 0x000007E0 /* Key index */
  152. #define B43legacy_RX_MAC_KEYIDX_SHIFT 5
  153. #define B43legacy_RX_MAC_DECERR 0x00000010 /* Decrypt error */
  154. #define B43legacy_RX_MAC_DEC 0x00000008 /* Decryption attempted */
  155. #define B43legacy_RX_MAC_PADDING 0x00000004 /* Pad bytes present */
  156. #define B43legacy_RX_MAC_RESP 0x00000002 /* Response frame xmitted */
  157. #define B43legacy_RX_MAC_FCSERR 0x00000001 /* FCS error */
  158. /* RX channel */
  159. #define B43legacy_RX_CHAN_GAIN 0xFC00 /* Gain */
  160. #define B43legacy_RX_CHAN_GAIN_SHIFT 10
  161. #define B43legacy_RX_CHAN_ID 0x03FC /* Channel ID */
  162. #define B43legacy_RX_CHAN_ID_SHIFT 2
  163. #define B43legacy_RX_CHAN_PHYTYPE 0x0003 /* PHY type */
  164. u8 b43legacy_plcp_get_ratecode_cck(const u8 bitrate);
  165. u8 b43legacy_plcp_get_ratecode_ofdm(const u8 bitrate);
  166. void b43legacy_generate_plcp_hdr(struct b43legacy_plcp_hdr4 *plcp,
  167. const u16 octets, const u8 bitrate);
  168. void b43legacy_rx(struct b43legacy_wldev *dev,
  169. struct sk_buff *skb,
  170. const void *_rxhdr);
  171. void b43legacy_handle_txstatus(struct b43legacy_wldev *dev,
  172. const struct b43legacy_txstatus *status);
  173. void b43legacy_handle_hwtxstatus(struct b43legacy_wldev *dev,
  174. const struct b43legacy_hwtxstatus *hw);
  175. void b43legacy_tx_suspend(struct b43legacy_wldev *dev);
  176. void b43legacy_tx_resume(struct b43legacy_wldev *dev);
  177. #define B43legacy_NR_QOSPARMS 22
  178. enum {
  179. B43legacy_QOSPARM_TXOP = 0,
  180. B43legacy_QOSPARM_CWMIN,
  181. B43legacy_QOSPARM_CWMAX,
  182. B43legacy_QOSPARM_CWCUR,
  183. B43legacy_QOSPARM_AIFS,
  184. B43legacy_QOSPARM_BSLOTS,
  185. B43legacy_QOSPARM_REGGAP,
  186. B43legacy_QOSPARM_STATUS,
  187. };
  188. void b43legacy_qos_init(struct b43legacy_wldev *dev);
  189. /* Helper functions for converting the key-table index from "firmware-format"
  190. * to "raw-format" and back. The firmware API changed for this at some revision.
  191. * We need to account for that here. */
  192. static inline
  193. int b43legacy_new_kidx_api(struct b43legacy_wldev *dev)
  194. {
  195. /* FIXME: Not sure the change was at rev 351 */
  196. return (dev->fw.rev >= 351);
  197. }
  198. static inline
  199. u8 b43legacy_kidx_to_fw(struct b43legacy_wldev *dev, u8 raw_kidx)
  200. {
  201. u8 firmware_kidx;
  202. if (b43legacy_new_kidx_api(dev))
  203. firmware_kidx = raw_kidx;
  204. else {
  205. if (raw_kidx >= 4) /* Is per STA key? */
  206. firmware_kidx = raw_kidx - 4;
  207. else
  208. firmware_kidx = raw_kidx; /* TX default key */
  209. }
  210. return firmware_kidx;
  211. }
  212. static inline
  213. u8 b43legacy_kidx_to_raw(struct b43legacy_wldev *dev, u8 firmware_kidx)
  214. {
  215. u8 raw_kidx;
  216. if (b43legacy_new_kidx_api(dev))
  217. raw_kidx = firmware_kidx;
  218. else
  219. /* RX default keys or per STA keys */
  220. raw_kidx = firmware_kidx + 4;
  221. return raw_kidx;
  222. }
  223. #endif /* B43legacy_XMIT_H_ */