net/mac80211/debugfs.c
Source file repositories/reference/linux-study-clean/net/mac80211/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/debugfs.c- Extension
.c- Size
- 18514 bytes
- Lines
- 713
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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
linux/debugfs.hlinux/rtnetlink.hlinux/vmalloc.hieee80211_i.hdriver-ops.hrate.hdebugfs.h
Detected Declarations
function Copyrightfunction aqm_readfunction aqm_writefunction airtime_flags_readfunction airtime_flags_writefunction aql_pending_readfunction aql_txq_limit_readfunction aql_txq_limit_writefunction list_for_each_entryfunction aql_enable_readfunction aql_enable_writefunction force_tx_status_readfunction force_tx_status_writefunction reset_writefunction hwflags_readfunction hwflags_writefunction misc_readfunction queues_readfunction format_devstat_counterfunction debugfs_hw_add
Annotated Snippet
static const struct file_operations hwflags_ops = {
.open = simple_open,
.read = hwflags_read,
.write = hwflags_write,
};
static ssize_t misc_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ieee80211_local *local = file->private_data;
/* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
char *buf;
char *pos, *end;
ssize_t rv;
int i;
int ln;
buf = kzalloc(bufsz, GFP_KERNEL);
if (!buf)
return -ENOMEM;
pos = buf;
end = buf + bufsz - 1;
pos += scnprintf(pos, end - pos, "pending:\n");
for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
ln = skb_queue_len(&local->pending[i]);
pos += scnprintf(pos, end - pos, "[%i] %d\n",
i, ln);
}
rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
kfree(buf);
return rv;
}
static ssize_t queues_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ieee80211_local *local = file->private_data;
unsigned long flags;
char buf[IEEE80211_MAX_QUEUES * 20];
int q, res = 0;
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
for (q = 0; q < local->hw.queues; q++)
res += sprintf(buf + res, "%02d: %#.8lx/%d\n", q,
local->queue_stop_reasons[q],
skb_queue_len(&local->pending[q]));
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
return simple_read_from_buffer(user_buf, count, ppos, buf, res);
}
DEBUGFS_READONLY_FILE_OPS(queues);
DEBUGFS_READONLY_FILE_OPS(misc);
/* statistics stuff */
static ssize_t format_devstat_counter(struct ieee80211_local *local,
char __user *userbuf,
size_t count, loff_t *ppos,
int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf,
int buflen))
{
struct ieee80211_low_level_stats stats;
char buf[20];
int res;
wiphy_lock(local->hw.wiphy);
res = drv_get_stats(local, &stats);
wiphy_unlock(local->hw.wiphy);
if (res)
return res;
res = printvalue(&stats, buf, sizeof(buf));
return simple_read_from_buffer(userbuf, count, ppos, buf, res);
}
#define DEBUGFS_DEVSTATS_FILE(name) \
static int print_devstats_##name(struct ieee80211_low_level_stats *stats,\
char *buf, int buflen) \
{ \
return scnprintf(buf, buflen, "%u\n", stats->name); \
} \
static ssize_t stats_ ##name## _read(struct file *file, \
char __user *userbuf, \
size_t count, loff_t *ppos) \
{ \
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/rtnetlink.h`, `linux/vmalloc.h`, `ieee80211_i.h`, `driver-ops.h`, `rate.h`, `debugfs.h`.
- Detected declarations: `function Copyright`, `function aqm_read`, `function aqm_write`, `function airtime_flags_read`, `function airtime_flags_write`, `function aql_pending_read`, `function aql_txq_limit_read`, `function aql_txq_limit_write`, `function list_for_each_entry`, `function aql_enable_read`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.