Lines Matching +full:timing +full:- +full:adjustment
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2011-2012, Pavel Zubarev <pavel.zubarev@gmail.com>
4 * Copyright 2011-2012, Marco Porsch <marco.porsch@s2005.tu-chemnitz.de>
5 * Copyright 2011-2012, cozybit Inc.
10 #include "driver-ops.h"
13 * which we do no TSF adjustment.
19 * introduced by TSF adjustment latency.
36 * mesh_peer_tbtt_adjusting - check if an mp is currently adjusting its TBTT
42 return (ie->mesh_config->meshconf_cap & in mesh_peer_tbtt_adjusting()
48 struct ieee80211_local *local = sdata->local; in mesh_sync_adjust_tsf()
49 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in mesh_sync_adjust_tsf()
50 /* sdata->vif.bss_conf.beacon_int in 1024us units, 0.04% */ in mesh_sync_adjust_tsf()
51 u64 beacon_int_fraction = sdata->vif.bss_conf.beacon_int * 1024 / 2500; in mesh_sync_adjust_tsf()
55 spin_lock_bh(&ifmsh->sync_offset_lock); in mesh_sync_adjust_tsf()
56 if (ifmsh->sync_offset_clockdrift_max < beacon_int_fraction) { in mesh_sync_adjust_tsf()
58 (long long) ifmsh->sync_offset_clockdrift_max); in mesh_sync_adjust_tsf()
59 tsfdelta = -ifmsh->sync_offset_clockdrift_max; in mesh_sync_adjust_tsf()
60 ifmsh->sync_offset_clockdrift_max = 0; in mesh_sync_adjust_tsf()
63 (long long) ifmsh->sync_offset_clockdrift_max, in mesh_sync_adjust_tsf()
65 tsfdelta = -beacon_int_fraction; in mesh_sync_adjust_tsf()
66 ifmsh->sync_offset_clockdrift_max -= beacon_int_fraction; in mesh_sync_adjust_tsf()
68 spin_unlock_bh(&ifmsh->sync_offset_lock); in mesh_sync_adjust_tsf()
70 if (local->ops->offset_tsf) { in mesh_sync_adjust_tsf()
74 if (tsf != -1ULL) in mesh_sync_adjust_tsf()
85 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in mesh_sync_offset_rx_bcn_presp()
86 struct ieee80211_local *local = sdata->local; in mesh_sync_offset_rx_bcn_presp()
90 WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); in mesh_sync_offset_rx_bcn_presp()
99 * drv_get_tsf() must be called before entering the rcu-read in mesh_sync_offset_rx_bcn_presp()
105 elems->total_len + in mesh_sync_offset_rx_bcn_presp()
112 sta = sta_info_get(sdata, mgmt->sa); in mesh_sync_offset_rx_bcn_presp()
119 * dot11MeshNbrOffsetMaxNeighbor non-peer non-MBSS neighbors in mesh_sync_offset_rx_bcn_presp()
122 if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) { in mesh_sync_offset_rx_bcn_presp()
124 sta->sta.addr); in mesh_sync_offset_rx_bcn_presp()
128 /* Timing offset calculation (see 13.13.2.2.2) */ in mesh_sync_offset_rx_bcn_presp()
129 t_t = le64_to_cpu(mgmt->u.beacon.timestamp); in mesh_sync_offset_rx_bcn_presp()
130 sta->mesh->t_offset = t_t - t_r; in mesh_sync_offset_rx_bcn_presp()
133 s64 t_clockdrift = sta->mesh->t_offset_setpoint - sta->mesh->t_offset; in mesh_sync_offset_rx_bcn_presp()
136 sta->sta.addr, (long long) sta->mesh->t_offset, in mesh_sync_offset_rx_bcn_presp()
137 (long long) sta->mesh->t_offset_setpoint, in mesh_sync_offset_rx_bcn_presp()
141 t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) { in mesh_sync_offset_rx_bcn_presp()
144 sta->sta.addr, in mesh_sync_offset_rx_bcn_presp()
150 spin_lock_bh(&ifmsh->sync_offset_lock); in mesh_sync_offset_rx_bcn_presp()
151 if (t_clockdrift > ifmsh->sync_offset_clockdrift_max) in mesh_sync_offset_rx_bcn_presp()
152 ifmsh->sync_offset_clockdrift_max = t_clockdrift; in mesh_sync_offset_rx_bcn_presp()
153 spin_unlock_bh(&ifmsh->sync_offset_lock); in mesh_sync_offset_rx_bcn_presp()
155 sta->mesh->t_offset_setpoint = sta->mesh->t_offset - TOFFSET_SET_MARGIN; in mesh_sync_offset_rx_bcn_presp()
159 sta->sta.addr, in mesh_sync_offset_rx_bcn_presp()
160 (long long) sta->mesh->t_offset); in mesh_sync_offset_rx_bcn_presp()
170 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; in mesh_sync_offset_adjust_tsf()
172 WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); in mesh_sync_offset_adjust_tsf()
175 spin_lock_bh(&ifmsh->sync_offset_lock); in mesh_sync_offset_adjust_tsf()
177 if (ifmsh->sync_offset_clockdrift_max > TOFFSET_MINIMUM_ADJUSTMENT) { in mesh_sync_offset_adjust_tsf()
181 * the tsf adjustment to the mesh tasklet in mesh_sync_offset_adjust_tsf()
184 "TSF : kicking off TSF adjustment with clockdrift_max=%lld\n", in mesh_sync_offset_adjust_tsf()
185 ifmsh->sync_offset_clockdrift_max); in mesh_sync_offset_adjust_tsf()
186 set_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags); in mesh_sync_offset_adjust_tsf()
190 (long long)ifmsh->sync_offset_clockdrift_max); in mesh_sync_offset_adjust_tsf()
191 ifmsh->sync_offset_clockdrift_max = 0; in mesh_sync_offset_adjust_tsf()
193 spin_unlock_bh(&ifmsh->sync_offset_lock); in mesh_sync_offset_adjust_tsf()