xref: /linux/include/net/bluetooth/bluetooth.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
1 /*
2    BlueZ - Bluetooth protocol stack for Linux
3    Copyright (C) 2000-2001 Qualcomm Incorporated
4    Copyright 2023 NXP
5 
6    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
7 
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License version 2 as
10    published by the Free Software Foundation;
11 
12    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
15    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
16    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
17    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 
21    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
22    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
23    SOFTWARE IS DISCLAIMED.
24 */
25 
26 #ifndef __BLUETOOTH_H
27 #define __BLUETOOTH_H
28 
29 #include <linux/poll.h>
30 #include <net/sock.h>
31 #include <linux/seq_file.h>
32 #include <linux/ethtool.h>
33 
34 #define BT_SUBSYS_VERSION	2
35 #define BT_SUBSYS_REVISION	22
36 
37 #ifndef AF_BLUETOOTH
38 #define AF_BLUETOOTH	31
39 #define PF_BLUETOOTH	AF_BLUETOOTH
40 #endif
41 
42 /* Bluetooth versions */
43 #define BLUETOOTH_VER_1_1	1
44 #define BLUETOOTH_VER_1_2	2
45 #define BLUETOOTH_VER_2_0	3
46 #define BLUETOOTH_VER_2_1	4
47 #define BLUETOOTH_VER_4_0	6
48 
49 /* Reserv for core and drivers use */
50 #define BT_SKB_RESERVE	8
51 
52 #define BTPROTO_L2CAP	0
53 #define BTPROTO_HCI	1
54 #define BTPROTO_SCO	2
55 #define BTPROTO_RFCOMM	3
56 #define BTPROTO_BNEP	4
57 #define BTPROTO_CMTP	5
58 #define BTPROTO_HIDP	6
59 #define BTPROTO_AVDTP	7
60 #define BTPROTO_ISO	8
61 #define BTPROTO_LAST	BTPROTO_ISO
62 
63 #define SOL_HCI		0
64 #define SOL_L2CAP	6
65 #define SOL_SCO		17
66 #define SOL_RFCOMM	18
67 
68 #define BT_SECURITY	4
69 struct bt_security {
70 	__u8 level;
71 	__u8 key_size;
72 };
73 #define BT_SECURITY_SDP		0
74 #define BT_SECURITY_LOW		1
75 #define BT_SECURITY_MEDIUM	2
76 #define BT_SECURITY_HIGH	3
77 #define BT_SECURITY_FIPS	4
78 
79 #define BT_DEFER_SETUP	7
80 
81 #define BT_FLUSHABLE	8
82 
83 #define BT_FLUSHABLE_OFF	0
84 #define BT_FLUSHABLE_ON		1
85 
86 #define BT_POWER	9
87 struct bt_power {
88 	__u8 force_active;
89 };
90 #define BT_POWER_FORCE_ACTIVE_OFF 0
91 #define BT_POWER_FORCE_ACTIVE_ON  1
92 
93 #define BT_CHANNEL_POLICY	10
94 
95 /* BR/EDR only (default policy)
96  *   AMP controllers cannot be used.
97  *   Channel move requests from the remote device are denied.
98  *   If the L2CAP channel is currently using AMP, move the channel to BR/EDR.
99  */
100 #define BT_CHANNEL_POLICY_BREDR_ONLY		0
101 
102 /* BR/EDR Preferred
103  *   Allow use of AMP controllers.
104  *   If the L2CAP channel is currently on AMP, move it to BR/EDR.
105  *   Channel move requests from the remote device are allowed.
106  */
107 #define BT_CHANNEL_POLICY_BREDR_PREFERRED	1
108 
109 /* AMP Preferred
110  *   Allow use of AMP controllers
111  *   If the L2CAP channel is currently on BR/EDR and AMP controller
112  *     resources are available, initiate a channel move to AMP.
113  *   Channel move requests from the remote device are allowed.
114  *   If the L2CAP socket has not been connected yet, try to create
115  *     and configure the channel directly on an AMP controller rather
116  *     than BR/EDR.
117  */
118 #define BT_CHANNEL_POLICY_AMP_PREFERRED		2
119 
120 #define BT_VOICE		11
121 struct bt_voice {
122 	__u16 setting;
123 };
124 
125 #define BT_VOICE_TRANSPARENT			0x0003
126 #define BT_VOICE_CVSD_16BIT			0x0060
127 #define BT_VOICE_TRANSPARENT_16BIT		0x0063
128 
129 #define BT_SNDMTU		12
130 #define BT_RCVMTU		13
131 #define BT_PHY			14
132 
133 #define BT_PHY_BR_1M_1SLOT	0x00000001
134 #define BT_PHY_BR_1M_3SLOT	0x00000002
135 #define BT_PHY_BR_1M_5SLOT	0x00000004
136 #define BT_PHY_EDR_2M_1SLOT	0x00000008
137 #define BT_PHY_EDR_2M_3SLOT	0x00000010
138 #define BT_PHY_EDR_2M_5SLOT	0x00000020
139 #define BT_PHY_EDR_3M_1SLOT	0x00000040
140 #define BT_PHY_EDR_3M_3SLOT	0x00000080
141 #define BT_PHY_EDR_3M_5SLOT	0x00000100
142 #define BT_PHY_LE_1M_TX		0x00000200
143 #define BT_PHY_LE_1M_RX		0x00000400
144 #define BT_PHY_LE_2M_TX		0x00000800
145 #define BT_PHY_LE_2M_RX		0x00001000
146 #define BT_PHY_LE_CODED_TX	0x00002000
147 #define BT_PHY_LE_CODED_RX	0x00004000
148 
149 #define BT_MODE			15
150 
151 #define BT_MODE_BASIC		0x00
152 #define BT_MODE_ERTM		0x01
153 #define BT_MODE_STREAMING	0x02
154 #define BT_MODE_LE_FLOWCTL	0x03
155 #define BT_MODE_EXT_FLOWCTL	0x04
156 
157 #define BT_PKT_STATUS           16
158 
159 #define BT_SCM_PKT_STATUS	0x03
160 #define BT_SCM_ERROR		0x04
161 
162 #define BT_ISO_QOS		17
163 
164 #define BT_ISO_QOS_CIG_UNSET	0xff
165 #define BT_ISO_QOS_CIS_UNSET	0xff
166 
167 #define BT_ISO_QOS_BIG_UNSET	0xff
168 #define BT_ISO_QOS_BIS_UNSET	0xff
169 
170 #define BT_ISO_SYNC_TIMEOUT	0x07d0 /* 20 secs */
171 
172 struct bt_iso_io_qos {
173 	__u32 interval;
174 	__u16 latency;
175 	__u16 sdu;
176 	__u8  phy;
177 	__u8  rtn;
178 };
179 
180 struct bt_iso_ucast_qos {
181 	__u8  cig;
182 	__u8  cis;
183 	__u8  sca;
184 	__u8  packing;
185 	__u8  framing;
186 	struct bt_iso_io_qos in;
187 	struct bt_iso_io_qos out;
188 };
189 
190 struct bt_iso_bcast_qos {
191 	__u8  big;
192 	__u8  bis;
193 	__u8  sync_factor;
194 	__u8  packing;
195 	__u8  framing;
196 	struct bt_iso_io_qos in;
197 	struct bt_iso_io_qos out;
198 	__u8  encryption;
199 	__u8  bcode[16];
200 	__u8  options;
201 	__u16 skip;
202 	__u16 sync_timeout;
203 	__u8  sync_cte_type;
204 	__u8  mse;
205 	__u16 timeout;
206 };
207 
208 struct bt_iso_qos {
209 	union {
210 		struct bt_iso_ucast_qos ucast;
211 		struct bt_iso_bcast_qos bcast;
212 	};
213 };
214 
215 #define BT_ISO_PHY_1M		0x01
216 #define BT_ISO_PHY_2M		0x02
217 #define BT_ISO_PHY_CODED	0x04
218 #define BT_ISO_PHY_ANY		(BT_ISO_PHY_1M | BT_ISO_PHY_2M | \
219 				 BT_ISO_PHY_CODED)
220 
221 #define BT_CODEC	19
222 
223 struct	bt_codec_caps {
224 	__u8	len;
225 	__u8	data[];
226 } __packed;
227 
228 struct bt_codec {
229 	__u8	id;
230 	__u16	cid;
231 	__u16	vid;
232 	__u8	data_path;
233 	__u8	num_caps;
234 } __packed;
235 
236 struct bt_codecs {
237 	__u8		num_codecs;
238 	struct bt_codec	codecs[];
239 } __packed;
240 
241 #define BT_CODEC_CVSD		0x02
242 #define BT_CODEC_TRANSPARENT	0x03
243 #define BT_CODEC_MSBC		0x05
244 
245 #define BT_ISO_BASE		20
246 
247 /* Socket option value 21 reserved */
248 
249 #define BT_PKT_SEQNUM		22
250 
251 #define BT_SCM_PKT_SEQNUM	0x05
252 
253 __printf(1, 2)
254 void bt_info(const char *fmt, ...);
255 __printf(1, 2)
256 void bt_warn(const char *fmt, ...);
257 __printf(1, 2)
258 void bt_err(const char *fmt, ...);
259 #if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
260 void bt_dbg_set(bool enable);
261 bool bt_dbg_get(void);
262 __printf(1, 2)
263 void bt_dbg(const char *fmt, ...);
264 #endif
265 __printf(1, 2)
266 void bt_warn_ratelimited(const char *fmt, ...);
267 __printf(1, 2)
268 void bt_err_ratelimited(const char *fmt, ...);
269 
270 #define BT_INFO(fmt, ...)	bt_info(fmt "\n", ##__VA_ARGS__)
271 #define BT_WARN(fmt, ...)	bt_warn(fmt "\n", ##__VA_ARGS__)
272 #define BT_ERR(fmt, ...)	bt_err(fmt "\n", ##__VA_ARGS__)
273 
274 #if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
275 #define BT_DBG(fmt, ...)	bt_dbg(fmt "\n", ##__VA_ARGS__)
276 #else
277 #define BT_DBG(fmt, ...)	pr_debug(fmt "\n", ##__VA_ARGS__)
278 #endif
279 
280 #define bt_dev_name(hdev) ((hdev) ? (hdev)->name : "null")
281 
282 #define bt_dev_info(hdev, fmt, ...)				\
283 	BT_INFO("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
284 #define bt_dev_warn(hdev, fmt, ...)				\
285 	BT_WARN("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
286 #define bt_dev_err(hdev, fmt, ...)				\
287 	BT_ERR("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
288 #define bt_dev_dbg(hdev, fmt, ...)				\
289 	BT_DBG("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
290 
291 #define bt_dev_warn_ratelimited(hdev, fmt, ...)			\
292 	bt_warn_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
293 #define bt_dev_err_ratelimited(hdev, fmt, ...)			\
294 	bt_err_ratelimited("%s: " fmt, bt_dev_name(hdev), ##__VA_ARGS__)
295 
296 /* Connection and socket states */
297 enum bt_sock_state {
298 	BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
299 	BT_OPEN,
300 	BT_BOUND,
301 	BT_LISTEN,
302 	BT_CONNECT,
303 	BT_CONNECT2,
304 	BT_CONFIG,
305 	BT_DISCONN,
306 	BT_CLOSED
307 };
308 
309 /* If unused will be removed by compiler */
state_to_string(int state)310 static inline const char *state_to_string(int state)
311 {
312 	switch (state) {
313 	case BT_CONNECTED:
314 		return "BT_CONNECTED";
315 	case BT_OPEN:
316 		return "BT_OPEN";
317 	case BT_BOUND:
318 		return "BT_BOUND";
319 	case BT_LISTEN:
320 		return "BT_LISTEN";
321 	case BT_CONNECT:
322 		return "BT_CONNECT";
323 	case BT_CONNECT2:
324 		return "BT_CONNECT2";
325 	case BT_CONFIG:
326 		return "BT_CONFIG";
327 	case BT_DISCONN:
328 		return "BT_DISCONN";
329 	case BT_CLOSED:
330 		return "BT_CLOSED";
331 	}
332 
333 	return "invalid state";
334 }
335 
336 /* BD Address */
337 typedef struct {
338 	__u8 b[6];
339 } __packed bdaddr_t;
340 
341 /* BD Address type */
342 #define BDADDR_BREDR		0x00
343 #define BDADDR_LE_PUBLIC	0x01
344 #define BDADDR_LE_RANDOM	0x02
345 
bdaddr_type_is_valid(u8 type)346 static inline bool bdaddr_type_is_valid(u8 type)
347 {
348 	switch (type) {
349 	case BDADDR_BREDR:
350 	case BDADDR_LE_PUBLIC:
351 	case BDADDR_LE_RANDOM:
352 		return true;
353 	}
354 
355 	return false;
356 }
357 
bdaddr_type_is_le(u8 type)358 static inline bool bdaddr_type_is_le(u8 type)
359 {
360 	switch (type) {
361 	case BDADDR_LE_PUBLIC:
362 	case BDADDR_LE_RANDOM:
363 		return true;
364 	}
365 
366 	return false;
367 }
368 
369 #define BDADDR_ANY  (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
370 #define BDADDR_NONE (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
371 
372 /* Copy, swap, convert BD Address */
bacmp(const bdaddr_t * ba1,const bdaddr_t * ba2)373 static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
374 {
375 	return memcmp(ba1, ba2, sizeof(bdaddr_t));
376 }
bacpy(bdaddr_t * dst,const bdaddr_t * src)377 static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
378 {
379 	memcpy(dst, src, sizeof(bdaddr_t));
380 }
381 
382 void baswap(bdaddr_t *dst, const bdaddr_t *src);
383 
384 /* Common socket structures and functions */
385 
386 #define bt_sk(__sk) ((struct bt_sock *) __sk)
387 
388 struct bt_sock {
389 	struct sock sk;
390 	struct list_head accept_q;
391 	struct sock *parent;
392 	unsigned long flags;
393 	void (*skb_msg_name)(struct sk_buff *, void *, int *);
394 	void (*skb_put_cmsg)(struct sk_buff *, struct msghdr *, struct sock *);
395 };
396 
397 enum {
398 	BT_SK_DEFER_SETUP,
399 	BT_SK_SUSPEND,
400 	BT_SK_PKT_STATUS,
401 	BT_SK_PKT_SEQNUM,
402 };
403 
404 struct bt_sock_list {
405 	struct hlist_head head;
406 	rwlock_t          lock;
407 #ifdef CONFIG_PROC_FS
408         int (* custom_seq_show)(struct seq_file *, void *);
409 #endif
410 };
411 
412 int  bt_sock_register(int proto, const struct net_proto_family *ops);
413 void bt_sock_unregister(int proto);
414 void bt_sock_link(struct bt_sock_list *l, struct sock *s);
415 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
416 bool bt_sock_linked(struct bt_sock_list *l, struct sock *s);
417 struct sock *bt_sock_alloc(struct net *net, struct socket *sock,
418 			   struct proto *prot, int proto, gfp_t prio, int kern);
419 int  bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
420 		     int flags);
421 int  bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
422 			    size_t len, int flags);
423 __poll_t bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
424 int  bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
425 int  bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
426 int  bt_sock_wait_ready(struct sock *sk, unsigned int msg_flags);
427 
428 void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh);
429 void bt_accept_unlink(struct sock *sk);
430 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
431 
432 /* Skb helpers */
433 struct l2cap_ctrl {
434 	u8	sframe:1,
435 		poll:1,
436 		final:1,
437 		fcs:1,
438 		sar:2,
439 		super:2;
440 
441 	u16	reqseq;
442 	u16	txseq;
443 	u8	retries;
444 	__le16  psm;
445 	bdaddr_t bdaddr;
446 	struct l2cap_chan *chan;
447 };
448 
449 struct hci_dev;
450 
451 typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
452 typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
453 				       u16 opcode, struct sk_buff *skb);
454 
455 void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
456 			  hci_req_complete_t *req_complete,
457 			  hci_req_complete_skb_t *req_complete_skb);
458 
459 int hci_ethtool_ts_info(unsigned int index, int sk_proto,
460 			struct kernel_ethtool_ts_info *ts_info);
461 
462 #define HCI_REQ_START	BIT(0)
463 #define HCI_REQ_SKB	BIT(1)
464 
465 struct hci_ctrl {
466 	struct sock *sk;
467 	u16 opcode;
468 	u8 req_flags;
469 	u8 req_event;
470 	union {
471 		hci_req_complete_t req_complete;
472 		hci_req_complete_skb_t req_complete_skb;
473 	};
474 };
475 
476 struct mgmt_ctrl {
477 	struct hci_dev *hdev;
478 	u16 opcode;
479 };
480 
481 struct bt_skb_cb {
482 	u8 pkt_type;
483 	u8 force_active;
484 	u16 expect;
485 	u16 pkt_seqnum;
486 	u8 incoming:1;
487 	u8 pkt_status:2;
488 	union {
489 		struct l2cap_ctrl l2cap;
490 		struct hci_ctrl hci;
491 		struct mgmt_ctrl mgmt;
492 		struct scm_creds creds;
493 	};
494 };
495 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
496 
497 #define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type
498 #define hci_skb_pkt_status(skb) bt_cb((skb))->pkt_status
499 #define hci_skb_pkt_seqnum(skb) bt_cb((skb))->pkt_seqnum
500 #define hci_skb_expect(skb) bt_cb((skb))->expect
501 #define hci_skb_opcode(skb) bt_cb((skb))->hci.opcode
502 #define hci_skb_event(skb) bt_cb((skb))->hci.req_event
503 #define hci_skb_sk(skb) bt_cb((skb))->hci.sk
504 
bt_skb_alloc(unsigned int len,gfp_t how)505 static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
506 {
507 	struct sk_buff *skb;
508 
509 	skb = alloc_skb(len + BT_SKB_RESERVE, how);
510 	if (skb)
511 		skb_reserve(skb, BT_SKB_RESERVE);
512 	return skb;
513 }
514 
bt_skb_send_alloc(struct sock * sk,unsigned long len,int nb,int * err)515 static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
516 					unsigned long len, int nb, int *err)
517 {
518 	struct sk_buff *skb;
519 
520 	skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err);
521 	if (skb)
522 		skb_reserve(skb, BT_SKB_RESERVE);
523 
524 	if (!skb && *err)
525 		return NULL;
526 
527 	*err = sock_error(sk);
528 	if (*err)
529 		goto out;
530 
531 	if (sk->sk_shutdown) {
532 		*err = -ECONNRESET;
533 		goto out;
534 	}
535 
536 	return skb;
537 
538 out:
539 	kfree_skb(skb);
540 	return NULL;
541 }
542 
543 /* Shall not be called with lock_sock held */
bt_skb_sendmsg(struct sock * sk,struct msghdr * msg,size_t len,size_t mtu,size_t headroom,size_t tailroom)544 static inline struct sk_buff *bt_skb_sendmsg(struct sock *sk,
545 					     struct msghdr *msg,
546 					     size_t len, size_t mtu,
547 					     size_t headroom, size_t tailroom)
548 {
549 	struct sk_buff *skb;
550 	size_t size = min_t(size_t, len, mtu);
551 	int err;
552 
553 	skb = bt_skb_send_alloc(sk, size + headroom + tailroom,
554 				msg->msg_flags & MSG_DONTWAIT, &err);
555 	if (!skb)
556 		return ERR_PTR(err);
557 
558 	skb_reserve(skb, headroom);
559 	skb_tailroom_reserve(skb, mtu, tailroom);
560 
561 	if (!copy_from_iter_full(skb_put(skb, size), size, &msg->msg_iter)) {
562 		kfree_skb(skb);
563 		return ERR_PTR(-EFAULT);
564 	}
565 
566 	skb->priority = READ_ONCE(sk->sk_priority);
567 
568 	return skb;
569 }
570 
571 /* Similar to bt_skb_sendmsg but can split the msg into multiple fragments
572  * accourding to the MTU.
573  */
bt_skb_sendmmsg(struct sock * sk,struct msghdr * msg,size_t len,size_t mtu,size_t headroom,size_t tailroom)574 static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk,
575 					      struct msghdr *msg,
576 					      size_t len, size_t mtu,
577 					      size_t headroom, size_t tailroom)
578 {
579 	struct sk_buff *skb, **frag;
580 
581 	skb = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
582 	if (IS_ERR(skb))
583 		return skb;
584 
585 	len -= skb->len;
586 	if (!len)
587 		return skb;
588 
589 	/* Add remaining data over MTU as continuation fragments */
590 	frag = &skb_shinfo(skb)->frag_list;
591 	while (len) {
592 		struct sk_buff *tmp;
593 
594 		tmp = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
595 		if (IS_ERR(tmp)) {
596 			return skb;
597 		}
598 
599 		len -= tmp->len;
600 
601 		*frag = tmp;
602 		frag = &(*frag)->next;
603 	}
604 
605 	return skb;
606 }
607 
608 int bt_to_errno(u16 code);
609 __u8 bt_status(int err);
610 
611 void hci_sock_set_flag(struct sock *sk, int nr);
612 void hci_sock_clear_flag(struct sock *sk, int nr);
613 int hci_sock_test_flag(struct sock *sk, int nr);
614 unsigned short hci_sock_get_channel(struct sock *sk);
615 u32 hci_sock_get_cookie(struct sock *sk);
616 
617 int hci_sock_init(void);
618 void hci_sock_cleanup(void);
619 
620 int bt_sysfs_init(void);
621 void bt_sysfs_cleanup(void);
622 
623 int bt_procfs_init(struct net *net, const char *name,
624 		   struct bt_sock_list *sk_list,
625 		   int (*seq_show)(struct seq_file *, void *));
626 void bt_procfs_cleanup(struct net *net, const char *name);
627 
628 extern struct dentry *bt_debugfs;
629 
630 int l2cap_init(void);
631 void l2cap_exit(void);
632 
633 #if IS_ENABLED(CONFIG_BT_BREDR)
634 int sco_init(void);
635 void sco_exit(void);
636 #else
sco_init(void)637 static inline int sco_init(void)
638 {
639 	return 0;
640 }
641 
sco_exit(void)642 static inline void sco_exit(void)
643 {
644 }
645 #endif
646 
647 #if IS_ENABLED(CONFIG_BT_LE)
648 int iso_init(void);
649 int iso_exit(void);
650 bool iso_enabled(void);
651 #else
iso_init(void)652 static inline int iso_init(void)
653 {
654 	return 0;
655 }
656 
iso_exit(void)657 static inline int iso_exit(void)
658 {
659 	return 0;
660 }
661 
iso_enabled(void)662 static inline bool iso_enabled(void)
663 {
664 	return false;
665 }
666 #endif
667 
668 int mgmt_init(void);
669 void mgmt_exit(void);
670 void mgmt_cleanup(struct sock *sk);
671 
672 void bt_sock_reclassify_lock(struct sock *sk, int proto);
673 
674 #endif /* __BLUETOOTH_H */
675