net/nfc/hci/hcp.c
Source file repositories/reference/linux-study-clean/net/nfc/hci/hcp.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/hci/hcp.c- Extension
.c- Size
- 3349 bytes
- Lines
- 137
- 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.
- 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/init.hlinux/kernel.hlinux/module.hnet/nfc/hci.hhci.h
Detected Declarations
function Copyrightfunction nfc_hci_hcp_message_rx
Annotated Snippet
if (skb == NULL) {
err = -ENOMEM;
goto out_skb_err;
}
skb_reserve(skb, ndev->tx_headroom);
skb_put(skb, NFC_HCI_HCP_PACKET_HEADER_LEN + data_link_len);
/* Only the last fragment will have the cb bit set to 1 */
packet = (struct hcp_packet *)skb->data;
packet->header = pipe;
if (firstfrag) {
firstfrag = false;
packet->message.header = HCP_HEADER(type, instruction);
} else {
packet->message.header = *ptr++;
}
if (ptr) {
memcpy(packet->message.data, ptr, data_link_len - 1);
ptr += data_link_len - 1;
}
/* This is the last fragment, set the cb bit */
if (hci_len == 0)
packet->header |= ~NFC_HCI_FRAGMENT;
skb_queue_tail(&cmd->msg_frags, skb);
}
mutex_lock(&hdev->msg_tx_mutex);
if (hdev->shutting_down) {
err = -ESHUTDOWN;
mutex_unlock(&hdev->msg_tx_mutex);
goto out_skb_err;
}
list_add_tail(&cmd->msg_l, &hdev->msg_tx_queue);
mutex_unlock(&hdev->msg_tx_mutex);
schedule_work(&hdev->msg_tx_work);
return 0;
out_skb_err:
skb_queue_purge(&cmd->msg_frags);
kfree(cmd);
return err;
}
/*
* Receive hcp message for pipe, with type and cmd.
* skb contains optional message data only.
*/
void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type,
u8 instruction, struct sk_buff *skb)
{
switch (type) {
case NFC_HCI_HCP_RESPONSE:
nfc_hci_resp_received(hdev, instruction, skb);
break;
case NFC_HCI_HCP_COMMAND:
nfc_hci_cmd_received(hdev, pipe, instruction, skb);
break;
case NFC_HCI_HCP_EVENT:
nfc_hci_event_received(hdev, pipe, instruction, skb);
break;
default:
pr_err("UNKNOWN MSG Type %d, instruction=%d\n",
type, instruction);
kfree_skb(skb);
break;
}
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `net/nfc/hci.h`, `hci.h`.
- Detected declarations: `function Copyright`, `function nfc_hci_hcp_message_rx`.
- 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.