net/nfc/nci/data.c
Source file repositories/reference/linux-study-clean/net/nfc/nci/data.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/nci/data.c- Extension
.c- Size
- 7383 bytes
- Lines
- 306
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/interrupt.hlinux/wait.hlinux/bitops.hlinux/skbuff.h../nfc.hnet/nfc/nci.hnet/nfc/nci_core.hlinux/nfc.h
Detected Declarations
function Controllerfunction nci_push_data_hdrfunction nci_conn_max_data_pkt_payload_sizefunction nci_queue_tx_data_fragsfunction nci_send_datafunction nci_add_rx_data_fragfunction nci_rx_data_packetexport nci_conn_max_data_pkt_payload_sizeexport nci_send_data
Annotated Snippet
if (skb_frag == NULL) {
rc = -ENOMEM;
goto free_exit;
}
skb_reserve(skb_frag, NCI_DATA_HDR_SIZE);
/* first, copy the data */
skb_put_data(skb_frag, data, frag_len);
/* second, set the header */
nci_push_data_hdr(ndev, conn_id, skb_frag,
((total_len == frag_len) ?
(NCI_PBF_LAST) : (NCI_PBF_CONT)));
__skb_queue_tail(&frags_q, skb_frag);
data += frag_len;
total_len -= frag_len;
pr_debug("frag_len %d, remaining total_len %d\n",
frag_len, total_len);
}
/* queue all fragments atomically */
spin_lock_irqsave(&ndev->tx_q.lock, flags);
while ((skb_frag = __skb_dequeue(&frags_q)) != NULL)
__skb_queue_tail(&ndev->tx_q, skb_frag);
spin_unlock_irqrestore(&ndev->tx_q.lock, flags);
/* free the original skb */
kfree_skb(skb);
goto exit;
free_exit:
while ((skb_frag = __skb_dequeue(&frags_q)) != NULL)
kfree_skb(skb_frag);
exit:
return rc;
}
/* Send NCI data */
int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb)
{
const struct nci_conn_info *conn_info;
int rc = 0;
pr_debug("conn_id 0x%x, plen %d\n", conn_id, skb->len);
conn_info = nci_get_conn_info_by_conn_id(ndev, conn_id);
if (!conn_info) {
rc = -EPROTO;
goto free_exit;
}
/* check if the packet need to be fragmented */
if (skb->len <= conn_info->max_pkt_payload_len) {
/* no need to fragment packet */
nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST);
skb_queue_tail(&ndev->tx_q, skb);
} else {
/* fragment packet and queue the fragments */
rc = nci_queue_tx_data_frags(ndev, conn_id, skb);
if (rc) {
pr_err("failed to fragment tx data packet\n");
goto free_exit;
}
}
ndev->cur_conn_id = conn_id;
queue_work(ndev->tx_wq, &ndev->tx_work);
goto exit;
free_exit:
kfree_skb(skb);
exit:
return rc;
}
EXPORT_SYMBOL(nci_send_data);
/* ----------------- NCI RX Data ----------------- */
static void nci_add_rx_data_frag(struct nci_dev *ndev,
struct sk_buff *skb,
Annotation
- Immediate include surface: `linux/types.h`, `linux/interrupt.h`, `linux/wait.h`, `linux/bitops.h`, `linux/skbuff.h`, `../nfc.h`, `net/nfc/nci.h`, `net/nfc/nci_core.h`.
- Detected declarations: `function Controller`, `function nci_push_data_hdr`, `function nci_conn_max_data_pkt_payload_size`, `function nci_queue_tx_data_frags`, `function nci_send_data`, `function nci_add_rx_data_frag`, `function nci_rx_data_packet`, `export nci_conn_max_data_pkt_payload_size`, `export nci_send_data`.
- 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.