net/nfc/nci/rsp.c

Source file repositories/reference/linux-study-clean/net/nfc/nci/rsp.c

File Facts

System
Linux kernel
Corpus path
net/nfc/nci/rsp.c
Extension
.c
Size
11327 bytes
Lines
429
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (rsp->status == NCI_STATUS_OK) {
			ndev->nci_ver = rsp->nci_ver;
			pr_debug("nci_ver 0x%x, config_status 0x%x\n",
				 rsp->nci_ver, rsp->config_status);
		}

		nci_req_complete(ndev, rsp->status);
	}
}

static u8 nci_core_init_rsp_packet_v1(struct nci_dev *ndev,
				      const struct sk_buff *skb)
{
	const struct nci_core_init_rsp_1 *rsp_1 = (void *)skb->data;
	const struct nci_core_init_rsp_2 *rsp_2;

	pr_debug("status 0x%x\n", rsp_1->status);

	if (rsp_1->status != NCI_STATUS_OK)
		return rsp_1->status;

	ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features);
	ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;

	ndev->num_supported_rf_interfaces =
		min((int)ndev->num_supported_rf_interfaces,
		    NCI_MAX_SUPPORTED_RF_INTERFACES);

	memcpy(ndev->supported_rf_interfaces,
	       rsp_1->supported_rf_interfaces,
	       ndev->num_supported_rf_interfaces);

	rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces);

	ndev->max_logical_connections = rsp_2->max_logical_connections;
	ndev->max_routing_table_size =
		__le16_to_cpu(rsp_2->max_routing_table_size);
	ndev->max_ctrl_pkt_payload_len =
		rsp_2->max_ctrl_pkt_payload_len;
	ndev->max_size_for_large_params =
		__le16_to_cpu(rsp_2->max_size_for_large_params);
	ndev->manufact_id =
		rsp_2->manufact_id;
	ndev->manufact_specific_info =
		__le32_to_cpu(rsp_2->manufact_specific_info);

	return NCI_STATUS_OK;
}

static u8 nci_core_init_rsp_packet_v2(struct nci_dev *ndev,
				      const struct sk_buff *skb)
{
	const struct nci_core_init_rsp_nci_ver2 *rsp = (void *)skb->data;
	const u8 *supported_rf_interface = rsp->supported_rf_interfaces;
	u8 rf_interface_idx = 0;
	u8 rf_extension_cnt = 0;

	pr_debug("status %x\n", rsp->status);

	if (rsp->status != NCI_STATUS_OK)
		return rsp->status;

	ndev->nfcc_features = __le32_to_cpu(rsp->nfcc_features);
	ndev->num_supported_rf_interfaces = rsp->num_supported_rf_interfaces;

	ndev->num_supported_rf_interfaces =
		min((int)ndev->num_supported_rf_interfaces,
		    NCI_MAX_SUPPORTED_RF_INTERFACES);

	while (rf_interface_idx < ndev->num_supported_rf_interfaces) {
		ndev->supported_rf_interfaces[rf_interface_idx++] = *supported_rf_interface++;

		/* skip rf extension parameters */
		rf_extension_cnt = *supported_rf_interface++;
		supported_rf_interface += rf_extension_cnt;
	}

	ndev->max_logical_connections = rsp->max_logical_connections;
	ndev->max_routing_table_size =
			__le16_to_cpu(rsp->max_routing_table_size);
	ndev->max_ctrl_pkt_payload_len =
			rsp->max_ctrl_pkt_payload_len;
	ndev->max_size_for_large_params = NCI_MAX_LARGE_PARAMS_NCI_v2;

	return NCI_STATUS_OK;
}

static void nci_core_init_rsp_packet(struct nci_dev *ndev, const struct sk_buff *skb)
{
	u8 status = 0;

Annotation

Implementation Notes