NFC: Add ISO 14443 type B protocol
[deliverable/linux.git] / net / nfc / nci / ntf.c
CommitLineData
6a2968aa
IE
1/*
2 * The NFC Controller Interface is the communication protocol between an
3 * NFC Controller (NFCC) and a Device Host (DH).
4 *
5 * Copyright (C) 2011 Texas Instruments, Inc.
6 *
7 * Written by Ilan Elias <ilane@ti.com>
8 *
9 * Acknowledgements:
10 * This file is based on hci_event.c, which was written
11 * by Maxim Krasnyansky.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
52858b51 28#define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__
ed1e0ad8 29
6a2968aa
IE
30#include <linux/types.h>
31#include <linux/interrupt.h>
32#include <linux/bitops.h>
33#include <linux/skbuff.h>
34
35#include "../nfc.h"
36#include <net/nfc/nci.h>
37#include <net/nfc/nci_core.h>
38#include <linux/nfc.h>
39
40/* Handle NCI Notification packets */
41
42static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
eb9bc6e9 43 struct sk_buff *skb)
6a2968aa
IE
44{
45 struct nci_core_conn_credit_ntf *ntf = (void *) skb->data;
46 int i;
47
24bf3304 48 pr_debug("num_entries %d\n", ntf->num_entries);
6a2968aa
IE
49
50 if (ntf->num_entries > NCI_MAX_NUM_CONN)
51 ntf->num_entries = NCI_MAX_NUM_CONN;
52
53 /* update the credits */
54 for (i = 0; i < ntf->num_entries; i++) {
637d85a7
IE
55 ntf->conn_entries[i].conn_id =
56 nci_conn_id(&ntf->conn_entries[i].conn_id);
57
20c239c1
JP
58 pr_debug("entry[%d]: conn_id %d, credits %d\n",
59 i, ntf->conn_entries[i].conn_id,
60 ntf->conn_entries[i].credits);
6a2968aa 61
e8c0dacd 62 if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) {
6a2968aa
IE
63 /* found static rf connection */
64 atomic_add(ntf->conn_entries[i].credits,
eb9bc6e9 65 &ndev->credits_cnt);
6a2968aa
IE
66 }
67 }
68
69 /* trigger the next tx */
70 if (!skb_queue_empty(&ndev->tx_q))
71 queue_work(ndev->tx_wq, &ndev->tx_work);
72}
73
019c4fba 74static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev,
eb9bc6e9 75 struct sk_buff *skb)
019c4fba
IE
76{
77 __u8 status = skb->data[0];
78
79 pr_debug("status 0x%x\n", status);
80
81 if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
82 /* Activation failed, so complete the request
eb9bc6e9 83 (the state remains the same) */
019c4fba
IE
84 nci_req_complete(ndev, status);
85 }
86}
87
004161cb
IE
88static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev,
89 struct sk_buff *skb)
90{
91 struct nci_core_intf_error_ntf *ntf = (void *) skb->data;
92
93 ntf->conn_id = nci_conn_id(&ntf->conn_id);
94
95 pr_debug("status 0x%x, conn_id %d\n", ntf->status, ntf->conn_id);
96
97 /* complete the data exchange transaction, if exists */
98 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
99 nci_data_exchange_complete(ndev, NULL, -EIO);
100}
101
e8c0dacd 102static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
019c4fba 103 struct rf_tech_specific_params_nfca_poll *nfca_poll,
eb9bc6e9 104 __u8 *data)
6a2968aa 105{
6a2968aa
IE
106 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
107 data += 2;
108
67de956f 109 nfca_poll->nfcid1_len = min_t(__u8, *data++, NFC_NFCID1_MAXSIZE);
6a2968aa 110
20c239c1
JP
111 pr_debug("sens_res 0x%x, nfcid1_len %d\n",
112 nfca_poll->sens_res, nfca_poll->nfcid1_len);
6a2968aa
IE
113
114 memcpy(nfca_poll->nfcid1, data, nfca_poll->nfcid1_len);
115 data += nfca_poll->nfcid1_len;
116
117 nfca_poll->sel_res_len = *data++;
118
119 if (nfca_poll->sel_res_len != 0)
120 nfca_poll->sel_res = *data++;
121
20c239c1
JP
122 pr_debug("sel_res_len %d, sel_res 0x%x\n",
123 nfca_poll->sel_res_len,
124 nfca_poll->sel_res);
e8c0dacd
IE
125
126 return data;
127}
128
d5a2ca60 129static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
019c4fba 130 struct rf_tech_specific_params_nfcb_poll *nfcb_poll,
eb9bc6e9 131 __u8 *data)
d5a2ca60 132{
67de956f 133 nfcb_poll->sensb_res_len = min_t(__u8, *data++, NFC_SENSB_RES_MAXSIZE);
d5a2ca60
IE
134
135 pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len);
136
137 memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len);
138 data += nfcb_poll->sensb_res_len;
139
140 return data;
141}
142
143static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,
019c4fba 144 struct rf_tech_specific_params_nfcf_poll *nfcf_poll,
eb9bc6e9 145 __u8 *data)
d5a2ca60 146{
d5a2ca60 147 nfcf_poll->bit_rate = *data++;
67de956f 148 nfcf_poll->sensf_res_len = min_t(__u8, *data++, NFC_SENSF_RES_MAXSIZE);
d5a2ca60
IE
149
150 pr_debug("bit_rate %d, sensf_res_len %d\n",
eb9bc6e9 151 nfcf_poll->bit_rate, nfcf_poll->sensf_res_len);
d5a2ca60
IE
152
153 memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len);
154 data += nfcf_poll->sensf_res_len;
155
156 return data;
157}
158
019c4fba
IE
159static int nci_add_new_protocol(struct nci_dev *ndev,
160 struct nfc_target *target,
161 __u8 rf_protocol,
162 __u8 rf_tech_and_mode,
163 void *params)
164{
165 struct rf_tech_specific_params_nfca_poll *nfca_poll;
166 struct rf_tech_specific_params_nfcb_poll *nfcb_poll;
167 struct rf_tech_specific_params_nfcf_poll *nfcf_poll;
168 __u32 protocol;
169
170 if (rf_protocol == NCI_RF_PROTOCOL_T2T)
171 protocol = NFC_PROTO_MIFARE_MASK;
172 else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP)
01d719a2
SO
173 if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE)
174 protocol = NFC_PROTO_ISO14443_MASK;
175 else
176 protocol = NFC_PROTO_ISO14443_B_MASK;
019c4fba
IE
177 else if (rf_protocol == NCI_RF_PROTOCOL_T3T)
178 protocol = NFC_PROTO_FELICA_MASK;
179 else
180 protocol = 0;
181
182 if (!(protocol & ndev->poll_prots)) {
183 pr_err("the target found does not have the desired protocol\n");
184 return -EPROTO;
185 }
186
187 if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) {
188 nfca_poll = (struct rf_tech_specific_params_nfca_poll *)params;
189
190 target->sens_res = nfca_poll->sens_res;
191 target->sel_res = nfca_poll->sel_res;
192 target->nfcid1_len = nfca_poll->nfcid1_len;
193 if (target->nfcid1_len > 0) {
194 memcpy(target->nfcid1, nfca_poll->nfcid1,
eb9bc6e9 195 target->nfcid1_len);
019c4fba
IE
196 }
197 } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) {
198 nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params;
199
200 target->sensb_res_len = nfcb_poll->sensb_res_len;
201 if (target->sensb_res_len > 0) {
202 memcpy(target->sensb_res, nfcb_poll->sensb_res,
eb9bc6e9 203 target->sensb_res_len);
019c4fba
IE
204 }
205 } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) {
206 nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params;
207
208 target->sensf_res_len = nfcf_poll->sensf_res_len;
209 if (target->sensf_res_len > 0) {
210 memcpy(target->sensf_res, nfcf_poll->sensf_res,
eb9bc6e9 211 target->sensf_res_len);
019c4fba
IE
212 }
213 } else {
214 pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode);
215 return -EPROTO;
216 }
217
218 target->supported_protocols |= protocol;
219
220 pr_debug("protocol 0x%x\n", protocol);
221
222 return 0;
223}
224
225static void nci_add_new_target(struct nci_dev *ndev,
eb9bc6e9 226 struct nci_rf_discover_ntf *ntf)
019c4fba
IE
227{
228 struct nfc_target *target;
229 int i, rc;
230
231 for (i = 0; i < ndev->n_targets; i++) {
232 target = &ndev->targets[i];
c4fbb651 233 if (target->logical_idx == ntf->rf_discovery_id) {
019c4fba
IE
234 /* This target already exists, add the new protocol */
235 nci_add_new_protocol(ndev, target, ntf->rf_protocol,
eb9bc6e9
SO
236 ntf->rf_tech_and_mode,
237 &ntf->rf_tech_specific_params);
019c4fba
IE
238 return;
239 }
240 }
241
242 /* This is a new target, check if we've enough room */
243 if (ndev->n_targets == NCI_MAX_DISCOVERED_TARGETS) {
244 pr_debug("not enough room, ignoring new target...\n");
245 return;
246 }
247
248 target = &ndev->targets[ndev->n_targets];
249
250 rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
eb9bc6e9
SO
251 ntf->rf_tech_and_mode,
252 &ntf->rf_tech_specific_params);
019c4fba 253 if (!rc) {
c4fbb651 254 target->logical_idx = ntf->rf_discovery_id;
019c4fba
IE
255 ndev->n_targets++;
256
c4fbb651 257 pr_debug("logical idx %d, n_targets %d\n", target->logical_idx,
eb9bc6e9 258 ndev->n_targets);
019c4fba
IE
259 }
260}
261
262void nci_clear_target_list(struct nci_dev *ndev)
263{
264 memset(ndev->targets, 0,
eb9bc6e9 265 (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS));
019c4fba
IE
266
267 ndev->n_targets = 0;
268}
269
270static void nci_rf_discover_ntf_packet(struct nci_dev *ndev,
eb9bc6e9 271 struct sk_buff *skb)
019c4fba
IE
272{
273 struct nci_rf_discover_ntf ntf;
274 __u8 *data = skb->data;
275 bool add_target = true;
276
277 ntf.rf_discovery_id = *data++;
278 ntf.rf_protocol = *data++;
279 ntf.rf_tech_and_mode = *data++;
280 ntf.rf_tech_specific_params_len = *data++;
281
282 pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id);
283 pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol);
284 pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode);
285 pr_debug("rf_tech_specific_params_len %d\n",
eb9bc6e9 286 ntf.rf_tech_specific_params_len);
019c4fba
IE
287
288 if (ntf.rf_tech_specific_params_len > 0) {
289 switch (ntf.rf_tech_and_mode) {
290 case NCI_NFC_A_PASSIVE_POLL_MODE:
291 data = nci_extract_rf_params_nfca_passive_poll(ndev,
292 &(ntf.rf_tech_specific_params.nfca_poll), data);
293 break;
294
295 case NCI_NFC_B_PASSIVE_POLL_MODE:
296 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
297 &(ntf.rf_tech_specific_params.nfcb_poll), data);
298 break;
299
300 case NCI_NFC_F_PASSIVE_POLL_MODE:
301 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
302 &(ntf.rf_tech_specific_params.nfcf_poll), data);
303 break;
304
305 default:
306 pr_err("unsupported rf_tech_and_mode 0x%x\n",
307 ntf.rf_tech_and_mode);
308 data += ntf.rf_tech_specific_params_len;
309 add_target = false;
310 }
311 }
312
313 ntf.ntf_type = *data++;
314 pr_debug("ntf_type %d\n", ntf.ntf_type);
315
316 if (add_target == true)
317 nci_add_new_target(ndev, &ntf);
318
319 if (ntf.ntf_type == NCI_DISCOVER_NTF_TYPE_MORE) {
320 atomic_set(&ndev->state, NCI_W4_ALL_DISCOVERIES);
321 } else {
322 atomic_set(&ndev->state, NCI_W4_HOST_SELECT);
323 nfc_targets_found(ndev->nfc_dev, ndev->targets,
eb9bc6e9 324 ndev->n_targets);
019c4fba
IE
325 }
326}
327
e8c0dacd
IE
328static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
329 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
330{
331 struct activation_params_nfca_poll_iso_dep *nfca_poll;
d5a2ca60 332 struct activation_params_nfcb_poll_iso_dep *nfcb_poll;
e8c0dacd
IE
333
334 switch (ntf->activation_rf_tech_and_mode) {
335 case NCI_NFC_A_PASSIVE_POLL_MODE:
336 nfca_poll = &ntf->activation_params.nfca_poll_iso_dep;
67de956f 337 nfca_poll->rats_res_len = min_t(__u8, *data++, 20);
d5a2ca60 338 pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len);
e8c0dacd
IE
339 if (nfca_poll->rats_res_len > 0) {
340 memcpy(nfca_poll->rats_res,
eb9bc6e9 341 data, nfca_poll->rats_res_len);
6a2968aa
IE
342 }
343 break;
344
d5a2ca60
IE
345 case NCI_NFC_B_PASSIVE_POLL_MODE:
346 nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;
67de956f 347 nfcb_poll->attrib_res_len = min_t(__u8, *data++, 50);
eb9bc6e9 348 pr_debug("attrib_res_len %d\n", nfcb_poll->attrib_res_len);
d5a2ca60
IE
349 if (nfcb_poll->attrib_res_len > 0) {
350 memcpy(nfcb_poll->attrib_res,
eb9bc6e9 351 data, nfcb_poll->attrib_res_len);
d5a2ca60
IE
352 }
353 break;
354
6a2968aa 355 default:
ed1e0ad8
JP
356 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
357 ntf->activation_rf_tech_and_mode);
019c4fba 358 return NCI_STATUS_RF_PROTOCOL_ERROR;
6a2968aa
IE
359 }
360
019c4fba 361 return NCI_STATUS_OK;
6a2968aa
IE
362}
363
019c4fba 364static void nci_target_auto_activated(struct nci_dev *ndev,
eb9bc6e9 365 struct nci_rf_intf_activated_ntf *ntf)
6a2968aa 366{
019c4fba
IE
367 struct nfc_target *target;
368 int rc;
6a2968aa 369
019c4fba 370 target = &ndev->targets[ndev->n_targets];
d5a2ca60 371
019c4fba 372 rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol,
eb9bc6e9
SO
373 ntf->activation_rf_tech_and_mode,
374 &ntf->rf_tech_specific_params);
019c4fba 375 if (rc)
6a2968aa 376 return;
6a2968aa 377
c4fbb651 378 target->logical_idx = ntf->rf_discovery_id;
019c4fba 379 ndev->n_targets++;
d5a2ca60 380
c4fbb651
SO
381 pr_debug("logical idx %d, n_targets %d\n",
382 target->logical_idx, ndev->n_targets);
637d85a7 383
019c4fba 384 nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets);
6a2968aa
IE
385}
386
e8c0dacd 387static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
eb9bc6e9 388 struct sk_buff *skb)
6a2968aa 389{
e8c0dacd 390 struct nci_rf_intf_activated_ntf ntf;
6a2968aa 391 __u8 *data = skb->data;
019c4fba 392 int err = NCI_STATUS_OK;
6a2968aa 393
e8c0dacd 394 ntf.rf_discovery_id = *data++;
637d85a7 395 ntf.rf_interface = *data++;
6a2968aa 396 ntf.rf_protocol = *data++;
e8c0dacd 397 ntf.activation_rf_tech_and_mode = *data++;
637d85a7
IE
398 ntf.max_data_pkt_payload_size = *data++;
399 ntf.initial_num_credits = *data++;
6a2968aa
IE
400 ntf.rf_tech_specific_params_len = *data++;
401
20c239c1 402 pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id);
637d85a7 403 pr_debug("rf_interface 0x%x\n", ntf.rf_interface);
20c239c1
JP
404 pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol);
405 pr_debug("activation_rf_tech_and_mode 0x%x\n",
406 ntf.activation_rf_tech_and_mode);
637d85a7
IE
407 pr_debug("max_data_pkt_payload_size 0x%x\n",
408 ntf.max_data_pkt_payload_size);
eb9bc6e9
SO
409 pr_debug("initial_num_credits 0x%x\n",
410 ntf.initial_num_credits);
20c239c1
JP
411 pr_debug("rf_tech_specific_params_len %d\n",
412 ntf.rf_tech_specific_params_len);
6a2968aa 413
e8c0dacd
IE
414 if (ntf.rf_tech_specific_params_len > 0) {
415 switch (ntf.activation_rf_tech_and_mode) {
416 case NCI_NFC_A_PASSIVE_POLL_MODE:
417 data = nci_extract_rf_params_nfca_passive_poll(ndev,
019c4fba 418 &(ntf.rf_tech_specific_params.nfca_poll), data);
e8c0dacd
IE
419 break;
420
d5a2ca60
IE
421 case NCI_NFC_B_PASSIVE_POLL_MODE:
422 data = nci_extract_rf_params_nfcb_passive_poll(ndev,
019c4fba 423 &(ntf.rf_tech_specific_params.nfcb_poll), data);
d5a2ca60
IE
424 break;
425
426 case NCI_NFC_F_PASSIVE_POLL_MODE:
427 data = nci_extract_rf_params_nfcf_passive_poll(ndev,
019c4fba 428 &(ntf.rf_tech_specific_params.nfcf_poll), data);
d5a2ca60
IE
429 break;
430
e8c0dacd 431 default:
ed1e0ad8
JP
432 pr_err("unsupported activation_rf_tech_and_mode 0x%x\n",
433 ntf.activation_rf_tech_and_mode);
019c4fba
IE
434 err = NCI_STATUS_RF_PROTOCOL_ERROR;
435 goto exit;
e8c0dacd
IE
436 }
437 }
6a2968aa 438
e8c0dacd
IE
439 ntf.data_exch_rf_tech_and_mode = *data++;
440 ntf.data_exch_tx_bit_rate = *data++;
441 ntf.data_exch_rx_bit_rate = *data++;
442 ntf.activation_params_len = *data++;
443
20c239c1
JP
444 pr_debug("data_exch_rf_tech_and_mode 0x%x\n",
445 ntf.data_exch_rf_tech_and_mode);
eb9bc6e9
SO
446 pr_debug("data_exch_tx_bit_rate 0x%x\n", ntf.data_exch_tx_bit_rate);
447 pr_debug("data_exch_rx_bit_rate 0x%x\n", ntf.data_exch_rx_bit_rate);
448 pr_debug("activation_params_len %d\n", ntf.activation_params_len);
e8c0dacd
IE
449
450 if (ntf.activation_params_len > 0) {
637d85a7 451 switch (ntf.rf_interface) {
e8c0dacd
IE
452 case NCI_RF_INTERFACE_ISO_DEP:
453 err = nci_extract_activation_params_iso_dep(ndev,
eb9bc6e9 454 &ntf, data);
e8c0dacd
IE
455 break;
456
457 case NCI_RF_INTERFACE_FRAME:
458 /* no activation params */
459 break;
460
461 default:
637d85a7
IE
462 pr_err("unsupported rf_interface 0x%x\n",
463 ntf.rf_interface);
019c4fba
IE
464 err = NCI_STATUS_RF_PROTOCOL_ERROR;
465 break;
e8c0dacd 466 }
6a2968aa
IE
467 }
468
019c4fba
IE
469exit:
470 if (err == NCI_STATUS_OK) {
471 ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size;
472 ndev->initial_num_credits = ntf.initial_num_credits;
473
474 /* set the available credits to initial value */
475 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
476 }
477
478 if (atomic_read(&ndev->state) == NCI_DISCOVERY) {
479 /* A single target was found and activated automatically */
480 atomic_set(&ndev->state, NCI_POLL_ACTIVE);
481 if (err == NCI_STATUS_OK)
482 nci_target_auto_activated(ndev, &ntf);
483 } else { /* ndev->state == NCI_W4_HOST_SELECT */
484 /* A selected target was activated, so complete the request */
485 atomic_set(&ndev->state, NCI_POLL_ACTIVE);
486 nci_req_complete(ndev, err);
487 }
6a2968aa
IE
488}
489
490static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
eb9bc6e9 491 struct sk_buff *skb)
6a2968aa 492{
e8c0dacd 493 struct nci_rf_deactivate_ntf *ntf = (void *) skb->data;
6a2968aa 494
20c239c1 495 pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason);
6a2968aa 496
6a2968aa
IE
497 /* drop tx data queue */
498 skb_queue_purge(&ndev->tx_q);
499
500 /* drop partial rx data packet */
501 if (ndev->rx_data_reassembly) {
502 kfree_skb(ndev->rx_data_reassembly);
799030b7 503 ndev->rx_data_reassembly = NULL;
6a2968aa
IE
504 }
505
506 /* complete the data exchange transaction, if exists */
38f04c6b 507 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags))
6a2968aa 508 nci_data_exchange_complete(ndev, NULL, -EIO);
bd7e01bc 509
019c4fba
IE
510 nci_clear_target_list(ndev);
511 atomic_set(&ndev->state, NCI_IDLE);
bd7e01bc 512 nci_req_complete(ndev, NCI_STATUS_OK);
6a2968aa
IE
513}
514
515void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
516{
517 __u16 ntf_opcode = nci_opcode(skb->data);
518
20c239c1
JP
519 pr_debug("NCI RX: MT=ntf, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n",
520 nci_pbf(skb->data),
521 nci_opcode_gid(ntf_opcode),
522 nci_opcode_oid(ntf_opcode),
523 nci_plen(skb->data));
6a2968aa
IE
524
525 /* strip the nci control header */
526 skb_pull(skb, NCI_CTRL_HDR_SIZE);
527
528 switch (ntf_opcode) {
529 case NCI_OP_CORE_CONN_CREDITS_NTF:
530 nci_core_conn_credits_ntf_packet(ndev, skb);
531 break;
532
019c4fba
IE
533 case NCI_OP_CORE_GENERIC_ERROR_NTF:
534 nci_core_generic_error_ntf_packet(ndev, skb);
535 break;
536
004161cb
IE
537 case NCI_OP_CORE_INTF_ERROR_NTF:
538 nci_core_conn_intf_error_ntf_packet(ndev, skb);
539 break;
540
019c4fba
IE
541 case NCI_OP_RF_DISCOVER_NTF:
542 nci_rf_discover_ntf_packet(ndev, skb);
543 break;
544
e8c0dacd
IE
545 case NCI_OP_RF_INTF_ACTIVATED_NTF:
546 nci_rf_intf_activated_ntf_packet(ndev, skb);
6a2968aa
IE
547 break;
548
549 case NCI_OP_RF_DEACTIVATE_NTF:
550 nci_rf_deactivate_ntf_packet(ndev, skb);
551 break;
552
553 default:
ed1e0ad8 554 pr_err("unknown ntf opcode 0x%x\n", ntf_opcode);
6a2968aa
IE
555 break;
556 }
557
558 kfree_skb(skb);
559}
This page took 0.090035 seconds and 5 git commands to generate.