Commit b5abcf02 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: corrections in timestamp related code

We get two timing related fields for each bss from firmware in scan
results.
1) timestamp - Actual timestamp information in probe response/beacon
2) network_tsf - firmware's TSF value at the time the beacon or probe
response was received.
Both are needed while associating by firmware.

The patch takes care of following things.
1) We should pass "timestamp" to cfg80211_inform_bss(), but currently
"network_tsf" is being provided. This error is corrected here.
2) Rename "network_tsf" to "fw_tsf"
3) Make use of u64 variable instead of an array of u8/u32 to save
parsed "timestamp" information.
4) Use timestamp provided to stack in scan results using
cfg80211_inform_bss() while associating. (bss->tsf)
5) Allocate space to save fw_tsf in "priv" of cfg80211_bss
and retrieve it while associating.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9558a407
...@@ -1482,8 +1482,8 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) ...@@ -1482,8 +1482,8 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv)
memcpy(wdev->wiphy->perm_addr, priv->curr_addr, ETH_ALEN); memcpy(wdev->wiphy->perm_addr, priv->curr_addr, ETH_ALEN);
wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
/* Reserve space for bss band information */ /* Reserve space for mwifiex specific private data for BSS */
wdev->wiphy->bss_priv_size = sizeof(u8); wdev->wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv);
wdev->wiphy->reg_notifier = mwifiex_reg_notifier; wdev->wiphy->reg_notifier = mwifiex_reg_notifier;
......
...@@ -819,7 +819,7 @@ struct host_cmd_ds_txpwr_cfg { ...@@ -819,7 +819,7 @@ struct host_cmd_ds_txpwr_cfg {
struct mwifiex_bcn_param { struct mwifiex_bcn_param {
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
u8 rssi; u8 rssi;
__le32 timestamp[2]; __le64 timestamp;
__le16 beacon_period; __le16 beacon_period;
__le16 cap_info_bitmap; __le16 cap_info_bitmap;
} __packed; } __packed;
......
...@@ -118,15 +118,15 @@ mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer, ...@@ -118,15 +118,15 @@ mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer,
*buffer += sizeof(tsf_tlv.header); *buffer += sizeof(tsf_tlv.header);
/* TSF at the time when beacon/probe_response was received */ /* TSF at the time when beacon/probe_response was received */
tsf_val = cpu_to_le64(bss_desc->network_tsf); tsf_val = cpu_to_le64(bss_desc->fw_tsf);
memcpy(*buffer, &tsf_val, sizeof(tsf_val)); memcpy(*buffer, &tsf_val, sizeof(tsf_val));
*buffer += sizeof(tsf_val); *buffer += sizeof(tsf_val);
memcpy(&tsf_val, bss_desc->time_stamp, sizeof(tsf_val)); tsf_val = cpu_to_le64(bss_desc->timestamp);
dev_dbg(priv->adapter->dev, dev_dbg(priv->adapter->dev,
"info: %s: TSF offset calc: %016llx - %016llx\n", "info: %s: TSF offset calc: %016llx - %016llx\n",
__func__, tsf_val, bss_desc->network_tsf); __func__, bss_desc->timestamp, bss_desc->fw_tsf);
memcpy(*buffer, &tsf_val, sizeof(tsf_val)); memcpy(*buffer, &tsf_val, sizeof(tsf_val));
*buffer += sizeof(tsf_val); *buffer += sizeof(tsf_val);
......
...@@ -260,8 +260,8 @@ struct mwifiex_bssdescriptor { ...@@ -260,8 +260,8 @@ struct mwifiex_bssdescriptor {
* BAND_A(0X04): 'a' band * BAND_A(0X04): 'a' band
*/ */
u16 bss_band; u16 bss_band;
u64 network_tsf; u64 fw_tsf;
u8 time_stamp[8]; u64 timestamp;
union ieee_types_phy_param_set phy_param_set; union ieee_types_phy_param_set phy_param_set;
union ieee_types_ss_param_set ss_param_set; union ieee_types_ss_param_set ss_param_set;
u16 cap_info_bitmap; u16 cap_info_bitmap;
...@@ -522,6 +522,11 @@ struct cmd_ctrl_node { ...@@ -522,6 +522,11 @@ struct cmd_ctrl_node {
u8 cmd_wait_q_woken; u8 cmd_wait_q_woken;
}; };
struct mwifiex_bss_priv {
u8 band;
u64 fw_tsf;
};
struct mwifiex_if_ops { struct mwifiex_if_ops {
int (*init_if) (struct mwifiex_adapter *); int (*init_if) (struct mwifiex_adapter *);
void (*cleanup_if) (struct mwifiex_adapter *); void (*cleanup_if) (struct mwifiex_adapter *);
......
...@@ -1603,14 +1603,16 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1603,14 +1603,16 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
const u8 *ie_buf; const u8 *ie_buf;
size_t ie_len; size_t ie_len;
u16 channel = 0; u16 channel = 0;
u64 network_tsf = 0; u64 fw_tsf = 0;
u16 beacon_size = 0; u16 beacon_size = 0;
u32 curr_bcn_bytes; u32 curr_bcn_bytes;
u32 freq; u32 freq;
u16 beacon_period; u16 beacon_period;
u16 cap_info_bitmap; u16 cap_info_bitmap;
u8 *current_ptr; u8 *current_ptr;
u64 timestamp;
struct mwifiex_bcn_param *bcn_param; struct mwifiex_bcn_param *bcn_param;
struct mwifiex_bss_priv *bss_priv;
if (bytes_left >= sizeof(beacon_size)) { if (bytes_left >= sizeof(beacon_size)) {
/* Extract & convert beacon size from command buffer */ /* Extract & convert beacon size from command buffer */
...@@ -1654,6 +1656,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1654,6 +1656,7 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
rssi = (-rssi) * 100; /* Convert dBm to mBm */ rssi = (-rssi) * 100; /* Convert dBm to mBm */
dev_dbg(adapter->dev, "info: InterpretIE: RSSI=%d\n", rssi); dev_dbg(adapter->dev, "info: InterpretIE: RSSI=%d\n", rssi);
timestamp = le64_to_cpu(bcn_param->timestamp);
beacon_period = le16_to_cpu(bcn_param->beacon_period); beacon_period = le16_to_cpu(bcn_param->beacon_period);
cap_info_bitmap = le16_to_cpu(bcn_param->cap_info_bitmap); cap_info_bitmap = le16_to_cpu(bcn_param->cap_info_bitmap);
...@@ -1693,14 +1696,13 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1693,14 +1696,13 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
/* /*
* If the TSF TLV was appended to the scan results, save this * If the TSF TLV was appended to the scan results, save this
* entry's TSF value in the networkTSF field.The networkTSF is * entry's TSF value in the fw_tsf field. It is the firmware's
* the firmware's TSF value at the time the beacon or probe * TSF value at the time the beacon or probe response was
* response was received. * received.
*/ */
if (tsf_tlv) if (tsf_tlv)
memcpy(&network_tsf, memcpy(&fw_tsf, &tsf_tlv->tsf_data[idx * TSF_DATA_SIZE],
&tsf_tlv->tsf_data[idx * TSF_DATA_SIZE], sizeof(fw_tsf));
sizeof(network_tsf));
if (channel) { if (channel) {
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
...@@ -1723,10 +1725,12 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, ...@@ -1723,10 +1725,12 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) { if (chan && !(chan->flags & IEEE80211_CHAN_DISABLED)) {
bss = cfg80211_inform_bss(priv->wdev->wiphy, bss = cfg80211_inform_bss(priv->wdev->wiphy,
chan, bssid, network_tsf, chan, bssid, timestamp,
cap_info_bitmap, beacon_period, cap_info_bitmap, beacon_period,
ie_buf, ie_len, rssi, GFP_KERNEL); ie_buf, ie_len, rssi, GFP_KERNEL);
*(u8 *)bss->priv = band; bss_priv = (struct mwifiex_bss_priv *)bss->priv;
bss_priv->band = band;
bss_priv->fw_tsf = fw_tsf;
if (priv->media_connected && if (priv->media_connected &&
!memcmp(bssid, !memcmp(bssid,
priv->curr_bss_params.bss_descriptor priv->curr_bss_params.bss_descriptor
......
...@@ -160,6 +160,7 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, ...@@ -160,6 +160,7 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
{ {
int ret; int ret;
u8 *beacon_ie; u8 *beacon_ie;
struct mwifiex_bss_priv *bss_priv = (void *)bss->priv;
beacon_ie = kmemdup(bss->information_elements, bss->len_beacon_ies, beacon_ie = kmemdup(bss->information_elements, bss->len_beacon_ies,
GFP_KERNEL); GFP_KERNEL);
...@@ -174,7 +175,9 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, ...@@ -174,7 +175,9 @@ int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
bss_desc->beacon_buf_size = bss->len_beacon_ies; bss_desc->beacon_buf_size = bss->len_beacon_ies;
bss_desc->beacon_period = bss->beacon_interval; bss_desc->beacon_period = bss->beacon_interval;
bss_desc->cap_info_bitmap = bss->capability; bss_desc->cap_info_bitmap = bss->capability;
bss_desc->bss_band = *(u8 *)bss->priv; bss_desc->bss_band = bss_priv->band;
bss_desc->fw_tsf = bss_priv->fw_tsf;
bss_desc->timestamp = bss->tsf;
if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) { if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n"); dev_dbg(priv->adapter->dev, "info: InterpretIE: AP WEP enabled\n");
bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP; bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment