Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2012  Intel Corporation. All rights reserved.
0004  */
0005 
0006 #ifndef __LOCAL_HCI_H
0007 #define __LOCAL_HCI_H
0008 
0009 #include <net/nfc/hci.h>
0010 
0011 struct gate_pipe_map {
0012     u8 gate;
0013     u8 pipe;
0014 };
0015 
0016 struct hcp_message {
0017     u8 header;      /* type -cmd,evt,rsp- + instruction */
0018     u8 data[];
0019 } __packed;
0020 
0021 struct hcp_packet {
0022     u8 header;      /* cbit+pipe */
0023     struct hcp_message message;
0024 } __packed;
0025 
0026 struct hcp_exec_waiter {
0027     wait_queue_head_t *wq;
0028     bool exec_complete;
0029     int exec_result;
0030     struct sk_buff *result_skb;
0031 };
0032 
0033 struct hci_msg {
0034     struct list_head msg_l;
0035     struct sk_buff_head msg_frags;
0036     bool wait_response;
0037     data_exchange_cb_t cb;
0038     void *cb_context;
0039     unsigned long completion_delay;
0040 };
0041 
0042 struct hci_create_pipe_params {
0043     u8 src_gate;
0044     u8 dest_host;
0045     u8 dest_gate;
0046 } __packed;
0047 
0048 struct hci_create_pipe_resp {
0049     u8 src_host;
0050     u8 src_gate;
0051     u8 dest_host;
0052     u8 dest_gate;
0053     u8 pipe;
0054 } __packed;
0055 
0056 struct hci_delete_pipe_noti {
0057     u8 pipe;
0058 } __packed;
0059 
0060 struct hci_all_pipe_cleared_noti {
0061     u8 host;
0062 } __packed;
0063 
0064 #define NFC_HCI_FRAGMENT    0x7f
0065 
0066 #define HCP_HEADER(type, instr) ((((type) & 0x03) << 6) | ((instr) & 0x3f))
0067 #define HCP_MSG_GET_TYPE(header) ((header & 0xc0) >> 6)
0068 #define HCP_MSG_GET_CMD(header) (header & 0x3f)
0069 
0070 int nfc_hci_hcp_message_tx(struct nfc_hci_dev *hdev, u8 pipe,
0071                u8 type, u8 instruction,
0072                const u8 *payload, size_t payload_len,
0073                data_exchange_cb_t cb, void *cb_context,
0074                unsigned long completion_delay);
0075 
0076 void nfc_hci_hcp_message_rx(struct nfc_hci_dev *hdev, u8 pipe, u8 type,
0077                 u8 instruction, struct sk_buff *skb);
0078 
0079 /* HCP headers */
0080 #define NFC_HCI_HCP_PACKET_HEADER_LEN   1
0081 #define NFC_HCI_HCP_MESSAGE_HEADER_LEN  1
0082 #define NFC_HCI_HCP_HEADER_LEN      2
0083 
0084 /* HCP types */
0085 #define NFC_HCI_HCP_COMMAND 0x00
0086 #define NFC_HCI_HCP_EVENT   0x01
0087 #define NFC_HCI_HCP_RESPONSE    0x02
0088 
0089 /* Generic commands */
0090 #define NFC_HCI_ANY_SET_PARAMETER   0x01
0091 #define NFC_HCI_ANY_GET_PARAMETER   0x02
0092 #define NFC_HCI_ANY_OPEN_PIPE       0x03
0093 #define NFC_HCI_ANY_CLOSE_PIPE      0x04
0094 
0095 /* Reader RF commands */
0096 #define NFC_HCI_WR_XCHG_DATA        0x10
0097 
0098 /* Admin commands */
0099 #define NFC_HCI_ADM_CREATE_PIPE         0x10
0100 #define NFC_HCI_ADM_DELETE_PIPE         0x11
0101 #define NFC_HCI_ADM_NOTIFY_PIPE_CREATED     0x12
0102 #define NFC_HCI_ADM_NOTIFY_PIPE_DELETED     0x13
0103 #define NFC_HCI_ADM_CLEAR_ALL_PIPE      0x14
0104 #define NFC_HCI_ADM_NOTIFY_ALL_PIPE_CLEARED 0x15
0105 
0106 /* Generic responses */
0107 #define NFC_HCI_ANY_OK              0x00
0108 #define NFC_HCI_ANY_E_NOT_CONNECTED     0x01
0109 #define NFC_HCI_ANY_E_CMD_PAR_UNKNOWN       0x02
0110 #define NFC_HCI_ANY_E_NOK           0x03
0111 #define NFC_HCI_ANY_E_PIPES_FULL        0x04
0112 #define NFC_HCI_ANY_E_REG_PAR_UNKNOWN       0x05
0113 #define NFC_HCI_ANY_E_PIPE_NOT_OPENED       0x06
0114 #define NFC_HCI_ANY_E_CMD_NOT_SUPPORTED     0x07
0115 #define NFC_HCI_ANY_E_INHIBITED         0x08
0116 #define NFC_HCI_ANY_E_TIMEOUT           0x09
0117 #define NFC_HCI_ANY_E_REG_ACCESS_DENIED     0x0a
0118 #define NFC_HCI_ANY_E_PIPE_ACCESS_DENIED    0x0b
0119 
0120 #endif /* __LOCAL_HCI_H */