Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Broadcom B43 wireless driver |
| 4 | |
| 5 | Transmission (TX/RX) related functions. |
| 6 | |
| 7 | Copyright (C) 2005 Martin Langer <martin-langer@gmx.de> |
Stefano Brivio | 1f21ad2 | 2007-11-06 22:49:20 +0100 | [diff] [blame] | 8 | Copyright (C) 2005 Stefano Brivio <stefano.brivio@polimi.it> |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 9 | Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de> |
| 10 | Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org> |
| 11 | Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch> |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or modify |
| 14 | it under the terms of the GNU General Public License as published by |
| 15 | the Free Software Foundation; either version 2 of the License, or |
| 16 | (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, |
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | GNU General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; see the file COPYING. If not, write to |
| 25 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, |
| 26 | Boston, MA 02110-1301, USA. |
| 27 | |
| 28 | */ |
| 29 | |
| 30 | #include "xmit.h" |
| 31 | #include "phy.h" |
| 32 | #include "dma.h" |
Michael Buesch | 03b2977 | 2007-12-26 14:41:30 +0100 | [diff] [blame] | 33 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 34 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 35 | /* Extract the bitrate index out of a CCK PLCP header. */ |
| 36 | static int b43_plcp_get_bitrate_idx_cck(struct b43_plcp_hdr6 *plcp) |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 37 | { |
| 38 | switch (plcp->raw[0]) { |
| 39 | case 0x0A: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 40 | return 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 41 | case 0x14: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 42 | return 1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 43 | case 0x37: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 44 | return 2; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 45 | case 0x6E: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 46 | return 3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 47 | } |
| 48 | B43_WARN_ON(1); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 49 | return -1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 50 | } |
| 51 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 52 | /* Extract the bitrate index out of an OFDM PLCP header. */ |
| 53 | static u8 b43_plcp_get_bitrate_idx_ofdm(struct b43_plcp_hdr6 *plcp, bool aphy) |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 54 | { |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 55 | int base = aphy ? 0 : 4; |
| 56 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 57 | switch (plcp->raw[0] & 0xF) { |
| 58 | case 0xB: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 59 | return base + 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 60 | case 0xF: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 61 | return base + 1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 62 | case 0xA: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 63 | return base + 2; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 64 | case 0xE: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 65 | return base + 3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 66 | case 0x9: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 67 | return base + 4; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 68 | case 0xD: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 69 | return base + 5; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 70 | case 0x8: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 71 | return base + 6; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 72 | case 0xC: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 73 | return base + 7; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 74 | } |
| 75 | B43_WARN_ON(1); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 76 | return -1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | u8 b43_plcp_get_ratecode_cck(const u8 bitrate) |
| 80 | { |
| 81 | switch (bitrate) { |
| 82 | case B43_CCK_RATE_1MB: |
| 83 | return 0x0A; |
| 84 | case B43_CCK_RATE_2MB: |
| 85 | return 0x14; |
| 86 | case B43_CCK_RATE_5MB: |
| 87 | return 0x37; |
| 88 | case B43_CCK_RATE_11MB: |
| 89 | return 0x6E; |
| 90 | } |
| 91 | B43_WARN_ON(1); |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | u8 b43_plcp_get_ratecode_ofdm(const u8 bitrate) |
| 96 | { |
| 97 | switch (bitrate) { |
| 98 | case B43_OFDM_RATE_6MB: |
| 99 | return 0xB; |
| 100 | case B43_OFDM_RATE_9MB: |
| 101 | return 0xF; |
| 102 | case B43_OFDM_RATE_12MB: |
| 103 | return 0xA; |
| 104 | case B43_OFDM_RATE_18MB: |
| 105 | return 0xE; |
| 106 | case B43_OFDM_RATE_24MB: |
| 107 | return 0x9; |
| 108 | case B43_OFDM_RATE_36MB: |
| 109 | return 0xD; |
| 110 | case B43_OFDM_RATE_48MB: |
| 111 | return 0x8; |
| 112 | case B43_OFDM_RATE_54MB: |
| 113 | return 0xC; |
| 114 | } |
| 115 | B43_WARN_ON(1); |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | void b43_generate_plcp_hdr(struct b43_plcp_hdr4 *plcp, |
| 120 | const u16 octets, const u8 bitrate) |
| 121 | { |
| 122 | __le32 *data = &(plcp->data); |
| 123 | __u8 *raw = plcp->raw; |
| 124 | |
| 125 | if (b43_is_ofdm_rate(bitrate)) { |
Michael Buesch | 1a09404 | 2007-09-20 11:13:40 -0700 | [diff] [blame] | 126 | u32 d; |
| 127 | |
| 128 | d = b43_plcp_get_ratecode_ofdm(bitrate); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 129 | B43_WARN_ON(octets & 0xF000); |
Michael Buesch | 1a09404 | 2007-09-20 11:13:40 -0700 | [diff] [blame] | 130 | d |= (octets << 5); |
| 131 | *data = cpu_to_le32(d); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 132 | } else { |
| 133 | u32 plen; |
| 134 | |
| 135 | plen = octets * 16 / bitrate; |
| 136 | if ((octets * 16 % bitrate) > 0) { |
| 137 | plen++; |
| 138 | if ((bitrate == B43_CCK_RATE_11MB) |
| 139 | && ((octets * 8 % 11) < 4)) { |
| 140 | raw[1] = 0x84; |
| 141 | } else |
| 142 | raw[1] = 0x04; |
| 143 | } else |
| 144 | raw[1] = 0x04; |
| 145 | *data |= cpu_to_le32(plen << 16); |
| 146 | raw[0] = b43_plcp_get_ratecode_cck(bitrate); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | static u8 b43_calc_fallback_rate(u8 bitrate) |
| 151 | { |
| 152 | switch (bitrate) { |
| 153 | case B43_CCK_RATE_1MB: |
| 154 | return B43_CCK_RATE_1MB; |
| 155 | case B43_CCK_RATE_2MB: |
| 156 | return B43_CCK_RATE_1MB; |
| 157 | case B43_CCK_RATE_5MB: |
| 158 | return B43_CCK_RATE_2MB; |
| 159 | case B43_CCK_RATE_11MB: |
| 160 | return B43_CCK_RATE_5MB; |
| 161 | case B43_OFDM_RATE_6MB: |
| 162 | return B43_CCK_RATE_5MB; |
| 163 | case B43_OFDM_RATE_9MB: |
| 164 | return B43_OFDM_RATE_6MB; |
| 165 | case B43_OFDM_RATE_12MB: |
| 166 | return B43_OFDM_RATE_9MB; |
| 167 | case B43_OFDM_RATE_18MB: |
| 168 | return B43_OFDM_RATE_12MB; |
| 169 | case B43_OFDM_RATE_24MB: |
| 170 | return B43_OFDM_RATE_18MB; |
| 171 | case B43_OFDM_RATE_36MB: |
| 172 | return B43_OFDM_RATE_24MB; |
| 173 | case B43_OFDM_RATE_48MB: |
| 174 | return B43_OFDM_RATE_36MB; |
| 175 | case B43_OFDM_RATE_54MB: |
| 176 | return B43_OFDM_RATE_48MB; |
| 177 | } |
| 178 | B43_WARN_ON(1); |
| 179 | return 0; |
| 180 | } |
| 181 | |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 182 | /* Generate a TX data header. */ |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 183 | int b43_generate_txhdr(struct b43_wldev *dev, |
| 184 | u8 *_txhdr, |
| 185 | const unsigned char *fragment_data, |
| 186 | unsigned int fragment_len, |
| 187 | const struct ieee80211_tx_control *txctl, |
| 188 | u16 cookie) |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 189 | { |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 190 | struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 191 | const struct b43_phy *phy = &dev->phy; |
| 192 | const struct ieee80211_hdr *wlhdr = |
| 193 | (const struct ieee80211_hdr *)fragment_data; |
| 194 | int use_encryption = (!(txctl->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT)); |
| 195 | u16 fctl = le16_to_cpu(wlhdr->frame_control); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 196 | struct ieee80211_rate *fbrate; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 197 | u8 rate, rate_fb; |
| 198 | int rate_ofdm, rate_fb_ofdm; |
| 199 | unsigned int plcp_fragment_len; |
| 200 | u32 mac_ctl = 0; |
| 201 | u16 phy_ctl = 0; |
| 202 | u8 extra_ft = 0; |
| 203 | |
| 204 | memset(txhdr, 0, sizeof(*txhdr)); |
| 205 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 206 | WARN_ON(!txctl->tx_rate); |
| 207 | rate = txctl->tx_rate ? txctl->tx_rate->hw_value : B43_CCK_RATE_1MB; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 208 | rate_ofdm = b43_is_ofdm_rate(rate); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 209 | fbrate = txctl->alt_retry_rate ? : txctl->tx_rate; |
| 210 | rate_fb = fbrate->hw_value; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 211 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); |
| 212 | |
| 213 | if (rate_ofdm) |
| 214 | txhdr->phy_rate = b43_plcp_get_ratecode_ofdm(rate); |
| 215 | else |
| 216 | txhdr->phy_rate = b43_plcp_get_ratecode_cck(rate); |
| 217 | txhdr->mac_frame_ctl = wlhdr->frame_control; |
| 218 | memcpy(txhdr->tx_receiver, wlhdr->addr1, 6); |
| 219 | |
| 220 | /* Calculate duration for fallback rate */ |
| 221 | if ((rate_fb == rate) || |
| 222 | (wlhdr->duration_id & cpu_to_le16(0x8000)) || |
| 223 | (wlhdr->duration_id == cpu_to_le16(0))) { |
| 224 | /* If the fallback rate equals the normal rate or the |
| 225 | * dur_id field contains an AID, CFP magic or 0, |
| 226 | * use the original dur_id field. */ |
| 227 | txhdr->dur_fb = wlhdr->duration_id; |
| 228 | } else { |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 229 | txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw, |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 230 | txctl->vif, |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 231 | fragment_len, |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 232 | fbrate); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | plcp_fragment_len = fragment_len + FCS_LEN; |
| 236 | if (use_encryption) { |
| 237 | u8 key_idx = (u16) (txctl->key_idx); |
| 238 | struct b43_key *key; |
| 239 | int wlhdr_len; |
| 240 | size_t iv_len; |
| 241 | |
| 242 | B43_WARN_ON(key_idx >= dev->max_nr_keys); |
| 243 | key = &(dev->key[key_idx]); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 244 | |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 245 | if (unlikely(!key->keyconf)) { |
| 246 | /* This key is invalid. This might only happen |
| 247 | * in a short timeframe after machine resume before |
| 248 | * we were able to reconfigure keys. |
| 249 | * Drop this packet completely. Do not transmit it |
| 250 | * unencrypted to avoid leaking information. */ |
| 251 | return -ENOKEY; |
Michael Buesch | 7be1bb6 | 2008-01-23 21:10:56 +0100 | [diff] [blame] | 252 | } |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 253 | |
| 254 | /* Hardware appends ICV. */ |
| 255 | plcp_fragment_len += txctl->icv_len; |
| 256 | |
| 257 | key_idx = b43_kidx_to_fw(dev, key_idx); |
| 258 | mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) & |
| 259 | B43_TXH_MAC_KEYIDX; |
| 260 | mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) & |
| 261 | B43_TXH_MAC_KEYALG; |
| 262 | wlhdr_len = ieee80211_get_hdrlen(fctl); |
| 263 | iv_len = min((size_t) txctl->iv_len, |
| 264 | ARRAY_SIZE(txhdr->iv)); |
| 265 | memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 266 | } |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 267 | if (b43_is_old_txhdr_format(dev)) { |
| 268 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->old_format.plcp), |
| 269 | plcp_fragment_len, rate); |
| 270 | } else { |
| 271 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->new_format.plcp), |
| 272 | plcp_fragment_len, rate); |
| 273 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 274 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->plcp_fb), |
| 275 | plcp_fragment_len, rate_fb); |
| 276 | |
| 277 | /* Extra Frame Types */ |
| 278 | if (rate_fb_ofdm) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 279 | extra_ft |= B43_TXH_EFT_FB_OFDM; |
| 280 | else |
| 281 | extra_ft |= B43_TXH_EFT_FB_CCK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 282 | |
| 283 | /* Set channel radio code. Note that the micrcode ORs 0x100 to |
| 284 | * this value before comparing it to the value in SHM, if this |
| 285 | * is a 5Ghz packet. |
| 286 | */ |
| 287 | txhdr->chan_radio_code = phy->channel; |
| 288 | |
| 289 | /* PHY TX Control word */ |
| 290 | if (rate_ofdm) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 291 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; |
| 292 | else |
| 293 | phy_ctl |= B43_TXH_PHY_ENC_CCK; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 294 | if (txctl->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 295 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 296 | |
| 297 | switch (b43_ieee80211_antenna_sanitize(dev, txctl->antenna_sel_tx)) { |
| 298 | case 0: /* Default */ |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 299 | phy_ctl |= B43_TXH_PHY_ANT01AUTO; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 300 | break; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 301 | case 1: /* Antenna 0 */ |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 302 | phy_ctl |= B43_TXH_PHY_ANT0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 303 | break; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 304 | case 2: /* Antenna 1 */ |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 305 | phy_ctl |= B43_TXH_PHY_ANT1; |
| 306 | break; |
| 307 | case 3: /* Antenna 2 */ |
| 308 | phy_ctl |= B43_TXH_PHY_ANT2; |
| 309 | break; |
| 310 | case 4: /* Antenna 3 */ |
| 311 | phy_ctl |= B43_TXH_PHY_ANT3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 312 | break; |
| 313 | default: |
| 314 | B43_WARN_ON(1); |
| 315 | } |
| 316 | |
| 317 | /* MAC control */ |
| 318 | if (!(txctl->flags & IEEE80211_TXCTL_NO_ACK)) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 319 | mac_ctl |= B43_TXH_MAC_ACK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 320 | if (!(((fctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && |
| 321 | ((fctl & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL))) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 322 | mac_ctl |= B43_TXH_MAC_HWSEQ; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 323 | if (txctl->flags & IEEE80211_TXCTL_FIRST_FRAGMENT) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 324 | mac_ctl |= B43_TXH_MAC_STMSDU; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 325 | if (phy->type == B43_PHYTYPE_A) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 326 | mac_ctl |= B43_TXH_MAC_5GHZ; |
Michael Buesch | 74cfdba | 2007-10-28 16:19:44 +0100 | [diff] [blame] | 327 | if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 328 | mac_ctl |= B43_TXH_MAC_LONGFRAME; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 329 | |
| 330 | /* Generate the RTS or CTS-to-self frame */ |
| 331 | if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) || |
| 332 | (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) { |
| 333 | unsigned int len; |
| 334 | struct ieee80211_hdr *hdr; |
| 335 | int rts_rate, rts_rate_fb; |
| 336 | int rts_rate_ofdm, rts_rate_fb_ofdm; |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 337 | struct b43_plcp_hdr6 *plcp; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 338 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 339 | WARN_ON(!txctl->rts_cts_rate); |
| 340 | rts_rate = txctl->rts_cts_rate ? txctl->rts_cts_rate->hw_value : B43_CCK_RATE_1MB; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 341 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); |
| 342 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); |
| 343 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); |
| 344 | |
| 345 | if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) { |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 346 | struct ieee80211_cts *cts; |
| 347 | |
| 348 | if (b43_is_old_txhdr_format(dev)) { |
| 349 | cts = (struct ieee80211_cts *) |
| 350 | (txhdr->old_format.rts_frame); |
| 351 | } else { |
| 352 | cts = (struct ieee80211_cts *) |
| 353 | (txhdr->new_format.rts_frame); |
| 354 | } |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 355 | ieee80211_ctstoself_get(dev->wl->hw, txctl->vif, |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 356 | fragment_data, fragment_len, |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 357 | txctl, cts); |
| 358 | mac_ctl |= B43_TXH_MAC_SENDCTS; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 359 | len = sizeof(struct ieee80211_cts); |
| 360 | } else { |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 361 | struct ieee80211_rts *rts; |
| 362 | |
| 363 | if (b43_is_old_txhdr_format(dev)) { |
| 364 | rts = (struct ieee80211_rts *) |
| 365 | (txhdr->old_format.rts_frame); |
| 366 | } else { |
| 367 | rts = (struct ieee80211_rts *) |
| 368 | (txhdr->new_format.rts_frame); |
| 369 | } |
Johannes Berg | 32bfd35 | 2007-12-19 01:31:26 +0100 | [diff] [blame] | 370 | ieee80211_rts_get(dev->wl->hw, txctl->vif, |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 371 | fragment_data, fragment_len, |
| 372 | txctl, rts); |
| 373 | mac_ctl |= B43_TXH_MAC_SENDRTS; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 374 | len = sizeof(struct ieee80211_rts); |
| 375 | } |
| 376 | len += FCS_LEN; |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 377 | |
| 378 | /* Generate the PLCP headers for the RTS/CTS frame */ |
| 379 | if (b43_is_old_txhdr_format(dev)) |
| 380 | plcp = &txhdr->old_format.rts_plcp; |
| 381 | else |
| 382 | plcp = &txhdr->new_format.rts_plcp; |
| 383 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)plcp, |
| 384 | len, rts_rate); |
| 385 | plcp = &txhdr->rts_plcp_fb; |
| 386 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)plcp, |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 387 | len, rts_rate_fb); |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 388 | |
| 389 | if (b43_is_old_txhdr_format(dev)) { |
| 390 | hdr = (struct ieee80211_hdr *) |
| 391 | (&txhdr->old_format.rts_frame); |
| 392 | } else { |
| 393 | hdr = (struct ieee80211_hdr *) |
| 394 | (&txhdr->new_format.rts_frame); |
| 395 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 396 | txhdr->rts_dur_fb = hdr->duration_id; |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 397 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 398 | if (rts_rate_ofdm) { |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 399 | extra_ft |= B43_TXH_EFT_RTS_OFDM; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 400 | txhdr->phy_rate_rts = |
| 401 | b43_plcp_get_ratecode_ofdm(rts_rate); |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 402 | } else { |
| 403 | extra_ft |= B43_TXH_EFT_RTS_CCK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 404 | txhdr->phy_rate_rts = |
| 405 | b43_plcp_get_ratecode_cck(rts_rate); |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 406 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 407 | if (rts_rate_fb_ofdm) |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 408 | extra_ft |= B43_TXH_EFT_RTSFB_OFDM; |
| 409 | else |
| 410 | extra_ft |= B43_TXH_EFT_RTSFB_CCK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | /* Magic cookie */ |
Michael Buesch | eb189d8 | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 414 | if (b43_is_old_txhdr_format(dev)) |
| 415 | txhdr->old_format.cookie = cpu_to_le16(cookie); |
| 416 | else |
| 417 | txhdr->new_format.cookie = cpu_to_le16(cookie); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 418 | |
| 419 | /* Apply the bitfields */ |
| 420 | txhdr->mac_ctl = cpu_to_le32(mac_ctl); |
| 421 | txhdr->phy_ctl = cpu_to_le16(phy_ctl); |
| 422 | txhdr->extra_ft = extra_ft; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 423 | |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 424 | return 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | static s8 b43_rssi_postprocess(struct b43_wldev *dev, |
| 428 | u8 in_rssi, int ofdm, |
| 429 | int adjust_2053, int adjust_2050) |
| 430 | { |
| 431 | struct b43_phy *phy = &dev->phy; |
| 432 | s32 tmp; |
| 433 | |
| 434 | switch (phy->radio_ver) { |
| 435 | case 0x2050: |
| 436 | if (ofdm) { |
| 437 | tmp = in_rssi; |
| 438 | if (tmp > 127) |
| 439 | tmp -= 256; |
| 440 | tmp *= 73; |
| 441 | tmp /= 64; |
| 442 | if (adjust_2050) |
| 443 | tmp += 25; |
| 444 | else |
| 445 | tmp -= 3; |
| 446 | } else { |
Larry Finger | 95de284 | 2007-11-09 16:57:18 -0600 | [diff] [blame] | 447 | if (dev->dev->bus->sprom. |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 448 | boardflags_lo & B43_BFL_RSSI) { |
| 449 | if (in_rssi > 63) |
| 450 | in_rssi = 63; |
| 451 | tmp = phy->nrssi_lt[in_rssi]; |
| 452 | tmp = 31 - tmp; |
| 453 | tmp *= -131; |
| 454 | tmp /= 128; |
| 455 | tmp -= 57; |
| 456 | } else { |
| 457 | tmp = in_rssi; |
| 458 | tmp = 31 - tmp; |
| 459 | tmp *= -149; |
| 460 | tmp /= 128; |
| 461 | tmp -= 68; |
| 462 | } |
| 463 | if (phy->type == B43_PHYTYPE_G && adjust_2050) |
| 464 | tmp += 25; |
| 465 | } |
| 466 | break; |
| 467 | case 0x2060: |
| 468 | if (in_rssi > 127) |
| 469 | tmp = in_rssi - 256; |
| 470 | else |
| 471 | tmp = in_rssi; |
| 472 | break; |
| 473 | default: |
| 474 | tmp = in_rssi; |
| 475 | tmp -= 11; |
| 476 | tmp *= 103; |
| 477 | tmp /= 64; |
| 478 | if (adjust_2053) |
| 479 | tmp -= 109; |
| 480 | else |
| 481 | tmp -= 83; |
| 482 | } |
| 483 | |
| 484 | return (s8) tmp; |
| 485 | } |
| 486 | |
| 487 | //TODO |
| 488 | #if 0 |
| 489 | static s8 b43_rssinoise_postprocess(struct b43_wldev *dev, u8 in_rssi) |
| 490 | { |
| 491 | struct b43_phy *phy = &dev->phy; |
| 492 | s8 ret; |
| 493 | |
| 494 | if (phy->type == B43_PHYTYPE_A) { |
| 495 | //TODO: Incomplete specs. |
| 496 | ret = 0; |
| 497 | } else |
| 498 | ret = b43_rssi_postprocess(dev, in_rssi, 0, 1, 1); |
| 499 | |
| 500 | return ret; |
| 501 | } |
| 502 | #endif |
| 503 | |
| 504 | void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) |
| 505 | { |
| 506 | struct ieee80211_rx_status status; |
| 507 | struct b43_plcp_hdr6 *plcp; |
| 508 | struct ieee80211_hdr *wlhdr; |
| 509 | const struct b43_rxhdr_fw4 *rxhdr = _rxhdr; |
| 510 | u16 fctl; |
| 511 | u16 phystat0, phystat3, chanstat, mactime; |
| 512 | u32 macstat; |
| 513 | u16 chanid; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 514 | u16 phytype; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 515 | u8 jssi; |
| 516 | int padding; |
| 517 | |
| 518 | memset(&status, 0, sizeof(status)); |
| 519 | |
| 520 | /* Get metadata about the frame from the header. */ |
| 521 | phystat0 = le16_to_cpu(rxhdr->phy_status0); |
| 522 | phystat3 = le16_to_cpu(rxhdr->phy_status3); |
| 523 | jssi = rxhdr->jssi; |
| 524 | macstat = le32_to_cpu(rxhdr->mac_status); |
| 525 | mactime = le16_to_cpu(rxhdr->mac_time); |
| 526 | chanstat = le16_to_cpu(rxhdr->channel); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 527 | phytype = chanstat & B43_RX_CHAN_PHYTYPE; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 528 | |
| 529 | if (macstat & B43_RX_MAC_FCSERR) |
| 530 | dev->wl->ieee_stats.dot11FCSErrorCount++; |
| 531 | if (macstat & B43_RX_MAC_DECERR) { |
| 532 | /* Decryption with the given key failed. |
| 533 | * Drop the packet. We also won't be able to decrypt it with |
| 534 | * the key in software. */ |
| 535 | goto drop; |
| 536 | } |
| 537 | |
| 538 | /* Skip PLCP and padding */ |
| 539 | padding = (macstat & B43_RX_MAC_PADDING) ? 2 : 0; |
| 540 | if (unlikely(skb->len < (sizeof(struct b43_plcp_hdr6) + padding))) { |
| 541 | b43dbg(dev->wl, "RX: Packet size underrun (1)\n"); |
| 542 | goto drop; |
| 543 | } |
| 544 | plcp = (struct b43_plcp_hdr6 *)(skb->data + padding); |
| 545 | skb_pull(skb, sizeof(struct b43_plcp_hdr6) + padding); |
| 546 | /* The skb contains the Wireless Header + payload data now */ |
| 547 | if (unlikely(skb->len < (2 + 2 + 6 /*minimum hdr */ + FCS_LEN))) { |
| 548 | b43dbg(dev->wl, "RX: Packet size underrun (2)\n"); |
| 549 | goto drop; |
| 550 | } |
| 551 | wlhdr = (struct ieee80211_hdr *)(skb->data); |
| 552 | fctl = le16_to_cpu(wlhdr->frame_control); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 553 | |
| 554 | if (macstat & B43_RX_MAC_DEC) { |
| 555 | unsigned int keyidx; |
| 556 | int wlhdr_len; |
| 557 | |
| 558 | keyidx = ((macstat & B43_RX_MAC_KEYIDX) |
| 559 | >> B43_RX_MAC_KEYIDX_SHIFT); |
| 560 | /* We must adjust the key index here. We want the "physical" |
| 561 | * key index, but the ucode passed it slightly different. |
| 562 | */ |
| 563 | keyidx = b43_kidx_to_raw(dev, keyidx); |
| 564 | B43_WARN_ON(keyidx >= dev->max_nr_keys); |
| 565 | |
| 566 | if (dev->key[keyidx].algorithm != B43_SEC_ALGO_NONE) { |
| 567 | wlhdr_len = ieee80211_get_hdrlen(fctl); |
| 568 | if (unlikely(skb->len < (wlhdr_len + 3))) { |
| 569 | b43dbg(dev->wl, |
| 570 | "RX: Packet size underrun (3)\n"); |
| 571 | goto drop; |
| 572 | } |
| 573 | status.flag |= RX_FLAG_DECRYPTED; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | status.ssi = b43_rssi_postprocess(dev, jssi, |
| 578 | (phystat0 & B43_RX_PHYST0_OFDM), |
| 579 | (phystat0 & B43_RX_PHYST0_GAINCTL), |
| 580 | (phystat3 & B43_RX_PHYST3_TRSTATE)); |
| 581 | status.noise = dev->stats.link_noise; |
| 582 | /* the next line looks wrong, but is what mac80211 wants */ |
| 583 | status.signal = (jssi * 100) / B43_RX_MAX_SSI; |
| 584 | if (phystat0 & B43_RX_PHYST0_OFDM) |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 585 | status.rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, |
| 586 | phytype == B43_PHYTYPE_A); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 587 | else |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 588 | status.rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 589 | status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); |
John W. Linville | c0ddd04 | 2008-01-21 13:41:18 -0500 | [diff] [blame] | 590 | |
| 591 | /* |
| 592 | * If monitors are present get full 64-bit timestamp. This |
| 593 | * code assumes we get to process the packet within 16 bits |
| 594 | * of timestamp, i.e. about 65 milliseconds after the PHY |
| 595 | * received the first symbol. |
| 596 | */ |
| 597 | if (dev->wl->radiotap_enabled) { |
| 598 | u16 low_mactime_now; |
| 599 | |
| 600 | b43_tsf_read(dev, &status.mactime); |
| 601 | low_mactime_now = status.mactime; |
| 602 | status.mactime = status.mactime & ~0xFFFFULL; |
| 603 | status.mactime += mactime; |
| 604 | if (low_mactime_now <= mactime) |
| 605 | status.mactime -= 0x10000; |
| 606 | status.flag |= RX_FLAG_TSFT; |
| 607 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 608 | |
| 609 | chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT; |
| 610 | switch (chanstat & B43_RX_CHAN_PHYTYPE) { |
| 611 | case B43_PHYTYPE_A: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 612 | status.band = IEEE80211_BAND_5GHZ; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 613 | B43_WARN_ON(1); |
| 614 | /* FIXME: We don't really know which value the "chanid" contains. |
| 615 | * So the following assignment might be wrong. */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 616 | status.freq = b43_channel_to_freq_5ghz(chanid); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 617 | break; |
| 618 | case B43_PHYTYPE_G: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 619 | status.band = IEEE80211_BAND_2GHZ; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 620 | /* chanid is the radio channel cookie value as used |
| 621 | * to tune the radio. */ |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 622 | status.freq = chanid + 2400; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 623 | break; |
| 624 | case B43_PHYTYPE_N: |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 625 | /* chanid is the SHM channel cookie. Which is the plain |
| 626 | * channel number in b43. */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 627 | if (chanstat & B43_RX_CHAN_5GHZ) { |
| 628 | status.band = IEEE80211_BAND_5GHZ; |
| 629 | status.freq = b43_freq_to_channel_5ghz(chanid); |
| 630 | } else { |
| 631 | status.band = IEEE80211_BAND_2GHZ; |
| 632 | status.freq = b43_freq_to_channel_2ghz(chanid); |
| 633 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 634 | break; |
| 635 | default: |
| 636 | B43_WARN_ON(1); |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 637 | goto drop; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | dev->stats.last_rx = jiffies; |
| 641 | ieee80211_rx_irqsafe(dev->wl->hw, skb, &status); |
| 642 | |
| 643 | return; |
| 644 | drop: |
| 645 | b43dbg(dev->wl, "RX: Packet dropped\n"); |
| 646 | dev_kfree_skb_any(skb); |
| 647 | } |
| 648 | |
| 649 | void b43_handle_txstatus(struct b43_wldev *dev, |
| 650 | const struct b43_txstatus *status) |
| 651 | { |
| 652 | b43_debugfs_log_txstat(dev, status); |
| 653 | |
| 654 | if (status->intermediate) |
| 655 | return; |
| 656 | if (status->for_ampdu) |
| 657 | return; |
| 658 | if (!status->acked) |
| 659 | dev->wl->ieee_stats.dot11ACKFailureCount++; |
| 660 | if (status->rts_count) { |
| 661 | if (status->rts_count == 0xF) //FIXME |
| 662 | dev->wl->ieee_stats.dot11RTSFailureCount++; |
| 663 | else |
| 664 | dev->wl->ieee_stats.dot11RTSSuccessCount++; |
| 665 | } |
| 666 | |
Michael Buesch | 03b2977 | 2007-12-26 14:41:30 +0100 | [diff] [blame] | 667 | b43_dma_handle_txstatus(dev, status); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | /* Handle TX status report as received through DMA/PIO queues */ |
| 671 | void b43_handle_hwtxstatus(struct b43_wldev *dev, |
| 672 | const struct b43_hwtxstatus *hw) |
| 673 | { |
| 674 | struct b43_txstatus status; |
| 675 | u8 tmp; |
| 676 | |
| 677 | status.cookie = le16_to_cpu(hw->cookie); |
| 678 | status.seq = le16_to_cpu(hw->seq); |
| 679 | status.phy_stat = hw->phy_stat; |
| 680 | tmp = hw->count; |
| 681 | status.frame_count = (tmp >> 4); |
| 682 | status.rts_count = (tmp & 0x0F); |
| 683 | tmp = hw->flags; |
| 684 | status.supp_reason = ((tmp & 0x1C) >> 2); |
| 685 | status.pm_indicated = !!(tmp & 0x80); |
| 686 | status.intermediate = !!(tmp & 0x40); |
| 687 | status.for_ampdu = !!(tmp & 0x20); |
| 688 | status.acked = !!(tmp & 0x02); |
| 689 | |
| 690 | b43_handle_txstatus(dev, &status); |
| 691 | } |
| 692 | |
| 693 | /* Stop any TX operation on the device (suspend the hardware queues) */ |
| 694 | void b43_tx_suspend(struct b43_wldev *dev) |
| 695 | { |
Michael Buesch | 03b2977 | 2007-12-26 14:41:30 +0100 | [diff] [blame] | 696 | b43_dma_tx_suspend(dev); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /* Resume any TX operation on the device (resume the hardware queues) */ |
| 700 | void b43_tx_resume(struct b43_wldev *dev) |
| 701 | { |
Michael Buesch | 03b2977 | 2007-12-26 14:41:30 +0100 | [diff] [blame] | 702 | b43_dma_tx_resume(dev); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | #if 0 |
| 706 | static void upload_qos_parms(struct b43_wldev *dev, |
| 707 | const u16 * parms, u16 offset) |
| 708 | { |
| 709 | int i; |
| 710 | |
| 711 | for (i = 0; i < B43_NR_QOSPARMS; i++) { |
| 712 | b43_shm_write16(dev, B43_SHM_SHARED, |
| 713 | offset + (i * 2), parms[i]); |
| 714 | } |
| 715 | } |
| 716 | #endif |
| 717 | |
| 718 | /* Initialize the QoS parameters */ |
| 719 | void b43_qos_init(struct b43_wldev *dev) |
| 720 | { |
| 721 | /* FIXME: This function must probably be called from the mac80211 |
| 722 | * config callback. */ |
| 723 | return; |
| 724 | |
| 725 | b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF); |
| 726 | //FIXME kill magic |
| 727 | b43_write16(dev, 0x688, b43_read16(dev, 0x688) | 0x4); |
| 728 | |
| 729 | /*TODO: We might need some stack support here to get the values. */ |
| 730 | } |