0001
0002 #ifndef B43_XMIT_H_
0003 #define B43_XMIT_H_
0004
0005 #include "main.h"
0006 #include <net/mac80211.h>
0007
0008
0009 #define _b43_declare_plcp_hdr(size) \
0010 struct b43_plcp_hdr##size { \
0011 union { \
0012 __le32 data; \
0013 __u8 raw[size]; \
0014 } __packed; \
0015 } __packed
0016
0017
0018 _b43_declare_plcp_hdr(4);
0019
0020 _b43_declare_plcp_hdr(6);
0021
0022 #undef _b43_declare_plcp_hdr
0023
0024
0025 struct b43_txhdr {
0026 __le32 mac_ctl;
0027 __le16 mac_frame_ctl;
0028 __le16 tx_fes_time_norm;
0029 __le16 phy_ctl;
0030 __le16 phy_ctl1;
0031 __le16 phy_ctl1_fb;
0032 __le16 phy_ctl1_rts;
0033 __le16 phy_ctl1_rts_fb;
0034 __u8 phy_rate;
0035 __u8 phy_rate_rts;
0036 __u8 extra_ft;
0037 __u8 chan_radio_code;
0038 __u8 iv[16];
0039 __u8 tx_receiver[6];
0040 __le16 tx_fes_time_fb;
0041 struct b43_plcp_hdr6 rts_plcp_fb;
0042 __le16 rts_dur_fb;
0043 struct b43_plcp_hdr6 plcp_fb;
0044 __le16 dur_fb;
0045 __le16 mimo_modelen;
0046 __le16 mimo_ratelen_fb;
0047 __le32 timeout;
0048
0049 union {
0050
0051 struct {
0052 __le16 mimo_antenna;
0053 __le16 preload_size;
0054 PAD_BYTES(2);
0055 __le16 cookie;
0056 __le16 tx_status;
0057 __le16 max_n_mpdus;
0058 __le16 max_a_bytes_mrt;
0059 __le16 max_a_bytes_fbr;
0060 __le16 min_m_bytes;
0061 struct b43_plcp_hdr6 rts_plcp;
0062 __u8 rts_frame[16];
0063 PAD_BYTES(2);
0064 struct b43_plcp_hdr6 plcp;
0065 } format_598 __packed;
0066
0067
0068 struct {
0069 __le16 mimo_antenna;
0070 __le16 preload_size;
0071 PAD_BYTES(2);
0072 __le16 cookie;
0073 __le16 tx_status;
0074 struct b43_plcp_hdr6 rts_plcp;
0075 __u8 rts_frame[16];
0076 PAD_BYTES(2);
0077 struct b43_plcp_hdr6 plcp;
0078 } format_410 __packed;
0079
0080
0081 struct {
0082 PAD_BYTES(2);
0083 __le16 cookie;
0084 __le16 tx_status;
0085 struct b43_plcp_hdr6 rts_plcp;
0086 __u8 rts_frame[16];
0087 PAD_BYTES(2);
0088 struct b43_plcp_hdr6 plcp;
0089 } format_351 __packed;
0090
0091 } __packed;
0092 } __packed;
0093
0094 struct b43_tx_legacy_rate_phy_ctl_entry {
0095 u8 bitrate;
0096 u16 coding_rate;
0097 u16 modulation;
0098 };
0099
0100
0101 #define B43_TXH_MAC_RTS_FB_SHORTPRMBL 0x80000000
0102 #define B43_TXH_MAC_RTS_SHORTPRMBL 0x40000000
0103 #define B43_TXH_MAC_FB_SHORTPRMBL 0x20000000
0104 #define B43_TXH_MAC_USEFBR 0x10000000
0105 #define B43_TXH_MAC_KEYIDX 0x0FF00000
0106 #define B43_TXH_MAC_KEYIDX_SHIFT 20
0107 #define B43_TXH_MAC_ALT_TXPWR 0x00080000
0108 #define B43_TXH_MAC_KEYALG 0x00070000
0109 #define B43_TXH_MAC_KEYALG_SHIFT 16
0110 #define B43_TXH_MAC_AMIC 0x00008000
0111 #define B43_TXH_MAC_RIFS 0x00004000
0112 #define B43_TXH_MAC_LIFETIME 0x00002000
0113 #define B43_TXH_MAC_FRAMEBURST 0x00001000
0114 #define B43_TXH_MAC_SENDCTS 0x00000800
0115 #define B43_TXH_MAC_AMPDU 0x00000600
0116 #define B43_TXH_MAC_AMPDU_MPDU 0x00000000
0117 #define B43_TXH_MAC_AMPDU_FIRST 0x00000200
0118 #define B43_TXH_MAC_AMPDU_INTER 0x00000400
0119 #define B43_TXH_MAC_AMPDU_LAST 0x00000600
0120 #define B43_TXH_MAC_40MHZ 0x00000100
0121 #define B43_TXH_MAC_5GHZ 0x00000080
0122 #define B43_TXH_MAC_DFCS 0x00000040
0123 #define B43_TXH_MAC_IGNPMQ 0x00000020
0124 #define B43_TXH_MAC_HWSEQ 0x00000010
0125 #define B43_TXH_MAC_STMSDU 0x00000008
0126 #define B43_TXH_MAC_SENDRTS 0x00000004
0127 #define B43_TXH_MAC_LONGFRAME 0x00000002
0128 #define B43_TXH_MAC_ACK 0x00000001
0129
0130
0131 #define B43_TXH_EFT_FB 0x03
0132 #define B43_TXH_EFT_FB_CCK 0x00
0133 #define B43_TXH_EFT_FB_OFDM 0x01
0134 #define B43_TXH_EFT_FB_HT 0x02
0135 #define B43_TXH_EFT_FB_VHT 0x03
0136 #define B43_TXH_EFT_RTS 0x0C
0137 #define B43_TXH_EFT_RTS_CCK 0x00
0138 #define B43_TXH_EFT_RTS_OFDM 0x04
0139 #define B43_TXH_EFT_RTS_HT 0x08
0140 #define B43_TXH_EFT_RTS_VHT 0x0C
0141 #define B43_TXH_EFT_RTSFB 0x30
0142 #define B43_TXH_EFT_RTSFB_CCK 0x00
0143 #define B43_TXH_EFT_RTSFB_OFDM 0x10
0144 #define B43_TXH_EFT_RTSFB_HT 0x20
0145 #define B43_TXH_EFT_RTSFB_VHT 0x30
0146
0147
0148 #define B43_TXH_PHY_ENC 0x0003
0149 #define B43_TXH_PHY_ENC_CCK 0x0000
0150 #define B43_TXH_PHY_ENC_OFDM 0x0001
0151 #define B43_TXH_PHY_ENC_HT 0x0002
0152 #define B43_TXH_PHY_ENC_VHT 0x0003
0153 #define B43_TXH_PHY_SHORTPRMBL 0x0010
0154 #define B43_TXH_PHY_ANT 0x03C0
0155 #define B43_TXH_PHY_ANT0 0x0000
0156 #define B43_TXH_PHY_ANT1 0x0040
0157 #define B43_TXH_PHY_ANT01AUTO 0x00C0
0158 #define B43_TXH_PHY_ANT2 0x0100
0159 #define B43_TXH_PHY_ANT3 0x0200
0160 #define B43_TXH_PHY_TXPWR 0xFC00
0161 #define B43_TXH_PHY_TXPWR_SHIFT 10
0162
0163
0164 #define B43_TXH_PHY1_BW 0x0007
0165 #define B43_TXH_PHY1_BW_10 0x0000
0166 #define B43_TXH_PHY1_BW_10U 0x0001
0167 #define B43_TXH_PHY1_BW_20 0x0002
0168 #define B43_TXH_PHY1_BW_20U 0x0003
0169 #define B43_TXH_PHY1_BW_40 0x0004
0170 #define B43_TXH_PHY1_BW_40DUP 0x0005
0171 #define B43_TXH_PHY1_MODE 0x0038
0172 #define B43_TXH_PHY1_MODE_SISO 0x0000
0173 #define B43_TXH_PHY1_MODE_CDD 0x0008
0174 #define B43_TXH_PHY1_MODE_STBC 0x0010
0175 #define B43_TXH_PHY1_MODE_SDM 0x0018
0176 #define B43_TXH_PHY1_CRATE 0x0700
0177 #define B43_TXH_PHY1_CRATE_1_2 0x0000
0178 #define B43_TXH_PHY1_CRATE_2_3 0x0100
0179 #define B43_TXH_PHY1_CRATE_3_4 0x0200
0180 #define B43_TXH_PHY1_CRATE_4_5 0x0300
0181 #define B43_TXH_PHY1_CRATE_5_6 0x0400
0182 #define B43_TXH_PHY1_CRATE_7_8 0x0600
0183 #define B43_TXH_PHY1_MODUL 0x3800
0184 #define B43_TXH_PHY1_MODUL_BPSK 0x0000
0185 #define B43_TXH_PHY1_MODUL_QPSK 0x0800
0186 #define B43_TXH_PHY1_MODUL_QAM16 0x1000
0187 #define B43_TXH_PHY1_MODUL_QAM64 0x1800
0188 #define B43_TXH_PHY1_MODUL_QAM256 0x2000
0189
0190
0191 static inline
0192 size_t b43_txhdr_size(struct b43_wldev *dev)
0193 {
0194 switch (dev->fw.hdr_format) {
0195 case B43_FW_HDR_598:
0196 return 112 + sizeof(struct b43_plcp_hdr6);
0197 case B43_FW_HDR_410:
0198 return 104 + sizeof(struct b43_plcp_hdr6);
0199 case B43_FW_HDR_351:
0200 return 100 + sizeof(struct b43_plcp_hdr6);
0201 }
0202 return 0;
0203 }
0204
0205
0206 int b43_generate_txhdr(struct b43_wldev *dev,
0207 u8 * txhdr,
0208 struct sk_buff *skb_frag,
0209 struct ieee80211_tx_info *txctl, u16 cookie);
0210
0211
0212 struct b43_txstatus {
0213 u16 cookie;
0214 u16 seq;
0215 u8 phy_stat;
0216 u8 frame_count;
0217 u8 rts_count;
0218 u8 supp_reason;
0219
0220 u8 pm_indicated;
0221 u8 intermediate;
0222 u8 for_ampdu;
0223 u8 acked;
0224 };
0225
0226
0227 enum {
0228 B43_TXST_SUPP_NONE,
0229 B43_TXST_SUPP_PMQ,
0230 B43_TXST_SUPP_FLUSH,
0231 B43_TXST_SUPP_PREV,
0232 B43_TXST_SUPP_CHAN,
0233 B43_TXST_SUPP_LIFE,
0234 B43_TXST_SUPP_UNDER,
0235 B43_TXST_SUPP_ABNACK,
0236 };
0237
0238
0239 struct b43_rxhdr_fw4 {
0240 __le16 frame_len;
0241 PAD_BYTES(2);
0242 __le16 phy_status0;
0243 union {
0244
0245 struct {
0246 __u8 jssi;
0247 __u8 sig_qual;
0248 } __packed;
0249
0250
0251 struct {
0252 __s8 power0;
0253 __s8 power1;
0254 } __packed;
0255 } __packed;
0256 union {
0257
0258 struct {
0259 PAD_BYTES(1);
0260 __s8 phy_ht_power0;
0261 } __packed;
0262
0263
0264 struct {
0265 __s8 power2;
0266 PAD_BYTES(1);
0267 } __packed;
0268
0269 __le16 phy_status2;
0270 } __packed;
0271 union {
0272
0273 struct {
0274 __s8 phy_ht_power1;
0275 __s8 phy_ht_power2;
0276 } __packed;
0277
0278 __le16 phy_status3;
0279 } __packed;
0280 union {
0281
0282 struct {
0283 __le16 phy_status4;
0284 __le16 phy_status5;
0285 __le32 mac_status;
0286 __le16 mac_time;
0287 __le16 channel;
0288 } format_598 __packed;
0289
0290
0291 struct {
0292 __le32 mac_status;
0293 __le16 mac_time;
0294 __le16 channel;
0295 } format_351 __packed;
0296 } __packed;
0297 } __packed;
0298
0299
0300 #define B43_RX_PHYST0_GAINCTL 0x4000
0301 #define B43_RX_PHYST0_PLCPHCF 0x0200
0302 #define B43_RX_PHYST0_PLCPFV 0x0100
0303 #define B43_RX_PHYST0_SHORTPRMBL 0x0080
0304 #define B43_RX_PHYST0_LCRS 0x0040
0305 #define B43_RX_PHYST0_ANT 0x0020
0306 #define B43_RX_PHYST0_UNSRATE 0x0010
0307 #define B43_RX_PHYST0_CLIP 0x000C
0308 #define B43_RX_PHYST0_CLIP_SHIFT 2
0309 #define B43_RX_PHYST0_FTYPE 0x0003
0310 #define B43_RX_PHYST0_CCK 0x0000
0311 #define B43_RX_PHYST0_OFDM 0x0001
0312 #define B43_RX_PHYST0_PRE_N 0x0002
0313 #define B43_RX_PHYST0_STD_N 0x0003
0314
0315
0316 #define B43_RX_PHYST2_LNAG 0xC000
0317 #define B43_RX_PHYST2_LNAG_SHIFT 14
0318 #define B43_RX_PHYST2_PNAG 0x3C00
0319 #define B43_RX_PHYST2_PNAG_SHIFT 10
0320 #define B43_RX_PHYST2_FOFF 0x03FF
0321
0322
0323 #define B43_RX_PHYST3_DIGG 0x1800
0324 #define B43_RX_PHYST3_DIGG_SHIFT 11
0325 #define B43_RX_PHYST3_TRSTATE 0x0400
0326
0327
0328 #define B43_RX_MAC_RXST_VALID 0x01000000
0329 #define B43_RX_MAC_TKIP_MICERR 0x00100000
0330 #define B43_RX_MAC_TKIP_MICATT 0x00080000
0331 #define B43_RX_MAC_AGGTYPE 0x00060000
0332 #define B43_RX_MAC_AGGTYPE_SHIFT 17
0333 #define B43_RX_MAC_AMSDU 0x00010000
0334 #define B43_RX_MAC_BEACONSENT 0x00008000
0335 #define B43_RX_MAC_KEYIDX 0x000007E0
0336 #define B43_RX_MAC_KEYIDX_SHIFT 5
0337 #define B43_RX_MAC_DECERR 0x00000010
0338 #define B43_RX_MAC_DEC 0x00000008
0339 #define B43_RX_MAC_PADDING 0x00000004
0340 #define B43_RX_MAC_RESP 0x00000002
0341 #define B43_RX_MAC_FCSERR 0x00000001
0342
0343
0344 #define B43_RX_CHAN_40MHZ 0x1000
0345 #define B43_RX_CHAN_5GHZ 0x0800
0346 #define B43_RX_CHAN_ID 0x07F8
0347 #define B43_RX_CHAN_ID_SHIFT 3
0348 #define B43_RX_CHAN_PHYTYPE 0x0007
0349
0350
0351 u8 b43_plcp_get_ratecode_cck(const u8 bitrate);
0352 u8 b43_plcp_get_ratecode_ofdm(const u8 bitrate);
0353
0354 void b43_generate_plcp_hdr(struct b43_plcp_hdr4 *plcp,
0355 const u16 octets, const u8 bitrate);
0356
0357 void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr);
0358
0359 void b43_handle_txstatus(struct b43_wldev *dev,
0360 const struct b43_txstatus *status);
0361 bool b43_fill_txstatus_report(struct b43_wldev *dev,
0362 struct ieee80211_tx_info *report,
0363 const struct b43_txstatus *status);
0364
0365 void b43_tx_suspend(struct b43_wldev *dev);
0366 void b43_tx_resume(struct b43_wldev *dev);
0367
0368
0369
0370
0371
0372 static inline int b43_new_kidx_api(struct b43_wldev *dev)
0373 {
0374
0375 return (dev->fw.rev >= 351);
0376 }
0377 static inline u8 b43_kidx_to_fw(struct b43_wldev *dev, u8 raw_kidx)
0378 {
0379 u8 firmware_kidx;
0380 if (b43_new_kidx_api(dev)) {
0381 firmware_kidx = raw_kidx;
0382 } else {
0383 if (raw_kidx >= 4)
0384 firmware_kidx = raw_kidx - 4;
0385 else
0386 firmware_kidx = raw_kidx;
0387 }
0388 return firmware_kidx;
0389 }
0390 static inline u8 b43_kidx_to_raw(struct b43_wldev *dev, u8 firmware_kidx)
0391 {
0392 u8 raw_kidx;
0393 if (b43_new_kidx_api(dev))
0394 raw_kidx = firmware_kidx;
0395 else
0396 raw_kidx = firmware_kidx + 4;
0397 return raw_kidx;
0398 }
0399
0400
0401
0402
0403
0404
0405 struct b43_private_tx_info {
0406 void *bouncebuffer;
0407 };
0408
0409 static inline struct b43_private_tx_info *
0410 b43_get_priv_tx_info(struct ieee80211_tx_info *info)
0411 {
0412 BUILD_BUG_ON(sizeof(struct b43_private_tx_info) >
0413 sizeof(info->rate_driver_data));
0414 return (struct b43_private_tx_info *)info->rate_driver_data;
0415 }
0416
0417 #endif