Daniel Drake | 66bb42f | 2007-11-19 16:20:12 +0000 | [diff] [blame] | 1 | /* ZD1211 USB-WLAN driver for Linux |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 2 | * |
Daniel Drake | 66bb42f | 2007-11-19 16:20:12 +0000 | [diff] [blame] | 3 | * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> |
| 4 | * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> |
| 5 | * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net> |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 6 | * Copyright (C) 2007-2008 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu> |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 7 | * |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <linux/netdevice.h> |
| 24 | #include <linux/etherdevice.h> |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 25 | #include <linux/usb.h> |
| 26 | #include <linux/jiffies.h> |
| 27 | #include <net/ieee80211_radiotap.h> |
| 28 | |
| 29 | #include "zd_def.h" |
| 30 | #include "zd_chip.h" |
| 31 | #include "zd_mac.h" |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 32 | #include "zd_rf.h" |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 33 | |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 34 | struct zd_reg_alpha2_map { |
| 35 | u32 reg; |
| 36 | char alpha2[2]; |
| 37 | }; |
| 38 | |
| 39 | static struct zd_reg_alpha2_map reg_alpha2_map[] = { |
| 40 | { ZD_REGDOMAIN_FCC, "US" }, |
| 41 | { ZD_REGDOMAIN_IC, "CA" }, |
| 42 | { ZD_REGDOMAIN_ETSI, "DE" }, /* Generic ETSI, use most restrictive */ |
| 43 | { ZD_REGDOMAIN_JAPAN, "JP" }, |
| 44 | { ZD_REGDOMAIN_JAPAN_ADD, "JP" }, |
| 45 | { ZD_REGDOMAIN_SPAIN, "ES" }, |
| 46 | { ZD_REGDOMAIN_FRANCE, "FR" }, |
| 47 | }; |
| 48 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 49 | /* This table contains the hardware specific values for the modulation rates. */ |
| 50 | static const struct ieee80211_rate zd_rates[] = { |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 51 | { .bitrate = 10, |
| 52 | .hw_value = ZD_CCK_RATE_1M, }, |
| 53 | { .bitrate = 20, |
| 54 | .hw_value = ZD_CCK_RATE_2M, |
| 55 | .hw_value_short = ZD_CCK_RATE_2M | ZD_CCK_PREA_SHORT, |
| 56 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 57 | { .bitrate = 55, |
| 58 | .hw_value = ZD_CCK_RATE_5_5M, |
| 59 | .hw_value_short = ZD_CCK_RATE_5_5M | ZD_CCK_PREA_SHORT, |
| 60 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 61 | { .bitrate = 110, |
| 62 | .hw_value = ZD_CCK_RATE_11M, |
| 63 | .hw_value_short = ZD_CCK_RATE_11M | ZD_CCK_PREA_SHORT, |
| 64 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, |
| 65 | { .bitrate = 60, |
| 66 | .hw_value = ZD_OFDM_RATE_6M, |
| 67 | .flags = 0 }, |
| 68 | { .bitrate = 90, |
| 69 | .hw_value = ZD_OFDM_RATE_9M, |
| 70 | .flags = 0 }, |
| 71 | { .bitrate = 120, |
| 72 | .hw_value = ZD_OFDM_RATE_12M, |
| 73 | .flags = 0 }, |
| 74 | { .bitrate = 180, |
| 75 | .hw_value = ZD_OFDM_RATE_18M, |
| 76 | .flags = 0 }, |
| 77 | { .bitrate = 240, |
| 78 | .hw_value = ZD_OFDM_RATE_24M, |
| 79 | .flags = 0 }, |
| 80 | { .bitrate = 360, |
| 81 | .hw_value = ZD_OFDM_RATE_36M, |
| 82 | .flags = 0 }, |
| 83 | { .bitrate = 480, |
| 84 | .hw_value = ZD_OFDM_RATE_48M, |
| 85 | .flags = 0 }, |
| 86 | { .bitrate = 540, |
| 87 | .hw_value = ZD_OFDM_RATE_54M, |
| 88 | .flags = 0 }, |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 91 | /* |
| 92 | * Zydas retry rates table. Each line is listed in the same order as |
| 93 | * in zd_rates[] and contains all the rate used when a packet is sent |
| 94 | * starting with a given rates. Let's consider an example : |
| 95 | * |
| 96 | * "11 Mbits : 4, 3, 2, 1, 0" means : |
| 97 | * - packet is sent using 4 different rates |
| 98 | * - 1st rate is index 3 (ie 11 Mbits) |
| 99 | * - 2nd rate is index 2 (ie 5.5 Mbits) |
| 100 | * - 3rd rate is index 1 (ie 2 Mbits) |
| 101 | * - 4th rate is index 0 (ie 1 Mbits) |
| 102 | */ |
| 103 | |
| 104 | static const struct tx_retry_rate zd_retry_rates[] = { |
| 105 | { /* 1 Mbits */ 1, { 0 }}, |
| 106 | { /* 2 Mbits */ 2, { 1, 0 }}, |
| 107 | { /* 5.5 Mbits */ 3, { 2, 1, 0 }}, |
| 108 | { /* 11 Mbits */ 4, { 3, 2, 1, 0 }}, |
| 109 | { /* 6 Mbits */ 5, { 4, 3, 2, 1, 0 }}, |
| 110 | { /* 9 Mbits */ 6, { 5, 4, 3, 2, 1, 0}}, |
| 111 | { /* 12 Mbits */ 5, { 6, 3, 2, 1, 0 }}, |
| 112 | { /* 18 Mbits */ 6, { 7, 6, 3, 2, 1, 0 }}, |
| 113 | { /* 24 Mbits */ 6, { 8, 6, 3, 2, 1, 0 }}, |
| 114 | { /* 36 Mbits */ 7, { 9, 8, 6, 3, 2, 1, 0 }}, |
| 115 | { /* 48 Mbits */ 8, {10, 9, 8, 6, 3, 2, 1, 0 }}, |
| 116 | { /* 54 Mbits */ 9, {11, 10, 9, 8, 6, 3, 2, 1, 0 }} |
| 117 | }; |
| 118 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 119 | static const struct ieee80211_channel zd_channels[] = { |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 120 | { .center_freq = 2412, .hw_value = 1 }, |
| 121 | { .center_freq = 2417, .hw_value = 2 }, |
| 122 | { .center_freq = 2422, .hw_value = 3 }, |
| 123 | { .center_freq = 2427, .hw_value = 4 }, |
| 124 | { .center_freq = 2432, .hw_value = 5 }, |
| 125 | { .center_freq = 2437, .hw_value = 6 }, |
| 126 | { .center_freq = 2442, .hw_value = 7 }, |
| 127 | { .center_freq = 2447, .hw_value = 8 }, |
| 128 | { .center_freq = 2452, .hw_value = 9 }, |
| 129 | { .center_freq = 2457, .hw_value = 10 }, |
| 130 | { .center_freq = 2462, .hw_value = 11 }, |
| 131 | { .center_freq = 2467, .hw_value = 12 }, |
| 132 | { .center_freq = 2472, .hw_value = 13 }, |
| 133 | { .center_freq = 2484, .hw_value = 14 }, |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 134 | }; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 135 | |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 136 | static void housekeeping_init(struct zd_mac *mac); |
| 137 | static void housekeeping_enable(struct zd_mac *mac); |
| 138 | static void housekeeping_disable(struct zd_mac *mac); |
| 139 | |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 140 | static int zd_reg2alpha2(u8 regdomain, char *alpha2) |
| 141 | { |
| 142 | unsigned int i; |
| 143 | struct zd_reg_alpha2_map *reg_map; |
| 144 | for (i = 0; i < ARRAY_SIZE(reg_alpha2_map); i++) { |
| 145 | reg_map = ®_alpha2_map[i]; |
| 146 | if (regdomain == reg_map->reg) { |
| 147 | alpha2[0] = reg_map->alpha2[0]; |
| 148 | alpha2[1] = reg_map->alpha2[1]; |
| 149 | return 0; |
| 150 | } |
| 151 | } |
| 152 | return 1; |
| 153 | } |
| 154 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 155 | int zd_mac_preinit_hw(struct ieee80211_hw *hw) |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 156 | { |
| 157 | int r; |
| 158 | u8 addr[ETH_ALEN]; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 159 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 160 | |
| 161 | r = zd_chip_read_mac_addr_fw(&mac->chip, addr); |
| 162 | if (r) |
| 163 | return r; |
| 164 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 165 | SET_IEEE80211_PERM_ADDR(hw, addr); |
| 166 | |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 167 | return 0; |
| 168 | } |
| 169 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 170 | int zd_mac_init_hw(struct ieee80211_hw *hw) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 171 | { |
| 172 | int r; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 173 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 174 | struct zd_chip *chip = &mac->chip; |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 175 | char alpha2[2]; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 176 | u8 default_regdomain; |
| 177 | |
| 178 | r = zd_chip_enable_int(chip); |
| 179 | if (r) |
| 180 | goto out; |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 181 | r = zd_chip_init_hw(chip); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 182 | if (r) |
| 183 | goto disable_int; |
| 184 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 185 | ZD_ASSERT(!irqs_disabled()); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 186 | |
| 187 | r = zd_read_regdomain(chip, &default_regdomain); |
| 188 | if (r) |
| 189 | goto disable_int; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 190 | spin_lock_irq(&mac->lock); |
| 191 | mac->regdomain = mac->default_regdomain = default_regdomain; |
| 192 | spin_unlock_irq(&mac->lock); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 193 | |
Daniel Drake | 40da08b | 2006-08-01 23:43:32 +0200 | [diff] [blame] | 194 | /* We must inform the device that we are doing encryption/decryption in |
| 195 | * software at the moment. */ |
| 196 | r = zd_set_encryption_type(chip, ENC_SNIFFER); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 197 | if (r) |
| 198 | goto disable_int; |
| 199 | |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 200 | r = zd_reg2alpha2(mac->regdomain, alpha2); |
Luis R. Rodriguez | fe33eb3 | 2009-02-21 00:04:30 -0500 | [diff] [blame] | 201 | if (r) |
| 202 | goto disable_int; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 203 | |
Luis R. Rodriguez | fe33eb3 | 2009-02-21 00:04:30 -0500 | [diff] [blame] | 204 | r = regulatory_hint(hw->wiphy, alpha2); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 205 | disable_int: |
| 206 | zd_chip_disable_int(chip); |
| 207 | out: |
| 208 | return r; |
| 209 | } |
| 210 | |
| 211 | void zd_mac_clear(struct zd_mac *mac) |
| 212 | { |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 213 | flush_workqueue(zd_workqueue); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 214 | zd_chip_clear(&mac->chip); |
Ulrich Kunitz | c48cf12 | 2006-08-12 18:00:17 +0100 | [diff] [blame] | 215 | ZD_ASSERT(!spin_is_locked(&mac->lock)); |
| 216 | ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 217 | } |
| 218 | |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 219 | static int set_rx_filter(struct zd_mac *mac) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 220 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 221 | unsigned long flags; |
| 222 | u32 filter = STA_RX_FILTER; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 223 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 224 | spin_lock_irqsave(&mac->lock, flags); |
| 225 | if (mac->pass_ctrl) |
| 226 | filter |= RX_FILTER_CTRL; |
| 227 | spin_unlock_irqrestore(&mac->lock, flags); |
| 228 | |
| 229 | return zd_iowrite32(&mac->chip, CR_RX_FILTER, filter); |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | static int set_mc_hash(struct zd_mac *mac) |
| 233 | { |
| 234 | struct zd_mc_hash hash; |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 235 | zd_mc_clear(&hash); |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 236 | return zd_chip_set_multicast_hash(&mac->chip, &hash); |
| 237 | } |
| 238 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 239 | static int zd_op_start(struct ieee80211_hw *hw) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 240 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 241 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 242 | struct zd_chip *chip = &mac->chip; |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 243 | struct zd_usb *usb = &chip->usb; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 244 | int r; |
| 245 | |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 246 | if (!usb->initialized) { |
| 247 | r = zd_usb_init_hw(usb); |
| 248 | if (r) |
| 249 | goto out; |
| 250 | } |
| 251 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 252 | r = zd_chip_enable_int(chip); |
| 253 | if (r < 0) |
| 254 | goto out; |
| 255 | |
| 256 | r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); |
| 257 | if (r < 0) |
| 258 | goto disable_int; |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 259 | r = set_rx_filter(mac); |
| 260 | if (r) |
| 261 | goto disable_int; |
Ulrich Kunitz | c569123 | 2007-07-21 22:42:13 +0100 | [diff] [blame] | 262 | r = set_mc_hash(mac); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 263 | if (r) |
| 264 | goto disable_int; |
| 265 | r = zd_chip_switch_radio_on(chip); |
| 266 | if (r < 0) |
| 267 | goto disable_int; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 268 | r = zd_chip_enable_rxtx(chip); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 269 | if (r < 0) |
| 270 | goto disable_radio; |
| 271 | r = zd_chip_enable_hwint(chip); |
| 272 | if (r < 0) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 273 | goto disable_rxtx; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 274 | |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 275 | housekeeping_enable(mac); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 276 | return 0; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 277 | disable_rxtx: |
| 278 | zd_chip_disable_rxtx(chip); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 279 | disable_radio: |
| 280 | zd_chip_switch_radio_off(chip); |
| 281 | disable_int: |
| 282 | zd_chip_disable_int(chip); |
| 283 | out: |
| 284 | return r; |
| 285 | } |
| 286 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 287 | static void zd_op_stop(struct ieee80211_hw *hw) |
| 288 | { |
| 289 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 290 | struct zd_chip *chip = &mac->chip; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 291 | struct sk_buff *skb; |
| 292 | struct sk_buff_head *ack_wait_queue = &mac->ack_wait_queue; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 293 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 294 | /* The order here deliberately is a little different from the open() |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 295 | * method, since we need to make sure there is no opportunity for RX |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 296 | * frames to be processed by mac80211 after we have stopped it. |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 297 | */ |
| 298 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 299 | zd_chip_disable_rxtx(chip); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 300 | housekeeping_disable(mac); |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 301 | flush_workqueue(zd_workqueue); |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 302 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 303 | zd_chip_disable_hwint(chip); |
| 304 | zd_chip_switch_radio_off(chip); |
| 305 | zd_chip_disable_int(chip); |
| 306 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 307 | |
| 308 | while ((skb = skb_dequeue(ack_wait_queue))) |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 309 | dev_kfree_skb_any(skb); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 310 | } |
| 311 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 312 | /** |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 313 | * zd_mac_tx_status - reports tx status of a packet if required |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 314 | * @hw - a &struct ieee80211_hw pointer |
| 315 | * @skb - a sk-buffer |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 316 | * @flags: extra flags to set in the TX status info |
| 317 | * @ackssi: ACK signal strength |
Coly Li | 73ac36e | 2009-01-07 18:09:16 -0800 | [diff] [blame] | 318 | * @success - True for successful transmission of the frame |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 319 | * |
| 320 | * This information calls ieee80211_tx_status_irqsafe() if required by the |
| 321 | * control information. It copies the control information into the status |
| 322 | * information. |
| 323 | * |
| 324 | * If no status information has been requested, the skb is freed. |
| 325 | */ |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 326 | static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 327 | int ackssi, struct tx_status *tx_status) |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 328 | { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 329 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 330 | int i; |
| 331 | int success = 1, retry = 1; |
| 332 | int first_idx; |
| 333 | const struct tx_retry_rate *retries; |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 334 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 335 | ieee80211_tx_info_clear_status(info); |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 336 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 337 | if (tx_status) { |
| 338 | success = !tx_status->failure; |
| 339 | retry = tx_status->retry + success; |
| 340 | } |
| 341 | |
| 342 | if (success) { |
| 343 | /* success */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 344 | info->flags |= IEEE80211_TX_STAT_ACK; |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 345 | } else { |
| 346 | /* failure */ |
| 347 | info->flags &= ~IEEE80211_TX_STAT_ACK; |
| 348 | } |
| 349 | |
| 350 | first_idx = info->status.rates[0].idx; |
| 351 | ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); |
| 352 | retries = &zd_retry_rates[first_idx]; |
| 353 | ZD_ASSERT(0<=retry && retry<=retries->count); |
| 354 | |
| 355 | info->status.rates[0].idx = retries->rate[0]; |
| 356 | info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1); |
| 357 | |
| 358 | for (i=1; i<IEEE80211_TX_MAX_RATES-1 && i<retry; i++) { |
| 359 | info->status.rates[i].idx = retries->rate[i]; |
| 360 | info->status.rates[i].count = 1; // ((i==retry-1) && success ? 1:2); |
| 361 | } |
| 362 | for (; i<IEEE80211_TX_MAX_RATES && i<retry; i++) { |
| 363 | info->status.rates[i].idx = retries->rate[retry-1]; |
| 364 | info->status.rates[i].count = 1; // (success ? 1:2); |
| 365 | } |
| 366 | if (i<IEEE80211_TX_MAX_RATES) |
| 367 | info->status.rates[i].idx = -1; /* terminate */ |
| 368 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 369 | info->status.ack_signal = ackssi; |
| 370 | ieee80211_tx_status_irqsafe(hw, skb); |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 373 | /** |
| 374 | * zd_mac_tx_failed - callback for failed frames |
| 375 | * @dev: the mac80211 wireless device |
| 376 | * |
Adam Buchbinder | 303863f | 2009-12-11 16:35:37 -0500 | [diff] [blame^] | 377 | * This function is called if a frame couldn't be successfully |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 378 | * transferred. The first frame from the tx queue, will be selected and |
| 379 | * reported as error to the upper layers. |
| 380 | */ |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 381 | void zd_mac_tx_failed(struct urb *urb) |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 382 | { |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 383 | struct ieee80211_hw * hw = zd_usb_to_hw(urb->context); |
| 384 | struct zd_mac *mac = zd_hw_mac(hw); |
| 385 | struct sk_buff_head *q = &mac->ack_wait_queue; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 386 | struct sk_buff *skb; |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 387 | struct tx_status *tx_status = (struct tx_status *)urb->transfer_buffer; |
| 388 | unsigned long flags; |
| 389 | int success = !tx_status->failure; |
| 390 | int retry = tx_status->retry + success; |
| 391 | int found = 0; |
| 392 | int i, position = 0; |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 393 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 394 | q = &mac->ack_wait_queue; |
| 395 | spin_lock_irqsave(&q->lock, flags); |
Johannes Berg | 5078ed5 | 2008-02-20 12:09:25 +0100 | [diff] [blame] | 396 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 397 | skb_queue_walk(q, skb) { |
| 398 | struct ieee80211_hdr *tx_hdr; |
| 399 | struct ieee80211_tx_info *info; |
| 400 | int first_idx, final_idx; |
| 401 | const struct tx_retry_rate *retries; |
| 402 | u8 final_rate; |
| 403 | |
| 404 | position ++; |
| 405 | |
| 406 | /* if the hardware reports a failure and we had a 802.11 ACK |
| 407 | * pending, then we skip the first skb when searching for a |
| 408 | * matching frame */ |
| 409 | if (tx_status->failure && mac->ack_pending && |
| 410 | skb_queue_is_first(q, skb)) { |
| 411 | continue; |
| 412 | } |
| 413 | |
| 414 | tx_hdr = (struct ieee80211_hdr *)skb->data; |
| 415 | |
| 416 | /* we skip all frames not matching the reported destination */ |
| 417 | if (unlikely(memcmp(tx_hdr->addr1, tx_status->mac, ETH_ALEN))) { |
| 418 | continue; |
| 419 | } |
| 420 | |
| 421 | /* we skip all frames not matching the reported final rate */ |
| 422 | |
| 423 | info = IEEE80211_SKB_CB(skb); |
| 424 | first_idx = info->status.rates[0].idx; |
| 425 | ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates)); |
| 426 | retries = &zd_retry_rates[first_idx]; |
| 427 | if (retry < 0 || retry > retries->count) { |
| 428 | continue; |
| 429 | } |
| 430 | |
| 431 | ZD_ASSERT(0<=retry && retry<=retries->count); |
| 432 | final_idx = retries->rate[retry-1]; |
| 433 | final_rate = zd_rates[final_idx].hw_value; |
| 434 | |
| 435 | if (final_rate != tx_status->rate) { |
| 436 | continue; |
| 437 | } |
| 438 | |
| 439 | found = 1; |
| 440 | break; |
| 441 | } |
| 442 | |
| 443 | if (found) { |
| 444 | for (i=1; i<=position; i++) { |
| 445 | skb = __skb_dequeue(q); |
| 446 | zd_mac_tx_status(hw, skb, |
| 447 | mac->ack_pending ? mac->ack_signal : 0, |
| 448 | i == position ? tx_status : NULL); |
| 449 | mac->ack_pending = 0; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | spin_unlock_irqrestore(&q->lock, flags); |
Ulrich Kunitz | 9cdac96 | 2006-12-01 00:58:07 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 456 | /** |
| 457 | * zd_mac_tx_to_dev - callback for USB layer |
| 458 | * @skb: a &sk_buff pointer |
| 459 | * @error: error value, 0 if transmission successful |
| 460 | * |
| 461 | * Informs the MAC layer that the frame has successfully transferred to the |
| 462 | * device. If an ACK is required and the transfer to the device has been |
| 463 | * successful, the packets are put on the @ack_wait_queue with |
| 464 | * the control set removed. |
| 465 | */ |
| 466 | void zd_mac_tx_to_dev(struct sk_buff *skb, int error) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 467 | { |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 468 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 469 | struct ieee80211_hw *hw = info->rate_driver_data[0]; |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 470 | struct zd_mac *mac = zd_hw_mac(hw); |
| 471 | |
| 472 | ieee80211_tx_info_clear_status(info); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 473 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 474 | skb_pull(skb, sizeof(struct zd_ctrlset)); |
| 475 | if (unlikely(error || |
| 476 | (info->flags & IEEE80211_TX_CTL_NO_ACK))) { |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 477 | /* |
| 478 | * FIXME : do we need to fill in anything ? |
| 479 | */ |
| 480 | ieee80211_tx_status_irqsafe(hw, skb); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 481 | } else { |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 482 | struct sk_buff_head *q = &mac->ack_wait_queue; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 483 | |
| 484 | skb_queue_tail(q, skb); |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 485 | while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS) { |
| 486 | zd_mac_tx_status(hw, skb_dequeue(q), |
| 487 | mac->ack_pending ? mac->ack_signal : 0, |
| 488 | NULL); |
| 489 | mac->ack_pending = 0; |
| 490 | } |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 491 | } |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 492 | } |
| 493 | |
Daniel Drake | b1cd8416 | 2006-11-22 00:06:38 +0000 | [diff] [blame] | 494 | static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 495 | { |
Ulrich Kunitz | 64f222c | 2007-08-06 01:24:31 +0100 | [diff] [blame] | 496 | /* ZD_PURE_RATE() must be used to remove the modulation type flag of |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 497 | * the zd-rate values. |
| 498 | */ |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 499 | static const u8 rate_divisor[] = { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 500 | [ZD_PURE_RATE(ZD_CCK_RATE_1M)] = 1, |
| 501 | [ZD_PURE_RATE(ZD_CCK_RATE_2M)] = 2, |
| 502 | /* Bits must be doubled. */ |
| 503 | [ZD_PURE_RATE(ZD_CCK_RATE_5_5M)] = 11, |
| 504 | [ZD_PURE_RATE(ZD_CCK_RATE_11M)] = 11, |
| 505 | [ZD_PURE_RATE(ZD_OFDM_RATE_6M)] = 6, |
| 506 | [ZD_PURE_RATE(ZD_OFDM_RATE_9M)] = 9, |
| 507 | [ZD_PURE_RATE(ZD_OFDM_RATE_12M)] = 12, |
| 508 | [ZD_PURE_RATE(ZD_OFDM_RATE_18M)] = 18, |
| 509 | [ZD_PURE_RATE(ZD_OFDM_RATE_24M)] = 24, |
| 510 | [ZD_PURE_RATE(ZD_OFDM_RATE_36M)] = 36, |
| 511 | [ZD_PURE_RATE(ZD_OFDM_RATE_48M)] = 48, |
| 512 | [ZD_PURE_RATE(ZD_OFDM_RATE_54M)] = 54, |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | u32 bits = (u32)tx_length * 8; |
| 516 | u32 divisor; |
| 517 | |
Ulrich Kunitz | 64f222c | 2007-08-06 01:24:31 +0100 | [diff] [blame] | 518 | divisor = rate_divisor[ZD_PURE_RATE(zd_rate)]; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 519 | if (divisor == 0) |
| 520 | return -EINVAL; |
| 521 | |
Daniel Drake | b1cd8416 | 2006-11-22 00:06:38 +0000 | [diff] [blame] | 522 | switch (zd_rate) { |
| 523 | case ZD_CCK_RATE_5_5M: |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 524 | bits = (2*bits) + 10; /* round up to the next integer */ |
| 525 | break; |
Daniel Drake | b1cd8416 | 2006-11-22 00:06:38 +0000 | [diff] [blame] | 526 | case ZD_CCK_RATE_11M: |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 527 | if (service) { |
| 528 | u32 t = bits % 11; |
| 529 | *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION; |
| 530 | if (0 < t && t <= 3) { |
| 531 | *service |= ZD_PLCP_SERVICE_LENGTH_EXTENSION; |
| 532 | } |
| 533 | } |
| 534 | bits += 10; /* round up to the next integer */ |
| 535 | break; |
| 536 | } |
| 537 | |
| 538 | return bits/divisor; |
| 539 | } |
| 540 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 541 | static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 542 | struct ieee80211_hdr *header, |
| 543 | struct ieee80211_tx_info *info) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 544 | { |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 545 | /* |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 546 | * CONTROL TODO: |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 547 | * - if backoff needed, enable bit 0 |
| 548 | * - if burst (backoff not needed) disable bit 0 |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 549 | */ |
| 550 | |
| 551 | cs->control = 0; |
| 552 | |
| 553 | /* First fragment */ |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 554 | if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 555 | cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; |
| 556 | |
Gábor Stefanik | 13bdcd9 | 2009-05-14 17:34:59 +0000 | [diff] [blame] | 557 | /* No ACK expected (multicast, etc.) */ |
| 558 | if (info->flags & IEEE80211_TX_CTL_NO_ACK) |
| 559 | cs->control |= ZD_CS_NO_ACK; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 560 | |
| 561 | /* PS-POLL */ |
Harvey Harrison | 8536582 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 562 | if (ieee80211_is_pspoll(header->frame_control)) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 563 | cs->control |= ZD_CS_PS_POLL_FRAME; |
| 564 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 565 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 566 | cs->control |= ZD_CS_RTS; |
| 567 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 568 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT) |
Daniel Drake | b1382ed | 2006-11-22 00:06:48 +0000 | [diff] [blame] | 569 | cs->control |= ZD_CS_SELF_CTS; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 570 | |
| 571 | /* FIXME: Management frame? */ |
| 572 | } |
| 573 | |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 574 | static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon) |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 575 | { |
| 576 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 577 | int r; |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 578 | u32 tmp, j = 0; |
| 579 | /* 4 more bytes for tail CRC */ |
| 580 | u32 full_len = beacon->len + 4; |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 581 | |
| 582 | r = zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 0); |
| 583 | if (r < 0) |
| 584 | return r; |
| 585 | r = zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); |
| 586 | if (r < 0) |
| 587 | return r; |
| 588 | |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 589 | while (tmp & 0x2) { |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 590 | r = zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); |
| 591 | if (r < 0) |
| 592 | return r; |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 593 | if ((++j % 100) == 0) { |
| 594 | printk(KERN_ERR "CR_BCN_FIFO_SEMAPHORE not ready\n"); |
| 595 | if (j >= 500) { |
| 596 | printk(KERN_ERR "Giving up beacon config.\n"); |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 597 | return -ETIMEDOUT; |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 598 | } |
| 599 | } |
| 600 | msleep(1); |
| 601 | } |
| 602 | |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 603 | r = zd_iowrite32(&mac->chip, CR_BCN_FIFO, full_len - 1); |
| 604 | if (r < 0) |
| 605 | return r; |
| 606 | if (zd_chip_is_zd1211b(&mac->chip)) { |
| 607 | r = zd_iowrite32(&mac->chip, CR_BCN_LENGTH, full_len - 1); |
| 608 | if (r < 0) |
| 609 | return r; |
| 610 | } |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 611 | |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 612 | for (j = 0 ; j < beacon->len; j++) { |
| 613 | r = zd_iowrite32(&mac->chip, CR_BCN_FIFO, |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 614 | *((u8 *)(beacon->data + j))); |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 615 | if (r < 0) |
| 616 | return r; |
| 617 | } |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 618 | |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 619 | for (j = 0; j < 4; j++) { |
| 620 | r = zd_iowrite32(&mac->chip, CR_BCN_FIFO, 0x0); |
| 621 | if (r < 0) |
| 622 | return r; |
| 623 | } |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 624 | |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 625 | r = zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 1); |
| 626 | if (r < 0) |
| 627 | return r; |
| 628 | |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 629 | /* 802.11b/g 2.4G CCK 1Mb |
| 630 | * 802.11a, not yet implemented, uses different values (see GPL vendor |
| 631 | * driver) |
| 632 | */ |
Daniel Drake | f2cae6c | 2008-07-04 04:30:49 +0100 | [diff] [blame] | 633 | return zd_iowrite32(&mac->chip, CR_BCN_PLCP_CFG, 0x00000400 | |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 634 | (full_len << 19)); |
| 635 | } |
| 636 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 637 | static int fill_ctrlset(struct zd_mac *mac, |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 638 | struct sk_buff *skb) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 639 | { |
| 640 | int r; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 641 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; |
| 642 | unsigned int frag_len = skb->len + FCS_LEN; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 643 | unsigned int packet_length; |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 644 | struct ieee80211_rate *txrate; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 645 | struct zd_ctrlset *cs = (struct zd_ctrlset *) |
| 646 | skb_push(skb, sizeof(struct zd_ctrlset)); |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 647 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 648 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 649 | ZD_ASSERT(frag_len <= 0xffff); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 650 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 651 | txrate = ieee80211_get_tx_rate(mac->hw, info); |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 652 | |
| 653 | cs->modulation = txrate->hw_value; |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 654 | if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) |
Johannes Berg | 2e92e6f | 2008-05-15 12:55:27 +0200 | [diff] [blame] | 655 | cs->modulation = txrate->hw_value_short; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 656 | |
| 657 | cs->tx_length = cpu_to_le16(frag_len); |
| 658 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 659 | cs_set_control(mac, cs, hdr, info); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 660 | |
| 661 | packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; |
| 662 | ZD_ASSERT(packet_length <= 0xffff); |
| 663 | /* ZD1211B: Computing the length difference this way, gives us |
| 664 | * flexibility to compute the packet length. |
| 665 | */ |
Daniel Drake | 74553ae | 2007-07-01 18:22:32 +0100 | [diff] [blame] | 666 | cs->packet_length = cpu_to_le16(zd_chip_is_zd1211b(&mac->chip) ? |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 667 | packet_length - frag_len : packet_length); |
| 668 | |
| 669 | /* |
| 670 | * CURRENT LENGTH: |
| 671 | * - transmit frame length in microseconds |
| 672 | * - seems to be derived from frame length |
| 673 | * - see Cal_Us_Service() in zdinlinef.h |
| 674 | * - if macp->bTxBurstEnable is enabled, then multiply by 4 |
| 675 | * - bTxBurstEnable is never set in the vendor driver |
| 676 | * |
| 677 | * SERVICE: |
| 678 | * - "for PLCP configuration" |
| 679 | * - always 0 except in some situations at 802.11b 11M |
| 680 | * - see line 53 of zdinlinef.h |
| 681 | */ |
| 682 | cs->service = 0; |
Ulrich Kunitz | 64f222c | 2007-08-06 01:24:31 +0100 | [diff] [blame] | 683 | r = zd_calc_tx_length_us(&cs->service, ZD_RATE(cs->modulation), |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 684 | le16_to_cpu(cs->tx_length)); |
| 685 | if (r < 0) |
| 686 | return r; |
| 687 | cs->current_length = cpu_to_le16(r); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 688 | cs->next_frame_length = 0; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 689 | |
| 690 | return 0; |
| 691 | } |
| 692 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 693 | /** |
| 694 | * zd_op_tx - transmits a network frame to the device |
Ulrich Kunitz | 741fec5 | 2006-11-22 00:05:53 +0000 | [diff] [blame] | 695 | * |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 696 | * @dev: mac80211 hardware device |
| 697 | * @skb: socket buffer |
| 698 | * @control: the control structure |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 699 | * |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 700 | * This function transmit an IEEE 802.11 network frame to the device. The |
| 701 | * control block of the skbuff will be initialized. If necessary the incoming |
| 702 | * mac80211 queues will be stopped. |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 703 | */ |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 704 | static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 705 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 706 | struct zd_mac *mac = zd_hw_mac(hw); |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 707 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 708 | int r; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 709 | |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 710 | r = fill_ctrlset(mac, skb); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 711 | if (r) |
Jouni Malinen | 640c65e | 2009-03-16 21:47:33 +0200 | [diff] [blame] | 712 | goto fail; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 713 | |
Johannes Berg | e6a9854 | 2008-10-21 12:40:02 +0200 | [diff] [blame] | 714 | info->rate_driver_data[0] = hw; |
Johannes Berg | e039fa4 | 2008-05-15 12:55:29 +0200 | [diff] [blame] | 715 | |
| 716 | r = zd_usb_tx(&mac->chip.usb, skb); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 717 | if (r) |
Jouni Malinen | 640c65e | 2009-03-16 21:47:33 +0200 | [diff] [blame] | 718 | goto fail; |
| 719 | return 0; |
| 720 | |
| 721 | fail: |
| 722 | dev_kfree_skb(skb); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 723 | return 0; |
| 724 | } |
| 725 | |
| 726 | /** |
| 727 | * filter_ack - filters incoming packets for acknowledgements |
| 728 | * @dev: the mac80211 device |
| 729 | * @rx_hdr: received header |
| 730 | * @stats: the status for the received packet |
| 731 | * |
| 732 | * This functions looks for ACK packets and tries to match them with the |
| 733 | * frames in the tx queue. If a match is found the frame will be dequeued and |
| 734 | * the upper layers is informed about the successful transmission. If |
| 735 | * mac80211 queues have been stopped and the number of frames still to be |
| 736 | * transmitted is low the queues will be opened again. |
| 737 | * |
| 738 | * Returns 1 if the frame was an ACK, 0 if it was ignored. |
| 739 | */ |
| 740 | static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr, |
| 741 | struct ieee80211_rx_status *stats) |
| 742 | { |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 743 | struct zd_mac *mac = zd_hw_mac(hw); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 744 | struct sk_buff *skb; |
| 745 | struct sk_buff_head *q; |
| 746 | unsigned long flags; |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 747 | int found = 0; |
| 748 | int i, position = 0; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 749 | |
Harvey Harrison | 8536582 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 750 | if (!ieee80211_is_ack(rx_hdr->frame_control)) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 751 | return 0; |
| 752 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 753 | q = &mac->ack_wait_queue; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 754 | spin_lock_irqsave(&q->lock, flags); |
David S. Miller | 47a227d | 2008-09-23 00:23:30 -0700 | [diff] [blame] | 755 | skb_queue_walk(q, skb) { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 756 | struct ieee80211_hdr *tx_hdr; |
| 757 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 758 | position ++; |
| 759 | |
| 760 | if (mac->ack_pending && skb_queue_is_first(q, skb)) |
| 761 | continue; |
| 762 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 763 | tx_hdr = (struct ieee80211_hdr *)skb->data; |
Shaddy Baddah | cde6901 | 2008-11-28 17:10:45 +1100 | [diff] [blame] | 764 | if (likely(!memcmp(tx_hdr->addr2, rx_hdr->addr1, ETH_ALEN))) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 765 | { |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 766 | found = 1; |
| 767 | break; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 768 | } |
| 769 | } |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 770 | |
| 771 | if (found) { |
| 772 | for (i=1; i<position; i++) { |
| 773 | skb = __skb_dequeue(q); |
| 774 | zd_mac_tx_status(hw, skb, |
| 775 | mac->ack_pending ? mac->ack_signal : 0, |
| 776 | NULL); |
| 777 | mac->ack_pending = 0; |
| 778 | } |
| 779 | |
| 780 | mac->ack_pending = 1; |
| 781 | mac->ack_signal = stats->signal; |
| 782 | } |
| 783 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 784 | spin_unlock_irqrestore(&q->lock, flags); |
| 785 | return 1; |
| 786 | } |
| 787 | |
| 788 | int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) |
| 789 | { |
| 790 | struct zd_mac *mac = zd_hw_mac(hw); |
| 791 | struct ieee80211_rx_status stats; |
| 792 | const struct rx_status *status; |
| 793 | struct sk_buff *skb; |
| 794 | int bad_frame = 0; |
Harvey Harrison | 8536582 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 795 | __le16 fc; |
| 796 | int need_padding; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 797 | int i; |
| 798 | u8 rate; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 799 | |
| 800 | if (length < ZD_PLCP_HEADER_SIZE + 10 /* IEEE80211_1ADDR_LEN */ + |
| 801 | FCS_LEN + sizeof(struct rx_status)) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 802 | return -EINVAL; |
| 803 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 804 | memset(&stats, 0, sizeof(stats)); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 805 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 806 | /* Note about pass_failed_fcs and pass_ctrl access below: |
| 807 | * mac locking intentionally omitted here, as this is the only unlocked |
| 808 | * reader and the only writer is configure_filter. Plus, if there were |
| 809 | * any races accessing these variables, it wouldn't really matter. |
| 810 | * If mac80211 ever provides a way for us to access filter flags |
| 811 | * from outside configure_filter, we could improve on this. Also, this |
| 812 | * situation may change once we implement some kind of DMA-into-skb |
| 813 | * RX path. */ |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 814 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 815 | /* Caller has to ensure that length >= sizeof(struct rx_status). */ |
| 816 | status = (struct rx_status *) |
Ulrich Kunitz | 937a049 | 2007-10-02 18:36:53 +0100 | [diff] [blame] | 817 | (buffer + (length - sizeof(struct rx_status))); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 818 | if (status->frame_status & ZD_RX_ERROR) { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 819 | if (mac->pass_failed_fcs && |
| 820 | (status->frame_status & ZD_RX_CRC32_ERROR)) { |
| 821 | stats.flag |= RX_FLAG_FAILED_FCS_CRC; |
| 822 | bad_frame = 1; |
| 823 | } else { |
| 824 | return -EINVAL; |
Ulrich Kunitz | 22d3405 | 2007-01-29 01:00:03 +0000 | [diff] [blame] | 825 | } |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 826 | } |
Ulrich Kunitz | 22d3405 | 2007-01-29 01:00:03 +0000 | [diff] [blame] | 827 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 828 | stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; |
| 829 | stats.band = IEEE80211_BAND_2GHZ; |
Bruno Randolf | 566bfe5 | 2008-05-08 19:15:40 +0200 | [diff] [blame] | 830 | stats.signal = status->signal_strength; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 831 | |
| 832 | rate = zd_rx_rate(buffer, status); |
| 833 | |
| 834 | /* todo: return index in the big switches in zd_rx_rate instead */ |
| 835 | for (i = 0; i < mac->band.n_bitrates; i++) |
| 836 | if (rate == mac->band.bitrates[i].hw_value) |
| 837 | stats.rate_idx = i; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 838 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 839 | length -= ZD_PLCP_HEADER_SIZE + sizeof(struct rx_status); |
| 840 | buffer += ZD_PLCP_HEADER_SIZE; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 841 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 842 | /* Except for bad frames, filter each frame to see if it is an ACK, in |
| 843 | * which case our internal TX tracking is updated. Normally we then |
| 844 | * bail here as there's no need to pass ACKs on up to the stack, but |
| 845 | * there is also the case where the stack has requested us to pass |
| 846 | * control frames on up (pass_ctrl) which we must consider. */ |
| 847 | if (!bad_frame && |
| 848 | filter_ack(hw, (struct ieee80211_hdr *)buffer, &stats) |
| 849 | && !mac->pass_ctrl) |
| 850 | return 0; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 851 | |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 852 | fc = get_unaligned((__le16*)buffer); |
Harvey Harrison | 8536582 | 2008-06-14 23:33:39 -0700 | [diff] [blame] | 853 | need_padding = ieee80211_is_data_qos(fc) ^ ieee80211_has_a4(fc); |
Michael Buesch | 9081728 | 2007-12-29 17:24:23 +0100 | [diff] [blame] | 854 | |
| 855 | skb = dev_alloc_skb(length + (need_padding ? 2 : 0)); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 856 | if (skb == NULL) |
Ulrich Kunitz | 4d1feab | 2006-12-10 11:13:12 -0800 | [diff] [blame] | 857 | return -ENOMEM; |
Michael Buesch | 9081728 | 2007-12-29 17:24:23 +0100 | [diff] [blame] | 858 | if (need_padding) { |
| 859 | /* Make sure the the payload data is 4 byte aligned. */ |
| 860 | skb_reserve(skb, 2); |
| 861 | } |
| 862 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 863 | /* FIXME : could we avoid this big memcpy ? */ |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 864 | memcpy(skb_put(skb, length), buffer, length); |
| 865 | |
Johannes Berg | f1d58c2 | 2009-06-17 13:13:00 +0200 | [diff] [blame] | 866 | memcpy(IEEE80211_SKB_RXCB(skb), &stats, sizeof(stats)); |
| 867 | ieee80211_rx_irqsafe(hw, skb); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 868 | return 0; |
| 869 | } |
| 870 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 871 | static int zd_op_add_interface(struct ieee80211_hw *hw, |
| 872 | struct ieee80211_if_init_conf *conf) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 873 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 874 | struct zd_mac *mac = zd_hw_mac(hw); |
| 875 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 876 | /* using NL80211_IFTYPE_UNSPECIFIED to indicate no mode selected */ |
| 877 | if (mac->type != NL80211_IFTYPE_UNSPECIFIED) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 878 | return -EOPNOTSUPP; |
| 879 | |
| 880 | switch (conf->type) { |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 881 | case NL80211_IFTYPE_MONITOR: |
| 882 | case NL80211_IFTYPE_MESH_POINT: |
| 883 | case NL80211_IFTYPE_STATION: |
| 884 | case NL80211_IFTYPE_ADHOC: |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 885 | mac->type = conf->type; |
| 886 | break; |
| 887 | default: |
| 888 | return -EOPNOTSUPP; |
| 889 | } |
| 890 | |
| 891 | return zd_write_mac_addr(&mac->chip, conf->mac_addr); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 892 | } |
| 893 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 894 | static void zd_op_remove_interface(struct ieee80211_hw *hw, |
| 895 | struct ieee80211_if_init_conf *conf) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 896 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 897 | struct zd_mac *mac = zd_hw_mac(hw); |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 898 | mac->type = NL80211_IFTYPE_UNSPECIFIED; |
Luis Carlos Cobo | 86229f0 | 2008-07-08 16:19:21 +0200 | [diff] [blame] | 899 | zd_set_beacon_interval(&mac->chip, 0); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 900 | zd_write_mac_addr(&mac->chip, NULL); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 901 | } |
| 902 | |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 903 | static int zd_op_config(struct ieee80211_hw *hw, u32 changed) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 904 | { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 905 | struct zd_mac *mac = zd_hw_mac(hw); |
Johannes Berg | e897558 | 2008-10-09 12:18:51 +0200 | [diff] [blame] | 906 | struct ieee80211_conf *conf = &hw->conf; |
| 907 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 908 | return zd_chip_set_channel(&mac->chip, conf->channel->hw_value); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 909 | } |
| 910 | |
Luis R. Rodriguez | e83a107 | 2008-09-09 23:19:49 -0700 | [diff] [blame] | 911 | static void zd_process_intr(struct work_struct *work) |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 912 | { |
| 913 | u16 int_status; |
| 914 | struct zd_mac *mac = container_of(work, struct zd_mac, process_intr); |
| 915 | |
Al Viro | d63ddce | 2008-05-21 01:34:30 +0100 | [diff] [blame] | 916 | int_status = le16_to_cpu(*(__le16 *)(mac->intr_buffer+4)); |
Johannes Berg | 570a0a7 | 2009-02-10 21:25:37 +0100 | [diff] [blame] | 917 | if (int_status & INT_CFG_NEXT_BCN) |
| 918 | dev_dbg_f_limit(zd_mac_dev(mac), "INT_CFG_NEXT_BCN\n"); |
| 919 | else |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 920 | dev_dbg_f(zd_mac_dev(mac), "Unsupported interrupt\n"); |
| 921 | |
| 922 | zd_chip_enable_hwint(&mac->chip); |
| 923 | } |
| 924 | |
| 925 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 926 | static void set_multicast_hash_handler(struct work_struct *work) |
| 927 | { |
| 928 | struct zd_mac *mac = |
| 929 | container_of(work, struct zd_mac, set_multicast_hash_work); |
| 930 | struct zd_mc_hash hash; |
| 931 | |
| 932 | spin_lock_irq(&mac->lock); |
| 933 | hash = mac->multicast_hash; |
| 934 | spin_unlock_irq(&mac->lock); |
| 935 | |
| 936 | zd_chip_set_multicast_hash(&mac->chip, &hash); |
| 937 | } |
| 938 | |
| 939 | static void set_rx_filter_handler(struct work_struct *work) |
| 940 | { |
| 941 | struct zd_mac *mac = |
| 942 | container_of(work, struct zd_mac, set_rx_filter_work); |
| 943 | int r; |
| 944 | |
| 945 | dev_dbg_f(zd_mac_dev(mac), "\n"); |
| 946 | r = set_rx_filter(mac); |
| 947 | if (r) |
| 948 | dev_err(zd_mac_dev(mac), "set_rx_filter_handler error %d\n", r); |
| 949 | } |
| 950 | |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 951 | static u64 zd_op_prepare_multicast(struct ieee80211_hw *hw, |
| 952 | int mc_count, struct dev_addr_list *mclist) |
| 953 | { |
| 954 | struct zd_mac *mac = zd_hw_mac(hw); |
| 955 | struct zd_mc_hash hash; |
| 956 | int i; |
| 957 | |
| 958 | zd_mc_clear(&hash); |
| 959 | |
| 960 | for (i = 0; i < mc_count; i++) { |
| 961 | if (!mclist) |
| 962 | break; |
| 963 | dev_dbg_f(zd_mac_dev(mac), "mc addr %pM\n", mclist->dmi_addr); |
| 964 | zd_mc_add_addr(&hash, mclist->dmi_addr); |
| 965 | mclist = mclist->next; |
| 966 | } |
| 967 | |
| 968 | return hash.low | ((u64)hash.high << 32); |
| 969 | } |
| 970 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 971 | #define SUPPORTED_FIF_FLAGS \ |
| 972 | (FIF_PROMISC_IN_BSS | FIF_ALLMULTI | FIF_FCSFAIL | FIF_CONTROL | \ |
Michael Buesch | 2c1a1b1 | 2008-02-10 16:03:55 +0100 | [diff] [blame] | 973 | FIF_OTHER_BSS | FIF_BCN_PRBRESP_PROMISC) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 974 | static void zd_op_configure_filter(struct ieee80211_hw *hw, |
| 975 | unsigned int changed_flags, |
| 976 | unsigned int *new_flags, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 977 | u64 multicast) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 978 | { |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 979 | struct zd_mc_hash hash = { |
| 980 | .low = multicast, |
| 981 | .high = multicast >> 32, |
| 982 | }; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 983 | struct zd_mac *mac = zd_hw_mac(hw); |
| 984 | unsigned long flags; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 985 | |
| 986 | /* Only deal with supported flags */ |
| 987 | changed_flags &= SUPPORTED_FIF_FLAGS; |
| 988 | *new_flags &= SUPPORTED_FIF_FLAGS; |
| 989 | |
Benoit Papillault | 7de3c5d | 2010-01-03 10:20:01 +0100 | [diff] [blame] | 990 | /* |
| 991 | * If multicast parameter (as returned by zd_op_prepare_multicast) |
| 992 | * has changed, no bit in changed_flags is set. To handle this |
| 993 | * situation, we do not return if changed_flags is 0. If we do so, |
| 994 | * we will have some issue with IPv6 which uses multicast for link |
| 995 | * layer address resolution. |
| 996 | */ |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 997 | if (*new_flags & (FIF_PROMISC_IN_BSS | FIF_ALLMULTI)) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 998 | zd_mc_add_all(&hash); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 999 | |
| 1000 | spin_lock_irqsave(&mac->lock, flags); |
| 1001 | mac->pass_failed_fcs = !!(*new_flags & FIF_FCSFAIL); |
| 1002 | mac->pass_ctrl = !!(*new_flags & FIF_CONTROL); |
| 1003 | mac->multicast_hash = hash; |
| 1004 | spin_unlock_irqrestore(&mac->lock, flags); |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 1005 | |
| 1006 | /* XXX: these can be called here now, can sleep now! */ |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1007 | queue_work(zd_workqueue, &mac->set_multicast_hash_work); |
| 1008 | |
| 1009 | if (changed_flags & FIF_CONTROL) |
| 1010 | queue_work(zd_workqueue, &mac->set_rx_filter_work); |
| 1011 | |
| 1012 | /* no handling required for FIF_OTHER_BSS as we don't currently |
| 1013 | * do BSSID filtering */ |
| 1014 | /* FIXME: in future it would be nice to enable the probe response |
| 1015 | * filter (so that the driver doesn't see them) until |
| 1016 | * FIF_BCN_PRBRESP_PROMISC is set. however due to atomicity here, we'd |
| 1017 | * have to schedule work to enable prbresp reception, which might |
| 1018 | * happen too late. For now we'll just listen and forward them all the |
| 1019 | * time. */ |
| 1020 | } |
| 1021 | |
| 1022 | static void set_rts_cts_work(struct work_struct *work) |
| 1023 | { |
| 1024 | struct zd_mac *mac = |
| 1025 | container_of(work, struct zd_mac, set_rts_cts_work); |
| 1026 | unsigned long flags; |
| 1027 | unsigned int short_preamble; |
| 1028 | |
| 1029 | mutex_lock(&mac->chip.mutex); |
| 1030 | |
| 1031 | spin_lock_irqsave(&mac->lock, flags); |
| 1032 | mac->updating_rts_rate = 0; |
| 1033 | short_preamble = mac->short_preamble; |
| 1034 | spin_unlock_irqrestore(&mac->lock, flags); |
| 1035 | |
| 1036 | zd_chip_set_rts_cts_rate_locked(&mac->chip, short_preamble); |
| 1037 | mutex_unlock(&mac->chip.mutex); |
| 1038 | } |
| 1039 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1040 | static void zd_op_bss_info_changed(struct ieee80211_hw *hw, |
| 1041 | struct ieee80211_vif *vif, |
| 1042 | struct ieee80211_bss_conf *bss_conf, |
| 1043 | u32 changes) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1044 | { |
| 1045 | struct zd_mac *mac = zd_hw_mac(hw); |
| 1046 | unsigned long flags; |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1047 | int associated; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1048 | |
| 1049 | dev_dbg_f(zd_mac_dev(mac), "changes: %x\n", changes); |
| 1050 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 1051 | if (mac->type == NL80211_IFTYPE_MESH_POINT || |
| 1052 | mac->type == NL80211_IFTYPE_ADHOC) { |
| 1053 | associated = true; |
| 1054 | if (changes & BSS_CHANGED_BEACON) { |
| 1055 | struct sk_buff *beacon = ieee80211_beacon_get(hw, vif); |
| 1056 | |
| 1057 | if (beacon) { |
| 1058 | zd_mac_config_beacon(hw, beacon); |
| 1059 | kfree_skb(beacon); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | if (changes & BSS_CHANGED_BEACON_ENABLED) { |
| 1064 | u32 interval; |
| 1065 | |
| 1066 | if (bss_conf->enable_beacon) |
| 1067 | interval = BCN_MODE_IBSS | |
| 1068 | bss_conf->beacon_int; |
| 1069 | else |
| 1070 | interval = 0; |
| 1071 | |
| 1072 | zd_set_beacon_interval(&mac->chip, interval); |
| 1073 | } |
| 1074 | } else |
| 1075 | associated = is_valid_ether_addr(bss_conf->bssid); |
| 1076 | |
| 1077 | spin_lock_irq(&mac->lock); |
| 1078 | mac->associated = associated; |
| 1079 | spin_unlock_irq(&mac->lock); |
| 1080 | |
| 1081 | /* TODO: do hardware bssid filtering */ |
| 1082 | |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1083 | if (changes & BSS_CHANGED_ERP_PREAMBLE) { |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1084 | spin_lock_irqsave(&mac->lock, flags); |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1085 | mac->short_preamble = bss_conf->use_short_preamble; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1086 | if (!mac->updating_rts_rate) { |
| 1087 | mac->updating_rts_rate = 1; |
| 1088 | /* FIXME: should disable TX here, until work has |
| 1089 | * completed and RTS_CTS reg is updated */ |
| 1090 | queue_work(zd_workqueue, &mac->set_rts_cts_work); |
| 1091 | } |
| 1092 | spin_unlock_irqrestore(&mac->lock, flags); |
| 1093 | } |
| 1094 | } |
| 1095 | |
Alina Friedrichsen | 5fe7319 | 2009-02-25 00:49:18 +0100 | [diff] [blame] | 1096 | static u64 zd_op_get_tsf(struct ieee80211_hw *hw) |
| 1097 | { |
| 1098 | struct zd_mac *mac = zd_hw_mac(hw); |
| 1099 | return zd_chip_get_tsf(&mac->chip); |
| 1100 | } |
| 1101 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1102 | static const struct ieee80211_ops zd_ops = { |
| 1103 | .tx = zd_op_tx, |
| 1104 | .start = zd_op_start, |
| 1105 | .stop = zd_op_stop, |
| 1106 | .add_interface = zd_op_add_interface, |
| 1107 | .remove_interface = zd_op_remove_interface, |
| 1108 | .config = zd_op_config, |
Johannes Berg | 3ac64be | 2009-08-17 16:16:53 +0200 | [diff] [blame] | 1109 | .prepare_multicast = zd_op_prepare_multicast, |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1110 | .configure_filter = zd_op_configure_filter, |
Johannes Berg | 471b3ef | 2007-12-28 14:32:58 +0100 | [diff] [blame] | 1111 | .bss_info_changed = zd_op_bss_info_changed, |
Alina Friedrichsen | 5fe7319 | 2009-02-25 00:49:18 +0100 | [diff] [blame] | 1112 | .get_tsf = zd_op_get_tsf, |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1113 | }; |
| 1114 | |
| 1115 | struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) |
| 1116 | { |
| 1117 | struct zd_mac *mac; |
| 1118 | struct ieee80211_hw *hw; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1119 | |
| 1120 | hw = ieee80211_alloc_hw(sizeof(struct zd_mac), &zd_ops); |
| 1121 | if (!hw) { |
| 1122 | dev_dbg_f(&intf->dev, "out of memory\n"); |
| 1123 | return NULL; |
| 1124 | } |
| 1125 | |
| 1126 | mac = zd_hw_mac(hw); |
| 1127 | |
| 1128 | memset(mac, 0, sizeof(*mac)); |
| 1129 | spin_lock_init(&mac->lock); |
| 1130 | mac->hw = hw; |
| 1131 | |
Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 1132 | mac->type = NL80211_IFTYPE_UNSPECIFIED; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1133 | |
| 1134 | memcpy(mac->channels, zd_channels, sizeof(zd_channels)); |
| 1135 | memcpy(mac->rates, zd_rates, sizeof(zd_rates)); |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 1136 | mac->band.n_bitrates = ARRAY_SIZE(zd_rates); |
| 1137 | mac->band.bitrates = mac->rates; |
| 1138 | mac->band.n_channels = ARRAY_SIZE(zd_channels); |
| 1139 | mac->band.channels = mac->channels; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1140 | |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 1141 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; |
| 1142 | |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 1143 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | |
Johannes Berg | 7fee537 | 2009-01-30 11:13:06 +0100 | [diff] [blame] | 1144 | IEEE80211_HW_SIGNAL_UNSPEC; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1145 | |
Luis R. Rodriguez | f59ac04 | 2008-08-29 16:26:43 -0700 | [diff] [blame] | 1146 | hw->wiphy->interface_modes = |
| 1147 | BIT(NL80211_IFTYPE_MESH_POINT) | |
| 1148 | BIT(NL80211_IFTYPE_STATION) | |
| 1149 | BIT(NL80211_IFTYPE_ADHOC); |
| 1150 | |
Bruno Randolf | 566bfe5 | 2008-05-08 19:15:40 +0200 | [diff] [blame] | 1151 | hw->max_signal = 100; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1152 | hw->queues = 1; |
| 1153 | hw->extra_tx_headroom = sizeof(struct zd_ctrlset); |
| 1154 | |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 1155 | /* |
| 1156 | * Tell mac80211 that we support multi rate retries |
| 1157 | */ |
| 1158 | hw->max_rates = IEEE80211_TX_MAX_RATES; |
| 1159 | hw->max_rate_tries = 18; /* 9 rates * 2 retries/rate */ |
| 1160 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1161 | skb_queue_head_init(&mac->ack_wait_queue); |
Benoit PAPILLAULT | 7f4013f | 2009-10-22 12:04:52 +0200 | [diff] [blame] | 1162 | mac->ack_pending = 0; |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1163 | |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1164 | zd_chip_init(&mac->chip, hw, intf); |
| 1165 | housekeeping_init(mac); |
| 1166 | INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); |
| 1167 | INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work); |
| 1168 | INIT_WORK(&mac->set_rx_filter_work, set_rx_filter_handler); |
Luis Carlos Cobo | 72e77a8 | 2008-03-03 12:32:15 -0800 | [diff] [blame] | 1169 | INIT_WORK(&mac->process_intr, zd_process_intr); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1170 | |
| 1171 | SET_IEEE80211_DEV(hw, &intf->dev); |
| 1172 | return hw; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 1173 | } |
| 1174 | |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1175 | #define LINK_LED_WORK_DELAY HZ |
| 1176 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 1177 | static void link_led_handler(struct work_struct *work) |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1178 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 1179 | struct zd_mac *mac = |
| 1180 | container_of(work, struct zd_mac, housekeeping.link_led_work.work); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1181 | struct zd_chip *chip = &mac->chip; |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1182 | int is_associated; |
| 1183 | int r; |
| 1184 | |
| 1185 | spin_lock_irq(&mac->lock); |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1186 | is_associated = mac->associated; |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1187 | spin_unlock_irq(&mac->lock); |
| 1188 | |
| 1189 | r = zd_chip_control_leds(chip, |
Luis R. Rodriguez | 14b46c8 | 2009-08-04 14:04:17 -0700 | [diff] [blame] | 1190 | is_associated ? ZD_LED_ASSOCIATED : ZD_LED_SCANNING); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1191 | if (r) |
Daniel Drake | 459c51a | 2007-11-19 15:00:29 +0000 | [diff] [blame] | 1192 | dev_dbg_f(zd_mac_dev(mac), "zd_chip_control_leds error %d\n", r); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1193 | |
| 1194 | queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work, |
| 1195 | LINK_LED_WORK_DELAY); |
| 1196 | } |
| 1197 | |
| 1198 | static void housekeeping_init(struct zd_mac *mac) |
| 1199 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 1200 | INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | static void housekeeping_enable(struct zd_mac *mac) |
| 1204 | { |
| 1205 | dev_dbg_f(zd_mac_dev(mac), "\n"); |
| 1206 | queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work, |
| 1207 | 0); |
| 1208 | } |
| 1209 | |
| 1210 | static void housekeeping_disable(struct zd_mac *mac) |
| 1211 | { |
| 1212 | dev_dbg_f(zd_mac_dev(mac), "\n"); |
| 1213 | cancel_rearming_delayed_workqueue(zd_workqueue, |
| 1214 | &mac->housekeeping.link_led_work); |
Luis R. Rodriguez | 14b46c8 | 2009-08-04 14:04:17 -0700 | [diff] [blame] | 1215 | zd_chip_control_leds(&mac->chip, ZD_LED_OFF); |
Ulrich Kunitz | 583afd1 | 2006-09-13 02:42:38 +0100 | [diff] [blame] | 1216 | } |