@@ -78,6 +78,11 @@ struct nci_ops {
78
78
int (* se_io )(struct nci_dev * ndev , u32 se_idx ,
79
79
u8 * apdu , size_t apdu_length ,
80
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
88
#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
@@ -102,10 +107,77 @@ struct nci_conn_info {
102
107
103
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
+
142
+ struct nci_hci_gate {
143
+ u8 gate ;
144
+ u8 pipe ;
145
+ u8 dest_host ;
146
+ } __packed ;
147
+
148
+ struct nci_hci_pipe {
149
+ u8 gate ;
150
+ u8 host ;
151
+ } __packed ;
152
+
153
+ struct 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
+
161
+ struct 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
176
/* NCI Core structures */
106
177
struct nci_dev {
107
178
struct nfc_dev * nfc_dev ;
108
179
struct nci_ops * ops ;
180
+ struct nci_hci_dev * hci_dev ;
109
181
110
182
int tx_headroom ;
111
183
int tx_tailroom ;
@@ -181,6 +253,10 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops,
181
253
void nci_free_device (struct nci_dev * ndev );
182
254
int nci_register_device (struct nci_dev * ndev );
183
255
void nci_unregister_device (struct nci_dev * ndev );
256
+ int nci_request (struct nci_dev * ndev ,
257
+ void (* req )(struct nci_dev * ndev ,
258
+ unsigned long opt ),
259
+ unsigned long opt , __u32 timeout );
184
260
int nci_recv_frame (struct nci_dev * ndev , struct sk_buff * skb );
185
261
int 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
266
struct core_conn_create_dest_spec_params * params );
191
267
int nci_core_conn_close (struct nci_dev * ndev , u8 conn_id );
192
268
269
+ struct nci_hci_dev * nci_hci_allocate (struct nci_dev * ndev );
270
+ int nci_hci_send_event (struct nci_dev * ndev , u8 gate , u8 event ,
271
+ const u8 * param , size_t param_len );
272
+ int 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 );
275
+ int nci_hci_open_pipe (struct nci_dev * ndev , u8 pipe );
276
+ int nci_hci_connect_gate (struct nci_dev * ndev , u8 dest_host ,
277
+ u8 dest_gate , u8 pipe );
278
+ int nci_hci_set_param (struct nci_dev * ndev , u8 gate , u8 idx ,
279
+ const u8 * param , size_t param_len );
280
+ int nci_hci_get_param (struct nci_dev * ndev , u8 gate , u8 idx ,
281
+ struct sk_buff * * skb );
282
+ int nci_hci_dev_session_init (struct nci_dev * ndev );
283
+
193
284
static inline struct sk_buff * nci_skb_alloc (struct nci_dev * ndev ,
194
285
unsigned int len ,
195
286
gfp_t how )
@@ -225,6 +316,8 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload);
225
316
int nci_send_data (struct nci_dev * ndev , __u8 conn_id , struct sk_buff * skb );
226
317
void nci_data_exchange_complete (struct nci_dev * ndev , struct sk_buff * skb ,
227
318
__u8 conn_id , int err );
319
+ void nci_hci_data_received_cb (void * context , struct sk_buff * skb , int err );
320
+
228
321
void nci_clear_target_list (struct nci_dev * ndev );
229
322
230
323
/* ----- NCI requests ----- */
0 commit comments