hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/net/bluetooth/l2cap.h
....@@ -29,6 +29,7 @@
2929
3030 #include <asm/unaligned.h>
3131 #include <linux/atomic.h>
32
+#include <linux/android_kabi.h>
3233
3334 /* L2CAP defaults */
3435 #define L2CAP_DEFAULT_MTU 672
....@@ -47,6 +48,7 @@
4748 #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF
4849 #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */
4950 #define L2CAP_LE_MIN_MTU 23
51
+#define L2CAP_ECRED_CONN_SCID_MAX 5
5052
5153 #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)
5254 #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000)
....@@ -119,6 +121,10 @@
119121 #define L2CAP_LE_CONN_REQ 0x14
120122 #define L2CAP_LE_CONN_RSP 0x15
121123 #define L2CAP_LE_CREDITS 0x16
124
+#define L2CAP_ECRED_CONN_REQ 0x17
125
+#define L2CAP_ECRED_CONN_RSP 0x18
126
+#define L2CAP_ECRED_RECONF_REQ 0x19
127
+#define L2CAP_ECRED_RECONF_RSP 0x1a
122128
123129 /* L2CAP extended feature mask */
124130 #define L2CAP_FEAT_FLOWCTL 0x00000001
....@@ -277,12 +283,21 @@
277283 #define L2CAP_CR_SEC_BLOCK 0x0003
278284 #define L2CAP_CR_NO_MEM 0x0004
279285 #define L2CAP_CR_BAD_AMP 0x0005
280
-#define L2CAP_CR_AUTHENTICATION 0x0005
281
-#define L2CAP_CR_AUTHORIZATION 0x0006
282
-#define L2CAP_CR_BAD_KEY_SIZE 0x0007
283
-#define L2CAP_CR_ENCRYPTION 0x0008
284
-#define L2CAP_CR_INVALID_SCID 0x0009
285
-#define L2CAP_CR_SCID_IN_USE 0x000A
286
+#define L2CAP_CR_INVALID_SCID 0x0006
287
+#define L2CAP_CR_SCID_IN_USE 0x0007
288
+
289
+/* credit based connect results */
290
+#define L2CAP_CR_LE_SUCCESS 0x0000
291
+#define L2CAP_CR_LE_BAD_PSM 0x0002
292
+#define L2CAP_CR_LE_NO_MEM 0x0004
293
+#define L2CAP_CR_LE_AUTHENTICATION 0x0005
294
+#define L2CAP_CR_LE_AUTHORIZATION 0x0006
295
+#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007
296
+#define L2CAP_CR_LE_ENCRYPTION 0x0008
297
+#define L2CAP_CR_LE_INVALID_SCID 0x0009
298
+#define L2CAP_CR_LE_SCID_IN_USE 0X000A
299
+#define L2CAP_CR_LE_UNACCEPT_PARAMS 0X000B
300
+#define L2CAP_CR_LE_INVALID_PARAMS 0X000C
286301
287302 /* connect/create channel status */
288303 #define L2CAP_CS_NO_INFO 0x0000
....@@ -292,14 +307,14 @@
292307 struct l2cap_conf_req {
293308 __le16 dcid;
294309 __le16 flags;
295
- __u8 data[0];
310
+ __u8 data[];
296311 } __packed;
297312
298313 struct l2cap_conf_rsp {
299314 __le16 scid;
300315 __le16 flags;
301316 __le16 result;
302
- __u8 data[0];
317
+ __u8 data[];
303318 } __packed;
304319
305320 #define L2CAP_CONF_SUCCESS 0x0000
....@@ -315,7 +330,7 @@
315330 struct l2cap_conf_opt {
316331 __u8 type;
317332 __u8 len;
318
- __u8 val[0];
333
+ __u8 val[];
319334 } __packed;
320335 #define L2CAP_CONF_OPT_SIZE 2
321336
....@@ -352,6 +367,7 @@
352367 * ever be used in the BR/EDR configuration phase.
353368 */
354369 #define L2CAP_MODE_LE_FLOWCTL 0x80
370
+#define L2CAP_MODE_EXT_FLOWCTL 0x81
355371
356372 struct l2cap_conf_efs {
357373 __u8 id;
....@@ -385,7 +401,7 @@
385401 struct l2cap_info_rsp {
386402 __le16 type;
387403 __le16 result;
388
- __u8 data[0];
404
+ __u8 data[];
389405 } __packed;
390406
391407 struct l2cap_create_chan_req {
....@@ -455,9 +471,6 @@
455471 #define L2CAP_CONN_PARAM_ACCEPTED 0x0000
456472 #define L2CAP_CONN_PARAM_REJECTED 0x0001
457473
458
-#define L2CAP_LE_MAX_CREDITS 10
459
-#define L2CAP_LE_DEFAULT_MPS 230
460
-
461474 struct l2cap_le_conn_req {
462475 __le16 psm;
463476 __le16 scid;
....@@ -477,6 +490,39 @@
477490 struct l2cap_le_credits {
478491 __le16 cid;
479492 __le16 credits;
493
+} __packed;
494
+
495
+#define L2CAP_ECRED_MIN_MTU 64
496
+#define L2CAP_ECRED_MIN_MPS 64
497
+
498
+struct l2cap_ecred_conn_req {
499
+ __le16 psm;
500
+ __le16 mtu;
501
+ __le16 mps;
502
+ __le16 credits;
503
+ __le16 scid[];
504
+} __packed;
505
+
506
+struct l2cap_ecred_conn_rsp {
507
+ __le16 mtu;
508
+ __le16 mps;
509
+ __le16 credits;
510
+ __le16 result;
511
+ __le16 dcid[];
512
+};
513
+
514
+struct l2cap_ecred_reconf_req {
515
+ __le16 mtu;
516
+ __le16 mps;
517
+ __le16 scid[];
518
+} __packed;
519
+
520
+#define L2CAP_RECONF_SUCCESS 0x0000
521
+#define L2CAP_RECONF_INVALID_MTU 0x0001
522
+#define L2CAP_RECONF_INVALID_MPS 0x0002
523
+
524
+struct l2cap_ecred_reconf_rsp {
525
+ __le16 result;
480526 } __packed;
481527
482528 /* ----- L2CAP channels and connections ----- */
....@@ -598,6 +644,9 @@
598644 void *data;
599645 const struct l2cap_ops *ops;
600646 struct mutex lock;
647
+
648
+ ANDROID_KABI_RESERVE(1);
649
+ ANDROID_KABI_RESERVE(2);
601650 };
602651
603652 struct l2cap_ops {
....@@ -616,11 +665,15 @@
616665 void (*suspend) (struct l2cap_chan *chan);
617666 void (*set_shutdown) (struct l2cap_chan *chan);
618667 long (*get_sndtimeo) (struct l2cap_chan *chan);
668
+ struct pid *(*get_peer_pid) (struct l2cap_chan *chan);
619669 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
620670 unsigned long hdr_len,
621671 unsigned long len, int nb);
622672 int (*filter) (struct l2cap_chan * chan,
623673 struct sk_buff *skb);
674
+
675
+ ANDROID_KABI_RESERVE(1);
676
+ ANDROID_KABI_RESERVE(2);
624677 };
625678
626679 struct l2cap_conn {
....@@ -656,6 +709,9 @@
656709 struct mutex chan_lock;
657710 struct kref ref;
658711 struct list_head users;
712
+
713
+ ANDROID_KABI_RESERVE(1);
714
+ ANDROID_KABI_RESERVE(2);
659715 };
660716
661717 struct l2cap_user {
....@@ -722,6 +778,7 @@
722778 FLAG_EFS_ENABLE,
723779 FLAG_DEFER_SETUP,
724780 FLAG_LE_CONN_REQ_SENT,
781
+ FLAG_ECRED_CONN_REQ_SENT,
725782 FLAG_PENDING_SECURITY,
726783 FLAG_HOLD_HCI_CONN,
727784 };
....@@ -798,6 +855,7 @@
798855 };
799856
800857 void l2cap_chan_hold(struct l2cap_chan *c);
858
+struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c);
801859 void l2cap_chan_put(struct l2cap_chan *c);
802860
803861 static inline void l2cap_chan_lock(struct l2cap_chan *chan)
....@@ -915,12 +973,14 @@
915973 }
916974
917975 extern bool disable_ertm;
976
+extern bool enable_ecred;
918977
919978 int l2cap_init_sockets(void);
920979 void l2cap_cleanup_sockets(void);
921980 bool l2cap_is_socket(struct socket *sock);
922981
923982 void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan);
983
+void __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan);
924984 void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
925985
926986 int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
....@@ -930,6 +990,7 @@
930990 void l2cap_chan_close(struct l2cap_chan *chan, int reason);
931991 int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
932992 bdaddr_t *dst, u8 dst_type);
993
+int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
933994 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
934995 void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
935996 int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);
....@@ -937,6 +998,9 @@
937998 int l2cap_ertm_init(struct l2cap_chan *chan);
938999 void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
9391000 void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
1001
+typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data);
1002
+void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func,
1003
+ void *data);
9401004 void l2cap_chan_del(struct l2cap_chan *chan, int err);
9411005 void l2cap_send_conn_req(struct l2cap_chan *chan);
9421006 void l2cap_move_start(struct l2cap_chan *chan);