aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-01 17:08:52 -0400
commit73287a43cc79ca06629a88d1a199cd283f42456a (patch)
treeacf4456e260115bea77ee31a29f10ce17f0db45c /include/net/bluetooth
parent251df49db3327c64bf917bfdba94491fde2b4ee0 (diff)
parent20074f357da4a637430aec2879c9d864c5d2c23c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: "Highlights (1721 non-merge commits, this has to be a record of some sort): 1) Add 'random' mode to team driver, from Jiri Pirko and Eric Dumazet. 2) Make it so that any driver that supports configuration of multiple MAC addresses can provide the forwarding database add and del calls by providing a default implementation and hooking that up if the driver doesn't have an explicit set of handlers. From Vlad Yasevich. 3) Support GSO segmentation over tunnels and other encapsulating devices such as VXLAN, from Pravin B Shelar. 4) Support L2 GRE tunnels in the flow dissector, from Michael Dalton. 5) Implement Tail Loss Probe (TLP) detection in TCP, from Nandita Dukkipati. 6) In the PHY layer, allow supporting wake-on-lan in situations where the PHY registers have to be written for it to be configured. Use it to support wake-on-lan in mv643xx_eth. From Michael Stapelberg. 7) Significantly improve firewire IPV6 support, from YOSHIFUJI Hideaki. 8) Allow multiple packets to be sent in a single transmission using network coding in batman-adv, from Martin Hundebøll. 9) Add support for T5 cxgb4 chips, from Santosh Rastapur. 10) Generalize the VXLAN forwarding tables so that there is more flexibility in configurating various aspects of the endpoints. From David Stevens. 11) Support RSS and TSO in hardware over GRE tunnels in bxn2x driver, from Dmitry Kravkov. 12) Zero copy support in nfnelink_queue, from Eric Dumazet and Pablo Neira Ayuso. 13) Start adding networking selftests. 14) In situations of overload on the same AF_PACKET fanout socket, or per-cpu packet receive queue, minimize drop by distributing the load to other cpus/fanouts. From Willem de Bruijn and Eric Dumazet. 15) Add support for new payload offset BPF instruction, from Daniel Borkmann. 16) Convert several drivers over to mdoule_platform_driver(), from Sachin Kamat. 17) Provide a minimal BPF JIT image disassembler userspace tool, from Daniel Borkmann. 18) Rewrite F-RTO implementation in TCP to match the final specification of it in RFC4138 and RFC5682. From Yuchung Cheng. 19) Provide netlink socket diag of netlink sockets ("Yo dawg, I hear you like netlink, so I implemented netlink dumping of netlink sockets.") From Andrey Vagin. 20) Remove ugly passing of rtnetlink attributes into rtnl_doit functions, from Thomas Graf. 21) Allow userspace to be able to see if a configuration change occurs in the middle of an address or device list dump, from Nicolas Dichtel. 22) Support RFC3168 ECN protection for ipv6 fragments, from Hannes Frederic Sowa. 23) Increase accuracy of packet length used by packet scheduler, from Jason Wang. 24) Beginning set of changes to make ipv4/ipv6 fragment handling more scalable and less susceptible to overload and locking contention, from Jesper Dangaard Brouer. 25) Get rid of using non-type-safe NLMSG_* macros and use nlmsg_*() instead. From Hong Zhiguo. 26) Optimize route usage in IPVS by avoiding reference counting where possible, from Julian Anastasov. 27) Convert IPVS schedulers to RCU, also from Julian Anastasov. 28) Support cpu fanouts in xt_NFQUEUE netfilter target, from Holger Eitzenberger. 29) Network namespace support for nf_log, ebt_log, xt_LOG, ipt_ULOG, nfnetlink_log, and nfnetlink_queue. From Gao feng. 30) Implement RFC3168 ECN protection, from Hannes Frederic Sowa. 31) Support several new r8169 chips, from Hayes Wang. 32) Support tokenized interface identifiers in ipv6, from Daniel Borkmann. 33) Use usbnet_link_change() helper in USB net driver, from Ming Lei. 34) Add 802.1ad vlan offload support, from Patrick McHardy. 35) Support mmap() based netlink communication, also from Patrick McHardy. 36) Support HW timestamping in mlx4 driver, from Amir Vadai. 37) Rationalize AF_PACKET packet timestamping when transmitting, from Willem de Bruijn and Daniel Borkmann. 38) Bring parity to what's provided by /proc/net/packet socket dumping and the info provided by netlink socket dumping of AF_PACKET sockets. From Nicolas Dichtel. 39) Fix peeking beyond zero sized SKBs in AF_UNIX, from Benjamin Poirier" * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1722 commits) filter: fix va_list build error af_unix: fix a fatal race with bit fields bnx2x: Prevent memory leak when cnic is absent bnx2x: correct reading of speed capabilities net: sctp: attribute printl with __printf for gcc fmt checks netlink: kconfig: move mmap i/o into netlink kconfig netpoll: convert mutex into a semaphore netlink: Fix skb ref counting. net_sched: act_ipt forward compat with xtables mlx4_en: fix a build error on 32bit arches Revert "bnx2x: allow nvram test to run when device is down" bridge: avoid OOPS if root port not found drivers: net: cpsw: fix kernel warn on cpsw irq enable sh_eth: use random MAC address if no valid one supplied 3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA) tg3: fix to append hardware time stamping flags unix/stream: fix peeking with an offset larger than data in queue unix/dgram: fix peeking with an offset larger than data in queue unix/dgram: peek beyond 0-sized skbs openvswitch: Remove unneeded ovs_netdev_get_ifindex() ...
Diffstat (limited to 'include/net/bluetooth')
-rw-r--r--include/net/bluetooth/bluetooth.h17
-rw-r--r--include/net/bluetooth/hci.h30
-rw-r--r--include/net/bluetooth/hci_core.h128
-rw-r--r--include/net/bluetooth/l2cap.h15
-rw-r--r--include/net/bluetooth/rfcomm.h6
5 files changed, 146 insertions, 50 deletions
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 9531beee09b5..6912ef9a1881 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -193,11 +193,11 @@ static inline bool bdaddr_type_is_le(__u8 type)
193#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) 193#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} })
194 194
195/* Copy, swap, convert BD Address */ 195/* Copy, swap, convert BD Address */
196static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) 196static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
197{ 197{
198 return memcmp(ba1, ba2, sizeof(bdaddr_t)); 198 return memcmp(ba1, ba2, sizeof(bdaddr_t));
199} 199}
200static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) 200static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
201{ 201{
202 memcpy(dst, src, sizeof(bdaddr_t)); 202 memcpy(dst, src, sizeof(bdaddr_t));
203} 203}
@@ -232,7 +232,7 @@ struct bt_sock_list {
232}; 232};
233 233
234int bt_sock_register(int proto, const struct net_proto_family *ops); 234int bt_sock_register(int proto, const struct net_proto_family *ops);
235int bt_sock_unregister(int proto); 235void bt_sock_unregister(int proto);
236void bt_sock_link(struct bt_sock_list *l, struct sock *s); 236void bt_sock_link(struct bt_sock_list *l, struct sock *s);
237void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); 237void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
238int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 238int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
@@ -260,12 +260,23 @@ struct l2cap_ctrl {
260 __u8 retries; 260 __u8 retries;
261}; 261};
262 262
263struct hci_dev;
264
265typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status);
266
267struct hci_req_ctrl {
268 bool start;
269 u8 event;
270 hci_req_complete_t complete;
271};
272
263struct bt_skb_cb { 273struct bt_skb_cb {
264 __u8 pkt_type; 274 __u8 pkt_type;
265 __u8 incoming; 275 __u8 incoming;
266 __u16 expect; 276 __u16 expect;
267 __u8 force_active; 277 __u8 force_active;
268 struct l2cap_ctrl control; 278 struct l2cap_ctrl control;
279 struct hci_req_ctrl req;
269}; 280};
270#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 281#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
271 282
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 7f12c25f1fca..e0512aaef4b8 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -119,10 +119,16 @@ enum {
119 HCI_CONNECTABLE, 119 HCI_CONNECTABLE,
120 HCI_DISCOVERABLE, 120 HCI_DISCOVERABLE,
121 HCI_LINK_SECURITY, 121 HCI_LINK_SECURITY,
122 HCI_PENDING_CLASS,
123 HCI_PERIODIC_INQ, 122 HCI_PERIODIC_INQ,
123 HCI_FAST_CONNECTABLE,
124}; 124};
125 125
126/* A mask for the flags that are supposed to remain when a reset happens
127 * or the HCI device is closed.
128 */
129#define HCI_PERSISTENT_MASK (BIT(HCI_LE_SCAN) | BIT(HCI_PERIODIC_INQ) | \
130 BIT(HCI_FAST_CONNECTABLE))
131
126/* HCI ioctl defines */ 132/* HCI ioctl defines */
127#define HCIDEVUP _IOW('H', 201, int) 133#define HCIDEVUP _IOW('H', 201, int)
128#define HCIDEVDOWN _IOW('H', 202, int) 134#define HCIDEVDOWN _IOW('H', 202, int)
@@ -881,12 +887,25 @@ struct hci_rp_read_data_block_size {
881 __le16 num_blocks; 887 __le16 num_blocks;
882} __packed; 888} __packed;
883 889
890#define HCI_OP_READ_PAGE_SCAN_ACTIVITY 0x0c1b
891struct hci_rp_read_page_scan_activity {
892 __u8 status;
893 __le16 interval;
894 __le16 window;
895} __packed;
896
884#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c 897#define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c
885struct hci_cp_write_page_scan_activity { 898struct hci_cp_write_page_scan_activity {
886 __le16 interval; 899 __le16 interval;
887 __le16 window; 900 __le16 window;
888} __packed; 901} __packed;
889 902
903#define HCI_OP_READ_PAGE_SCAN_TYPE 0x0c46
904struct hci_rp_read_page_scan_type {
905 __u8 status;
906 __u8 type;
907} __packed;
908
890#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47 909#define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47
891 #define PAGE_SCAN_TYPE_STANDARD 0x00 910 #define PAGE_SCAN_TYPE_STANDARD 0x00
892 #define PAGE_SCAN_TYPE_INTERLACED 0x01 911 #define PAGE_SCAN_TYPE_INTERLACED 0x01
@@ -965,6 +984,9 @@ struct hci_cp_le_set_adv_data {
965 984
966#define HCI_OP_LE_SET_ADV_ENABLE 0x200a 985#define HCI_OP_LE_SET_ADV_ENABLE 0x200a
967 986
987#define LE_SCAN_PASSIVE 0x00
988#define LE_SCAN_ACTIVE 0x01
989
968#define HCI_OP_LE_SET_SCAN_PARAM 0x200b 990#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
969struct hci_cp_le_set_scan_param { 991struct hci_cp_le_set_scan_param {
970 __u8 type; 992 __u8 type;
@@ -974,8 +996,10 @@ struct hci_cp_le_set_scan_param {
974 __u8 filter_policy; 996 __u8 filter_policy;
975} __packed; 997} __packed;
976 998
977#define LE_SCANNING_DISABLED 0x00 999#define LE_SCAN_DISABLE 0x00
978#define LE_SCANNING_ENABLED 0x01 1000#define LE_SCAN_ENABLE 0x01
1001#define LE_SCAN_FILTER_DUP_DISABLE 0x00
1002#define LE_SCAN_FILTER_DUP_ENABLE 0x01
979 1003
980#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c 1004#define HCI_OP_LE_SET_SCAN_ENABLE 0x200c
981struct hci_cp_le_set_scan_enable { 1005struct hci_cp_le_set_scan_enable {
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 90cf75afcb02..35a57cd1704c 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -134,6 +134,8 @@ struct amp_assoc {
134 __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; 134 __u8 data[HCI_MAX_AMP_ASSOC_SIZE];
135}; 135};
136 136
137#define HCI_MAX_PAGES 3
138
137#define NUM_REASSEMBLY 4 139#define NUM_REASSEMBLY 4
138struct hci_dev { 140struct hci_dev {
139 struct list_head list; 141 struct list_head list;
@@ -151,8 +153,8 @@ struct hci_dev {
151 __u8 dev_class[3]; 153 __u8 dev_class[3];
152 __u8 major_class; 154 __u8 major_class;
153 __u8 minor_class; 155 __u8 minor_class;
154 __u8 features[8]; 156 __u8 max_page;
155 __u8 host_features[8]; 157 __u8 features[HCI_MAX_PAGES][8];
156 __u8 le_features[8]; 158 __u8 le_features[8];
157 __u8 le_white_list_size; 159 __u8 le_white_list_size;
158 __u8 le_states[8]; 160 __u8 le_states[8];
@@ -165,6 +167,10 @@ struct hci_dev {
165 __u16 voice_setting; 167 __u16 voice_setting;
166 __u8 io_capability; 168 __u8 io_capability;
167 __s8 inq_tx_power; 169 __s8 inq_tx_power;
170 __u16 page_scan_interval;
171 __u16 page_scan_window;
172 __u8 page_scan_type;
173
168 __u16 devid_source; 174 __u16 devid_source;
169 __u16 devid_vendor; 175 __u16 devid_vendor;
170 __u16 devid_product; 176 __u16 devid_product;
@@ -240,6 +246,7 @@ struct hci_dev {
240 struct sk_buff_head raw_q; 246 struct sk_buff_head raw_q;
241 struct sk_buff_head cmd_q; 247 struct sk_buff_head cmd_q;
242 248
249 struct sk_buff *recv_evt;
243 struct sk_buff *sent_cmd; 250 struct sk_buff *sent_cmd;
244 struct sk_buff *reassembly[NUM_REASSEMBLY]; 251 struct sk_buff *reassembly[NUM_REASSEMBLY];
245 252
@@ -248,8 +255,6 @@ struct hci_dev {
248 __u32 req_status; 255 __u32 req_status;
249 __u32 req_result; 256 __u32 req_result;
250 257
251 __u16 init_last_cmd;
252
253 struct list_head mgmt_pending; 258 struct list_head mgmt_pending;
254 259
255 struct discovery_state discovery; 260 struct discovery_state discovery;
@@ -266,8 +271,6 @@ struct hci_dev {
266 271
267 struct hci_dev_stats stat; 272 struct hci_dev_stats stat;
268 273
269 struct sk_buff_head driver_init;
270
271 atomic_t promisc; 274 atomic_t promisc;
272 275
273 struct dentry *debugfs; 276 struct dentry *debugfs;
@@ -290,6 +293,7 @@ struct hci_dev {
290 int (*open)(struct hci_dev *hdev); 293 int (*open)(struct hci_dev *hdev);
291 int (*close)(struct hci_dev *hdev); 294 int (*close)(struct hci_dev *hdev);
292 int (*flush)(struct hci_dev *hdev); 295 int (*flush)(struct hci_dev *hdev);
296 int (*setup)(struct hci_dev *hdev);
293 int (*send)(struct sk_buff *skb); 297 int (*send)(struct sk_buff *skb);
294 void (*notify)(struct hci_dev *hdev, unsigned int evt); 298 void (*notify)(struct hci_dev *hdev, unsigned int evt);
295 int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); 299 int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
@@ -311,7 +315,7 @@ struct hci_conn {
311 bool out; 315 bool out;
312 __u8 attempt; 316 __u8 attempt;
313 __u8 dev_class[3]; 317 __u8 dev_class[3];
314 __u8 features[8]; 318 __u8 features[HCI_MAX_PAGES][8];
315 __u16 interval; 319 __u16 interval;
316 __u16 pkt_type; 320 __u16 pkt_type;
317 __u16 link_policy; 321 __u16 link_policy;
@@ -343,7 +347,6 @@ struct hci_conn {
343 struct timer_list auto_accept_timer; 347 struct timer_list auto_accept_timer;
344 348
345 struct device dev; 349 struct device dev;
346 atomic_t devref;
347 350
348 struct hci_dev *hdev; 351 struct hci_dev *hdev;
349 void *l2cap_data; 352 void *l2cap_data;
@@ -574,7 +577,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev,
574 return NULL; 577 return NULL;
575} 578}
576 579
577void hci_acl_disconn(struct hci_conn *conn, __u8 reason); 580void hci_disconnect(struct hci_conn *conn, __u8 reason);
578void hci_setup_sync(struct hci_conn *conn, __u16 handle); 581void hci_setup_sync(struct hci_conn *conn, __u16 handle);
579void hci_sco_setup(struct hci_conn *conn, __u8 status); 582void hci_sco_setup(struct hci_conn *conn, __u8 status);
580 583
@@ -582,7 +585,6 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst);
582int hci_conn_del(struct hci_conn *conn); 585int hci_conn_del(struct hci_conn *conn);
583void hci_conn_hash_flush(struct hci_dev *hdev); 586void hci_conn_hash_flush(struct hci_dev *hdev);
584void hci_conn_check_pending(struct hci_dev *hdev); 587void hci_conn_check_pending(struct hci_dev *hdev);
585void hci_conn_accept(struct hci_conn *conn, int mask);
586 588
587struct hci_chan *hci_chan_create(struct hci_conn *conn); 589struct hci_chan *hci_chan_create(struct hci_conn *conn);
588void hci_chan_del(struct hci_chan *chan); 590void hci_chan_del(struct hci_chan *chan);
@@ -599,8 +601,36 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
599 601
600void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); 602void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active);
601 603
602void hci_conn_hold_device(struct hci_conn *conn); 604/*
603void hci_conn_put_device(struct hci_conn *conn); 605 * hci_conn_get() and hci_conn_put() are used to control the life-time of an
606 * "hci_conn" object. They do not guarantee that the hci_conn object is running,
607 * working or anything else. They just guarantee that the object is available
608 * and can be dereferenced. So you can use its locks, local variables and any
609 * other constant data.
610 * Before accessing runtime data, you _must_ lock the object and then check that
611 * it is still running. As soon as you release the locks, the connection might
612 * get dropped, though.
613 *
614 * On the other hand, hci_conn_hold() and hci_conn_drop() are used to control
615 * how long the underlying connection is held. So every channel that runs on the
616 * hci_conn object calls this to prevent the connection from disappearing. As
617 * long as you hold a device, you must also guarantee that you have a valid
618 * reference to the device via hci_conn_get() (or the initial reference from
619 * hci_conn_add()).
620 * The hold()/drop() ref-count is known to drop below 0 sometimes, which doesn't
621 * break because nobody cares for that. But this means, we cannot use
622 * _get()/_drop() in it, but require the caller to have a valid ref (FIXME).
623 */
624
625static inline void hci_conn_get(struct hci_conn *conn)
626{
627 get_device(&conn->dev);
628}
629
630static inline void hci_conn_put(struct hci_conn *conn)
631{
632 put_device(&conn->dev);
633}
604 634
605static inline void hci_conn_hold(struct hci_conn *conn) 635static inline void hci_conn_hold(struct hci_conn *conn)
606{ 636{
@@ -610,7 +640,7 @@ static inline void hci_conn_hold(struct hci_conn *conn)
610 cancel_delayed_work(&conn->disc_work); 640 cancel_delayed_work(&conn->disc_work);
611} 641}
612 642
613static inline void hci_conn_put(struct hci_conn *conn) 643static inline void hci_conn_drop(struct hci_conn *conn)
614{ 644{
615 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); 645 BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));
616 646
@@ -742,8 +772,6 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
742 u8 *randomizer); 772 u8 *randomizer);
743int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); 773int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
744 774
745int hci_update_ad(struct hci_dev *hdev);
746
747void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 775void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
748 776
749int hci_recv_frame(struct sk_buff *skb); 777int hci_recv_frame(struct sk_buff *skb);
@@ -760,29 +788,29 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
760#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) 788#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev))
761 789
762/* ----- LMP capabilities ----- */ 790/* ----- LMP capabilities ----- */
763#define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) 791#define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT)
764#define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) 792#define lmp_rswitch_capable(dev) ((dev)->features[0][0] & LMP_RSWITCH)
765#define lmp_hold_capable(dev) ((dev)->features[0] & LMP_HOLD) 793#define lmp_hold_capable(dev) ((dev)->features[0][0] & LMP_HOLD)
766#define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) 794#define lmp_sniff_capable(dev) ((dev)->features[0][0] & LMP_SNIFF)
767#define lmp_park_capable(dev) ((dev)->features[1] & LMP_PARK) 795#define lmp_park_capable(dev) ((dev)->features[0][1] & LMP_PARK)
768#define lmp_inq_rssi_capable(dev) ((dev)->features[3] & LMP_RSSI_INQ) 796#define lmp_inq_rssi_capable(dev) ((dev)->features[0][3] & LMP_RSSI_INQ)
769#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) 797#define lmp_esco_capable(dev) ((dev)->features[0][3] & LMP_ESCO)
770#define lmp_bredr_capable(dev) (!((dev)->features[4] & LMP_NO_BREDR)) 798#define lmp_bredr_capable(dev) (!((dev)->features[0][4] & LMP_NO_BREDR))
771#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) 799#define lmp_le_capable(dev) ((dev)->features[0][4] & LMP_LE)
772#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) 800#define lmp_sniffsubr_capable(dev) ((dev)->features[0][5] & LMP_SNIFF_SUBR)
773#define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC) 801#define lmp_pause_enc_capable(dev) ((dev)->features[0][5] & LMP_PAUSE_ENC)
774#define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ) 802#define lmp_ext_inq_capable(dev) ((dev)->features[0][6] & LMP_EXT_INQ)
775#define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR) 803#define lmp_le_br_capable(dev) (!!((dev)->features[0][6] & LMP_SIMUL_LE_BR))
776#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) 804#define lmp_ssp_capable(dev) ((dev)->features[0][6] & LMP_SIMPLE_PAIR)
777#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) 805#define lmp_no_flush_capable(dev) ((dev)->features[0][6] & LMP_NO_FLUSH)
778#define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO) 806#define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO)
779#define lmp_inq_tx_pwr_capable(dev) ((dev)->features[7] & LMP_INQ_TX_PWR) 807#define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR)
780#define lmp_ext_feat_capable(dev) ((dev)->features[7] & LMP_EXTFEATURES) 808#define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES)
781 809
782/* ----- Extended LMP capabilities ----- */ 810/* ----- Extended LMP capabilities ----- */
783#define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP) 811#define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP)
784#define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE) 812#define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE))
785#define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR) 813#define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR))
786 814
787/* returns true if at least one AMP active */ 815/* returns true if at least one AMP active */
788static inline bool hci_amp_capable(void) 816static inline bool hci_amp_capable(void)
@@ -1041,7 +1069,31 @@ static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
1041int hci_register_cb(struct hci_cb *hcb); 1069int hci_register_cb(struct hci_cb *hcb);
1042int hci_unregister_cb(struct hci_cb *hcb); 1070int hci_unregister_cb(struct hci_cb *hcb);
1043 1071
1044int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); 1072struct hci_request {
1073 struct hci_dev *hdev;
1074 struct sk_buff_head cmd_q;
1075
1076 /* If something goes wrong when building the HCI request, the error
1077 * value is stored in this field.
1078 */
1079 int err;
1080};
1081
1082void hci_req_init(struct hci_request *req, struct hci_dev *hdev);
1083int hci_req_run(struct hci_request *req, hci_req_complete_t complete);
1084void hci_req_add(struct hci_request *req, u16 opcode, u32 plen,
1085 const void *param);
1086void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen,
1087 const void *param, u8 event);
1088void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status);
1089
1090struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
1091 const void *param, u32 timeout);
1092struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
1093 const void *param, u8 event, u32 timeout);
1094
1095int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen,
1096 const void *param);
1045void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); 1097void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags);
1046void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); 1098void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb);
1047 1099
@@ -1153,7 +1205,7 @@ struct hci_sec_filter {
1153#define hci_req_lock(d) mutex_lock(&d->req_lock) 1205#define hci_req_lock(d) mutex_lock(&d->req_lock)
1154#define hci_req_unlock(d) mutex_unlock(&d->req_lock) 1206#define hci_req_unlock(d) mutex_unlock(&d->req_lock)
1155 1207
1156void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); 1208void hci_update_ad(struct hci_request *req);
1157 1209
1158void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, 1210void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
1159 u16 latency, u16 to_multiplier); 1211 u16 latency, u16 to_multiplier);
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index cdd33021f831..fb94cf13c777 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -583,6 +583,14 @@ struct l2cap_conn {
583 583
584 struct list_head chan_l; 584 struct list_head chan_l;
585 struct mutex chan_lock; 585 struct mutex chan_lock;
586 struct kref ref;
587 struct list_head users;
588};
589
590struct l2cap_user {
591 struct list_head list;
592 int (*probe) (struct l2cap_conn *conn, struct l2cap_user *user);
593 void (*remove) (struct l2cap_conn *conn, struct l2cap_user *user);
586}; 594};
587 595
588#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 596#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
@@ -786,6 +794,7 @@ extern bool disable_ertm;
786 794
787int l2cap_init_sockets(void); 795int l2cap_init_sockets(void);
788void l2cap_cleanup_sockets(void); 796void l2cap_cleanup_sockets(void);
797bool l2cap_is_socket(struct socket *sock);
789 798
790void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); 799void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
791int __l2cap_wait_ack(struct sock *sk); 800int __l2cap_wait_ack(struct sock *sk);
@@ -812,4 +821,10 @@ void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
812 u8 status); 821 u8 status);
813void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); 822void __l2cap_physical_cfm(struct l2cap_chan *chan, int result);
814 823
824void l2cap_conn_get(struct l2cap_conn *conn);
825void l2cap_conn_put(struct l2cap_conn *conn);
826
827int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
828void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
829
815#endif /* __L2CAP_H */ 830#endif /* __L2CAP_H */
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index e2e3ecad1008..7afd4199d6b6 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -158,7 +158,6 @@ struct rfcomm_session {
158 struct timer_list timer; 158 struct timer_list timer;
159 unsigned long state; 159 unsigned long state;
160 unsigned long flags; 160 unsigned long flags;
161 atomic_t refcnt;
162 int initiator; 161 int initiator;
163 162
164 /* Default DLC parameters */ 163 /* Default DLC parameters */
@@ -276,11 +275,6 @@ static inline void rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
276void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src, 275void rfcomm_session_getaddr(struct rfcomm_session *s, bdaddr_t *src,
277 bdaddr_t *dst); 276 bdaddr_t *dst);
278 277
279static inline void rfcomm_session_hold(struct rfcomm_session *s)
280{
281 atomic_inc(&s->refcnt);
282}
283
284/* ---- RFCOMM sockets ---- */ 278/* ---- RFCOMM sockets ---- */
285struct sockaddr_rc { 279struct sockaddr_rc {
286 sa_family_t rc_family; 280 sa_family_t rc_family;