Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 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 | |
Andrei Emeltchenko | 97e8e89 | 2012-05-29 13:59:17 +0300 | [diff] [blame] | 18 | #include <net/bluetooth/l2cap.h> |
| 19 | |
Andrei Emeltchenko | 8598d06 | 2012-05-29 13:59:09 +0300 | [diff] [blame] | 20 | #define A2MP_FEAT_EXT 0x8000 |
| 21 | |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 22 | enum amp_mgr_state { |
| 23 | READ_LOC_AMP_INFO, |
| 24 | }; |
| 25 | |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 26 | struct amp_mgr { |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 27 | struct list_head list; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 28 | struct l2cap_conn *l2cap_conn; |
| 29 | struct l2cap_chan *a2mp_chan; |
| 30 | struct kref kref; |
| 31 | __u8 ident; |
| 32 | __u8 handle; |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 33 | enum amp_mgr_state state; |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 34 | unsigned long flags; |
| 35 | }; |
| 36 | |
Andrei Emeltchenko | f6d3c6e | 2012-05-29 13:59:03 +0300 | [diff] [blame] | 37 | struct a2mp_cmd { |
| 38 | __u8 code; |
| 39 | __u8 ident; |
| 40 | __le16 len; |
| 41 | __u8 data[0]; |
| 42 | } __packed; |
| 43 | |
Andrei Emeltchenko | b9058fb | 2012-05-29 13:59:05 +0300 | [diff] [blame] | 44 | /* A2MP command codes */ |
| 45 | #define A2MP_COMMAND_REJ 0x01 |
| 46 | struct a2mp_cmd_rej { |
| 47 | __le16 reason; |
| 48 | __u8 data[0]; |
| 49 | } __packed; |
| 50 | |
| 51 | #define A2MP_DISCOVER_REQ 0x02 |
| 52 | struct a2mp_discov_req { |
| 53 | __le16 mtu; |
| 54 | __le16 ext_feat; |
| 55 | } __packed; |
| 56 | |
| 57 | struct a2mp_cl { |
| 58 | __u8 id; |
| 59 | __u8 type; |
| 60 | __u8 status; |
| 61 | } __packed; |
| 62 | |
| 63 | #define A2MP_DISCOVER_RSP 0x03 |
| 64 | struct a2mp_discov_rsp { |
| 65 | __le16 mtu; |
| 66 | __le16 ext_feat; |
| 67 | struct a2mp_cl cl[0]; |
| 68 | } __packed; |
| 69 | |
| 70 | #define A2MP_CHANGE_NOTIFY 0x04 |
| 71 | #define A2MP_CHANGE_RSP 0x05 |
| 72 | |
| 73 | #define A2MP_GETINFO_REQ 0x06 |
| 74 | struct a2mp_info_req { |
| 75 | __u8 id; |
| 76 | } __packed; |
| 77 | |
| 78 | #define A2MP_GETINFO_RSP 0x07 |
| 79 | struct a2mp_info_rsp { |
| 80 | __u8 id; |
| 81 | __u8 status; |
| 82 | __le32 total_bw; |
| 83 | __le32 max_bw; |
| 84 | __le32 min_latency; |
| 85 | __le16 pal_cap; |
| 86 | __le16 assoc_size; |
| 87 | } __packed; |
| 88 | |
| 89 | #define A2MP_GETAMPASSOC_REQ 0x08 |
| 90 | struct a2mp_amp_assoc_req { |
| 91 | __u8 id; |
| 92 | } __packed; |
| 93 | |
| 94 | #define A2MP_GETAMPASSOC_RSP 0x09 |
| 95 | struct a2mp_amp_assoc_rsp { |
| 96 | __u8 id; |
| 97 | __u8 status; |
| 98 | __u8 amp_assoc[0]; |
| 99 | } __packed; |
| 100 | |
| 101 | #define A2MP_CREATEPHYSLINK_REQ 0x0A |
| 102 | #define A2MP_DISCONNPHYSLINK_REQ 0x0C |
| 103 | struct a2mp_physlink_req { |
| 104 | __u8 local_id; |
| 105 | __u8 remote_id; |
| 106 | __u8 amp_assoc[0]; |
| 107 | } __packed; |
| 108 | |
| 109 | #define A2MP_CREATEPHYSLINK_RSP 0x0B |
| 110 | #define A2MP_DISCONNPHYSLINK_RSP 0x0D |
| 111 | struct a2mp_physlink_rsp { |
| 112 | __u8 local_id; |
| 113 | __u8 remote_id; |
| 114 | __u8 status; |
| 115 | } __packed; |
| 116 | |
Andrei Emeltchenko | e7af522e | 2012-05-29 13:59:06 +0300 | [diff] [blame] | 117 | /* A2MP response status */ |
| 118 | #define A2MP_STATUS_SUCCESS 0x00 |
| 119 | #define A2MP_STATUS_INVALID_CTRL_ID 0x01 |
| 120 | #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02 |
| 121 | #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02 |
| 122 | #define A2MP_STATUS_COLLISION_OCCURED 0x03 |
| 123 | #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04 |
| 124 | #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05 |
| 125 | #define A2MP_STATUS_SECURITY_VIOLATION 0x06 |
| 126 | |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 127 | extern struct list_head amp_mgr_list; |
| 128 | extern struct mutex amp_mgr_list_lock; |
| 129 | |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 130 | void amp_mgr_get(struct amp_mgr *mgr); |
| 131 | int amp_mgr_put(struct amp_mgr *mgr); |
Andrei Emeltchenko | 97e8e89 | 2012-05-29 13:59:17 +0300 | [diff] [blame] | 132 | struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, |
| 133 | struct sk_buff *skb); |
Andrei Emeltchenko | f97268f | 2012-09-27 17:26:07 +0300 | [diff] [blame] | 134 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state); |
Andrei Emeltchenko | 8e2a0d9 | 2012-09-27 17:26:08 +0300 | [diff] [blame^] | 135 | void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data); |
| 136 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev); |
Andrei Emeltchenko | 9740e49 | 2012-05-29 13:59:02 +0300 | [diff] [blame] | 137 | |
| 138 | #endif /* __A2MP_H */ |