Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 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 |
Jeff Kirsher | 98b32de | 2013-12-06 08:56:16 -0800 | [diff] [blame] | 23 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 24 | * |
| 25 | */ |
| 26 | |
Samuel Ortiz | 52858b5 | 2011-12-14 16:43:05 +0100 | [diff] [blame] | 27 | #define pr_fmt(fmt) KBUILD_MODNAME ": %s: " fmt, __func__ |
Joe Perches | ed1e0ad | 2011-11-29 11:37:32 -0800 | [diff] [blame] | 28 | |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 29 | #include <linux/types.h> |
| 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/bitops.h> |
| 32 | #include <linux/skbuff.h> |
| 33 | |
| 34 | #include "../nfc.h" |
| 35 | #include <net/nfc/nci.h> |
| 36 | #include <net/nfc/nci_core.h> |
| 37 | #include <linux/nfc.h> |
| 38 | |
| 39 | /* Handle NCI Notification packets */ |
| 40 | |
| 41 | static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 42 | struct sk_buff *skb) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 43 | { |
| 44 | struct nci_core_conn_credit_ntf *ntf = (void *) skb->data; |
| 45 | int i; |
| 46 | |
Joe Perches | 24bf330 | 2011-11-29 11:37:35 -0800 | [diff] [blame] | 47 | pr_debug("num_entries %d\n", ntf->num_entries); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 48 | |
| 49 | if (ntf->num_entries > NCI_MAX_NUM_CONN) |
| 50 | ntf->num_entries = NCI_MAX_NUM_CONN; |
| 51 | |
| 52 | /* update the credits */ |
| 53 | for (i = 0; i < ntf->num_entries; i++) { |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 54 | ntf->conn_entries[i].conn_id = |
| 55 | nci_conn_id(&ntf->conn_entries[i].conn_id); |
| 56 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 57 | pr_debug("entry[%d]: conn_id %d, credits %d\n", |
| 58 | i, ntf->conn_entries[i].conn_id, |
| 59 | ntf->conn_entries[i].credits); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 60 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 61 | if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) { |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 62 | /* found static rf connection */ |
| 63 | atomic_add(ntf->conn_entries[i].credits, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 64 | &ndev->credits_cnt); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
| 68 | /* trigger the next tx */ |
| 69 | if (!skb_queue_empty(&ndev->tx_q)) |
| 70 | queue_work(ndev->tx_wq, &ndev->tx_work); |
| 71 | } |
| 72 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 73 | static void nci_core_generic_error_ntf_packet(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 74 | struct sk_buff *skb) |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 75 | { |
| 76 | __u8 status = skb->data[0]; |
| 77 | |
| 78 | pr_debug("status 0x%x\n", status); |
| 79 | |
| 80 | if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) { |
| 81 | /* Activation failed, so complete the request |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 82 | (the state remains the same) */ |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 83 | nci_req_complete(ndev, status); |
| 84 | } |
| 85 | } |
| 86 | |
Ilan Elias | 004161c | 2011-12-20 16:57:41 +0200 | [diff] [blame] | 87 | static void nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev, |
| 88 | struct sk_buff *skb) |
| 89 | { |
| 90 | struct nci_core_intf_error_ntf *ntf = (void *) skb->data; |
| 91 | |
| 92 | ntf->conn_id = nci_conn_id(&ntf->conn_id); |
| 93 | |
| 94 | pr_debug("status 0x%x, conn_id %d\n", ntf->status, ntf->conn_id); |
| 95 | |
| 96 | /* complete the data exchange transaction, if exists */ |
| 97 | if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) |
| 98 | nci_data_exchange_complete(ndev, NULL, -EIO); |
| 99 | } |
| 100 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 101 | static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 102 | struct rf_tech_specific_params_nfca_poll *nfca_poll, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 103 | __u8 *data) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 104 | { |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 105 | nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); |
| 106 | data += 2; |
| 107 | |
Dan Rosenberg | 67de956 | 2012-06-25 16:05:27 +0200 | [diff] [blame] | 108 | nfca_poll->nfcid1_len = min_t(__u8, *data++, NFC_NFCID1_MAXSIZE); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 109 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 110 | pr_debug("sens_res 0x%x, nfcid1_len %d\n", |
| 111 | nfca_poll->sens_res, nfca_poll->nfcid1_len); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 112 | |
| 113 | memcpy(nfca_poll->nfcid1, data, nfca_poll->nfcid1_len); |
| 114 | data += nfca_poll->nfcid1_len; |
| 115 | |
| 116 | nfca_poll->sel_res_len = *data++; |
| 117 | |
| 118 | if (nfca_poll->sel_res_len != 0) |
| 119 | nfca_poll->sel_res = *data++; |
| 120 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 121 | pr_debug("sel_res_len %d, sel_res 0x%x\n", |
| 122 | nfca_poll->sel_res_len, |
| 123 | nfca_poll->sel_res); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 124 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 125 | return data; |
| 126 | } |
| 127 | |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 128 | static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 129 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 130 | __u8 *data) |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 131 | { |
Dan Rosenberg | 67de956 | 2012-06-25 16:05:27 +0200 | [diff] [blame] | 132 | nfcb_poll->sensb_res_len = min_t(__u8, *data++, NFC_SENSB_RES_MAXSIZE); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 133 | |
| 134 | pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len); |
| 135 | |
| 136 | memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len); |
| 137 | data += nfcb_poll->sensb_res_len; |
| 138 | |
| 139 | return data; |
| 140 | } |
| 141 | |
| 142 | static __u8 *nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 143 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 144 | __u8 *data) |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 145 | { |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 146 | nfcf_poll->bit_rate = *data++; |
Dan Rosenberg | 67de956 | 2012-06-25 16:05:27 +0200 | [diff] [blame] | 147 | nfcf_poll->sensf_res_len = min_t(__u8, *data++, NFC_SENSF_RES_MAXSIZE); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 148 | |
| 149 | pr_debug("bit_rate %d, sensf_res_len %d\n", |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 150 | nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 151 | |
| 152 | memcpy(nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len); |
| 153 | data += nfcf_poll->sensf_res_len; |
| 154 | |
| 155 | return data; |
| 156 | } |
| 157 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 158 | static int nci_add_new_protocol(struct nci_dev *ndev, |
| 159 | struct nfc_target *target, |
| 160 | __u8 rf_protocol, |
| 161 | __u8 rf_tech_and_mode, |
| 162 | void *params) |
| 163 | { |
| 164 | struct rf_tech_specific_params_nfca_poll *nfca_poll; |
| 165 | struct rf_tech_specific_params_nfcb_poll *nfcb_poll; |
| 166 | struct rf_tech_specific_params_nfcf_poll *nfcf_poll; |
| 167 | __u32 protocol; |
| 168 | |
| 169 | if (rf_protocol == NCI_RF_PROTOCOL_T2T) |
| 170 | protocol = NFC_PROTO_MIFARE_MASK; |
| 171 | else if (rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) |
Samuel Ortiz | 01d719a | 2012-07-04 00:14:04 +0200 | [diff] [blame] | 172 | if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) |
| 173 | protocol = NFC_PROTO_ISO14443_MASK; |
| 174 | else |
| 175 | protocol = NFC_PROTO_ISO14443_B_MASK; |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 176 | else if (rf_protocol == NCI_RF_PROTOCOL_T3T) |
| 177 | protocol = NFC_PROTO_FELICA_MASK; |
Ilan Elias | 767f19a | 2012-08-15 11:46:24 +0300 | [diff] [blame] | 178 | else if (rf_protocol == NCI_RF_PROTOCOL_NFC_DEP) |
| 179 | protocol = NFC_PROTO_NFC_DEP_MASK; |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 180 | else |
| 181 | protocol = 0; |
| 182 | |
| 183 | if (!(protocol & ndev->poll_prots)) { |
| 184 | pr_err("the target found does not have the desired protocol\n"); |
| 185 | return -EPROTO; |
| 186 | } |
| 187 | |
| 188 | if (rf_tech_and_mode == NCI_NFC_A_PASSIVE_POLL_MODE) { |
| 189 | nfca_poll = (struct rf_tech_specific_params_nfca_poll *)params; |
| 190 | |
| 191 | target->sens_res = nfca_poll->sens_res; |
| 192 | target->sel_res = nfca_poll->sel_res; |
| 193 | target->nfcid1_len = nfca_poll->nfcid1_len; |
| 194 | if (target->nfcid1_len > 0) { |
| 195 | memcpy(target->nfcid1, nfca_poll->nfcid1, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 196 | target->nfcid1_len); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 197 | } |
| 198 | } else if (rf_tech_and_mode == NCI_NFC_B_PASSIVE_POLL_MODE) { |
| 199 | nfcb_poll = (struct rf_tech_specific_params_nfcb_poll *)params; |
| 200 | |
| 201 | target->sensb_res_len = nfcb_poll->sensb_res_len; |
| 202 | if (target->sensb_res_len > 0) { |
| 203 | memcpy(target->sensb_res, nfcb_poll->sensb_res, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 204 | target->sensb_res_len); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 205 | } |
| 206 | } else if (rf_tech_and_mode == NCI_NFC_F_PASSIVE_POLL_MODE) { |
| 207 | nfcf_poll = (struct rf_tech_specific_params_nfcf_poll *)params; |
| 208 | |
| 209 | target->sensf_res_len = nfcf_poll->sensf_res_len; |
| 210 | if (target->sensf_res_len > 0) { |
| 211 | memcpy(target->sensf_res, nfcf_poll->sensf_res, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 212 | target->sensf_res_len); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 213 | } |
| 214 | } else { |
| 215 | pr_err("unsupported rf_tech_and_mode 0x%x\n", rf_tech_and_mode); |
| 216 | return -EPROTO; |
| 217 | } |
| 218 | |
| 219 | target->supported_protocols |= protocol; |
| 220 | |
| 221 | pr_debug("protocol 0x%x\n", protocol); |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | static void nci_add_new_target(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 227 | struct nci_rf_discover_ntf *ntf) |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 228 | { |
| 229 | struct nfc_target *target; |
| 230 | int i, rc; |
| 231 | |
| 232 | for (i = 0; i < ndev->n_targets; i++) { |
| 233 | target = &ndev->targets[i]; |
Samuel Ortiz | c4fbb65 | 2012-04-10 19:43:09 +0200 | [diff] [blame] | 234 | if (target->logical_idx == ntf->rf_discovery_id) { |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 235 | /* This target already exists, add the new protocol */ |
| 236 | nci_add_new_protocol(ndev, target, ntf->rf_protocol, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 237 | ntf->rf_tech_and_mode, |
| 238 | &ntf->rf_tech_specific_params); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 239 | return; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | /* This is a new target, check if we've enough room */ |
| 244 | if (ndev->n_targets == NCI_MAX_DISCOVERED_TARGETS) { |
| 245 | pr_debug("not enough room, ignoring new target...\n"); |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | target = &ndev->targets[ndev->n_targets]; |
| 250 | |
| 251 | rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 252 | ntf->rf_tech_and_mode, |
| 253 | &ntf->rf_tech_specific_params); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 254 | if (!rc) { |
Samuel Ortiz | c4fbb65 | 2012-04-10 19:43:09 +0200 | [diff] [blame] | 255 | target->logical_idx = ntf->rf_discovery_id; |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 256 | ndev->n_targets++; |
| 257 | |
Samuel Ortiz | c4fbb65 | 2012-04-10 19:43:09 +0200 | [diff] [blame] | 258 | pr_debug("logical idx %d, n_targets %d\n", target->logical_idx, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 259 | ndev->n_targets); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
| 263 | void nci_clear_target_list(struct nci_dev *ndev) |
| 264 | { |
| 265 | memset(ndev->targets, 0, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 266 | (sizeof(struct nfc_target)*NCI_MAX_DISCOVERED_TARGETS)); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 267 | |
| 268 | ndev->n_targets = 0; |
| 269 | } |
| 270 | |
| 271 | static void nci_rf_discover_ntf_packet(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 272 | struct sk_buff *skb) |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 273 | { |
| 274 | struct nci_rf_discover_ntf ntf; |
| 275 | __u8 *data = skb->data; |
| 276 | bool add_target = true; |
| 277 | |
| 278 | ntf.rf_discovery_id = *data++; |
| 279 | ntf.rf_protocol = *data++; |
| 280 | ntf.rf_tech_and_mode = *data++; |
| 281 | ntf.rf_tech_specific_params_len = *data++; |
| 282 | |
| 283 | pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id); |
| 284 | pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol); |
| 285 | pr_debug("rf_tech_and_mode 0x%x\n", ntf.rf_tech_and_mode); |
| 286 | pr_debug("rf_tech_specific_params_len %d\n", |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 287 | ntf.rf_tech_specific_params_len); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 288 | |
| 289 | if (ntf.rf_tech_specific_params_len > 0) { |
| 290 | switch (ntf.rf_tech_and_mode) { |
| 291 | case NCI_NFC_A_PASSIVE_POLL_MODE: |
| 292 | data = nci_extract_rf_params_nfca_passive_poll(ndev, |
| 293 | &(ntf.rf_tech_specific_params.nfca_poll), data); |
| 294 | break; |
| 295 | |
| 296 | case NCI_NFC_B_PASSIVE_POLL_MODE: |
| 297 | data = nci_extract_rf_params_nfcb_passive_poll(ndev, |
| 298 | &(ntf.rf_tech_specific_params.nfcb_poll), data); |
| 299 | break; |
| 300 | |
| 301 | case NCI_NFC_F_PASSIVE_POLL_MODE: |
| 302 | data = nci_extract_rf_params_nfcf_passive_poll(ndev, |
| 303 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
| 304 | break; |
| 305 | |
| 306 | default: |
| 307 | pr_err("unsupported rf_tech_and_mode 0x%x\n", |
| 308 | ntf.rf_tech_and_mode); |
| 309 | data += ntf.rf_tech_specific_params_len; |
| 310 | add_target = false; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | ntf.ntf_type = *data++; |
| 315 | pr_debug("ntf_type %d\n", ntf.ntf_type); |
| 316 | |
| 317 | if (add_target == true) |
| 318 | nci_add_new_target(ndev, &ntf); |
| 319 | |
| 320 | if (ntf.ntf_type == NCI_DISCOVER_NTF_TYPE_MORE) { |
| 321 | atomic_set(&ndev->state, NCI_W4_ALL_DISCOVERIES); |
| 322 | } else { |
| 323 | atomic_set(&ndev->state, NCI_W4_HOST_SELECT); |
| 324 | nfc_targets_found(ndev->nfc_dev, ndev->targets, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 325 | ndev->n_targets); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 329 | static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, |
| 330 | struct nci_rf_intf_activated_ntf *ntf, __u8 *data) |
| 331 | { |
| 332 | struct activation_params_nfca_poll_iso_dep *nfca_poll; |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 333 | struct activation_params_nfcb_poll_iso_dep *nfcb_poll; |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 334 | |
| 335 | switch (ntf->activation_rf_tech_and_mode) { |
| 336 | case NCI_NFC_A_PASSIVE_POLL_MODE: |
| 337 | nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; |
Dan Rosenberg | 67de956 | 2012-06-25 16:05:27 +0200 | [diff] [blame] | 338 | nfca_poll->rats_res_len = min_t(__u8, *data++, 20); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 339 | pr_debug("rats_res_len %d\n", nfca_poll->rats_res_len); |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 340 | if (nfca_poll->rats_res_len > 0) { |
| 341 | memcpy(nfca_poll->rats_res, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 342 | data, nfca_poll->rats_res_len); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 343 | } |
| 344 | break; |
| 345 | |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 346 | case NCI_NFC_B_PASSIVE_POLL_MODE: |
| 347 | nfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep; |
Dan Rosenberg | 67de956 | 2012-06-25 16:05:27 +0200 | [diff] [blame] | 348 | nfcb_poll->attrib_res_len = min_t(__u8, *data++, 50); |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 349 | pr_debug("attrib_res_len %d\n", nfcb_poll->attrib_res_len); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 350 | if (nfcb_poll->attrib_res_len > 0) { |
| 351 | memcpy(nfcb_poll->attrib_res, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 352 | data, nfcb_poll->attrib_res_len); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 353 | } |
| 354 | break; |
| 355 | |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 356 | default: |
Joe Perches | ed1e0ad | 2011-11-29 11:37:32 -0800 | [diff] [blame] | 357 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", |
| 358 | ntf->activation_rf_tech_and_mode); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 359 | return NCI_STATUS_RF_PROTOCOL_ERROR; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 360 | } |
| 361 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 362 | return NCI_STATUS_OK; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 363 | } |
| 364 | |
Ilan Elias | ac20683 | 2012-08-15 11:46:23 +0300 | [diff] [blame] | 365 | static int nci_extract_activation_params_nfc_dep(struct nci_dev *ndev, |
| 366 | struct nci_rf_intf_activated_ntf *ntf, __u8 *data) |
| 367 | { |
| 368 | struct activation_params_poll_nfc_dep *poll; |
| 369 | int i; |
| 370 | |
| 371 | switch (ntf->activation_rf_tech_and_mode) { |
| 372 | case NCI_NFC_A_PASSIVE_POLL_MODE: |
| 373 | case NCI_NFC_F_PASSIVE_POLL_MODE: |
| 374 | poll = &ntf->activation_params.poll_nfc_dep; |
| 375 | poll->atr_res_len = min_t(__u8, *data++, 63); |
| 376 | pr_debug("atr_res_len %d\n", poll->atr_res_len); |
| 377 | if (poll->atr_res_len > 0) { |
| 378 | for (i = 0; i < poll->atr_res_len; i++) |
| 379 | poll->atr_res[poll->atr_res_len-1-i] = data[i]; |
| 380 | } |
| 381 | break; |
| 382 | |
| 383 | default: |
| 384 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", |
| 385 | ntf->activation_rf_tech_and_mode); |
| 386 | return NCI_STATUS_RF_PROTOCOL_ERROR; |
| 387 | } |
| 388 | |
| 389 | return NCI_STATUS_OK; |
| 390 | } |
| 391 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 392 | static void nci_target_auto_activated(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 393 | struct nci_rf_intf_activated_ntf *ntf) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 394 | { |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 395 | struct nfc_target *target; |
| 396 | int rc; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 397 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 398 | target = &ndev->targets[ndev->n_targets]; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 399 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 400 | rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 401 | ntf->activation_rf_tech_and_mode, |
| 402 | &ntf->rf_tech_specific_params); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 403 | if (rc) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 404 | return; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 405 | |
Samuel Ortiz | c4fbb65 | 2012-04-10 19:43:09 +0200 | [diff] [blame] | 406 | target->logical_idx = ntf->rf_discovery_id; |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 407 | ndev->n_targets++; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 408 | |
Samuel Ortiz | c4fbb65 | 2012-04-10 19:43:09 +0200 | [diff] [blame] | 409 | pr_debug("logical idx %d, n_targets %d\n", |
| 410 | target->logical_idx, ndev->n_targets); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 411 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 412 | nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 413 | } |
| 414 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 415 | static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 416 | struct sk_buff *skb) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 417 | { |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 418 | struct nci_rf_intf_activated_ntf ntf; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 419 | __u8 *data = skb->data; |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 420 | int err = NCI_STATUS_OK; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 421 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 422 | ntf.rf_discovery_id = *data++; |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 423 | ntf.rf_interface = *data++; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 424 | ntf.rf_protocol = *data++; |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 425 | ntf.activation_rf_tech_and_mode = *data++; |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 426 | ntf.max_data_pkt_payload_size = *data++; |
| 427 | ntf.initial_num_credits = *data++; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 428 | ntf.rf_tech_specific_params_len = *data++; |
| 429 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 430 | pr_debug("rf_discovery_id %d\n", ntf.rf_discovery_id); |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 431 | pr_debug("rf_interface 0x%x\n", ntf.rf_interface); |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 432 | pr_debug("rf_protocol 0x%x\n", ntf.rf_protocol); |
| 433 | pr_debug("activation_rf_tech_and_mode 0x%x\n", |
| 434 | ntf.activation_rf_tech_and_mode); |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 435 | pr_debug("max_data_pkt_payload_size 0x%x\n", |
| 436 | ntf.max_data_pkt_payload_size); |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 437 | pr_debug("initial_num_credits 0x%x\n", |
| 438 | ntf.initial_num_credits); |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 439 | pr_debug("rf_tech_specific_params_len %d\n", |
| 440 | ntf.rf_tech_specific_params_len); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 441 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 442 | if (ntf.rf_tech_specific_params_len > 0) { |
| 443 | switch (ntf.activation_rf_tech_and_mode) { |
| 444 | case NCI_NFC_A_PASSIVE_POLL_MODE: |
| 445 | data = nci_extract_rf_params_nfca_passive_poll(ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 446 | &(ntf.rf_tech_specific_params.nfca_poll), data); |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 447 | break; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 448 | |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 449 | case NCI_NFC_B_PASSIVE_POLL_MODE: |
| 450 | data = nci_extract_rf_params_nfcb_passive_poll(ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 451 | &(ntf.rf_tech_specific_params.nfcb_poll), data); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 452 | break; |
| 453 | |
| 454 | case NCI_NFC_F_PASSIVE_POLL_MODE: |
| 455 | data = nci_extract_rf_params_nfcf_passive_poll(ndev, |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 456 | &(ntf.rf_tech_specific_params.nfcf_poll), data); |
Ilan Elias | d5a2ca6 | 2012-01-17 11:06:43 +0200 | [diff] [blame] | 457 | break; |
| 458 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 459 | default: |
Joe Perches | ed1e0ad | 2011-11-29 11:37:32 -0800 | [diff] [blame] | 460 | pr_err("unsupported activation_rf_tech_and_mode 0x%x\n", |
| 461 | ntf.activation_rf_tech_and_mode); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 462 | err = NCI_STATUS_RF_PROTOCOL_ERROR; |
| 463 | goto exit; |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 464 | } |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 465 | } |
| 466 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 467 | ntf.data_exch_rf_tech_and_mode = *data++; |
| 468 | ntf.data_exch_tx_bit_rate = *data++; |
| 469 | ntf.data_exch_rx_bit_rate = *data++; |
| 470 | ntf.activation_params_len = *data++; |
| 471 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 472 | pr_debug("data_exch_rf_tech_and_mode 0x%x\n", |
| 473 | ntf.data_exch_rf_tech_and_mode); |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 474 | pr_debug("data_exch_tx_bit_rate 0x%x\n", ntf.data_exch_tx_bit_rate); |
| 475 | pr_debug("data_exch_rx_bit_rate 0x%x\n", ntf.data_exch_rx_bit_rate); |
| 476 | pr_debug("activation_params_len %d\n", ntf.activation_params_len); |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 477 | |
| 478 | if (ntf.activation_params_len > 0) { |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 479 | switch (ntf.rf_interface) { |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 480 | case NCI_RF_INTERFACE_ISO_DEP: |
| 481 | err = nci_extract_activation_params_iso_dep(ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 482 | &ntf, data); |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 483 | break; |
| 484 | |
Ilan Elias | ac20683 | 2012-08-15 11:46:23 +0300 | [diff] [blame] | 485 | case NCI_RF_INTERFACE_NFC_DEP: |
| 486 | err = nci_extract_activation_params_nfc_dep(ndev, |
| 487 | &ntf, data); |
| 488 | break; |
| 489 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 490 | case NCI_RF_INTERFACE_FRAME: |
| 491 | /* no activation params */ |
| 492 | break; |
| 493 | |
| 494 | default: |
Ilan Elias | 637d85a | 2011-12-20 16:57:40 +0200 | [diff] [blame] | 495 | pr_err("unsupported rf_interface 0x%x\n", |
| 496 | ntf.rf_interface); |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 497 | err = NCI_STATUS_RF_PROTOCOL_ERROR; |
| 498 | break; |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 502 | exit: |
| 503 | if (err == NCI_STATUS_OK) { |
| 504 | ndev->max_data_pkt_payload_size = ntf.max_data_pkt_payload_size; |
| 505 | ndev->initial_num_credits = ntf.initial_num_credits; |
| 506 | |
| 507 | /* set the available credits to initial value */ |
| 508 | atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); |
Ilan Elias | 767f19a | 2012-08-15 11:46:24 +0300 | [diff] [blame] | 509 | |
| 510 | /* store general bytes to be reported later in dep_link_up */ |
| 511 | if (ntf.rf_interface == NCI_RF_INTERFACE_NFC_DEP) { |
| 512 | ndev->remote_gb_len = 0; |
| 513 | |
| 514 | if (ntf.activation_params_len > 0) { |
| 515 | /* ATR_RES general bytes at offset 15 */ |
| 516 | ndev->remote_gb_len = min_t(__u8, |
| 517 | (ntf.activation_params |
| 518 | .poll_nfc_dep.atr_res_len |
| 519 | - NFC_ATR_RES_GT_OFFSET), |
| 520 | NFC_MAX_GT_LEN); |
| 521 | memcpy(ndev->remote_gb, |
| 522 | (ntf.activation_params.poll_nfc_dep |
| 523 | .atr_res + NFC_ATR_RES_GT_OFFSET), |
| 524 | ndev->remote_gb_len); |
| 525 | } |
| 526 | } |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | if (atomic_read(&ndev->state) == NCI_DISCOVERY) { |
| 530 | /* A single target was found and activated automatically */ |
| 531 | atomic_set(&ndev->state, NCI_POLL_ACTIVE); |
| 532 | if (err == NCI_STATUS_OK) |
| 533 | nci_target_auto_activated(ndev, &ntf); |
| 534 | } else { /* ndev->state == NCI_W4_HOST_SELECT */ |
| 535 | /* A selected target was activated, so complete the request */ |
| 536 | atomic_set(&ndev->state, NCI_POLL_ACTIVE); |
| 537 | nci_req_complete(ndev, err); |
| 538 | } |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, |
Samuel Ortiz | eb9bc6e | 2012-03-05 01:03:54 +0100 | [diff] [blame] | 542 | struct sk_buff *skb) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 543 | { |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 544 | struct nci_rf_deactivate_ntf *ntf = (void *) skb->data; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 545 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 546 | pr_debug("entry, type 0x%x, reason 0x%x\n", ntf->type, ntf->reason); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 547 | |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 548 | /* drop tx data queue */ |
| 549 | skb_queue_purge(&ndev->tx_q); |
| 550 | |
| 551 | /* drop partial rx data packet */ |
| 552 | if (ndev->rx_data_reassembly) { |
| 553 | kfree_skb(ndev->rx_data_reassembly); |
H Hartley Sweeten | 799030b | 2012-05-07 12:31:26 +0200 | [diff] [blame] | 554 | ndev->rx_data_reassembly = NULL; |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | /* complete the data exchange transaction, if exists */ |
Ilan Elias | 38f04c6 | 2011-09-22 11:36:19 +0300 | [diff] [blame] | 558 | if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 559 | nci_data_exchange_complete(ndev, NULL, -EIO); |
Ilan Elias | bd7e01b | 2012-01-08 11:21:53 +0200 | [diff] [blame] | 560 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 561 | nci_clear_target_list(ndev); |
| 562 | atomic_set(&ndev->state, NCI_IDLE); |
Ilan Elias | bd7e01b | 2012-01-08 11:21:53 +0200 | [diff] [blame] | 563 | nci_req_complete(ndev, NCI_STATUS_OK); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb) |
| 567 | { |
| 568 | __u16 ntf_opcode = nci_opcode(skb->data); |
| 569 | |
Joe Perches | 20c239c | 2011-11-29 11:37:33 -0800 | [diff] [blame] | 570 | pr_debug("NCI RX: MT=ntf, PBF=%d, GID=0x%x, OID=0x%x, plen=%d\n", |
| 571 | nci_pbf(skb->data), |
| 572 | nci_opcode_gid(ntf_opcode), |
| 573 | nci_opcode_oid(ntf_opcode), |
| 574 | nci_plen(skb->data)); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 575 | |
| 576 | /* strip the nci control header */ |
| 577 | skb_pull(skb, NCI_CTRL_HDR_SIZE); |
| 578 | |
| 579 | switch (ntf_opcode) { |
| 580 | case NCI_OP_CORE_CONN_CREDITS_NTF: |
| 581 | nci_core_conn_credits_ntf_packet(ndev, skb); |
| 582 | break; |
| 583 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 584 | case NCI_OP_CORE_GENERIC_ERROR_NTF: |
| 585 | nci_core_generic_error_ntf_packet(ndev, skb); |
| 586 | break; |
| 587 | |
Ilan Elias | 004161c | 2011-12-20 16:57:41 +0200 | [diff] [blame] | 588 | case NCI_OP_CORE_INTF_ERROR_NTF: |
| 589 | nci_core_conn_intf_error_ntf_packet(ndev, skb); |
| 590 | break; |
| 591 | |
Ilan Elias | 019c4fb | 2012-01-18 13:16:14 +0200 | [diff] [blame] | 592 | case NCI_OP_RF_DISCOVER_NTF: |
| 593 | nci_rf_discover_ntf_packet(ndev, skb); |
| 594 | break; |
| 595 | |
Ilan Elias | e8c0dac | 2011-11-09 12:09:14 +0200 | [diff] [blame] | 596 | case NCI_OP_RF_INTF_ACTIVATED_NTF: |
| 597 | nci_rf_intf_activated_ntf_packet(ndev, skb); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 598 | break; |
| 599 | |
| 600 | case NCI_OP_RF_DEACTIVATE_NTF: |
| 601 | nci_rf_deactivate_ntf_packet(ndev, skb); |
| 602 | break; |
| 603 | |
| 604 | default: |
Joe Perches | ed1e0ad | 2011-11-29 11:37:32 -0800 | [diff] [blame] | 605 | pr_err("unknown ntf opcode 0x%x\n", ntf_opcode); |
Ilan Elias | 6a2968a | 2011-09-18 11:19:35 +0300 | [diff] [blame] | 606 | break; |
| 607 | } |
| 608 | |
| 609 | kfree_skb(skb); |
| 610 | } |