net/nfc/nci/ntf.c
Source file repositories/reference/linux-study-clean/net/nfc/nci/ntf.c
File Facts
- System
- Linux kernel
- Corpus path
net/nfc/nci/ntf.c- Extension
.c- Size
- 28802 bytes
- Lines
- 1041
- 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/types.hlinux/interrupt.hlinux/bitops.hlinux/skbuff.h../nfc.hnet/nfc/nci.hnet/nfc/nci_core.hlinux/nfc.h
Detected Declarations
function Controllerfunction nci_core_conn_credits_ntf_packetfunction nci_core_generic_error_ntf_packetfunction nci_core_conn_intf_error_ntf_packetfunction nci_extract_rf_params_nfca_passive_pollfunction nci_extract_rf_params_nfcb_passive_pollfunction nci_extract_rf_params_nfcf_passive_pollfunction nci_extract_rf_params_nfcv_passive_pollfunction nci_extract_rf_params_nfcf_passive_listenfunction nci_get_prop_rf_protocolfunction nci_add_new_protocolfunction nci_add_new_targetfunction nci_clear_target_listfunction nci_rf_discover_ntf_packetfunction nci_extract_activation_params_iso_depfunction nci_extract_activation_params_nfc_depfunction nci_target_auto_activatedfunction nci_store_general_bytes_nfc_depfunction nci_store_ats_nfc_iso_depfunction nci_rf_intf_activated_ntf_packetfunction nci_rf_deactivate_ntf_packetfunction nci_nfcee_discover_ntf_packetfunction nci_ntf_packet
Annotated Snippet
if (target->nfcid1_len > 0) {
memcpy(target->nfcid1, nfca_poll->nfcid1,
target->nfcid1_len);
}
} else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) {
nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params;
target->sensb_res_len = nfcb_poll->sensb_res_len;
if (target->sensb_res_len > ARRAY_SIZE(target->sensb_res))
return -EPROTO;
if (target->sensb_res_len > 0) {
memcpy(target->sensb_res, nfcb_poll->sensb_res,
target->sensb_res_len);
}
} else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) {
nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params;
target->sensf_res_len = nfcf_poll->sensf_res_len;
if (target->sensf_res_len > ARRAY_SIZE(target->sensf_res))
return -EPROTO;
if (target->sensf_res_len > 0) {
memcpy(target->sensf_res, nfcf_poll->sensf_res,
target->sensf_res_len);
}
} else if (rf_tech_and_mode == NCI_NFC_V_PASSIVE_POLL_MODE) {
nfcv_poll = (struct rf_tech_specific_params_nfcv_poll *)params;
target->is_iso15693 = 1;
target->iso15693_dsfid = nfcv_poll->dsfid;
memcpy(target->iso15693_uid, nfcv_poll->uid, NFC_ISO15693_UID_MAXSIZE);
} else {
pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
return -EPROTO;
}
target->supported_protocols |= protocol;
pr_debug("protocol 0x%x\n", protocol);
return 0;
}
static void nci_add_new_target(struct nci_dev *ndev,
const struct nci_rf_discover_ntf *ntf)
{
struct nfc_target *target;
int i, rc;
for (i = 0; i < ndev->n_targets; i++) {
target = &ndev->targets[i];
if (target->logical_idx == ntf->rf_discovery_id) {
/* This target already exists, add the new protocol */
nci_add_new_protocol(ndev, target, ntf->rf_protocol,
ntf->rf_tech_and_mode,
&ntf->rf_tech_specific_params);
return;
}
}
/* This is a new target, check if we've enough room */
if (ndev->n_targets == NCI_MAX_DISCOVERED_TARGETS) {
pr_debug("not enough room, ignoring new target...\n");
return;
}
target = &ndev->targets[ndev->n_targets];
rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
ntf->rf_tech_and_mode,
&ntf->rf_tech_specific_params);
if (!rc) {
target->logical_idx = ntf->rf_discovery_id;
ndev->n_targets++;
pr_debug("logical idx %d, n_targets %d\n", target->logical_idx,
ndev->n_targets);
}
}
void nci_clear_target_list(struct nci_dev *ndev)
{
memset(ndev->targets, 0,
(sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS));
ndev->n_targets = 0;
}
static int nci_rf_discover_ntf_packet(struct nci_dev *ndev,
const struct sk_buff *skb)
{
Annotation
- Immediate include surface: `linux/types.h`, `linux/interrupt.h`, `linux/bitops.h`, `linux/skbuff.h`, `../nfc.h`, `net/nfc/nci.h`, `net/nfc/nci_core.h`, `linux/nfc.h`.
- Detected declarations: `function Controller`, `function nci_core_conn_credits_ntf_packet`, `function nci_core_generic_error_ntf_packet`, `function nci_core_conn_intf_error_ntf_packet`, `function nci_extract_rf_params_nfca_passive_poll`, `function nci_extract_rf_params_nfcb_passive_poll`, `function nci_extract_rf_params_nfcf_passive_poll`, `function nci_extract_rf_params_nfcv_passive_poll`, `function nci_extract_rf_params_nfcf_passive_listen`, `function nci_get_prop_rf_protocol`.
- 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.