blob: 9410e272d8b66fc11824d79ffb41d46081005b09 [file] [log] [blame]
Andrei Emeltchenko466f8002012-05-29 13:59:01 +03001/*
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#include <net/bluetooth/bluetooth.h>
16#include <net/bluetooth/hci_core.h>
17#include <net/bluetooth/l2cap.h>
Andrei Emeltchenko9740e492012-05-29 13:59:02 +030018#include <net/bluetooth/a2mp.h>
Andrei Emeltchenko903e4542012-09-27 17:26:09 +030019#include <net/bluetooth/amp.h>
Andrei Emeltchenko466f8002012-05-29 13:59:01 +030020
Andrei Emeltchenkof97268f2012-09-27 17:26:07 +030021/* Global AMP Manager list */
22LIST_HEAD(amp_mgr_list);
23DEFINE_MUTEX(amp_mgr_list_lock);
24
Andrei Emeltchenkof6d3c6e2012-05-29 13:59:03 +030025/* A2MP build & send command helper functions */
26static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data)
27{
28 struct a2mp_cmd *cmd;
29 int plen;
30
31 plen = sizeof(*cmd) + len;
32 cmd = kzalloc(plen, GFP_KERNEL);
33 if (!cmd)
34 return NULL;
35
36 cmd->code = code;
37 cmd->ident = ident;
38 cmd->len = cpu_to_le16(len);
39
40 memcpy(cmd->data, data, len);
41
42 return cmd;
43}
44
Andrei Emeltchenko8e2a0d92012-09-27 17:26:08 +030045void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
Andrei Emeltchenkof6d3c6e2012-05-29 13:59:03 +030046{
47 struct l2cap_chan *chan = mgr->a2mp_chan;
48 struct a2mp_cmd *cmd;
49 u16 total_len = len + sizeof(*cmd);
50 struct kvec iv;
51 struct msghdr msg;
52
53 cmd = __a2mp_build(code, ident, len, data);
54 if (!cmd)
55 return;
56
57 iv.iov_base = cmd;
58 iv.iov_len = total_len;
59
60 memset(&msg, 0, sizeof(msg));
61
62 msg.msg_iov = (struct iovec *) &iv;
63 msg.msg_iovlen = 1;
64
65 l2cap_chan_send(chan, &msg, total_len, 0);
66
67 kfree(cmd);
68}
69
Andrei Emeltchenko9495b2e2012-09-27 17:26:22 +030070u8 __next_ident(struct amp_mgr *mgr)
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +030071{
72 if (++mgr->ident == 0)
73 mgr->ident = 1;
74
75 return mgr->ident;
76}
77
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030078/* hci_dev_list shall be locked */
Marcel Holtmann23f0cb42013-10-05 11:47:47 -070079static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl)
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030080{
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030081 struct hci_dev *hdev;
Marcel Holtmanne8803532013-10-06 02:08:35 -070082 int i = 1;
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030083
Marcel Holtmann346e7092013-10-05 11:47:46 -070084 cl[0].id = AMP_ID_BREDR;
85 cl[0].type = AMP_TYPE_BREDR;
86 cl[0].status = AMP_STATUS_BLUETOOTH_ONLY;
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030087
88 list_for_each_entry(hdev, &hci_dev_list, list) {
Marcel Holtmanne8803532013-10-06 02:08:35 -070089 if (hdev->dev_type == HCI_AMP) {
90 cl[i].id = hdev->id;
91 cl[i].type = hdev->amp_type;
92 cl[i].status = hdev->amp_status;
93 i++;
94 }
Andrei Emeltchenko8598d062012-05-29 13:59:09 +030095 }
96}
97
Andrei Emeltchenko21dbd2c2012-05-29 13:59:08 +030098/* Processing A2MP messages */
99static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb,
100 struct a2mp_cmd *hdr)
101{
102 struct a2mp_cmd_rej *rej = (void *) skb->data;
103
104 if (le16_to_cpu(hdr->len) < sizeof(*rej))
105 return -EINVAL;
106
107 BT_DBG("ident %d reason %d", hdr->ident, le16_to_cpu(rej->reason));
108
109 skb_pull(skb, sizeof(*rej));
110
111 return 0;
112}
113
Andrei Emeltchenko8598d062012-05-29 13:59:09 +0300114static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb,
115 struct a2mp_cmd *hdr)
116{
117 struct a2mp_discov_req *req = (void *) skb->data;
118 u16 len = le16_to_cpu(hdr->len);
119 struct a2mp_discov_rsp *rsp;
120 u16 ext_feat;
121 u8 num_ctrl;
Marcel Holtmannf822c412013-10-05 11:47:41 -0700122 struct hci_dev *hdev;
Andrei Emeltchenko8598d062012-05-29 13:59:09 +0300123
124 if (len < sizeof(*req))
125 return -EINVAL;
126
127 skb_pull(skb, sizeof(*req));
128
129 ext_feat = le16_to_cpu(req->ext_feat);
130
131 BT_DBG("mtu %d efm 0x%4.4x", le16_to_cpu(req->mtu), ext_feat);
132
133 /* check that packet is not broken for now */
134 while (ext_feat & A2MP_FEAT_EXT) {
135 if (len < sizeof(ext_feat))
136 return -EINVAL;
137
138 ext_feat = get_unaligned_le16(skb->data);
139 BT_DBG("efm 0x%4.4x", ext_feat);
140 len -= sizeof(ext_feat);
141 skb_pull(skb, sizeof(ext_feat));
142 }
143
144 read_lock(&hci_dev_list_lock);
145
Marcel Holtmannf822c412013-10-05 11:47:41 -0700146 /* at minimum the BR/EDR needs to be listed */
147 num_ctrl = 1;
148
149 list_for_each_entry(hdev, &hci_dev_list, list) {
150 if (hdev->dev_type == HCI_AMP)
151 num_ctrl++;
152 }
153
Andrei Emeltchenko8598d062012-05-29 13:59:09 +0300154 len = num_ctrl * sizeof(struct a2mp_cl) + sizeof(*rsp);
155 rsp = kmalloc(len, GFP_ATOMIC);
156 if (!rsp) {
157 read_unlock(&hci_dev_list_lock);
158 return -ENOMEM;
159 }
160
161 rsp->mtu = __constant_cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU);
162 rsp->ext_feat = 0;
163
Marcel Holtmann23f0cb42013-10-05 11:47:47 -0700164 __a2mp_add_cl(mgr, rsp->cl);
Andrei Emeltchenko8598d062012-05-29 13:59:09 +0300165
166 read_unlock(&hci_dev_list_lock);
167
168 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp);
169
170 kfree(rsp);
171 return 0;
172}
173
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300174static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
175 struct a2mp_cmd *hdr)
176{
177 struct a2mp_discov_rsp *rsp = (void *) skb->data;
178 u16 len = le16_to_cpu(hdr->len);
179 struct a2mp_cl *cl;
180 u16 ext_feat;
Andrei Emeltchenko2766be42012-09-27 17:26:21 +0300181 bool found = false;
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300182
183 if (len < sizeof(*rsp))
184 return -EINVAL;
185
186 len -= sizeof(*rsp);
187 skb_pull(skb, sizeof(*rsp));
188
189 ext_feat = le16_to_cpu(rsp->ext_feat);
190
191 BT_DBG("mtu %d efm 0x%4.4x", le16_to_cpu(rsp->mtu), ext_feat);
192
193 /* check that packet is not broken for now */
194 while (ext_feat & A2MP_FEAT_EXT) {
195 if (len < sizeof(ext_feat))
196 return -EINVAL;
197
198 ext_feat = get_unaligned_le16(skb->data);
199 BT_DBG("efm 0x%4.4x", ext_feat);
200 len -= sizeof(ext_feat);
201 skb_pull(skb, sizeof(ext_feat));
202 }
203
204 cl = (void *) skb->data;
205 while (len >= sizeof(*cl)) {
206 BT_DBG("Remote AMP id %d type %d status %d", cl->id, cl->type,
207 cl->status);
208
Marcel Holtmanna646bd82013-10-05 13:57:53 -0700209 if (cl->id != AMP_ID_BREDR && cl->type != AMP_TYPE_BREDR) {
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300210 struct a2mp_info_req req;
211
Andrei Emeltchenko2766be42012-09-27 17:26:21 +0300212 found = true;
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300213 req.id = cl->id;
214 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr),
215 sizeof(req), &req);
216 }
217
218 len -= sizeof(*cl);
219 cl = (void *) skb_pull(skb, sizeof(*cl));
220 }
221
Andrei Emeltchenko2766be42012-09-27 17:26:21 +0300222 /* Fall back to L2CAP init sequence */
223 if (!found) {
224 struct l2cap_conn *conn = mgr->l2cap_conn;
225 struct l2cap_chan *chan;
226
227 mutex_lock(&conn->chan_lock);
228
229 list_for_each_entry(chan, &conn->chan_l, list) {
230
231 BT_DBG("chan %p state %s", chan,
232 state_to_string(chan->state));
233
234 if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP)
235 continue;
236
237 l2cap_chan_lock(chan);
238
239 if (chan->state == BT_CONNECT)
240 l2cap_send_conn_req(chan);
241
242 l2cap_chan_unlock(chan);
243 }
244
245 mutex_unlock(&conn->chan_lock);
246 }
247
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300248 return 0;
249}
250
Andrei Emeltchenko329d81af2012-05-29 13:59:10 +0300251static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb,
252 struct a2mp_cmd *hdr)
253{
254 struct a2mp_cl *cl = (void *) skb->data;
255
256 while (skb->len >= sizeof(*cl)) {
257 BT_DBG("Controller id %d type %d status %d", cl->id, cl->type,
258 cl->status);
259 cl = (struct a2mp_cl *) skb_pull(skb, sizeof(*cl));
260 }
261
262 /* TODO send A2MP_CHANGE_RSP */
263
264 return 0;
265}
266
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300267static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
268 struct a2mp_cmd *hdr)
269{
270 struct a2mp_info_req *req = (void *) skb->data;
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300271 struct hci_dev *hdev;
272
273 if (le16_to_cpu(hdr->len) < sizeof(*req))
274 return -EINVAL;
275
276 BT_DBG("id %d", req->id);
277
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300278 hdev = hci_dev_get(req->id);
Andrei Emeltchenkobc8dce42012-09-28 14:28:50 +0300279 if (!hdev || hdev->dev_type != HCI_AMP) {
Andrei Emeltchenko8e2a0d92012-09-27 17:26:08 +0300280 struct a2mp_info_rsp rsp;
281
282 rsp.id = req->id;
283 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
284
285 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp),
286 &rsp);
Andrei Emeltchenkobc8dce42012-09-28 14:28:50 +0300287
288 goto done;
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300289 }
290
Andrei Emeltchenkocb6801c62012-12-07 14:59:08 +0200291 set_bit(READ_LOC_AMP_INFO, &mgr->state);
Andrei Emeltchenkobc8dce42012-09-28 14:28:50 +0300292 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300293
Andrei Emeltchenkobc8dce42012-09-28 14:28:50 +0300294done:
295 if (hdev)
296 hci_dev_put(hdev);
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300297
298 skb_pull(skb, sizeof(*req));
299 return 0;
300}
301
Andrei Emeltchenko0d868de2012-09-27 17:26:14 +0300302static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
303 struct a2mp_cmd *hdr)
304{
305 struct a2mp_info_rsp *rsp = (struct a2mp_info_rsp *) skb->data;
306 struct a2mp_amp_assoc_req req;
307 struct amp_ctrl *ctrl;
308
309 if (le16_to_cpu(hdr->len) < sizeof(*rsp))
310 return -EINVAL;
311
312 BT_DBG("id %d status 0x%2.2x", rsp->id, rsp->status);
313
314 if (rsp->status)
315 return -EINVAL;
316
Andrei Emeltchenkofa4ebc62012-10-05 16:56:55 +0300317 ctrl = amp_ctrl_add(mgr, rsp->id);
Andrei Emeltchenko0d868de2012-09-27 17:26:14 +0300318 if (!ctrl)
319 return -ENOMEM;
320
Andrei Emeltchenko0d868de2012-09-27 17:26:14 +0300321 req.id = rsp->id;
322 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
323 &req);
324
325 skb_pull(skb, sizeof(*rsp));
326 return 0;
327}
328
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300329static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb,
330 struct a2mp_cmd *hdr)
331{
332 struct a2mp_amp_assoc_req *req = (void *) skb->data;
333 struct hci_dev *hdev;
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300334 struct amp_mgr *tmp;
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300335
336 if (le16_to_cpu(hdr->len) < sizeof(*req))
337 return -EINVAL;
338
339 BT_DBG("id %d", req->id);
340
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300341 /* Make sure that other request is not processed */
342 tmp = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC);
343
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300344 hdev = hci_dev_get(req->id);
Marcel Holtmannece69122013-10-05 11:47:43 -0700345 if (!hdev || hdev->amp_type == AMP_TYPE_BREDR || tmp) {
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300346 struct a2mp_amp_assoc_rsp rsp;
347 rsp.id = req->id;
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300348
349 if (tmp) {
350 rsp.status = A2MP_STATUS_COLLISION_OCCURED;
351 amp_mgr_put(tmp);
352 } else {
353 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
354 }
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300355
356 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp),
357 &rsp);
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300358
359 goto done;
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300360 }
361
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300362 amp_read_loc_assoc(hdev, mgr);
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300363
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300364done:
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300365 if (hdev)
366 hci_dev_put(hdev);
367
368 skb_pull(skb, sizeof(*req));
369 return 0;
370}
371
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300372static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
373 struct a2mp_cmd *hdr)
374{
375 struct a2mp_amp_assoc_rsp *rsp = (void *) skb->data;
376 u16 len = le16_to_cpu(hdr->len);
377 struct hci_dev *hdev;
378 struct amp_ctrl *ctrl;
379 struct hci_conn *hcon;
Andrei Emeltchenko13465c02012-09-28 16:55:00 +0300380 size_t assoc_len;
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300381
382 if (len < sizeof(*rsp))
383 return -EINVAL;
384
Andrei Emeltchenko13465c02012-09-28 16:55:00 +0300385 assoc_len = len - sizeof(*rsp);
386
387 BT_DBG("id %d status 0x%2.2x assoc len %zu", rsp->id, rsp->status,
388 assoc_len);
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300389
390 if (rsp->status)
391 return -EINVAL;
392
393 /* Save remote ASSOC data */
394 ctrl = amp_ctrl_lookup(mgr, rsp->id);
395 if (ctrl) {
Andrei Emeltchenko13465c02012-09-28 16:55:00 +0300396 u8 *assoc;
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300397
Alexandru Gheorghiu5ae327f2013-03-17 07:16:50 +0200398 assoc = kmemdup(rsp->amp_assoc, assoc_len, GFP_KERNEL);
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300399 if (!assoc) {
400 amp_ctrl_put(ctrl);
401 return -ENOMEM;
402 }
403
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300404 ctrl->assoc = assoc;
405 ctrl->assoc_len = assoc_len;
406 ctrl->assoc_rem_len = assoc_len;
407 ctrl->assoc_len_so_far = 0;
408
409 amp_ctrl_put(ctrl);
410 }
411
412 /* Create Phys Link */
413 hdev = hci_dev_get(rsp->id);
414 if (!hdev)
415 return -EINVAL;
416
Andrei Emeltchenkoa0c234f2012-10-05 16:56:56 +0300417 hcon = phylink_add(hdev, mgr, rsp->id, true);
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300418 if (!hcon)
419 goto done;
420
421 BT_DBG("Created hcon %p: loc:%d -> rem:%d", hcon, hdev->id, rsp->id);
422
Andrei Emeltchenkofffadc02012-11-01 15:37:03 +0200423 mgr->bredr_chan->remote_amp_id = rsp->id;
Andrei Emeltchenko9495b2e2012-09-27 17:26:22 +0300424
Andrei Emeltchenkoa02226d2012-09-27 17:26:19 +0300425 amp_create_phylink(hdev, mgr, hcon);
426
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300427done:
428 hci_dev_put(hdev);
429 skb_pull(skb, len);
430 return 0;
431}
432
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300433static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
434 struct a2mp_cmd *hdr)
435{
436 struct a2mp_physlink_req *req = (void *) skb->data;
437
438 struct a2mp_physlink_rsp rsp;
439 struct hci_dev *hdev;
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300440 struct hci_conn *hcon;
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300441 struct amp_ctrl *ctrl;
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300442
443 if (le16_to_cpu(hdr->len) < sizeof(*req))
444 return -EINVAL;
445
446 BT_DBG("local_id %d, remote_id %d", req->local_id, req->remote_id);
447
448 rsp.local_id = req->remote_id;
449 rsp.remote_id = req->local_id;
450
451 hdev = hci_dev_get(req->remote_id);
Marcel Holtmannece69122013-10-05 11:47:43 -0700452 if (!hdev || hdev->amp_type == AMP_TYPE_BREDR) {
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300453 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
454 goto send_rsp;
455 }
456
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300457 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id);
458 if (!ctrl) {
Andrei Emeltchenkofa4ebc62012-10-05 16:56:55 +0300459 ctrl = amp_ctrl_add(mgr, rsp.remote_id);
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300460 if (ctrl) {
461 amp_ctrl_get(ctrl);
462 } else {
463 rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION;
464 goto send_rsp;
465 }
466 }
467
468 if (ctrl) {
Andrei Emeltchenko13465c02012-09-28 16:55:00 +0300469 size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
470 u8 *assoc;
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300471
Alexandru Gheorghiu5ae327f2013-03-17 07:16:50 +0200472 assoc = kmemdup(req->amp_assoc, assoc_len, GFP_KERNEL);
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300473 if (!assoc) {
474 amp_ctrl_put(ctrl);
475 return -ENOMEM;
476 }
477
Andrei Emeltchenko0b26ab92012-09-27 17:26:24 +0300478 ctrl->assoc = assoc;
479 ctrl->assoc_len = assoc_len;
480 ctrl->assoc_rem_len = assoc_len;
481 ctrl->assoc_len_so_far = 0;
482
483 amp_ctrl_put(ctrl);
484 }
485
Andrei Emeltchenkoa0c234f2012-10-05 16:56:56 +0300486 hcon = phylink_add(hdev, mgr, req->local_id, false);
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300487 if (hcon) {
Andrei Emeltchenkodffa3872012-09-27 17:26:23 +0300488 amp_accept_phylink(hdev, mgr, hcon);
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300489 rsp.status = A2MP_STATUS_SUCCESS;
490 } else {
491 rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION;
492 }
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300493
494send_rsp:
495 if (hdev)
496 hci_dev_put(hdev);
497
Andrei Emeltchenko8e05e3b2012-12-07 14:59:05 +0200498 /* Reply error now and success after HCI Write Remote AMP Assoc
499 command complete with success status
500 */
501 if (rsp.status != A2MP_STATUS_SUCCESS) {
502 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident,
503 sizeof(rsp), &rsp);
504 } else {
Andrei Emeltchenkocb6801c62012-12-07 14:59:08 +0200505 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state);
Andrei Emeltchenko8e05e3b2012-12-07 14:59:05 +0200506 mgr->ident = hdr->ident;
507 }
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300508
509 skb_pull(skb, le16_to_cpu(hdr->len));
510 return 0;
511}
512
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300513static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
514 struct a2mp_cmd *hdr)
515{
516 struct a2mp_physlink_req *req = (void *) skb->data;
517 struct a2mp_physlink_rsp rsp;
518 struct hci_dev *hdev;
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300519 struct hci_conn *hcon;
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300520
521 if (le16_to_cpu(hdr->len) < sizeof(*req))
522 return -EINVAL;
523
524 BT_DBG("local_id %d remote_id %d", req->local_id, req->remote_id);
525
526 rsp.local_id = req->remote_id;
527 rsp.remote_id = req->local_id;
528 rsp.status = A2MP_STATUS_SUCCESS;
529
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300530 hdev = hci_dev_get(req->remote_id);
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300531 if (!hdev) {
532 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
533 goto send_rsp;
534 }
535
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300536 hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, mgr->l2cap_conn->dst);
537 if (!hcon) {
538 BT_ERR("No phys link exist");
539 rsp.status = A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS;
540 goto clean;
541 }
542
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300543 /* TODO Disconnect Phys Link here */
544
Andrei Emeltchenkocb8488c2012-09-27 17:26:13 +0300545clean:
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300546 hci_dev_put(hdev);
547
548send_rsp:
549 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp);
550
551 skb_pull(skb, sizeof(*req));
552 return 0;
553}
554
Andrei Emeltchenkof6410a82012-05-29 13:59:15 +0300555static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
556 struct a2mp_cmd *hdr)
557{
Andrei Emeltchenko8e8c7e32012-07-19 17:03:41 +0300558 BT_DBG("ident %d code 0x%2.2x", hdr->ident, hdr->code);
Andrei Emeltchenkof6410a82012-05-29 13:59:15 +0300559
560 skb_pull(skb, le16_to_cpu(hdr->len));
561 return 0;
562}
563
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300564/* Handle A2MP signalling */
565static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
566{
Andrei Emeltchenkod9fc1d52012-07-19 17:03:46 +0300567 struct a2mp_cmd *hdr;
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300568 struct amp_mgr *mgr = chan->data;
569 int err = 0;
570
571 amp_mgr_get(mgr);
572
573 while (skb->len >= sizeof(*hdr)) {
Andrei Emeltchenkod9fc1d52012-07-19 17:03:46 +0300574 u16 len;
575
576 hdr = (void *) skb->data;
577 len = le16_to_cpu(hdr->len);
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300578
Andrei Emeltchenko8e8c7e32012-07-19 17:03:41 +0300579 BT_DBG("code 0x%2.2x id %d len %u", hdr->code, hdr->ident, len);
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300580
581 skb_pull(skb, sizeof(*hdr));
582
583 if (len > skb->len || !hdr->ident) {
584 err = -EINVAL;
585 break;
586 }
587
588 mgr->ident = hdr->ident;
589
590 switch (hdr->code) {
591 case A2MP_COMMAND_REJ:
Andrei Emeltchenko21dbd2c2012-05-29 13:59:08 +0300592 a2mp_command_rej(mgr, skb, hdr);
593 break;
594
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300595 case A2MP_DISCOVER_REQ:
Andrei Emeltchenko8598d062012-05-29 13:59:09 +0300596 err = a2mp_discover_req(mgr, skb, hdr);
597 break;
598
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300599 case A2MP_CHANGE_NOTIFY:
Andrei Emeltchenko329d81af2012-05-29 13:59:10 +0300600 err = a2mp_change_notify(mgr, skb, hdr);
601 break;
602
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300603 case A2MP_GETINFO_REQ:
Andrei Emeltchenko47f2d972012-05-29 13:59:11 +0300604 err = a2mp_getinfo_req(mgr, skb, hdr);
605 break;
606
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300607 case A2MP_GETAMPASSOC_REQ:
Andrei Emeltchenkoa28381dc2012-05-29 13:59:12 +0300608 err = a2mp_getampassoc_req(mgr, skb, hdr);
609 break;
610
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300611 case A2MP_CREATEPHYSLINK_REQ:
Andrei Emeltchenkoe072f5d2012-05-29 13:59:13 +0300612 err = a2mp_createphyslink_req(mgr, skb, hdr);
613 break;
614
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300615 case A2MP_DISCONNPHYSLINK_REQ:
Andrei Emeltchenko6113f842012-05-29 13:59:14 +0300616 err = a2mp_discphyslink_req(mgr, skb, hdr);
617 break;
618
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300619 case A2MP_DISCOVER_RSP:
Andrei Emeltchenkoaa095372012-09-27 17:26:10 +0300620 err = a2mp_discover_rsp(mgr, skb, hdr);
621 break;
622
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300623 case A2MP_GETINFO_RSP:
Andrei Emeltchenko0d868de2012-09-27 17:26:14 +0300624 err = a2mp_getinfo_rsp(mgr, skb, hdr);
625 break;
626
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300627 case A2MP_GETAMPASSOC_RSP:
Andrei Emeltchenko9a5e94d2012-09-27 17:26:15 +0300628 err = a2mp_getampassoc_rsp(mgr, skb, hdr);
629 break;
630
631 case A2MP_CHANGE_RSP:
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300632 case A2MP_CREATEPHYSLINK_RSP:
633 case A2MP_DISCONNPHYSLINK_RSP:
Andrei Emeltchenkof6410a82012-05-29 13:59:15 +0300634 err = a2mp_cmd_rsp(mgr, skb, hdr);
635 break;
636
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300637 default:
638 BT_ERR("Unknown A2MP sig cmd 0x%2.2x", hdr->code);
639 err = -EINVAL;
640 break;
641 }
642 }
643
644 if (err) {
645 struct a2mp_cmd_rej rej;
Andrei Emeltchenkod9fc1d52012-07-19 17:03:46 +0300646
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300647 rej.reason = __constant_cpu_to_le16(0);
Andrei Emeltchenkod9fc1d52012-07-19 17:03:46 +0300648 hdr = (void *) skb->data;
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300649
650 BT_DBG("Send A2MP Rej: cmd 0x%2.2x err %d", hdr->code, err);
651
652 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej),
653 &rej);
654 }
655
656 /* Always free skb and return success error code to prevent
657 from sending L2CAP Disconnect over A2MP channel */
658 kfree_skb(skb);
659
660 amp_mgr_put(mgr);
661
662 return 0;
663}
664
Andrei Emeltchenko46d5c902012-05-29 13:59:04 +0300665static void a2mp_chan_close_cb(struct l2cap_chan *chan)
666{
Jaganath Kanakkassery4af66c62012-07-13 18:17:55 +0530667 l2cap_chan_put(chan);
Andrei Emeltchenko46d5c902012-05-29 13:59:04 +0300668}
669
670static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state)
671{
672 struct amp_mgr *mgr = chan->data;
673
674 if (!mgr)
675 return;
676
677 BT_DBG("chan %p state %s", chan, state_to_string(state));
678
679 chan->state = state;
680
681 switch (state) {
682 case BT_CLOSED:
683 if (mgr)
684 amp_mgr_put(mgr);
685 break;
686 }
687}
688
689static struct sk_buff *a2mp_chan_alloc_skb_cb(struct l2cap_chan *chan,
690 unsigned long len, int nb)
691{
692 return bt_skb_alloc(len, GFP_KERNEL);
693}
694
Andrei Emeltchenko466f8002012-05-29 13:59:01 +0300695static struct l2cap_ops a2mp_chan_ops = {
696 .name = "L2CAP A2MP channel",
Andrei Emeltchenko6b44d9b2012-05-29 13:59:07 +0300697 .recv = a2mp_chan_recv_cb,
Andrei Emeltchenko46d5c902012-05-29 13:59:04 +0300698 .close = a2mp_chan_close_cb,
699 .state_change = a2mp_chan_state_change_cb,
700 .alloc_skb = a2mp_chan_alloc_skb_cb,
701
702 /* Not implemented for A2MP */
Gustavo Padovan7e1af8a2012-05-29 13:19:26 -0300703 .new_connection = l2cap_chan_no_new_connection,
704 .teardown = l2cap_chan_no_teardown,
705 .ready = l2cap_chan_no_ready,
Gustavo Padovan2dc4e512012-10-12 19:35:24 +0800706 .defer = l2cap_chan_no_defer,
Andrei Emeltchenko466f8002012-05-29 13:59:01 +0300707};
708
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300709static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
Andrei Emeltchenko466f8002012-05-29 13:59:01 +0300710{
711 struct l2cap_chan *chan;
712 int err;
713
714 chan = l2cap_chan_create();
715 if (!chan)
716 return NULL;
717
718 BT_DBG("chan %p", chan);
719
Andrei Emeltchenko416fa752012-05-29 13:59:16 +0300720 chan->chan_type = L2CAP_CHAN_CONN_FIX_A2MP;
Andrei Emeltchenko466f8002012-05-29 13:59:01 +0300721 chan->flush_to = L2CAP_DEFAULT_FLUSH_TO;
722
723 chan->ops = &a2mp_chan_ops;
724
725 l2cap_chan_set_defaults(chan);
726 chan->remote_max_tx = chan->max_tx;
727 chan->remote_tx_win = chan->tx_win;
728
729 chan->retrans_timeout = L2CAP_DEFAULT_RETRANS_TO;
730 chan->monitor_timeout = L2CAP_DEFAULT_MONITOR_TO;
731
732 skb_queue_head_init(&chan->tx_q);
733
734 chan->mode = L2CAP_MODE_ERTM;
735
736 err = l2cap_ertm_init(chan);
737 if (err < 0) {
738 l2cap_chan_del(chan, 0);
739 return NULL;
740 }
741
742 chan->conf_state = 0;
743
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300744 if (locked)
745 __l2cap_chan_add(conn, chan);
746 else
747 l2cap_chan_add(conn, chan);
Andrei Emeltchenko466f8002012-05-29 13:59:01 +0300748
749 chan->remote_mps = chan->omtu;
750 chan->mps = chan->omtu;
751
752 chan->state = BT_CONNECTED;
753
754 return chan;
755}
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300756
757/* AMP Manager functions */
Andrei Emeltchenkof706adf2012-10-18 13:16:19 +0300758struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr)
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300759{
Andrei Emeltchenkoa0dfe0a2012-07-11 14:43:35 +0300760 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount));
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300761
762 kref_get(&mgr->kref);
Andrei Emeltchenkof706adf2012-10-18 13:16:19 +0300763
764 return mgr;
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300765}
766
767static void amp_mgr_destroy(struct kref *kref)
768{
769 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref);
770
771 BT_DBG("mgr %p", mgr);
772
Andrei Emeltchenkof97268f2012-09-27 17:26:07 +0300773 mutex_lock(&amp_mgr_list_lock);
774 list_del(&mgr->list);
775 mutex_unlock(&amp_mgr_list_lock);
776
Andrei Emeltchenko52c0d6e2012-09-27 17:26:12 +0300777 amp_ctrl_list_flush(mgr);
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300778 kfree(mgr);
779}
780
781int amp_mgr_put(struct amp_mgr *mgr)
782{
Andrei Emeltchenkoa0dfe0a2012-07-11 14:43:35 +0300783 BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount));
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300784
785 return kref_put(&mgr->kref, &amp_mgr_destroy);
786}
787
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300788static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn, bool locked)
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300789{
790 struct amp_mgr *mgr;
791 struct l2cap_chan *chan;
792
793 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
794 if (!mgr)
795 return NULL;
796
797 BT_DBG("conn %p mgr %p", conn, mgr);
798
799 mgr->l2cap_conn = conn;
800
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300801 chan = a2mp_chan_open(conn, locked);
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300802 if (!chan) {
803 kfree(mgr);
804 return NULL;
805 }
806
807 mgr->a2mp_chan = chan;
808 chan->data = mgr;
809
810 conn->hcon->amp_mgr = mgr;
811
812 kref_init(&mgr->kref);
813
Andrei Emeltchenko52c0d6e2012-09-27 17:26:12 +0300814 /* Remote AMP ctrl list initialization */
815 INIT_LIST_HEAD(&mgr->amp_ctrls);
816 mutex_init(&mgr->amp_ctrls_lock);
817
Andrei Emeltchenkof97268f2012-09-27 17:26:07 +0300818 mutex_lock(&amp_mgr_list_lock);
819 list_add(&mgr->list, &amp_mgr_list);
820 mutex_unlock(&amp_mgr_list_lock);
821
Andrei Emeltchenko9740e492012-05-29 13:59:02 +0300822 return mgr;
823}
Andrei Emeltchenko97e8e892012-05-29 13:59:17 +0300824
825struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
826 struct sk_buff *skb)
827{
828 struct amp_mgr *mgr;
829
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300830 mgr = amp_mgr_create(conn, false);
Andrei Emeltchenko97e8e892012-05-29 13:59:17 +0300831 if (!mgr) {
832 BT_ERR("Could not create AMP manager");
833 return NULL;
834 }
835
836 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan);
837
838 return mgr->a2mp_chan;
839}
Andrei Emeltchenkof97268f2012-09-27 17:26:07 +0300840
841struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
842{
843 struct amp_mgr *mgr;
844
845 mutex_lock(&amp_mgr_list_lock);
846 list_for_each_entry(mgr, &amp_mgr_list, list) {
Andrei Emeltchenkocb6801c62012-12-07 14:59:08 +0200847 if (test_and_clear_bit(state, &mgr->state)) {
Andrei Emeltchenkof97268f2012-09-27 17:26:07 +0300848 amp_mgr_get(mgr);
849 mutex_unlock(&amp_mgr_list_lock);
850 return mgr;
851 }
852 }
853 mutex_unlock(&amp_mgr_list_lock);
854
855 return NULL;
856}
Andrei Emeltchenko8e2a0d92012-09-27 17:26:08 +0300857
858void a2mp_send_getinfo_rsp(struct hci_dev *hdev)
859{
860 struct amp_mgr *mgr;
861 struct a2mp_info_rsp rsp;
862
863 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO);
864 if (!mgr)
865 return;
866
867 BT_DBG("%s mgr %p", hdev->name, mgr);
868
869 rsp.id = hdev->id;
870 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
871
Marcel Holtmannece69122013-10-05 11:47:43 -0700872 if (hdev->amp_type != AMP_TYPE_BREDR) {
Andrei Emeltchenko8e2a0d92012-09-27 17:26:08 +0300873 rsp.status = 0;
874 rsp.total_bw = cpu_to_le32(hdev->amp_total_bw);
875 rsp.max_bw = cpu_to_le32(hdev->amp_max_bw);
876 rsp.min_latency = cpu_to_le32(hdev->amp_min_latency);
877 rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap);
878 rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size);
879 }
880
881 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp);
882 amp_mgr_put(mgr);
883}
Andrei Emeltchenko903e4542012-09-27 17:26:09 +0300884
885void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status)
886{
887 struct amp_mgr *mgr;
888 struct amp_assoc *loc_assoc = &hdev->loc_assoc;
889 struct a2mp_amp_assoc_rsp *rsp;
890 size_t len;
891
892 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC);
893 if (!mgr)
894 return;
895
896 BT_DBG("%s mgr %p", hdev->name, mgr);
897
898 len = sizeof(struct a2mp_amp_assoc_rsp) + loc_assoc->len;
899 rsp = kzalloc(len, GFP_KERNEL);
900 if (!rsp) {
901 amp_mgr_put(mgr);
902 return;
903 }
904
905 rsp->id = hdev->id;
906
907 if (status) {
908 rsp->status = A2MP_STATUS_INVALID_CTRL_ID;
909 } else {
910 rsp->status = A2MP_STATUS_SUCCESS;
911 memcpy(rsp->amp_assoc, loc_assoc->data, loc_assoc->len);
912 }
913
914 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp);
915 amp_mgr_put(mgr);
916 kfree(rsp);
917}
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300918
Andrei Emeltchenko9495b2e2012-09-27 17:26:22 +0300919void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status)
920{
921 struct amp_mgr *mgr;
922 struct amp_assoc *loc_assoc = &hdev->loc_assoc;
923 struct a2mp_physlink_req *req;
924 struct l2cap_chan *bredr_chan;
925 size_t len;
926
927 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL);
928 if (!mgr)
929 return;
930
931 len = sizeof(*req) + loc_assoc->len;
932
933 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len);
934
935 req = kzalloc(len, GFP_KERNEL);
936 if (!req) {
937 amp_mgr_put(mgr);
938 return;
939 }
940
941 bredr_chan = mgr->bredr_chan;
942 if (!bredr_chan)
943 goto clean;
944
945 req->local_id = hdev->id;
Andrei Emeltchenkofffadc02012-11-01 15:37:03 +0200946 req->remote_id = bredr_chan->remote_amp_id;
Andrei Emeltchenko9495b2e2012-09-27 17:26:22 +0300947 memcpy(req->amp_assoc, loc_assoc->data, loc_assoc->len);
948
949 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req);
950
951clean:
952 amp_mgr_put(mgr);
953 kfree(req);
954}
955
Andrei Emeltchenko8e05e3b2012-12-07 14:59:05 +0200956void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status)
957{
958 struct amp_mgr *mgr;
959 struct a2mp_physlink_rsp rsp;
960 struct hci_conn *hs_hcon;
961
962 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC);
963 if (!mgr)
964 return;
965
966 hs_hcon = hci_conn_hash_lookup_state(hdev, AMP_LINK, BT_CONNECT);
967 if (!hs_hcon) {
968 rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION;
969 } else {
970 rsp.remote_id = hs_hcon->remote_id;
971 rsp.status = A2MP_STATUS_SUCCESS;
972 }
973
974 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon,
975 status);
976
977 rsp.local_id = hdev->id;
978 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp);
979 amp_mgr_put(mgr);
980}
981
Andrei Emeltchenko93c3e8f2012-09-27 17:26:16 +0300982void a2mp_discover_amp(struct l2cap_chan *chan)
983{
984 struct l2cap_conn *conn = chan->conn;
985 struct amp_mgr *mgr = conn->hcon->amp_mgr;
986 struct a2mp_discov_req req;
987
988 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr);
989
990 if (!mgr) {
991 mgr = amp_mgr_create(conn, true);
992 if (!mgr)
993 return;
994 }
995
996 mgr->bredr_chan = chan;
997
998 req.mtu = cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU);
999 req.ext_feat = 0;
1000 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req);
1001}