net/mac802154/tx.c
Source file repositories/reference/linux-study-clean/net/mac802154/tx.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac802154/tx.c- Extension
.c- Size
- 5830 bytes
- Lines
- 241
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/netdevice.hlinux/if_arp.hlinux/crc-ccitt.hlinux/unaligned.hnet/rtnetlink.hnet/ieee802154_netdev.hnet/mac802154.hnet/cfg802154.hieee802154_i.hdriver-ops.h
Detected Declarations
function ieee802154_xmit_sync_workerfunction ieee802154_txfunction ieee802154_sync_queuefunction ieee802154_sync_and_hold_queuefunction ieee802154_mlme_op_prefunction ieee802154_mlme_tx_lockedfunction ieee802154_mlme_txfunction ieee802154_mlme_op_postfunction ieee802154_mlme_tx_one_lockedfunction ieee802154_queue_is_stoppedfunction ieee802154_hot_txfunction ieee802154_monitor_start_xmitfunction ieee802154_subif_start_xmit
Annotated Snippet
if (unlikely(skb_tailroom(skb) < IEEE802154_FCS_LEN)) {
nskb = skb_copy_expand(skb, 0, IEEE802154_FCS_LEN,
GFP_ATOMIC);
if (likely(nskb)) {
consume_skb(skb);
skb = nskb;
} else {
goto err_free_skb;
}
}
crc = crc_ccitt(0, skb->data, skb->len);
put_unaligned_le16(crc, skb_put(skb, 2));
}
/* Stop the netif queue on each sub_if_data object. */
ieee802154_hold_queue(local);
atomic_inc(&local->phy->ongoing_txs);
/* Drivers should preferably implement the async callback. In some rare
* cases they only provide a sync callback which we will use as a
* fallback.
*/
if (local->ops->xmit_async) {
unsigned int len = skb->len;
ret = drv_xmit_async(local, skb);
if (ret)
goto err_wake_netif_queue;
DEV_STATS_INC(dev, tx_packets);
DEV_STATS_ADD(dev, tx_bytes, len);
} else {
local->tx_skb = skb;
queue_work(local->workqueue, &local->sync_tx_work);
}
return NETDEV_TX_OK;
err_wake_netif_queue:
ieee802154_release_queue(local);
if (atomic_dec_and_test(&local->phy->ongoing_txs))
wake_up(&local->phy->sync_txq);
err_free_skb:
kfree_skb(skb);
return NETDEV_TX_OK;
}
static int ieee802154_sync_queue(struct ieee802154_local *local)
{
int ret;
ieee802154_hold_queue(local);
ieee802154_disable_queue(local);
wait_event(local->phy->sync_txq, !atomic_read(&local->phy->ongoing_txs));
ret = local->tx_result;
ieee802154_release_queue(local);
return ret;
}
int ieee802154_sync_and_hold_queue(struct ieee802154_local *local)
{
int ret;
ieee802154_hold_queue(local);
ret = ieee802154_sync_queue(local);
set_bit(WPAN_PHY_FLAG_STATE_QUEUE_STOPPED, &local->phy->flags);
return ret;
}
int ieee802154_mlme_op_pre(struct ieee802154_local *local)
{
return ieee802154_sync_and_hold_queue(local);
}
int ieee802154_mlme_tx_locked(struct ieee802154_local *local,
struct ieee802154_sub_if_data *sdata,
struct sk_buff *skb)
{
/* Avoid possible calls to ->ndo_stop() when we asynchronously perform
* MLME transmissions.
*/
ASSERT_RTNL();
/* Ensure the device was not stopped, otherwise error out */
if (!local->open_count)
return -ENETDOWN;
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/if_arp.h`, `linux/crc-ccitt.h`, `linux/unaligned.h`, `net/rtnetlink.h`, `net/ieee802154_netdev.h`, `net/mac802154.h`, `net/cfg802154.h`.
- Detected declarations: `function ieee802154_xmit_sync_worker`, `function ieee802154_tx`, `function ieee802154_sync_queue`, `function ieee802154_sync_and_hold_queue`, `function ieee802154_mlme_op_pre`, `function ieee802154_mlme_tx_locked`, `function ieee802154_mlme_tx`, `function ieee802154_mlme_op_post`, `function ieee802154_mlme_tx_one_locked`, `function ieee802154_queue_is_stopped`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.