drivers/net/wireless/virtual/mac80211_hwsim_nan.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/virtual/mac80211_hwsim_nan.c- Extension
.c- Size
- 38564 bytes
- Lines
- 1347
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cfg80211.hmac80211_hwsim_i.h
Detected Declarations
struct hwsim_nan_sta_iter_ctxstruct hwsim_nan_mcast_data_iter_ctxfunction hwsim_nan_get_timer_tsffunction hwsim_nan_slot_from_tsffunction hwsim_nan_encode_master_rankfunction hwsim_nan_get_master_rankfunction mac80211_hwsim_nan_is_dw_slotfunction hwsim_nan_rx_chandef_compatiblefunction hwsim_nan_peer_present_in_dwfunction hwsim_nan_peer_present_in_fawfunction scoped_guardfunction mac80211_hwsim_nan_schedule_slotfunction mac80211_hwsim_nan_rxfunction for_each_nan_attrfunction ieee80211_tu_to_usecfunction scoped_guardfunction mac80211_hwsim_nan_exec_state_transitionsfunction mac80211_hwsim_nan_tx_beaconfunction mac80211_hwsim_nan_slot_timerfunction scoped_guardfunction mac80211_hwsim_nan_discovery_beacon_timerfunction scoped_guardfunction mac80211_hwsim_nan_startfunction scoped_guardfunction mac80211_hwsim_nan_stopfunction mac80211_hwsim_nan_change_configfunction hwsim_nan_can_sta_transmitfunction mac80211_hwsim_nan_resume_txqsfunction scoped_guardfunction hwsim_nan_wake_sta_iterfunction mac80211_hwsim_nan_resume_txqs_timerfunction hwsim_nan_can_mcast_sta_transmitfunction mac80211_hwsim_nan_mcast_data_transmittingfunction mac80211_hwsim_nan_txq_transmittingfunction mac80211_hwsim_nan_get_tx_chandeffunction mac80211_hwsim_nan_receivefunction mac80211_hwsim_nan_local_sched_changedfunction mac80211_hwsim_nan_peer_sched_changed
Annotated Snippet
struct hwsim_nan_sta_iter_ctx {
struct ieee80211_hw *hw;
bool can_tx;
};
struct hwsim_nan_mcast_data_iter_ctx {
struct ieee80211_hw *hw;
struct ieee80211_vif *vif;
size_t n_vif_sta;
size_t n_sta_can_tx;
};
static void mac80211_hwsim_nan_resume_txqs(struct mac80211_hwsim_data *data);
static u64 hwsim_nan_get_timer_tsf(struct mac80211_hwsim_data *data)
{
ktime_t expires = hrtimer_get_expires(&data->nan.slot_timer);
return mac80211_hwsim_boottime_to_tsf(data, expires);
}
static u8 hwsim_nan_slot_from_tsf(u64 tsf)
{
return (tsf & DWST_TSF_MASK) / ieee80211_tu_to_usec(SLOT_TU);
}
static u64 hwsim_nan_encode_master_rank(u8 master_pref, u8 random_factor,
const u8 *addr)
{
return ((u64)master_pref << 56) +
((u64)random_factor << 48) +
((u64)addr[5] << 40) +
((u64)addr[4] << 32) +
((u64)addr[3] << 24) +
((u64)addr[2] << 16) +
((u64)addr[1] << 8) +
((u64)addr[0] << 0);
}
static u64 hwsim_nan_get_master_rank(struct mac80211_hwsim_data *data)
{
u8 master_pref = 0;
u8 random_factor = 0;
if (data->nan.phase == MAC80211_HWSIM_NAN_PHASE_UP) {
master_pref = data->nan.master_pref;
random_factor = data->nan.random_factor;
}
return hwsim_nan_encode_master_rank(master_pref, random_factor,
data->nan.device_vif->addr);
}
static bool mac80211_hwsim_nan_is_dw_slot(struct mac80211_hwsim_data *data,
u8 slot)
{
return slot == SLOT_24GHZ_DW ||
(slot == SLOT_5GHZ_DW &&
(data->nan.bands & BIT(NL80211_BAND_5GHZ)));
}
static bool
hwsim_nan_rx_chandef_compatible(struct mac80211_hwsim_data *data, u8 slot,
struct ieee80211_channel *rx_chan, u8 rx_bw)
{
static const int bw_to_mhz[] = {
[RATE_INFO_BW_20] = 20, [RATE_INFO_BW_40] = 40,
[RATE_INFO_BW_80] = 80, [RATE_INFO_BW_160] = 160,
};
struct cfg80211_chan_def sched_chandef;
int rx_mhz, sched_mhz;
scoped_guard(spinlock_bh, &data->nan.state_lock)
sched_chandef = data->nan.local_sched[slot];
if (!sched_chandef.chan ||
sched_chandef.chan->center_freq != rx_chan->center_freq)
return false;
if (rx_bw >= ARRAY_SIZE(bw_to_mhz) || !bw_to_mhz[rx_bw])
return false;
rx_mhz = bw_to_mhz[rx_bw];
sched_mhz = cfg80211_chandef_get_width(&sched_chandef);
/* Accept RX at narrower or equal bandwidth */
return rx_mhz <= sched_mhz;
}
static bool hwsim_nan_peer_present_in_dw(struct hwsim_sta_priv *sp, u64 tsf)
Annotation
- Immediate include surface: `net/cfg80211.h`, `mac80211_hwsim_i.h`.
- Detected declarations: `struct hwsim_nan_sta_iter_ctx`, `struct hwsim_nan_mcast_data_iter_ctx`, `function hwsim_nan_get_timer_tsf`, `function hwsim_nan_slot_from_tsf`, `function hwsim_nan_encode_master_rank`, `function hwsim_nan_get_master_rank`, `function mac80211_hwsim_nan_is_dw_slot`, `function hwsim_nan_rx_chandef_compatible`, `function hwsim_nan_peer_present_in_dw`, `function hwsim_nan_peer_present_in_faw`.
- Atlas domain: Driver Families / drivers/net.
- 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.