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