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 Büsch | eb032b9 | 2011-07-04 20:50:05 +0200 | [diff] [blame] | 9 | Copyright (C) 2005, 2006 Michael Buesch <m@bues.ch> |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 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 | |
Michael Buesch | 88499ab | 2009-10-09 20:33:32 +0200 | [diff] [blame] | 30 | #include "xmit.h" |
Michael Buesch | ef1a628 | 2008-08-27 18:53:02 +0200 | [diff] [blame] | 31 | #include "phy_common.h" |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 32 | #include "dma.h" |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 33 | #include "pio.h" |
Michael Buesch | 03b2977 | 2007-12-26 14:41:30 +0100 | [diff] [blame] | 34 | |
Rafał Miłecki | 3311abb | 2011-02-25 12:34:11 +0100 | [diff] [blame] | 35 | static const struct b43_tx_legacy_rate_phy_ctl_entry b43_tx_legacy_rate_phy_ctl[] = { |
| 36 | { B43_CCK_RATE_1MB, 0x0, 0x0 }, |
| 37 | { B43_CCK_RATE_2MB, 0x0, 0x1 }, |
| 38 | { B43_CCK_RATE_5MB, 0x0, 0x2 }, |
| 39 | { B43_CCK_RATE_11MB, 0x0, 0x3 }, |
| 40 | { B43_OFDM_RATE_6MB, B43_TXH_PHY1_CRATE_1_2, B43_TXH_PHY1_MODUL_BPSK }, |
| 41 | { B43_OFDM_RATE_9MB, B43_TXH_PHY1_CRATE_3_4, B43_TXH_PHY1_MODUL_BPSK }, |
| 42 | { B43_OFDM_RATE_12MB, B43_TXH_PHY1_CRATE_1_2, B43_TXH_PHY1_MODUL_QPSK }, |
| 43 | { B43_OFDM_RATE_18MB, B43_TXH_PHY1_CRATE_3_4, B43_TXH_PHY1_MODUL_QPSK }, |
| 44 | { B43_OFDM_RATE_24MB, B43_TXH_PHY1_CRATE_1_2, B43_TXH_PHY1_MODUL_QAM16 }, |
| 45 | { B43_OFDM_RATE_36MB, B43_TXH_PHY1_CRATE_3_4, B43_TXH_PHY1_MODUL_QAM16 }, |
| 46 | { B43_OFDM_RATE_48MB, B43_TXH_PHY1_CRATE_2_3, B43_TXH_PHY1_MODUL_QAM64 }, |
| 47 | { B43_OFDM_RATE_54MB, B43_TXH_PHY1_CRATE_3_4, B43_TXH_PHY1_MODUL_QAM64 }, |
| 48 | }; |
| 49 | |
| 50 | static const struct b43_tx_legacy_rate_phy_ctl_entry * |
| 51 | b43_tx_legacy_rate_phy_ctl_ent(u8 bitrate) |
| 52 | { |
| 53 | const struct b43_tx_legacy_rate_phy_ctl_entry *e; |
| 54 | unsigned int i; |
| 55 | |
| 56 | for (i = 0; i < ARRAY_SIZE(b43_tx_legacy_rate_phy_ctl); i++) { |
| 57 | e = &(b43_tx_legacy_rate_phy_ctl[i]); |
| 58 | if (e->bitrate == bitrate) |
| 59 | return e; |
| 60 | } |
| 61 | |
| 62 | B43_WARN_ON(1); |
| 63 | return NULL; |
| 64 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 65 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 66 | /* Extract the bitrate index out of a CCK PLCP header. */ |
| 67 | 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] | 68 | { |
| 69 | switch (plcp->raw[0]) { |
| 70 | case 0x0A: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 71 | return 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 72 | case 0x14: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 73 | return 1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 74 | case 0x37: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 75 | return 2; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 76 | case 0x6E: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 77 | return 3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 78 | } |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 79 | return -1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 82 | /* Extract the bitrate index out of an OFDM PLCP header. */ |
Lorenzo Nava | a3c0b87 | 2009-03-22 19:15:41 +0100 | [diff] [blame] | 83 | static int 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] | 84 | { |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 85 | int base = aphy ? 0 : 4; |
| 86 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 87 | switch (plcp->raw[0] & 0xF) { |
| 88 | case 0xB: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 89 | return base + 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 90 | case 0xF: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 91 | return base + 1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 92 | case 0xA: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 93 | return base + 2; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 94 | case 0xE: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 95 | return base + 3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 96 | case 0x9: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 97 | return base + 4; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 98 | case 0xD: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 99 | return base + 5; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 100 | case 0x8: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 101 | return base + 6; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 102 | case 0xC: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 103 | return base + 7; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 104 | } |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 105 | return -1; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | u8 b43_plcp_get_ratecode_cck(const u8 bitrate) |
| 109 | { |
| 110 | switch (bitrate) { |
| 111 | case B43_CCK_RATE_1MB: |
| 112 | return 0x0A; |
| 113 | case B43_CCK_RATE_2MB: |
| 114 | return 0x14; |
| 115 | case B43_CCK_RATE_5MB: |
| 116 | return 0x37; |
| 117 | case B43_CCK_RATE_11MB: |
| 118 | return 0x6E; |
| 119 | } |
| 120 | B43_WARN_ON(1); |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | u8 b43_plcp_get_ratecode_ofdm(const u8 bitrate) |
| 125 | { |
| 126 | switch (bitrate) { |
| 127 | case B43_OFDM_RATE_6MB: |
| 128 | return 0xB; |
| 129 | case B43_OFDM_RATE_9MB: |
| 130 | return 0xF; |
| 131 | case B43_OFDM_RATE_12MB: |
| 132 | return 0xA; |
| 133 | case B43_OFDM_RATE_18MB: |
| 134 | return 0xE; |
| 135 | case B43_OFDM_RATE_24MB: |
| 136 | return 0x9; |
| 137 | case B43_OFDM_RATE_36MB: |
| 138 | return 0xD; |
| 139 | case B43_OFDM_RATE_48MB: |
| 140 | return 0x8; |
| 141 | case B43_OFDM_RATE_54MB: |
| 142 | return 0xC; |
| 143 | } |
| 144 | B43_WARN_ON(1); |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | void b43_generate_plcp_hdr(struct b43_plcp_hdr4 *plcp, |
| 149 | const u16 octets, const u8 bitrate) |
| 150 | { |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 151 | __u8 *raw = plcp->raw; |
| 152 | |
| 153 | if (b43_is_ofdm_rate(bitrate)) { |
Michael Buesch | 1a09404 | 2007-09-20 11:13:40 -0700 | [diff] [blame] | 154 | u32 d; |
| 155 | |
| 156 | d = b43_plcp_get_ratecode_ofdm(bitrate); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 157 | B43_WARN_ON(octets & 0xF000); |
Michael Buesch | 1a09404 | 2007-09-20 11:13:40 -0700 | [diff] [blame] | 158 | d |= (octets << 5); |
Matthieu CASTET | b52a033 | 2009-06-04 23:18:33 +0200 | [diff] [blame] | 159 | plcp->data = cpu_to_le32(d); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 160 | } else { |
| 161 | u32 plen; |
| 162 | |
| 163 | plen = octets * 16 / bitrate; |
| 164 | if ((octets * 16 % bitrate) > 0) { |
| 165 | plen++; |
| 166 | if ((bitrate == B43_CCK_RATE_11MB) |
| 167 | && ((octets * 8 % 11) < 4)) { |
| 168 | raw[1] = 0x84; |
| 169 | } else |
| 170 | raw[1] = 0x04; |
| 171 | } else |
| 172 | raw[1] = 0x04; |
Matthieu CASTET | b52a033 | 2009-06-04 23:18:33 +0200 | [diff] [blame] | 173 | plcp->data |= cpu_to_le32(plen << 16); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 174 | raw[0] = b43_plcp_get_ratecode_cck(bitrate); |
| 175 | } |
| 176 | } |
| 177 | |
Rafał Miłecki | 3311abb | 2011-02-25 12:34:11 +0100 | [diff] [blame] | 178 | static u16 b43_generate_tx_phy_ctl1(struct b43_wldev *dev, u8 bitrate) |
| 179 | { |
| 180 | const struct b43_phy *phy = &dev->phy; |
| 181 | const struct b43_tx_legacy_rate_phy_ctl_entry *e; |
| 182 | u16 control = 0; |
| 183 | u16 bw; |
| 184 | |
| 185 | if (phy->type == B43_PHYTYPE_LP) |
| 186 | bw = B43_TXH_PHY1_BW_20; |
| 187 | else /* FIXME */ |
| 188 | bw = B43_TXH_PHY1_BW_20; |
| 189 | |
| 190 | if (0) { /* FIXME: MIMO */ |
| 191 | } else if (b43_is_cck_rate(bitrate) && phy->type != B43_PHYTYPE_LP) { |
| 192 | control = bw; |
| 193 | } else { |
| 194 | control = bw; |
| 195 | e = b43_tx_legacy_rate_phy_ctl_ent(bitrate); |
| 196 | if (e) { |
| 197 | control |= e->coding_rate; |
| 198 | control |= e->modulation; |
| 199 | } |
| 200 | control |= B43_TXH_PHY1_MODE_SISO; |
| 201 | } |
| 202 | |
| 203 | return control; |
| 204 | } |
| 205 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 206 | static u8 b43_calc_fallback_rate(u8 bitrate) |
| 207 | { |
| 208 | switch (bitrate) { |
| 209 | case B43_CCK_RATE_1MB: |
| 210 | return B43_CCK_RATE_1MB; |
| 211 | case B43_CCK_RATE_2MB: |
| 212 | return B43_CCK_RATE_1MB; |
| 213 | case B43_CCK_RATE_5MB: |
| 214 | return B43_CCK_RATE_2MB; |
| 215 | case B43_CCK_RATE_11MB: |
| 216 | return B43_CCK_RATE_5MB; |
| 217 | case B43_OFDM_RATE_6MB: |
| 218 | return B43_CCK_RATE_5MB; |
| 219 | case B43_OFDM_RATE_9MB: |
| 220 | return B43_OFDM_RATE_6MB; |
| 221 | case B43_OFDM_RATE_12MB: |
| 222 | return B43_OFDM_RATE_9MB; |
| 223 | case B43_OFDM_RATE_18MB: |
| 224 | return B43_OFDM_RATE_12MB; |
| 225 | case B43_OFDM_RATE_24MB: |
| 226 | return B43_OFDM_RATE_18MB; |
| 227 | case B43_OFDM_RATE_36MB: |
| 228 | return B43_OFDM_RATE_24MB; |
| 229 | case B43_OFDM_RATE_48MB: |
| 230 | return B43_OFDM_RATE_36MB; |
| 231 | case B43_OFDM_RATE_54MB: |
| 232 | return B43_OFDM_RATE_48MB; |
| 233 | } |
| 234 | B43_WARN_ON(1); |
| 235 | return 0; |
| 236 | } |
| 237 | |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 238 | /* Generate a TX data header. */ |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 239 | int b43_generate_txhdr(struct b43_wldev *dev, |
| 240 | u8 *_txhdr, |
gregor kowski | 035d024 | 2009-08-19 22:35:45 +0200 | [diff] [blame] | 241 | struct sk_buff *skb_frag, |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 242 | struct ieee80211_tx_info *info, |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 243 | u16 cookie) |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 244 | { |
gregor kowski | 035d024 | 2009-08-19 22:35:45 +0200 | [diff] [blame] | 245 | const unsigned char *fragment_data = skb_frag->data; |
| 246 | unsigned int fragment_len = skb_frag->len; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 247 | struct b43_txhdr *txhdr = (struct b43_txhdr *)_txhdr; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 248 | const struct b43_phy *phy = &dev->phy; |
| 249 | const struct ieee80211_hdr *wlhdr = |
| 250 | (const struct ieee80211_hdr *)fragment_data; |
Johannes Berg | d0f0980 | 2008-07-29 11:32:07 +0200 | [diff] [blame] | 251 | int use_encryption = !!info->control.hw_key; |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 252 | __le16 fctl = wlhdr->frame_control; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 253 | struct ieee80211_rate *fbrate; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 254 | u8 rate, rate_fb; |
| 255 | int rate_ofdm, rate_fb_ofdm; |
| 256 | unsigned int plcp_fragment_len; |
| 257 | u32 mac_ctl = 0; |
| 258 | u16 phy_ctl = 0; |
| 259 | u8 extra_ft = 0; |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 260 | struct ieee80211_rate *txrate; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 261 | struct ieee80211_tx_rate *rates; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 262 | |
| 263 | memset(txhdr, 0, sizeof(*txhdr)); |
| 264 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 265 | txrate = ieee80211_get_tx_rate(dev->wl->hw, info); |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 266 | rate = txrate ? txrate->hw_value : B43_CCK_RATE_1MB; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 267 | rate_ofdm = b43_is_ofdm_rate(rate); |
Felix Fietkau | 870abdf | 2008-10-05 18:04:24 +0200 | [diff] [blame] | 268 | fbrate = ieee80211_get_alt_retry_rate(dev->wl->hw, info, 0) ? : txrate; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 269 | rate_fb = fbrate->hw_value; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 270 | rate_fb_ofdm = b43_is_ofdm_rate(rate_fb); |
| 271 | |
| 272 | if (rate_ofdm) |
| 273 | txhdr->phy_rate = b43_plcp_get_ratecode_ofdm(rate); |
| 274 | else |
| 275 | txhdr->phy_rate = b43_plcp_get_ratecode_cck(rate); |
| 276 | txhdr->mac_frame_ctl = wlhdr->frame_control; |
| 277 | memcpy(txhdr->tx_receiver, wlhdr->addr1, 6); |
| 278 | |
| 279 | /* Calculate duration for fallback rate */ |
| 280 | if ((rate_fb == rate) || |
| 281 | (wlhdr->duration_id & cpu_to_le16(0x8000)) || |
| 282 | (wlhdr->duration_id == cpu_to_le16(0))) { |
| 283 | /* If the fallback rate equals the normal rate or the |
| 284 | * dur_id field contains an AID, CFP magic or 0, |
| 285 | * use the original dur_id field. */ |
| 286 | txhdr->dur_fb = wlhdr->duration_id; |
| 287 | } else { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 288 | txhdr->dur_fb = ieee80211_generic_frame_duration( |
| 289 | dev->wl->hw, info->control.vif, fragment_len, fbrate); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | plcp_fragment_len = fragment_len + FCS_LEN; |
| 293 | if (use_encryption) { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 294 | u8 key_idx = info->control.hw_key->hw_key_idx; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 295 | struct b43_key *key; |
| 296 | int wlhdr_len; |
| 297 | size_t iv_len; |
| 298 | |
Michael Buesch | 66d2d08 | 2009-08-06 10:36:50 +0200 | [diff] [blame] | 299 | B43_WARN_ON(key_idx >= ARRAY_SIZE(dev->key)); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 300 | key = &(dev->key[key_idx]); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 301 | |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 302 | if (unlikely(!key->keyconf)) { |
| 303 | /* This key is invalid. This might only happen |
| 304 | * in a short timeframe after machine resume before |
| 305 | * we were able to reconfigure keys. |
| 306 | * Drop this packet completely. Do not transmit it |
| 307 | * unencrypted to avoid leaking information. */ |
| 308 | return -ENOKEY; |
Michael Buesch | 7be1bb6 | 2008-01-23 21:10:56 +0100 | [diff] [blame] | 309 | } |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 310 | |
| 311 | /* Hardware appends ICV. */ |
Felix Fietkau | 76708de | 2008-10-05 18:02:48 +0200 | [diff] [blame] | 312 | plcp_fragment_len += info->control.hw_key->icv_len; |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 313 | |
| 314 | key_idx = b43_kidx_to_fw(dev, key_idx); |
| 315 | mac_ctl |= (key_idx << B43_TXH_MAC_KEYIDX_SHIFT) & |
| 316 | B43_TXH_MAC_KEYIDX; |
| 317 | mac_ctl |= (key->algorithm << B43_TXH_MAC_KEYALG_SHIFT) & |
| 318 | B43_TXH_MAC_KEYALG; |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 319 | wlhdr_len = ieee80211_hdrlen(fctl); |
gregor kowski | 035d024 | 2009-08-19 22:35:45 +0200 | [diff] [blame] | 320 | if (key->algorithm == B43_SEC_ALGO_TKIP) { |
| 321 | u16 phase1key[5]; |
| 322 | int i; |
| 323 | /* we give the phase1key and iv16 here, the key is stored in |
| 324 | * shm. With that the hardware can do phase 2 and encryption. |
| 325 | */ |
Johannes Berg | 523b02e | 2011-07-07 22:28:01 +0200 | [diff] [blame] | 326 | ieee80211_get_tkip_p1k(info->control.hw_key, skb_frag, phase1key); |
Michael Buesch | cde1b55 | 2009-09-06 16:18:58 +0200 | [diff] [blame] | 327 | /* phase1key is in host endian. Copy to little-endian txhdr->iv. */ |
| 328 | for (i = 0; i < 5; i++) { |
| 329 | txhdr->iv[i * 2 + 0] = phase1key[i]; |
| 330 | txhdr->iv[i * 2 + 1] = phase1key[i] >> 8; |
| 331 | } |
gregor kowski | 035d024 | 2009-08-19 22:35:45 +0200 | [diff] [blame] | 332 | /* iv16 */ |
| 333 | memcpy(txhdr->iv + 10, ((u8 *) wlhdr) + wlhdr_len, 3); |
| 334 | } else { |
| 335 | iv_len = min((size_t) info->control.hw_key->iv_len, |
| 336 | ARRAY_SIZE(txhdr->iv)); |
| 337 | memcpy(txhdr->iv, ((u8 *) wlhdr) + wlhdr_len, iv_len); |
| 338 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 339 | } |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 340 | switch (dev->fw.hdr_format) { |
| 341 | case B43_FW_HDR_351: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 342 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->format_351.plcp), |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 343 | plcp_fragment_len, rate); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 344 | break; |
| 345 | case B43_FW_HDR_410: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 346 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->format_410.plcp), |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 347 | plcp_fragment_len, rate); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 348 | break; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 349 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 350 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)(&txhdr->plcp_fb), |
| 351 | plcp_fragment_len, rate_fb); |
| 352 | |
| 353 | /* Extra Frame Types */ |
| 354 | if (rate_fb_ofdm) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 355 | extra_ft |= B43_TXH_EFT_FB_OFDM; |
| 356 | else |
| 357 | extra_ft |= B43_TXH_EFT_FB_CCK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 358 | |
| 359 | /* Set channel radio code. Note that the micrcode ORs 0x100 to |
| 360 | * this value before comparing it to the value in SHM, if this |
| 361 | * is a 5Ghz packet. |
| 362 | */ |
| 363 | txhdr->chan_radio_code = phy->channel; |
| 364 | |
| 365 | /* PHY TX Control word */ |
| 366 | if (rate_ofdm) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 367 | phy_ctl |= B43_TXH_PHY_ENC_OFDM; |
| 368 | else |
| 369 | phy_ctl |= B43_TXH_PHY_ENC_CCK; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 370 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 371 | phy_ctl |= B43_TXH_PHY_SHORTPRMBL; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 372 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 373 | switch (b43_ieee80211_antenna_sanitize(dev, info->antenna_sel_tx)) { |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 374 | case 0: /* Default */ |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 375 | phy_ctl |= B43_TXH_PHY_ANT01AUTO; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 376 | break; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 377 | case 1: /* Antenna 0 */ |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 378 | phy_ctl |= B43_TXH_PHY_ANT0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 379 | break; |
Michael Buesch | 9db1f6d | 2007-12-22 21:54:20 +0100 | [diff] [blame] | 380 | case 2: /* Antenna 1 */ |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 381 | phy_ctl |= B43_TXH_PHY_ANT1; |
| 382 | break; |
| 383 | case 3: /* Antenna 2 */ |
| 384 | phy_ctl |= B43_TXH_PHY_ANT2; |
| 385 | break; |
| 386 | case 4: /* Antenna 3 */ |
| 387 | phy_ctl |= B43_TXH_PHY_ANT3; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 388 | break; |
| 389 | default: |
| 390 | B43_WARN_ON(1); |
| 391 | } |
| 392 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 393 | rates = info->control.rates; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 394 | /* MAC control */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 395 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 396 | mac_ctl |= B43_TXH_MAC_ACK; |
Johannes Berg | f591fa5 | 2008-07-10 11:21:26 +0200 | [diff] [blame] | 397 | /* use hardware sequence counter as the non-TID counter */ |
| 398 | if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 399 | mac_ctl |= B43_TXH_MAC_HWSEQ; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 400 | if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 401 | mac_ctl |= B43_TXH_MAC_STMSDU; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 402 | if (phy->type == B43_PHYTYPE_A) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 403 | mac_ctl |= B43_TXH_MAC_5GHZ; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 404 | |
| 405 | /* Overwrite rates[0].count to make the retry calculation |
| 406 | * in the tx status easier. need the actual retry limit to |
| 407 | * detect whether the fallback rate was used. |
| 408 | */ |
| 409 | if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || |
| 410 | (rates[0].count <= dev->wl->hw->conf.long_frame_max_tx_count)) { |
| 411 | rates[0].count = dev->wl->hw->conf.long_frame_max_tx_count; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 412 | mac_ctl |= B43_TXH_MAC_LONGFRAME; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 413 | } else { |
| 414 | rates[0].count = dev->wl->hw->conf.short_frame_max_tx_count; |
| 415 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 416 | |
| 417 | /* Generate the RTS or CTS-to-self frame */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 418 | if ((rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || |
| 419 | (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)) { |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 420 | unsigned int len; |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 421 | struct ieee80211_hdr *uninitialized_var(hdr); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 422 | int rts_rate, rts_rate_fb; |
| 423 | int rts_rate_ofdm, rts_rate_fb_ofdm; |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 424 | struct b43_plcp_hdr6 *uninitialized_var(plcp); |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 425 | struct ieee80211_rate *rts_cts_rate; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 426 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 427 | rts_cts_rate = ieee80211_get_rts_cts_rate(dev->wl->hw, info); |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 428 | |
| 429 | rts_rate = rts_cts_rate ? rts_cts_rate->hw_value : B43_CCK_RATE_1MB; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 430 | rts_rate_ofdm = b43_is_ofdm_rate(rts_rate); |
| 431 | rts_rate_fb = b43_calc_fallback_rate(rts_rate); |
| 432 | rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb); |
| 433 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 434 | if (rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 435 | struct ieee80211_cts *uninitialized_var(cts); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 436 | |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 437 | switch (dev->fw.hdr_format) { |
| 438 | case B43_FW_HDR_351: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 439 | cts = (struct ieee80211_cts *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 440 | (txhdr->format_351.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 441 | break; |
| 442 | case B43_FW_HDR_410: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 443 | cts = (struct ieee80211_cts *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 444 | (txhdr->format_410.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 445 | break; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 446 | } |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 447 | ieee80211_ctstoself_get(dev->wl->hw, info->control.vif, |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 448 | fragment_data, fragment_len, |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 449 | info, cts); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 450 | mac_ctl |= B43_TXH_MAC_SENDCTS; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 451 | len = sizeof(struct ieee80211_cts); |
| 452 | } else { |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 453 | struct ieee80211_rts *uninitialized_var(rts); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 454 | |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 455 | switch (dev->fw.hdr_format) { |
| 456 | case B43_FW_HDR_351: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 457 | rts = (struct ieee80211_rts *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 458 | (txhdr->format_351.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 459 | break; |
| 460 | case B43_FW_HDR_410: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 461 | rts = (struct ieee80211_rts *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 462 | (txhdr->format_410.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 463 | break; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 464 | } |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 465 | ieee80211_rts_get(dev->wl->hw, info->control.vif, |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 466 | fragment_data, fragment_len, |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 467 | info, rts); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 468 | mac_ctl |= B43_TXH_MAC_SENDRTS; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 469 | len = sizeof(struct ieee80211_rts); |
| 470 | } |
| 471 | len += FCS_LEN; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 472 | |
| 473 | /* Generate the PLCP headers for the RTS/CTS frame */ |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 474 | switch (dev->fw.hdr_format) { |
| 475 | case B43_FW_HDR_351: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 476 | plcp = &txhdr->format_351.rts_plcp; |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 477 | break; |
| 478 | case B43_FW_HDR_410: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 479 | plcp = &txhdr->format_410.rts_plcp; |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 480 | break; |
| 481 | } |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 482 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)plcp, |
| 483 | len, rts_rate); |
| 484 | plcp = &txhdr->rts_plcp_fb; |
| 485 | b43_generate_plcp_hdr((struct b43_plcp_hdr4 *)plcp, |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 486 | len, rts_rate_fb); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 487 | |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 488 | switch (dev->fw.hdr_format) { |
| 489 | case B43_FW_HDR_351: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 490 | hdr = (struct ieee80211_hdr *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 491 | (&txhdr->format_351.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 492 | break; |
| 493 | case B43_FW_HDR_410: |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 494 | hdr = (struct ieee80211_hdr *) |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 495 | (&txhdr->format_410.rts_frame); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 496 | break; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 497 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 498 | txhdr->rts_dur_fb = hdr->duration_id; |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 499 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 500 | if (rts_rate_ofdm) { |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 501 | extra_ft |= B43_TXH_EFT_RTS_OFDM; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 502 | txhdr->phy_rate_rts = |
| 503 | b43_plcp_get_ratecode_ofdm(rts_rate); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 504 | } else { |
| 505 | extra_ft |= B43_TXH_EFT_RTS_CCK; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 506 | txhdr->phy_rate_rts = |
| 507 | b43_plcp_get_ratecode_cck(rts_rate); |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 508 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 509 | if (rts_rate_fb_ofdm) |
Michael Buesch | eb189d8b | 2008-01-28 14:47:41 -0800 | [diff] [blame] | 510 | extra_ft |= B43_TXH_EFT_RTSFB_OFDM; |
| 511 | else |
| 512 | extra_ft |= B43_TXH_EFT_RTSFB_CCK; |
Rafał Miłecki | 3311abb | 2011-02-25 12:34:11 +0100 | [diff] [blame] | 513 | |
| 514 | if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS && |
| 515 | phy->type == B43_PHYTYPE_N) { |
| 516 | txhdr->phy_ctl1_rts = cpu_to_le16( |
| 517 | b43_generate_tx_phy_ctl1(dev, rts_rate)); |
| 518 | txhdr->phy_ctl1_rts_fb = cpu_to_le16( |
| 519 | b43_generate_tx_phy_ctl1(dev, rts_rate_fb)); |
| 520 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | /* Magic cookie */ |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 524 | switch (dev->fw.hdr_format) { |
| 525 | case B43_FW_HDR_351: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 526 | txhdr->format_351.cookie = cpu_to_le16(cookie); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 527 | break; |
| 528 | case B43_FW_HDR_410: |
Rafał Miłecki | 2391b7e | 2011-08-11 15:07:14 +0200 | [diff] [blame] | 529 | txhdr->format_410.cookie = cpu_to_le16(cookie); |
Rafał Miłecki | efe0249 | 2011-08-11 15:07:15 +0200 | [diff] [blame^] | 530 | break; |
| 531 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 532 | |
Rafał Miłecki | 3311abb | 2011-02-25 12:34:11 +0100 | [diff] [blame] | 533 | if (phy->type == B43_PHYTYPE_N) { |
| 534 | txhdr->phy_ctl1 = |
| 535 | cpu_to_le16(b43_generate_tx_phy_ctl1(dev, rate)); |
| 536 | txhdr->phy_ctl1_fb = |
| 537 | cpu_to_le16(b43_generate_tx_phy_ctl1(dev, rate_fb)); |
| 538 | } |
| 539 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 540 | /* Apply the bitfields */ |
| 541 | txhdr->mac_ctl = cpu_to_le32(mac_ctl); |
| 542 | txhdr->phy_ctl = cpu_to_le16(phy_ctl); |
| 543 | txhdr->extra_ft = extra_ft; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 544 | |
Michael Buesch | 09552cc | 2008-01-23 21:44:15 +0100 | [diff] [blame] | 545 | return 0; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | static s8 b43_rssi_postprocess(struct b43_wldev *dev, |
| 549 | u8 in_rssi, int ofdm, |
| 550 | int adjust_2053, int adjust_2050) |
| 551 | { |
| 552 | struct b43_phy *phy = &dev->phy; |
Michael Buesch | ef1a628 | 2008-08-27 18:53:02 +0200 | [diff] [blame] | 553 | struct b43_phy_g *gphy = phy->g; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 554 | s32 tmp; |
| 555 | |
| 556 | switch (phy->radio_ver) { |
| 557 | case 0x2050: |
| 558 | if (ofdm) { |
| 559 | tmp = in_rssi; |
| 560 | if (tmp > 127) |
| 561 | tmp -= 256; |
| 562 | tmp *= 73; |
| 563 | tmp /= 64; |
| 564 | if (adjust_2050) |
| 565 | tmp += 25; |
| 566 | else |
| 567 | tmp -= 3; |
| 568 | } else { |
Rafał Miłecki | 0581483 | 2011-05-18 02:06:39 +0200 | [diff] [blame] | 569 | if (dev->dev->bus_sprom-> |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 570 | boardflags_lo & B43_BFL_RSSI) { |
| 571 | if (in_rssi > 63) |
| 572 | in_rssi = 63; |
Michael Buesch | ef1a628 | 2008-08-27 18:53:02 +0200 | [diff] [blame] | 573 | B43_WARN_ON(phy->type != B43_PHYTYPE_G); |
| 574 | tmp = gphy->nrssi_lt[in_rssi]; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 575 | tmp = 31 - tmp; |
| 576 | tmp *= -131; |
| 577 | tmp /= 128; |
| 578 | tmp -= 57; |
| 579 | } else { |
| 580 | tmp = in_rssi; |
| 581 | tmp = 31 - tmp; |
| 582 | tmp *= -149; |
| 583 | tmp /= 128; |
| 584 | tmp -= 68; |
| 585 | } |
| 586 | if (phy->type == B43_PHYTYPE_G && adjust_2050) |
| 587 | tmp += 25; |
| 588 | } |
| 589 | break; |
| 590 | case 0x2060: |
| 591 | if (in_rssi > 127) |
| 592 | tmp = in_rssi - 256; |
| 593 | else |
| 594 | tmp = in_rssi; |
| 595 | break; |
| 596 | default: |
| 597 | tmp = in_rssi; |
| 598 | tmp -= 11; |
| 599 | tmp *= 103; |
| 600 | tmp /= 64; |
| 601 | if (adjust_2053) |
| 602 | tmp -= 109; |
| 603 | else |
| 604 | tmp -= 83; |
| 605 | } |
| 606 | |
| 607 | return (s8) tmp; |
| 608 | } |
| 609 | |
| 610 | //TODO |
| 611 | #if 0 |
| 612 | static s8 b43_rssinoise_postprocess(struct b43_wldev *dev, u8 in_rssi) |
| 613 | { |
| 614 | struct b43_phy *phy = &dev->phy; |
| 615 | s8 ret; |
| 616 | |
| 617 | if (phy->type == B43_PHYTYPE_A) { |
| 618 | //TODO: Incomplete specs. |
| 619 | ret = 0; |
| 620 | } else |
| 621 | ret = b43_rssi_postprocess(dev, in_rssi, 0, 1, 1); |
| 622 | |
| 623 | return ret; |
| 624 | } |
| 625 | #endif |
| 626 | |
| 627 | void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) |
| 628 | { |
| 629 | struct ieee80211_rx_status status; |
| 630 | struct b43_plcp_hdr6 *plcp; |
| 631 | struct ieee80211_hdr *wlhdr; |
| 632 | const struct b43_rxhdr_fw4 *rxhdr = _rxhdr; |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 633 | __le16 fctl; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 634 | u16 phystat0, phystat3, chanstat, mactime; |
| 635 | u32 macstat; |
| 636 | u16 chanid; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 637 | u16 phytype; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 638 | int padding; |
| 639 | |
| 640 | memset(&status, 0, sizeof(status)); |
| 641 | |
| 642 | /* Get metadata about the frame from the header. */ |
| 643 | phystat0 = le16_to_cpu(rxhdr->phy_status0); |
| 644 | phystat3 = le16_to_cpu(rxhdr->phy_status3); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 645 | macstat = le32_to_cpu(rxhdr->mac_status); |
| 646 | mactime = le16_to_cpu(rxhdr->mac_time); |
| 647 | chanstat = le16_to_cpu(rxhdr->channel); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 648 | phytype = chanstat & B43_RX_CHAN_PHYTYPE; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 649 | |
Michael Buesch | ce4fbdb | 2009-03-02 23:18:37 +0100 | [diff] [blame] | 650 | if (unlikely(macstat & B43_RX_MAC_FCSERR)) { |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 651 | dev->wl->ieee_stats.dot11FCSErrorCount++; |
Michael Buesch | ce4fbdb | 2009-03-02 23:18:37 +0100 | [diff] [blame] | 652 | status.flag |= RX_FLAG_FAILED_FCS_CRC; |
| 653 | } |
| 654 | if (unlikely(phystat0 & (B43_RX_PHYST0_PLCPHCF | B43_RX_PHYST0_PLCPFV))) |
| 655 | status.flag |= RX_FLAG_FAILED_PLCP_CRC; |
| 656 | if (phystat0 & B43_RX_PHYST0_SHORTPRMBL) |
| 657 | status.flag |= RX_FLAG_SHORTPRE; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 658 | if (macstat & B43_RX_MAC_DECERR) { |
| 659 | /* Decryption with the given key failed. |
| 660 | * Drop the packet. We also won't be able to decrypt it with |
| 661 | * the key in software. */ |
| 662 | goto drop; |
| 663 | } |
| 664 | |
| 665 | /* Skip PLCP and padding */ |
| 666 | padding = (macstat & B43_RX_MAC_PADDING) ? 2 : 0; |
| 667 | if (unlikely(skb->len < (sizeof(struct b43_plcp_hdr6) + padding))) { |
| 668 | b43dbg(dev->wl, "RX: Packet size underrun (1)\n"); |
| 669 | goto drop; |
| 670 | } |
| 671 | plcp = (struct b43_plcp_hdr6 *)(skb->data + padding); |
| 672 | skb_pull(skb, sizeof(struct b43_plcp_hdr6) + padding); |
| 673 | /* The skb contains the Wireless Header + payload data now */ |
| 674 | if (unlikely(skb->len < (2 + 2 + 6 /*minimum hdr */ + FCS_LEN))) { |
| 675 | b43dbg(dev->wl, "RX: Packet size underrun (2)\n"); |
| 676 | goto drop; |
| 677 | } |
| 678 | wlhdr = (struct ieee80211_hdr *)(skb->data); |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 679 | fctl = wlhdr->frame_control; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 680 | |
| 681 | if (macstat & B43_RX_MAC_DEC) { |
| 682 | unsigned int keyidx; |
| 683 | int wlhdr_len; |
| 684 | |
| 685 | keyidx = ((macstat & B43_RX_MAC_KEYIDX) |
| 686 | >> B43_RX_MAC_KEYIDX_SHIFT); |
| 687 | /* We must adjust the key index here. We want the "physical" |
| 688 | * key index, but the ucode passed it slightly different. |
| 689 | */ |
| 690 | keyidx = b43_kidx_to_raw(dev, keyidx); |
Michael Buesch | 66d2d08 | 2009-08-06 10:36:50 +0200 | [diff] [blame] | 691 | B43_WARN_ON(keyidx >= ARRAY_SIZE(dev->key)); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 692 | |
| 693 | if (dev->key[keyidx].algorithm != B43_SEC_ALGO_NONE) { |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 694 | wlhdr_len = ieee80211_hdrlen(fctl); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 695 | if (unlikely(skb->len < (wlhdr_len + 3))) { |
| 696 | b43dbg(dev->wl, |
| 697 | "RX: Packet size underrun (3)\n"); |
| 698 | goto drop; |
| 699 | } |
| 700 | status.flag |= RX_FLAG_DECRYPTED; |
| 701 | } |
| 702 | } |
| 703 | |
Michael Buesch | 7b58416 | 2008-04-03 18:01:12 +0200 | [diff] [blame] | 704 | /* Link quality statistics */ |
Michael Buesch | 7b58416 | 2008-04-03 18:01:12 +0200 | [diff] [blame] | 705 | if ((chanstat & B43_RX_CHAN_PHYTYPE) == B43_PHYTYPE_N) { |
| 706 | // s8 rssi = max(rxhdr->power0, rxhdr->power1); |
| 707 | //TODO: Find out what the rssi value is (dBm or percentage?) |
| 708 | // and also find out what the maximum possible value is. |
| 709 | // Fill status.ssi and status.signal fields. |
| 710 | } else { |
Bruno Randolf | 566bfe5 | 2008-05-08 19:15:40 +0200 | [diff] [blame] | 711 | status.signal = b43_rssi_postprocess(dev, rxhdr->jssi, |
Michael Buesch | 7b58416 | 2008-04-03 18:01:12 +0200 | [diff] [blame] | 712 | (phystat0 & B43_RX_PHYST0_OFDM), |
| 713 | (phystat0 & B43_RX_PHYST0_GAINCTL), |
| 714 | (phystat3 & B43_RX_PHYST3_TRSTATE)); |
Michael Buesch | 7b58416 | 2008-04-03 18:01:12 +0200 | [diff] [blame] | 715 | } |
| 716 | |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 717 | if (phystat0 & B43_RX_PHYST0_OFDM) |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 718 | status.rate_idx = b43_plcp_get_bitrate_idx_ofdm(plcp, |
| 719 | phytype == B43_PHYTYPE_A); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 720 | else |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 721 | status.rate_idx = b43_plcp_get_bitrate_idx_cck(plcp); |
Michael Buesch | ce4fbdb | 2009-03-02 23:18:37 +0100 | [diff] [blame] | 722 | if (unlikely(status.rate_idx == -1)) { |
| 723 | /* PLCP seems to be corrupted. |
| 724 | * Drop the frame, if we are not interested in corrupted frames. */ |
| 725 | if (!(dev->wl->filter_flags & FIF_PLCPFAIL)) |
| 726 | goto drop; |
| 727 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 728 | status.antenna = !!(phystat0 & B43_RX_PHYST0_ANT); |
John W. Linville | c0ddd04 | 2008-01-21 13:41:18 -0500 | [diff] [blame] | 729 | |
| 730 | /* |
Johannes Berg | d007b7f | 2008-02-18 18:53:55 +0100 | [diff] [blame] | 731 | * All frames on monitor interfaces and beacons always need a full |
| 732 | * 64-bit timestamp. Monitor interfaces need it for diagnostic |
| 733 | * purposes and beacons for IBSS merging. |
| 734 | * This code assumes we get to process the packet within 16 bits |
| 735 | * of timestamp, i.e. about 65 milliseconds after the PHY received |
| 736 | * the first symbol. |
John W. Linville | c0ddd04 | 2008-01-21 13:41:18 -0500 | [diff] [blame] | 737 | */ |
Harvey Harrison | f37d923 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 738 | if (ieee80211_is_beacon(fctl) || dev->wl->radiotap_enabled) { |
John W. Linville | c0ddd04 | 2008-01-21 13:41:18 -0500 | [diff] [blame] | 739 | u16 low_mactime_now; |
| 740 | |
| 741 | b43_tsf_read(dev, &status.mactime); |
| 742 | low_mactime_now = status.mactime; |
| 743 | status.mactime = status.mactime & ~0xFFFFULL; |
| 744 | status.mactime += mactime; |
| 745 | if (low_mactime_now <= mactime) |
| 746 | status.mactime -= 0x10000; |
Johannes Berg | 6ebacbb | 2011-02-23 15:06:08 +0100 | [diff] [blame] | 747 | status.flag |= RX_FLAG_MACTIME_MPDU; |
John W. Linville | c0ddd04 | 2008-01-21 13:41:18 -0500 | [diff] [blame] | 748 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 749 | |
| 750 | chanid = (chanstat & B43_RX_CHAN_ID) >> B43_RX_CHAN_ID_SHIFT; |
| 751 | switch (chanstat & B43_RX_CHAN_PHYTYPE) { |
| 752 | case B43_PHYTYPE_A: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 753 | status.band = IEEE80211_BAND_5GHZ; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 754 | B43_WARN_ON(1); |
| 755 | /* FIXME: We don't really know which value the "chanid" contains. |
| 756 | * So the following assignment might be wrong. */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 757 | status.freq = b43_channel_to_freq_5ghz(chanid); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 758 | break; |
| 759 | case B43_PHYTYPE_G: |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 760 | status.band = IEEE80211_BAND_2GHZ; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 761 | /* chanid is the radio channel cookie value as used |
| 762 | * to tune the radio. */ |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 763 | status.freq = chanid + 2400; |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 764 | break; |
| 765 | case B43_PHYTYPE_N: |
Gábor Stefanik | 826ee70 | 2009-08-15 00:52:02 +0200 | [diff] [blame] | 766 | case B43_PHYTYPE_LP: |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 767 | /* chanid is the SHM channel cookie. Which is the plain |
| 768 | * channel number in b43. */ |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 769 | if (chanstat & B43_RX_CHAN_5GHZ) { |
| 770 | status.band = IEEE80211_BAND_5GHZ; |
| 771 | status.freq = b43_freq_to_channel_5ghz(chanid); |
| 772 | } else { |
| 773 | status.band = IEEE80211_BAND_2GHZ; |
| 774 | status.freq = b43_freq_to_channel_2ghz(chanid); |
| 775 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 776 | break; |
| 777 | default: |
| 778 | B43_WARN_ON(1); |
Michael Buesch | d987160 | 2008-01-02 18:55:53 +0100 | [diff] [blame] | 779 | goto drop; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 780 | } |
| 781 | |
Johannes Berg | f1d58c2 | 2009-06-17 13:13:00 +0200 | [diff] [blame] | 782 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
John W. Linville | 72f5f45 | 2009-10-16 14:35:51 -0400 | [diff] [blame] | 783 | ieee80211_rx_ni(dev->wl->hw, skb); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 784 | |
Michael Buesch | 990b86f | 2009-09-12 00:48:03 +0200 | [diff] [blame] | 785 | #if B43_DEBUG |
| 786 | dev->rx_count++; |
| 787 | #endif |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 788 | return; |
| 789 | drop: |
| 790 | b43dbg(dev->wl, "RX: Packet dropped\n"); |
| 791 | dev_kfree_skb_any(skb); |
| 792 | } |
| 793 | |
| 794 | void b43_handle_txstatus(struct b43_wldev *dev, |
| 795 | const struct b43_txstatus *status) |
| 796 | { |
| 797 | b43_debugfs_log_txstat(dev, status); |
| 798 | |
| 799 | if (status->intermediate) |
| 800 | return; |
| 801 | if (status->for_ampdu) |
| 802 | return; |
| 803 | if (!status->acked) |
| 804 | dev->wl->ieee_stats.dot11ACKFailureCount++; |
| 805 | if (status->rts_count) { |
| 806 | if (status->rts_count == 0xF) //FIXME |
| 807 | dev->wl->ieee_stats.dot11RTSFailureCount++; |
| 808 | else |
| 809 | dev->wl->ieee_stats.dot11RTSSuccessCount++; |
| 810 | } |
| 811 | |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 812 | if (b43_using_pio_transfers(dev)) |
| 813 | b43_pio_handle_txstatus(dev, status); |
| 814 | else |
| 815 | b43_dma_handle_txstatus(dev, status); |
Michael Buesch | 18c8ade | 2008-08-28 19:33:40 +0200 | [diff] [blame] | 816 | |
| 817 | b43_phy_txpower_check(dev, 0); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 818 | } |
| 819 | |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 820 | /* Fill out the mac80211 TXstatus report based on the b43-specific |
| 821 | * txstatus report data. This returns a boolean whether the frame was |
| 822 | * successfully transmitted. */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 823 | bool b43_fill_txstatus_report(struct b43_wldev *dev, |
| 824 | struct ieee80211_tx_info *report, |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 825 | const struct b43_txstatus *status) |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 826 | { |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 827 | bool frame_success = 1; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 828 | int retry_limit; |
| 829 | |
| 830 | /* preserve the confiured retry limit before clearing the status |
| 831 | * The xmit function has overwritten the rc's value with the actual |
| 832 | * retry limit done by the hardware */ |
| 833 | retry_limit = report->status.rates[0].count; |
| 834 | ieee80211_tx_info_clear_status(report); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 835 | |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 836 | if (status->acked) { |
| 837 | /* The frame was ACKed. */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 838 | report->flags |= IEEE80211_TX_STAT_ACK; |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 839 | } else { |
| 840 | /* The frame was not ACKed... */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 841 | if (!(report->flags & IEEE80211_TX_CTL_NO_ACK)) { |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 842 | /* ...but we expected an ACK. */ |
| 843 | frame_success = 0; |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 844 | } |
| 845 | } |
| 846 | if (status->frame_count == 0) { |
| 847 | /* The frame was not transmitted at all. */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 848 | report->status.rates[0].count = 0; |
| 849 | } else if (status->rts_count > dev->wl->hw->conf.short_frame_max_tx_count) { |
| 850 | /* |
| 851 | * If the short retries (RTS, not data frame) have exceeded |
| 852 | * the limit, the hw will not have tried the selected rate, |
| 853 | * but will have used the fallback rate instead. |
| 854 | * Don't let the rate control count attempts for the selected |
| 855 | * rate in this case, otherwise the statistics will be off. |
| 856 | */ |
| 857 | report->status.rates[0].count = 0; |
| 858 | report->status.rates[1].count = status->frame_count; |
| 859 | } else { |
| 860 | if (status->frame_count > retry_limit) { |
| 861 | report->status.rates[0].count = retry_limit; |
| 862 | report->status.rates[1].count = status->frame_count - |
| 863 | retry_limit; |
| 864 | |
| 865 | } else { |
| 866 | report->status.rates[0].count = status->frame_count; |
| 867 | report->status.rates[1].idx = -1; |
| 868 | } |
| 869 | } |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 870 | |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 871 | return frame_success; |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | /* Stop any TX operation on the device (suspend the hardware queues) */ |
| 875 | void b43_tx_suspend(struct b43_wldev *dev) |
| 876 | { |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 877 | if (b43_using_pio_transfers(dev)) |
| 878 | b43_pio_tx_suspend(dev); |
| 879 | else |
| 880 | b43_dma_tx_suspend(dev); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | /* Resume any TX operation on the device (resume the hardware queues) */ |
| 884 | void b43_tx_resume(struct b43_wldev *dev) |
| 885 | { |
Michael Buesch | 5100d5a | 2008-03-29 21:01:16 +0100 | [diff] [blame] | 886 | if (b43_using_pio_transfers(dev)) |
| 887 | b43_pio_tx_resume(dev); |
| 888 | else |
| 889 | b43_dma_tx_resume(dev); |
Michael Buesch | e4d6b79 | 2007-09-18 15:39:42 -0400 | [diff] [blame] | 890 | } |