aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-05-22 16:13:05 -0400
committerJohannes Berg <johannes.berg@intel.com>2012-07-12 06:10:46 -0400
commit8c358bcd097fa1f63e57fb82525ba52f4a537bfa (patch)
treeac11cd1fef6682c7eabecda0254f56e4ba8e4316
parent30f422925c39edf61cbcf6d35140d726402d4b04 (diff)
mac80211: add time synchronisation with BSS for assoc
Some drivers (iwlegacy, iwlwifi and rt2x00) today use the bss_conf.last_tsf value. By itself though that value is completely worthless since it may be ancient. What really is needed is synchronisation between some device time and the TSF. To clarify this, rename bss_conf.last_tsf to sync_tsf and add sync_device_ts which is obtained from rx_status which gets a new field device_timestamp for this purpose. This is intentionally not using the mactime field since that is used for other things and in IBSS is expected to sync with the IBSS's TSF which isn't necessarily true for the device timestamp. Also, since we have the information and it's useful even before the connection has been established, give all the timing details to the driver before authenticating. Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/iwlegacy/common.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/rxon.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c2
-rw-r--r--include/net/mac80211.h10
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/mlme.c15
-rw-r--r--net/mac80211/scan.c3
-rw-r--r--net/mac80211/trace.h6
8 files changed, 27 insertions, 15 deletions
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index cbf2dc18341f..9cbed0b15b07 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -5360,7 +5360,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5360 if (changes & BSS_CHANGED_ASSOC) { 5360 if (changes & BSS_CHANGED_ASSOC) {
5361 D_MAC80211("ASSOC %d\n", bss_conf->assoc); 5361 D_MAC80211("ASSOC %d\n", bss_conf->assoc);
5362 if (bss_conf->assoc) { 5362 if (bss_conf->assoc) {
5363 il->timestamp = bss_conf->last_tsf; 5363 il->timestamp = bss_conf->sync_tsf;
5364 5364
5365 if (!il_is_rfkill(il)) 5365 if (!il_is_rfkill(il))
5366 il->ops->post_associate(il); 5366 il->ops->post_associate(il);
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c
index 6ee940f497f9..10896393e5a0 100644
--- a/drivers/net/wireless/iwlwifi/dvm/rxon.c
+++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c
@@ -1447,7 +1447,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
1447 1447
1448 if (changes & BSS_CHANGED_ASSOC) { 1448 if (changes & BSS_CHANGED_ASSOC) {
1449 if (bss_conf->assoc) { 1449 if (bss_conf->assoc) {
1450 priv->timestamp = bss_conf->last_tsf; 1450 priv->timestamp = bss_conf->sync_tsf;
1451 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; 1451 ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK;
1452 } else { 1452 } else {
1453 /* 1453 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index e7361d913e8e..49a63e973934 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -102,7 +102,7 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
102 102
103 /* Update the AID, this is needed for dynamic PS support */ 103 /* Update the AID, this is needed for dynamic PS support */
104 rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0; 104 rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0;
105 rt2x00dev->last_beacon = bss_conf->last_tsf; 105 rt2x00dev->last_beacon = bss_conf->sync_tsf;
106 106
107 /* Update global beacon interval time, this is needed for PS support */ 107 /* Update global beacon interval time, this is needed for PS support */
108 rt2x00dev->beacon_int = bss_conf->beacon_int; 108 rt2x00dev->beacon_int = bss_conf->beacon_int;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 7300cb51dd5f..bb86aa6f98dd 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -233,8 +233,10 @@ enum ieee80211_rssi_event {
233 * valid in station mode only while @assoc is true and if also 233 * valid in station mode only while @assoc is true and if also
234 * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf 234 * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf
235 * @ps_dtim_period) 235 * @ps_dtim_period)
236 * @last_tsf: last beacon's/probe response's TSF timestamp (could be old 236 * @sync_tsf: last beacon's/probe response's TSF timestamp (could be old
237 * as it may have been received during scanning long ago) 237 * as it may have been received during scanning long ago)
238 * @sync_device_ts: the device timestamp corresponding to the sync_tsf,
239 * the driver/device can use this to calculate synchronisation
238 * @beacon_int: beacon interval 240 * @beacon_int: beacon interval
239 * @assoc_capability: capabilities taken from assoc resp 241 * @assoc_capability: capabilities taken from assoc resp
240 * @basic_rates: bitmap of basic rates, each bit stands for an 242 * @basic_rates: bitmap of basic rates, each bit stands for an
@@ -281,7 +283,8 @@ struct ieee80211_bss_conf {
281 u8 dtim_period; 283 u8 dtim_period;
282 u16 beacon_int; 284 u16 beacon_int;
283 u16 assoc_capability; 285 u16 assoc_capability;
284 u64 last_tsf; 286 u64 sync_tsf;
287 u32 sync_device_ts;
285 u32 basic_rates; 288 u32 basic_rates;
286 int mcast_rate[IEEE80211_NUM_BANDS]; 289 int mcast_rate[IEEE80211_NUM_BANDS];
287 u16 ht_operation_mode; 290 u16 ht_operation_mode;
@@ -696,6 +699,8 @@ enum mac80211_rx_flags {
696 * 699 *
697 * @mactime: value in microseconds of the 64-bit Time Synchronization Function 700 * @mactime: value in microseconds of the 64-bit Time Synchronization Function
698 * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. 701 * (TSF) timer when the first data symbol (MPDU) arrived at the hardware.
702 * @device_timestamp: arbitrary timestamp for the device, mac80211 doesn't use
703 * it but can store it and pass it back to the driver for synchronisation
699 * @band: the active band when this frame was received 704 * @band: the active band when this frame was received
700 * @freq: frequency the radio was tuned to when receiving this frame, in MHz 705 * @freq: frequency the radio was tuned to when receiving this frame, in MHz
701 * @signal: signal strength when receiving this frame, either in dBm, in dB or 706 * @signal: signal strength when receiving this frame, either in dBm, in dB or
@@ -709,6 +714,7 @@ enum mac80211_rx_flags {
709 */ 714 */
710struct ieee80211_rx_status { 715struct ieee80211_rx_status {
711 u64 mactime; 716 u64 mactime;
717 u32 device_timestamp;
712 u16 flag; 718 u16 flag;
713 u16 freq; 719 u16 freq;
714 u8 rate_idx; 720 u8 rate_idx;
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 2a97d668d2da..7998513ec831 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -85,6 +85,8 @@ struct ieee80211_bss {
85 size_t ssid_len; 85 size_t ssid_len;
86 u8 ssid[IEEE80211_MAX_SSID_LEN]; 86 u8 ssid[IEEE80211_MAX_SSID_LEN];
87 87
88 u32 device_ts;
89
88 u8 dtim_period; 90 u8 dtim_period;
89 91
90 bool wmm_used; 92 bool wmm_used;
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 4b503ce893d8..4efcbf89a72d 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1269,11 +1269,6 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
1269 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 1269 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
1270 1270
1271 bss_info_changed |= BSS_CHANGED_ASSOC; 1271 bss_info_changed |= BSS_CHANGED_ASSOC;
1272 /* set timing information */
1273 bss_conf->beacon_int = cbss->beacon_interval;
1274 bss_conf->last_tsf = cbss->tsf;
1275
1276 bss_info_changed |= BSS_CHANGED_BEACON_INT;
1277 bss_info_changed |= ieee80211_handle_bss_capability(sdata, 1272 bss_info_changed |= ieee80211_handle_bss_capability(sdata,
1278 bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value); 1273 bss_conf->assoc_capability, bss->has_erp_value, bss->erp_value);
1279 1274
@@ -3135,9 +3130,15 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3135 3130
3136 memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN); 3131 memcpy(ifmgd->bssid, cbss->bssid, ETH_ALEN);
3137 3132
3138 /* tell driver about BSSID and basic rates */ 3133 /* set timing information */
3134 sdata->vif.bss_conf.beacon_int = cbss->beacon_interval;
3135 sdata->vif.bss_conf.sync_tsf = cbss->tsf;
3136 sdata->vif.bss_conf.sync_device_ts = bss->device_ts;
3137
3138 /* tell driver about BSSID, basic rates and timing */
3139 ieee80211_bss_info_change_notify(sdata, 3139 ieee80211_bss_info_change_notify(sdata,
3140 BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES); 3140 BSS_CHANGED_BSSID | BSS_CHANGED_BASIC_RATES |
3141 BSS_CHANGED_BEACON_INT);
3141 3142
3142 if (assoc) 3143 if (assoc)
3143 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH); 3144 sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 1a893f3637c5..e80a8b644aa0 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -83,13 +83,14 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
83 83
84 cbss = cfg80211_inform_bss_frame(local->hw.wiphy, channel, 84 cbss = cfg80211_inform_bss_frame(local->hw.wiphy, channel,
85 mgmt, len, signal, GFP_ATOMIC); 85 mgmt, len, signal, GFP_ATOMIC);
86
87 if (!cbss) 86 if (!cbss)
88 return NULL; 87 return NULL;
89 88
90 cbss->free_priv = ieee80211_rx_bss_free; 89 cbss->free_priv = ieee80211_rx_bss_free;
91 bss = (void *)cbss->priv; 90 bss = (void *)cbss->priv;
92 91
92 bss->device_ts = rx_status->device_timestamp;
93
93 if (elems->parse_error) { 94 if (elems->parse_error) {
94 if (beacon) 95 if (beacon)
95 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON; 96 bss->corrupt_data |= IEEE80211_BSS_CORRUPT_BEACON;
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h
index e1e9d10ec2e7..c6d33b55b2df 100644
--- a/net/mac80211/trace.h
+++ b/net/mac80211/trace.h
@@ -306,7 +306,8 @@ TRACE_EVENT(drv_bss_info_changed,
306 __field(u8, dtimper) 306 __field(u8, dtimper)
307 __field(u16, bcnint) 307 __field(u16, bcnint)
308 __field(u16, assoc_cap) 308 __field(u16, assoc_cap)
309 __field(u64, timestamp) 309 __field(u64, sync_tsf)
310 __field(u32, sync_device_ts)
310 __field(u32, basic_rates) 311 __field(u32, basic_rates)
311 __field(u32, changed) 312 __field(u32, changed)
312 __field(bool, enable_beacon) 313 __field(bool, enable_beacon)
@@ -325,7 +326,8 @@ TRACE_EVENT(drv_bss_info_changed,
325 __entry->dtimper = info->dtim_period; 326 __entry->dtimper = info->dtim_period;
326 __entry->bcnint = info->beacon_int; 327 __entry->bcnint = info->beacon_int;
327 __entry->assoc_cap = info->assoc_capability; 328 __entry->assoc_cap = info->assoc_capability;
328 __entry->timestamp = info->last_tsf; 329 __entry->sync_tsf = info->sync_tsf;
330 __entry->sync_device_ts = info->sync_device_ts;
329 __entry->basic_rates = info->basic_rates; 331 __entry->basic_rates = info->basic_rates;
330 __entry->enable_beacon = info->enable_beacon; 332 __entry->enable_beacon = info->enable_beacon;
331 __entry->ht_operation_mode = info->ht_operation_mode; 333 __entry->ht_operation_mode = info->ht_operation_mode;