net/mac80211/mesh_sync.c
Source file repositories/reference/linux-study-clean/net/mac80211/mesh_sync.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/mesh_sync.c- Extension
.c- Size
- 6585 bytes
- Lines
- 216
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ieee80211_i.hmesh.hdriver-ops.h
Detected Declarations
struct sync_methodfunction mesh_peer_tbtt_adjustingfunction mesh_sync_adjust_tsffunction mesh_sync_offset_rx_bcn_prespfunction mesh_sync_offset_adjust_tsf
Annotated Snippet
struct sync_method {
u8 method;
struct ieee80211_mesh_sync_ops ops;
};
/**
* mesh_peer_tbtt_adjusting - check if an mp is currently adjusting its TBTT
*
* @cfg: mesh config element from the mesh peer (or %NULL)
*
* Returns: If the mesh peer is currently adjusting its TBTT
*/
static bool mesh_peer_tbtt_adjusting(const struct ieee80211_meshconf_ie *cfg)
{
return cfg &&
(cfg->meshconf_cap & IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING);
}
void mesh_sync_adjust_tsf(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
/* sdata->vif.bss_conf.beacon_int in 1024us units, 0.04% */
u64 beacon_int_fraction = sdata->vif.bss_conf.beacon_int * 1024 / 2500;
u64 tsf;
u64 tsfdelta;
spin_lock_bh(&ifmsh->sync_offset_lock);
if (ifmsh->sync_offset_clockdrift_max < beacon_int_fraction) {
msync_dbg(sdata, "TSF : max clockdrift=%lld; adjusting\n",
(long long) ifmsh->sync_offset_clockdrift_max);
tsfdelta = -ifmsh->sync_offset_clockdrift_max;
ifmsh->sync_offset_clockdrift_max = 0;
} else {
msync_dbg(sdata, "TSF : max clockdrift=%lld; adjusting by %llu\n",
(long long) ifmsh->sync_offset_clockdrift_max,
(unsigned long long) beacon_int_fraction);
tsfdelta = -beacon_int_fraction;
ifmsh->sync_offset_clockdrift_max -= beacon_int_fraction;
}
spin_unlock_bh(&ifmsh->sync_offset_lock);
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, u16 stype,
struct ieee80211_mgmt *mgmt, unsigned int len,
const struct ieee80211_meshconf_ie *mesh_cfg,
struct ieee80211_rx_status *rx_status)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
struct ieee80211_local *local = sdata->local;
struct sta_info *sta;
u64 t_t, t_r;
WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
/* standard mentions only beacons */
if (stype != IEEE80211_STYPE_BEACON)
return;
/*
* Get time when timestamp field was received. If we don't
* have rx timestamps, then use current tsf as an approximation.
* drv_get_tsf() must be called before entering the rcu-read
* section.
*/
if (ieee80211_have_rx_timestamp(rx_status))
t_r = ieee80211_calculate_rx_timestamp(&local->hw, rx_status,
len + FCS_LEN, 24);
else
t_r = drv_get_tsf(local, sdata);
rcu_read_lock();
sta = sta_info_get(sdata, mgmt->sa);
if (!sta)
goto no_sync;
/* check offset sync conditions (13.13.2.2.1)
*
* TODO also sync to
* dot11MeshNbrOffsetMaxNeighbor non-peer non-MBSS neighbors
*/
Annotation
- Immediate include surface: `ieee80211_i.h`, `mesh.h`, `driver-ops.h`.
- Detected declarations: `struct sync_method`, `function mesh_peer_tbtt_adjusting`, `function mesh_sync_adjust_tsf`, `function mesh_sync_offset_rx_bcn_presp`, `function mesh_sync_offset_adjust_tsf`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.