net/mac802154/rx.c
Source file repositories/reference/linux-study-clean/net/mac802154/rx.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac802154/rx.c- Extension
.c- Size
- 11488 bytes
- Lines
- 451
- 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
linux/kernel.hlinux/module.hlinux/netdevice.hlinux/crc-ccitt.hlinux/unaligned.hnet/mac802154.hnet/ieee802154_netdev.hnet/nl802154.hieee802154_i.h
Detected Declarations
function Copyrightfunction mac802154_rx_beacon_workerfunction mac802154_should_answer_beacon_reqfunction mac802154_rx_mac_cmd_workerfunction ieee802154_subif_framefunction ieee802154_print_addrfunction ieee802154_parse_frame_startfunction __ieee802154_rx_handle_packetfunction list_for_each_entry_rcufunction ieee802154_monitors_rxfunction list_for_each_entry_rcufunction ieee802154_rxfunction ieee802154_rx_irqsafeexport ieee802154_rx_irqsafe
Annotated Snippet
if (mac_cb(skb)->type != IEEE802154_FC_TYPE_BEACON) {
dev_dbg(&sdata->dev->dev,
"drop non-beacon frame (0x%x) during scan\n",
mac_cb(skb)->type);
goto fail;
}
}
switch (mac_cb(skb)->dest.mode) {
case IEEE802154_ADDR_NONE:
if (hdr->source.mode == IEEE802154_ADDR_NONE)
/* ACK comes with both addresses empty */
skb->pkt_type = PACKET_HOST;
else if (!wpan_dev->parent)
/* No dest means PAN coordinator is the recipient */
skb->pkt_type = PACKET_HOST;
else
/* We are not the PAN coordinator, just relaying */
skb->pkt_type = PACKET_OTHERHOST;
break;
case IEEE802154_ADDR_LONG:
if (mac_cb(skb)->dest.pan_id != span &&
mac_cb(skb)->dest.pan_id != cpu_to_le16(IEEE802154_PANID_BROADCAST))
skb->pkt_type = PACKET_OTHERHOST;
else if (mac_cb(skb)->dest.extended_addr == wpan_dev->extended_addr)
skb->pkt_type = PACKET_HOST;
else
skb->pkt_type = PACKET_OTHERHOST;
break;
case IEEE802154_ADDR_SHORT:
if (mac_cb(skb)->dest.pan_id != span &&
mac_cb(skb)->dest.pan_id != cpu_to_le16(IEEE802154_PANID_BROADCAST))
skb->pkt_type = PACKET_OTHERHOST;
else if (mac_cb(skb)->dest.short_addr == sshort)
skb->pkt_type = PACKET_HOST;
else if (mac_cb(skb)->dest.short_addr ==
cpu_to_le16(IEEE802154_ADDR_BROADCAST))
skb->pkt_type = PACKET_BROADCAST;
else
skb->pkt_type = PACKET_OTHERHOST;
break;
default:
pr_debug("invalid dest mode\n");
goto fail;
}
skb->dev = sdata->dev;
/* TODO this should be moved after netif_receive_skb call, otherwise
* wireshark will show a mac header with security fields and the
* payload is already decrypted.
*/
rc = mac802154_llsec_decrypt(&sdata->sec, skb);
if (rc) {
pr_debug("decryption failed: %i\n", rc);
goto fail;
}
sdata->dev->stats.rx_packets++;
sdata->dev->stats.rx_bytes += skb->len;
switch (mac_cb(skb)->type) {
case IEEE802154_FC_TYPE_BEACON:
dev_dbg(&sdata->dev->dev, "BEACON received\n");
if (!mac802154_is_scanning(sdata->local))
goto fail;
mac_pkt = kzalloc_obj(*mac_pkt, GFP_ATOMIC);
if (!mac_pkt)
goto fail;
mac_pkt->skb = skb_get(skb);
mac_pkt->sdata = sdata;
mac_pkt->page = sdata->local->scan_page;
mac_pkt->channel = sdata->local->scan_channel;
list_add_tail(&mac_pkt->node, &sdata->local->rx_beacon_list);
queue_work(sdata->local->mac_wq, &sdata->local->rx_beacon_work);
return NET_RX_SUCCESS;
case IEEE802154_FC_TYPE_MAC_CMD:
dev_dbg(&sdata->dev->dev, "MAC COMMAND received\n");
mac_pkt = kzalloc_obj(*mac_pkt, GFP_ATOMIC);
if (!mac_pkt)
goto fail;
mac_pkt->skb = skb_get(skb);
mac_pkt->sdata = sdata;
list_add_tail(&mac_pkt->node, &sdata->local->rx_mac_cmd_list);
queue_work(sdata->local->mac_wq, &sdata->local->rx_mac_cmd_work);
return NET_RX_SUCCESS;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/netdevice.h`, `linux/crc-ccitt.h`, `linux/unaligned.h`, `net/mac802154.h`, `net/ieee802154_netdev.h`, `net/nl802154.h`.
- Detected declarations: `function Copyright`, `function mac802154_rx_beacon_worker`, `function mac802154_should_answer_beacon_req`, `function mac802154_rx_mac_cmd_worker`, `function ieee802154_subif_frame`, `function ieee802154_print_addr`, `function ieee802154_parse_frame_start`, `function __ieee802154_rx_handle_packet`, `function list_for_each_entry_rcu`, `function ieee802154_monitors_rx`.
- 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.