aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2015-02-01 16:26:14 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2015-02-02 15:50:40 -0500
commit11f54f228643d0248ec00ce8c9fb8d872f87e7b8 (patch)
tree5cf467e89367c99bff3565669ee777dc8d5cad8f /include/net
parent736bb9577407d3556d81c3c3cd57581cd3ae10ea (diff)
NFC: nci: Add HCI over NCI protocol support
According to the NCI specification, one can use HCI over NCI to talk with specific NFCEE. The HCI network is viewed as one logical NFCEE. This is needed to support secure element running HCI only firmwares embedded on an NCI capable chipset, like e.g. the st21nfcb. There is some duplication between this piece of code and the HCI core code, but the latter would need to be abstracted even more to be able to use NCI as a logical transport for HCP packets. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/nfc/nci_core.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index 8ba3e38e4167..be858870dace 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -78,6 +78,11 @@ struct nci_ops {
78 int (*se_io)(struct nci_dev *ndev, u32 se_idx, 78 int (*se_io)(struct nci_dev *ndev, u32 se_idx,
79 u8 *apdu, size_t apdu_length, 79 u8 *apdu, size_t apdu_length,
80 se_io_cb_t cb, void *cb_context); 80 se_io_cb_t cb, void *cb_context);
81 int (*hci_load_session)(struct nci_dev *ndev);
82 void (*hci_event_received)(struct nci_dev *ndev, u8 pipe, u8 event,
83 struct sk_buff *skb);
84 void (*hci_cmd_received)(struct nci_dev *ndev, u8 pipe, u8 cmd,
85 struct sk_buff *skb);
81}; 86};
82 87
83#define NCI_MAX_SUPPORTED_RF_INTERFACES 4 88#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
@@ -102,10 +107,77 @@ struct nci_conn_info {
102 107
103#define NCI_INVALID_CONN_ID 0x80 108#define NCI_INVALID_CONN_ID 0x80
104 109
110#define NCI_HCI_ANY_OPEN_PIPE 0x03
111
112/* Gates */
113#define NCI_HCI_ADMIN_GATE 0x00
114#define NCI_HCI_LINK_MGMT_GATE 0x06
115
116/* Pipes */
117#define NCI_HCI_LINK_MGMT_PIPE 0x00
118#define NCI_HCI_ADMIN_PIPE 0x01
119
120/* Generic responses */
121#define NCI_HCI_ANY_OK 0x00
122#define NCI_HCI_ANY_E_NOT_CONNECTED 0x01
123#define NCI_HCI_ANY_E_CMD_PAR_UNKNOWN 0x02
124#define NCI_HCI_ANY_E_NOK 0x03
125#define NCI_HCI_ANY_E_PIPES_FULL 0x04
126#define NCI_HCI_ANY_E_REG_PAR_UNKNOWN 0x05
127#define NCI_HCI_ANY_E_PIPE_NOT_OPENED 0x06
128#define NCI_HCI_ANY_E_CMD_NOT_SUPPORTED 0x07
129#define NCI_HCI_ANY_E_INHIBITED 0x08
130#define NCI_HCI_ANY_E_TIMEOUT 0x09
131#define NCI_HCI_ANY_E_REG_ACCESS_DENIED 0x0a
132#define NCI_HCI_ANY_E_PIPE_ACCESS_DENIED 0x0b
133
134#define NCI_HCI_DO_NOT_OPEN_PIPE 0x81
135#define NCI_HCI_INVALID_PIPE 0x80
136#define NCI_HCI_INVALID_GATE 0xFF
137#define NCI_HCI_INVALID_HOST 0x80
138
139#define NCI_HCI_MAX_CUSTOM_GATES 50
140#define NCI_HCI_MAX_PIPES 127
141
142struct nci_hci_gate {
143 u8 gate;
144 u8 pipe;
145 u8 dest_host;
146} __packed;
147
148struct nci_hci_pipe {
149 u8 gate;
150 u8 host;
151} __packed;
152
153struct nci_hci_init_data {
154 u8 gate_count;
155 struct nci_hci_gate gates[NCI_HCI_MAX_CUSTOM_GATES];
156 char session_id[9];
157};
158
159#define NCI_HCI_MAX_GATES 256
160
161struct nci_hci_dev {
162 struct nci_dev *ndev;
163 struct nci_conn_info *conn_info;
164
165 struct nci_hci_init_data init_data;
166 struct nci_hci_pipe pipes[NCI_HCI_MAX_PIPES];
167 u8 gate2pipe[NCI_HCI_MAX_GATES];
168 int expected_pipes;
169 int count_pipes;
170
171 struct sk_buff_head rx_hcp_frags;
172 struct work_struct msg_rx_work;
173 struct sk_buff_head msg_rx_queue;
174};
175
105/* NCI Core structures */ 176/* NCI Core structures */
106struct nci_dev { 177struct nci_dev {
107 struct nfc_dev *nfc_dev; 178 struct nfc_dev *nfc_dev;
108 struct nci_ops *ops; 179 struct nci_ops *ops;
180 struct nci_hci_dev *hci_dev;
109 181
110 int tx_headroom; 182 int tx_headroom;
111 int tx_tailroom; 183 int tx_tailroom;
@@ -181,6 +253,10 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops,
181void nci_free_device(struct nci_dev *ndev); 253void nci_free_device(struct nci_dev *ndev);
182int nci_register_device(struct nci_dev *ndev); 254int nci_register_device(struct nci_dev *ndev);
183void nci_unregister_device(struct nci_dev *ndev); 255void nci_unregister_device(struct nci_dev *ndev);
256int nci_request(struct nci_dev *ndev,
257 void (*req)(struct nci_dev *ndev,
258 unsigned long opt),
259 unsigned long opt, __u32 timeout);
184int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb); 260int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
185int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val); 261int nci_set_config(struct nci_dev *ndev, __u8 id, size_t len, __u8 *val);
186 262
@@ -190,6 +266,21 @@ int nci_core_conn_create(struct nci_dev *ndev,
190 struct core_conn_create_dest_spec_params *params); 266 struct core_conn_create_dest_spec_params *params);
191int nci_core_conn_close(struct nci_dev *ndev, u8 conn_id); 267int nci_core_conn_close(struct nci_dev *ndev, u8 conn_id);
192 268
269struct nci_hci_dev *nci_hci_allocate(struct nci_dev *ndev);
270int nci_hci_send_event(struct nci_dev *ndev, u8 gate, u8 event,
271 const u8 *param, size_t param_len);
272int nci_hci_send_cmd(struct nci_dev *ndev, u8 gate,
273 u8 cmd, const u8 *param, size_t param_len,
274 struct sk_buff **skb);
275int nci_hci_open_pipe(struct nci_dev *ndev, u8 pipe);
276int nci_hci_connect_gate(struct nci_dev *ndev, u8 dest_host,
277 u8 dest_gate, u8 pipe);
278int nci_hci_set_param(struct nci_dev *ndev, u8 gate, u8 idx,
279 const u8 *param, size_t param_len);
280int nci_hci_get_param(struct nci_dev *ndev, u8 gate, u8 idx,
281 struct sk_buff **skb);
282int nci_hci_dev_session_init(struct nci_dev *ndev);
283
193static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, 284static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev,
194 unsigned int len, 285 unsigned int len,
195 gfp_t how) 286 gfp_t how)
@@ -225,6 +316,8 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
225int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb); 316int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb);
226void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, 317void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb,
227 __u8 conn_id, int err); 318 __u8 conn_id, int err);
319void nci_hci_data_received_cb(void *context, struct sk_buff *skb, int err);
320
228void nci_clear_target_list(struct nci_dev *ndev); 321void nci_clear_target_list(struct nci_dev *ndev);
229 322
230/* ----- NCI requests ----- */ 323/* ----- NCI requests ----- */