net/mac802154/iface.c
Source file repositories/reference/linux-study-clean/net/mac802154/iface.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac802154/iface.c- Extension
.c- Size
- 19759 bytes
- Lines
- 747
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/module.hlinux/if_arp.hlinux/ieee802154.hnet/nl802154.hnet/mac802154.hnet/ieee802154_netdev.hnet/cfg802154.hieee802154_i.hdriver-ops.h
Detected Declarations
function mac802154_wpan_update_llsecfunction mac802154_wpan_ioctlfunction mac802154_wpan_mac_addrfunction ieee802154_setup_hwfunction mac802154_slave_openfunction ieee802154_check_mac_settingsfunction ieee802154_check_concurrent_ifacefunction mac802154_wpan_openfunction mac802154_slave_closefunction mac802154_set_header_securityfunction ieee802154_header_createfunction mac802154_header_createfunction mac802154_header_parsefunction mac802154_wpan_freefunction ieee802154_if_setupfunction ieee802154_setup_sdatafunction ieee802154_if_addfunction ieee802154_if_removefunction ieee802154_remove_interfacesfunction netdev_notifyfunction ieee802154_iface_initfunction ieee802154_iface_exit
Annotated Snippet
static const struct net_device_ops mac802154_wpan_ops = {
.ndo_open = mac802154_wpan_open,
.ndo_stop = mac802154_slave_close,
.ndo_start_xmit = ieee802154_subif_start_xmit,
.ndo_do_ioctl = mac802154_wpan_ioctl,
.ndo_set_mac_address = mac802154_wpan_mac_addr,
};
static const struct net_device_ops mac802154_monitor_ops = {
.ndo_open = mac802154_wpan_open,
.ndo_stop = mac802154_slave_close,
.ndo_start_xmit = ieee802154_monitor_start_xmit,
};
static void mac802154_wpan_free(struct net_device *dev)
{
struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
mac802154_llsec_destroy(&sdata->sec);
}
static void ieee802154_if_setup(struct net_device *dev)
{
dev->addr_len = IEEE802154_EXTENDED_ADDR_LEN;
memset(dev->broadcast, 0xff, IEEE802154_EXTENDED_ADDR_LEN);
/* Let hard_header_len set to IEEE802154_MIN_HEADER_LEN. AF_PACKET
* will not send frames without any payload, but ack frames
* has no payload, so substract one that we can send a 3 bytes
* frame. The xmit callback assumes at least a hard header where two
* bytes fc and sequence field are set.
*/
dev->hard_header_len = IEEE802154_MIN_HEADER_LEN - 1;
/* The auth_tag header is for security and places in private payload
* room of mac frame which stucks between payload and FCS field.
*/
dev->needed_tailroom = IEEE802154_MAX_AUTH_TAG_LEN +
IEEE802154_FCS_LEN;
/* The mtu size is the payload without mac header in this case.
* We have a dynamic length header with a minimum header length
* which is hard_header_len. In this case we let mtu to the size
* of maximum payload which is IEEE802154_MTU - IEEE802154_FCS_LEN -
* hard_header_len. The FCS which is set by hardware or ndo_start_xmit
* and the minimum mac header which can be evaluated inside driver
* layer. The rest of mac header will be part of payload if greater
* than hard_header_len.
*/
dev->mtu = IEEE802154_MTU - IEEE802154_FCS_LEN -
dev->hard_header_len;
dev->tx_queue_len = 300;
dev->flags = IFF_NOARP | IFF_BROADCAST;
}
static int
ieee802154_setup_sdata(struct ieee802154_sub_if_data *sdata,
enum nl802154_iftype type)
{
struct wpan_dev *wpan_dev = &sdata->wpan_dev;
int ret;
u8 tmp;
/* set some type-dependent values */
sdata->wpan_dev.iftype = type;
get_random_bytes(&tmp, sizeof(tmp));
atomic_set(&wpan_dev->bsn, tmp);
get_random_bytes(&tmp, sizeof(tmp));
atomic_set(&wpan_dev->dsn, tmp);
/* defaults per 802.15.4-2011 */
wpan_dev->min_be = 3;
wpan_dev->max_be = 5;
wpan_dev->csma_retries = 4;
wpan_dev->frame_retries = 3;
wpan_dev->pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
switch (type) {
case NL802154_IFTYPE_COORD:
case NL802154_IFTYPE_NODE:
ieee802154_be64_to_le64(&wpan_dev->extended_addr,
sdata->dev->dev_addr);
sdata->dev->header_ops = &mac802154_header_ops;
sdata->dev->needs_free_netdev = true;
sdata->dev->priv_destructor = mac802154_wpan_free;
sdata->dev->netdev_ops = &mac802154_wpan_ops;
sdata->dev->ml_priv = &mac802154_mlme_wpan;
sdata->iface_default_filtering = IEEE802154_FILTERING_4_FRAME_FIELDS;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/module.h`, `linux/if_arp.h`, `linux/ieee802154.h`, `net/nl802154.h`, `net/mac802154.h`, `net/ieee802154_netdev.h`, `net/cfg802154.h`.
- Detected declarations: `function mac802154_wpan_update_llsec`, `function mac802154_wpan_ioctl`, `function mac802154_wpan_mac_addr`, `function ieee802154_setup_hw`, `function mac802154_slave_open`, `function ieee802154_check_mac_settings`, `function ieee802154_check_concurrent_iface`, `function mac802154_wpan_open`, `function mac802154_slave_close`, `function mac802154_set_header_security`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.