| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* | 
| Gertjan van Wingerde | 9c9a0d1 | 2009-11-08 16:39:55 +0100 | [diff] [blame] | 2 | Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 3 | <http://rt2x00.serialmonkey.com> | 
|  | 4 |  | 
|  | 5 | This program is free software; you can redistribute it and/or modify | 
|  | 6 | it under the terms of the GNU General Public License as published by | 
|  | 7 | the Free Software Foundation; either version 2 of the License, or | 
|  | 8 | (at your option) any later version. | 
|  | 9 |  | 
|  | 10 | This program is distributed in the hope that it will be useful, | 
|  | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
|  | 13 | GNU General Public License for more details. | 
|  | 14 |  | 
|  | 15 | You should have received a copy of the GNU General Public License | 
|  | 16 | along with this program; if not, write to the | 
|  | 17 | Free Software Foundation, Inc., | 
|  | 18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 
|  | 19 | */ | 
|  | 20 |  | 
|  | 21 | /* | 
|  | 22 | Module: rt2x00lib | 
|  | 23 | Abstract: rt2x00 generic configuration routines. | 
|  | 24 | */ | 
|  | 25 |  | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 26 | #include <linux/kernel.h> | 
|  | 27 | #include <linux/module.h> | 
|  | 28 |  | 
|  | 29 | #include "rt2x00.h" | 
|  | 30 | #include "rt2x00lib.h" | 
|  | 31 |  | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 32 | void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, | 
|  | 33 | struct rt2x00_intf *intf, | 
| Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 34 | enum nl80211_iftype type, | 
| Johannes Berg | 5f936f1 | 2009-01-21 12:47:05 +0100 | [diff] [blame] | 35 | const u8 *mac, const u8 *bssid) | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 36 | { | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 37 | struct rt2x00intf_conf conf; | 
|  | 38 | unsigned int flags = 0; | 
| Ivo van Doorn | 4abee4b | 2007-10-06 14:11:46 +0200 | [diff] [blame] | 39 |  | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 40 | conf.type = type; | 
| Ivo van Doorn | feb2469 | 2007-10-06 14:14:29 +0200 | [diff] [blame] | 41 |  | 
|  | 42 | switch (type) { | 
| Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 43 | case NL80211_IFTYPE_ADHOC: | 
| Helmut Schaa | ab8966d | 2010-07-11 12:30:13 +0200 | [diff] [blame] | 44 | conf.sync = TSF_SYNC_ADHOC; | 
|  | 45 | break; | 
| Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 46 | case NL80211_IFTYPE_AP: | 
| Andrey Yurovsky | a07dbea | 2008-12-20 10:55:34 +0100 | [diff] [blame] | 47 | case NL80211_IFTYPE_MESH_POINT: | 
| Ivo van Doorn | ce292a6 | 2008-12-20 10:57:02 +0100 | [diff] [blame] | 48 | case NL80211_IFTYPE_WDS: | 
| Helmut Schaa | ab8966d | 2010-07-11 12:30:13 +0200 | [diff] [blame] | 49 | conf.sync = TSF_SYNC_AP_NONE; | 
| Ivo van Doorn | feb2469 | 2007-10-06 14:14:29 +0200 | [diff] [blame] | 50 | break; | 
| Johannes Berg | 05c914f | 2008-09-11 00:01:58 +0200 | [diff] [blame] | 51 | case NL80211_IFTYPE_STATION: | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 52 | conf.sync = TSF_SYNC_INFRA; | 
| Ivo van Doorn | feb2469 | 2007-10-06 14:14:29 +0200 | [diff] [blame] | 53 | break; | 
|  | 54 | default: | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 55 | conf.sync = TSF_SYNC_NONE; | 
| Ivo van Doorn | feb2469 | 2007-10-06 14:14:29 +0200 | [diff] [blame] | 56 | break; | 
|  | 57 | } | 
|  | 58 |  | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 59 | /* | 
|  | 60 | * Note that when NULL is passed as address we will send | 
|  | 61 | * 00:00:00:00:00 to the device to clear the address. | 
|  | 62 | * This will prevent the device being confused when it wants | 
| Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 63 | * to ACK frames or considers itself associated. | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 64 | */ | 
| Gertjan van Wingerde | 736e3ac | 2010-12-27 15:05:55 +0100 | [diff] [blame] | 65 | memset(conf.mac, 0, sizeof(conf.mac)); | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 66 | if (mac) | 
| Gertjan van Wingerde | 736e3ac | 2010-12-27 15:05:55 +0100 | [diff] [blame] | 67 | memcpy(conf.mac, mac, ETH_ALEN); | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 68 |  | 
| Gertjan van Wingerde | 736e3ac | 2010-12-27 15:05:55 +0100 | [diff] [blame] | 69 | memset(conf.bssid, 0, sizeof(conf.bssid)); | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 70 | if (bssid) | 
| Gertjan van Wingerde | 736e3ac | 2010-12-27 15:05:55 +0100 | [diff] [blame] | 71 | memcpy(conf.bssid, bssid, ETH_ALEN); | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 72 |  | 
|  | 73 | flags |= CONFIG_UPDATE_TYPE; | 
|  | 74 | if (mac || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count)) | 
|  | 75 | flags |= CONFIG_UPDATE_MAC; | 
|  | 76 | if (bssid || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count)) | 
|  | 77 | flags |= CONFIG_UPDATE_BSSID; | 
|  | 78 |  | 
|  | 79 | rt2x00dev->ops->lib->config_intf(rt2x00dev, intf, &conf, flags); | 
|  | 80 | } | 
|  | 81 |  | 
| Ivo van Doorn | 7281037 | 2008-03-09 22:46:18 +0100 | [diff] [blame] | 82 | void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev, | 
|  | 83 | struct rt2x00_intf *intf, | 
| Helmut Schaa | 0204464 | 2010-09-08 20:56:32 +0200 | [diff] [blame] | 84 | struct ieee80211_bss_conf *bss_conf, | 
|  | 85 | u32 changed) | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 86 | { | 
| Ivo van Doorn | 7281037 | 2008-03-09 22:46:18 +0100 | [diff] [blame] | 87 | struct rt2x00lib_erp erp; | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 88 |  | 
| Ivo van Doorn | 7281037 | 2008-03-09 22:46:18 +0100 | [diff] [blame] | 89 | memset(&erp, 0, sizeof(erp)); | 
|  | 90 |  | 
|  | 91 | erp.short_preamble = bss_conf->use_short_preamble; | 
| Ivo van Doorn | e360c4c | 2008-07-09 15:12:06 +0200 | [diff] [blame] | 92 | erp.cts_protection = bss_conf->use_cts_prot; | 
|  | 93 |  | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 94 | erp.slot_time = bss_conf->use_short_slot ? SHORT_SLOT_TIME : SLOT_TIME; | 
|  | 95 | erp.sifs = SIFS; | 
|  | 96 | erp.pifs = bss_conf->use_short_slot ? SHORT_PIFS : PIFS; | 
|  | 97 | erp.difs = bss_conf->use_short_slot ? SHORT_DIFS : DIFS; | 
|  | 98 | erp.eifs = bss_conf->use_short_slot ? SHORT_EIFS : EIFS; | 
| Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 99 |  | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 100 | erp.basic_rates = bss_conf->basic_rates; | 
| Ivo van Doorn | 8a566af | 2009-05-21 19:16:46 +0200 | [diff] [blame] | 101 | erp.beacon_int = bss_conf->beacon_int; | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 102 |  | 
| Ivo van Doorn | 1c0bcf8 | 2011-04-30 17:18:18 +0200 | [diff] [blame] | 103 | /* Update the AID, this is needed for dynamic PS support */ | 
|  | 104 | rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0; | 
|  | 105 | rt2x00dev->last_beacon = bss_conf->timestamp; | 
|  | 106 |  | 
| Ivo van Doorn | 6b347bf | 2009-05-23 21:09:28 +0200 | [diff] [blame] | 107 | /* Update global beacon interval time, this is needed for PS support */ | 
|  | 108 | rt2x00dev->beacon_int = bss_conf->beacon_int; | 
|  | 109 |  | 
| Helmut Schaa | 87c1915 | 2010-10-02 11:28:34 +0200 | [diff] [blame] | 110 | if (changed & BSS_CHANGED_HT) | 
|  | 111 | erp.ht_opmode = bss_conf->ht_operation_mode; | 
|  | 112 |  | 
| Helmut Schaa | 0204464 | 2010-09-08 20:56:32 +0200 | [diff] [blame] | 113 | rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp, changed); | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 114 | } | 
|  | 115 |  | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 116 | void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 117 | struct antenna_setup config) | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 118 | { | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 119 | struct link_ant *ant = &rt2x00dev->link.ant; | 
| Ivo van Doorn | 0b927a0 | 2008-12-02 18:20:22 +0100 | [diff] [blame] | 120 | struct antenna_setup *def = &rt2x00dev->default_ant; | 
|  | 121 | struct antenna_setup *active = &rt2x00dev->link.ant.active; | 
|  | 122 |  | 
| Ivo van Doorn | 6d64360 | 2008-11-02 00:38:10 +0100 | [diff] [blame] | 123 | /* | 
| Ivo van Doorn | 0ed7b3c | 2011-04-18 15:35:12 +0200 | [diff] [blame] | 124 | * When the caller tries to send the SW diversity, | 
|  | 125 | * we must update the ANTENNA_RX_DIVERSITY flag to | 
|  | 126 | * enable the antenna diversity in the link tuner. | 
|  | 127 | * | 
|  | 128 | * Secondly, we must guarentee we never send the | 
|  | 129 | * software antenna diversity command to the driver. | 
| Ivo van Doorn | 6d64360 | 2008-11-02 00:38:10 +0100 | [diff] [blame] | 130 | */ | 
| Ivo van Doorn | 0ed7b3c | 2011-04-18 15:35:12 +0200 | [diff] [blame] | 131 | if (!(ant->flags & ANTENNA_RX_DIVERSITY)) { | 
|  | 132 | if (config.rx == ANTENNA_SW_DIVERSITY) { | 
|  | 133 | ant->flags |= ANTENNA_RX_DIVERSITY; | 
|  | 134 |  | 
|  | 135 | if (def->rx == ANTENNA_SW_DIVERSITY) | 
|  | 136 | config.rx = ANTENNA_B; | 
|  | 137 | else | 
|  | 138 | config.rx = def->rx; | 
|  | 139 | } | 
|  | 140 | } else if (config.rx == ANTENNA_SW_DIVERSITY) | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 141 | config.rx = active->rx; | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 142 |  | 
| Ivo van Doorn | 0ed7b3c | 2011-04-18 15:35:12 +0200 | [diff] [blame] | 143 | if (!(ant->flags & ANTENNA_TX_DIVERSITY)) { | 
|  | 144 | if (config.tx == ANTENNA_SW_DIVERSITY) { | 
|  | 145 | ant->flags |= ANTENNA_TX_DIVERSITY; | 
|  | 146 |  | 
|  | 147 | if (def->tx == ANTENNA_SW_DIVERSITY) | 
|  | 148 | config.tx = ANTENNA_B; | 
|  | 149 | else | 
|  | 150 | config.tx = def->tx; | 
|  | 151 | } | 
|  | 152 | } else if (config.tx == ANTENNA_SW_DIVERSITY) | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 153 | config.tx = active->tx; | 
|  | 154 |  | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 155 | /* | 
| Ivo van Doorn | e25c4bb | 2007-10-27 13:39:28 +0200 | [diff] [blame] | 156 | * Antenna setup changes require the RX to be disabled, | 
|  | 157 | * else the changes will be ignored by the device. | 
|  | 158 | */ | 
| Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 159 | if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) | 
| Ivo van Doorn | 0b7fde5 | 2010-12-13 12:35:17 +0100 | [diff] [blame] | 160 | rt2x00queue_stop_queue(rt2x00dev->rx); | 
| Ivo van Doorn | e25c4bb | 2007-10-27 13:39:28 +0200 | [diff] [blame] | 161 |  | 
|  | 162 | /* | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 163 | * Write new antenna setup to device and reset the link tuner. | 
|  | 164 | * The latter is required since we need to recalibrate the | 
|  | 165 | * noise-sensitivity ratio for the new setup. | 
|  | 166 | */ | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 167 | rt2x00dev->ops->lib->config_ant(rt2x00dev, &config); | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 168 |  | 
| Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 169 | rt2x00link_reset_tuner(rt2x00dev, true); | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 170 |  | 
| Ivo van Doorn | bdfa500 | 2009-08-08 23:53:04 +0200 | [diff] [blame] | 171 | memcpy(active, &config, sizeof(config)); | 
| Ivo van Doorn | e25c4bb | 2007-10-27 13:39:28 +0200 | [diff] [blame] | 172 |  | 
| Ivo van Doorn | 0262ab0 | 2008-08-29 21:04:26 +0200 | [diff] [blame] | 173 | if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) | 
| Ivo van Doorn | 0b7fde5 | 2010-12-13 12:35:17 +0100 | [diff] [blame] | 174 | rt2x00queue_start_queue(rt2x00dev->rx); | 
| Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 175 | } | 
|  | 176 |  | 
| Gertjan van Wingerde | 46a01ec | 2011-04-18 15:33:41 +0200 | [diff] [blame] | 177 | static u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev, | 
|  | 178 | struct ieee80211_conf *conf) | 
|  | 179 | { | 
|  | 180 | struct hw_mode_spec *spec = &rt2x00dev->spec; | 
|  | 181 | int center_channel; | 
|  | 182 | u16 i; | 
|  | 183 |  | 
|  | 184 | /* | 
|  | 185 | * Initialize center channel to current channel. | 
|  | 186 | */ | 
|  | 187 | center_channel = spec->channels[conf->channel->hw_value].channel; | 
|  | 188 |  | 
|  | 189 | /* | 
|  | 190 | * Adjust center channel to HT40+ and HT40- operation. | 
|  | 191 | */ | 
|  | 192 | if (conf_is_ht40_plus(conf)) | 
|  | 193 | center_channel += 2; | 
|  | 194 | else if (conf_is_ht40_minus(conf)) | 
|  | 195 | center_channel -= (center_channel == 14) ? 1 : 2; | 
|  | 196 |  | 
|  | 197 | for (i = 0; i < spec->num_channels; i++) | 
|  | 198 | if (spec->channels[i].channel == center_channel) | 
|  | 199 | return i; | 
|  | 200 |  | 
|  | 201 | WARN_ON(1); | 
|  | 202 | return conf->channel->hw_value; | 
|  | 203 | } | 
|  | 204 |  | 
| Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 205 | void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 206 | struct ieee80211_conf *conf, | 
|  | 207 | unsigned int ieee80211_flags) | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 208 | { | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 209 | struct rt2x00lib_conf libconf; | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 210 | u16 hw_value; | 
| Ivo van Doorn | 1c0bcf8 | 2011-04-30 17:18:18 +0200 | [diff] [blame] | 211 | u16 autowake_timeout; | 
|  | 212 | u16 beacon_int; | 
|  | 213 | u16 beacon_diff; | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 214 |  | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 215 | memset(&libconf, 0, sizeof(libconf)); | 
|  | 216 |  | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 217 | libconf.conf = conf; | 
| Ivo van Doorn | f5507ce | 2008-02-03 15:51:13 +0100 | [diff] [blame] | 218 |  | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 219 | if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL) { | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 220 | if (conf_is_ht40(conf)) { | 
| Ivo van Doorn | 7dab73b | 2011-04-18 15:27:06 +0200 | [diff] [blame] | 221 | set_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags); | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 222 | hw_value = rt2x00ht_center_channel(rt2x00dev, conf); | 
|  | 223 | } else { | 
| Ivo van Doorn | 7dab73b | 2011-04-18 15:27:06 +0200 | [diff] [blame] | 224 | clear_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags); | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 225 | hw_value = conf->channel->hw_value; | 
|  | 226 | } | 
| Ivo van Doorn | 35f00cf | 2009-04-26 16:09:32 +0200 | [diff] [blame] | 227 |  | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 228 | memcpy(&libconf.rf, | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 229 | &rt2x00dev->spec.channels[hw_value], | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 230 | sizeof(libconf.rf)); | 
| Ivo van Doorn | 8c5e7a5 | 2008-08-04 16:38:47 +0200 | [diff] [blame] | 231 |  | 
|  | 232 | memcpy(&libconf.channel, | 
| Gertjan van Wingerde | 06443e4 | 2010-06-03 10:52:08 +0200 | [diff] [blame] | 233 | &rt2x00dev->spec.channels_info[hw_value], | 
| Ivo van Doorn | 8c5e7a5 | 2008-08-04 16:38:47 +0200 | [diff] [blame] | 234 | sizeof(libconf.channel)); | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 235 | } | 
|  | 236 |  | 
| Ivo van Doorn | 1c0bcf8 | 2011-04-30 17:18:18 +0200 | [diff] [blame] | 237 | if (test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) && | 
|  | 238 | (ieee80211_flags & IEEE80211_CONF_CHANGE_PS)) | 
|  | 239 | cancel_delayed_work_sync(&rt2x00dev->autowakeup_work); | 
|  | 240 |  | 
| Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 241 | /* | 
|  | 242 | * Start configuration. | 
|  | 243 | */ | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 244 | rt2x00dev->ops->lib->config(rt2x00dev, &libconf, ieee80211_flags); | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 245 |  | 
|  | 246 | /* | 
|  | 247 | * Some configuration changes affect the link quality | 
|  | 248 | * which means we need to reset the link tuner. | 
|  | 249 | */ | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 250 | if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL) | 
| Ivo van Doorn | 84e3196 | 2008-12-20 10:53:29 +0100 | [diff] [blame] | 251 | rt2x00link_reset_tuner(rt2x00dev, false); | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 252 |  | 
| Stanislaw Gruszka | 3bb42a6 | 2011-06-04 16:48:54 +0200 | [diff] [blame] | 253 | if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) && | 
|  | 254 | test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) && | 
| Ivo van Doorn | 1c0bcf8 | 2011-04-30 17:18:18 +0200 | [diff] [blame] | 255 | (ieee80211_flags & IEEE80211_CONF_CHANGE_PS) && | 
|  | 256 | (conf->flags & IEEE80211_CONF_PS)) { | 
|  | 257 | beacon_diff = (long)jiffies - (long)rt2x00dev->last_beacon; | 
|  | 258 | beacon_int = msecs_to_jiffies(rt2x00dev->beacon_int); | 
|  | 259 |  | 
|  | 260 | if (beacon_diff > beacon_int) | 
|  | 261 | beacon_diff = 0; | 
|  | 262 |  | 
|  | 263 | autowake_timeout = (conf->max_sleep_period * beacon_int) - beacon_diff; | 
|  | 264 | queue_delayed_work(rt2x00dev->workqueue, | 
|  | 265 | &rt2x00dev->autowakeup_work, | 
|  | 266 | autowake_timeout - 15); | 
|  | 267 | } | 
|  | 268 |  | 
|  | 269 | if (conf->flags & IEEE80211_CONF_PS) | 
|  | 270 | set_bit(CONFIG_POWERSAVING, &rt2x00dev->flags); | 
|  | 271 | else | 
|  | 272 | clear_bit(CONFIG_POWERSAVING, &rt2x00dev->flags); | 
|  | 273 |  | 
| Ivo van Doorn | e4ea1c4 | 2008-10-29 17:17:57 +0100 | [diff] [blame] | 274 | rt2x00dev->curr_band = conf->channel->band; | 
| Ivo van Doorn | e5ef5ba | 2010-08-06 20:49:27 +0200 | [diff] [blame] | 275 | rt2x00dev->curr_freq = conf->channel->center_freq; | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 276 | rt2x00dev->tx_power = conf->power_level; | 
| Ivo van Doorn | 42c8285 | 2008-12-02 18:20:04 +0100 | [diff] [blame] | 277 | rt2x00dev->short_retry = conf->short_frame_max_tx_count; | 
|  | 278 | rt2x00dev->long_retry = conf->long_frame_max_tx_count; | 
| Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 279 | } |