net/mac80211/util.c
Source file repositories/reference/linux-study-clean/net/mac80211/util.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/util.c- Extension
.c- Size
- 127990 bytes
- Lines
- 4734
- 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.
- 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/mac80211.hlinux/netdevice.hlinux/export.hlinux/types.hlinux/slab.hlinux/skbuff.hlinux/etherdevice.hlinux/if_arp.hlinux/bitmap.hlinux/crc32.hnet/net_namespace.hnet/cfg80211.hnet/rtnetlink.hkunit/visibility.hieee80211_i.hdriver-ops.hrate.hmesh.hwme.hled.hwep.h
Detected Declarations
function ieee80211_tx_set_protectedfunction skb_queue_walkfunction ieee80211_frame_durationfunction bytesfunction ieee80211_generic_frame_durationfunction ieee80211_rts_durationfunction ieee80211_ctstoself_durationfunction wake_tx_push_queuefunction ieee80211_handle_wake_tx_queuefunction __ieee80211_wake_txqsfunction list_for_each_entry_rcufunction __releasesfunction list_for_each_entry_rcufunction ieee80211_wake_txqsfunction __ieee80211_wake_queuefunction ieee80211_wake_queue_by_reasonfunction ieee80211_wake_queuefunction __ieee80211_stop_queuefunction ieee80211_stop_queue_by_reasonfunction ieee80211_stop_queuefunction ieee80211_add_pending_skbfunction ieee80211_add_pending_skbsfunction ieee80211_stop_queues_by_reasonfunction ieee80211_stop_queuesfunction ieee80211_queue_stoppedfunction ieee80211_wake_queues_by_reasonfunction ieee80211_wake_queuesfunction ieee80211_get_vif_queuesfunction __ieee80211_flush_queuesfunction __ieee80211_wake_queuefunction ieee80211_flush_queuesfunction __iterate_interfacesfunction list_for_each_entry_rcufunction ieee80211_iterate_interfacesfunction ieee80211_iterate_active_interfaces_atomicfunction __ieee80211_iterate_interfacesfunction __iterate_stationsfunction list_for_each_entry_rcufunction ieee80211_iterate_stations_atomicfunction __ieee80211_iterate_stationsfunction pathfunction ieee80211_queue_workfunction ieee80211_queue_delayed_workfunction ieee80211_regulatory_limit_wmm_paramsfunction ieee80211_set_wmm_defaultfunction ieee80211_send_authfunction ieee80211_send_deauth_disassocfunction ieee80211_put_s1g_cap
Annotated Snippet
if (ieee80211_is_back_req(fc)) {
switch (type) {
case NL80211_IFTYPE_STATION:
return hdr->addr2;
case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_AP_VLAN:
return hdr->addr1;
default:
break; /* fall through to the return */
}
}
}
return NULL;
}
void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx)
{
struct sk_buff *skb;
struct ieee80211_hdr *hdr;
skb_queue_walk(&tx->skbs, skb) {
hdr = (struct ieee80211_hdr *) skb->data;
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
}
}
int ieee80211_frame_duration(enum nl80211_band band, size_t len,
int rate, int erp, int short_preamble)
{
int dur;
/* calculate duration (in microseconds, rounded up to next higher
* integer if it includes a fractional microsecond) to send frame of
* len bytes (does not include FCS) at the given rate. Duration will
* also include SIFS.
*
* rate is in 100 kbps, so divident is multiplied by 10 in the
* DIV_ROUND_UP() operations.
*/
if (band == NL80211_BAND_5GHZ || erp) {
/*
* OFDM:
*
* N_DBPS = DATARATE x 4
* N_SYM = Ceiling((16+8xLENGTH+6) / N_DBPS)
* (16 = SIGNAL time, 6 = tail bits)
* TXTIME = T_PREAMBLE + T_SIGNAL + T_SYM x N_SYM + Signal Ext
*
* T_SYM = 4 usec
* 802.11a - 18.5.2: aSIFSTime = 16 usec
* 802.11g - 19.8.4: aSIFSTime = 10 usec +
* signal ext = 6 usec
*/
dur = 16; /* SIFS + signal ext */
dur += 16; /* IEEE 802.11-2012 18.3.2.4: T_PREAMBLE = 16 usec */
dur += 4; /* IEEE 802.11-2012 18.3.2.4: T_SIGNAL = 4 usec */
/* rates should already consider the channel bandwidth,
* don't apply divisor again.
*/
dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
4 * rate); /* T_SYM x N_SYM */
} else {
/*
* 802.11b or 802.11g with 802.11b compatibility:
* 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime +
* Ceiling(((LENGTH+PBCC)x8)/DATARATE). PBCC=0.
*
* 802.11 (DS): 15.3.3, 802.11b: 18.3.4
* aSIFSTime = 10 usec
* aPreambleLength = 144 usec or 72 usec with short preamble
* aPLCPHeaderLength = 48 usec or 24 usec with short preamble
*/
dur = 10; /* aSIFSTime = 10 usec */
dur += short_preamble ? (72 + 24) : (144 + 48);
dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate);
}
return dur;
}
/* Exported duration function for driver use */
__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
enum nl80211_band band,
size_t frame_len,
struct ieee80211_rate *rate)
Annotation
- Immediate include surface: `net/mac80211.h`, `linux/netdevice.h`, `linux/export.h`, `linux/types.h`, `linux/slab.h`, `linux/skbuff.h`, `linux/etherdevice.h`, `linux/if_arp.h`.
- Detected declarations: `function ieee80211_tx_set_protected`, `function skb_queue_walk`, `function ieee80211_frame_duration`, `function bytes`, `function ieee80211_generic_frame_duration`, `function ieee80211_rts_duration`, `function ieee80211_ctstoself_duration`, `function wake_tx_push_queue`, `function ieee80211_handle_wake_tx_queue`, `function __ieee80211_wake_txqs`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.