Thomas Gleixner | 97fb5e8 | 2019-05-29 07:17:58 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 2 | /* |
| 3 | Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved. |
| 4 | Copyright (c) 2011,2012 Intel Corp. |
| 5 | |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef __A2MP_H |
| 9 | #define __A2MP_H |
| 10 | |
Andrei Emeltchenko | 97e8e89 | 2012-05-29 13:59:17 +0300 | [diff] [blame] | 11 | #include <net/bluetooth/l2cap.h> |
| 12 | |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 13 | enum amp_mgr_state { |
| 14 | READ_LOC_AMP_INFO, |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 15 | READ_LOC_AMP_ASSOC, |
Andrei Emeltchenko | 9495b2e | 2012-09-27 17:26:22 +0300 | [diff] [blame] | 16 | READ_LOC_AMP_ASSOC_FINAL, |
Andrei Emeltchenko | 8e05e3b | 2012-12-07 14:59:05 +0200 | [diff] [blame] | 17 | WRITE_REMOTE_AMP_ASSOC, |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 18 | }; |
| 19 | |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 20 | struct amp_mgr { |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 21 | struct list_head list; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 22 | struct l2cap_conn *l2cap_conn; |
| 23 | struct l2cap_chan *a2mp_chan; |
Andrei Emeltchenko | 93c3e8f | 2012-09-27 17:26:16 +0300 | [diff] [blame] | 24 | struct l2cap_chan *bredr_chan; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 25 | struct kref kref; |
| 26 | __u8 ident; |
| 27 | __u8 handle; |
Andrei Emeltchenko | cb6801c6 | 2012-12-07 14:59:08 +0200 | [diff] [blame] | 28 | unsigned long state; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 29 | unsigned long flags; |
Andrei Emeltchenko | 52c0d6e | 2012-09-27 17:26:12 +0300 | [diff] [blame] | 30 | |
| 31 | struct list_head amp_ctrls; |
| 32 | struct mutex amp_ctrls_lock; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 33 | }; |
| 34 | |
Andrei Emeltchenko | f6d3c6e | 2012-05-29 13:59:03 +0300 | [diff] [blame] | 35 | struct a2mp_cmd { |
| 36 | __u8 code; |
| 37 | __u8 ident; |
| 38 | __le16 len; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 39 | __u8 data[]; |
Andrei Emeltchenko | f6d3c6e | 2012-05-29 13:59:03 +0300 | [diff] [blame] | 40 | } __packed; |
| 41 | |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 42 | /* A2MP command codes */ |
| 43 | #define A2MP_COMMAND_REJ 0x01 |
| 44 | struct a2mp_cmd_rej { |
| 45 | __le16 reason; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 46 | __u8 data[]; |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 47 | } __packed; |
| 48 | |
| 49 | #define A2MP_DISCOVER_REQ 0x02 |
| 50 | struct a2mp_discov_req { |
| 51 | __le16 mtu; |
| 52 | __le16 ext_feat; |
| 53 | } __packed; |
| 54 | |
| 55 | struct a2mp_cl { |
| 56 | __u8 id; |
| 57 | __u8 type; |
| 58 | __u8 status; |
| 59 | } __packed; |
| 60 | |
| 61 | #define A2MP_DISCOVER_RSP 0x03 |
| 62 | struct a2mp_discov_rsp { |
| 63 | __le16 mtu; |
| 64 | __le16 ext_feat; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 65 | struct a2mp_cl cl[]; |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 66 | } __packed; |
| 67 | |
| 68 | #define A2MP_CHANGE_NOTIFY 0x04 |
| 69 | #define A2MP_CHANGE_RSP 0x05 |
| 70 | |
| 71 | #define A2MP_GETINFO_REQ 0x06 |
| 72 | struct a2mp_info_req { |
| 73 | __u8 id; |
| 74 | } __packed; |
| 75 | |
| 76 | #define A2MP_GETINFO_RSP 0x07 |
| 77 | struct a2mp_info_rsp { |
| 78 | __u8 id; |
| 79 | __u8 status; |
| 80 | __le32 total_bw; |
| 81 | __le32 max_bw; |
| 82 | __le32 min_latency; |
| 83 | __le16 pal_cap; |
| 84 | __le16 assoc_size; |
| 85 | } __packed; |
| 86 | |
| 87 | #define A2MP_GETAMPASSOC_REQ 0x08 |
| 88 | struct a2mp_amp_assoc_req { |
| 89 | __u8 id; |
| 90 | } __packed; |
| 91 | |
| 92 | #define A2MP_GETAMPASSOC_RSP 0x09 |
| 93 | struct a2mp_amp_assoc_rsp { |
| 94 | __u8 id; |
| 95 | __u8 status; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 96 | __u8 amp_assoc[]; |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 97 | } __packed; |
| 98 | |
| 99 | #define A2MP_CREATEPHYSLINK_REQ 0x0A |
| 100 | #define A2MP_DISCONNPHYSLINK_REQ 0x0C |
| 101 | struct a2mp_physlink_req { |
| 102 | __u8 local_id; |
| 103 | __u8 remote_id; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 104 | __u8 amp_assoc[]; |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 105 | } __packed; |
| 106 | |
| 107 | #define A2MP_CREATEPHYSLINK_RSP 0x0B |
| 108 | #define A2MP_DISCONNPHYSLINK_RSP 0x0D |
| 109 | struct a2mp_physlink_rsp { |
| 110 | __u8 local_id; |
| 111 | __u8 remote_id; |
| 112 | __u8 status; |
| 113 | } __packed; |
| 114 | |
Andrei Emeltchenko | e7af522e | 2012-05-29 13:59:06 +0300 | [diff] [blame] | 115 | /* A2MP response status */ |
| 116 | #define A2MP_STATUS_SUCCESS 0x00 |
| 117 | #define A2MP_STATUS_INVALID_CTRL_ID 0x01 |
| 118 | #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02 |
| 119 | #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02 |
| 120 | #define A2MP_STATUS_COLLISION_OCCURED 0x03 |
| 121 | #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04 |
| 122 | #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05 |
| 123 | #define A2MP_STATUS_SECURITY_VIOLATION 0x06 |
| 124 | |
Andrei Emeltchenko | f706adf | 2012-10-18 13:16:19 +0300 | [diff] [blame] | 125 | struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr); |
Arron Wang | 244bc37 | 2015-07-24 17:12:55 +0800 | [diff] [blame] | 126 | |
| 127 | #if IS_ENABLED(CONFIG_BT_HS) |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 128 | int amp_mgr_put(struct amp_mgr *mgr); |
Andrei Emeltchenko | 97e8e89 | 2012-05-29 13:59:17 +0300 | [diff] [blame] | 129 | struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, |
| 130 | struct sk_buff *skb); |
Andrei Emeltchenko | 93c3e8f | 2012-09-27 17:26:16 +0300 | [diff] [blame] | 131 | void a2mp_discover_amp(struct l2cap_chan *chan); |
Arron Wang | 244bc37 | 2015-07-24 17:12:55 +0800 | [diff] [blame] | 132 | #else |
| 133 | static inline int amp_mgr_put(struct amp_mgr *mgr) |
| 134 | { |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | static inline struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, |
| 139 | struct sk_buff *skb) |
| 140 | { |
| 141 | return NULL; |
| 142 | } |
| 143 | |
| 144 | static inline void a2mp_discover_amp(struct l2cap_chan *chan) |
| 145 | { |
| 146 | } |
| 147 | #endif |
| 148 | |
Andrei Emeltchenko | 8e2a0d9 | 2012-09-27 17:26:08 +0300 | [diff] [blame] | 149 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev); |
Andrei Emeltchenko | 903e454 | 2012-09-27 17:26:09 +0300 | [diff] [blame] | 150 | void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status); |
Andrei Emeltchenko | 9495b2e | 2012-09-27 17:26:22 +0300 | [diff] [blame] | 151 | void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status); |
Andrei Emeltchenko | 8e05e3b | 2012-12-07 14:59:05 +0200 | [diff] [blame] | 152 | void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status); |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 153 | |
| 154 | #endif /* __A2MP_H */ |