aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/net/bluetooth/a2mp.h150
-rw-r--r--include/net/bluetooth/amp.h54
-rw-r--r--include/net/bluetooth/bluetooth.h5
-rw-r--r--include/net/bluetooth/hci.h49
-rw-r--r--include/net/bluetooth/hci_core.h79
-rw-r--r--include/net/bluetooth/l2cap.h14
-rw-r--r--include/net/bluetooth/mgmt.h7
-rw-r--r--include/net/bluetooth/rfcomm.h2
-rw-r--r--include/net/bluetooth/sco.h5
-rw-r--r--include/net/bluetooth/smp.h146
-rw-r--r--include/net/cfg80211.h9
-rw-r--r--include/net/nfc/digital.h227
-rw-r--r--include/net/nfc/hci.h6
-rw-r--r--include/net/nfc/nci.h4
-rw-r--r--include/net/nfc/nci_core.h46
-rw-r--r--include/net/nfc/nfc.h25
-rw-r--r--include/uapi/linux/nfc.h4
17 files changed, 365 insertions, 467 deletions
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h
deleted file mode 100644
index 487b54c1308f..000000000000
--- a/include/net/bluetooth/a2mp.h
+++ /dev/null
@@ -1,150 +0,0 @@
1/*
2 Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved.
3 Copyright (c) 2011,2012 Intel Corp.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 and
7 only version 2 as published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13*/
14
15#ifndef __A2MP_H
16#define __A2MP_H
17
18#include <net/bluetooth/l2cap.h>
19
20#define A2MP_FEAT_EXT 0x8000
21
22enum amp_mgr_state {
23 READ_LOC_AMP_INFO,
24 READ_LOC_AMP_ASSOC,
25 READ_LOC_AMP_ASSOC_FINAL,
26 WRITE_REMOTE_AMP_ASSOC,
27};
28
29struct amp_mgr {
30 struct list_head list;
31 struct l2cap_conn *l2cap_conn;
32 struct l2cap_chan *a2mp_chan;
33 struct l2cap_chan *bredr_chan;
34 struct kref kref;
35 __u8 ident;
36 __u8 handle;
37 unsigned long state;
38 unsigned long flags;
39
40 struct list_head amp_ctrls;
41 struct mutex amp_ctrls_lock;
42};
43
44struct a2mp_cmd {
45 __u8 code;
46 __u8 ident;
47 __le16 len;
48 __u8 data[0];
49} __packed;
50
51/* A2MP command codes */
52#define A2MP_COMMAND_REJ 0x01
53struct a2mp_cmd_rej {
54 __le16 reason;
55 __u8 data[0];
56} __packed;
57
58#define A2MP_DISCOVER_REQ 0x02
59struct a2mp_discov_req {
60 __le16 mtu;
61 __le16 ext_feat;
62} __packed;
63
64struct a2mp_cl {
65 __u8 id;
66 __u8 type;
67 __u8 status;
68} __packed;
69
70#define A2MP_DISCOVER_RSP 0x03
71struct a2mp_discov_rsp {
72 __le16 mtu;
73 __le16 ext_feat;
74 struct a2mp_cl cl[0];
75} __packed;
76
77#define A2MP_CHANGE_NOTIFY 0x04
78#define A2MP_CHANGE_RSP 0x05
79
80#define A2MP_GETINFO_REQ 0x06
81struct a2mp_info_req {
82 __u8 id;
83} __packed;
84
85#define A2MP_GETINFO_RSP 0x07
86struct a2mp_info_rsp {
87 __u8 id;
88 __u8 status;
89 __le32 total_bw;
90 __le32 max_bw;
91 __le32 min_latency;
92 __le16 pal_cap;
93 __le16 assoc_size;
94} __packed;
95
96#define A2MP_GETAMPASSOC_REQ 0x08
97struct a2mp_amp_assoc_req {
98 __u8 id;
99} __packed;
100
101#define A2MP_GETAMPASSOC_RSP 0x09
102struct a2mp_amp_assoc_rsp {
103 __u8 id;
104 __u8 status;
105 __u8 amp_assoc[0];
106} __packed;
107
108#define A2MP_CREATEPHYSLINK_REQ 0x0A
109#define A2MP_DISCONNPHYSLINK_REQ 0x0C
110struct a2mp_physlink_req {
111 __u8 local_id;
112 __u8 remote_id;
113 __u8 amp_assoc[0];
114} __packed;
115
116#define A2MP_CREATEPHYSLINK_RSP 0x0B
117#define A2MP_DISCONNPHYSLINK_RSP 0x0D
118struct a2mp_physlink_rsp {
119 __u8 local_id;
120 __u8 remote_id;
121 __u8 status;
122} __packed;
123
124/* A2MP response status */
125#define A2MP_STATUS_SUCCESS 0x00
126#define A2MP_STATUS_INVALID_CTRL_ID 0x01
127#define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
128#define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
129#define A2MP_STATUS_COLLISION_OCCURED 0x03
130#define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
131#define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
132#define A2MP_STATUS_SECURITY_VIOLATION 0x06
133
134extern struct list_head amp_mgr_list;
135extern struct mutex amp_mgr_list_lock;
136
137struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
138int amp_mgr_put(struct amp_mgr *mgr);
139u8 __next_ident(struct amp_mgr *mgr);
140struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
141 struct sk_buff *skb);
142struct amp_mgr *amp_mgr_lookup_by_state(u8 state);
143void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data);
144void a2mp_discover_amp(struct l2cap_chan *chan);
145void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
146void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
147void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
148void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status);
149
150#endif /* __A2MP_H */
diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h
deleted file mode 100644
index 7ea3db77ba89..000000000000
--- a/include/net/bluetooth/amp.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 Copyright (c) 2011,2012 Intel Corp.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License version 2 and
6 only version 2 as published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*/
13
14#ifndef __AMP_H
15#define __AMP_H
16
17struct amp_ctrl {
18 struct list_head list;
19 struct kref kref;
20 __u8 id;
21 __u16 assoc_len_so_far;
22 __u16 assoc_rem_len;
23 __u16 assoc_len;
24 __u8 *assoc;
25};
26
27int amp_ctrl_put(struct amp_ctrl *ctrl);
28void amp_ctrl_get(struct amp_ctrl *ctrl);
29struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id);
30struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id);
31void amp_ctrl_list_flush(struct amp_mgr *mgr);
32
33struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr,
34 u8 remote_id, bool out);
35
36int phylink_gen_key(struct hci_conn *hcon, u8 *data, u8 *len, u8 *type);
37
38void amp_read_loc_info(struct hci_dev *hdev, struct amp_mgr *mgr);
39void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle);
40void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr);
41void amp_read_loc_assoc_final_data(struct hci_dev *hdev,
42 struct hci_conn *hcon);
43void amp_create_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
44 struct hci_conn *hcon);
45void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
46 struct hci_conn *hcon);
47void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
48void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
49void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon);
50void amp_create_logical_link(struct l2cap_chan *chan);
51void amp_disconnect_logical_link(struct hci_chan *hchan);
52void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason);
53
54#endif /* __AMP_H */
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index d0de412bfa43..2cc9517fb0d5 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -218,11 +218,10 @@ void baswap(bdaddr_t *dst, bdaddr_t *src);
218 218
219struct bt_sock { 219struct bt_sock {
220 struct sock sk; 220 struct sock sk;
221 bdaddr_t src;
222 bdaddr_t dst;
223 struct list_head accept_q; 221 struct list_head accept_q;
224 struct sock *parent; 222 struct sock *parent;
225 unsigned long flags; 223 unsigned long flags;
224 void (*skb_msg_name)(struct sk_buff *, void *, int *);
226}; 225};
227 226
228enum { 227enum {
@@ -285,6 +284,8 @@ struct bt_skb_cb {
285 __u8 force_active; 284 __u8 force_active;
286 struct l2cap_ctrl control; 285 struct l2cap_ctrl control;
287 struct hci_req_ctrl req; 286 struct hci_req_ctrl req;
287 bdaddr_t bdaddr;
288 __le16 psm;
288}; 289};
289#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 290#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
290 291
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index b90eec5e9c06..b096f5f73789 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -64,16 +64,20 @@
64#define HCI_AMP 0x01 64#define HCI_AMP 0x01
65 65
66/* First BR/EDR Controller shall have ID = 0 */ 66/* First BR/EDR Controller shall have ID = 0 */
67#define HCI_BREDR_ID 0 67#define AMP_ID_BREDR 0x00
68
69/* AMP controller types */
70#define AMP_TYPE_BREDR 0x00
71#define AMP_TYPE_80211 0x01
68 72
69/* AMP controller status */ 73/* AMP controller status */
70#define AMP_CTRL_POWERED_DOWN 0x00 74#define AMP_STATUS_POWERED_DOWN 0x00
71#define AMP_CTRL_BLUETOOTH_ONLY 0x01 75#define AMP_STATUS_BLUETOOTH_ONLY 0x01
72#define AMP_CTRL_NO_CAPACITY 0x02 76#define AMP_STATUS_NO_CAPACITY 0x02
73#define AMP_CTRL_LOW_CAPACITY 0x03 77#define AMP_STATUS_LOW_CAPACITY 0x03
74#define AMP_CTRL_MEDIUM_CAPACITY 0x04 78#define AMP_STATUS_MEDIUM_CAPACITY 0x04
75#define AMP_CTRL_HIGH_CAPACITY 0x05 79#define AMP_STATUS_HIGH_CAPACITY 0x05
76#define AMP_CTRL_FULL_CAPACITY 0x06 80#define AMP_STATUS_FULL_CAPACITY 0x06
77 81
78/* HCI device quirks */ 82/* HCI device quirks */
79enum { 83enum {
@@ -118,7 +122,7 @@ enum {
118 HCI_SSP_ENABLED, 122 HCI_SSP_ENABLED,
119 HCI_HS_ENABLED, 123 HCI_HS_ENABLED,
120 HCI_LE_ENABLED, 124 HCI_LE_ENABLED,
121 HCI_LE_PERIPHERAL, 125 HCI_ADVERTISING,
122 HCI_CONNECTABLE, 126 HCI_CONNECTABLE,
123 HCI_DISCOVERABLE, 127 HCI_DISCOVERABLE,
124 HCI_LINK_SECURITY, 128 HCI_LINK_SECURITY,
@@ -811,6 +815,14 @@ struct hci_cp_host_buffer_size {
811 __le16 sco_max_pkt; 815 __le16 sco_max_pkt;
812} __packed; 816} __packed;
813 817
818#define HCI_OP_READ_NUM_SUPPORTED_IAC 0x0c38
819struct hci_rp_read_num_supported_iac {
820 __u8 status;
821 __u8 num_iac;
822} __packed;
823
824#define HCI_OP_READ_CURRENT_IAC_LAP 0x0c39
825
814#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45 826#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
815 827
816#define HCI_MAX_EIR_LENGTH 240 828#define HCI_MAX_EIR_LENGTH 240
@@ -847,6 +859,8 @@ struct hci_rp_read_inq_rsp_tx_power {
847 859
848#define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63 860#define HCI_OP_SET_EVENT_MASK_PAGE_2 0x0c63
849 861
862#define HCI_OP_READ_LOCATION_DATA 0x0c64
863
850#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66 864#define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
851struct hci_rp_read_flow_control_mode { 865struct hci_rp_read_flow_control_mode {
852 __u8 status; 866 __u8 status;
@@ -1042,6 +1056,23 @@ struct hci_rp_le_read_local_features {
1042 1056
1043#define HCI_OP_LE_SET_RANDOM_ADDR 0x2005 1057#define HCI_OP_LE_SET_RANDOM_ADDR 0x2005
1044 1058
1059#define LE_ADV_IND 0x00
1060#define LE_ADV_DIRECT_IND 0x01
1061#define LE_ADV_SCAN_IND 0x02
1062#define LE_ADV_NONCONN_IND 0x03
1063
1064#define HCI_OP_LE_SET_ADV_PARAM 0x2006
1065struct hci_cp_le_set_adv_param {
1066 __le16 min_interval;
1067 __le16 max_interval;
1068 __u8 type;
1069 __u8 own_address_type;
1070 __u8 direct_addr_type;
1071 bdaddr_t direct_addr;
1072 __u8 channel_map;
1073 __u8 filter_policy;
1074} __packed;
1075
1045#define HCI_OP_LE_READ_ADV_TX_POWER 0x2007 1076#define HCI_OP_LE_READ_ADV_TX_POWER 0x2007
1046struct hci_rp_le_read_adv_tx_power { 1077struct hci_rp_le_read_adv_tx_power {
1047 __u8 status; 1078 __u8 status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e3ea48d6c992..2dc467939be7 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -159,11 +159,14 @@ struct hci_dev {
159 __u16 manufacturer; 159 __u16 manufacturer;
160 __u16 lmp_subver; 160 __u16 lmp_subver;
161 __u16 voice_setting; 161 __u16 voice_setting;
162 __u8 num_iac;
162 __u8 io_capability; 163 __u8 io_capability;
163 __s8 inq_tx_power; 164 __s8 inq_tx_power;
164 __u16 page_scan_interval; 165 __u16 page_scan_interval;
165 __u16 page_scan_window; 166 __u16 page_scan_window;
166 __u8 page_scan_type; 167 __u8 page_scan_type;
168 __u16 le_scan_interval;
169 __u16 le_scan_window;
167 170
168 __u16 devid_source; 171 __u16 devid_source;
169 __u16 devid_vendor; 172 __u16 devid_vendor;
@@ -285,9 +288,8 @@ struct hci_dev {
285 int (*close)(struct hci_dev *hdev); 288 int (*close)(struct hci_dev *hdev);
286 int (*flush)(struct hci_dev *hdev); 289 int (*flush)(struct hci_dev *hdev);
287 int (*setup)(struct hci_dev *hdev); 290 int (*setup)(struct hci_dev *hdev);
288 int (*send)(struct sk_buff *skb); 291 int (*send)(struct hci_dev *hdev, struct sk_buff *skb);
289 void (*notify)(struct hci_dev *hdev, unsigned int evt); 292 void (*notify)(struct hci_dev *hdev, unsigned int evt);
290 int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
291}; 293};
292 294
293#define HCI_PHY_HANDLE(handle) (handle & 0xff) 295#define HCI_PHY_HANDLE(handle) (handle & 0xff)
@@ -299,6 +301,8 @@ struct hci_conn {
299 301
300 bdaddr_t dst; 302 bdaddr_t dst;
301 __u8 dst_type; 303 __u8 dst_type;
304 bdaddr_t src;
305 __u8 src_type;
302 __u16 handle; 306 __u16 handle;
303 __u16 state; 307 __u16 state;
304 __u8 mode; 308 __u8 mode;
@@ -703,19 +707,6 @@ static inline void hci_set_drvdata(struct hci_dev *hdev, void *data)
703 dev_set_drvdata(&hdev->dev, data); 707 dev_set_drvdata(&hdev->dev, data);
704} 708}
705 709
706/* hci_dev_list shall be locked */
707static inline uint8_t __hci_num_ctrl(void)
708{
709 uint8_t count = 0;
710 struct list_head *p;
711
712 list_for_each(p, &hci_dev_list) {
713 count++;
714 }
715
716 return count;
717}
718
719struct hci_dev *hci_dev_get(int index); 710struct hci_dev *hci_dev_get(int index);
720struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); 711struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src);
721 712
@@ -768,7 +759,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
768 759
769void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 760void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
770 761
771int hci_recv_frame(struct sk_buff *skb); 762int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb);
772int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); 763int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
773int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); 764int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
774 765
@@ -807,22 +798,6 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
807#define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) 798#define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE))
808#define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) 799#define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR))
809 800
810/* returns true if at least one AMP active */
811static inline bool hci_amp_capable(void)
812{
813 struct hci_dev *hdev;
814 bool ret = false;
815
816 read_lock(&hci_dev_list_lock);
817 list_for_each_entry(hdev, &hci_dev_list, list)
818 if (hdev->amp_type == HCI_AMP &&
819 test_bit(HCI_UP, &hdev->flags))
820 ret = true;
821 read_unlock(&hci_dev_list_lock);
822
823 return ret;
824}
825
826/* ----- HCI protocols ----- */ 801/* ----- HCI protocols ----- */
827#define HCI_PROTO_DEFER 0x01 802#define HCI_PROTO_DEFER 0x01
828 803
@@ -1120,24 +1095,24 @@ void hci_sock_dev_event(struct hci_dev *hdev, int event);
1120#define DISCOV_BREDR_INQUIRY_LEN 0x08 1095#define DISCOV_BREDR_INQUIRY_LEN 0x08
1121 1096
1122int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); 1097int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
1123int mgmt_index_added(struct hci_dev *hdev); 1098void mgmt_index_added(struct hci_dev *hdev);
1124int mgmt_index_removed(struct hci_dev *hdev); 1099void mgmt_index_removed(struct hci_dev *hdev);
1125int mgmt_set_powered_failed(struct hci_dev *hdev, int err); 1100void mgmt_set_powered_failed(struct hci_dev *hdev, int err);
1126int mgmt_powered(struct hci_dev *hdev, u8 powered); 1101int mgmt_powered(struct hci_dev *hdev, u8 powered);
1127int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); 1102int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable);
1128int mgmt_connectable(struct hci_dev *hdev, u8 connectable); 1103int mgmt_connectable(struct hci_dev *hdev, u8 connectable);
1129int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); 1104int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status);
1130int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, 1105int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
1131 bool persistent); 1106 bool persistent);
1132int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1107void mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1133 u8 addr_type, u32 flags, u8 *name, u8 name_len, 1108 u8 addr_type, u32 flags, u8 *name, u8 name_len,
1134 u8 *dev_class); 1109 u8 *dev_class);
1135int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, 1110void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
1136 u8 link_type, u8 addr_type, u8 reason); 1111 u8 link_type, u8 addr_type, u8 reason);
1137int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, 1112void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
1138 u8 link_type, u8 addr_type, u8 status); 1113 u8 link_type, u8 addr_type, u8 status);
1139int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1114void mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1140 u8 addr_type, u8 status); 1115 u8 addr_type, u8 status);
1141int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); 1116int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure);
1142int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 1117int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
1143 u8 status); 1118 u8 status);
@@ -1168,16 +1143,16 @@ int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class,
1168int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); 1143int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
1169int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, 1144int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
1170 u8 *randomizer, u8 status); 1145 u8 *randomizer, u8 status);
1171int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1146void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1172 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, 1147 u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name,
1173 u8 ssp, u8 *eir, u16 eir_len); 1148 u8 ssp, u8 *eir, u16 eir_len);
1174int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, 1149void mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
1175 u8 addr_type, s8 rssi, u8 *name, u8 name_len); 1150 u8 addr_type, s8 rssi, u8 *name, u8 name_len);
1176int mgmt_discovering(struct hci_dev *hdev, u8 discovering); 1151void mgmt_discovering(struct hci_dev *hdev, u8 discovering);
1177int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 1152int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
1178int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 1153int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
1179bool mgmt_valid_hdev(struct hci_dev *hdev);
1180int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); 1154int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent);
1155void mgmt_reenable_advertising(struct hci_dev *hdev);
1181 1156
1182/* HCI info for socket */ 1157/* HCI info for socket */
1183#define hci_pi(sk) ((struct hci_pinfo *) sk) 1158#define hci_pi(sk) ((struct hci_pinfo *) sk)
@@ -1214,8 +1189,6 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
1214void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], 1189void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
1215 __u8 ltk[16]); 1190 __u8 ltk[16]);
1216 1191
1217u8 bdaddr_to_le(u8 bdaddr_type);
1218
1219#define SCO_AIRMODE_MASK 0x0003 1192#define SCO_AIRMODE_MASK 0x0003
1220#define SCO_AIRMODE_CVSD 0x0000 1193#define SCO_AIRMODE_CVSD 0x0000
1221#define SCO_AIRMODE_TRANSP 0x0003 1194#define SCO_AIRMODE_TRANSP 0x0003
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f141b5f6e4f1..07757a2af942 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -131,6 +131,7 @@ struct l2cap_conninfo {
131 131
132/* L2CAP fixed channels */ 132/* L2CAP fixed channels */
133#define L2CAP_FC_L2CAP 0x02 133#define L2CAP_FC_L2CAP 0x02
134#define L2CAP_FC_CONNLESS 0x04
134#define L2CAP_FC_A2MP 0x08 135#define L2CAP_FC_A2MP 0x08
135 136
136/* L2CAP Control Field bit masks */ 137/* L2CAP Control Field bit masks */
@@ -237,6 +238,7 @@ struct l2cap_conn_rsp {
237/* protocol/service multiplexer (PSM) */ 238/* protocol/service multiplexer (PSM) */
238#define L2CAP_PSM_SDP 0x0001 239#define L2CAP_PSM_SDP 0x0001
239#define L2CAP_PSM_RFCOMM 0x0003 240#define L2CAP_PSM_RFCOMM 0x0003
241#define L2CAP_PSM_3DSP 0x0021
240 242
241/* channel indentifier */ 243/* channel indentifier */
242#define L2CAP_CID_SIGNALING 0x0001 244#define L2CAP_CID_SIGNALING 0x0001
@@ -442,7 +444,12 @@ struct l2cap_chan {
442 444
443 __u8 state; 445 __u8 state;
444 446
447 bdaddr_t dst;
448 __u8 dst_type;
449 bdaddr_t src;
450 __u8 src_type;
445 __le16 psm; 451 __le16 psm;
452 __le16 sport;
446 __u16 dcid; 453 __u16 dcid;
447 __u16 scid; 454 __u16 scid;
448 455
@@ -453,8 +460,6 @@ struct l2cap_chan {
453 __u8 chan_type; 460 __u8 chan_type;
454 __u8 chan_policy; 461 __u8 chan_policy;
455 462
456 __le16 sport;
457
458 __u8 sec_level; 463 __u8 sec_level;
459 464
460 __u8 ident; 465 __u8 ident;
@@ -549,6 +554,7 @@ struct l2cap_ops {
549 int state); 554 int state);
550 void (*ready) (struct l2cap_chan *chan); 555 void (*ready) (struct l2cap_chan *chan);
551 void (*defer) (struct l2cap_chan *chan); 556 void (*defer) (struct l2cap_chan *chan);
557 void (*resume) (struct l2cap_chan *chan);
552 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, 558 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
553 unsigned long len, int nb); 559 unsigned long len, int nb);
554}; 560};
@@ -557,9 +563,6 @@ struct l2cap_conn {
557 struct hci_conn *hcon; 563 struct hci_conn *hcon;
558 struct hci_chan *hchan; 564 struct hci_chan *hchan;
559 565
560 bdaddr_t *dst;
561 bdaddr_t *src;
562
563 unsigned int mtu; 566 unsigned int mtu;
564 567
565 __u32 feat_mask; 568 __u32 feat_mask;
@@ -650,6 +653,7 @@ enum {
650 FLAG_FLUSHABLE, 653 FLAG_FLUSHABLE,
651 FLAG_EXT_CTRL, 654 FLAG_EXT_CTRL,
652 FLAG_EFS_ENABLE, 655 FLAG_EFS_ENABLE,
656 FLAG_DEFER_SETUP,
653}; 657};
654 658
655enum { 659enum {
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 2ad433bb9a2e..518c5c84e39a 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -362,6 +362,13 @@ struct mgmt_cp_set_static_address {
362} __packed; 362} __packed;
363#define MGMT_SET_STATIC_ADDRESS_SIZE 6 363#define MGMT_SET_STATIC_ADDRESS_SIZE 6
364 364
365#define MGMT_OP_SET_SCAN_PARAMS 0x002C
366struct mgmt_cp_set_scan_params {
367 __le16 interval;
368 __le16 window;
369} __packed;
370#define MGMT_SET_SCAN_PARAMS_SIZE 4
371
365#define MGMT_EV_CMD_COMPLETE 0x0001 372#define MGMT_EV_CMD_COMPLETE 0x0001
366struct mgmt_ev_cmd_complete { 373struct mgmt_ev_cmd_complete {
367 __le16 opcode; 374 __le16 opcode;
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index b7f43e76a5c5..486213a1aed8 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -300,6 +300,8 @@ struct rfcomm_conninfo {
300 300
301struct rfcomm_pinfo { 301struct rfcomm_pinfo {
302 struct bt_sock bt; 302 struct bt_sock bt;
303 bdaddr_t src;
304 bdaddr_t dst;
303 struct rfcomm_dlc *dlc; 305 struct rfcomm_dlc *dlc;
304 u8 channel; 306 u8 channel;
305 u8 sec_level; 307 u8 sec_level;
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h
index e252a31ee6b6..2019d1a0996a 100644
--- a/include/net/bluetooth/sco.h
+++ b/include/net/bluetooth/sco.h
@@ -55,9 +55,6 @@ struct sco_conninfo {
55struct sco_conn { 55struct sco_conn {
56 struct hci_conn *hcon; 56 struct hci_conn *hcon;
57 57
58 bdaddr_t *dst;
59 bdaddr_t *src;
60
61 spinlock_t lock; 58 spinlock_t lock;
62 struct sock *sk; 59 struct sock *sk;
63 60
@@ -72,6 +69,8 @@ struct sco_conn {
72 69
73struct sco_pinfo { 70struct sco_pinfo {
74 struct bt_sock bt; 71 struct bt_sock bt;
72 bdaddr_t src;
73 bdaddr_t dst;
75 __u32 flags; 74 __u32 flags;
76 __u16 setting; 75 __u16 setting;
77 struct sco_conn *conn; 76 struct sco_conn *conn;
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
deleted file mode 100644
index f8ba07f3e5fa..000000000000
--- a/include/net/bluetooth/smp.h
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation;
8
9 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
12 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
13 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
18 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
19 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
20 SOFTWARE IS DISCLAIMED.
21*/
22
23#ifndef __SMP_H
24#define __SMP_H
25
26struct smp_command_hdr {
27 __u8 code;
28} __packed;
29
30#define SMP_CMD_PAIRING_REQ 0x01
31#define SMP_CMD_PAIRING_RSP 0x02
32struct smp_cmd_pairing {
33 __u8 io_capability;
34 __u8 oob_flag;
35 __u8 auth_req;
36 __u8 max_key_size;
37 __u8 init_key_dist;
38 __u8 resp_key_dist;
39} __packed;
40
41#define SMP_IO_DISPLAY_ONLY 0x00
42#define SMP_IO_DISPLAY_YESNO 0x01
43#define SMP_IO_KEYBOARD_ONLY 0x02
44#define SMP_IO_NO_INPUT_OUTPUT 0x03
45#define SMP_IO_KEYBOARD_DISPLAY 0x04
46
47#define SMP_OOB_NOT_PRESENT 0x00
48#define SMP_OOB_PRESENT 0x01
49
50#define SMP_DIST_ENC_KEY 0x01
51#define SMP_DIST_ID_KEY 0x02
52#define SMP_DIST_SIGN 0x04
53
54#define SMP_AUTH_NONE 0x00
55#define SMP_AUTH_BONDING 0x01
56#define SMP_AUTH_MITM 0x04
57
58#define SMP_CMD_PAIRING_CONFIRM 0x03
59struct smp_cmd_pairing_confirm {
60 __u8 confirm_val[16];
61} __packed;
62
63#define SMP_CMD_PAIRING_RANDOM 0x04
64struct smp_cmd_pairing_random {
65 __u8 rand_val[16];
66} __packed;
67
68#define SMP_CMD_PAIRING_FAIL 0x05
69struct smp_cmd_pairing_fail {
70 __u8 reason;
71} __packed;
72
73#define SMP_CMD_ENCRYPT_INFO 0x06
74struct smp_cmd_encrypt_info {
75 __u8 ltk[16];
76} __packed;
77
78#define SMP_CMD_MASTER_IDENT 0x07
79struct smp_cmd_master_ident {
80 __le16 ediv;
81 __u8 rand[8];
82} __packed;
83
84#define SMP_CMD_IDENT_INFO 0x08
85struct smp_cmd_ident_info {
86 __u8 irk[16];
87} __packed;
88
89#define SMP_CMD_IDENT_ADDR_INFO 0x09
90struct smp_cmd_ident_addr_info {
91 __u8 addr_type;
92 bdaddr_t bdaddr;
93} __packed;
94
95#define SMP_CMD_SIGN_INFO 0x0a
96struct smp_cmd_sign_info {
97 __u8 csrk[16];
98} __packed;
99
100#define SMP_CMD_SECURITY_REQ 0x0b
101struct smp_cmd_security_req {
102 __u8 auth_req;
103} __packed;
104
105#define SMP_PASSKEY_ENTRY_FAILED 0x01
106#define SMP_OOB_NOT_AVAIL 0x02
107#define SMP_AUTH_REQUIREMENTS 0x03
108#define SMP_CONFIRM_FAILED 0x04
109#define SMP_PAIRING_NOTSUPP 0x05
110#define SMP_ENC_KEY_SIZE 0x06
111#define SMP_CMD_NOTSUPP 0x07
112#define SMP_UNSPECIFIED 0x08
113#define SMP_REPEATED_ATTEMPTS 0x09
114
115#define SMP_MIN_ENC_KEY_SIZE 7
116#define SMP_MAX_ENC_KEY_SIZE 16
117
118#define SMP_FLAG_TK_VALID 1
119#define SMP_FLAG_CFM_PENDING 2
120#define SMP_FLAG_MITM_AUTH 3
121
122struct smp_chan {
123 struct l2cap_conn *conn;
124 u8 preq[7]; /* SMP Pairing Request */
125 u8 prsp[7]; /* SMP Pairing Response */
126 u8 prnd[16]; /* SMP Pairing Random (local) */
127 u8 rrnd[16]; /* SMP Pairing Random (remote) */
128 u8 pcnf[16]; /* SMP Pairing Confirm */
129 u8 tk[16]; /* SMP Temporary Key */
130 u8 enc_key_size;
131 unsigned long smp_flags;
132 struct crypto_blkcipher *tfm;
133 struct work_struct confirm;
134 struct work_struct random;
135
136};
137
138/* SMP Commands */
139int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
140int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
141int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
142int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);
143
144void smp_chan_destroy(struct l2cap_conn *conn);
145
146#endif /* __SMP_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 45f6bf591104..419202ce3f95 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3483,6 +3483,15 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
3483const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy, 3483const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
3484 u32 center_freq); 3484 u32 center_freq);
3485 3485
3486/**
3487 * reg_initiator_name - map regulatory request initiator enum to name
3488 * @initiator: the regulatory request initiator
3489 *
3490 * You can use this to map the regulatory request initiator enum to a
3491 * proper string representation.
3492 */
3493const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
3494
3486/* 3495/*
3487 * callbacks for asynchronous cfg80211 methods, notification 3496 * callbacks for asynchronous cfg80211 methods, notification
3488 * functions and BSS handling helpers 3497 * functions and BSS handling helpers
diff --git a/include/net/nfc/digital.h b/include/net/nfc/digital.h
new file mode 100644
index 000000000000..36acecd5f06c
--- /dev/null
+++ b/include/net/nfc/digital.h
@@ -0,0 +1,227 @@
1/*
2 * NFC Digital Protocol stack
3 * Copyright (c) 2013, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 */
15
16#ifndef __NFC_DIGITAL_H
17#define __NFC_DIGITAL_H
18
19#include <linux/skbuff.h>
20#include <net/nfc/nfc.h>
21
22/**
23 * Configuration types for in_configure_hw and tg_configure_hw.
24 */
25enum {
26 NFC_DIGITAL_CONFIG_RF_TECH = 0,
27 NFC_DIGITAL_CONFIG_FRAMING,
28};
29
30/**
31 * RF technology values passed as param argument to in_configure_hw and
32 * tg_configure_hw for NFC_DIGITAL_CONFIG_RF_TECH configuration type.
33 */
34enum {
35 NFC_DIGITAL_RF_TECH_106A = 0,
36 NFC_DIGITAL_RF_TECH_212F,
37 NFC_DIGITAL_RF_TECH_424F,
38
39 NFC_DIGITAL_RF_TECH_LAST,
40};
41
42/**
43 * Framing configuration passed as param argument to in_configure_hw and
44 * tg_configure_hw for NFC_DIGITAL_CONFIG_FRAMING configuration type.
45 */
46enum {
47 NFC_DIGITAL_FRAMING_NFCA_SHORT = 0,
48 NFC_DIGITAL_FRAMING_NFCA_STANDARD,
49 NFC_DIGITAL_FRAMING_NFCA_STANDARD_WITH_CRC_A,
50
51 NFC_DIGITAL_FRAMING_NFCA_T1T,
52 NFC_DIGITAL_FRAMING_NFCA_T2T,
53 NFC_DIGITAL_FRAMING_NFCA_NFC_DEP,
54
55 NFC_DIGITAL_FRAMING_NFCF,
56 NFC_DIGITAL_FRAMING_NFCF_T3T,
57 NFC_DIGITAL_FRAMING_NFCF_NFC_DEP,
58 NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED,
59
60 NFC_DIGITAL_FRAMING_LAST,
61};
62
63#define DIGITAL_MDAA_NFCID1_SIZE 3
64
65struct digital_tg_mdaa_params {
66 u16 sens_res;
67 u8 nfcid1[DIGITAL_MDAA_NFCID1_SIZE];
68 u8 sel_res;
69
70 u8 nfcid2[NFC_NFCID2_MAXSIZE];
71 u16 sc;
72};
73
74struct nfc_digital_dev;
75
76/**
77 * nfc_digital_cmd_complete_t - Definition of command result callback
78 *
79 * @ddev: nfc_digital_device ref
80 * @arg: user data
81 * @resp: response data
82 *
83 * resp pointer can be an error code and will be checked with IS_ERR() macro.
84 * The callback is responsible for freeing resp sk_buff.
85 */
86typedef void (*nfc_digital_cmd_complete_t)(struct nfc_digital_dev *ddev,
87 void *arg, struct sk_buff *resp);
88
89/**
90 * Device side NFC Digital operations
91 *
92 * Initiator mode:
93 * @in_configure_hw: Hardware configuration for RF technology and communication
94 * framing in initiator mode. This is a synchronous function.
95 * @in_send_cmd: Initiator mode data exchange using RF technology and framing
96 * previously set with in_configure_hw. The peer response is returned
97 * through callback cb. If an io error occurs or the peer didn't reply
98 * within the specified timeout (ms), the error code is passed back through
99 * the resp pointer. This is an asynchronous function.
100 *
101 * Target mode: Only NFC-DEP protocol is supported in target mode.
102 * @tg_configure_hw: Hardware configuration for RF technology and communication
103 * framing in target mode. This is a synchronous function.
104 * @tg_send_cmd: Target mode data exchange using RF technology and framing
105 * previously set with tg_configure_hw. The peer next command is returned
106 * through callback cb. If an io error occurs or the peer didn't reply
107 * within the specified timeout (ms), the error code is passed back through
108 * the resp pointer. This is an asynchronous function.
109 * @tg_listen: Put the device in listen mode waiting for data from the peer
110 * device. This is an asynchronous function.
111 * @tg_listen_mdaa: If supported, put the device in automatic listen mode with
112 * mode detection and automatic anti-collision. In this mode, the device
113 * automatically detects the RF technology and executes the anti-collision
114 * detection using the command responses specified in mdaa_params. The
115 * mdaa_params structure contains SENS_RES, NFCID1, and SEL_RES for 106A RF
116 * tech. NFCID2 and system code (sc) for 212F and 424F. The driver returns
117 * the NFC-DEP ATR_REQ command through cb. The digital stack deducts the RF
118 * tech by analyzing the SoD of the frame containing the ATR_REQ command.
119 * This is an asynchronous function.
120 *
121 * @switch_rf: Turns device radio on or off. The stack does not call explicitly
122 * switch_rf to turn the radio on. A call to in|tg_configure_hw must turn
123 * the device radio on.
124 * @abort_cmd: Discard the last sent command.
125 */
126struct nfc_digital_ops {
127 int (*in_configure_hw)(struct nfc_digital_dev *ddev, int type,
128 int param);
129 int (*in_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
130 u16 timeout, nfc_digital_cmd_complete_t cb,
131 void *arg);
132
133 int (*tg_configure_hw)(struct nfc_digital_dev *ddev, int type,
134 int param);
135 int (*tg_send_cmd)(struct nfc_digital_dev *ddev, struct sk_buff *skb,
136 u16 timeout, nfc_digital_cmd_complete_t cb,
137 void *arg);
138 int (*tg_listen)(struct nfc_digital_dev *ddev, u16 timeout,
139 nfc_digital_cmd_complete_t cb, void *arg);
140 int (*tg_listen_mdaa)(struct nfc_digital_dev *ddev,
141 struct digital_tg_mdaa_params *mdaa_params,
142 u16 timeout, nfc_digital_cmd_complete_t cb,
143 void *arg);
144
145 int (*switch_rf)(struct nfc_digital_dev *ddev, bool on);
146 void (*abort_cmd)(struct nfc_digital_dev *ddev);
147};
148
149#define NFC_DIGITAL_POLL_MODE_COUNT_MAX 6 /* 106A, 212F, and 424F in & tg */
150
151typedef int (*digital_poll_t)(struct nfc_digital_dev *ddev, u8 rf_tech);
152
153struct digital_poll_tech {
154 u8 rf_tech;
155 digital_poll_t poll_func;
156};
157
158/**
159 * Driver capabilities - bit mask made of the following values
160 *
161 * @NFC_DIGITAL_DRV_CAPS_IN_CRC: The driver handles CRC calculation in initiator
162 * mode.
163 * @NFC_DIGITAL_DRV_CAPS_TG_CRC: The driver handles CRC calculation in target
164 * mode.
165 */
166#define NFC_DIGITAL_DRV_CAPS_IN_CRC 0x0001
167#define NFC_DIGITAL_DRV_CAPS_TG_CRC 0x0002
168
169struct nfc_digital_dev {
170 struct nfc_dev *nfc_dev;
171 struct nfc_digital_ops *ops;
172
173 u32 protocols;
174
175 int tx_headroom;
176 int tx_tailroom;
177
178 u32 driver_capabilities;
179 void *driver_data;
180
181 struct digital_poll_tech poll_techs[NFC_DIGITAL_POLL_MODE_COUNT_MAX];
182 u8 poll_tech_count;
183 u8 poll_tech_index;
184 struct mutex poll_lock;
185
186 struct work_struct cmd_work;
187 struct work_struct cmd_complete_work;
188 struct list_head cmd_queue;
189 struct mutex cmd_lock;
190
191 struct work_struct poll_work;
192
193 u8 curr_protocol;
194 u8 curr_rf_tech;
195 u8 curr_nfc_dep_pni;
196
197 int (*skb_check_crc)(struct sk_buff *skb);
198 void (*skb_add_crc)(struct sk_buff *skb);
199};
200
201struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
202 __u32 supported_protocols,
203 __u32 driver_capabilities,
204 int tx_headroom,
205 int tx_tailroom);
206void nfc_digital_free_device(struct nfc_digital_dev *ndev);
207int nfc_digital_register_device(struct nfc_digital_dev *ndev);
208void nfc_digital_unregister_device(struct nfc_digital_dev *ndev);
209
210static inline void nfc_digital_set_parent_dev(struct nfc_digital_dev *ndev,
211 struct device *dev)
212{
213 nfc_set_parent_dev(ndev->nfc_dev, dev);
214}
215
216static inline void nfc_digital_set_drvdata(struct nfc_digital_dev *dev,
217 void *data)
218{
219 dev->driver_data = data;
220}
221
222static inline void *nfc_digital_get_drvdata(struct nfc_digital_dev *dev)
223{
224 return dev->driver_data;
225}
226
227#endif /* __NFC_DIGITAL_H */
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h
index b64b7bce4b94..2eca2960ca9c 100644
--- a/include/net/nfc/hci.h
+++ b/include/net/nfc/hci.h
@@ -24,12 +24,6 @@
24 24
25#include <net/nfc/nfc.h> 25#include <net/nfc/nfc.h>
26 26
27struct nfc_phy_ops {
28 int (*write)(void *dev_id, struct sk_buff *skb);
29 int (*enable)(void *dev_id);
30 void (*disable)(void *dev_id);
31};
32
33struct nfc_hci_dev; 27struct nfc_hci_dev;
34 28
35struct nfc_hci_ops { 29struct nfc_hci_ops {
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h
index 88785e5c6b2c..e5aa5acafea0 100644
--- a/include/net/nfc/nci.h
+++ b/include/net/nfc/nci.h
@@ -166,6 +166,10 @@
166#define NCI_GID_NFCEE_MGMT 0x2 166#define NCI_GID_NFCEE_MGMT 0x2
167#define NCI_GID_PROPRIETARY 0xf 167#define NCI_GID_PROPRIETARY 0xf
168 168
169/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
170#define NCI_SPI_HDR_LEN 4
171#define NCI_SPI_CRC_LEN 2
172
169/* ---- NCI Packet structures ---- */ 173/* ---- NCI Packet structures ---- */
170#define NCI_CTRL_HDR_SIZE 3 174#define NCI_CTRL_HDR_SIZE 3
171#define NCI_DATA_HDR_SIZE 3 175#define NCI_DATA_HDR_SIZE 3
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index 99fc1f3a392a..6126f1f992b4 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -207,19 +207,9 @@ int nci_to_errno(__u8 code);
207#define NCI_SPI_CRC_ENABLED 0x01 207#define NCI_SPI_CRC_ENABLED 0x01
208 208
209/* ----- NCI SPI structures ----- */ 209/* ----- NCI SPI structures ----- */
210struct nci_spi_dev; 210struct nci_spi {
211 211 struct nci_dev *ndev;
212struct nci_spi_ops {
213 int (*open)(struct nci_spi_dev *ndev);
214 int (*close)(struct nci_spi_dev *ndev);
215 void (*assert_int)(struct nci_spi_dev *ndev);
216 void (*deassert_int)(struct nci_spi_dev *ndev);
217};
218
219struct nci_spi_dev {
220 struct nci_dev *nci_dev;
221 struct spi_device *spi; 212 struct spi_device *spi;
222 struct nci_spi_ops *ops;
223 213
224 unsigned int xfer_udelay; /* microseconds delay between 214 unsigned int xfer_udelay; /* microseconds delay between
225 transactions */ 215 transactions */
@@ -227,31 +217,15 @@ struct nci_spi_dev {
227 217
228 struct completion req_completion; 218 struct completion req_completion;
229 u8 req_result; 219 u8 req_result;
230
231 void *driver_data;
232}; 220};
233 221
234/* ----- NCI SPI Devices ----- */ 222/* ----- NCI SPI ----- */
235struct nci_spi_dev *nci_spi_allocate_device(struct spi_device *spi, 223struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
236 struct nci_spi_ops *ops, 224 u8 acknowledge_mode, unsigned int delay,
237 u32 supported_protocols, 225 struct nci_dev *ndev);
238 u32 supported_se, 226int nci_spi_send(struct nci_spi *nspi,
239 u8 acknowledge_mode, 227 struct completion *write_handshake_completion,
240 unsigned int delay); 228 struct sk_buff *skb);
241void nci_spi_free_device(struct nci_spi_dev *ndev); 229struct sk_buff *nci_spi_read(struct nci_spi *nspi);
242int nci_spi_register_device(struct nci_spi_dev *ndev);
243void nci_spi_unregister_device(struct nci_spi_dev *ndev);
244int nci_spi_recv_frame(struct nci_spi_dev *ndev);
245
246static inline void nci_spi_set_drvdata(struct nci_spi_dev *ndev,
247 void *data)
248{
249 ndev->driver_data = data;
250}
251
252static inline void *nci_spi_get_drvdata(struct nci_spi_dev *ndev)
253{
254 return ndev->driver_data;
255}
256 230
257#endif /* __NCI_CORE_H */ 231#endif /* __NCI_CORE_H */
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index f68ee68e4e3e..82fc4e43fc6e 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -28,9 +28,14 @@
28#include <linux/device.h> 28#include <linux/device.h>
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30 30
31#define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt "\n", ## arg) 31#define nfc_info(dev, fmt, ...) dev_info((dev), "NFC: " fmt, ##__VA_ARGS__)
32#define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "NFC: " fmt "\n", ## arg) 32#define nfc_err(dev, fmt, ...) dev_err((dev), "NFC: " fmt, ##__VA_ARGS__)
33#define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), fmt "\n", ## arg) 33
34struct nfc_phy_ops {
35 int (*write)(void *dev_id, struct sk_buff *skb);
36 int (*enable)(void *dev_id);
37 void (*disable)(void *dev_id);
38};
34 39
35struct nfc_dev; 40struct nfc_dev;
36 41
@@ -48,6 +53,8 @@ struct nfc_dev;
48typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb, 53typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
49 int err); 54 int err);
50 55
56typedef void (*se_io_cb_t)(void *context, u8 *apdu, size_t apdu_len, int err);
57
51struct nfc_target; 58struct nfc_target;
52 59
53struct nfc_ops { 60struct nfc_ops {
@@ -74,12 +81,23 @@ struct nfc_ops {
74 int (*discover_se)(struct nfc_dev *dev); 81 int (*discover_se)(struct nfc_dev *dev);
75 int (*enable_se)(struct nfc_dev *dev, u32 se_idx); 82 int (*enable_se)(struct nfc_dev *dev, u32 se_idx);
76 int (*disable_se)(struct nfc_dev *dev, u32 se_idx); 83 int (*disable_se)(struct nfc_dev *dev, u32 se_idx);
84 int (*se_io) (struct nfc_dev *dev, u32 se_idx,
85 u8 *apdu, size_t apdu_length,
86 se_io_cb_t cb, void *cb_context);
77}; 87};
78 88
79#define NFC_TARGET_IDX_ANY -1 89#define NFC_TARGET_IDX_ANY -1
80#define NFC_MAX_GT_LEN 48 90#define NFC_MAX_GT_LEN 48
81#define NFC_ATR_RES_GT_OFFSET 15 91#define NFC_ATR_RES_GT_OFFSET 15
82 92
93/**
94 * struct nfc_target - NFC target descriptiom
95 *
96 * @sens_res: 2 bytes describing the target SENS_RES response, if the target
97 * is a type A one. The %sens_res most significant byte must be byte 2
98 * as described by the NFC Forum digital specification (i.e. the platform
99 * configuration one) while %sens_res least significant byte is byte 1.
100 */
83struct nfc_target { 101struct nfc_target {
84 u32 idx; 102 u32 idx;
85 u32 supported_protocols; 103 u32 supported_protocols;
@@ -243,5 +261,6 @@ void nfc_driver_failure(struct nfc_dev *dev, int err);
243 261
244int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type); 262int nfc_add_se(struct nfc_dev *dev, u32 se_idx, u16 type);
245int nfc_remove_se(struct nfc_dev *dev, u32 se_idx); 263int nfc_remove_se(struct nfc_dev *dev, u32 se_idx);
264struct nfc_se *nfc_find_se(struct nfc_dev *dev, u32 se_idx);
246 265
247#endif /* __NET_NFC_H */ 266#endif /* __NET_NFC_H */
diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h
index 29bed72a4ac4..6ad6cc03ccd3 100644
--- a/include/uapi/linux/nfc.h
+++ b/include/uapi/linux/nfc.h
@@ -85,6 +85,7 @@
85 * a specific SE notifies us about the end of a transaction. The parameter 85 * a specific SE notifies us about the end of a transaction. The parameter
86 * for this event is the application ID (AID). 86 * for this event is the application ID (AID).
87 * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller. 87 * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller.
88 * @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element.
88 */ 89 */
89enum nfc_commands { 90enum nfc_commands {
90 NFC_CMD_UNSPEC, 91 NFC_CMD_UNSPEC,
@@ -114,6 +115,7 @@ enum nfc_commands {
114 NFC_EVENT_SE_CONNECTIVITY, 115 NFC_EVENT_SE_CONNECTIVITY,
115 NFC_EVENT_SE_TRANSACTION, 116 NFC_EVENT_SE_TRANSACTION,
116 NFC_CMD_GET_SE, 117 NFC_CMD_GET_SE,
118 NFC_CMD_SE_IO,
117/* private: internal use only */ 119/* private: internal use only */
118 __NFC_CMD_AFTER_LAST 120 __NFC_CMD_AFTER_LAST
119}; 121};
@@ -147,6 +149,7 @@ enum nfc_commands {
147 * @NFC_ATTR_SE_INDEX: Secure element index 149 * @NFC_ATTR_SE_INDEX: Secure element index
148 * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED) 150 * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
149 * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status 151 * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
152 * @NFC_ATTR_APDU: Secure element APDU
150 */ 153 */
151enum nfc_attrs { 154enum nfc_attrs {
152 NFC_ATTR_UNSPEC, 155 NFC_ATTR_UNSPEC,
@@ -174,6 +177,7 @@ enum nfc_attrs {
174 NFC_ATTR_SE_TYPE, 177 NFC_ATTR_SE_TYPE,
175 NFC_ATTR_SE_AID, 178 NFC_ATTR_SE_AID,
176 NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS, 179 NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
180 NFC_ATTR_SE_APDU,
177/* private: internal use only */ 181/* private: internal use only */
178 __NFC_ATTR_AFTER_LAST 182 __NFC_ATTR_AFTER_LAST
179}; 183};