net/ieee802154/nl802154.c
Source file repositories/reference/linux-study-clean/net/ieee802154/nl802154.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/nl802154.c- Extension
.c- Size
- 85901 bytes
- Lines
- 3109
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/rtnetlink.hnet/cfg802154.hnet/genetlink.hnet/mac802154.hnet/netlink.hnet/nl802154.hnet/sock.hnl802154.hrdev-ops.hcore.hnet/ieee802154_netdev.h
Detected Declarations
struct nl802154_dump_wpan_phy_stateenum nl802154_multicast_groupsfunction __cfg802154_wpan_dev_from_attrsfunction list_for_each_entryfunction list_for_each_entryfunction __cfg802154_rdev_from_attrsfunction IS_ERRfunction nl802154_prepare_wpan_dev_dumpfunction list_for_each_entryfunction nl802154_finish_wpan_dev_dumpfunction nl802154_put_flagsfunction nl802154_send_wpan_phy_channelsfunction nl802154_put_capabilitiesfunction nl802154_send_wpan_phyfunction nl802154_dump_wpan_phy_parsefunction nl802154_dump_wpan_phyfunction list_for_each_entryfunction nl802154_dump_wpan_phy_donefunction nl802154_get_wpan_phyfunction wpan_dev_idfunction ieee802154_llsec_send_key_idfunction nl802154_get_llsec_paramsfunction nl802154_send_ifacefunction nl802154_dump_interfacefunction list_for_each_entryfunction nl802154_get_interfacefunction nl802154_new_interfacefunction nl802154_del_interfacefunction nl802154_set_channelfunction nl802154_set_cca_modefunction nl802154_set_cca_ed_levelfunction nl802154_set_tx_powerfunction nl802154_set_pan_idfunction nl802154_set_short_addrfunction nl802154_set_backoff_exponentfunction nl802154_set_max_csma_backoffsfunction nl802154_set_max_frame_retriesfunction nl802154_set_lbt_modefunction nl802154_set_ackreq_defaultfunction nl802154_wpan_phy_netnsfunction nl802154_prep_scan_event_msgfunction nl802154_scan_eventfunction nl802154_trigger_scanfunction nl802154_prep_scan_msgfunction nl802154_send_scan_msgfunction nl802154_scan_startedfunction nl802154_scan_donefunction nl802154_abort_scan
Annotated Snippet
struct nl802154_dump_wpan_phy_state {
s64 filter_wpan_phy;
long start;
};
static int nl802154_dump_wpan_phy_parse(struct sk_buff *skb,
struct netlink_callback *cb,
struct nl802154_dump_wpan_phy_state *state)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct nlattr **tb = info->info.attrs;
if (tb[NL802154_ATTR_WPAN_PHY])
state->filter_wpan_phy = nla_get_u32(tb[NL802154_ATTR_WPAN_PHY]);
if (tb[NL802154_ATTR_WPAN_DEV])
state->filter_wpan_phy = nla_get_u64(tb[NL802154_ATTR_WPAN_DEV]) >> 32;
if (tb[NL802154_ATTR_IFINDEX]) {
struct net_device *netdev;
struct cfg802154_registered_device *rdev;
int ifidx = nla_get_u32(tb[NL802154_ATTR_IFINDEX]);
netdev = __dev_get_by_index(&init_net, ifidx);
if (!netdev)
return -ENODEV;
if (netdev->ieee802154_ptr) {
rdev = wpan_phy_to_rdev(
netdev->ieee802154_ptr->wpan_phy);
state->filter_wpan_phy = rdev->wpan_phy_idx;
}
}
return 0;
}
static int
nl802154_dump_wpan_phy(struct sk_buff *skb, struct netlink_callback *cb)
{
int idx = 0, ret;
struct nl802154_dump_wpan_phy_state *state = (void *)cb->args[0];
struct cfg802154_registered_device *rdev;
rtnl_lock();
if (!state) {
state = kzalloc_obj(*state);
if (!state) {
rtnl_unlock();
return -ENOMEM;
}
state->filter_wpan_phy = -1;
ret = nl802154_dump_wpan_phy_parse(skb, cb, state);
if (ret) {
kfree(state);
rtnl_unlock();
return ret;
}
cb->args[0] = (long)state;
}
list_for_each_entry(rdev, &cfg802154_rdev_list, list) {
if (!net_eq(wpan_phy_net(&rdev->wpan_phy), sock_net(skb->sk)))
continue;
if (++idx <= state->start)
continue;
if (state->filter_wpan_phy != -1 &&
state->filter_wpan_phy != rdev->wpan_phy_idx)
continue;
/* attempt to fit multiple wpan_phy data chunks into the skb */
ret = nl802154_send_wpan_phy(rdev,
NL802154_CMD_NEW_WPAN_PHY,
skb,
NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI);
if (ret < 0) {
if ((ret == -ENOBUFS || ret == -EMSGSIZE) &&
!skb->len && cb->min_dump_alloc < 4096) {
cb->min_dump_alloc = 4096;
rtnl_unlock();
return 1;
}
idx--;
break;
}
break;
}
rtnl_unlock();
state->start = idx;
return skb->len;
Annotation
- Immediate include surface: `linux/rtnetlink.h`, `net/cfg802154.h`, `net/genetlink.h`, `net/mac802154.h`, `net/netlink.h`, `net/nl802154.h`, `net/sock.h`, `nl802154.h`.
- Detected declarations: `struct nl802154_dump_wpan_phy_state`, `enum nl802154_multicast_groups`, `function __cfg802154_wpan_dev_from_attrs`, `function list_for_each_entry`, `function list_for_each_entry`, `function __cfg802154_rdev_from_attrs`, `function IS_ERR`, `function nl802154_prepare_wpan_dev_dump`, `function list_for_each_entry`, `function nl802154_finish_wpan_dev_dump`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.