aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlan Elias <ilane@ti.com>2011-11-09 05:09:14 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-11-11 12:32:50 -0500
commite8c0dacd9836dc2dcb28d236c9cc3cfaa9965a20 (patch)
treeafc78589cb1a21a25d6ef0e1ad5532451bc47838
parente999882a052a2959571989b2db2b51893d23c0bb (diff)
NFC: Update names and structs to NCI spec 1.0 d18
Addition, deletion and modification of NCI constants. Changes in NCI commands, responses and notifications structures. Signed-off-by: Ilan Elias <ilane@ti.com> Acked-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--include/net/nfc/nci.h81
-rw-r--r--include/net/nfc/nci_core.h11
-rw-r--r--net/nfc/nci/core.c7
-rw-r--r--net/nfc/nci/data.c5
-rw-r--r--net/nfc/nci/lib.c8
-rw-r--r--net/nfc/nci/ntf.c137
-rw-r--r--net/nfc/nci/rsp.c58
7 files changed, 193 insertions, 114 deletions
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h
index 39b85bc0804f..0ebf842b5946 100644
--- a/include/net/nfc/nci.h
+++ b/include/net/nfc/nci.h
@@ -36,24 +36,23 @@
36/* NCI Status Codes */ 36/* NCI Status Codes */
37#define NCI_STATUS_OK 0x00 37#define NCI_STATUS_OK 0x00
38#define NCI_STATUS_REJECTED 0x01 38#define NCI_STATUS_REJECTED 0x01
39#define NCI_STATUS_MESSAGE_CORRUPTED 0x02 39#define NCI_STATUS_RF_FRAME_CORRUPTED 0x02
40#define NCI_STATUS_BUFFER_FULL 0x03 40#define NCI_STATUS_FAILED 0x03
41#define NCI_STATUS_FAILED 0x04 41#define NCI_STATUS_NOT_INITIALIZED 0x04
42#define NCI_STATUS_NOT_INITIALIZED 0x05 42#define NCI_STATUS_SYNTAX_ERROR 0x05
43#define NCI_STATUS_SYNTAX_ERROR 0x06 43#define NCI_STATUS_SEMANTIC_ERROR 0x06
44#define NCI_STATUS_SEMANTIC_ERROR 0x07 44#define NCI_STATUS_UNKNOWN_GID 0x07
45#define NCI_STATUS_UNKNOWN_GID 0x08 45#define NCI_STATUS_UNKNOWN_OID 0x08
46#define NCI_STATUS_UNKNOWN_OID 0x09 46#define NCI_STATUS_INVALID_PARAM 0x09
47#define NCI_STATUS_INVALID_PARAM 0x0a 47#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0a
48#define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0b
49/* Discovery Specific Status Codes */ 48/* Discovery Specific Status Codes */
50#define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0 49#define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0
51#define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1 50#define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1
51#define NCI_STATUS_DISCOVERY_TEAR_DOWN 0xa2
52/* RF Interface Specific Status Codes */ 52/* RF Interface Specific Status Codes */
53#define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0 53#define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0
54#define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1 54#define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1
55#define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2 55#define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2
56#define NCI_STATUS_RF_LINK_LOSS_ERROR 0xb3
57/* NFCEE Interface Specific Status Codes */ 56/* NFCEE Interface Specific Status Codes */
58#define NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED 0xc0 57#define NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED 0xc0
59#define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc1 58#define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc1
@@ -73,6 +72,21 @@
73#define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 72#define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83
74#define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 73#define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85
75 74
75/* NCI RF Technologies */
76#define NCI_NFC_RF_TECHNOLOGY_A 0x00
77#define NCI_NFC_RF_TECHNOLOGY_B 0x01
78#define NCI_NFC_RF_TECHNOLOGY_F 0x02
79#define NCI_NFC_RF_TECHNOLOGY_15693 0x03
80
81/* NCI Bit Rates */
82#define NCI_NFC_BIT_RATE_106 0x00
83#define NCI_NFC_BIT_RATE_212 0x01
84#define NCI_NFC_BIT_RATE_424 0x02
85#define NCI_NFC_BIT_RATE_848 0x03
86#define NCI_NFC_BIT_RATE_1696 0x04
87#define NCI_NFC_BIT_RATE_3392 0x05
88#define NCI_NFC_BIT_RATE_6784 0x06
89
76/* NCI RF Protocols */ 90/* NCI RF Protocols */
77#define NCI_RF_PROTOCOL_UNKNOWN 0x00 91#define NCI_RF_PROTOCOL_UNKNOWN 0x00
78#define NCI_RF_PROTOCOL_T1T 0x01 92#define NCI_RF_PROTOCOL_T1T 0x01
@@ -82,11 +96,18 @@
82#define NCI_RF_PROTOCOL_NFC_DEP 0x05 96#define NCI_RF_PROTOCOL_NFC_DEP 0x05
83 97
84/* NCI RF Interfaces */ 98/* NCI RF Interfaces */
85#define NCI_RF_INTERFACE_RFU 0x00 99#define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00
86#define NCI_RF_INTERFACE_FRAME 0x01 100#define NCI_RF_INTERFACE_FRAME 0x01
87#define NCI_RF_INTERFACE_ISO_DEP 0x02 101#define NCI_RF_INTERFACE_ISO_DEP 0x02
88#define NCI_RF_INTERFACE_NFC_DEP 0x03 102#define NCI_RF_INTERFACE_NFC_DEP 0x03
89 103
104/* NCI Reset types */
105#define NCI_RESET_TYPE_KEEP_CONFIG 0x00
106#define NCI_RESET_TYPE_RESET_CONFIG 0x01
107
108/* NCI Static RF connection ID */
109#define NCI_STATIC_RF_CONN_ID 0x00
110
90/* NCI RF_DISCOVER_MAP_CMD modes */ 111/* NCI RF_DISCOVER_MAP_CMD modes */
91#define NCI_DISC_MAP_MODE_POLL 0x01 112#define NCI_DISC_MAP_MODE_POLL 0x01
92#define NCI_DISC_MAP_MODE_LISTEN 0x02 113#define NCI_DISC_MAP_MODE_LISTEN 0x02
@@ -98,8 +119,6 @@
98#define NCI_DISCOVERY_TYPE_POLL_F_PASSIVE 0x02 119#define NCI_DISCOVERY_TYPE_POLL_F_PASSIVE 0x02
99#define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03 120#define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03
100#define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05 121#define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05
101#define NCI_DISCOVERY_TYPE_WAKEUP_A_PASSIVE 0x06
102#define NCI_DISCOVERY_TYPE_WAKEUP_B_PASSIVE 0x07
103#define NCI_DISCOVERY_TYPE_WAKEUP_A_ACTIVE 0x09 122#define NCI_DISCOVERY_TYPE_WAKEUP_A_ACTIVE 0x09
104#define NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE 0x80 123#define NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE 0x80
105#define NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE 0x81 124#define NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE 0x81
@@ -111,8 +130,7 @@
111#define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 130#define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00
112#define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 131#define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01
113#define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02 132#define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02
114#define NCI_DEACTIVATE_TYPE_RF_LINK_LOSS 0x03 133#define NCI_DEACTIVATE_TYPE_DISCOVERY 0x03
115#define NCI_DEACTIVATE_TYPE_DISCOVERY_ERROR 0x04
116 134
117/* Message Type (MT) */ 135/* Message Type (MT) */
118#define NCI_MT_DATA_PKT 0x00 136#define NCI_MT_DATA_PKT 0x00
@@ -169,6 +187,9 @@ struct nci_data_hdr {
169/* ----- NCI Commands ---- */ 187/* ----- NCI Commands ---- */
170/* ------------------------ */ 188/* ------------------------ */
171#define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00) 189#define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00)
190struct nci_core_reset_cmd {
191 __u8 reset_type;
192} __packed;
172 193
173#define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) 194#define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01)
174 195
@@ -218,6 +239,7 @@ struct nci_rf_deactivate_cmd {
218struct nci_core_reset_rsp { 239struct nci_core_reset_rsp {
219 __u8 status; 240 __u8 status;
220 __u8 nci_ver; 241 __u8 nci_ver;
242 __u8 config_status;
221} __packed; 243} __packed;
222 244
223#define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01) 245#define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01)
@@ -232,10 +254,12 @@ struct nci_core_init_rsp_1 {
232struct nci_core_init_rsp_2 { 254struct nci_core_init_rsp_2 {
233 __u8 max_logical_connections; 255 __u8 max_logical_connections;
234 __le16 max_routing_table_size; 256 __le16 max_routing_table_size;
235 __u8 max_control_packet_payload_length; 257 __u8 max_ctrl_pkt_payload_len;
236 __le16 rf_sending_buffer_size; 258 __le16 max_size_for_large_params;
237 __le16 rf_receiving_buffer_size; 259 __u8 max_data_pkt_payload_size;
238 __le16 manufacturer_id; 260 __u8 initial_num_credits;
261 __u8 manufact_id;
262 __le32 manufact_specific_info;
239} __packed; 263} __packed;
240 264
241#define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) 265#define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02)
@@ -275,7 +299,7 @@ struct nci_rf_field_info_ntf {
275 __u8 rf_field_status; 299 __u8 rf_field_status;
276} __packed; 300} __packed;
277 301
278#define NCI_OP_RF_ACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) 302#define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05)
279struct rf_tech_specific_params_nfca_poll { 303struct rf_tech_specific_params_nfca_poll {
280 __u16 sens_res; 304 __u16 sens_res;
281 __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ 305 __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */
@@ -289,17 +313,20 @@ struct activation_params_nfca_poll_iso_dep {
289 __u8 rats_res[20]; 313 __u8 rats_res[20];
290}; 314};
291 315
292struct nci_rf_activate_ntf { 316struct nci_rf_intf_activated_ntf {
293 __u8 target_handle; 317 __u8 rf_discovery_id;
318 __u8 rf_interface_type;
294 __u8 rf_protocol; 319 __u8 rf_protocol;
295 __u8 rf_tech_and_mode; 320 __u8 activation_rf_tech_and_mode;
296 __u8 rf_tech_specific_params_len; 321 __u8 rf_tech_specific_params_len;
297 322
298 union { 323 union {
299 struct rf_tech_specific_params_nfca_poll nfca_poll; 324 struct rf_tech_specific_params_nfca_poll nfca_poll;
300 } rf_tech_specific_params; 325 } rf_tech_specific_params;
301 326
302 __u8 rf_interface_type; 327 __u8 data_exch_rf_tech_and_mode;
328 __u8 data_exch_tx_bit_rate;
329 __u8 data_exch_rx_bit_rate;
303 __u8 activation_params_len; 330 __u8 activation_params_len;
304 331
305 union { 332 union {
@@ -309,5 +336,9 @@ struct nci_rf_activate_ntf {
309} __packed; 336} __packed;
310 337
311#define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 338#define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06)
339struct nci_rf_deactivate_ntf {
340 __u8 type;
341 __u8 reason;
342} __packed;
312 343
313#endif /* __NCI_H */ 344#endif /* __NCI_H */
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index b8b4bbd7e0fc..6e6a7be485c1 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -109,14 +109,15 @@ struct nci_dev {
109 [NCI_MAX_SUPPORTED_RF_INTERFACES]; 109 [NCI_MAX_SUPPORTED_RF_INTERFACES];
110 __u8 max_logical_connections; 110 __u8 max_logical_connections;
111 __u16 max_routing_table_size; 111 __u16 max_routing_table_size;
112 __u8 max_control_packet_payload_length; 112 __u8 max_ctrl_pkt_payload_len;
113 __u16 rf_sending_buffer_size; 113 __u16 max_size_for_large_params;
114 __u16 rf_receiving_buffer_size; 114 __u8 max_data_pkt_payload_size;
115 __u16 manufacturer_id; 115 __u8 initial_num_credits;
116 __u8 manufact_id;
117 __u32 manufact_specific_info;
116 118
117 /* received during NCI_OP_CORE_CONN_CREATE_RSP for static conn 0 */ 119 /* received during NCI_OP_CORE_CONN_CREATE_RSP for static conn 0 */
118 __u8 max_pkt_payload_size; 120 __u8 max_pkt_payload_size;
119 __u8 initial_num_credits;
120 __u8 conn_id; 121 __u8 conn_id;
121 122
122 /* stored during nci_data_exchange */ 123 /* stored during nci_data_exchange */
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 4047e29acb3b..557fe92d29c7 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -125,7 +125,10 @@ static inline int nci_request(struct nci_dev *ndev,
125 125
126static void nci_reset_req(struct nci_dev *ndev, unsigned long opt) 126static void nci_reset_req(struct nci_dev *ndev, unsigned long opt)
127{ 127{
128 nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 0, NULL); 128 struct nci_core_reset_cmd cmd;
129
130 cmd.reset_type = NCI_RESET_TYPE_RESET_CONFIG;
131 nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd);
129} 132}
130 133
131static void nci_init_req(struct nci_dev *ndev, unsigned long opt) 134static void nci_init_req(struct nci_dev *ndev, unsigned long opt)
@@ -469,7 +472,7 @@ static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
469 ndev->data_exchange_cb = cb; 472 ndev->data_exchange_cb = cb;
470 ndev->data_exchange_cb_context = cb_context; 473 ndev->data_exchange_cb_context = cb_context;
471 474
472 rc = nci_send_data(ndev, ndev->conn_id, skb); 475 rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb);
473 if (rc) 476 if (rc)
474 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); 477 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags);
475 478
diff --git a/net/nfc/nci/data.c b/net/nfc/nci/data.c
index e5ed90fc1a9c..511fb96e21bc 100644
--- a/net/nfc/nci/data.c
+++ b/net/nfc/nci/data.c
@@ -95,7 +95,8 @@ static int nci_queue_tx_data_frags(struct nci_dev *ndev,
95 __skb_queue_head_init(&frags_q); 95 __skb_queue_head_init(&frags_q);
96 96
97 while (total_len) { 97 while (total_len) {
98 frag_len = min_t(int, total_len, ndev->max_pkt_payload_size); 98 frag_len =
99 min_t(int, total_len, ndev->max_data_pkt_payload_size);
99 100
100 skb_frag = nci_skb_alloc(ndev, 101 skb_frag = nci_skb_alloc(ndev,
101 (NCI_DATA_HDR_SIZE + frag_len), 102 (NCI_DATA_HDR_SIZE + frag_len),
@@ -151,7 +152,7 @@ int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb)
151 nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len); 152 nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len);
152 153
153 /* check if the packet need to be fragmented */ 154 /* check if the packet need to be fragmented */
154 if (skb->len <= ndev->max_pkt_payload_size) { 155 if (skb->len <= ndev->max_data_pkt_payload_size) {
155 /* no need to fragment packet */ 156 /* no need to fragment packet */
156 nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); 157 nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST);
157 158
diff --git a/net/nfc/nci/lib.c b/net/nfc/nci/lib.c
index b19dc2fa90e1..e99adcfb1bcf 100644
--- a/net/nfc/nci/lib.c
+++ b/net/nfc/nci/lib.c
@@ -42,12 +42,9 @@ int nci_to_errno(__u8 code)
42 case NCI_STATUS_REJECTED: 42 case NCI_STATUS_REJECTED:
43 return -EBUSY; 43 return -EBUSY;
44 44
45 case NCI_STATUS_MESSAGE_CORRUPTED: 45 case NCI_STATUS_RF_FRAME_CORRUPTED:
46 return -EBADMSG; 46 return -EBADMSG;
47 47
48 case NCI_STATUS_BUFFER_FULL:
49 return -ENOBUFS;
50
51 case NCI_STATUS_NOT_INITIALIZED: 48 case NCI_STATUS_NOT_INITIALIZED:
52 return -EHOSTDOWN; 49 return -EHOSTDOWN;
53 50
@@ -80,9 +77,6 @@ int nci_to_errno(__u8 code)
80 case NCI_STATUS_NFCEE_TIMEOUT_ERROR: 77 case NCI_STATUS_NFCEE_TIMEOUT_ERROR:
81 return -ETIMEDOUT; 78 return -ETIMEDOUT;
82 79
83 case NCI_STATUS_RF_LINK_LOSS_ERROR:
84 return -ENOLINK;
85
86 case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED: 80 case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED:
87 return -EDQUOT; 81 return -EDQUOT;
88 82
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index 96633f5cda4f..6789f4828c0b 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -54,7 +54,7 @@ static void nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,
54 ntf->conn_entries[i].conn_id, 54 ntf->conn_entries[i].conn_id,
55 ntf->conn_entries[i].credits); 55 ntf->conn_entries[i].credits);
56 56
57 if (ntf->conn_entries[i].conn_id == ndev->conn_id) { 57 if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) {
58 /* found static rf connection */ 58 /* found static rf connection */
59 atomic_add(ntf->conn_entries[i].credits, 59 atomic_add(ntf->conn_entries[i].credits,
60 &ndev->credits_cnt); 60 &ndev->credits_cnt);
@@ -74,14 +74,12 @@ static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev,
74 nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status); 74 nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status);
75} 75}
76 76
77static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, 77static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,
78 struct nci_rf_activate_ntf *ntf, __u8 *data) 78 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
79{ 79{
80 struct rf_tech_specific_params_nfca_poll *nfca_poll; 80 struct rf_tech_specific_params_nfca_poll *nfca_poll;
81 struct activation_params_nfca_poll_iso_dep *nfca_poll_iso_dep;
82 81
83 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll; 82 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll;
84 nfca_poll_iso_dep = &ntf->activation_params.nfca_poll_iso_dep;
85 83
86 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); 84 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data));
87 data += 2; 85 data += 2;
@@ -100,32 +98,32 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
100 if (nfca_poll->sel_res_len != 0) 98 if (nfca_poll->sel_res_len != 0)
101 nfca_poll->sel_res = *data++; 99 nfca_poll->sel_res = *data++;
102 100
103 ntf->rf_interface_type = *data++; 101 nfc_dbg("sel_res_len %d, sel_res 0x%x",
104 ntf->activation_params_len = *data++;
105
106 nfc_dbg("sel_res_len %d, sel_res 0x%x, rf_interface_type %d, activation_params_len %d",
107 nfca_poll->sel_res_len, 102 nfca_poll->sel_res_len,
108 nfca_poll->sel_res, 103 nfca_poll->sel_res);
109 ntf->rf_interface_type, 104
110 ntf->activation_params_len); 105 return data;
111 106}
112 switch (ntf->rf_interface_type) { 107
113 case NCI_RF_INTERFACE_ISO_DEP: 108static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,
114 nfca_poll_iso_dep->rats_res_len = *data++; 109 struct nci_rf_intf_activated_ntf *ntf, __u8 *data)
115 if (nfca_poll_iso_dep->rats_res_len > 0) { 110{
116 memcpy(nfca_poll_iso_dep->rats_res, 111 struct activation_params_nfca_poll_iso_dep *nfca_poll;
112
113 switch (ntf->activation_rf_tech_and_mode) {
114 case NCI_NFC_A_PASSIVE_POLL_MODE:
115 nfca_poll = &ntf->activation_params.nfca_poll_iso_dep;
116 nfca_poll->rats_res_len = *data++;
117 if (nfca_poll->rats_res_len > 0) {
118 memcpy(nfca_poll->rats_res,
117 data, 119 data,
118 nfca_poll_iso_dep->rats_res_len); 120 nfca_poll->rats_res_len);
119 } 121 }
120 break; 122 break;
121 123
122 case NCI_RF_INTERFACE_FRAME:
123 /* no activation params */
124 break;
125
126 default: 124 default:
127 nfc_err("unsupported rf_interface_type 0x%x", 125 nfc_err("unsupported activation_rf_tech_and_mode 0x%x",
128 ntf->rf_interface_type); 126 ntf->activation_rf_tech_and_mode);
129 return -EPROTO; 127 return -EPROTO;
130 } 128 }
131 129
@@ -133,7 +131,7 @@ static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev,
133} 131}
134 132
135static void nci_target_found(struct nci_dev *ndev, 133static void nci_target_found(struct nci_dev *ndev,
136 struct nci_rf_activate_ntf *ntf) 134 struct nci_rf_intf_activated_ntf *ntf)
137{ 135{
138 struct nfc_target nfc_tgt; 136 struct nfc_target nfc_tgt;
139 137
@@ -141,6 +139,8 @@ static void nci_target_found(struct nci_dev *ndev,
141 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; 139 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK;
142 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */ 140 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */
143 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; 141 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK;
142 else
143 nfc_tgt.supported_protocols = 0;
144 144
145 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; 145 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res;
146 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; 146 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res;
@@ -158,49 +158,86 @@ static void nci_target_found(struct nci_dev *ndev,
158 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1); 158 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1);
159} 159}
160 160
161static void nci_rf_activate_ntf_packet(struct nci_dev *ndev, 161static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,
162 struct sk_buff *skb) 162 struct sk_buff *skb)
163{ 163{
164 struct nci_rf_activate_ntf ntf; 164 struct nci_rf_intf_activated_ntf ntf;
165 __u8 *data = skb->data; 165 __u8 *data = skb->data;
166 int rc = -1; 166 int err = 0;
167 167
168 clear_bit(NCI_DISCOVERY, &ndev->flags); 168 clear_bit(NCI_DISCOVERY, &ndev->flags);
169 set_bit(NCI_POLL_ACTIVE, &ndev->flags); 169 set_bit(NCI_POLL_ACTIVE, &ndev->flags);
170 170
171 ntf.target_handle = *data++; 171 ntf.rf_discovery_id = *data++;
172 ntf.rf_interface_type = *data++;
172 ntf.rf_protocol = *data++; 173 ntf.rf_protocol = *data++;
173 ntf.rf_tech_and_mode = *data++; 174 ntf.activation_rf_tech_and_mode = *data++;
174 ntf.rf_tech_specific_params_len = *data++; 175 ntf.rf_tech_specific_params_len = *data++;
175 176
176 nfc_dbg("target_handle %d, rf_protocol 0x%x, rf_tech_and_mode 0x%x, rf_tech_specific_params_len %d", 177 nfc_dbg("rf_discovery_id %d", ntf.rf_discovery_id);
177 ntf.target_handle, 178 nfc_dbg("rf_interface_type 0x%x", ntf.rf_interface_type);
178 ntf.rf_protocol, 179 nfc_dbg("rf_protocol 0x%x", ntf.rf_protocol);
179 ntf.rf_tech_and_mode, 180 nfc_dbg("activation_rf_tech_and_mode 0x%x",
181 ntf.activation_rf_tech_and_mode);
182 nfc_dbg("rf_tech_specific_params_len %d",
180 ntf.rf_tech_specific_params_len); 183 ntf.rf_tech_specific_params_len);
181 184
182 switch (ntf.rf_tech_and_mode) { 185 if (ntf.rf_tech_specific_params_len > 0) {
183 case NCI_NFC_A_PASSIVE_POLL_MODE: 186 switch (ntf.activation_rf_tech_and_mode) {
184 rc = nci_rf_activate_nfca_passive_poll(ndev, &ntf, 187 case NCI_NFC_A_PASSIVE_POLL_MODE:
185 data); 188 data = nci_extract_rf_params_nfca_passive_poll(ndev,
186 break; 189 &ntf, data);
190 break;
191
192 default:
193 nfc_err("unsupported activation_rf_tech_and_mode 0x%x",
194 ntf.activation_rf_tech_and_mode);
195 return;
196 }
197 }
187 198
188 default: 199 ntf.data_exch_rf_tech_and_mode = *data++;
189 nfc_err("unsupported rf_tech_and_mode 0x%x", 200 ntf.data_exch_tx_bit_rate = *data++;
190 ntf.rf_tech_and_mode); 201 ntf.data_exch_rx_bit_rate = *data++;
191 return; 202 ntf.activation_params_len = *data++;
203
204 nfc_dbg("data_exch_rf_tech_and_mode 0x%x",
205 ntf.data_exch_rf_tech_and_mode);
206 nfc_dbg("data_exch_tx_bit_rate 0x%x",
207 ntf.data_exch_tx_bit_rate);
208 nfc_dbg("data_exch_rx_bit_rate 0x%x",
209 ntf.data_exch_rx_bit_rate);
210 nfc_dbg("activation_params_len %d",
211 ntf.activation_params_len);
212
213 if (ntf.activation_params_len > 0) {
214 switch (ntf.rf_interface_type) {
215 case NCI_RF_INTERFACE_ISO_DEP:
216 err = nci_extract_activation_params_iso_dep(ndev,
217 &ntf, data);
218 break;
219
220 case NCI_RF_INTERFACE_FRAME:
221 /* no activation params */
222 break;
223
224 default:
225 nfc_err("unsupported rf_interface_type 0x%x",
226 ntf.rf_interface_type);
227 return;
228 }
192 } 229 }
193 230
194 if (!rc) 231 if (!err)
195 nci_target_found(ndev, &ntf); 232 nci_target_found(ndev, &ntf);
196} 233}
197 234
198static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, 235static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev,
199 struct sk_buff *skb) 236 struct sk_buff *skb)
200{ 237{
201 __u8 type = skb->data[0]; 238 struct nci_rf_deactivate_ntf *ntf = (void *) skb->data;
202 239
203 nfc_dbg("entry, type 0x%x", type); 240 nfc_dbg("entry, type 0x%x, reason 0x%x", ntf->type, ntf->reason);
204 241
205 clear_bit(NCI_POLL_ACTIVE, &ndev->flags); 242 clear_bit(NCI_POLL_ACTIVE, &ndev->flags);
206 ndev->target_active_prot = 0; 243 ndev->target_active_prot = 0;
@@ -241,8 +278,8 @@ void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb)
241 nci_rf_field_info_ntf_packet(ndev, skb); 278 nci_rf_field_info_ntf_packet(ndev, skb);
242 break; 279 break;
243 280
244 case NCI_OP_RF_ACTIVATE_NTF: 281 case NCI_OP_RF_INTF_ACTIVATED_NTF:
245 nci_rf_activate_ntf_packet(ndev, skb); 282 nci_rf_intf_activated_ntf_packet(ndev, skb);
246 break; 283 break;
247 284
248 case NCI_OP_RF_DEACTIVATE_NTF: 285 case NCI_OP_RF_DEACTIVATE_NTF:
diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c
index 0403d4cd0917..64fc58a6e28b 100644
--- a/net/nfc/nci/rsp.c
+++ b/net/nfc/nci/rsp.c
@@ -42,10 +42,11 @@ static void nci_core_reset_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
42 42
43 nfc_dbg("entry, status 0x%x", rsp->status); 43 nfc_dbg("entry, status 0x%x", rsp->status);
44 44
45 if (rsp->status == NCI_STATUS_OK) 45 if (rsp->status == NCI_STATUS_OK) {
46 ndev->nci_ver = rsp->nci_ver; 46 ndev->nci_ver = rsp->nci_ver;
47 47 nfc_dbg("nci_ver 0x%x, config_status 0x%x",
48 nfc_dbg("nci_ver 0x%x", ndev->nci_ver); 48 rsp->nci_ver, rsp->config_status);
49 }
49 50
50 nci_req_complete(ndev, rsp->status); 51 nci_req_complete(ndev, rsp->status);
51} 52}
@@ -58,13 +59,13 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
58 nfc_dbg("entry, status 0x%x", rsp_1->status); 59 nfc_dbg("entry, status 0x%x", rsp_1->status);
59 60
60 if (rsp_1->status != NCI_STATUS_OK) 61 if (rsp_1->status != NCI_STATUS_OK)
61 return; 62 goto exit;
62 63
63 ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features); 64 ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features);
64 ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces; 65 ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces;
65 66
66 if (ndev->num_supported_rf_interfaces > 67 if (ndev->num_supported_rf_interfaces >
67 NCI_MAX_SUPPORTED_RF_INTERFACES) { 68 NCI_MAX_SUPPORTED_RF_INTERFACES) {
68 ndev->num_supported_rf_interfaces = 69 ndev->num_supported_rf_interfaces =
69 NCI_MAX_SUPPORTED_RF_INTERFACES; 70 NCI_MAX_SUPPORTED_RF_INTERFACES;
70 } 71 }
@@ -73,20 +74,26 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
73 rsp_1->supported_rf_interfaces, 74 rsp_1->supported_rf_interfaces,
74 ndev->num_supported_rf_interfaces); 75 ndev->num_supported_rf_interfaces);
75 76
76 rsp_2 = (void *) (skb->data + 6 + ndev->num_supported_rf_interfaces); 77 rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces);
77 78
78 ndev->max_logical_connections = 79 ndev->max_logical_connections =
79 rsp_2->max_logical_connections; 80 rsp_2->max_logical_connections;
80 ndev->max_routing_table_size = 81 ndev->max_routing_table_size =
81 __le16_to_cpu(rsp_2->max_routing_table_size); 82 __le16_to_cpu(rsp_2->max_routing_table_size);
82 ndev->max_control_packet_payload_length = 83 ndev->max_ctrl_pkt_payload_len =
83 rsp_2->max_control_packet_payload_length; 84 rsp_2->max_ctrl_pkt_payload_len;
84 ndev->rf_sending_buffer_size = 85 ndev->max_size_for_large_params =
85 __le16_to_cpu(rsp_2->rf_sending_buffer_size); 86 __le16_to_cpu(rsp_2->max_size_for_large_params);
86 ndev->rf_receiving_buffer_size = 87 ndev->max_data_pkt_payload_size =
87 __le16_to_cpu(rsp_2->rf_receiving_buffer_size); 88 rsp_2->max_data_pkt_payload_size;
88 ndev->manufacturer_id = 89 ndev->initial_num_credits =
89 __le16_to_cpu(rsp_2->manufacturer_id); 90 rsp_2->initial_num_credits;
91 ndev->manufact_id =
92 rsp_2->manufact_id;
93 ndev->manufact_specific_info =
94 __le32_to_cpu(rsp_2->manufact_specific_info);
95
96 atomic_set(&ndev->credits_cnt, ndev->initial_num_credits);
90 97
91 nfc_dbg("nfcc_features 0x%x", 98 nfc_dbg("nfcc_features 0x%x",
92 ndev->nfcc_features); 99 ndev->nfcc_features);
@@ -104,15 +111,20 @@ static void nci_core_init_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb)
104 ndev->max_logical_connections); 111 ndev->max_logical_connections);
105 nfc_dbg("max_routing_table_size %d", 112 nfc_dbg("max_routing_table_size %d",
106 ndev->max_routing_table_size); 113 ndev->max_routing_table_size);
107 nfc_dbg("max_control_packet_payload_length %d", 114 nfc_dbg("max_ctrl_pkt_payload_len %d",
108 ndev->max_control_packet_payload_length); 115 ndev->max_ctrl_pkt_payload_len);
109 nfc_dbg("rf_sending_buffer_size %d", 116 nfc_dbg("max_size_for_large_params %d",
110 ndev->rf_sending_buffer_size); 117 ndev->max_size_for_large_params);
111 nfc_dbg("rf_receiving_buffer_size %d", 118 nfc_dbg("max_data_pkt_payload_size %d",
112 ndev->rf_receiving_buffer_size); 119 ndev->max_data_pkt_payload_size);
113 nfc_dbg("manufacturer_id 0x%x", 120 nfc_dbg("initial_num_credits %d",
114 ndev->manufacturer_id); 121 ndev->initial_num_credits);
115 122 nfc_dbg("manufact_id 0x%x",
123 ndev->manufact_id);
124 nfc_dbg("manufact_specific_info 0x%x",
125 ndev->manufact_specific_info);
126
127exit:
116 nci_req_complete(ndev, rsp_1->status); 128 nci_req_complete(ndev, rsp_1->status);
117} 129}
118 130