net/mac80211/nan.c
Source file repositories/reference/linux-study-clean/net/mac80211/nan.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/nan.c- Extension
.c- Size
- 23794 bytes
- Lines
- 848
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/mac80211.hieee80211_i.hdriver-ops.hsta_info.h
Detected Declarations
function Copyrightfunction ieee80211_nan_update_channelfunction ieee80211_nan_use_chanctxfunction ieee80211_nan_update_peer_channelsfunction list_for_each_entryfunction ieee80211_nan_remove_channelfunction ieee80211_nan_update_all_ndi_carriersfunction ieee80211_nan_find_free_channelfunction ieee80211_nan_set_local_schedfunction ieee80211_nan_sched_update_donefunction ieee80211_nan_free_peer_schedfunction ieee80211_nan_init_peer_channelfunction ieee80211_nan_init_peer_mapfunction ieee80211_nan_has_common_slotsfunction ieee80211_nan_update_ndi_carrierfunction list_for_each_entryfunction ieee80211_nan_update_peer_ndis_carrierfunction list_for_each_entryfunction ieee80211_nan_set_peer_schedfunction ieee80211_nan_evacuate_channelfunction ieee80211_nan_find_evac_chanfunction ieee80211_nan_try_evacuateexport ieee80211_nan_sched_update_doneexport ieee80211_nan_try_evacuate
Annotated Snippet
if (peer_sched->channels[i].chanctx_conf == removed_conf) {
updated = true;
continue;
}
if (write_idx != i) {
/* Update map pointers before moving */
for (int m = 0; m < CFG80211_NAN_MAX_PEER_MAPS; m++) {
struct ieee80211_nan_peer_map *map =
&peer_sched->maps[m];
if (map->map_id == CFG80211_NAN_INVALID_MAP_ID)
continue;
for (int s = 0; s < ARRAY_SIZE(map->slots); s++)
if (map->slots[s] == &peer_sched->channels[i])
map->slots[s] = &peer_sched->channels[write_idx];
}
peer_sched->channels[write_idx] = peer_sched->channels[i];
}
write_idx++;
}
/* Clear any remaining entries at the end */
for (int i = write_idx; i < peer_sched->n_channels; i++)
memset(&peer_sched->channels[i], 0, sizeof(peer_sched->channels[i]));
peer_sched->n_channels = write_idx;
if (updated)
drv_nan_peer_sched_changed(local, sdata, sta);
}
}
static void
ieee80211_nan_remove_channel(struct ieee80211_sub_if_data *sdata,
struct ieee80211_nan_channel *nan_channel)
{
struct ieee80211_chanctx_conf *conf;
struct ieee80211_chanctx *ctx;
struct ieee80211_nan_sched_cfg *sched_cfg = &sdata->vif.cfg.nan_sched;
if (WARN_ON(!nan_channel))
return;
lockdep_assert_wiphy(sdata->local->hw.wiphy);
if (!nan_channel->chanreq.oper.chan)
return;
for (int slot = 0; slot < ARRAY_SIZE(sched_cfg->schedule); slot++)
if (sched_cfg->schedule[slot] == nan_channel)
sched_cfg->schedule[slot] = NULL;
conf = nan_channel->chanctx_conf;
/* If any peer nan schedule uses this chanctx, update them */
if (conf)
ieee80211_nan_update_peer_channels(sdata, conf);
memset(nan_channel, 0, sizeof(*nan_channel));
/* Update the driver before (possibly) releasing the channel context */
drv_vif_cfg_changed(sdata->local, sdata, BSS_CHANGED_NAN_LOCAL_SCHED);
/* Channel might not have a chanctx if it was ULWed */
if (!conf)
return;
ctx = container_of(conf, struct ieee80211_chanctx, conf);
if (ieee80211_chanctx_num_assigned(sdata->local, ctx) > 0) {
ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
ieee80211_recalc_smps_chanctx(sdata->local, ctx);
ieee80211_recalc_chanctx_min_def(sdata->local, ctx);
}
if (ieee80211_chanctx_refcount(sdata->local, ctx) == 0)
ieee80211_free_chanctx(sdata->local, ctx, false);
}
static void
ieee80211_nan_update_all_ndi_carriers(struct ieee80211_local *local)
{
struct ieee80211_sub_if_data *sdata;
lockdep_assert_wiphy(local->hw.wiphy);
/* Iterate all interfaces and update carrier for NDI interfaces */
Annotation
- Immediate include surface: `net/mac80211.h`, `ieee80211_i.h`, `driver-ops.h`, `sta_info.h`.
- Detected declarations: `function Copyright`, `function ieee80211_nan_update_channel`, `function ieee80211_nan_use_chanctx`, `function ieee80211_nan_update_peer_channels`, `function list_for_each_entry`, `function ieee80211_nan_remove_channel`, `function ieee80211_nan_update_all_ndi_carriers`, `function ieee80211_nan_find_free_channel`, `function ieee80211_nan_set_local_sched`, `function ieee80211_nan_sched_update_done`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.