diff options
author | Ilan Elias <ilane@ti.com> | 2011-11-09 05:09:14 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-11 12:32:50 -0500 |
commit | e8c0dacd9836dc2dcb28d236c9cc3cfaa9965a20 (patch) | |
tree | afc78589cb1a21a25d6ef0e1ad5532451bc47838 /net/nfc/nci/ntf.c | |
parent | e999882a052a2959571989b2db2b51893d23c0bb (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>
Diffstat (limited to 'net/nfc/nci/ntf.c')
-rw-r--r-- | net/nfc/nci/ntf.c | 137 |
1 files changed, 87 insertions, 50 deletions
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 | ||
77 | static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, | 77 | static __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: | 108 | static 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 | ||
135 | static void nci_target_found(struct nci_dev *ndev, | 133 | static 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 | ||
161 | static void nci_rf_activate_ntf_packet(struct nci_dev *ndev, | 161 | static 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 | ||
198 | static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, | 235 | static 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: |