28 #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
30 #include <linux/types.h>
32 #include <linux/bitops.h>
42 static void nci_core_conn_credits_ntf_packet(
struct nci_dev *
ndev,
58 pr_debug(
"entry[%d]: conn_id %d, credits %d\n",
70 if (!skb_queue_empty(&ndev->
tx_q))
74 static void nci_core_generic_error_ntf_packet(
struct nci_dev *
ndev,
88 static void nci_core_conn_intf_error_ntf_packet(
struct nci_dev *ndev,
102 static __u8 *nci_extract_rf_params_nfca_passive_poll(
struct nci_dev *ndev,
111 pr_debug(
"sens_res 0x%x, nfcid1_len %d\n",
122 pr_debug(
"sel_res_len %d, sel_res 0x%x\n",
129 static __u8 *nci_extract_rf_params_nfcb_passive_poll(
struct nci_dev *ndev,
143 static __u8 *nci_extract_rf_params_nfcf_passive_poll(
struct nci_dev *ndev,
150 pr_debug(
"bit_rate %d, sensf_res_len %d\n",
159 static int nci_add_new_protocol(
struct nci_dev *ndev,
162 __u8 rf_tech_and_mode,
185 pr_err(
"the target found does not have the desired protocol\n");
216 pr_err(
"unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
222 pr_debug(
"protocol 0x%x\n", protocol);
227 static void nci_add_new_target(
struct nci_dev *ndev,
237 nci_add_new_protocol(ndev, target, ntf->
rf_protocol,
246 pr_debug(
"not enough room, ignoring new target...\n");
252 rc = nci_add_new_protocol(ndev, target, ntf->
rf_protocol,
272 static void nci_rf_discover_ntf_packet(
struct nci_dev *ndev,
277 bool add_target =
true;
287 pr_debug(
"rf_tech_specific_params_len %d\n",
293 data = nci_extract_rf_params_nfca_passive_poll(ndev,
298 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
303 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
308 pr_err(
"unsupported rf_tech_and_mode 0x%x\n",
318 if (add_target ==
true)
319 nci_add_new_target(ndev, &ntf);
330 static int nci_extract_activation_params_iso_dep(
struct nci_dev *ndev,
358 pr_err(
"unsupported activation_rf_tech_and_mode 0x%x\n",
366 static int nci_extract_activation_params_nfc_dep(
struct nci_dev *ndev,
385 pr_err(
"unsupported activation_rf_tech_and_mode 0x%x\n",
393 static void nci_target_auto_activated(
struct nci_dev *ndev,
401 rc = nci_add_new_protocol(ndev, target, ntf->
rf_protocol,
410 pr_debug(
"logical idx %d, n_targets %d\n",
416 static void nci_rf_intf_activated_ntf_packet(
struct nci_dev *ndev,
434 pr_debug(
"activation_rf_tech_and_mode 0x%x\n",
436 pr_debug(
"max_data_pkt_payload_size 0x%x\n",
438 pr_debug(
"initial_num_credits 0x%x\n",
440 pr_debug(
"rf_tech_specific_params_len %d\n",
446 data = nci_extract_rf_params_nfca_passive_poll(ndev,
451 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
456 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
461 pr_err(
"unsupported activation_rf_tech_and_mode 0x%x\n",
473 pr_debug(
"data_exch_rf_tech_and_mode 0x%x\n",
482 err = nci_extract_activation_params_iso_dep(ndev,
487 err = nci_extract_activation_params_nfc_dep(ndev,
496 pr_err(
"unsupported rf_interface 0x%x\n",
534 nci_target_auto_activated(ndev, &ntf);
542 static void nci_rf_deactivate_ntf_packet(
struct nci_dev *ndev,
571 pr_debug(
"NCI RX: MT=ntf, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n",
580 switch (ntf_opcode) {
582 nci_core_conn_credits_ntf_packet(ndev, skb);
586 nci_core_generic_error_ntf_packet(ndev, skb);
590 nci_core_conn_intf_error_ntf_packet(ndev, skb);
594 nci_rf_discover_ntf_packet(ndev, skb);
598 nci_rf_intf_activated_ntf_packet(ndev, skb);
602 nci_rf_deactivate_ntf_packet(ndev, skb);
606 pr_err(
"unknown ntf opcode 0x%x\n", ntf_opcode);