ath10k: fix mesh sync operation
Subsystems (2)
cover ath10k: fix mesh sync operation
This patchset introduces a new ieee80211_op offset_tsf(), which gives the driver a s64 TSF offset for TSF adjustment. This is more accurate than programming absolute TSF since programming delay is avoided.
ath10k can't get the current TSF or program an absolute TSF, so we remove those ops to not mislead the stack and hopefully avoid future bugs.
Tested on QCA4019 with firmware 10.4-3.2.1-0033. After this change Toffset remains stable to within 5us.
Thomas Pedersen (4):
mac80211: add offset_tsf driver op
ath10k: implement offset_tsf ieee80211_op
ath10k: remove set/get_tsf ieee80211_ops
mac80211: mesh: decrease max drift
drivers/net/wireless/ath/ath10k/mac.c | 45 +++++++++++-------------------- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 1 - drivers/net/wireless/ath/ath10k/wmi.c | 6 ++--- drivers/net/wireless/ath/ath10k/wmi.h | 8 +++++- include/net/mac80211.h | 8 ++++++ net/mac80211/debugfs_netdev.c | 12 ++++++--- net/mac80211/driver-ops.c | 15 +++++++++++ net/mac80211/driver-ops.h | 3 +++ net/mac80211/mesh_sync.c | 12 ++++++--- net/mac80211/trace.h | 26 ++++++++++++++++++ 10 files changed, 94 insertions(+), 42 deletions(-)
Signature · 7 lines
2.10.0.297.gf6727b0 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
PATCH 1/4 mac80211: add offset_tsf driver op
Allows ie. mesh sync code to make incremental TSF adjustments, avoiding any uncertainty introduced by delay in programming absolute TSF.
--- include/net/mac80211.h | 8 ++++++++ net/mac80211/debugfs_netdev.c | 12 +++++++++--- net/mac80211/driver-ops.c | 15 +++++++++++++++ net/mac80211/driver-ops.h | 3 +++ net/mac80211/mesh_sync.c | 10 +++++++--- net/mac80211/trace.h | 26 ++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 6 deletions(-)
include/net/mac80211.h +8 -0
@@ -3166,6 +3166,12 @@ enum ieee80211_reconfig_type {* required function. * The callback can sleep. * +* @offset_tsf: Offset the TSF timer by the specified value in the +* firmware/hardware. Preferred to set_tsf as it avoids delay between +* calling set_tsf() and hardware getting programmed, which will show up +* as TSF delay. Is not a required function. +* The callback can sleep. +* * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize * with other STAs in the IBSS. This is only used in IBSS mode. This * function is optional if the firmware/hardware takes full care of
@@ -3531,6 +3537,8 @@ struct ieee80211_ops {u64 (*get_tsf)(struct ieee80211_hw *hw,struct ieee80211_vif *vif);void (*set_tsf)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,u64 tsf); +void (*offset_tsf)(struct ieee80211_hw *hw,struct ieee80211_vif *vif, +s64 offset);void (*reset_tsf)(struct ieee80211_hw *hw,struct ieee80211_vif *vif);int (*tx_last_beacon)(struct ieee80211_hw *hw); int (*ampdu_action)(struct ieee80211_hw *hw,
net/mac80211/debugfs_netdev.c +9 -3
@@ -556,9 +556,15 @@ static ssize_t ieee80211_if_parse_tsf( ret =kstrtoull (buf,10 , &tsf);if (ret <0 )return ret; -if (tsf_is_delta) - tsf =drv_get_tsf (local, sdata) + tsf_is_delta * tsf; -if (local->ops->set_tsf) { +if (tsf_is_delta && local->ops->offset_tsf) { +drv_offset_tsf (local, sdata, tsf_is_delta * tsf); +wiphy_info (local->hw.wiphy, +"debugfs offset TSF by %018lld\n" , + tsf_is_delta * tsf); + }else if (local->ops->set_tsf) { +if (tsf_is_delta) + tsf =drv_get_tsf (local, sdata) + + tsf_is_delta * tsf;drv_set_tsf (local, sdata, tsf);wiphy_info (local->hw.wiphy,"debugfs set TSF to %#018llx\n" , tsf);
net/mac80211/driver-ops.c +15 -0
@@ -215,6 +215,21 @@ void drv_set_tsf(struct ieee80211_local *local,trace_drv_return_void (local); } +void drv_offset_tsf (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +s64 offset) +{ +might_sleep (); + +if (!check_sdata_in_driver (sdata)) +return ; + +trace_drv_offset_tsf (local, sdata, offset); +if (local->ops->offset_tsf) + local->ops->offset_tsf (&local->hw, &sdata->vif, offset); +trace_drv_return_void (local); +} +void drv_reset_tsf (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata) {
net/mac80211/driver-ops.h +3 -0
@@ -568,6 +568,9 @@ u64 drv_get_tsf(struct ieee80211_local *local,void drv_set_tsf (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata,u64 tsf); +void drv_offset_tsf (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +s64 offset);void drv_reset_tsf (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata);
net/mac80211/mesh_sync.c +7 -3
@@ -70,9 +70,13 @@ void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata) }spin_unlock_bh (&ifmsh->sync_offset_lock); - tsf =drv_get_tsf (local, sdata); -if (tsf !=-1ULL ) -drv_set_tsf (local, sdata, tsf + tsfdelta); +if (local->ops->offset_tsf) { +drv_offset_tsf (local, sdata, tsfdelta); + }else { + tsf =drv_get_tsf (local, sdata); +if (tsf !=-1ULL ) +drv_set_tsf (local, sdata, tsf + tsfdelta); + } } static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
net/mac80211/trace.h +26 -0
@@ -984,6 +984,32 @@ TRACE_EVENT(drv_set_tsf, ) ); +TRACE_EVENT (drv_offset_tsf, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata, + s64 offset), + +TP_ARGS (local, sdata, offset), + +TP_STRUCT__entry ( + LOCAL_ENTRY + VIF_ENTRY +__field (s64, tsf_offset) + ), + +TP_fast_assign ( + LOCAL_ASSIGN; + VIF_ASSIGN; + __entry->tsf_offset = offset; + ), + +TP_printk ( + LOCAL_PR_FMT VIF_PR_FMT " tsf offset:%lld", +LOCAL_PR_ARG ,VIF_PR_ARG , + (unsigned long long )__entry->tsf_offset + ) +); + DEFINE_EVENT(local_sdata_evt, drv_reset_tsf, TP_PROTO(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata),
Signature · 1 line
2.10.0.297.gf6727b0
PATCH 2/4 ath10k: implement offset_tsf ieee80211_op
In reply to Thomas PedersenCurrent set_tsf is implemented in terms of TSF_INCREMENT only. Instead support new WMI command TSF_DECREMENT and export these through offset_tsf. Advantage is we get more accurate TSF adjustments, and don't calculate wrong offset in case absolute TSF was calculated from rx_mactime (actual TSF).
The new WMI command is available in firmware 10.4-3.2.1-00033 for QCA4019 chips. Old drivers on new firmware or vice versa shouldn't be a problem since get/set tsf logic was already broken.
--- drivers/net/wireless/ath/ath10k/mac.c | 25 +++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 2 ++ drivers/net/wireless/ath/ath10k/wmi.h | 7 +++++++ 3 files changed, 34 insertions(+)
drivers/net/wireless/ath/ath10k/mac.c +25 -0
@@ -6992,6 +6992,30 @@ static void ath10k_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,ath10k_warn (ar,"failed to set tsf offset: %d\n" , ret); } +static void ath10k_offset_tsf (struct ieee80211_hw *hw, +struct ieee80211_vif *vif,s64 tsf_offset) +{ +struct ath10k *ar = hw->priv; +struct ath10k_vif *arvif =ath10k_vif_to_arvif (vif); +u32 offset, vdev_param; +int ret; + +if (tsf_offset <0 ) { + vdev_param = ar->wmi.vdev_param->dec_tsf; + offset = -tsf_offset; + }else { + vdev_param = ar->wmi.vdev_param->inc_tsf; + offset = tsf_offset; + } + + ret =ath10k_wmi_vdev_set_param (ar, arvif->vdev_id, + vdev_param, offset); + +if (ret && ret != -EOPNOTSUPP ) +ath10k_warn (ar,"failed to set tsf offset %d cmd %d: %d\n" , + offset, vdev_param, ret); +} +static int ath10k_ampdu_action (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_ampdu_params *params)
@@ -7455,6 +7479,7 @@ static const struct ieee80211_ops ath10k_ops = { .sta_rc_update = ath10k_sta_rc_update, .get_tsf = ath10k_get_tsf, .set_tsf = ath10k_set_tsf, + .offset_tsf = ath10k_offset_tsf, .ampdu_action = ath10k_ampdu_action, .get_et_sset_count = ath10k_debug_get_et_sset_count, .get_et_stats = ath10k_debug_get_et_stats,
drivers/net/wireless/ath/ath10k/wmi.c +2 -0
@@ -1013,6 +1013,8 @@ static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = { .rx_decap_type = WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE, .bw_nss_ratemask = WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK, .set_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT, + .inc_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT, + .dec_tsf = WMI_10_4_VDEV_PARAM_TSF_DECREMENT, };static struct wmi_pdev_param_map wmi_pdev_param_map = {
drivers/net/wireless/ath/ath10k/wmi.h +7 -0
@@ -4677,6 +4677,8 @@ struct wmi_vdev_param_map {u32 rx_decap_type;u32 bw_nss_ratemask;u32 set_tsf; +u32 inc_tsf; +u32 dec_tsf; };#define WMI_VDEV_PARAM_UNSUPPORTED 0
@@ -5009,6 +5011,11 @@ enum wmi_10_4_vdev_param {WMI_10_4_VDEV_PARAM_STA_KICKOUT ,WMI_10_4_VDEV_PARAM_CAPABILITIES ,WMI_10_4_VDEV_PARAM_TSF_INCREMENT , +WMI_10_4_VDEV_PARAM_RX_FILTER , +WMI_10_4_VDEV_PARAM_MGMT_TX_POWER , +WMI_10_4_VDEV_PARAM_ATF_SSID_SCHED_POLICY , +WMI_10_4_VDEV_PARAM_DISABLE_DYN_BW_RTS , + WMI_10_4_VDEV_PARAM_TSF_DECREMENT, };#define WMI_VDEV_PARAM_TXBF_SU_TX_BFEE BIT(0)
Signature · 1 line
2.10.0.297.gf6727b0
Re: [2/4] ath10k: implement offset_tsf ieee80211_op
Quoted 7 lines · Thomas
Current
set_tsfis implemented in terms ofTSF_INCREMENTonly. Instead support new WMI commandTSF_DECREMENTand export these throughoffset_tsf. Advantage is we get more accurate TSF adjustments, and don't calculate wrong offset in case absolute TSF was calculated fromrx_mactime(actual TSF).
Quoted 6 lines
The new WMI command is available in firmware 10.4-3.2.1-00033 for QCA4019 chips. Old drivers on new firmware or vice versa shouldn't be a problem since get/set tsf logic was already broken.
Signed-off-by Thomas Pedersen <[email protected]>
Depends on:
3a53731df7e2 mac80211: mesh: decrease max drift 354d381baf11 mac80211: add offset_tsf driver op and use it for mesh
2 patches set to Awaiting Upstream.
9355377 [2/4] ath10k: implement offset_tsf ieee80211_op 9355375 [3/4] ath10k: remove set/get_tsf ieee80211_ops
Signature · 6 lines
https://patchwork.kernel.org/patch/9355377/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [2/4] ath10k: implement offset_tsf ieee80211_op
In reply to Thomas PedersenQuoted 7 lines · Thomas
Current
set_tsfis implemented in terms ofTSF_INCREMENTonly. Instead support new WMI commandTSF_DECREMENTand export these throughoffset_tsf. Advantage is we get more accurate TSF adjustments, and don't calculate wrong offset in case absolute TSF was calculated fromrx_mactime(actual TSF).
Quoted 6 lines
The new WMI command is available in firmware 10.4-3.2.1-00033 for QCA4019 chips. Old drivers on new firmware or vice versa shouldn't be a problem since get/set tsf logic was already broken.
Signed-off-by Thomas Pedersen <[email protected]>
2 patches applied to ath-next branch of ath.git, thanks.
973324fff154 ath10k: implement offset_tsf ieee80211_op f6f64cfb966d ath10k: remove set/get_tsf ieee80211_ops
Signature · 6 lines
https://patchwork.kernel.org/patch/9355377/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH 3/4 ath10k: remove set/get_tsf ieee80211_ops
In reply to Thomas PedersenNeither of these did the right thing:
- get_tsf just returned 0
- set_tsf assumed a simple offset was applied against get_tsf(), which works, except in the case of calculating TSF from rx_mactime (actual TSF).
Just remove them for now. We can reimplement set_tsf in terms of TSF increment/decrement in the future if get_tsf is ever supported by FW.
--- drivers/net/wireless/ath/ath10k/mac.c | 38 ------------------------------- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 1 - drivers/net/wireless/ath/ath10k/wmi.c | 4 ---- drivers/net/wireless/ath/ath10k/wmi.h | 1 - 4 files changed, 44 deletions(-)
drivers/net/wireless/ath/ath10k/mac.c +0 -38
@@ -6956,42 +6956,6 @@ static void ath10k_sta_rc_update(struct ieee80211_hw *hw,ieee80211_queue_work (hw, &arsta->update_wk); } -static u64 ath10k_get_tsf (struct ieee80211_hw *hw,struct ieee80211_vif *vif) -{ -/* -* FIXME: Return 0 for time being. Need to figure out whether FW -* has the API to fetch 64-bit local TSF -*/ - -return 0 ; -} - -static void ath10k_set_tsf (struct ieee80211_hw *hw,struct ieee80211_vif *vif, -u64 tsf) -{ -struct ath10k *ar = hw->priv; -struct ath10k_vif *arvif =ath10k_vif_to_arvif (vif); -u32 tsf_offset, vdev_param = ar->wmi.vdev_param->set_tsf; -int ret; - -/* Workaround: -* -* Given tsf argument is entire TSF value, but firmware accepts -* only TSF offset to current TSF. -* -* get_tsf function is used to get offset value, however since -* ath10k_get_tsf is not implemented properly, it will return 0 always. -* Luckily all the caller functions to set_tsf, as of now, also rely on -* get_tsf function to get entire tsf value such get_tsf() + tsf_delta, -* final tsf offset value to firmware will be arithmetically correct. -*/ - tsf_offset = tsf -ath10k_get_tsf (hw, vif); - ret =ath10k_wmi_vdev_set_param (ar, arvif->vdev_id, - vdev_param, tsf_offset); -if (ret && ret != -EOPNOTSUPP ) -ath10k_warn (ar,"failed to set tsf offset: %d\n" , ret); -} -static void ath10k_offset_tsf (struct ieee80211_hw *hw,struct ieee80211_vif *vif,s64 tsf_offset) {
@@ -7477,8 +7441,6 @@ static const struct ieee80211_ops ath10k_ops = { .get_survey = ath10k_get_survey, .set_bitrate_mask = ath10k_mac_op_set_bitrate_mask, .sta_rc_update = ath10k_sta_rc_update, - .get_tsf = ath10k_get_tsf, - .set_tsf = ath10k_set_tsf, .offset_tsf = ath10k_offset_tsf, .ampdu_action = ath10k_ampdu_action, .get_et_sset_count = ath10k_debug_get_et_sset_count,
drivers/net/wireless/ath/ath10k/wmi-tlv.c +0 -1
@@ -3464,7 +3464,6 @@ static struct wmi_vdev_param_map wmi_tlv_vdev_param_map = { .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, - .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, };static const struct wmi_ops wmi_tlv_ops = {
drivers/net/wireless/ath/ath10k/wmi.c +0 -4
@@ -785,7 +785,6 @@ static struct wmi_vdev_param_map wmi_vdev_param_map = { .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, - .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, };/* 10.X WMI VDEV param map */
@@ -861,7 +860,6 @@ static struct wmi_vdev_param_map wmi_10x_vdev_param_map = { .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, - .set_tsf = WMI_VDEV_PARAM_UNSUPPORTED, };static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = {
@@ -936,7 +934,6 @@ static struct wmi_vdev_param_map wmi_10_2_4_vdev_param_map = { .meru_vc = WMI_VDEV_PARAM_UNSUPPORTED, .rx_decap_type = WMI_VDEV_PARAM_UNSUPPORTED, .bw_nss_ratemask = WMI_VDEV_PARAM_UNSUPPORTED, - .set_tsf = WMI_10X_VDEV_PARAM_TSF_INCREMENT, };static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = {
@@ -1012,7 +1009,6 @@ static struct wmi_vdev_param_map wmi_10_4_vdev_param_map = { .meru_vc = WMI_10_4_VDEV_PARAM_MERU_VC, .rx_decap_type = WMI_10_4_VDEV_PARAM_RX_DECAP_TYPE, .bw_nss_ratemask = WMI_10_4_VDEV_PARAM_BW_NSS_RATEMASK, - .set_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT, .inc_tsf = WMI_10_4_VDEV_PARAM_TSF_INCREMENT, .dec_tsf = WMI_10_4_VDEV_PARAM_TSF_DECREMENT, };
drivers/net/wireless/ath/ath10k/wmi.h +0 -1
@@ -4676,7 +4676,6 @@ struct wmi_vdev_param_map {u32 meru_vc;u32 rx_decap_type;u32 bw_nss_ratemask; -u32 set_tsf;u32 inc_tsf;u32 dec_tsf; };
Signature · 1 line
2.10.0.297.gf6727b0
PATCH 4/4 mac80211: mesh: decrease max drift
In reply to Thomas PedersenThe old value was 30ms, which means mesh sync will treat any value below as merely TSF drift. This isn't really reasonable (typical drift is < 10us/s) since people probably want to adjust TSF in smaller increments (for ie. beacon collision avoidance) without mesh sync fighting back.
Change max drift adjustment to 0.8ms, so manual TSF adjustments can be made in 1ms increments, with some margin.
--- net/mac80211/mesh_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_sync.c +1 -1
@@ -28,7 +28,7 @@* could be, for instance, in case a neighbor is restarted and its TSF counter * reset. */ -#define TOFFSET_MAXIMUM_ADJUSTMENT 30000/* 30 ms */ +#define TOFFSET_MAXIMUM_ADJUSTMENT 800/* 0.8 ms */ struct sync_method {u8 method;
Signature · 1 line
2.10.0.297.gf6727b0
Quoted 4 lines · Thomas Pedersen
This patchset introduces a new
ieee80211_opoffset_tsf(), which gives the driver a s64 TSF offset for TSF adjustment. This is more accurate than programming absolute TSF since programming delay is avoided.
You were lucky we have patchwork, otherwise I would've missed the mac80211 patches in this series :)
Applied both now - no reason to apply them in the order you sent them.
johannes