diff options
Diffstat (limited to 'net')
90 files changed, 9843 insertions, 1999 deletions
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig index 3537d385035e..d3f3f7b1d32c 100644 --- a/net/bluetooth/Kconfig +++ b/net/bluetooth/Kconfig | |||
@@ -11,6 +11,7 @@ menuconfig BT | |||
11 | select CRYPTO_BLKCIPHER | 11 | select CRYPTO_BLKCIPHER |
12 | select CRYPTO_AES | 12 | select CRYPTO_AES |
13 | select CRYPTO_ECB | 13 | select CRYPTO_ECB |
14 | select CRYPTO_SHA256 | ||
14 | help | 15 | help |
15 | Bluetooth is low-cost, low-power, short-range wireless technology. | 16 | Bluetooth is low-cost, low-power, short-range wireless technology. |
16 | It was designed as a replacement for cables and other short-range | 17 | It was designed as a replacement for cables and other short-range |
@@ -47,4 +48,3 @@ source "net/bluetooth/cmtp/Kconfig" | |||
47 | source "net/bluetooth/hidp/Kconfig" | 48 | source "net/bluetooth/hidp/Kconfig" |
48 | 49 | ||
49 | source "drivers/bluetooth/Kconfig" | 50 | source "drivers/bluetooth/Kconfig" |
50 | |||
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile index fa6d94a4602a..dea6a287daca 100644 --- a/net/bluetooth/Makefile +++ b/net/bluetooth/Makefile | |||
@@ -10,4 +10,4 @@ obj-$(CONFIG_BT_HIDP) += hidp/ | |||
10 | 10 | ||
11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ | 11 | bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o \ |
12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ | 12 | hci_sock.o hci_sysfs.o l2cap_core.o l2cap_sock.o smp.o sco.o lib.o \ |
13 | a2mp.o | 13 | a2mp.o amp.o |
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 0760d1fed6f0..2f67d5ecc907 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -16,6 +16,11 @@ | |||
16 | #include <net/bluetooth/hci_core.h> | 16 | #include <net/bluetooth/hci_core.h> |
17 | #include <net/bluetooth/l2cap.h> | 17 | #include <net/bluetooth/l2cap.h> |
18 | #include <net/bluetooth/a2mp.h> | 18 | #include <net/bluetooth/a2mp.h> |
19 | #include <net/bluetooth/amp.h> | ||
20 | |||
21 | /* Global AMP Manager list */ | ||
22 | LIST_HEAD(amp_mgr_list); | ||
23 | DEFINE_MUTEX(amp_mgr_list_lock); | ||
19 | 24 | ||
20 | /* A2MP build & send command helper functions */ | 25 | /* A2MP build & send command helper functions */ |
21 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) | 26 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) |
@@ -37,8 +42,7 @@ static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) | |||
37 | return cmd; | 42 | return cmd; |
38 | } | 43 | } |
39 | 44 | ||
40 | static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, | 45 | void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) |
41 | void *data) | ||
42 | { | 46 | { |
43 | struct l2cap_chan *chan = mgr->a2mp_chan; | 47 | struct l2cap_chan *chan = mgr->a2mp_chan; |
44 | struct a2mp_cmd *cmd; | 48 | struct a2mp_cmd *cmd; |
@@ -63,6 +67,14 @@ static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, | |||
63 | kfree(cmd); | 67 | kfree(cmd); |
64 | } | 68 | } |
65 | 69 | ||
70 | u8 __next_ident(struct amp_mgr *mgr) | ||
71 | { | ||
72 | if (++mgr->ident == 0) | ||
73 | mgr->ident = 1; | ||
74 | |||
75 | return mgr->ident; | ||
76 | } | ||
77 | |||
66 | static inline void __a2mp_cl_bredr(struct a2mp_cl *cl) | 78 | static inline void __a2mp_cl_bredr(struct a2mp_cl *cl) |
67 | { | 79 | { |
68 | cl->id = 0; | 80 | cl->id = 0; |
@@ -161,6 +173,83 @@ static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
161 | return 0; | 173 | return 0; |
162 | } | 174 | } |
163 | 175 | ||
176 | static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, | ||
177 | struct a2mp_cmd *hdr) | ||
178 | { | ||
179 | struct a2mp_discov_rsp *rsp = (void *) skb->data; | ||
180 | u16 len = le16_to_cpu(hdr->len); | ||
181 | struct a2mp_cl *cl; | ||
182 | u16 ext_feat; | ||
183 | bool found = false; | ||
184 | |||
185 | if (len < sizeof(*rsp)) | ||
186 | return -EINVAL; | ||
187 | |||
188 | len -= sizeof(*rsp); | ||
189 | skb_pull(skb, sizeof(*rsp)); | ||
190 | |||
191 | ext_feat = le16_to_cpu(rsp->ext_feat); | ||
192 | |||
193 | BT_DBG("mtu %d efm 0x%4.4x", le16_to_cpu(rsp->mtu), ext_feat); | ||
194 | |||
195 | /* check that packet is not broken for now */ | ||
196 | while (ext_feat & A2MP_FEAT_EXT) { | ||
197 | if (len < sizeof(ext_feat)) | ||
198 | return -EINVAL; | ||
199 | |||
200 | ext_feat = get_unaligned_le16(skb->data); | ||
201 | BT_DBG("efm 0x%4.4x", ext_feat); | ||
202 | len -= sizeof(ext_feat); | ||
203 | skb_pull(skb, sizeof(ext_feat)); | ||
204 | } | ||
205 | |||
206 | cl = (void *) skb->data; | ||
207 | while (len >= sizeof(*cl)) { | ||
208 | BT_DBG("Remote AMP id %d type %d status %d", cl->id, cl->type, | ||
209 | cl->status); | ||
210 | |||
211 | if (cl->id != HCI_BREDR_ID && cl->type == HCI_AMP) { | ||
212 | struct a2mp_info_req req; | ||
213 | |||
214 | found = true; | ||
215 | req.id = cl->id; | ||
216 | a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), | ||
217 | sizeof(req), &req); | ||
218 | } | ||
219 | |||
220 | len -= sizeof(*cl); | ||
221 | cl = (void *) skb_pull(skb, sizeof(*cl)); | ||
222 | } | ||
223 | |||
224 | /* Fall back to L2CAP init sequence */ | ||
225 | if (!found) { | ||
226 | struct l2cap_conn *conn = mgr->l2cap_conn; | ||
227 | struct l2cap_chan *chan; | ||
228 | |||
229 | mutex_lock(&conn->chan_lock); | ||
230 | |||
231 | list_for_each_entry(chan, &conn->chan_l, list) { | ||
232 | |||
233 | BT_DBG("chan %p state %s", chan, | ||
234 | state_to_string(chan->state)); | ||
235 | |||
236 | if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP) | ||
237 | continue; | ||
238 | |||
239 | l2cap_chan_lock(chan); | ||
240 | |||
241 | if (chan->state == BT_CONNECT) | ||
242 | l2cap_send_conn_req(chan); | ||
243 | |||
244 | l2cap_chan_unlock(chan); | ||
245 | } | ||
246 | |||
247 | mutex_unlock(&conn->chan_lock); | ||
248 | } | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
164 | static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, | 253 | static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, |
165 | struct a2mp_cmd *hdr) | 254 | struct a2mp_cmd *hdr) |
166 | { | 255 | { |
@@ -181,7 +270,6 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
181 | struct a2mp_cmd *hdr) | 270 | struct a2mp_cmd *hdr) |
182 | { | 271 | { |
183 | struct a2mp_info_req *req = (void *) skb->data; | 272 | struct a2mp_info_req *req = (void *) skb->data; |
184 | struct a2mp_info_rsp rsp; | ||
185 | struct hci_dev *hdev; | 273 | struct hci_dev *hdev; |
186 | 274 | ||
187 | if (le16_to_cpu(hdr->len) < sizeof(*req)) | 275 | if (le16_to_cpu(hdr->len) < sizeof(*req)) |
@@ -189,53 +277,93 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
189 | 277 | ||
190 | BT_DBG("id %d", req->id); | 278 | BT_DBG("id %d", req->id); |
191 | 279 | ||
192 | rsp.id = req->id; | ||
193 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; | ||
194 | |||
195 | hdev = hci_dev_get(req->id); | 280 | hdev = hci_dev_get(req->id); |
196 | if (hdev && hdev->amp_type != HCI_BREDR) { | 281 | if (!hdev || hdev->dev_type != HCI_AMP) { |
197 | rsp.status = 0; | 282 | struct a2mp_info_rsp rsp; |
198 | rsp.total_bw = cpu_to_le32(hdev->amp_total_bw); | 283 | |
199 | rsp.max_bw = cpu_to_le32(hdev->amp_max_bw); | 284 | rsp.id = req->id; |
200 | rsp.min_latency = cpu_to_le32(hdev->amp_min_latency); | 285 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; |
201 | rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap); | 286 | |
202 | rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size); | 287 | a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), |
288 | &rsp); | ||
289 | |||
290 | goto done; | ||
203 | } | 291 | } |
204 | 292 | ||
293 | mgr->state = READ_LOC_AMP_INFO; | ||
294 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL); | ||
295 | |||
296 | done: | ||
205 | if (hdev) | 297 | if (hdev) |
206 | hci_dev_put(hdev); | 298 | hci_dev_put(hdev); |
207 | 299 | ||
208 | a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), &rsp); | ||
209 | |||
210 | skb_pull(skb, sizeof(*req)); | 300 | skb_pull(skb, sizeof(*req)); |
211 | return 0; | 301 | return 0; |
212 | } | 302 | } |
213 | 303 | ||
304 | static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, | ||
305 | struct a2mp_cmd *hdr) | ||
306 | { | ||
307 | struct a2mp_info_rsp *rsp = (struct a2mp_info_rsp *) skb->data; | ||
308 | struct a2mp_amp_assoc_req req; | ||
309 | struct amp_ctrl *ctrl; | ||
310 | |||
311 | if (le16_to_cpu(hdr->len) < sizeof(*rsp)) | ||
312 | return -EINVAL; | ||
313 | |||
314 | BT_DBG("id %d status 0x%2.2x", rsp->id, rsp->status); | ||
315 | |||
316 | if (rsp->status) | ||
317 | return -EINVAL; | ||
318 | |||
319 | ctrl = amp_ctrl_add(mgr, rsp->id); | ||
320 | if (!ctrl) | ||
321 | return -ENOMEM; | ||
322 | |||
323 | req.id = rsp->id; | ||
324 | a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), | ||
325 | &req); | ||
326 | |||
327 | skb_pull(skb, sizeof(*rsp)); | ||
328 | return 0; | ||
329 | } | ||
330 | |||
214 | static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, | 331 | static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, |
215 | struct a2mp_cmd *hdr) | 332 | struct a2mp_cmd *hdr) |
216 | { | 333 | { |
217 | struct a2mp_amp_assoc_req *req = (void *) skb->data; | 334 | struct a2mp_amp_assoc_req *req = (void *) skb->data; |
218 | struct hci_dev *hdev; | 335 | struct hci_dev *hdev; |
336 | struct amp_mgr *tmp; | ||
219 | 337 | ||
220 | if (le16_to_cpu(hdr->len) < sizeof(*req)) | 338 | if (le16_to_cpu(hdr->len) < sizeof(*req)) |
221 | return -EINVAL; | 339 | return -EINVAL; |
222 | 340 | ||
223 | BT_DBG("id %d", req->id); | 341 | BT_DBG("id %d", req->id); |
224 | 342 | ||
343 | /* Make sure that other request is not processed */ | ||
344 | tmp = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); | ||
345 | |||
225 | hdev = hci_dev_get(req->id); | 346 | hdev = hci_dev_get(req->id); |
226 | if (!hdev || hdev->amp_type == HCI_BREDR) { | 347 | if (!hdev || hdev->amp_type == HCI_BREDR || tmp) { |
227 | struct a2mp_amp_assoc_rsp rsp; | 348 | struct a2mp_amp_assoc_rsp rsp; |
228 | rsp.id = req->id; | 349 | rsp.id = req->id; |
229 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; | 350 | |
351 | if (tmp) { | ||
352 | rsp.status = A2MP_STATUS_COLLISION_OCCURED; | ||
353 | amp_mgr_put(tmp); | ||
354 | } else { | ||
355 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; | ||
356 | } | ||
230 | 357 | ||
231 | a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), | 358 | a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), |
232 | &rsp); | 359 | &rsp); |
233 | goto clean; | 360 | |
361 | goto done; | ||
234 | } | 362 | } |
235 | 363 | ||
236 | /* Placeholder for HCI Read AMP Assoc */ | 364 | amp_read_loc_assoc(hdev, mgr); |
237 | 365 | ||
238 | clean: | 366 | done: |
239 | if (hdev) | 367 | if (hdev) |
240 | hci_dev_put(hdev); | 368 | hci_dev_put(hdev); |
241 | 369 | ||
@@ -243,6 +371,68 @@ clean: | |||
243 | return 0; | 371 | return 0; |
244 | } | 372 | } |
245 | 373 | ||
374 | static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, | ||
375 | struct a2mp_cmd *hdr) | ||
376 | { | ||
377 | struct a2mp_amp_assoc_rsp *rsp = (void *) skb->data; | ||
378 | u16 len = le16_to_cpu(hdr->len); | ||
379 | struct hci_dev *hdev; | ||
380 | struct amp_ctrl *ctrl; | ||
381 | struct hci_conn *hcon; | ||
382 | size_t assoc_len; | ||
383 | |||
384 | if (len < sizeof(*rsp)) | ||
385 | return -EINVAL; | ||
386 | |||
387 | assoc_len = len - sizeof(*rsp); | ||
388 | |||
389 | BT_DBG("id %d status 0x%2.2x assoc len %zu", rsp->id, rsp->status, | ||
390 | assoc_len); | ||
391 | |||
392 | if (rsp->status) | ||
393 | return -EINVAL; | ||
394 | |||
395 | /* Save remote ASSOC data */ | ||
396 | ctrl = amp_ctrl_lookup(mgr, rsp->id); | ||
397 | if (ctrl) { | ||
398 | u8 *assoc; | ||
399 | |||
400 | assoc = kzalloc(assoc_len, GFP_KERNEL); | ||
401 | if (!assoc) { | ||
402 | amp_ctrl_put(ctrl); | ||
403 | return -ENOMEM; | ||
404 | } | ||
405 | |||
406 | memcpy(assoc, rsp->amp_assoc, assoc_len); | ||
407 | ctrl->assoc = assoc; | ||
408 | ctrl->assoc_len = assoc_len; | ||
409 | ctrl->assoc_rem_len = assoc_len; | ||
410 | ctrl->assoc_len_so_far = 0; | ||
411 | |||
412 | amp_ctrl_put(ctrl); | ||
413 | } | ||
414 | |||
415 | /* Create Phys Link */ | ||
416 | hdev = hci_dev_get(rsp->id); | ||
417 | if (!hdev) | ||
418 | return -EINVAL; | ||
419 | |||
420 | hcon = phylink_add(hdev, mgr, rsp->id, true); | ||
421 | if (!hcon) | ||
422 | goto done; | ||
423 | |||
424 | BT_DBG("Created hcon %p: loc:%d -> rem:%d", hcon, hdev->id, rsp->id); | ||
425 | |||
426 | mgr->bredr_chan->remote_amp_id = rsp->id; | ||
427 | |||
428 | amp_create_phylink(hdev, mgr, hcon); | ||
429 | |||
430 | done: | ||
431 | hci_dev_put(hdev); | ||
432 | skb_pull(skb, len); | ||
433 | return 0; | ||
434 | } | ||
435 | |||
246 | static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, | 436 | static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, |
247 | struct a2mp_cmd *hdr) | 437 | struct a2mp_cmd *hdr) |
248 | { | 438 | { |
@@ -250,6 +440,8 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
250 | 440 | ||
251 | struct a2mp_physlink_rsp rsp; | 441 | struct a2mp_physlink_rsp rsp; |
252 | struct hci_dev *hdev; | 442 | struct hci_dev *hdev; |
443 | struct hci_conn *hcon; | ||
444 | struct amp_ctrl *ctrl; | ||
253 | 445 | ||
254 | if (le16_to_cpu(hdr->len) < sizeof(*req)) | 446 | if (le16_to_cpu(hdr->len) < sizeof(*req)) |
255 | return -EINVAL; | 447 | return -EINVAL; |
@@ -265,9 +457,43 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
265 | goto send_rsp; | 457 | goto send_rsp; |
266 | } | 458 | } |
267 | 459 | ||
268 | /* TODO process physlink create */ | 460 | ctrl = amp_ctrl_lookup(mgr, rsp.remote_id); |
461 | if (!ctrl) { | ||
462 | ctrl = amp_ctrl_add(mgr, rsp.remote_id); | ||
463 | if (ctrl) { | ||
464 | amp_ctrl_get(ctrl); | ||
465 | } else { | ||
466 | rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION; | ||
467 | goto send_rsp; | ||
468 | } | ||
469 | } | ||
269 | 470 | ||
270 | rsp.status = A2MP_STATUS_SUCCESS; | 471 | if (ctrl) { |
472 | size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req); | ||
473 | u8 *assoc; | ||
474 | |||
475 | assoc = kzalloc(assoc_len, GFP_KERNEL); | ||
476 | if (!assoc) { | ||
477 | amp_ctrl_put(ctrl); | ||
478 | return -ENOMEM; | ||
479 | } | ||
480 | |||
481 | memcpy(assoc, req->amp_assoc, assoc_len); | ||
482 | ctrl->assoc = assoc; | ||
483 | ctrl->assoc_len = assoc_len; | ||
484 | ctrl->assoc_rem_len = assoc_len; | ||
485 | ctrl->assoc_len_so_far = 0; | ||
486 | |||
487 | amp_ctrl_put(ctrl); | ||
488 | } | ||
489 | |||
490 | hcon = phylink_add(hdev, mgr, req->local_id, false); | ||
491 | if (hcon) { | ||
492 | amp_accept_phylink(hdev, mgr, hcon); | ||
493 | rsp.status = A2MP_STATUS_SUCCESS; | ||
494 | } else { | ||
495 | rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION; | ||
496 | } | ||
271 | 497 | ||
272 | send_rsp: | 498 | send_rsp: |
273 | if (hdev) | 499 | if (hdev) |
@@ -286,6 +512,7 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
286 | struct a2mp_physlink_req *req = (void *) skb->data; | 512 | struct a2mp_physlink_req *req = (void *) skb->data; |
287 | struct a2mp_physlink_rsp rsp; | 513 | struct a2mp_physlink_rsp rsp; |
288 | struct hci_dev *hdev; | 514 | struct hci_dev *hdev; |
515 | struct hci_conn *hcon; | ||
289 | 516 | ||
290 | if (le16_to_cpu(hdr->len) < sizeof(*req)) | 517 | if (le16_to_cpu(hdr->len) < sizeof(*req)) |
291 | return -EINVAL; | 518 | return -EINVAL; |
@@ -296,14 +523,22 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, | |||
296 | rsp.remote_id = req->local_id; | 523 | rsp.remote_id = req->local_id; |
297 | rsp.status = A2MP_STATUS_SUCCESS; | 524 | rsp.status = A2MP_STATUS_SUCCESS; |
298 | 525 | ||
299 | hdev = hci_dev_get(req->local_id); | 526 | hdev = hci_dev_get(req->remote_id); |
300 | if (!hdev) { | 527 | if (!hdev) { |
301 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; | 528 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; |
302 | goto send_rsp; | 529 | goto send_rsp; |
303 | } | 530 | } |
304 | 531 | ||
532 | hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, mgr->l2cap_conn->dst); | ||
533 | if (!hcon) { | ||
534 | BT_ERR("No phys link exist"); | ||
535 | rsp.status = A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS; | ||
536 | goto clean; | ||
537 | } | ||
538 | |||
305 | /* TODO Disconnect Phys Link here */ | 539 | /* TODO Disconnect Phys Link here */ |
306 | 540 | ||
541 | clean: | ||
307 | hci_dev_put(hdev); | 542 | hci_dev_put(hdev); |
308 | 543 | ||
309 | send_rsp: | 544 | send_rsp: |
@@ -377,10 +612,19 @@ static int a2mp_chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb) | |||
377 | err = a2mp_discphyslink_req(mgr, skb, hdr); | 612 | err = a2mp_discphyslink_req(mgr, skb, hdr); |
378 | break; | 613 | break; |
379 | 614 | ||
380 | case A2MP_CHANGE_RSP: | ||
381 | case A2MP_DISCOVER_RSP: | 615 | case A2MP_DISCOVER_RSP: |
616 | err = a2mp_discover_rsp(mgr, skb, hdr); | ||
617 | break; | ||
618 | |||
382 | case A2MP_GETINFO_RSP: | 619 | case A2MP_GETINFO_RSP: |
620 | err = a2mp_getinfo_rsp(mgr, skb, hdr); | ||
621 | break; | ||
622 | |||
383 | case A2MP_GETAMPASSOC_RSP: | 623 | case A2MP_GETAMPASSOC_RSP: |
624 | err = a2mp_getampassoc_rsp(mgr, skb, hdr); | ||
625 | break; | ||
626 | |||
627 | case A2MP_CHANGE_RSP: | ||
384 | case A2MP_CREATEPHYSLINK_RSP: | 628 | case A2MP_CREATEPHYSLINK_RSP: |
385 | case A2MP_DISCONNPHYSLINK_RSP: | 629 | case A2MP_DISCONNPHYSLINK_RSP: |
386 | err = a2mp_cmd_rsp(mgr, skb, hdr); | 630 | err = a2mp_cmd_rsp(mgr, skb, hdr); |
@@ -455,9 +699,10 @@ static struct l2cap_ops a2mp_chan_ops = { | |||
455 | .new_connection = l2cap_chan_no_new_connection, | 699 | .new_connection = l2cap_chan_no_new_connection, |
456 | .teardown = l2cap_chan_no_teardown, | 700 | .teardown = l2cap_chan_no_teardown, |
457 | .ready = l2cap_chan_no_ready, | 701 | .ready = l2cap_chan_no_ready, |
702 | .defer = l2cap_chan_no_defer, | ||
458 | }; | 703 | }; |
459 | 704 | ||
460 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | 705 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) |
461 | { | 706 | { |
462 | struct l2cap_chan *chan; | 707 | struct l2cap_chan *chan; |
463 | int err; | 708 | int err; |
@@ -492,7 +737,10 @@ static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | |||
492 | 737 | ||
493 | chan->conf_state = 0; | 738 | chan->conf_state = 0; |
494 | 739 | ||
495 | l2cap_chan_add(conn, chan); | 740 | if (locked) |
741 | __l2cap_chan_add(conn, chan); | ||
742 | else | ||
743 | l2cap_chan_add(conn, chan); | ||
496 | 744 | ||
497 | chan->remote_mps = chan->omtu; | 745 | chan->remote_mps = chan->omtu; |
498 | chan->mps = chan->omtu; | 746 | chan->mps = chan->omtu; |
@@ -503,11 +751,13 @@ static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | |||
503 | } | 751 | } |
504 | 752 | ||
505 | /* AMP Manager functions */ | 753 | /* AMP Manager functions */ |
506 | void amp_mgr_get(struct amp_mgr *mgr) | 754 | struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) |
507 | { | 755 | { |
508 | BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); | 756 | BT_DBG("mgr %p orig refcnt %d", mgr, atomic_read(&mgr->kref.refcount)); |
509 | 757 | ||
510 | kref_get(&mgr->kref); | 758 | kref_get(&mgr->kref); |
759 | |||
760 | return mgr; | ||
511 | } | 761 | } |
512 | 762 | ||
513 | static void amp_mgr_destroy(struct kref *kref) | 763 | static void amp_mgr_destroy(struct kref *kref) |
@@ -516,6 +766,11 @@ static void amp_mgr_destroy(struct kref *kref) | |||
516 | 766 | ||
517 | BT_DBG("mgr %p", mgr); | 767 | BT_DBG("mgr %p", mgr); |
518 | 768 | ||
769 | mutex_lock(&_mgr_list_lock); | ||
770 | list_del(&mgr->list); | ||
771 | mutex_unlock(&_mgr_list_lock); | ||
772 | |||
773 | amp_ctrl_list_flush(mgr); | ||
519 | kfree(mgr); | 774 | kfree(mgr); |
520 | } | 775 | } |
521 | 776 | ||
@@ -526,7 +781,7 @@ int amp_mgr_put(struct amp_mgr *mgr) | |||
526 | return kref_put(&mgr->kref, &_mgr_destroy); | 781 | return kref_put(&mgr->kref, &_mgr_destroy); |
527 | } | 782 | } |
528 | 783 | ||
529 | static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn) | 784 | static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn, bool locked) |
530 | { | 785 | { |
531 | struct amp_mgr *mgr; | 786 | struct amp_mgr *mgr; |
532 | struct l2cap_chan *chan; | 787 | struct l2cap_chan *chan; |
@@ -539,7 +794,7 @@ static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn) | |||
539 | 794 | ||
540 | mgr->l2cap_conn = conn; | 795 | mgr->l2cap_conn = conn; |
541 | 796 | ||
542 | chan = a2mp_chan_open(conn); | 797 | chan = a2mp_chan_open(conn, locked); |
543 | if (!chan) { | 798 | if (!chan) { |
544 | kfree(mgr); | 799 | kfree(mgr); |
545 | return NULL; | 800 | return NULL; |
@@ -552,6 +807,14 @@ static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn) | |||
552 | 807 | ||
553 | kref_init(&mgr->kref); | 808 | kref_init(&mgr->kref); |
554 | 809 | ||
810 | /* Remote AMP ctrl list initialization */ | ||
811 | INIT_LIST_HEAD(&mgr->amp_ctrls); | ||
812 | mutex_init(&mgr->amp_ctrls_lock); | ||
813 | |||
814 | mutex_lock(&_mgr_list_lock); | ||
815 | list_add(&mgr->list, &_mgr_list); | ||
816 | mutex_unlock(&_mgr_list_lock); | ||
817 | |||
555 | return mgr; | 818 | return mgr; |
556 | } | 819 | } |
557 | 820 | ||
@@ -560,7 +823,7 @@ struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | |||
560 | { | 823 | { |
561 | struct amp_mgr *mgr; | 824 | struct amp_mgr *mgr; |
562 | 825 | ||
563 | mgr = amp_mgr_create(conn); | 826 | mgr = amp_mgr_create(conn, false); |
564 | if (!mgr) { | 827 | if (!mgr) { |
565 | BT_ERR("Could not create AMP manager"); | 828 | BT_ERR("Could not create AMP manager"); |
566 | return NULL; | 829 | return NULL; |
@@ -570,3 +833,139 @@ struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | |||
570 | 833 | ||
571 | return mgr->a2mp_chan; | 834 | return mgr->a2mp_chan; |
572 | } | 835 | } |
836 | |||
837 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state) | ||
838 | { | ||
839 | struct amp_mgr *mgr; | ||
840 | |||
841 | mutex_lock(&_mgr_list_lock); | ||
842 | list_for_each_entry(mgr, &_mgr_list, list) { | ||
843 | if (mgr->state == state) { | ||
844 | amp_mgr_get(mgr); | ||
845 | mutex_unlock(&_mgr_list_lock); | ||
846 | return mgr; | ||
847 | } | ||
848 | } | ||
849 | mutex_unlock(&_mgr_list_lock); | ||
850 | |||
851 | return NULL; | ||
852 | } | ||
853 | |||
854 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev) | ||
855 | { | ||
856 | struct amp_mgr *mgr; | ||
857 | struct a2mp_info_rsp rsp; | ||
858 | |||
859 | mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO); | ||
860 | if (!mgr) | ||
861 | return; | ||
862 | |||
863 | BT_DBG("%s mgr %p", hdev->name, mgr); | ||
864 | |||
865 | rsp.id = hdev->id; | ||
866 | rsp.status = A2MP_STATUS_INVALID_CTRL_ID; | ||
867 | |||
868 | if (hdev->amp_type != HCI_BREDR) { | ||
869 | rsp.status = 0; | ||
870 | rsp.total_bw = cpu_to_le32(hdev->amp_total_bw); | ||
871 | rsp.max_bw = cpu_to_le32(hdev->amp_max_bw); | ||
872 | rsp.min_latency = cpu_to_le32(hdev->amp_min_latency); | ||
873 | rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap); | ||
874 | rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size); | ||
875 | } | ||
876 | |||
877 | a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp); | ||
878 | amp_mgr_put(mgr); | ||
879 | } | ||
880 | |||
881 | void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status) | ||
882 | { | ||
883 | struct amp_mgr *mgr; | ||
884 | struct amp_assoc *loc_assoc = &hdev->loc_assoc; | ||
885 | struct a2mp_amp_assoc_rsp *rsp; | ||
886 | size_t len; | ||
887 | |||
888 | mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); | ||
889 | if (!mgr) | ||
890 | return; | ||
891 | |||
892 | BT_DBG("%s mgr %p", hdev->name, mgr); | ||
893 | |||
894 | len = sizeof(struct a2mp_amp_assoc_rsp) + loc_assoc->len; | ||
895 | rsp = kzalloc(len, GFP_KERNEL); | ||
896 | if (!rsp) { | ||
897 | amp_mgr_put(mgr); | ||
898 | return; | ||
899 | } | ||
900 | |||
901 | rsp->id = hdev->id; | ||
902 | |||
903 | if (status) { | ||
904 | rsp->status = A2MP_STATUS_INVALID_CTRL_ID; | ||
905 | } else { | ||
906 | rsp->status = A2MP_STATUS_SUCCESS; | ||
907 | memcpy(rsp->amp_assoc, loc_assoc->data, loc_assoc->len); | ||
908 | } | ||
909 | |||
910 | a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp); | ||
911 | amp_mgr_put(mgr); | ||
912 | kfree(rsp); | ||
913 | } | ||
914 | |||
915 | void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status) | ||
916 | { | ||
917 | struct amp_mgr *mgr; | ||
918 | struct amp_assoc *loc_assoc = &hdev->loc_assoc; | ||
919 | struct a2mp_physlink_req *req; | ||
920 | struct l2cap_chan *bredr_chan; | ||
921 | size_t len; | ||
922 | |||
923 | mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL); | ||
924 | if (!mgr) | ||
925 | return; | ||
926 | |||
927 | len = sizeof(*req) + loc_assoc->len; | ||
928 | |||
929 | BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len); | ||
930 | |||
931 | req = kzalloc(len, GFP_KERNEL); | ||
932 | if (!req) { | ||
933 | amp_mgr_put(mgr); | ||
934 | return; | ||
935 | } | ||
936 | |||
937 | bredr_chan = mgr->bredr_chan; | ||
938 | if (!bredr_chan) | ||
939 | goto clean; | ||
940 | |||
941 | req->local_id = hdev->id; | ||
942 | req->remote_id = bredr_chan->remote_amp_id; | ||
943 | memcpy(req->amp_assoc, loc_assoc->data, loc_assoc->len); | ||
944 | |||
945 | a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req); | ||
946 | |||
947 | clean: | ||
948 | amp_mgr_put(mgr); | ||
949 | kfree(req); | ||
950 | } | ||
951 | |||
952 | void a2mp_discover_amp(struct l2cap_chan *chan) | ||
953 | { | ||
954 | struct l2cap_conn *conn = chan->conn; | ||
955 | struct amp_mgr *mgr = conn->hcon->amp_mgr; | ||
956 | struct a2mp_discov_req req; | ||
957 | |||
958 | BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr); | ||
959 | |||
960 | if (!mgr) { | ||
961 | mgr = amp_mgr_create(conn, true); | ||
962 | if (!mgr) | ||
963 | return; | ||
964 | } | ||
965 | |||
966 | mgr->bredr_chan = chan; | ||
967 | |||
968 | req.mtu = cpu_to_le16(L2CAP_A2MP_DEFAULT_MTU); | ||
969 | req.ext_feat = 0; | ||
970 | a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); | ||
971 | } | ||
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index ba033f09196e..5355df63d39b 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -569,7 +569,6 @@ static int bt_seq_show(struct seq_file *seq, void *v) | |||
569 | { | 569 | { |
570 | struct bt_seq_state *s = seq->private; | 570 | struct bt_seq_state *s = seq->private; |
571 | struct bt_sock_list *l = s->l; | 571 | struct bt_sock_list *l = s->l; |
572 | bdaddr_t src_baswapped, dst_baswapped; | ||
573 | 572 | ||
574 | if (v == SEQ_START_TOKEN) { | 573 | if (v == SEQ_START_TOKEN) { |
575 | seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); | 574 | seq_puts(seq ,"sk RefCnt Rmem Wmem User Inode Src Dst Parent"); |
@@ -583,18 +582,17 @@ static int bt_seq_show(struct seq_file *seq, void *v) | |||
583 | } else { | 582 | } else { |
584 | struct sock *sk = sk_entry(v); | 583 | struct sock *sk = sk_entry(v); |
585 | struct bt_sock *bt = bt_sk(sk); | 584 | struct bt_sock *bt = bt_sk(sk); |
586 | baswap(&src_baswapped, &bt->src); | ||
587 | baswap(&dst_baswapped, &bt->dst); | ||
588 | 585 | ||
589 | seq_printf(seq, "%pK %-6d %-6u %-6u %-6u %-6lu %pM %pM %-6lu", | 586 | seq_printf(seq, |
587 | "%pK %-6d %-6u %-6u %-6u %-6lu %pMR %pMR %-6lu", | ||
590 | sk, | 588 | sk, |
591 | atomic_read(&sk->sk_refcnt), | 589 | atomic_read(&sk->sk_refcnt), |
592 | sk_rmem_alloc_get(sk), | 590 | sk_rmem_alloc_get(sk), |
593 | sk_wmem_alloc_get(sk), | 591 | sk_wmem_alloc_get(sk), |
594 | from_kuid(seq_user_ns(seq), sock_i_uid(sk)), | 592 | from_kuid(seq_user_ns(seq), sock_i_uid(sk)), |
595 | sock_i_ino(sk), | 593 | sock_i_ino(sk), |
596 | &src_baswapped, | 594 | &bt->src, |
597 | &dst_baswapped, | 595 | &bt->dst, |
598 | bt->parent? sock_i_ino(bt->parent): 0LU); | 596 | bt->parent? sock_i_ino(bt->parent): 0LU); |
599 | 597 | ||
600 | if (l->custom_seq_show) { | 598 | if (l->custom_seq_show) { |
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c new file mode 100644 index 000000000000..1b0d92c0643a --- /dev/null +++ b/net/bluetooth/amp.c | |||
@@ -0,0 +1,471 @@ | |||
1 | /* | ||
2 | Copyright (c) 2011,2012 Intel Corp. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License version 2 and | ||
6 | only version 2 as published by the Free Software Foundation. | ||
7 | |||
8 | This program is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <net/bluetooth/bluetooth.h> | ||
15 | #include <net/bluetooth/hci.h> | ||
16 | #include <net/bluetooth/hci_core.h> | ||
17 | #include <net/bluetooth/a2mp.h> | ||
18 | #include <net/bluetooth/amp.h> | ||
19 | #include <crypto/hash.h> | ||
20 | |||
21 | /* Remote AMP Controllers interface */ | ||
22 | void amp_ctrl_get(struct amp_ctrl *ctrl) | ||
23 | { | ||
24 | BT_DBG("ctrl %p orig refcnt %d", ctrl, | ||
25 | atomic_read(&ctrl->kref.refcount)); | ||
26 | |||
27 | kref_get(&ctrl->kref); | ||
28 | } | ||
29 | |||
30 | static void amp_ctrl_destroy(struct kref *kref) | ||
31 | { | ||
32 | struct amp_ctrl *ctrl = container_of(kref, struct amp_ctrl, kref); | ||
33 | |||
34 | BT_DBG("ctrl %p", ctrl); | ||
35 | |||
36 | kfree(ctrl->assoc); | ||
37 | kfree(ctrl); | ||
38 | } | ||
39 | |||
40 | int amp_ctrl_put(struct amp_ctrl *ctrl) | ||
41 | { | ||
42 | BT_DBG("ctrl %p orig refcnt %d", ctrl, | ||
43 | atomic_read(&ctrl->kref.refcount)); | ||
44 | |||
45 | return kref_put(&ctrl->kref, &_ctrl_destroy); | ||
46 | } | ||
47 | |||
48 | struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id) | ||
49 | { | ||
50 | struct amp_ctrl *ctrl; | ||
51 | |||
52 | ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); | ||
53 | if (!ctrl) | ||
54 | return NULL; | ||
55 | |||
56 | kref_init(&ctrl->kref); | ||
57 | ctrl->id = id; | ||
58 | |||
59 | mutex_lock(&mgr->amp_ctrls_lock); | ||
60 | list_add(&ctrl->list, &mgr->amp_ctrls); | ||
61 | mutex_unlock(&mgr->amp_ctrls_lock); | ||
62 | |||
63 | BT_DBG("mgr %p ctrl %p", mgr, ctrl); | ||
64 | |||
65 | return ctrl; | ||
66 | } | ||
67 | |||
68 | void amp_ctrl_list_flush(struct amp_mgr *mgr) | ||
69 | { | ||
70 | struct amp_ctrl *ctrl, *n; | ||
71 | |||
72 | BT_DBG("mgr %p", mgr); | ||
73 | |||
74 | mutex_lock(&mgr->amp_ctrls_lock); | ||
75 | list_for_each_entry_safe(ctrl, n, &mgr->amp_ctrls, list) { | ||
76 | list_del(&ctrl->list); | ||
77 | amp_ctrl_put(ctrl); | ||
78 | } | ||
79 | mutex_unlock(&mgr->amp_ctrls_lock); | ||
80 | } | ||
81 | |||
82 | struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id) | ||
83 | { | ||
84 | struct amp_ctrl *ctrl; | ||
85 | |||
86 | BT_DBG("mgr %p id %d", mgr, id); | ||
87 | |||
88 | mutex_lock(&mgr->amp_ctrls_lock); | ||
89 | list_for_each_entry(ctrl, &mgr->amp_ctrls, list) { | ||
90 | if (ctrl->id == id) { | ||
91 | amp_ctrl_get(ctrl); | ||
92 | mutex_unlock(&mgr->amp_ctrls_lock); | ||
93 | return ctrl; | ||
94 | } | ||
95 | } | ||
96 | mutex_unlock(&mgr->amp_ctrls_lock); | ||
97 | |||
98 | return NULL; | ||
99 | } | ||
100 | |||
101 | /* Physical Link interface */ | ||
102 | static u8 __next_handle(struct amp_mgr *mgr) | ||
103 | { | ||
104 | if (++mgr->handle == 0) | ||
105 | mgr->handle = 1; | ||
106 | |||
107 | return mgr->handle; | ||
108 | } | ||
109 | |||
110 | struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
111 | u8 remote_id, bool out) | ||
112 | { | ||
113 | bdaddr_t *dst = mgr->l2cap_conn->dst; | ||
114 | struct hci_conn *hcon; | ||
115 | |||
116 | hcon = hci_conn_add(hdev, AMP_LINK, dst); | ||
117 | if (!hcon) | ||
118 | return NULL; | ||
119 | |||
120 | BT_DBG("hcon %p dst %pMR", hcon, dst); | ||
121 | |||
122 | hcon->state = BT_CONNECT; | ||
123 | hcon->attempt++; | ||
124 | hcon->handle = __next_handle(mgr); | ||
125 | hcon->remote_id = remote_id; | ||
126 | hcon->amp_mgr = amp_mgr_get(mgr); | ||
127 | hcon->out = out; | ||
128 | |||
129 | return hcon; | ||
130 | } | ||
131 | |||
132 | /* AMP crypto key generation interface */ | ||
133 | static int hmac_sha256(u8 *key, u8 ksize, char *plaintext, u8 psize, u8 *output) | ||
134 | { | ||
135 | int ret = 0; | ||
136 | struct crypto_shash *tfm; | ||
137 | |||
138 | if (!ksize) | ||
139 | return -EINVAL; | ||
140 | |||
141 | tfm = crypto_alloc_shash("hmac(sha256)", 0, 0); | ||
142 | if (IS_ERR(tfm)) { | ||
143 | BT_DBG("crypto_alloc_ahash failed: err %ld", PTR_ERR(tfm)); | ||
144 | return PTR_ERR(tfm); | ||
145 | } | ||
146 | |||
147 | ret = crypto_shash_setkey(tfm, key, ksize); | ||
148 | if (ret) { | ||
149 | BT_DBG("crypto_ahash_setkey failed: err %d", ret); | ||
150 | } else { | ||
151 | struct { | ||
152 | struct shash_desc shash; | ||
153 | char ctx[crypto_shash_descsize(tfm)]; | ||
154 | } desc; | ||
155 | |||
156 | desc.shash.tfm = tfm; | ||
157 | desc.shash.flags = CRYPTO_TFM_REQ_MAY_SLEEP; | ||
158 | |||
159 | ret = crypto_shash_digest(&desc.shash, plaintext, psize, | ||
160 | output); | ||
161 | } | ||
162 | |||
163 | crypto_free_shash(tfm); | ||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | int phylink_gen_key(struct hci_conn *conn, u8 *data, u8 *len, u8 *type) | ||
168 | { | ||
169 | struct hci_dev *hdev = conn->hdev; | ||
170 | struct link_key *key; | ||
171 | u8 keybuf[HCI_AMP_LINK_KEY_SIZE]; | ||
172 | u8 gamp_key[HCI_AMP_LINK_KEY_SIZE]; | ||
173 | int err; | ||
174 | |||
175 | if (!hci_conn_check_link_mode(conn)) | ||
176 | return -EACCES; | ||
177 | |||
178 | BT_DBG("conn %p key_type %d", conn, conn->key_type); | ||
179 | |||
180 | /* Legacy key */ | ||
181 | if (conn->key_type < 3) { | ||
182 | BT_ERR("Legacy key type %d", conn->key_type); | ||
183 | return -EACCES; | ||
184 | } | ||
185 | |||
186 | *type = conn->key_type; | ||
187 | *len = HCI_AMP_LINK_KEY_SIZE; | ||
188 | |||
189 | key = hci_find_link_key(hdev, &conn->dst); | ||
190 | if (!key) { | ||
191 | BT_DBG("No Link key for conn %p dst %pMR", conn, &conn->dst); | ||
192 | return -EACCES; | ||
193 | } | ||
194 | |||
195 | /* BR/EDR Link Key concatenated together with itself */ | ||
196 | memcpy(&keybuf[0], key->val, HCI_LINK_KEY_SIZE); | ||
197 | memcpy(&keybuf[HCI_LINK_KEY_SIZE], key->val, HCI_LINK_KEY_SIZE); | ||
198 | |||
199 | /* Derive Generic AMP Link Key (gamp) */ | ||
200 | err = hmac_sha256(keybuf, HCI_AMP_LINK_KEY_SIZE, "gamp", 4, gamp_key); | ||
201 | if (err) { | ||
202 | BT_ERR("Could not derive Generic AMP Key: err %d", err); | ||
203 | return err; | ||
204 | } | ||
205 | |||
206 | if (conn->key_type == HCI_LK_DEBUG_COMBINATION) { | ||
207 | BT_DBG("Use Generic AMP Key (gamp)"); | ||
208 | memcpy(data, gamp_key, HCI_AMP_LINK_KEY_SIZE); | ||
209 | return err; | ||
210 | } | ||
211 | |||
212 | /* Derive Dedicated AMP Link Key: "802b" is 802.11 PAL keyID */ | ||
213 | return hmac_sha256(gamp_key, HCI_AMP_LINK_KEY_SIZE, "802b", 4, data); | ||
214 | } | ||
215 | |||
216 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle) | ||
217 | { | ||
218 | struct hci_cp_read_local_amp_assoc cp; | ||
219 | struct amp_assoc *loc_assoc = &hdev->loc_assoc; | ||
220 | |||
221 | BT_DBG("%s handle %d", hdev->name, phy_handle); | ||
222 | |||
223 | cp.phy_handle = phy_handle; | ||
224 | cp.max_len = cpu_to_le16(hdev->amp_assoc_size); | ||
225 | cp.len_so_far = cpu_to_le16(loc_assoc->offset); | ||
226 | |||
227 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); | ||
228 | } | ||
229 | |||
230 | void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr) | ||
231 | { | ||
232 | struct hci_cp_read_local_amp_assoc cp; | ||
233 | |||
234 | memset(&hdev->loc_assoc, 0, sizeof(struct amp_assoc)); | ||
235 | memset(&cp, 0, sizeof(cp)); | ||
236 | |||
237 | cp.max_len = cpu_to_le16(hdev->amp_assoc_size); | ||
238 | |||
239 | mgr->state = READ_LOC_AMP_ASSOC; | ||
240 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); | ||
241 | } | ||
242 | |||
243 | void amp_read_loc_assoc_final_data(struct hci_dev *hdev, | ||
244 | struct hci_conn *hcon) | ||
245 | { | ||
246 | struct hci_cp_read_local_amp_assoc cp; | ||
247 | struct amp_mgr *mgr = hcon->amp_mgr; | ||
248 | |||
249 | cp.phy_handle = hcon->handle; | ||
250 | cp.len_so_far = cpu_to_le16(0); | ||
251 | cp.max_len = cpu_to_le16(hdev->amp_assoc_size); | ||
252 | |||
253 | mgr->state = READ_LOC_AMP_ASSOC_FINAL; | ||
254 | |||
255 | /* Read Local AMP Assoc final link information data */ | ||
256 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_ASSOC, sizeof(cp), &cp); | ||
257 | } | ||
258 | |||
259 | /* Write AMP Assoc data fragments, returns true with last fragment written*/ | ||
260 | static bool amp_write_rem_assoc_frag(struct hci_dev *hdev, | ||
261 | struct hci_conn *hcon) | ||
262 | { | ||
263 | struct hci_cp_write_remote_amp_assoc *cp; | ||
264 | struct amp_mgr *mgr = hcon->amp_mgr; | ||
265 | struct amp_ctrl *ctrl; | ||
266 | u16 frag_len, len; | ||
267 | |||
268 | ctrl = amp_ctrl_lookup(mgr, hcon->remote_id); | ||
269 | if (!ctrl) | ||
270 | return false; | ||
271 | |||
272 | if (!ctrl->assoc_rem_len) { | ||
273 | BT_DBG("all fragments are written"); | ||
274 | ctrl->assoc_rem_len = ctrl->assoc_len; | ||
275 | ctrl->assoc_len_so_far = 0; | ||
276 | |||
277 | amp_ctrl_put(ctrl); | ||
278 | return true; | ||
279 | } | ||
280 | |||
281 | frag_len = min_t(u16, 248, ctrl->assoc_rem_len); | ||
282 | len = frag_len + sizeof(*cp); | ||
283 | |||
284 | cp = kzalloc(len, GFP_KERNEL); | ||
285 | if (!cp) { | ||
286 | amp_ctrl_put(ctrl); | ||
287 | return false; | ||
288 | } | ||
289 | |||
290 | BT_DBG("hcon %p ctrl %p frag_len %u assoc_len %u rem_len %u", | ||
291 | hcon, ctrl, frag_len, ctrl->assoc_len, ctrl->assoc_rem_len); | ||
292 | |||
293 | cp->phy_handle = hcon->handle; | ||
294 | cp->len_so_far = cpu_to_le16(ctrl->assoc_len_so_far); | ||
295 | cp->rem_len = cpu_to_le16(ctrl->assoc_rem_len); | ||
296 | memcpy(cp->frag, ctrl->assoc, frag_len); | ||
297 | |||
298 | ctrl->assoc_len_so_far += frag_len; | ||
299 | ctrl->assoc_rem_len -= frag_len; | ||
300 | |||
301 | amp_ctrl_put(ctrl); | ||
302 | |||
303 | hci_send_cmd(hdev, HCI_OP_WRITE_REMOTE_AMP_ASSOC, len, cp); | ||
304 | |||
305 | kfree(cp); | ||
306 | |||
307 | return false; | ||
308 | } | ||
309 | |||
310 | void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle) | ||
311 | { | ||
312 | struct hci_conn *hcon; | ||
313 | |||
314 | BT_DBG("%s phy handle 0x%2.2x", hdev->name, handle); | ||
315 | |||
316 | hcon = hci_conn_hash_lookup_handle(hdev, handle); | ||
317 | if (!hcon) | ||
318 | return; | ||
319 | |||
320 | amp_write_rem_assoc_frag(hdev, hcon); | ||
321 | } | ||
322 | |||
323 | void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle) | ||
324 | { | ||
325 | struct hci_conn *hcon; | ||
326 | |||
327 | BT_DBG("%s phy handle 0x%2.2x", hdev->name, handle); | ||
328 | |||
329 | hcon = hci_conn_hash_lookup_handle(hdev, handle); | ||
330 | if (!hcon) | ||
331 | return; | ||
332 | |||
333 | BT_DBG("%s phy handle 0x%2.2x hcon %p", hdev->name, handle, hcon); | ||
334 | |||
335 | amp_write_rem_assoc_frag(hdev, hcon); | ||
336 | } | ||
337 | |||
338 | void amp_create_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
339 | struct hci_conn *hcon) | ||
340 | { | ||
341 | struct hci_cp_create_phy_link cp; | ||
342 | |||
343 | cp.phy_handle = hcon->handle; | ||
344 | |||
345 | BT_DBG("%s hcon %p phy handle 0x%2.2x", hdev->name, hcon, | ||
346 | hcon->handle); | ||
347 | |||
348 | if (phylink_gen_key(mgr->l2cap_conn->hcon, cp.key, &cp.key_len, | ||
349 | &cp.key_type)) { | ||
350 | BT_DBG("Cannot create link key"); | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | hci_send_cmd(hdev, HCI_OP_CREATE_PHY_LINK, sizeof(cp), &cp); | ||
355 | } | ||
356 | |||
357 | void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
358 | struct hci_conn *hcon) | ||
359 | { | ||
360 | struct hci_cp_accept_phy_link cp; | ||
361 | |||
362 | cp.phy_handle = hcon->handle; | ||
363 | |||
364 | BT_DBG("%s hcon %p phy handle 0x%2.2x", hdev->name, hcon, | ||
365 | hcon->handle); | ||
366 | |||
367 | if (phylink_gen_key(mgr->l2cap_conn->hcon, cp.key, &cp.key_len, | ||
368 | &cp.key_type)) { | ||
369 | BT_DBG("Cannot create link key"); | ||
370 | return; | ||
371 | } | ||
372 | |||
373 | hci_send_cmd(hdev, HCI_OP_ACCEPT_PHY_LINK, sizeof(cp), &cp); | ||
374 | } | ||
375 | |||
376 | void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon) | ||
377 | { | ||
378 | struct hci_dev *bredr_hdev = hci_dev_hold(bredr_hcon->hdev); | ||
379 | struct amp_mgr *mgr = hs_hcon->amp_mgr; | ||
380 | struct l2cap_chan *bredr_chan; | ||
381 | |||
382 | BT_DBG("bredr_hcon %p hs_hcon %p mgr %p", bredr_hcon, hs_hcon, mgr); | ||
383 | |||
384 | if (!bredr_hdev || !mgr || !mgr->bredr_chan) | ||
385 | return; | ||
386 | |||
387 | bredr_chan = mgr->bredr_chan; | ||
388 | |||
389 | l2cap_chan_lock(bredr_chan); | ||
390 | |||
391 | set_bit(FLAG_EFS_ENABLE, &bredr_chan->flags); | ||
392 | bredr_chan->remote_amp_id = hs_hcon->remote_id; | ||
393 | bredr_chan->local_amp_id = hs_hcon->hdev->id; | ||
394 | bredr_chan->hs_hcon = hs_hcon; | ||
395 | bredr_chan->conn->mtu = hs_hcon->hdev->block_mtu; | ||
396 | |||
397 | __l2cap_physical_cfm(bredr_chan, 0); | ||
398 | |||
399 | l2cap_chan_unlock(bredr_chan); | ||
400 | |||
401 | hci_dev_put(bredr_hdev); | ||
402 | } | ||
403 | |||
404 | void amp_create_logical_link(struct l2cap_chan *chan) | ||
405 | { | ||
406 | struct hci_cp_create_accept_logical_link cp; | ||
407 | struct hci_conn *hcon; | ||
408 | struct hci_dev *hdev; | ||
409 | |||
410 | BT_DBG("chan %p", chan); | ||
411 | |||
412 | if (!chan->hs_hcon) | ||
413 | return; | ||
414 | |||
415 | hdev = hci_dev_hold(chan->hs_hcon->hdev); | ||
416 | if (!hdev) | ||
417 | return; | ||
418 | |||
419 | BT_DBG("chan %p dst %pMR", chan, chan->conn->dst); | ||
420 | |||
421 | hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, chan->conn->dst); | ||
422 | if (!hcon) | ||
423 | goto done; | ||
424 | |||
425 | cp.phy_handle = hcon->handle; | ||
426 | |||
427 | cp.tx_flow_spec.id = chan->local_id; | ||
428 | cp.tx_flow_spec.stype = chan->local_stype; | ||
429 | cp.tx_flow_spec.msdu = cpu_to_le16(chan->local_msdu); | ||
430 | cp.tx_flow_spec.sdu_itime = cpu_to_le32(chan->local_sdu_itime); | ||
431 | cp.tx_flow_spec.acc_lat = cpu_to_le32(chan->local_acc_lat); | ||
432 | cp.tx_flow_spec.flush_to = cpu_to_le32(chan->local_flush_to); | ||
433 | |||
434 | cp.rx_flow_spec.id = chan->remote_id; | ||
435 | cp.rx_flow_spec.stype = chan->remote_stype; | ||
436 | cp.rx_flow_spec.msdu = cpu_to_le16(chan->remote_msdu); | ||
437 | cp.rx_flow_spec.sdu_itime = cpu_to_le32(chan->remote_sdu_itime); | ||
438 | cp.rx_flow_spec.acc_lat = cpu_to_le32(chan->remote_acc_lat); | ||
439 | cp.rx_flow_spec.flush_to = cpu_to_le32(chan->remote_flush_to); | ||
440 | |||
441 | if (hcon->out) | ||
442 | hci_send_cmd(hdev, HCI_OP_CREATE_LOGICAL_LINK, sizeof(cp), | ||
443 | &cp); | ||
444 | else | ||
445 | hci_send_cmd(hdev, HCI_OP_ACCEPT_LOGICAL_LINK, sizeof(cp), | ||
446 | &cp); | ||
447 | |||
448 | done: | ||
449 | hci_dev_put(hdev); | ||
450 | } | ||
451 | |||
452 | void amp_disconnect_logical_link(struct hci_chan *hchan) | ||
453 | { | ||
454 | struct hci_conn *hcon = hchan->conn; | ||
455 | struct hci_cp_disconn_logical_link cp; | ||
456 | |||
457 | if (hcon->state != BT_CONNECTED) { | ||
458 | BT_DBG("hchan %p not connected", hchan); | ||
459 | return; | ||
460 | } | ||
461 | |||
462 | cp.log_handle = cpu_to_le16(hchan->handle); | ||
463 | hci_send_cmd(hcon->hdev, HCI_OP_DISCONN_LOGICAL_LINK, sizeof(cp), &cp); | ||
464 | } | ||
465 | |||
466 | void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason) | ||
467 | { | ||
468 | BT_DBG("hchan %p", hchan); | ||
469 | |||
470 | hci_chan_del(hchan); | ||
471 | } | ||
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 4a6620bc1570..a5b639702637 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -182,8 +182,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len) | |||
182 | a2 = data; | 182 | a2 = data; |
183 | data += ETH_ALEN; | 183 | data += ETH_ALEN; |
184 | 184 | ||
185 | BT_DBG("mc filter %s -> %s", | 185 | BT_DBG("mc filter %pMR -> %pMR", a1, a2); |
186 | batostr((void *) a1), batostr((void *) a2)); | ||
187 | 186 | ||
188 | /* Iterate from a1 to a2 */ | 187 | /* Iterate from a1 to a2 */ |
189 | set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter); | 188 | set_bit(bnep_mc_hash(a1), (ulong *) &s->mc_filter); |
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c index 98f86f91d47c..e58c8b32589c 100644 --- a/net/bluetooth/bnep/netdev.c +++ b/net/bluetooth/bnep/netdev.c | |||
@@ -25,7 +25,6 @@ | |||
25 | SOFTWARE IS DISCLAIMED. | 25 | SOFTWARE IS DISCLAIMED. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <linux/export.h> | ||
29 | #include <linux/etherdevice.h> | 28 | #include <linux/etherdevice.h> |
30 | 29 | ||
31 | #include <net/bluetooth/bluetooth.h> | 30 | #include <net/bluetooth/bluetooth.h> |
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c index 50f0d135eb8f..a4a9d4b6816c 100644 --- a/net/bluetooth/cmtp/capi.c +++ b/net/bluetooth/cmtp/capi.c | |||
@@ -20,7 +20,7 @@ | |||
20 | SOFTWARE IS DISCLAIMED. | 20 | SOFTWARE IS DISCLAIMED. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/export.h> |
24 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 6c9c1fd601ca..e0a6ebf2baa6 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c | |||
@@ -353,7 +353,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock) | |||
353 | 353 | ||
354 | BT_DBG("mtu %d", session->mtu); | 354 | BT_DBG("mtu %d", session->mtu); |
355 | 355 | ||
356 | sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst)); | 356 | sprintf(session->name, "%pMR", &bt_sk(sock->sk)->dst); |
357 | 357 | ||
358 | session->sock = sock; | 358 | session->sock = sock; |
359 | session->state = BT_CONFIG; | 359 | session->state = BT_CONFIG; |
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index aacb802d1ee4..1c57482112b6 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c | |||
@@ -20,7 +20,7 @@ | |||
20 | SOFTWARE IS DISCLAIMED. | 20 | SOFTWARE IS DISCLAIMED. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/export.h> |
24 | 24 | ||
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/capability.h> | 26 | #include <linux/capability.h> |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b9196a44f759..25bfce0666eb 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -130,6 +130,20 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason) | |||
130 | hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp); | 130 | hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp); |
131 | } | 131 | } |
132 | 132 | ||
133 | static void hci_amp_disconn(struct hci_conn *conn, __u8 reason) | ||
134 | { | ||
135 | struct hci_cp_disconn_phy_link cp; | ||
136 | |||
137 | BT_DBG("hcon %p", conn); | ||
138 | |||
139 | conn->state = BT_DISCONN; | ||
140 | |||
141 | cp.phy_handle = HCI_PHY_HANDLE(conn->handle); | ||
142 | cp.reason = reason; | ||
143 | hci_send_cmd(conn->hdev, HCI_OP_DISCONN_PHY_LINK, | ||
144 | sizeof(cp), &cp); | ||
145 | } | ||
146 | |||
133 | static void hci_add_sco(struct hci_conn *conn, __u16 handle) | 147 | static void hci_add_sco(struct hci_conn *conn, __u16 handle) |
134 | { | 148 | { |
135 | struct hci_dev *hdev = conn->hdev; | 149 | struct hci_dev *hdev = conn->hdev; |
@@ -230,11 +244,24 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status) | |||
230 | } | 244 | } |
231 | } | 245 | } |
232 | 246 | ||
247 | static void hci_conn_disconnect(struct hci_conn *conn) | ||
248 | { | ||
249 | __u8 reason = hci_proto_disconn_ind(conn); | ||
250 | |||
251 | switch (conn->type) { | ||
252 | case ACL_LINK: | ||
253 | hci_acl_disconn(conn, reason); | ||
254 | break; | ||
255 | case AMP_LINK: | ||
256 | hci_amp_disconn(conn, reason); | ||
257 | break; | ||
258 | } | ||
259 | } | ||
260 | |||
233 | static void hci_conn_timeout(struct work_struct *work) | 261 | static void hci_conn_timeout(struct work_struct *work) |
234 | { | 262 | { |
235 | struct hci_conn *conn = container_of(work, struct hci_conn, | 263 | struct hci_conn *conn = container_of(work, struct hci_conn, |
236 | disc_work.work); | 264 | disc_work.work); |
237 | __u8 reason; | ||
238 | 265 | ||
239 | BT_DBG("hcon %p state %s", conn, state_to_string(conn->state)); | 266 | BT_DBG("hcon %p state %s", conn, state_to_string(conn->state)); |
240 | 267 | ||
@@ -253,8 +280,7 @@ static void hci_conn_timeout(struct work_struct *work) | |||
253 | break; | 280 | break; |
254 | case BT_CONFIG: | 281 | case BT_CONFIG: |
255 | case BT_CONNECTED: | 282 | case BT_CONNECTED: |
256 | reason = hci_proto_disconn_ind(conn); | 283 | hci_conn_disconnect(conn); |
257 | hci_acl_disconn(conn, reason); | ||
258 | break; | 284 | break; |
259 | default: | 285 | default: |
260 | conn->state = BT_CLOSED; | 286 | conn->state = BT_CLOSED; |
@@ -320,7 +346,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
320 | { | 346 | { |
321 | struct hci_conn *conn; | 347 | struct hci_conn *conn; |
322 | 348 | ||
323 | BT_DBG("%s dst %s", hdev->name, batostr(dst)); | 349 | BT_DBG("%s dst %pMR", hdev->name, dst); |
324 | 350 | ||
325 | conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL); | 351 | conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL); |
326 | if (!conn) | 352 | if (!conn) |
@@ -437,7 +463,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) | |||
437 | int use_src = bacmp(src, BDADDR_ANY); | 463 | int use_src = bacmp(src, BDADDR_ANY); |
438 | struct hci_dev *hdev = NULL, *d; | 464 | struct hci_dev *hdev = NULL, *d; |
439 | 465 | ||
440 | BT_DBG("%s -> %s", batostr(src), batostr(dst)); | 466 | BT_DBG("%pMR -> %pMR", src, dst); |
441 | 467 | ||
442 | read_lock(&hci_dev_list_lock); | 468 | read_lock(&hci_dev_list_lock); |
443 | 469 | ||
@@ -476,6 +502,9 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
476 | { | 502 | { |
477 | struct hci_conn *le; | 503 | struct hci_conn *le; |
478 | 504 | ||
505 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->flags)) | ||
506 | return ERR_PTR(-ENOTSUPP); | ||
507 | |||
479 | le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); | 508 | le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); |
480 | if (!le) { | 509 | if (!le) { |
481 | le = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT); | 510 | le = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT); |
@@ -567,7 +596,7 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, | |||
567 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | 596 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, |
568 | __u8 dst_type, __u8 sec_level, __u8 auth_type) | 597 | __u8 dst_type, __u8 sec_level, __u8 auth_type) |
569 | { | 598 | { |
570 | BT_DBG("%s dst %s type 0x%x", hdev->name, batostr(dst), type); | 599 | BT_DBG("%s dst %pMR type 0x%x", hdev->name, dst, type); |
571 | 600 | ||
572 | switch (type) { | 601 | switch (type) { |
573 | case LE_LINK: | 602 | case LE_LINK: |
@@ -933,6 +962,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn) | |||
933 | 962 | ||
934 | chan->conn = conn; | 963 | chan->conn = conn; |
935 | skb_queue_head_init(&chan->data_q); | 964 | skb_queue_head_init(&chan->data_q); |
965 | chan->state = BT_CONNECTED; | ||
936 | 966 | ||
937 | list_add_rcu(&chan->list, &conn->chan_list); | 967 | list_add_rcu(&chan->list, &conn->chan_list); |
938 | 968 | ||
@@ -950,6 +980,8 @@ void hci_chan_del(struct hci_chan *chan) | |||
950 | 980 | ||
951 | synchronize_rcu(); | 981 | synchronize_rcu(); |
952 | 982 | ||
983 | hci_conn_put(conn); | ||
984 | |||
953 | skb_queue_purge(&chan->data_q); | 985 | skb_queue_purge(&chan->data_q); |
954 | kfree(chan); | 986 | kfree(chan); |
955 | } | 987 | } |
@@ -963,3 +995,35 @@ void hci_chan_list_flush(struct hci_conn *conn) | |||
963 | list_for_each_entry_safe(chan, n, &conn->chan_list, list) | 995 | list_for_each_entry_safe(chan, n, &conn->chan_list, list) |
964 | hci_chan_del(chan); | 996 | hci_chan_del(chan); |
965 | } | 997 | } |
998 | |||
999 | static struct hci_chan *__hci_chan_lookup_handle(struct hci_conn *hcon, | ||
1000 | __u16 handle) | ||
1001 | { | ||
1002 | struct hci_chan *hchan; | ||
1003 | |||
1004 | list_for_each_entry(hchan, &hcon->chan_list, list) { | ||
1005 | if (hchan->handle == handle) | ||
1006 | return hchan; | ||
1007 | } | ||
1008 | |||
1009 | return NULL; | ||
1010 | } | ||
1011 | |||
1012 | struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle) | ||
1013 | { | ||
1014 | struct hci_conn_hash *h = &hdev->conn_hash; | ||
1015 | struct hci_conn *hcon; | ||
1016 | struct hci_chan *hchan = NULL; | ||
1017 | |||
1018 | rcu_read_lock(); | ||
1019 | |||
1020 | list_for_each_entry_rcu(hcon, &h->list, list) { | ||
1021 | hchan = __hci_chan_lookup_handle(hcon, handle); | ||
1022 | if (hchan) | ||
1023 | break; | ||
1024 | } | ||
1025 | |||
1026 | rcu_read_unlock(); | ||
1027 | |||
1028 | return hchan; | ||
1029 | } | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8a0ce706aebd..7140f83328a2 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -178,48 +178,13 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt) | |||
178 | 178 | ||
179 | static void bredr_init(struct hci_dev *hdev) | 179 | static void bredr_init(struct hci_dev *hdev) |
180 | { | 180 | { |
181 | struct hci_cp_delete_stored_link_key cp; | ||
182 | __le16 param; | ||
183 | __u8 flt_type; | ||
184 | |||
185 | hdev->flow_ctl_mode = HCI_FLOW_CTL_MODE_PACKET_BASED; | 181 | hdev->flow_ctl_mode = HCI_FLOW_CTL_MODE_PACKET_BASED; |
186 | 182 | ||
187 | /* Mandatory initialization */ | ||
188 | |||
189 | /* Read Local Supported Features */ | 183 | /* Read Local Supported Features */ |
190 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL); | 184 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL); |
191 | 185 | ||
192 | /* Read Local Version */ | 186 | /* Read Local Version */ |
193 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL); | 187 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL); |
194 | |||
195 | /* Read Buffer Size (ACL mtu, max pkt, etc.) */ | ||
196 | hci_send_cmd(hdev, HCI_OP_READ_BUFFER_SIZE, 0, NULL); | ||
197 | |||
198 | /* Read BD Address */ | ||
199 | hci_send_cmd(hdev, HCI_OP_READ_BD_ADDR, 0, NULL); | ||
200 | |||
201 | /* Read Class of Device */ | ||
202 | hci_send_cmd(hdev, HCI_OP_READ_CLASS_OF_DEV, 0, NULL); | ||
203 | |||
204 | /* Read Local Name */ | ||
205 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL); | ||
206 | |||
207 | /* Read Voice Setting */ | ||
208 | hci_send_cmd(hdev, HCI_OP_READ_VOICE_SETTING, 0, NULL); | ||
209 | |||
210 | /* Optional initialization */ | ||
211 | |||
212 | /* Clear Event Filters */ | ||
213 | flt_type = HCI_FLT_CLEAR_ALL; | ||
214 | hci_send_cmd(hdev, HCI_OP_SET_EVENT_FLT, 1, &flt_type); | ||
215 | |||
216 | /* Connection accept timeout ~20 secs */ | ||
217 | param = __constant_cpu_to_le16(0x7d00); | ||
218 | hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, ¶m); | ||
219 | |||
220 | bacpy(&cp.bdaddr, BDADDR_ANY); | ||
221 | cp.delete_all = 1; | ||
222 | hci_send_cmd(hdev, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp); | ||
223 | } | 188 | } |
224 | 189 | ||
225 | static void amp_init(struct hci_dev *hdev) | 190 | static void amp_init(struct hci_dev *hdev) |
@@ -273,14 +238,6 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) | |||
273 | } | 238 | } |
274 | } | 239 | } |
275 | 240 | ||
276 | static void hci_le_init_req(struct hci_dev *hdev, unsigned long opt) | ||
277 | { | ||
278 | BT_DBG("%s", hdev->name); | ||
279 | |||
280 | /* Read LE buffer size */ | ||
281 | hci_send_cmd(hdev, HCI_OP_LE_READ_BUFFER_SIZE, 0, NULL); | ||
282 | } | ||
283 | |||
284 | static void hci_scan_req(struct hci_dev *hdev, unsigned long opt) | 241 | static void hci_scan_req(struct hci_dev *hdev, unsigned long opt) |
285 | { | 242 | { |
286 | __u8 scan = opt; | 243 | __u8 scan = opt; |
@@ -405,7 +362,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, | |||
405 | struct discovery_state *cache = &hdev->discovery; | 362 | struct discovery_state *cache = &hdev->discovery; |
406 | struct inquiry_entry *e; | 363 | struct inquiry_entry *e; |
407 | 364 | ||
408 | BT_DBG("cache %p, %s", cache, batostr(bdaddr)); | 365 | BT_DBG("cache %p, %pMR", cache, bdaddr); |
409 | 366 | ||
410 | list_for_each_entry(e, &cache->all, all) { | 367 | list_for_each_entry(e, &cache->all, all) { |
411 | if (!bacmp(&e->data.bdaddr, bdaddr)) | 368 | if (!bacmp(&e->data.bdaddr, bdaddr)) |
@@ -421,7 +378,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, | |||
421 | struct discovery_state *cache = &hdev->discovery; | 378 | struct discovery_state *cache = &hdev->discovery; |
422 | struct inquiry_entry *e; | 379 | struct inquiry_entry *e; |
423 | 380 | ||
424 | BT_DBG("cache %p, %s", cache, batostr(bdaddr)); | 381 | BT_DBG("cache %p, %pMR", cache, bdaddr); |
425 | 382 | ||
426 | list_for_each_entry(e, &cache->unknown, list) { | 383 | list_for_each_entry(e, &cache->unknown, list) { |
427 | if (!bacmp(&e->data.bdaddr, bdaddr)) | 384 | if (!bacmp(&e->data.bdaddr, bdaddr)) |
@@ -438,7 +395,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, | |||
438 | struct discovery_state *cache = &hdev->discovery; | 395 | struct discovery_state *cache = &hdev->discovery; |
439 | struct inquiry_entry *e; | 396 | struct inquiry_entry *e; |
440 | 397 | ||
441 | BT_DBG("cache %p bdaddr %s state %d", cache, batostr(bdaddr), state); | 398 | BT_DBG("cache %p bdaddr %pMR state %d", cache, bdaddr, state); |
442 | 399 | ||
443 | list_for_each_entry(e, &cache->resolve, list) { | 400 | list_for_each_entry(e, &cache->resolve, list) { |
444 | if (!bacmp(bdaddr, BDADDR_ANY) && e->name_state == state) | 401 | if (!bacmp(bdaddr, BDADDR_ANY) && e->name_state == state) |
@@ -475,7 +432,9 @@ bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, | |||
475 | struct discovery_state *cache = &hdev->discovery; | 432 | struct discovery_state *cache = &hdev->discovery; |
476 | struct inquiry_entry *ie; | 433 | struct inquiry_entry *ie; |
477 | 434 | ||
478 | BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr)); | 435 | BT_DBG("cache %p, %pMR", cache, &data->bdaddr); |
436 | |||
437 | hci_remove_remote_oob_data(hdev, &data->bdaddr); | ||
479 | 438 | ||
480 | if (ssp) | 439 | if (ssp) |
481 | *ssp = data->ssp_mode; | 440 | *ssp = data->ssp_mode; |
@@ -637,6 +596,99 @@ done: | |||
637 | return err; | 596 | return err; |
638 | } | 597 | } |
639 | 598 | ||
599 | static u8 create_ad(struct hci_dev *hdev, u8 *ptr) | ||
600 | { | ||
601 | u8 ad_len = 0, flags = 0; | ||
602 | size_t name_len; | ||
603 | |||
604 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) | ||
605 | flags |= LE_AD_GENERAL; | ||
606 | |||
607 | if (!lmp_bredr_capable(hdev)) | ||
608 | flags |= LE_AD_NO_BREDR; | ||
609 | |||
610 | if (lmp_le_br_capable(hdev)) | ||
611 | flags |= LE_AD_SIM_LE_BREDR_CTRL; | ||
612 | |||
613 | if (lmp_host_le_br_capable(hdev)) | ||
614 | flags |= LE_AD_SIM_LE_BREDR_HOST; | ||
615 | |||
616 | if (flags) { | ||
617 | BT_DBG("adv flags 0x%02x", flags); | ||
618 | |||
619 | ptr[0] = 2; | ||
620 | ptr[1] = EIR_FLAGS; | ||
621 | ptr[2] = flags; | ||
622 | |||
623 | ad_len += 3; | ||
624 | ptr += 3; | ||
625 | } | ||
626 | |||
627 | if (hdev->adv_tx_power != HCI_TX_POWER_INVALID) { | ||
628 | ptr[0] = 2; | ||
629 | ptr[1] = EIR_TX_POWER; | ||
630 | ptr[2] = (u8) hdev->adv_tx_power; | ||
631 | |||
632 | ad_len += 3; | ||
633 | ptr += 3; | ||
634 | } | ||
635 | |||
636 | name_len = strlen(hdev->dev_name); | ||
637 | if (name_len > 0) { | ||
638 | size_t max_len = HCI_MAX_AD_LENGTH - ad_len - 2; | ||
639 | |||
640 | if (name_len > max_len) { | ||
641 | name_len = max_len; | ||
642 | ptr[1] = EIR_NAME_SHORT; | ||
643 | } else | ||
644 | ptr[1] = EIR_NAME_COMPLETE; | ||
645 | |||
646 | ptr[0] = name_len + 1; | ||
647 | |||
648 | memcpy(ptr + 2, hdev->dev_name, name_len); | ||
649 | |||
650 | ad_len += (name_len + 2); | ||
651 | ptr += (name_len + 2); | ||
652 | } | ||
653 | |||
654 | return ad_len; | ||
655 | } | ||
656 | |||
657 | int hci_update_ad(struct hci_dev *hdev) | ||
658 | { | ||
659 | struct hci_cp_le_set_adv_data cp; | ||
660 | u8 len; | ||
661 | int err; | ||
662 | |||
663 | hci_dev_lock(hdev); | ||
664 | |||
665 | if (!lmp_le_capable(hdev)) { | ||
666 | err = -EINVAL; | ||
667 | goto unlock; | ||
668 | } | ||
669 | |||
670 | memset(&cp, 0, sizeof(cp)); | ||
671 | |||
672 | len = create_ad(hdev, cp.data); | ||
673 | |||
674 | if (hdev->adv_data_len == len && | ||
675 | memcmp(cp.data, hdev->adv_data, len) == 0) { | ||
676 | err = 0; | ||
677 | goto unlock; | ||
678 | } | ||
679 | |||
680 | memcpy(hdev->adv_data, cp.data, sizeof(cp.data)); | ||
681 | hdev->adv_data_len = len; | ||
682 | |||
683 | cp.length = len; | ||
684 | err = hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp); | ||
685 | |||
686 | unlock: | ||
687 | hci_dev_unlock(hdev); | ||
688 | |||
689 | return err; | ||
690 | } | ||
691 | |||
640 | /* ---- HCI ioctl helpers ---- */ | 692 | /* ---- HCI ioctl helpers ---- */ |
641 | 693 | ||
642 | int hci_dev_open(__u16 dev) | 694 | int hci_dev_open(__u16 dev) |
@@ -687,10 +739,6 @@ int hci_dev_open(__u16 dev) | |||
687 | 739 | ||
688 | ret = __hci_request(hdev, hci_init_req, 0, HCI_INIT_TIMEOUT); | 740 | ret = __hci_request(hdev, hci_init_req, 0, HCI_INIT_TIMEOUT); |
689 | 741 | ||
690 | if (lmp_host_le_capable(hdev)) | ||
691 | ret = __hci_request(hdev, hci_le_init_req, 0, | ||
692 | HCI_INIT_TIMEOUT); | ||
693 | |||
694 | clear_bit(HCI_INIT, &hdev->flags); | 742 | clear_bit(HCI_INIT, &hdev->flags); |
695 | } | 743 | } |
696 | 744 | ||
@@ -698,6 +746,7 @@ int hci_dev_open(__u16 dev) | |||
698 | hci_dev_hold(hdev); | 746 | hci_dev_hold(hdev); |
699 | set_bit(HCI_UP, &hdev->flags); | 747 | set_bit(HCI_UP, &hdev->flags); |
700 | hci_notify(hdev, HCI_DEV_UP); | 748 | hci_notify(hdev, HCI_DEV_UP); |
749 | hci_update_ad(hdev); | ||
701 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && | 750 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && |
702 | mgmt_valid_hdev(hdev)) { | 751 | mgmt_valid_hdev(hdev)) { |
703 | hci_dev_lock(hdev); | 752 | hci_dev_lock(hdev); |
@@ -1039,10 +1088,17 @@ int hci_get_dev_info(void __user *arg) | |||
1039 | di.type = (hdev->bus & 0x0f) | (hdev->dev_type << 4); | 1088 | di.type = (hdev->bus & 0x0f) | (hdev->dev_type << 4); |
1040 | di.flags = hdev->flags; | 1089 | di.flags = hdev->flags; |
1041 | di.pkt_type = hdev->pkt_type; | 1090 | di.pkt_type = hdev->pkt_type; |
1042 | di.acl_mtu = hdev->acl_mtu; | 1091 | if (lmp_bredr_capable(hdev)) { |
1043 | di.acl_pkts = hdev->acl_pkts; | 1092 | di.acl_mtu = hdev->acl_mtu; |
1044 | di.sco_mtu = hdev->sco_mtu; | 1093 | di.acl_pkts = hdev->acl_pkts; |
1045 | di.sco_pkts = hdev->sco_pkts; | 1094 | di.sco_mtu = hdev->sco_mtu; |
1095 | di.sco_pkts = hdev->sco_pkts; | ||
1096 | } else { | ||
1097 | di.acl_mtu = hdev->le_mtu; | ||
1098 | di.acl_pkts = hdev->le_pkts; | ||
1099 | di.sco_mtu = 0; | ||
1100 | di.sco_pkts = 0; | ||
1101 | } | ||
1046 | di.link_policy = hdev->link_policy; | 1102 | di.link_policy = hdev->link_policy; |
1047 | di.link_mode = hdev->link_mode; | 1103 | di.link_mode = hdev->link_mode; |
1048 | 1104 | ||
@@ -1259,7 +1315,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | |||
1259 | list_add(&key->list, &hdev->link_keys); | 1315 | list_add(&key->list, &hdev->link_keys); |
1260 | } | 1316 | } |
1261 | 1317 | ||
1262 | BT_DBG("%s key for %s type %u", hdev->name, batostr(bdaddr), type); | 1318 | BT_DBG("%s key for %pMR type %u", hdev->name, bdaddr, type); |
1263 | 1319 | ||
1264 | /* Some buggy controller combinations generate a changed | 1320 | /* Some buggy controller combinations generate a changed |
1265 | * combination key for legacy pairing even when there's no | 1321 | * combination key for legacy pairing even when there's no |
@@ -1338,7 +1394,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1338 | if (!key) | 1394 | if (!key) |
1339 | return -ENOENT; | 1395 | return -ENOENT; |
1340 | 1396 | ||
1341 | BT_DBG("%s removing %s", hdev->name, batostr(bdaddr)); | 1397 | BT_DBG("%s removing %pMR", hdev->name, bdaddr); |
1342 | 1398 | ||
1343 | list_del(&key->list); | 1399 | list_del(&key->list); |
1344 | kfree(key); | 1400 | kfree(key); |
@@ -1354,7 +1410,7 @@ int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1354 | if (bacmp(bdaddr, &k->bdaddr)) | 1410 | if (bacmp(bdaddr, &k->bdaddr)) |
1355 | continue; | 1411 | continue; |
1356 | 1412 | ||
1357 | BT_DBG("%s removing %s", hdev->name, batostr(bdaddr)); | 1413 | BT_DBG("%s removing %pMR", hdev->name, bdaddr); |
1358 | 1414 | ||
1359 | list_del(&k->list); | 1415 | list_del(&k->list); |
1360 | kfree(k); | 1416 | kfree(k); |
@@ -1401,7 +1457,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
1401 | if (!data) | 1457 | if (!data) |
1402 | return -ENOENT; | 1458 | return -ENOENT; |
1403 | 1459 | ||
1404 | BT_DBG("%s removing %s", hdev->name, batostr(bdaddr)); | 1460 | BT_DBG("%s removing %pMR", hdev->name, bdaddr); |
1405 | 1461 | ||
1406 | list_del(&data->list); | 1462 | list_del(&data->list); |
1407 | kfree(data); | 1463 | kfree(data); |
@@ -1440,7 +1496,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | |||
1440 | memcpy(data->hash, hash, sizeof(data->hash)); | 1496 | memcpy(data->hash, hash, sizeof(data->hash)); |
1441 | memcpy(data->randomizer, randomizer, sizeof(data->randomizer)); | 1497 | memcpy(data->randomizer, randomizer, sizeof(data->randomizer)); |
1442 | 1498 | ||
1443 | BT_DBG("%s for %s", hdev->name, batostr(bdaddr)); | 1499 | BT_DBG("%s for %pMR", hdev->name, bdaddr); |
1444 | 1500 | ||
1445 | return 0; | 1501 | return 0; |
1446 | } | 1502 | } |
@@ -1617,6 +1673,9 @@ int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, | |||
1617 | 1673 | ||
1618 | BT_DBG("%s", hdev->name); | 1674 | BT_DBG("%s", hdev->name); |
1619 | 1675 | ||
1676 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) | ||
1677 | return -ENOTSUPP; | ||
1678 | |||
1620 | if (work_busy(&hdev->le_scan)) | 1679 | if (work_busy(&hdev->le_scan)) |
1621 | return -EINPROGRESS; | 1680 | return -EINPROGRESS; |
1622 | 1681 | ||
@@ -1643,6 +1702,8 @@ struct hci_dev *hci_alloc_dev(void) | |||
1643 | hdev->esco_type = (ESCO_HV1); | 1702 | hdev->esco_type = (ESCO_HV1); |
1644 | hdev->link_mode = (HCI_LM_ACCEPT); | 1703 | hdev->link_mode = (HCI_LM_ACCEPT); |
1645 | hdev->io_capability = 0x03; /* No Input No Output */ | 1704 | hdev->io_capability = 0x03; /* No Input No Output */ |
1705 | hdev->inq_tx_power = HCI_TX_POWER_INVALID; | ||
1706 | hdev->adv_tx_power = HCI_TX_POWER_INVALID; | ||
1646 | 1707 | ||
1647 | hdev->sniff_max_interval = 800; | 1708 | hdev->sniff_max_interval = 800; |
1648 | hdev->sniff_min_interval = 80; | 1709 | hdev->sniff_min_interval = 80; |
@@ -1754,11 +1815,11 @@ int hci_register_dev(struct hci_dev *hdev) | |||
1754 | if (hdev->dev_type != HCI_AMP) | 1815 | if (hdev->dev_type != HCI_AMP) |
1755 | set_bit(HCI_AUTO_OFF, &hdev->dev_flags); | 1816 | set_bit(HCI_AUTO_OFF, &hdev->dev_flags); |
1756 | 1817 | ||
1757 | schedule_work(&hdev->power_on); | ||
1758 | |||
1759 | hci_notify(hdev, HCI_DEV_REG); | 1818 | hci_notify(hdev, HCI_DEV_REG); |
1760 | hci_dev_hold(hdev); | 1819 | hci_dev_hold(hdev); |
1761 | 1820 | ||
1821 | schedule_work(&hdev->power_on); | ||
1822 | |||
1762 | return id; | 1823 | return id; |
1763 | 1824 | ||
1764 | err_wqueue: | 1825 | err_wqueue: |
@@ -2153,9 +2214,10 @@ static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags) | |||
2153 | hdr->dlen = cpu_to_le16(len); | 2214 | hdr->dlen = cpu_to_le16(len); |
2154 | } | 2215 | } |
2155 | 2216 | ||
2156 | static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, | 2217 | static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue, |
2157 | struct sk_buff *skb, __u16 flags) | 2218 | struct sk_buff *skb, __u16 flags) |
2158 | { | 2219 | { |
2220 | struct hci_conn *conn = chan->conn; | ||
2159 | struct hci_dev *hdev = conn->hdev; | 2221 | struct hci_dev *hdev = conn->hdev; |
2160 | struct sk_buff *list; | 2222 | struct sk_buff *list; |
2161 | 2223 | ||
@@ -2163,7 +2225,18 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, | |||
2163 | skb->data_len = 0; | 2225 | skb->data_len = 0; |
2164 | 2226 | ||
2165 | bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; | 2227 | bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; |
2166 | hci_add_acl_hdr(skb, conn->handle, flags); | 2228 | |
2229 | switch (hdev->dev_type) { | ||
2230 | case HCI_BREDR: | ||
2231 | hci_add_acl_hdr(skb, conn->handle, flags); | ||
2232 | break; | ||
2233 | case HCI_AMP: | ||
2234 | hci_add_acl_hdr(skb, chan->handle, flags); | ||
2235 | break; | ||
2236 | default: | ||
2237 | BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type); | ||
2238 | return; | ||
2239 | } | ||
2167 | 2240 | ||
2168 | list = skb_shinfo(skb)->frag_list; | 2241 | list = skb_shinfo(skb)->frag_list; |
2169 | if (!list) { | 2242 | if (!list) { |
@@ -2202,14 +2275,13 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, | |||
2202 | 2275 | ||
2203 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags) | 2276 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags) |
2204 | { | 2277 | { |
2205 | struct hci_conn *conn = chan->conn; | 2278 | struct hci_dev *hdev = chan->conn->hdev; |
2206 | struct hci_dev *hdev = conn->hdev; | ||
2207 | 2279 | ||
2208 | BT_DBG("%s chan %p flags 0x%4.4x", hdev->name, chan, flags); | 2280 | BT_DBG("%s chan %p flags 0x%4.4x", hdev->name, chan, flags); |
2209 | 2281 | ||
2210 | skb->dev = (void *) hdev; | 2282 | skb->dev = (void *) hdev; |
2211 | 2283 | ||
2212 | hci_queue_acl(conn, &chan->data_q, skb, flags); | 2284 | hci_queue_acl(chan, &chan->data_q, skb, flags); |
2213 | 2285 | ||
2214 | queue_work(hdev->workqueue, &hdev->tx_work); | 2286 | queue_work(hdev->workqueue, &hdev->tx_work); |
2215 | } | 2287 | } |
@@ -2311,8 +2383,8 @@ static void hci_link_tx_to(struct hci_dev *hdev, __u8 type) | |||
2311 | /* Kill stalled connections */ | 2383 | /* Kill stalled connections */ |
2312 | list_for_each_entry_rcu(c, &h->list, list) { | 2384 | list_for_each_entry_rcu(c, &h->list, list) { |
2313 | if (c->type == type && c->sent) { | 2385 | if (c->type == type && c->sent) { |
2314 | BT_ERR("%s killing stalled connection %s", | 2386 | BT_ERR("%s killing stalled connection %pMR", |
2315 | hdev->name, batostr(&c->dst)); | 2387 | hdev->name, &c->dst); |
2316 | hci_acl_disconn(c, HCI_ERROR_REMOTE_USER_TERM); | 2388 | hci_acl_disconn(c, HCI_ERROR_REMOTE_USER_TERM); |
2317 | } | 2389 | } |
2318 | } | 2390 | } |
@@ -2381,6 +2453,9 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, | |||
2381 | case ACL_LINK: | 2453 | case ACL_LINK: |
2382 | cnt = hdev->acl_cnt; | 2454 | cnt = hdev->acl_cnt; |
2383 | break; | 2455 | break; |
2456 | case AMP_LINK: | ||
2457 | cnt = hdev->block_cnt; | ||
2458 | break; | ||
2384 | case SCO_LINK: | 2459 | case SCO_LINK: |
2385 | case ESCO_LINK: | 2460 | case ESCO_LINK: |
2386 | cnt = hdev->sco_cnt; | 2461 | cnt = hdev->sco_cnt; |
@@ -2510,11 +2585,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev) | |||
2510 | struct hci_chan *chan; | 2585 | struct hci_chan *chan; |
2511 | struct sk_buff *skb; | 2586 | struct sk_buff *skb; |
2512 | int quote; | 2587 | int quote; |
2588 | u8 type; | ||
2513 | 2589 | ||
2514 | __check_timeout(hdev, cnt); | 2590 | __check_timeout(hdev, cnt); |
2515 | 2591 | ||
2592 | BT_DBG("%s", hdev->name); | ||
2593 | |||
2594 | if (hdev->dev_type == HCI_AMP) | ||
2595 | type = AMP_LINK; | ||
2596 | else | ||
2597 | type = ACL_LINK; | ||
2598 | |||
2516 | while (hdev->block_cnt > 0 && | 2599 | while (hdev->block_cnt > 0 && |
2517 | (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { | 2600 | (chan = hci_chan_sent(hdev, type, "e))) { |
2518 | u32 priority = (skb_peek(&chan->data_q))->priority; | 2601 | u32 priority = (skb_peek(&chan->data_q))->priority; |
2519 | while (quote > 0 && (skb = skb_peek(&chan->data_q))) { | 2602 | while (quote > 0 && (skb = skb_peek(&chan->data_q))) { |
2520 | int blocks; | 2603 | int blocks; |
@@ -2547,14 +2630,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev) | |||
2547 | } | 2630 | } |
2548 | 2631 | ||
2549 | if (cnt != hdev->block_cnt) | 2632 | if (cnt != hdev->block_cnt) |
2550 | hci_prio_recalculate(hdev, ACL_LINK); | 2633 | hci_prio_recalculate(hdev, type); |
2551 | } | 2634 | } |
2552 | 2635 | ||
2553 | static void hci_sched_acl(struct hci_dev *hdev) | 2636 | static void hci_sched_acl(struct hci_dev *hdev) |
2554 | { | 2637 | { |
2555 | BT_DBG("%s", hdev->name); | 2638 | BT_DBG("%s", hdev->name); |
2556 | 2639 | ||
2557 | if (!hci_conn_num(hdev, ACL_LINK)) | 2640 | /* No ACL link over BR/EDR controller */ |
2641 | if (!hci_conn_num(hdev, ACL_LINK) && hdev->dev_type == HCI_BREDR) | ||
2642 | return; | ||
2643 | |||
2644 | /* No AMP link over AMP controller */ | ||
2645 | if (!hci_conn_num(hdev, AMP_LINK) && hdev->dev_type == HCI_AMP) | ||
2558 | return; | 2646 | return; |
2559 | 2647 | ||
2560 | switch (hdev->flow_ctl_mode) { | 2648 | switch (hdev->flow_ctl_mode) { |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2022b43c7353..9f5c5f244502 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -24,12 +24,13 @@ | |||
24 | 24 | ||
25 | /* Bluetooth HCI event handling. */ | 25 | /* Bluetooth HCI event handling. */ |
26 | 26 | ||
27 | #include <linux/export.h> | ||
28 | #include <asm/unaligned.h> | 27 | #include <asm/unaligned.h> |
29 | 28 | ||
30 | #include <net/bluetooth/bluetooth.h> | 29 | #include <net/bluetooth/bluetooth.h> |
31 | #include <net/bluetooth/hci_core.h> | 30 | #include <net/bluetooth/hci_core.h> |
32 | #include <net/bluetooth/mgmt.h> | 31 | #include <net/bluetooth/mgmt.h> |
32 | #include <net/bluetooth/a2mp.h> | ||
33 | #include <net/bluetooth/amp.h> | ||
33 | 34 | ||
34 | /* Handle HCI Event packets */ | 35 | /* Handle HCI Event packets */ |
35 | 36 | ||
@@ -201,6 +202,11 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) | |||
201 | BIT(HCI_PERIODIC_INQ)); | 202 | BIT(HCI_PERIODIC_INQ)); |
202 | 203 | ||
203 | hdev->discovery.state = DISCOVERY_STOPPED; | 204 | hdev->discovery.state = DISCOVERY_STOPPED; |
205 | hdev->inq_tx_power = HCI_TX_POWER_INVALID; | ||
206 | hdev->adv_tx_power = HCI_TX_POWER_INVALID; | ||
207 | |||
208 | memset(hdev->adv_data, 0, sizeof(hdev->adv_data)); | ||
209 | hdev->adv_data_len = 0; | ||
204 | } | 210 | } |
205 | 211 | ||
206 | static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) | 212 | static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) |
@@ -223,6 +229,9 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb) | |||
223 | 229 | ||
224 | hci_dev_unlock(hdev); | 230 | hci_dev_unlock(hdev); |
225 | 231 | ||
232 | if (!status && !test_bit(HCI_INIT, &hdev->flags)) | ||
233 | hci_update_ad(hdev); | ||
234 | |||
226 | hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status); | 235 | hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status); |
227 | } | 236 | } |
228 | 237 | ||
@@ -438,7 +447,7 @@ static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb) | |||
438 | static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | 447 | static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) |
439 | { | 448 | { |
440 | __u8 status = *((__u8 *) skb->data); | 449 | __u8 status = *((__u8 *) skb->data); |
441 | void *sent; | 450 | struct hci_cp_write_ssp_mode *sent; |
442 | 451 | ||
443 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | 452 | BT_DBG("%s status 0x%2.2x", hdev->name, status); |
444 | 453 | ||
@@ -446,10 +455,17 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | |||
446 | if (!sent) | 455 | if (!sent) |
447 | return; | 456 | return; |
448 | 457 | ||
458 | if (!status) { | ||
459 | if (sent->mode) | ||
460 | hdev->host_features[0] |= LMP_HOST_SSP; | ||
461 | else | ||
462 | hdev->host_features[0] &= ~LMP_HOST_SSP; | ||
463 | } | ||
464 | |||
449 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) | 465 | if (test_bit(HCI_MGMT, &hdev->dev_flags)) |
450 | mgmt_ssp_enable_complete(hdev, *((u8 *) sent), status); | 466 | mgmt_ssp_enable_complete(hdev, sent->mode, status); |
451 | else if (!status) { | 467 | else if (!status) { |
452 | if (*((u8 *) sent)) | 468 | if (sent->mode) |
453 | set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); | 469 | set_bit(HCI_SSP_ENABLED, &hdev->dev_flags); |
454 | else | 470 | else |
455 | clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); | 471 | clear_bit(HCI_SSP_ENABLED, &hdev->dev_flags); |
@@ -458,10 +474,10 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb) | |||
458 | 474 | ||
459 | static u8 hci_get_inquiry_mode(struct hci_dev *hdev) | 475 | static u8 hci_get_inquiry_mode(struct hci_dev *hdev) |
460 | { | 476 | { |
461 | if (hdev->features[6] & LMP_EXT_INQ) | 477 | if (lmp_ext_inq_capable(hdev)) |
462 | return 2; | 478 | return 2; |
463 | 479 | ||
464 | if (hdev->features[3] & LMP_RSSI_INQ) | 480 | if (lmp_inq_rssi_capable(hdev)) |
465 | return 1; | 481 | return 1; |
466 | 482 | ||
467 | if (hdev->manufacturer == 11 && hdev->hci_rev == 0x00 && | 483 | if (hdev->manufacturer == 11 && hdev->hci_rev == 0x00 && |
@@ -505,28 +521,30 @@ static void hci_setup_event_mask(struct hci_dev *hdev) | |||
505 | if (hdev->hci_ver < BLUETOOTH_VER_1_2) | 521 | if (hdev->hci_ver < BLUETOOTH_VER_1_2) |
506 | return; | 522 | return; |
507 | 523 | ||
508 | events[4] |= 0x01; /* Flow Specification Complete */ | 524 | if (lmp_bredr_capable(hdev)) { |
509 | events[4] |= 0x02; /* Inquiry Result with RSSI */ | 525 | events[4] |= 0x01; /* Flow Specification Complete */ |
510 | events[4] |= 0x04; /* Read Remote Extended Features Complete */ | 526 | events[4] |= 0x02; /* Inquiry Result with RSSI */ |
511 | events[5] |= 0x08; /* Synchronous Connection Complete */ | 527 | events[4] |= 0x04; /* Read Remote Extended Features Complete */ |
512 | events[5] |= 0x10; /* Synchronous Connection Changed */ | 528 | events[5] |= 0x08; /* Synchronous Connection Complete */ |
529 | events[5] |= 0x10; /* Synchronous Connection Changed */ | ||
530 | } | ||
513 | 531 | ||
514 | if (hdev->features[3] & LMP_RSSI_INQ) | 532 | if (lmp_inq_rssi_capable(hdev)) |
515 | events[4] |= 0x02; /* Inquiry Result with RSSI */ | 533 | events[4] |= 0x02; /* Inquiry Result with RSSI */ |
516 | 534 | ||
517 | if (lmp_sniffsubr_capable(hdev)) | 535 | if (lmp_sniffsubr_capable(hdev)) |
518 | events[5] |= 0x20; /* Sniff Subrating */ | 536 | events[5] |= 0x20; /* Sniff Subrating */ |
519 | 537 | ||
520 | if (hdev->features[5] & LMP_PAUSE_ENC) | 538 | if (lmp_pause_enc_capable(hdev)) |
521 | events[5] |= 0x80; /* Encryption Key Refresh Complete */ | 539 | events[5] |= 0x80; /* Encryption Key Refresh Complete */ |
522 | 540 | ||
523 | if (hdev->features[6] & LMP_EXT_INQ) | 541 | if (lmp_ext_inq_capable(hdev)) |
524 | events[5] |= 0x40; /* Extended Inquiry Result */ | 542 | events[5] |= 0x40; /* Extended Inquiry Result */ |
525 | 543 | ||
526 | if (lmp_no_flush_capable(hdev)) | 544 | if (lmp_no_flush_capable(hdev)) |
527 | events[7] |= 0x01; /* Enhanced Flush Complete */ | 545 | events[7] |= 0x01; /* Enhanced Flush Complete */ |
528 | 546 | ||
529 | if (hdev->features[7] & LMP_LSTO) | 547 | if (lmp_lsto_capable(hdev)) |
530 | events[6] |= 0x80; /* Link Supervision Timeout Changed */ | 548 | events[6] |= 0x80; /* Link Supervision Timeout Changed */ |
531 | 549 | ||
532 | if (lmp_ssp_capable(hdev)) { | 550 | if (lmp_ssp_capable(hdev)) { |
@@ -546,6 +564,53 @@ static void hci_setup_event_mask(struct hci_dev *hdev) | |||
546 | events[7] |= 0x20; /* LE Meta-Event */ | 564 | events[7] |= 0x20; /* LE Meta-Event */ |
547 | 565 | ||
548 | hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events); | 566 | hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events); |
567 | |||
568 | if (lmp_le_capable(hdev)) { | ||
569 | memset(events, 0, sizeof(events)); | ||
570 | events[0] = 0x1f; | ||
571 | hci_send_cmd(hdev, HCI_OP_LE_SET_EVENT_MASK, | ||
572 | sizeof(events), events); | ||
573 | } | ||
574 | } | ||
575 | |||
576 | static void bredr_setup(struct hci_dev *hdev) | ||
577 | { | ||
578 | struct hci_cp_delete_stored_link_key cp; | ||
579 | __le16 param; | ||
580 | __u8 flt_type; | ||
581 | |||
582 | /* Read Buffer Size (ACL mtu, max pkt, etc.) */ | ||
583 | hci_send_cmd(hdev, HCI_OP_READ_BUFFER_SIZE, 0, NULL); | ||
584 | |||
585 | /* Read Class of Device */ | ||
586 | hci_send_cmd(hdev, HCI_OP_READ_CLASS_OF_DEV, 0, NULL); | ||
587 | |||
588 | /* Read Local Name */ | ||
589 | hci_send_cmd(hdev, HCI_OP_READ_LOCAL_NAME, 0, NULL); | ||
590 | |||
591 | /* Read Voice Setting */ | ||
592 | hci_send_cmd(hdev, HCI_OP_READ_VOICE_SETTING, 0, NULL); | ||
593 | |||
594 | /* Clear Event Filters */ | ||
595 | flt_type = HCI_FLT_CLEAR_ALL; | ||
596 | hci_send_cmd(hdev, HCI_OP_SET_EVENT_FLT, 1, &flt_type); | ||
597 | |||
598 | /* Connection accept timeout ~20 secs */ | ||
599 | param = __constant_cpu_to_le16(0x7d00); | ||
600 | hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, ¶m); | ||
601 | |||
602 | bacpy(&cp.bdaddr, BDADDR_ANY); | ||
603 | cp.delete_all = 1; | ||
604 | hci_send_cmd(hdev, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp); | ||
605 | } | ||
606 | |||
607 | static void le_setup(struct hci_dev *hdev) | ||
608 | { | ||
609 | /* Read LE Buffer Size */ | ||
610 | hci_send_cmd(hdev, HCI_OP_LE_READ_BUFFER_SIZE, 0, NULL); | ||
611 | |||
612 | /* Read LE Advertising Channel TX Power */ | ||
613 | hci_send_cmd(hdev, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL); | ||
549 | } | 614 | } |
550 | 615 | ||
551 | static void hci_setup(struct hci_dev *hdev) | 616 | static void hci_setup(struct hci_dev *hdev) |
@@ -553,6 +618,15 @@ static void hci_setup(struct hci_dev *hdev) | |||
553 | if (hdev->dev_type != HCI_BREDR) | 618 | if (hdev->dev_type != HCI_BREDR) |
554 | return; | 619 | return; |
555 | 620 | ||
621 | /* Read BD Address */ | ||
622 | hci_send_cmd(hdev, HCI_OP_READ_BD_ADDR, 0, NULL); | ||
623 | |||
624 | if (lmp_bredr_capable(hdev)) | ||
625 | bredr_setup(hdev); | ||
626 | |||
627 | if (lmp_le_capable(hdev)) | ||
628 | le_setup(hdev); | ||
629 | |||
556 | hci_setup_event_mask(hdev); | 630 | hci_setup_event_mask(hdev); |
557 | 631 | ||
558 | if (hdev->hci_ver > BLUETOOTH_VER_1_1) | 632 | if (hdev->hci_ver > BLUETOOTH_VER_1_1) |
@@ -573,13 +647,13 @@ static void hci_setup(struct hci_dev *hdev) | |||
573 | } | 647 | } |
574 | } | 648 | } |
575 | 649 | ||
576 | if (hdev->features[3] & LMP_RSSI_INQ) | 650 | if (lmp_inq_rssi_capable(hdev)) |
577 | hci_setup_inquiry_mode(hdev); | 651 | hci_setup_inquiry_mode(hdev); |
578 | 652 | ||
579 | if (hdev->features[7] & LMP_INQ_TX_PWR) | 653 | if (lmp_inq_tx_pwr_capable(hdev)) |
580 | hci_send_cmd(hdev, HCI_OP_READ_INQ_RSP_TX_POWER, 0, NULL); | 654 | hci_send_cmd(hdev, HCI_OP_READ_INQ_RSP_TX_POWER, 0, NULL); |
581 | 655 | ||
582 | if (hdev->features[7] & LMP_EXTFEATURES) { | 656 | if (lmp_ext_feat_capable(hdev)) { |
583 | struct hci_cp_read_local_ext_features cp; | 657 | struct hci_cp_read_local_ext_features cp; |
584 | 658 | ||
585 | cp.page = 0x01; | 659 | cp.page = 0x01; |
@@ -626,11 +700,11 @@ static void hci_setup_link_policy(struct hci_dev *hdev) | |||
626 | 700 | ||
627 | if (lmp_rswitch_capable(hdev)) | 701 | if (lmp_rswitch_capable(hdev)) |
628 | link_policy |= HCI_LP_RSWITCH; | 702 | link_policy |= HCI_LP_RSWITCH; |
629 | if (hdev->features[0] & LMP_HOLD) | 703 | if (lmp_hold_capable(hdev)) |
630 | link_policy |= HCI_LP_HOLD; | 704 | link_policy |= HCI_LP_HOLD; |
631 | if (lmp_sniff_capable(hdev)) | 705 | if (lmp_sniff_capable(hdev)) |
632 | link_policy |= HCI_LP_SNIFF; | 706 | link_policy |= HCI_LP_SNIFF; |
633 | if (hdev->features[1] & LMP_PARK) | 707 | if (lmp_park_capable(hdev)) |
634 | link_policy |= HCI_LP_PARK; | 708 | link_policy |= HCI_LP_PARK; |
635 | 709 | ||
636 | cp.policy = cpu_to_le16(link_policy); | 710 | cp.policy = cpu_to_le16(link_policy); |
@@ -720,10 +794,10 @@ static void hci_set_le_support(struct hci_dev *hdev) | |||
720 | 794 | ||
721 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { | 795 | if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) { |
722 | cp.le = 1; | 796 | cp.le = 1; |
723 | cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); | 797 | cp.simul = !!lmp_le_br_capable(hdev); |
724 | } | 798 | } |
725 | 799 | ||
726 | if (cp.le != !!(hdev->host_features[0] & LMP_HOST_LE)) | 800 | if (cp.le != !!lmp_host_le_capable(hdev)) |
727 | hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp), | 801 | hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp), |
728 | &cp); | 802 | &cp); |
729 | } | 803 | } |
@@ -846,7 +920,7 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev, | |||
846 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); | 920 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); |
847 | 921 | ||
848 | if (rp->status) | 922 | if (rp->status) |
849 | return; | 923 | goto a2mp_rsp; |
850 | 924 | ||
851 | hdev->amp_status = rp->amp_status; | 925 | hdev->amp_status = rp->amp_status; |
852 | hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); | 926 | hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); |
@@ -860,6 +934,46 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev, | |||
860 | hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); | 934 | hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); |
861 | 935 | ||
862 | hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status); | 936 | hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status); |
937 | |||
938 | a2mp_rsp: | ||
939 | a2mp_send_getinfo_rsp(hdev); | ||
940 | } | ||
941 | |||
942 | static void hci_cc_read_local_amp_assoc(struct hci_dev *hdev, | ||
943 | struct sk_buff *skb) | ||
944 | { | ||
945 | struct hci_rp_read_local_amp_assoc *rp = (void *) skb->data; | ||
946 | struct amp_assoc *assoc = &hdev->loc_assoc; | ||
947 | size_t rem_len, frag_len; | ||
948 | |||
949 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); | ||
950 | |||
951 | if (rp->status) | ||
952 | goto a2mp_rsp; | ||
953 | |||
954 | frag_len = skb->len - sizeof(*rp); | ||
955 | rem_len = __le16_to_cpu(rp->rem_len); | ||
956 | |||
957 | if (rem_len > frag_len) { | ||
958 | BT_DBG("frag_len %zu rem_len %zu", frag_len, rem_len); | ||
959 | |||
960 | memcpy(assoc->data + assoc->offset, rp->frag, frag_len); | ||
961 | assoc->offset += frag_len; | ||
962 | |||
963 | /* Read other fragments */ | ||
964 | amp_read_loc_assoc_frag(hdev, rp->phy_handle); | ||
965 | |||
966 | return; | ||
967 | } | ||
968 | |||
969 | memcpy(assoc->data + assoc->offset, rp->frag, rem_len); | ||
970 | assoc->len = assoc->offset + rem_len; | ||
971 | assoc->offset = 0; | ||
972 | |||
973 | a2mp_rsp: | ||
974 | /* Send A2MP Rsp when all fragments are received */ | ||
975 | a2mp_send_getampassoc_rsp(hdev, rp->status); | ||
976 | a2mp_send_create_phy_link_req(hdev, rp->status); | ||
863 | } | 977 | } |
864 | 978 | ||
865 | static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, | 979 | static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, |
@@ -976,6 +1090,31 @@ static void hci_cc_le_read_buffer_size(struct hci_dev *hdev, | |||
976 | hci_req_complete(hdev, HCI_OP_LE_READ_BUFFER_SIZE, rp->status); | 1090 | hci_req_complete(hdev, HCI_OP_LE_READ_BUFFER_SIZE, rp->status); |
977 | } | 1091 | } |
978 | 1092 | ||
1093 | static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev, | ||
1094 | struct sk_buff *skb) | ||
1095 | { | ||
1096 | struct hci_rp_le_read_adv_tx_power *rp = (void *) skb->data; | ||
1097 | |||
1098 | BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); | ||
1099 | |||
1100 | if (!rp->status) { | ||
1101 | hdev->adv_tx_power = rp->tx_power; | ||
1102 | if (!test_bit(HCI_INIT, &hdev->flags)) | ||
1103 | hci_update_ad(hdev); | ||
1104 | } | ||
1105 | |||
1106 | hci_req_complete(hdev, HCI_OP_LE_READ_ADV_TX_POWER, rp->status); | ||
1107 | } | ||
1108 | |||
1109 | static void hci_cc_le_set_event_mask(struct hci_dev *hdev, struct sk_buff *skb) | ||
1110 | { | ||
1111 | __u8 status = *((__u8 *) skb->data); | ||
1112 | |||
1113 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1114 | |||
1115 | hci_req_complete(hdev, HCI_OP_LE_SET_EVENT_MASK, status); | ||
1116 | } | ||
1117 | |||
979 | static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) | 1118 | static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) |
980 | { | 1119 | { |
981 | struct hci_rp_user_confirm_reply *rp = (void *) skb->data; | 1120 | struct hci_rp_user_confirm_reply *rp = (void *) skb->data; |
@@ -1051,6 +1190,33 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, | |||
1051 | hci_dev_unlock(hdev); | 1190 | hci_dev_unlock(hdev); |
1052 | } | 1191 | } |
1053 | 1192 | ||
1193 | static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb) | ||
1194 | { | ||
1195 | __u8 *sent, status = *((__u8 *) skb->data); | ||
1196 | |||
1197 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1198 | |||
1199 | sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE); | ||
1200 | if (!sent) | ||
1201 | return; | ||
1202 | |||
1203 | hci_dev_lock(hdev); | ||
1204 | |||
1205 | if (!status) { | ||
1206 | if (*sent) | ||
1207 | set_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); | ||
1208 | else | ||
1209 | clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); | ||
1210 | } | ||
1211 | |||
1212 | hci_dev_unlock(hdev); | ||
1213 | |||
1214 | if (!test_bit(HCI_INIT, &hdev->flags)) | ||
1215 | hci_update_ad(hdev); | ||
1216 | |||
1217 | hci_req_complete(hdev, HCI_OP_LE_SET_ADV_ENABLE, status); | ||
1218 | } | ||
1219 | |||
1054 | static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) | 1220 | static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb) |
1055 | { | 1221 | { |
1056 | __u8 status = *((__u8 *) skb->data); | 1222 | __u8 status = *((__u8 *) skb->data); |
@@ -1165,6 +1331,11 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev, | |||
1165 | hdev->host_features[0] |= LMP_HOST_LE; | 1331 | hdev->host_features[0] |= LMP_HOST_LE; |
1166 | else | 1332 | else |
1167 | hdev->host_features[0] &= ~LMP_HOST_LE; | 1333 | hdev->host_features[0] &= ~LMP_HOST_LE; |
1334 | |||
1335 | if (sent->simul) | ||
1336 | hdev->host_features[0] |= LMP_HOST_LE_BREDR; | ||
1337 | else | ||
1338 | hdev->host_features[0] &= ~LMP_HOST_LE_BREDR; | ||
1168 | } | 1339 | } |
1169 | 1340 | ||
1170 | if (test_bit(HCI_MGMT, &hdev->dev_flags) && | 1341 | if (test_bit(HCI_MGMT, &hdev->dev_flags) && |
@@ -1174,6 +1345,20 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev, | |||
1174 | hci_req_complete(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, status); | 1345 | hci_req_complete(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, status); |
1175 | } | 1346 | } |
1176 | 1347 | ||
1348 | static void hci_cc_write_remote_amp_assoc(struct hci_dev *hdev, | ||
1349 | struct sk_buff *skb) | ||
1350 | { | ||
1351 | struct hci_rp_write_remote_amp_assoc *rp = (void *) skb->data; | ||
1352 | |||
1353 | BT_DBG("%s status 0x%2.2x phy_handle 0x%2.2x", | ||
1354 | hdev->name, rp->status, rp->phy_handle); | ||
1355 | |||
1356 | if (rp->status) | ||
1357 | return; | ||
1358 | |||
1359 | amp_write_rem_assoc_continue(hdev, rp->phy_handle); | ||
1360 | } | ||
1361 | |||
1177 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | 1362 | static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) |
1178 | { | 1363 | { |
1179 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | 1364 | BT_DBG("%s status 0x%2.2x", hdev->name, status); |
@@ -1210,7 +1395,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) | |||
1210 | 1395 | ||
1211 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); | 1396 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); |
1212 | 1397 | ||
1213 | BT_DBG("%s bdaddr %s hcon %p", hdev->name, batostr(&cp->bdaddr), conn); | 1398 | BT_DBG("%s bdaddr %pMR hcon %p", hdev->name, &cp->bdaddr, conn); |
1214 | 1399 | ||
1215 | if (status) { | 1400 | if (status) { |
1216 | if (conn && conn->state == BT_CONNECT) { | 1401 | if (conn && conn->state == BT_CONNECT) { |
@@ -1639,8 +1824,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status) | |||
1639 | return; | 1824 | return; |
1640 | } | 1825 | } |
1641 | 1826 | ||
1642 | BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&conn->dst), | 1827 | BT_DBG("%s bdaddr %pMR conn %p", hdev->name, &conn->dst, conn); |
1643 | conn); | ||
1644 | 1828 | ||
1645 | conn->state = BT_CLOSED; | 1829 | conn->state = BT_CLOSED; |
1646 | mgmt_connect_failed(hdev, &conn->dst, conn->type, | 1830 | mgmt_connect_failed(hdev, &conn->dst, conn->type, |
@@ -1657,6 +1841,52 @@ static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status) | |||
1657 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | 1841 | BT_DBG("%s status 0x%2.2x", hdev->name, status); |
1658 | } | 1842 | } |
1659 | 1843 | ||
1844 | static void hci_cs_create_phylink(struct hci_dev *hdev, u8 status) | ||
1845 | { | ||
1846 | struct hci_cp_create_phy_link *cp; | ||
1847 | |||
1848 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1849 | |||
1850 | cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_PHY_LINK); | ||
1851 | if (!cp) | ||
1852 | return; | ||
1853 | |||
1854 | hci_dev_lock(hdev); | ||
1855 | |||
1856 | if (status) { | ||
1857 | struct hci_conn *hcon; | ||
1858 | |||
1859 | hcon = hci_conn_hash_lookup_handle(hdev, cp->phy_handle); | ||
1860 | if (hcon) | ||
1861 | hci_conn_del(hcon); | ||
1862 | } else { | ||
1863 | amp_write_remote_assoc(hdev, cp->phy_handle); | ||
1864 | } | ||
1865 | |||
1866 | hci_dev_unlock(hdev); | ||
1867 | } | ||
1868 | |||
1869 | static void hci_cs_accept_phylink(struct hci_dev *hdev, u8 status) | ||
1870 | { | ||
1871 | struct hci_cp_accept_phy_link *cp; | ||
1872 | |||
1873 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1874 | |||
1875 | if (status) | ||
1876 | return; | ||
1877 | |||
1878 | cp = hci_sent_cmd_data(hdev, HCI_OP_ACCEPT_PHY_LINK); | ||
1879 | if (!cp) | ||
1880 | return; | ||
1881 | |||
1882 | amp_write_remote_assoc(hdev, cp->phy_handle); | ||
1883 | } | ||
1884 | |||
1885 | static void hci_cs_create_logical_link(struct hci_dev *hdev, u8 status) | ||
1886 | { | ||
1887 | BT_DBG("%s status 0x%2.2x", hdev->name, status); | ||
1888 | } | ||
1889 | |||
1660 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | 1890 | static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) |
1661 | { | 1891 | { |
1662 | __u8 status = *((__u8 *) skb->data); | 1892 | __u8 status = *((__u8 *) skb->data); |
@@ -1822,7 +2052,7 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
1822 | struct hci_ev_conn_request *ev = (void *) skb->data; | 2052 | struct hci_ev_conn_request *ev = (void *) skb->data; |
1823 | int mask = hdev->link_mode; | 2053 | int mask = hdev->link_mode; |
1824 | 2054 | ||
1825 | BT_DBG("%s bdaddr %s type 0x%x", hdev->name, batostr(&ev->bdaddr), | 2055 | BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr, |
1826 | ev->link_type); | 2056 | ev->link_type); |
1827 | 2057 | ||
1828 | mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type); | 2058 | mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type); |
@@ -2314,6 +2544,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2314 | hci_cc_read_local_amp_info(hdev, skb); | 2544 | hci_cc_read_local_amp_info(hdev, skb); |
2315 | break; | 2545 | break; |
2316 | 2546 | ||
2547 | case HCI_OP_READ_LOCAL_AMP_ASSOC: | ||
2548 | hci_cc_read_local_amp_assoc(hdev, skb); | ||
2549 | break; | ||
2550 | |||
2317 | case HCI_OP_DELETE_STORED_LINK_KEY: | 2551 | case HCI_OP_DELETE_STORED_LINK_KEY: |
2318 | hci_cc_delete_stored_link_key(hdev, skb); | 2552 | hci_cc_delete_stored_link_key(hdev, skb); |
2319 | break; | 2553 | break; |
@@ -2350,6 +2584,14 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2350 | hci_cc_le_read_buffer_size(hdev, skb); | 2584 | hci_cc_le_read_buffer_size(hdev, skb); |
2351 | break; | 2585 | break; |
2352 | 2586 | ||
2587 | case HCI_OP_LE_READ_ADV_TX_POWER: | ||
2588 | hci_cc_le_read_adv_tx_power(hdev, skb); | ||
2589 | break; | ||
2590 | |||
2591 | case HCI_OP_LE_SET_EVENT_MASK: | ||
2592 | hci_cc_le_set_event_mask(hdev, skb); | ||
2593 | break; | ||
2594 | |||
2353 | case HCI_OP_USER_CONFIRM_REPLY: | 2595 | case HCI_OP_USER_CONFIRM_REPLY: |
2354 | hci_cc_user_confirm_reply(hdev, skb); | 2596 | hci_cc_user_confirm_reply(hdev, skb); |
2355 | break; | 2597 | break; |
@@ -2370,6 +2612,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2370 | hci_cc_le_set_scan_param(hdev, skb); | 2612 | hci_cc_le_set_scan_param(hdev, skb); |
2371 | break; | 2613 | break; |
2372 | 2614 | ||
2615 | case HCI_OP_LE_SET_ADV_ENABLE: | ||
2616 | hci_cc_le_set_adv_enable(hdev, skb); | ||
2617 | break; | ||
2618 | |||
2373 | case HCI_OP_LE_SET_SCAN_ENABLE: | 2619 | case HCI_OP_LE_SET_SCAN_ENABLE: |
2374 | hci_cc_le_set_scan_enable(hdev, skb); | 2620 | hci_cc_le_set_scan_enable(hdev, skb); |
2375 | break; | 2621 | break; |
@@ -2386,6 +2632,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2386 | hci_cc_write_le_host_supported(hdev, skb); | 2632 | hci_cc_write_le_host_supported(hdev, skb); |
2387 | break; | 2633 | break; |
2388 | 2634 | ||
2635 | case HCI_OP_WRITE_REMOTE_AMP_ASSOC: | ||
2636 | hci_cc_write_remote_amp_assoc(hdev, skb); | ||
2637 | break; | ||
2638 | |||
2389 | default: | 2639 | default: |
2390 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2640 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2391 | break; | 2641 | break; |
@@ -2467,6 +2717,18 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2467 | hci_cs_le_start_enc(hdev, ev->status); | 2717 | hci_cs_le_start_enc(hdev, ev->status); |
2468 | break; | 2718 | break; |
2469 | 2719 | ||
2720 | case HCI_OP_CREATE_PHY_LINK: | ||
2721 | hci_cs_create_phylink(hdev, ev->status); | ||
2722 | break; | ||
2723 | |||
2724 | case HCI_OP_ACCEPT_PHY_LINK: | ||
2725 | hci_cs_accept_phylink(hdev, ev->status); | ||
2726 | break; | ||
2727 | |||
2728 | case HCI_OP_CREATE_LOGICAL_LINK: | ||
2729 | hci_cs_create_logical_link(hdev, ev->status); | ||
2730 | break; | ||
2731 | |||
2470 | default: | 2732 | default: |
2471 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); | 2733 | BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode); |
2472 | break; | 2734 | break; |
@@ -2574,6 +2836,27 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2574 | queue_work(hdev->workqueue, &hdev->tx_work); | 2836 | queue_work(hdev->workqueue, &hdev->tx_work); |
2575 | } | 2837 | } |
2576 | 2838 | ||
2839 | static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev, | ||
2840 | __u16 handle) | ||
2841 | { | ||
2842 | struct hci_chan *chan; | ||
2843 | |||
2844 | switch (hdev->dev_type) { | ||
2845 | case HCI_BREDR: | ||
2846 | return hci_conn_hash_lookup_handle(hdev, handle); | ||
2847 | case HCI_AMP: | ||
2848 | chan = hci_chan_lookup_handle(hdev, handle); | ||
2849 | if (chan) | ||
2850 | return chan->conn; | ||
2851 | break; | ||
2852 | default: | ||
2853 | BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type); | ||
2854 | break; | ||
2855 | } | ||
2856 | |||
2857 | return NULL; | ||
2858 | } | ||
2859 | |||
2577 | static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) | 2860 | static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) |
2578 | { | 2861 | { |
2579 | struct hci_ev_num_comp_blocks *ev = (void *) skb->data; | 2862 | struct hci_ev_num_comp_blocks *ev = (void *) skb->data; |
@@ -2595,13 +2878,13 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2595 | 2878 | ||
2596 | for (i = 0; i < ev->num_hndl; i++) { | 2879 | for (i = 0; i < ev->num_hndl; i++) { |
2597 | struct hci_comp_blocks_info *info = &ev->handles[i]; | 2880 | struct hci_comp_blocks_info *info = &ev->handles[i]; |
2598 | struct hci_conn *conn; | 2881 | struct hci_conn *conn = NULL; |
2599 | __u16 handle, block_count; | 2882 | __u16 handle, block_count; |
2600 | 2883 | ||
2601 | handle = __le16_to_cpu(info->handle); | 2884 | handle = __le16_to_cpu(info->handle); |
2602 | block_count = __le16_to_cpu(info->blocks); | 2885 | block_count = __le16_to_cpu(info->blocks); |
2603 | 2886 | ||
2604 | conn = hci_conn_hash_lookup_handle(hdev, handle); | 2887 | conn = __hci_conn_lookup_handle(hdev, handle); |
2605 | if (!conn) | 2888 | if (!conn) |
2606 | continue; | 2889 | continue; |
2607 | 2890 | ||
@@ -2609,6 +2892,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2609 | 2892 | ||
2610 | switch (conn->type) { | 2893 | switch (conn->type) { |
2611 | case ACL_LINK: | 2894 | case ACL_LINK: |
2895 | case AMP_LINK: | ||
2612 | hdev->block_cnt += block_count; | 2896 | hdev->block_cnt += block_count; |
2613 | if (hdev->block_cnt > hdev->num_blocks) | 2897 | if (hdev->block_cnt > hdev->num_blocks) |
2614 | hdev->block_cnt = hdev->num_blocks; | 2898 | hdev->block_cnt = hdev->num_blocks; |
@@ -2705,13 +2989,13 @@ static void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2705 | 2989 | ||
2706 | key = hci_find_link_key(hdev, &ev->bdaddr); | 2990 | key = hci_find_link_key(hdev, &ev->bdaddr); |
2707 | if (!key) { | 2991 | if (!key) { |
2708 | BT_DBG("%s link key not found for %s", hdev->name, | 2992 | BT_DBG("%s link key not found for %pMR", hdev->name, |
2709 | batostr(&ev->bdaddr)); | 2993 | &ev->bdaddr); |
2710 | goto not_found; | 2994 | goto not_found; |
2711 | } | 2995 | } |
2712 | 2996 | ||
2713 | BT_DBG("%s found key type %u for %s", hdev->name, key->type, | 2997 | BT_DBG("%s found key type %u for %pMR", hdev->name, key->type, |
2714 | batostr(&ev->bdaddr)); | 2998 | &ev->bdaddr); |
2715 | 2999 | ||
2716 | if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) && | 3000 | if (!test_bit(HCI_DEBUG_KEYS, &hdev->dev_flags) && |
2717 | key->type == HCI_LK_DEBUG_COMBINATION) { | 3001 | key->type == HCI_LK_DEBUG_COMBINATION) { |
@@ -3419,6 +3703,130 @@ unlock: | |||
3419 | hci_dev_unlock(hdev); | 3703 | hci_dev_unlock(hdev); |
3420 | } | 3704 | } |
3421 | 3705 | ||
3706 | static void hci_phy_link_complete_evt(struct hci_dev *hdev, | ||
3707 | struct sk_buff *skb) | ||
3708 | { | ||
3709 | struct hci_ev_phy_link_complete *ev = (void *) skb->data; | ||
3710 | struct hci_conn *hcon, *bredr_hcon; | ||
3711 | |||
3712 | BT_DBG("%s handle 0x%2.2x status 0x%2.2x", hdev->name, ev->phy_handle, | ||
3713 | ev->status); | ||
3714 | |||
3715 | hci_dev_lock(hdev); | ||
3716 | |||
3717 | hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); | ||
3718 | if (!hcon) { | ||
3719 | hci_dev_unlock(hdev); | ||
3720 | return; | ||
3721 | } | ||
3722 | |||
3723 | if (ev->status) { | ||
3724 | hci_conn_del(hcon); | ||
3725 | hci_dev_unlock(hdev); | ||
3726 | return; | ||
3727 | } | ||
3728 | |||
3729 | bredr_hcon = hcon->amp_mgr->l2cap_conn->hcon; | ||
3730 | |||
3731 | hcon->state = BT_CONNECTED; | ||
3732 | bacpy(&hcon->dst, &bredr_hcon->dst); | ||
3733 | |||
3734 | hci_conn_hold(hcon); | ||
3735 | hcon->disc_timeout = HCI_DISCONN_TIMEOUT; | ||
3736 | hci_conn_put(hcon); | ||
3737 | |||
3738 | hci_conn_hold_device(hcon); | ||
3739 | hci_conn_add_sysfs(hcon); | ||
3740 | |||
3741 | amp_physical_cfm(bredr_hcon, hcon); | ||
3742 | |||
3743 | hci_dev_unlock(hdev); | ||
3744 | } | ||
3745 | |||
3746 | static void hci_loglink_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | ||
3747 | { | ||
3748 | struct hci_ev_logical_link_complete *ev = (void *) skb->data; | ||
3749 | struct hci_conn *hcon; | ||
3750 | struct hci_chan *hchan; | ||
3751 | struct amp_mgr *mgr; | ||
3752 | |||
3753 | BT_DBG("%s log_handle 0x%4.4x phy_handle 0x%2.2x status 0x%2.2x", | ||
3754 | hdev->name, le16_to_cpu(ev->handle), ev->phy_handle, | ||
3755 | ev->status); | ||
3756 | |||
3757 | hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); | ||
3758 | if (!hcon) | ||
3759 | return; | ||
3760 | |||
3761 | /* Create AMP hchan */ | ||
3762 | hchan = hci_chan_create(hcon); | ||
3763 | if (!hchan) | ||
3764 | return; | ||
3765 | |||
3766 | hchan->handle = le16_to_cpu(ev->handle); | ||
3767 | |||
3768 | BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan); | ||
3769 | |||
3770 | mgr = hcon->amp_mgr; | ||
3771 | if (mgr && mgr->bredr_chan) { | ||
3772 | struct l2cap_chan *bredr_chan = mgr->bredr_chan; | ||
3773 | |||
3774 | l2cap_chan_lock(bredr_chan); | ||
3775 | |||
3776 | bredr_chan->conn->mtu = hdev->block_mtu; | ||
3777 | l2cap_logical_cfm(bredr_chan, hchan, 0); | ||
3778 | hci_conn_hold(hcon); | ||
3779 | |||
3780 | l2cap_chan_unlock(bredr_chan); | ||
3781 | } | ||
3782 | } | ||
3783 | |||
3784 | static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev, | ||
3785 | struct sk_buff *skb) | ||
3786 | { | ||
3787 | struct hci_ev_disconn_logical_link_complete *ev = (void *) skb->data; | ||
3788 | struct hci_chan *hchan; | ||
3789 | |||
3790 | BT_DBG("%s log handle 0x%4.4x status 0x%2.2x", hdev->name, | ||
3791 | le16_to_cpu(ev->handle), ev->status); | ||
3792 | |||
3793 | if (ev->status) | ||
3794 | return; | ||
3795 | |||
3796 | hci_dev_lock(hdev); | ||
3797 | |||
3798 | hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle)); | ||
3799 | if (!hchan) | ||
3800 | goto unlock; | ||
3801 | |||
3802 | amp_destroy_logical_link(hchan, ev->reason); | ||
3803 | |||
3804 | unlock: | ||
3805 | hci_dev_unlock(hdev); | ||
3806 | } | ||
3807 | |||
3808 | static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev, | ||
3809 | struct sk_buff *skb) | ||
3810 | { | ||
3811 | struct hci_ev_disconn_phy_link_complete *ev = (void *) skb->data; | ||
3812 | struct hci_conn *hcon; | ||
3813 | |||
3814 | BT_DBG("%s status 0x%2.2x", hdev->name, ev->status); | ||
3815 | |||
3816 | if (ev->status) | ||
3817 | return; | ||
3818 | |||
3819 | hci_dev_lock(hdev); | ||
3820 | |||
3821 | hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); | ||
3822 | if (hcon) { | ||
3823 | hcon->state = BT_CLOSED; | ||
3824 | hci_conn_del(hcon); | ||
3825 | } | ||
3826 | |||
3827 | hci_dev_unlock(hdev); | ||
3828 | } | ||
3829 | |||
3422 | static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | 3830 | static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) |
3423 | { | 3831 | { |
3424 | struct hci_ev_le_conn_complete *ev = (void *) skb->data; | 3832 | struct hci_ev_le_conn_complete *ev = (void *) skb->data; |
@@ -3558,6 +3966,22 @@ static void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3558 | } | 3966 | } |
3559 | } | 3967 | } |
3560 | 3968 | ||
3969 | static void hci_chan_selected_evt(struct hci_dev *hdev, struct sk_buff *skb) | ||
3970 | { | ||
3971 | struct hci_ev_channel_selected *ev = (void *) skb->data; | ||
3972 | struct hci_conn *hcon; | ||
3973 | |||
3974 | BT_DBG("%s handle 0x%2.2x", hdev->name, ev->phy_handle); | ||
3975 | |||
3976 | skb_pull(skb, sizeof(*ev)); | ||
3977 | |||
3978 | hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle); | ||
3979 | if (!hcon) | ||
3980 | return; | ||
3981 | |||
3982 | amp_read_loc_assoc_final_data(hdev, hcon); | ||
3983 | } | ||
3984 | |||
3561 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) | 3985 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) |
3562 | { | 3986 | { |
3563 | struct hci_event_hdr *hdr = (void *) skb->data; | 3987 | struct hci_event_hdr *hdr = (void *) skb->data; |
@@ -3722,10 +4146,30 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) | |||
3722 | hci_le_meta_evt(hdev, skb); | 4146 | hci_le_meta_evt(hdev, skb); |
3723 | break; | 4147 | break; |
3724 | 4148 | ||
4149 | case HCI_EV_CHANNEL_SELECTED: | ||
4150 | hci_chan_selected_evt(hdev, skb); | ||
4151 | break; | ||
4152 | |||
3725 | case HCI_EV_REMOTE_OOB_DATA_REQUEST: | 4153 | case HCI_EV_REMOTE_OOB_DATA_REQUEST: |
3726 | hci_remote_oob_data_request_evt(hdev, skb); | 4154 | hci_remote_oob_data_request_evt(hdev, skb); |
3727 | break; | 4155 | break; |
3728 | 4156 | ||
4157 | case HCI_EV_PHY_LINK_COMPLETE: | ||
4158 | hci_phy_link_complete_evt(hdev, skb); | ||
4159 | break; | ||
4160 | |||
4161 | case HCI_EV_LOGICAL_LINK_COMPLETE: | ||
4162 | hci_loglink_complete_evt(hdev, skb); | ||
4163 | break; | ||
4164 | |||
4165 | case HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE: | ||
4166 | hci_disconn_loglink_complete_evt(hdev, skb); | ||
4167 | break; | ||
4168 | |||
4169 | case HCI_EV_DISCONN_PHY_LINK_COMPLETE: | ||
4170 | hci_disconn_phylink_complete_evt(hdev, skb); | ||
4171 | break; | ||
4172 | |||
3729 | case HCI_EV_NUM_COMP_BLOCKS: | 4173 | case HCI_EV_NUM_COMP_BLOCKS: |
3730 | hci_num_comp_blocks_evt(hdev, skb); | 4174 | hci_num_comp_blocks_evt(hdev, skb); |
3731 | break; | 4175 | break; |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index a20e61c3653d..55cceee02a84 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -38,7 +38,7 @@ static ssize_t show_link_address(struct device *dev, | |||
38 | struct device_attribute *attr, char *buf) | 38 | struct device_attribute *attr, char *buf) |
39 | { | 39 | { |
40 | struct hci_conn *conn = to_hci_conn(dev); | 40 | struct hci_conn *conn = to_hci_conn(dev); |
41 | return sprintf(buf, "%s\n", batostr(&conn->dst)); | 41 | return sprintf(buf, "%pMR\n", &conn->dst); |
42 | } | 42 | } |
43 | 43 | ||
44 | static ssize_t show_link_features(struct device *dev, | 44 | static ssize_t show_link_features(struct device *dev, |
@@ -224,7 +224,7 @@ static ssize_t show_address(struct device *dev, | |||
224 | struct device_attribute *attr, char *buf) | 224 | struct device_attribute *attr, char *buf) |
225 | { | 225 | { |
226 | struct hci_dev *hdev = to_hci_dev(dev); | 226 | struct hci_dev *hdev = to_hci_dev(dev); |
227 | return sprintf(buf, "%s\n", batostr(&hdev->bdaddr)); | 227 | return sprintf(buf, "%pMR\n", &hdev->bdaddr); |
228 | } | 228 | } |
229 | 229 | ||
230 | static ssize_t show_features(struct device *dev, | 230 | static ssize_t show_features(struct device *dev, |
@@ -406,8 +406,8 @@ static int inquiry_cache_show(struct seq_file *f, void *p) | |||
406 | 406 | ||
407 | list_for_each_entry(e, &cache->all, all) { | 407 | list_for_each_entry(e, &cache->all, all) { |
408 | struct inquiry_data *data = &e->data; | 408 | struct inquiry_data *data = &e->data; |
409 | seq_printf(f, "%s %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", | 409 | seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", |
410 | batostr(&data->bdaddr), | 410 | &data->bdaddr, |
411 | data->pscan_rep_mode, data->pscan_period_mode, | 411 | data->pscan_rep_mode, data->pscan_period_mode, |
412 | data->pscan_mode, data->dev_class[2], | 412 | data->pscan_mode, data->dev_class[2], |
413 | data->dev_class[1], data->dev_class[0], | 413 | data->dev_class[1], data->dev_class[0], |
@@ -440,7 +440,7 @@ static int blacklist_show(struct seq_file *f, void *p) | |||
440 | hci_dev_lock(hdev); | 440 | hci_dev_lock(hdev); |
441 | 441 | ||
442 | list_for_each_entry(b, &hdev->blacklist, list) | 442 | list_for_each_entry(b, &hdev->blacklist, list) |
443 | seq_printf(f, "%s\n", batostr(&b->bdaddr)); | 443 | seq_printf(f, "%pMR\n", &b->bdaddr); |
444 | 444 | ||
445 | hci_dev_unlock(hdev); | 445 | hci_dev_unlock(hdev); |
446 | 446 | ||
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index ccd985da6518..0c0028463fa3 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -932,8 +932,12 @@ static int hidp_setup_hid(struct hidp_session *session, | |||
932 | hid->country = req->country; | 932 | hid->country = req->country; |
933 | 933 | ||
934 | strncpy(hid->name, req->name, 128); | 934 | strncpy(hid->name, req->name, 128); |
935 | strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64); | 935 | |
936 | strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64); | 936 | snprintf(hid->phys, sizeof(hid->phys), "%pMR", |
937 | &bt_sk(session->ctrl_sock->sk)->src); | ||
938 | |||
939 | snprintf(hid->uniq, sizeof(hid->uniq), "%pMR", | ||
940 | &bt_sk(session->ctrl_sock->sk)->dst); | ||
937 | 941 | ||
938 | hid->dev.parent = &session->conn->dev; | 942 | hid->dev.parent = &session->conn->dev; |
939 | hid->ll_driver = &hidp_hid_driver; | 943 | hid->ll_driver = &hidp_hid_driver; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a91239dcda41..b52f66d22437 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <net/bluetooth/l2cap.h> | 38 | #include <net/bluetooth/l2cap.h> |
39 | #include <net/bluetooth/smp.h> | 39 | #include <net/bluetooth/smp.h> |
40 | #include <net/bluetooth/a2mp.h> | 40 | #include <net/bluetooth/a2mp.h> |
41 | #include <net/bluetooth/amp.h> | ||
41 | 42 | ||
42 | bool disable_ertm; | 43 | bool disable_ertm; |
43 | 44 | ||
@@ -48,19 +49,20 @@ static LIST_HEAD(chan_list); | |||
48 | static DEFINE_RWLOCK(chan_list_lock); | 49 | static DEFINE_RWLOCK(chan_list_lock); |
49 | 50 | ||
50 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, | 51 | static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, |
51 | u8 code, u8 ident, u16 dlen, void *data); | 52 | u8 code, u8 ident, u16 dlen, void *data); |
52 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, | 53 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, |
53 | void *data); | 54 | void *data); |
54 | static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); | 55 | static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data); |
55 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, | 56 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, |
56 | struct l2cap_chan *chan, int err); | 57 | struct l2cap_chan *chan, int err); |
57 | 58 | ||
58 | static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, | 59 | static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control, |
59 | struct sk_buff_head *skbs, u8 event); | 60 | struct sk_buff_head *skbs, u8 event); |
60 | 61 | ||
61 | /* ---- L2CAP channels ---- */ | 62 | /* ---- L2CAP channels ---- */ |
62 | 63 | ||
63 | static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) | 64 | static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, |
65 | u16 cid) | ||
64 | { | 66 | { |
65 | struct l2cap_chan *c; | 67 | struct l2cap_chan *c; |
66 | 68 | ||
@@ -71,7 +73,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 | |||
71 | return NULL; | 73 | return NULL; |
72 | } | 74 | } |
73 | 75 | ||
74 | static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) | 76 | static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, |
77 | u16 cid) | ||
75 | { | 78 | { |
76 | struct l2cap_chan *c; | 79 | struct l2cap_chan *c; |
77 | 80 | ||
@@ -84,7 +87,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 | |||
84 | 87 | ||
85 | /* Find channel with given SCID. | 88 | /* Find channel with given SCID. |
86 | * Returns locked channel. */ | 89 | * Returns locked channel. */ |
87 | static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) | 90 | static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, |
91 | u16 cid) | ||
88 | { | 92 | { |
89 | struct l2cap_chan *c; | 93 | struct l2cap_chan *c; |
90 | 94 | ||
@@ -97,7 +101,25 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci | |||
97 | return c; | 101 | return c; |
98 | } | 102 | } |
99 | 103 | ||
100 | static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident) | 104 | /* Find channel with given DCID. |
105 | * Returns locked channel. | ||
106 | */ | ||
107 | static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn, | ||
108 | u16 cid) | ||
109 | { | ||
110 | struct l2cap_chan *c; | ||
111 | |||
112 | mutex_lock(&conn->chan_lock); | ||
113 | c = __l2cap_get_chan_by_dcid(conn, cid); | ||
114 | if (c) | ||
115 | l2cap_chan_lock(c); | ||
116 | mutex_unlock(&conn->chan_lock); | ||
117 | |||
118 | return c; | ||
119 | } | ||
120 | |||
121 | static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, | ||
122 | u8 ident) | ||
101 | { | 123 | { |
102 | struct l2cap_chan *c; | 124 | struct l2cap_chan *c; |
103 | 125 | ||
@@ -108,6 +130,20 @@ static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 | |||
108 | return NULL; | 130 | return NULL; |
109 | } | 131 | } |
110 | 132 | ||
133 | static struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn, | ||
134 | u8 ident) | ||
135 | { | ||
136 | struct l2cap_chan *c; | ||
137 | |||
138 | mutex_lock(&conn->chan_lock); | ||
139 | c = __l2cap_get_chan_by_ident(conn, ident); | ||
140 | if (c) | ||
141 | l2cap_chan_lock(c); | ||
142 | mutex_unlock(&conn->chan_lock); | ||
143 | |||
144 | return c; | ||
145 | } | ||
146 | |||
111 | static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src) | 147 | static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src) |
112 | { | 148 | { |
113 | struct l2cap_chan *c; | 149 | struct l2cap_chan *c; |
@@ -178,7 +214,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn) | |||
178 | static void __l2cap_state_change(struct l2cap_chan *chan, int state) | 214 | static void __l2cap_state_change(struct l2cap_chan *chan, int state) |
179 | { | 215 | { |
180 | BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), | 216 | BT_DBG("chan %p %s -> %s", chan, state_to_string(chan->state), |
181 | state_to_string(state)); | 217 | state_to_string(state)); |
182 | 218 | ||
183 | chan->state = state; | 219 | chan->state = state; |
184 | chan->ops->state_change(chan, state); | 220 | chan->ops->state_change(chan, state); |
@@ -361,7 +397,7 @@ static void l2cap_seq_list_append(struct l2cap_seq_list *seq_list, u16 seq) | |||
361 | static void l2cap_chan_timeout(struct work_struct *work) | 397 | static void l2cap_chan_timeout(struct work_struct *work) |
362 | { | 398 | { |
363 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, | 399 | struct l2cap_chan *chan = container_of(work, struct l2cap_chan, |
364 | chan_timer.work); | 400 | chan_timer.work); |
365 | struct l2cap_conn *conn = chan->conn; | 401 | struct l2cap_conn *conn = chan->conn; |
366 | int reason; | 402 | int reason; |
367 | 403 | ||
@@ -373,7 +409,7 @@ static void l2cap_chan_timeout(struct work_struct *work) | |||
373 | if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) | 409 | if (chan->state == BT_CONNECTED || chan->state == BT_CONFIG) |
374 | reason = ECONNREFUSED; | 410 | reason = ECONNREFUSED; |
375 | else if (chan->state == BT_CONNECT && | 411 | else if (chan->state == BT_CONNECT && |
376 | chan->sec_level != BT_SECURITY_SDP) | 412 | chan->sec_level != BT_SECURITY_SDP) |
377 | reason = ECONNREFUSED; | 413 | reason = ECONNREFUSED; |
378 | else | 414 | else |
379 | reason = ETIMEDOUT; | 415 | reason = ETIMEDOUT; |
@@ -455,7 +491,7 @@ void l2cap_chan_set_defaults(struct l2cap_chan *chan) | |||
455 | set_bit(FLAG_FORCE_ACTIVE, &chan->flags); | 491 | set_bit(FLAG_FORCE_ACTIVE, &chan->flags); |
456 | } | 492 | } |
457 | 493 | ||
458 | static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | 494 | void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) |
459 | { | 495 | { |
460 | BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, | 496 | BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, |
461 | __le16_to_cpu(chan->psm), chan->dcid); | 497 | __le16_to_cpu(chan->psm), chan->dcid); |
@@ -504,7 +540,7 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) | |||
504 | chan->local_msdu = L2CAP_DEFAULT_MAX_SDU_SIZE; | 540 | chan->local_msdu = L2CAP_DEFAULT_MAX_SDU_SIZE; |
505 | chan->local_sdu_itime = L2CAP_DEFAULT_SDU_ITIME; | 541 | chan->local_sdu_itime = L2CAP_DEFAULT_SDU_ITIME; |
506 | chan->local_acc_lat = L2CAP_DEFAULT_ACC_LAT; | 542 | chan->local_acc_lat = L2CAP_DEFAULT_ACC_LAT; |
507 | chan->local_flush_to = L2CAP_DEFAULT_FLUSH_TO; | 543 | chan->local_flush_to = L2CAP_EFS_DEFAULT_FLUSH_TO; |
508 | 544 | ||
509 | l2cap_chan_hold(chan); | 545 | l2cap_chan_hold(chan); |
510 | 546 | ||
@@ -527,6 +563,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
527 | BT_DBG("chan %p, conn %p, err %d", chan, conn, err); | 563 | BT_DBG("chan %p, conn %p, err %d", chan, conn, err); |
528 | 564 | ||
529 | if (conn) { | 565 | if (conn) { |
566 | struct amp_mgr *mgr = conn->hcon->amp_mgr; | ||
530 | /* Delete from channel list */ | 567 | /* Delete from channel list */ |
531 | list_del(&chan->list); | 568 | list_del(&chan->list); |
532 | 569 | ||
@@ -536,10 +573,19 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
536 | 573 | ||
537 | if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP) | 574 | if (chan->chan_type != L2CAP_CHAN_CONN_FIX_A2MP) |
538 | hci_conn_put(conn->hcon); | 575 | hci_conn_put(conn->hcon); |
576 | |||
577 | if (mgr && mgr->bredr_chan == chan) | ||
578 | mgr->bredr_chan = NULL; | ||
579 | } | ||
580 | |||
581 | if (chan->hs_hchan) { | ||
582 | struct hci_chan *hs_hchan = chan->hs_hchan; | ||
583 | |||
584 | BT_DBG("chan %p disconnect hs_hchan %p", chan, hs_hchan); | ||
585 | amp_disconnect_logical_link(hs_hchan); | ||
539 | } | 586 | } |
540 | 587 | ||
541 | if (chan->ops->teardown) | 588 | chan->ops->teardown(chan, err); |
542 | chan->ops->teardown(chan, err); | ||
543 | 589 | ||
544 | if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state)) | 590 | if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state)) |
545 | return; | 591 | return; |
@@ -573,19 +619,18 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
573 | struct l2cap_conn *conn = chan->conn; | 619 | struct l2cap_conn *conn = chan->conn; |
574 | struct sock *sk = chan->sk; | 620 | struct sock *sk = chan->sk; |
575 | 621 | ||
576 | BT_DBG("chan %p state %s sk %p", chan, | 622 | BT_DBG("chan %p state %s sk %p", chan, state_to_string(chan->state), |
577 | state_to_string(chan->state), sk); | 623 | sk); |
578 | 624 | ||
579 | switch (chan->state) { | 625 | switch (chan->state) { |
580 | case BT_LISTEN: | 626 | case BT_LISTEN: |
581 | if (chan->ops->teardown) | 627 | chan->ops->teardown(chan, 0); |
582 | chan->ops->teardown(chan, 0); | ||
583 | break; | 628 | break; |
584 | 629 | ||
585 | case BT_CONNECTED: | 630 | case BT_CONNECTED: |
586 | case BT_CONFIG: | 631 | case BT_CONFIG: |
587 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 632 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && |
588 | conn->hcon->type == ACL_LINK) { | 633 | conn->hcon->type == ACL_LINK) { |
589 | __set_chan_timer(chan, sk->sk_sndtimeo); | 634 | __set_chan_timer(chan, sk->sk_sndtimeo); |
590 | l2cap_send_disconn_req(conn, chan, reason); | 635 | l2cap_send_disconn_req(conn, chan, reason); |
591 | } else | 636 | } else |
@@ -594,7 +639,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
594 | 639 | ||
595 | case BT_CONNECT2: | 640 | case BT_CONNECT2: |
596 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && | 641 | if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED && |
597 | conn->hcon->type == ACL_LINK) { | 642 | conn->hcon->type == ACL_LINK) { |
598 | struct l2cap_conn_rsp rsp; | 643 | struct l2cap_conn_rsp rsp; |
599 | __u16 result; | 644 | __u16 result; |
600 | 645 | ||
@@ -609,7 +654,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
609 | rsp.result = cpu_to_le16(result); | 654 | rsp.result = cpu_to_le16(result); |
610 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | 655 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); |
611 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 656 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
612 | sizeof(rsp), &rsp); | 657 | sizeof(rsp), &rsp); |
613 | } | 658 | } |
614 | 659 | ||
615 | l2cap_chan_del(chan, reason); | 660 | l2cap_chan_del(chan, reason); |
@@ -621,8 +666,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) | |||
621 | break; | 666 | break; |
622 | 667 | ||
623 | default: | 668 | default: |
624 | if (chan->ops->teardown) | 669 | chan->ops->teardown(chan, 0); |
625 | chan->ops->teardown(chan, 0); | ||
626 | break; | 670 | break; |
627 | } | 671 | } |
628 | } | 672 | } |
@@ -691,7 +735,8 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn) | |||
691 | return id; | 735 | return id; |
692 | } | 736 | } |
693 | 737 | ||
694 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data) | 738 | static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, |
739 | void *data) | ||
695 | { | 740 | { |
696 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); | 741 | struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data); |
697 | u8 flags; | 742 | u8 flags; |
@@ -712,16 +757,31 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, | |||
712 | hci_send_acl(conn->hchan, skb, flags); | 757 | hci_send_acl(conn->hchan, skb, flags); |
713 | } | 758 | } |
714 | 759 | ||
760 | static bool __chan_is_moving(struct l2cap_chan *chan) | ||
761 | { | ||
762 | return chan->move_state != L2CAP_MOVE_STABLE && | ||
763 | chan->move_state != L2CAP_MOVE_WAIT_PREPARE; | ||
764 | } | ||
765 | |||
715 | static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) | 766 | static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) |
716 | { | 767 | { |
717 | struct hci_conn *hcon = chan->conn->hcon; | 768 | struct hci_conn *hcon = chan->conn->hcon; |
718 | u16 flags; | 769 | u16 flags; |
719 | 770 | ||
720 | BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, | 771 | BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, |
721 | skb->priority); | 772 | skb->priority); |
773 | |||
774 | if (chan->hs_hcon && !__chan_is_moving(chan)) { | ||
775 | if (chan->hs_hchan) | ||
776 | hci_send_acl(chan->hs_hchan, skb, ACL_COMPLETE); | ||
777 | else | ||
778 | kfree_skb(skb); | ||
779 | |||
780 | return; | ||
781 | } | ||
722 | 782 | ||
723 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && | 783 | if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && |
724 | lmp_no_flush_capable(hcon->hdev)) | 784 | lmp_no_flush_capable(hcon->hdev)) |
725 | flags = ACL_START_NO_FLUSH; | 785 | flags = ACL_START_NO_FLUSH; |
726 | else | 786 | else |
727 | flags = ACL_START; | 787 | flags = ACL_START; |
@@ -895,6 +955,9 @@ static void l2cap_send_sframe(struct l2cap_chan *chan, | |||
895 | if (!control->sframe) | 955 | if (!control->sframe) |
896 | return; | 956 | return; |
897 | 957 | ||
958 | if (__chan_is_moving(chan)) | ||
959 | return; | ||
960 | |||
898 | if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state) && | 961 | if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state) && |
899 | !control->poll) | 962 | !control->poll) |
900 | control->final = 1; | 963 | control->final = 1; |
@@ -946,7 +1009,25 @@ static inline int __l2cap_no_conn_pending(struct l2cap_chan *chan) | |||
946 | return !test_bit(CONF_CONNECT_PEND, &chan->conf_state); | 1009 | return !test_bit(CONF_CONNECT_PEND, &chan->conf_state); |
947 | } | 1010 | } |
948 | 1011 | ||
949 | static void l2cap_send_conn_req(struct l2cap_chan *chan) | 1012 | static bool __amp_capable(struct l2cap_chan *chan) |
1013 | { | ||
1014 | struct l2cap_conn *conn = chan->conn; | ||
1015 | |||
1016 | if (enable_hs && | ||
1017 | chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED && | ||
1018 | conn->fixed_chan_mask & L2CAP_FC_A2MP) | ||
1019 | return true; | ||
1020 | else | ||
1021 | return false; | ||
1022 | } | ||
1023 | |||
1024 | static bool l2cap_check_efs(struct l2cap_chan *chan) | ||
1025 | { | ||
1026 | /* Check EFS parameters */ | ||
1027 | return true; | ||
1028 | } | ||
1029 | |||
1030 | void l2cap_send_conn_req(struct l2cap_chan *chan) | ||
950 | { | 1031 | { |
951 | struct l2cap_conn *conn = chan->conn; | 1032 | struct l2cap_conn *conn = chan->conn; |
952 | struct l2cap_conn_req req; | 1033 | struct l2cap_conn_req req; |
@@ -961,6 +1042,76 @@ static void l2cap_send_conn_req(struct l2cap_chan *chan) | |||
961 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); | 1042 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req); |
962 | } | 1043 | } |
963 | 1044 | ||
1045 | static void l2cap_send_create_chan_req(struct l2cap_chan *chan, u8 amp_id) | ||
1046 | { | ||
1047 | struct l2cap_create_chan_req req; | ||
1048 | req.scid = cpu_to_le16(chan->scid); | ||
1049 | req.psm = chan->psm; | ||
1050 | req.amp_id = amp_id; | ||
1051 | |||
1052 | chan->ident = l2cap_get_ident(chan->conn); | ||
1053 | |||
1054 | l2cap_send_cmd(chan->conn, chan->ident, L2CAP_CREATE_CHAN_REQ, | ||
1055 | sizeof(req), &req); | ||
1056 | } | ||
1057 | |||
1058 | static void l2cap_move_setup(struct l2cap_chan *chan) | ||
1059 | { | ||
1060 | struct sk_buff *skb; | ||
1061 | |||
1062 | BT_DBG("chan %p", chan); | ||
1063 | |||
1064 | if (chan->mode != L2CAP_MODE_ERTM) | ||
1065 | return; | ||
1066 | |||
1067 | __clear_retrans_timer(chan); | ||
1068 | __clear_monitor_timer(chan); | ||
1069 | __clear_ack_timer(chan); | ||
1070 | |||
1071 | chan->retry_count = 0; | ||
1072 | skb_queue_walk(&chan->tx_q, skb) { | ||
1073 | if (bt_cb(skb)->control.retries) | ||
1074 | bt_cb(skb)->control.retries = 1; | ||
1075 | else | ||
1076 | break; | ||
1077 | } | ||
1078 | |||
1079 | chan->expected_tx_seq = chan->buffer_seq; | ||
1080 | |||
1081 | clear_bit(CONN_REJ_ACT, &chan->conn_state); | ||
1082 | clear_bit(CONN_SREJ_ACT, &chan->conn_state); | ||
1083 | l2cap_seq_list_clear(&chan->retrans_list); | ||
1084 | l2cap_seq_list_clear(&chan->srej_list); | ||
1085 | skb_queue_purge(&chan->srej_q); | ||
1086 | |||
1087 | chan->tx_state = L2CAP_TX_STATE_XMIT; | ||
1088 | chan->rx_state = L2CAP_RX_STATE_MOVE; | ||
1089 | |||
1090 | set_bit(CONN_REMOTE_BUSY, &chan->conn_state); | ||
1091 | } | ||
1092 | |||
1093 | static void l2cap_move_done(struct l2cap_chan *chan) | ||
1094 | { | ||
1095 | u8 move_role = chan->move_role; | ||
1096 | BT_DBG("chan %p", chan); | ||
1097 | |||
1098 | chan->move_state = L2CAP_MOVE_STABLE; | ||
1099 | chan->move_role = L2CAP_MOVE_ROLE_NONE; | ||
1100 | |||
1101 | if (chan->mode != L2CAP_MODE_ERTM) | ||
1102 | return; | ||
1103 | |||
1104 | switch (move_role) { | ||
1105 | case L2CAP_MOVE_ROLE_INITIATOR: | ||
1106 | l2cap_tx(chan, NULL, NULL, L2CAP_EV_EXPLICIT_POLL); | ||
1107 | chan->rx_state = L2CAP_RX_STATE_WAIT_F; | ||
1108 | break; | ||
1109 | case L2CAP_MOVE_ROLE_RESPONDER: | ||
1110 | chan->rx_state = L2CAP_RX_STATE_WAIT_P; | ||
1111 | break; | ||
1112 | } | ||
1113 | } | ||
1114 | |||
964 | static void l2cap_chan_ready(struct l2cap_chan *chan) | 1115 | static void l2cap_chan_ready(struct l2cap_chan *chan) |
965 | { | 1116 | { |
966 | /* This clears all conf flags, including CONF_NOT_COMPLETE */ | 1117 | /* This clears all conf flags, including CONF_NOT_COMPLETE */ |
@@ -972,6 +1123,16 @@ static void l2cap_chan_ready(struct l2cap_chan *chan) | |||
972 | chan->ops->ready(chan); | 1123 | chan->ops->ready(chan); |
973 | } | 1124 | } |
974 | 1125 | ||
1126 | static void l2cap_start_connection(struct l2cap_chan *chan) | ||
1127 | { | ||
1128 | if (__amp_capable(chan)) { | ||
1129 | BT_DBG("chan %p AMP capable: discover AMPs", chan); | ||
1130 | a2mp_discover_amp(chan); | ||
1131 | } else { | ||
1132 | l2cap_send_conn_req(chan); | ||
1133 | } | ||
1134 | } | ||
1135 | |||
975 | static void l2cap_do_start(struct l2cap_chan *chan) | 1136 | static void l2cap_do_start(struct l2cap_chan *chan) |
976 | { | 1137 | { |
977 | struct l2cap_conn *conn = chan->conn; | 1138 | struct l2cap_conn *conn = chan->conn; |
@@ -986,8 +1147,9 @@ static void l2cap_do_start(struct l2cap_chan *chan) | |||
986 | return; | 1147 | return; |
987 | 1148 | ||
988 | if (l2cap_chan_check_security(chan) && | 1149 | if (l2cap_chan_check_security(chan) && |
989 | __l2cap_no_conn_pending(chan)) | 1150 | __l2cap_no_conn_pending(chan)) { |
990 | l2cap_send_conn_req(chan); | 1151 | l2cap_start_connection(chan); |
1152 | } | ||
991 | } else { | 1153 | } else { |
992 | struct l2cap_info_req req; | 1154 | struct l2cap_info_req req; |
993 | req.type = __constant_cpu_to_le16(L2CAP_IT_FEAT_MASK); | 1155 | req.type = __constant_cpu_to_le16(L2CAP_IT_FEAT_MASK); |
@@ -997,8 +1159,8 @@ static void l2cap_do_start(struct l2cap_chan *chan) | |||
997 | 1159 | ||
998 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); | 1160 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); |
999 | 1161 | ||
1000 | l2cap_send_cmd(conn, conn->info_ident, | 1162 | l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, |
1001 | L2CAP_INFO_REQ, sizeof(req), &req); | 1163 | sizeof(req), &req); |
1002 | } | 1164 | } |
1003 | } | 1165 | } |
1004 | 1166 | ||
@@ -1018,7 +1180,8 @@ static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) | |||
1018 | } | 1180 | } |
1019 | } | 1181 | } |
1020 | 1182 | ||
1021 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err) | 1183 | static void l2cap_send_disconn_req(struct l2cap_conn *conn, |
1184 | struct l2cap_chan *chan, int err) | ||
1022 | { | 1185 | { |
1023 | struct sock *sk = chan->sk; | 1186 | struct sock *sk = chan->sk; |
1024 | struct l2cap_disconn_req req; | 1187 | struct l2cap_disconn_req req; |
@@ -1033,14 +1196,14 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *c | |||
1033 | } | 1196 | } |
1034 | 1197 | ||
1035 | if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP) { | 1198 | if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP) { |
1036 | __l2cap_state_change(chan, BT_DISCONN); | 1199 | l2cap_state_change(chan, BT_DISCONN); |
1037 | return; | 1200 | return; |
1038 | } | 1201 | } |
1039 | 1202 | ||
1040 | req.dcid = cpu_to_le16(chan->dcid); | 1203 | req.dcid = cpu_to_le16(chan->dcid); |
1041 | req.scid = cpu_to_le16(chan->scid); | 1204 | req.scid = cpu_to_le16(chan->scid); |
1042 | l2cap_send_cmd(conn, l2cap_get_ident(conn), | 1205 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_DISCONN_REQ, |
1043 | L2CAP_DISCONN_REQ, sizeof(req), &req); | 1206 | sizeof(req), &req); |
1044 | 1207 | ||
1045 | lock_sock(sk); | 1208 | lock_sock(sk); |
1046 | __l2cap_state_change(chan, BT_DISCONN); | 1209 | __l2cap_state_change(chan, BT_DISCONN); |
@@ -1069,20 +1232,20 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
1069 | 1232 | ||
1070 | if (chan->state == BT_CONNECT) { | 1233 | if (chan->state == BT_CONNECT) { |
1071 | if (!l2cap_chan_check_security(chan) || | 1234 | if (!l2cap_chan_check_security(chan) || |
1072 | !__l2cap_no_conn_pending(chan)) { | 1235 | !__l2cap_no_conn_pending(chan)) { |
1073 | l2cap_chan_unlock(chan); | 1236 | l2cap_chan_unlock(chan); |
1074 | continue; | 1237 | continue; |
1075 | } | 1238 | } |
1076 | 1239 | ||
1077 | if (!l2cap_mode_supported(chan->mode, conn->feat_mask) | 1240 | if (!l2cap_mode_supported(chan->mode, conn->feat_mask) |
1078 | && test_bit(CONF_STATE2_DEVICE, | 1241 | && test_bit(CONF_STATE2_DEVICE, |
1079 | &chan->conf_state)) { | 1242 | &chan->conf_state)) { |
1080 | l2cap_chan_close(chan, ECONNRESET); | 1243 | l2cap_chan_close(chan, ECONNRESET); |
1081 | l2cap_chan_unlock(chan); | 1244 | l2cap_chan_unlock(chan); |
1082 | continue; | 1245 | continue; |
1083 | } | 1246 | } |
1084 | 1247 | ||
1085 | l2cap_send_conn_req(chan); | 1248 | l2cap_start_connection(chan); |
1086 | 1249 | ||
1087 | } else if (chan->state == BT_CONNECT2) { | 1250 | } else if (chan->state == BT_CONNECT2) { |
1088 | struct l2cap_conn_rsp rsp; | 1251 | struct l2cap_conn_rsp rsp; |
@@ -1094,11 +1257,9 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
1094 | lock_sock(sk); | 1257 | lock_sock(sk); |
1095 | if (test_bit(BT_SK_DEFER_SETUP, | 1258 | if (test_bit(BT_SK_DEFER_SETUP, |
1096 | &bt_sk(sk)->flags)) { | 1259 | &bt_sk(sk)->flags)) { |
1097 | struct sock *parent = bt_sk(sk)->parent; | ||
1098 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND); | 1260 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND); |
1099 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_AUTHOR_PEND); | 1261 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_AUTHOR_PEND); |
1100 | if (parent) | 1262 | chan->ops->defer(chan); |
1101 | parent->sk_data_ready(parent, 0); | ||
1102 | 1263 | ||
1103 | } else { | 1264 | } else { |
1104 | __l2cap_state_change(chan, BT_CONFIG); | 1265 | __l2cap_state_change(chan, BT_CONFIG); |
@@ -1112,17 +1273,17 @@ static void l2cap_conn_start(struct l2cap_conn *conn) | |||
1112 | } | 1273 | } |
1113 | 1274 | ||
1114 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 1275 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
1115 | sizeof(rsp), &rsp); | 1276 | sizeof(rsp), &rsp); |
1116 | 1277 | ||
1117 | if (test_bit(CONF_REQ_SENT, &chan->conf_state) || | 1278 | if (test_bit(CONF_REQ_SENT, &chan->conf_state) || |
1118 | rsp.result != L2CAP_CR_SUCCESS) { | 1279 | rsp.result != L2CAP_CR_SUCCESS) { |
1119 | l2cap_chan_unlock(chan); | 1280 | l2cap_chan_unlock(chan); |
1120 | continue; | 1281 | continue; |
1121 | } | 1282 | } |
1122 | 1283 | ||
1123 | set_bit(CONF_REQ_SENT, &chan->conf_state); | 1284 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
1124 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 1285 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
1125 | l2cap_build_conf_req(chan, buf), buf); | 1286 | l2cap_build_conf_req(chan, buf), buf); |
1126 | chan->num_conf_req++; | 1287 | chan->num_conf_req++; |
1127 | } | 1288 | } |
1128 | 1289 | ||
@@ -1204,8 +1365,6 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) | |||
1204 | bacpy(&bt_sk(sk)->src, conn->src); | 1365 | bacpy(&bt_sk(sk)->src, conn->src); |
1205 | bacpy(&bt_sk(sk)->dst, conn->dst); | 1366 | bacpy(&bt_sk(sk)->dst, conn->dst); |
1206 | 1367 | ||
1207 | bt_accept_enqueue(parent, sk); | ||
1208 | |||
1209 | l2cap_chan_add(conn, chan); | 1368 | l2cap_chan_add(conn, chan); |
1210 | 1369 | ||
1211 | l2cap_chan_ready(chan); | 1370 | l2cap_chan_ready(chan); |
@@ -1270,7 +1429,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) | |||
1270 | 1429 | ||
1271 | list_for_each_entry(chan, &conn->chan_l, list) { | 1430 | list_for_each_entry(chan, &conn->chan_l, list) { |
1272 | if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) | 1431 | if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) |
1273 | __l2cap_chan_set_err(chan, err); | 1432 | l2cap_chan_set_err(chan, err); |
1274 | } | 1433 | } |
1275 | 1434 | ||
1276 | mutex_unlock(&conn->chan_lock); | 1435 | mutex_unlock(&conn->chan_lock); |
@@ -1279,7 +1438,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err) | |||
1279 | static void l2cap_info_timeout(struct work_struct *work) | 1438 | static void l2cap_info_timeout(struct work_struct *work) |
1280 | { | 1439 | { |
1281 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, | 1440 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, |
1282 | info_timer.work); | 1441 | info_timer.work); |
1283 | 1442 | ||
1284 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 1443 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
1285 | conn->info_ident = 0; | 1444 | conn->info_ident = 0; |
@@ -1333,7 +1492,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) | |||
1333 | static void security_timeout(struct work_struct *work) | 1492 | static void security_timeout(struct work_struct *work) |
1334 | { | 1493 | { |
1335 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, | 1494 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, |
1336 | security_timer.work); | 1495 | security_timer.work); |
1337 | 1496 | ||
1338 | BT_DBG("conn %p", conn); | 1497 | BT_DBG("conn %p", conn); |
1339 | 1498 | ||
@@ -1355,7 +1514,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) | |||
1355 | if (!hchan) | 1514 | if (!hchan) |
1356 | return NULL; | 1515 | return NULL; |
1357 | 1516 | ||
1358 | conn = kzalloc(sizeof(struct l2cap_conn), GFP_ATOMIC); | 1517 | conn = kzalloc(sizeof(struct l2cap_conn), GFP_KERNEL); |
1359 | if (!conn) { | 1518 | if (!conn) { |
1360 | hci_chan_del(hchan); | 1519 | hci_chan_del(hchan); |
1361 | return NULL; | 1520 | return NULL; |
@@ -1367,10 +1526,22 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) | |||
1367 | 1526 | ||
1368 | BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan); | 1527 | BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan); |
1369 | 1528 | ||
1370 | if (hcon->hdev->le_mtu && hcon->type == LE_LINK) | 1529 | switch (hcon->type) { |
1371 | conn->mtu = hcon->hdev->le_mtu; | 1530 | case AMP_LINK: |
1372 | else | 1531 | conn->mtu = hcon->hdev->block_mtu; |
1532 | break; | ||
1533 | |||
1534 | case LE_LINK: | ||
1535 | if (hcon->hdev->le_mtu) { | ||
1536 | conn->mtu = hcon->hdev->le_mtu; | ||
1537 | break; | ||
1538 | } | ||
1539 | /* fall through */ | ||
1540 | |||
1541 | default: | ||
1373 | conn->mtu = hcon->hdev->acl_mtu; | 1542 | conn->mtu = hcon->hdev->acl_mtu; |
1543 | break; | ||
1544 | } | ||
1374 | 1545 | ||
1375 | conn->src = &hcon->hdev->bdaddr; | 1546 | conn->src = &hcon->hdev->bdaddr; |
1376 | conn->dst = &hcon->dst; | 1547 | conn->dst = &hcon->dst; |
@@ -1448,7 +1619,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1448 | __u8 auth_type; | 1619 | __u8 auth_type; |
1449 | int err; | 1620 | int err; |
1450 | 1621 | ||
1451 | BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst), | 1622 | BT_DBG("%pMR -> %pMR (type %u) psm 0x%2.2x", src, dst, |
1452 | dst_type, __le16_to_cpu(psm)); | 1623 | dst_type, __le16_to_cpu(psm)); |
1453 | 1624 | ||
1454 | hdev = hci_get_route(dst, src); | 1625 | hdev = hci_get_route(dst, src); |
@@ -1461,7 +1632,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
1461 | 1632 | ||
1462 | /* PSM must be odd and lsb of upper byte must be 0 */ | 1633 | /* PSM must be odd and lsb of upper byte must be 0 */ |
1463 | if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid && | 1634 | if ((__le16_to_cpu(psm) & 0x0101) != 0x0001 && !cid && |
1464 | chan->chan_type != L2CAP_CHAN_RAW) { | 1635 | chan->chan_type != L2CAP_CHAN_RAW) { |
1465 | err = -EINVAL; | 1636 | err = -EINVAL; |
1466 | goto done; | 1637 | goto done; |
1467 | } | 1638 | } |
@@ -1657,6 +1828,9 @@ static void l2cap_streaming_send(struct l2cap_chan *chan, | |||
1657 | 1828 | ||
1658 | BT_DBG("chan %p, skbs %p", chan, skbs); | 1829 | BT_DBG("chan %p, skbs %p", chan, skbs); |
1659 | 1830 | ||
1831 | if (__chan_is_moving(chan)) | ||
1832 | return; | ||
1833 | |||
1660 | skb_queue_splice_tail_init(skbs, &chan->tx_q); | 1834 | skb_queue_splice_tail_init(skbs, &chan->tx_q); |
1661 | 1835 | ||
1662 | while (!skb_queue_empty(&chan->tx_q)) { | 1836 | while (!skb_queue_empty(&chan->tx_q)) { |
@@ -1699,6 +1873,9 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) | |||
1699 | if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state)) | 1873 | if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state)) |
1700 | return 0; | 1874 | return 0; |
1701 | 1875 | ||
1876 | if (__chan_is_moving(chan)) | ||
1877 | return 0; | ||
1878 | |||
1702 | while (chan->tx_send_head && | 1879 | while (chan->tx_send_head && |
1703 | chan->unacked_frames < chan->remote_tx_win && | 1880 | chan->unacked_frames < chan->remote_tx_win && |
1704 | chan->tx_state == L2CAP_TX_STATE_XMIT) { | 1881 | chan->tx_state == L2CAP_TX_STATE_XMIT) { |
@@ -1764,13 +1941,16 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan) | |||
1764 | if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state)) | 1941 | if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state)) |
1765 | return; | 1942 | return; |
1766 | 1943 | ||
1944 | if (__chan_is_moving(chan)) | ||
1945 | return; | ||
1946 | |||
1767 | while (chan->retrans_list.head != L2CAP_SEQ_LIST_CLEAR) { | 1947 | while (chan->retrans_list.head != L2CAP_SEQ_LIST_CLEAR) { |
1768 | seq = l2cap_seq_list_pop(&chan->retrans_list); | 1948 | seq = l2cap_seq_list_pop(&chan->retrans_list); |
1769 | 1949 | ||
1770 | skb = l2cap_ertm_seq_in_queue(&chan->tx_q, seq); | 1950 | skb = l2cap_ertm_seq_in_queue(&chan->tx_q, seq); |
1771 | if (!skb) { | 1951 | if (!skb) { |
1772 | BT_DBG("Error: Can't retransmit seq %d, frame missing", | 1952 | BT_DBG("Error: Can't retransmit seq %d, frame missing", |
1773 | seq); | 1953 | seq); |
1774 | continue; | 1954 | continue; |
1775 | } | 1955 | } |
1776 | 1956 | ||
@@ -1795,9 +1975,9 @@ static void l2cap_ertm_resend(struct l2cap_chan *chan) | |||
1795 | /* Cloned sk_buffs are read-only, so we need a | 1975 | /* Cloned sk_buffs are read-only, so we need a |
1796 | * writeable copy | 1976 | * writeable copy |
1797 | */ | 1977 | */ |
1798 | tx_skb = skb_copy(skb, GFP_ATOMIC); | 1978 | tx_skb = skb_copy(skb, GFP_KERNEL); |
1799 | } else { | 1979 | } else { |
1800 | tx_skb = skb_clone(skb, GFP_ATOMIC); | 1980 | tx_skb = skb_clone(skb, GFP_KERNEL); |
1801 | } | 1981 | } |
1802 | 1982 | ||
1803 | if (!tx_skb) { | 1983 | if (!tx_skb) { |
@@ -1855,7 +2035,7 @@ static void l2cap_retransmit_all(struct l2cap_chan *chan, | |||
1855 | if (chan->unacked_frames) { | 2035 | if (chan->unacked_frames) { |
1856 | skb_queue_walk(&chan->tx_q, skb) { | 2036 | skb_queue_walk(&chan->tx_q, skb) { |
1857 | if (bt_cb(skb)->control.txseq == control->reqseq || | 2037 | if (bt_cb(skb)->control.txseq == control->reqseq || |
1858 | skb == chan->tx_send_head) | 2038 | skb == chan->tx_send_head) |
1859 | break; | 2039 | break; |
1860 | } | 2040 | } |
1861 | 2041 | ||
@@ -2106,7 +2286,9 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan, | |||
2106 | /* PDU size is derived from the HCI MTU */ | 2286 | /* PDU size is derived from the HCI MTU */ |
2107 | pdu_len = chan->conn->mtu; | 2287 | pdu_len = chan->conn->mtu; |
2108 | 2288 | ||
2109 | pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD); | 2289 | /* Constrain PDU size for BR/EDR connections */ |
2290 | if (!chan->hs_hcon) | ||
2291 | pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD); | ||
2110 | 2292 | ||
2111 | /* Adjust for largest possible L2CAP overhead. */ | 2293 | /* Adjust for largest possible L2CAP overhead. */ |
2112 | if (chan->fcs) | 2294 | if (chan->fcs) |
@@ -2156,7 +2338,7 @@ static int l2cap_segment_sdu(struct l2cap_chan *chan, | |||
2156 | } | 2338 | } |
2157 | 2339 | ||
2158 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | 2340 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, |
2159 | u32 priority) | 2341 | u32 priority) |
2160 | { | 2342 | { |
2161 | struct sk_buff *skb; | 2343 | struct sk_buff *skb; |
2162 | int err; | 2344 | int err; |
@@ -2543,7 +2725,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb) | |||
2543 | /* Don't send frame to the socket it came from */ | 2725 | /* Don't send frame to the socket it came from */ |
2544 | if (skb->sk == sk) | 2726 | if (skb->sk == sk) |
2545 | continue; | 2727 | continue; |
2546 | nskb = skb_clone(skb, GFP_ATOMIC); | 2728 | nskb = skb_clone(skb, GFP_KERNEL); |
2547 | if (!nskb) | 2729 | if (!nskb) |
2548 | continue; | 2730 | continue; |
2549 | 2731 | ||
@@ -2569,7 +2751,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code, | |||
2569 | len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; | 2751 | len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; |
2570 | count = min_t(unsigned int, conn->mtu, len); | 2752 | count = min_t(unsigned int, conn->mtu, len); |
2571 | 2753 | ||
2572 | skb = bt_skb_alloc(count, GFP_ATOMIC); | 2754 | skb = bt_skb_alloc(count, GFP_KERNEL); |
2573 | if (!skb) | 2755 | if (!skb) |
2574 | return NULL; | 2756 | return NULL; |
2575 | 2757 | ||
@@ -2599,7 +2781,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn, u8 code, | |||
2599 | while (len) { | 2781 | while (len) { |
2600 | count = min_t(unsigned int, conn->mtu, len); | 2782 | count = min_t(unsigned int, conn->mtu, len); |
2601 | 2783 | ||
2602 | *frag = bt_skb_alloc(count, GFP_ATOMIC); | 2784 | *frag = bt_skb_alloc(count, GFP_KERNEL); |
2603 | if (!*frag) | 2785 | if (!*frag) |
2604 | goto fail; | 2786 | goto fail; |
2605 | 2787 | ||
@@ -2618,7 +2800,8 @@ fail: | |||
2618 | return NULL; | 2800 | return NULL; |
2619 | } | 2801 | } |
2620 | 2802 | ||
2621 | static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val) | 2803 | static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, |
2804 | unsigned long *val) | ||
2622 | { | 2805 | { |
2623 | struct l2cap_conf_opt *opt = *ptr; | 2806 | struct l2cap_conf_opt *opt = *ptr; |
2624 | int len; | 2807 | int len; |
@@ -2692,7 +2875,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) | |||
2692 | efs.msdu = cpu_to_le16(chan->local_msdu); | 2875 | efs.msdu = cpu_to_le16(chan->local_msdu); |
2693 | efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); | 2876 | efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); |
2694 | efs.acc_lat = __constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT); | 2877 | efs.acc_lat = __constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT); |
2695 | efs.flush_to = __constant_cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO); | 2878 | efs.flush_to = __constant_cpu_to_le32(L2CAP_EFS_DEFAULT_FLUSH_TO); |
2696 | break; | 2879 | break; |
2697 | 2880 | ||
2698 | case L2CAP_MODE_STREAMING: | 2881 | case L2CAP_MODE_STREAMING: |
@@ -2709,7 +2892,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) | |||
2709 | } | 2892 | } |
2710 | 2893 | ||
2711 | l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs), | 2894 | l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs), |
2712 | (unsigned long) &efs); | 2895 | (unsigned long) &efs); |
2713 | } | 2896 | } |
2714 | 2897 | ||
2715 | static void l2cap_ack_timeout(struct work_struct *work) | 2898 | static void l2cap_ack_timeout(struct work_struct *work) |
@@ -2749,6 +2932,11 @@ int l2cap_ertm_init(struct l2cap_chan *chan) | |||
2749 | 2932 | ||
2750 | skb_queue_head_init(&chan->tx_q); | 2933 | skb_queue_head_init(&chan->tx_q); |
2751 | 2934 | ||
2935 | chan->local_amp_id = 0; | ||
2936 | chan->move_id = 0; | ||
2937 | chan->move_state = L2CAP_MOVE_STABLE; | ||
2938 | chan->move_role = L2CAP_MOVE_ROLE_NONE; | ||
2939 | |||
2752 | if (chan->mode != L2CAP_MODE_ERTM) | 2940 | if (chan->mode != L2CAP_MODE_ERTM) |
2753 | return 0; | 2941 | return 0; |
2754 | 2942 | ||
@@ -2795,16 +2983,54 @@ static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) | |||
2795 | return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; | 2983 | return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; |
2796 | } | 2984 | } |
2797 | 2985 | ||
2986 | static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan, | ||
2987 | struct l2cap_conf_rfc *rfc) | ||
2988 | { | ||
2989 | if (chan->local_amp_id && chan->hs_hcon) { | ||
2990 | u64 ertm_to = chan->hs_hcon->hdev->amp_be_flush_to; | ||
2991 | |||
2992 | /* Class 1 devices have must have ERTM timeouts | ||
2993 | * exceeding the Link Supervision Timeout. The | ||
2994 | * default Link Supervision Timeout for AMP | ||
2995 | * controllers is 10 seconds. | ||
2996 | * | ||
2997 | * Class 1 devices use 0xffffffff for their | ||
2998 | * best-effort flush timeout, so the clamping logic | ||
2999 | * will result in a timeout that meets the above | ||
3000 | * requirement. ERTM timeouts are 16-bit values, so | ||
3001 | * the maximum timeout is 65.535 seconds. | ||
3002 | */ | ||
3003 | |||
3004 | /* Convert timeout to milliseconds and round */ | ||
3005 | ertm_to = DIV_ROUND_UP_ULL(ertm_to, 1000); | ||
3006 | |||
3007 | /* This is the recommended formula for class 2 devices | ||
3008 | * that start ERTM timers when packets are sent to the | ||
3009 | * controller. | ||
3010 | */ | ||
3011 | ertm_to = 3 * ertm_to + 500; | ||
3012 | |||
3013 | if (ertm_to > 0xffff) | ||
3014 | ertm_to = 0xffff; | ||
3015 | |||
3016 | rfc->retrans_timeout = cpu_to_le16((u16) ertm_to); | ||
3017 | rfc->monitor_timeout = rfc->retrans_timeout; | ||
3018 | } else { | ||
3019 | rfc->retrans_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO); | ||
3020 | rfc->monitor_timeout = __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO); | ||
3021 | } | ||
3022 | } | ||
3023 | |||
2798 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) | 3024 | static inline void l2cap_txwin_setup(struct l2cap_chan *chan) |
2799 | { | 3025 | { |
2800 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && | 3026 | if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && |
2801 | __l2cap_ews_supported(chan)) { | 3027 | __l2cap_ews_supported(chan)) { |
2802 | /* use extended control field */ | 3028 | /* use extended control field */ |
2803 | set_bit(FLAG_EXT_CTRL, &chan->flags); | 3029 | set_bit(FLAG_EXT_CTRL, &chan->flags); |
2804 | chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; | 3030 | chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; |
2805 | } else { | 3031 | } else { |
2806 | chan->tx_win = min_t(u16, chan->tx_win, | 3032 | chan->tx_win = min_t(u16, chan->tx_win, |
2807 | L2CAP_DEFAULT_TX_WINDOW); | 3033 | L2CAP_DEFAULT_TX_WINDOW); |
2808 | chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; | 3034 | chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; |
2809 | } | 3035 | } |
2810 | chan->ack_win = chan->tx_win; | 3036 | chan->ack_win = chan->tx_win; |
@@ -2844,7 +3070,7 @@ done: | |||
2844 | switch (chan->mode) { | 3070 | switch (chan->mode) { |
2845 | case L2CAP_MODE_BASIC: | 3071 | case L2CAP_MODE_BASIC: |
2846 | if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) && | 3072 | if (!(chan->conn->feat_mask & L2CAP_FEAT_ERTM) && |
2847 | !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING)) | 3073 | !(chan->conn->feat_mask & L2CAP_FEAT_STREAMING)) |
2848 | break; | 3074 | break; |
2849 | 3075 | ||
2850 | rfc.mode = L2CAP_MODE_BASIC; | 3076 | rfc.mode = L2CAP_MODE_BASIC; |
@@ -2855,28 +3081,27 @@ done: | |||
2855 | rfc.max_pdu_size = 0; | 3081 | rfc.max_pdu_size = 0; |
2856 | 3082 | ||
2857 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 3083 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2858 | (unsigned long) &rfc); | 3084 | (unsigned long) &rfc); |
2859 | break; | 3085 | break; |
2860 | 3086 | ||
2861 | case L2CAP_MODE_ERTM: | 3087 | case L2CAP_MODE_ERTM: |
2862 | rfc.mode = L2CAP_MODE_ERTM; | 3088 | rfc.mode = L2CAP_MODE_ERTM; |
2863 | rfc.max_transmit = chan->max_tx; | 3089 | rfc.max_transmit = chan->max_tx; |
2864 | rfc.retrans_timeout = 0; | 3090 | |
2865 | rfc.monitor_timeout = 0; | 3091 | __l2cap_set_ertm_timeouts(chan, &rfc); |
2866 | 3092 | ||
2867 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - | 3093 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - |
2868 | L2CAP_EXT_HDR_SIZE - | 3094 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - |
2869 | L2CAP_SDULEN_SIZE - | 3095 | L2CAP_FCS_SIZE); |
2870 | L2CAP_FCS_SIZE); | ||
2871 | rfc.max_pdu_size = cpu_to_le16(size); | 3096 | rfc.max_pdu_size = cpu_to_le16(size); |
2872 | 3097 | ||
2873 | l2cap_txwin_setup(chan); | 3098 | l2cap_txwin_setup(chan); |
2874 | 3099 | ||
2875 | rfc.txwin_size = min_t(u16, chan->tx_win, | 3100 | rfc.txwin_size = min_t(u16, chan->tx_win, |
2876 | L2CAP_DEFAULT_TX_WINDOW); | 3101 | L2CAP_DEFAULT_TX_WINDOW); |
2877 | 3102 | ||
2878 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 3103 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2879 | (unsigned long) &rfc); | 3104 | (unsigned long) &rfc); |
2880 | 3105 | ||
2881 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) | 3106 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
2882 | l2cap_add_opt_efs(&ptr, chan); | 3107 | l2cap_add_opt_efs(&ptr, chan); |
@@ -2885,14 +3110,14 @@ done: | |||
2885 | break; | 3110 | break; |
2886 | 3111 | ||
2887 | if (chan->fcs == L2CAP_FCS_NONE || | 3112 | if (chan->fcs == L2CAP_FCS_NONE || |
2888 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { | 3113 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
2889 | chan->fcs = L2CAP_FCS_NONE; | 3114 | chan->fcs = L2CAP_FCS_NONE; |
2890 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 3115 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
2891 | } | 3116 | } |
2892 | 3117 | ||
2893 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | 3118 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) |
2894 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, | 3119 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, |
2895 | chan->tx_win); | 3120 | chan->tx_win); |
2896 | break; | 3121 | break; |
2897 | 3122 | ||
2898 | case L2CAP_MODE_STREAMING: | 3123 | case L2CAP_MODE_STREAMING: |
@@ -2904,13 +3129,12 @@ done: | |||
2904 | rfc.monitor_timeout = 0; | 3129 | rfc.monitor_timeout = 0; |
2905 | 3130 | ||
2906 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - | 3131 | size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - |
2907 | L2CAP_EXT_HDR_SIZE - | 3132 | L2CAP_EXT_HDR_SIZE - L2CAP_SDULEN_SIZE - |
2908 | L2CAP_SDULEN_SIZE - | 3133 | L2CAP_FCS_SIZE); |
2909 | L2CAP_FCS_SIZE); | ||
2910 | rfc.max_pdu_size = cpu_to_le16(size); | 3134 | rfc.max_pdu_size = cpu_to_le16(size); |
2911 | 3135 | ||
2912 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), | 3136 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
2913 | (unsigned long) &rfc); | 3137 | (unsigned long) &rfc); |
2914 | 3138 | ||
2915 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) | 3139 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) |
2916 | l2cap_add_opt_efs(&ptr, chan); | 3140 | l2cap_add_opt_efs(&ptr, chan); |
@@ -2919,7 +3143,7 @@ done: | |||
2919 | break; | 3143 | break; |
2920 | 3144 | ||
2921 | if (chan->fcs == L2CAP_FCS_NONE || | 3145 | if (chan->fcs == L2CAP_FCS_NONE || |
2922 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { | 3146 | test_bit(CONF_NO_FCS_RECV, &chan->conf_state)) { |
2923 | chan->fcs = L2CAP_FCS_NONE; | 3147 | chan->fcs = L2CAP_FCS_NONE; |
2924 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); | 3148 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); |
2925 | } | 3149 | } |
@@ -3011,7 +3235,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data) | |||
3011 | case L2CAP_MODE_ERTM: | 3235 | case L2CAP_MODE_ERTM: |
3012 | if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { | 3236 | if (!test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) { |
3013 | chan->mode = l2cap_select_mode(rfc.mode, | 3237 | chan->mode = l2cap_select_mode(rfc.mode, |
3014 | chan->conn->feat_mask); | 3238 | chan->conn->feat_mask); |
3015 | break; | 3239 | break; |
3016 | } | 3240 | } |
3017 | 3241 | ||
@@ -3036,8 +3260,8 @@ done: | |||
3036 | if (chan->num_conf_rsp == 1) | 3260 | if (chan->num_conf_rsp == 1) |
3037 | return -ECONNREFUSED; | 3261 | return -ECONNREFUSED; |
3038 | 3262 | ||
3039 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3263 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
3040 | sizeof(rfc), (unsigned long) &rfc); | 3264 | (unsigned long) &rfc); |
3041 | } | 3265 | } |
3042 | 3266 | ||
3043 | if (result == L2CAP_CONF_SUCCESS) { | 3267 | if (result == L2CAP_CONF_SUCCESS) { |
@@ -3054,8 +3278,8 @@ done: | |||
3054 | 3278 | ||
3055 | if (remote_efs) { | 3279 | if (remote_efs) { |
3056 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && | 3280 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && |
3057 | efs.stype != L2CAP_SERV_NOTRAFIC && | 3281 | efs.stype != L2CAP_SERV_NOTRAFIC && |
3058 | efs.stype != chan->local_stype) { | 3282 | efs.stype != chan->local_stype) { |
3059 | 3283 | ||
3060 | result = L2CAP_CONF_UNACCEPT; | 3284 | result = L2CAP_CONF_UNACCEPT; |
3061 | 3285 | ||
@@ -3063,8 +3287,8 @@ done: | |||
3063 | return -ECONNREFUSED; | 3287 | return -ECONNREFUSED; |
3064 | 3288 | ||
3065 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3289 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
3066 | sizeof(efs), | 3290 | sizeof(efs), |
3067 | (unsigned long) &efs); | 3291 | (unsigned long) &efs); |
3068 | } else { | 3292 | } else { |
3069 | /* Send PENDING Conf Rsp */ | 3293 | /* Send PENDING Conf Rsp */ |
3070 | result = L2CAP_CONF_PENDING; | 3294 | result = L2CAP_CONF_PENDING; |
@@ -3087,51 +3311,45 @@ done: | |||
3087 | chan->remote_max_tx = rfc.max_transmit; | 3311 | chan->remote_max_tx = rfc.max_transmit; |
3088 | 3312 | ||
3089 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), | 3313 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), |
3090 | chan->conn->mtu - | 3314 | chan->conn->mtu - L2CAP_EXT_HDR_SIZE - |
3091 | L2CAP_EXT_HDR_SIZE - | 3315 | L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE); |
3092 | L2CAP_SDULEN_SIZE - | ||
3093 | L2CAP_FCS_SIZE); | ||
3094 | rfc.max_pdu_size = cpu_to_le16(size); | 3316 | rfc.max_pdu_size = cpu_to_le16(size); |
3095 | chan->remote_mps = size; | 3317 | chan->remote_mps = size; |
3096 | 3318 | ||
3097 | rfc.retrans_timeout = | 3319 | __l2cap_set_ertm_timeouts(chan, &rfc); |
3098 | __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO); | ||
3099 | rfc.monitor_timeout = | ||
3100 | __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO); | ||
3101 | 3320 | ||
3102 | set_bit(CONF_MODE_DONE, &chan->conf_state); | 3321 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
3103 | 3322 | ||
3104 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3323 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
3105 | sizeof(rfc), (unsigned long) &rfc); | 3324 | sizeof(rfc), (unsigned long) &rfc); |
3106 | 3325 | ||
3107 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { | 3326 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { |
3108 | chan->remote_id = efs.id; | 3327 | chan->remote_id = efs.id; |
3109 | chan->remote_stype = efs.stype; | 3328 | chan->remote_stype = efs.stype; |
3110 | chan->remote_msdu = le16_to_cpu(efs.msdu); | 3329 | chan->remote_msdu = le16_to_cpu(efs.msdu); |
3111 | chan->remote_flush_to = | 3330 | chan->remote_flush_to = |
3112 | le32_to_cpu(efs.flush_to); | 3331 | le32_to_cpu(efs.flush_to); |
3113 | chan->remote_acc_lat = | 3332 | chan->remote_acc_lat = |
3114 | le32_to_cpu(efs.acc_lat); | 3333 | le32_to_cpu(efs.acc_lat); |
3115 | chan->remote_sdu_itime = | 3334 | chan->remote_sdu_itime = |
3116 | le32_to_cpu(efs.sdu_itime); | 3335 | le32_to_cpu(efs.sdu_itime); |
3117 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3336 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, |
3118 | sizeof(efs), (unsigned long) &efs); | 3337 | sizeof(efs), |
3338 | (unsigned long) &efs); | ||
3119 | } | 3339 | } |
3120 | break; | 3340 | break; |
3121 | 3341 | ||
3122 | case L2CAP_MODE_STREAMING: | 3342 | case L2CAP_MODE_STREAMING: |
3123 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), | 3343 | size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), |
3124 | chan->conn->mtu - | 3344 | chan->conn->mtu - L2CAP_EXT_HDR_SIZE - |
3125 | L2CAP_EXT_HDR_SIZE - | 3345 | L2CAP_SDULEN_SIZE - L2CAP_FCS_SIZE); |
3126 | L2CAP_SDULEN_SIZE - | ||
3127 | L2CAP_FCS_SIZE); | ||
3128 | rfc.max_pdu_size = cpu_to_le16(size); | 3346 | rfc.max_pdu_size = cpu_to_le16(size); |
3129 | chan->remote_mps = size; | 3347 | chan->remote_mps = size; |
3130 | 3348 | ||
3131 | set_bit(CONF_MODE_DONE, &chan->conf_state); | 3349 | set_bit(CONF_MODE_DONE, &chan->conf_state); |
3132 | 3350 | ||
3133 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3351 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), |
3134 | sizeof(rfc), (unsigned long) &rfc); | 3352 | (unsigned long) &rfc); |
3135 | 3353 | ||
3136 | break; | 3354 | break; |
3137 | 3355 | ||
@@ -3152,7 +3370,8 @@ done: | |||
3152 | return ptr - data; | 3370 | return ptr - data; |
3153 | } | 3371 | } |
3154 | 3372 | ||
3155 | static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, void *data, u16 *result) | 3373 | static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, |
3374 | void *data, u16 *result) | ||
3156 | { | 3375 | { |
3157 | struct l2cap_conf_req *req = data; | 3376 | struct l2cap_conf_req *req = data; |
3158 | void *ptr = req->data; | 3377 | void *ptr = req->data; |
@@ -3179,7 +3398,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3179 | case L2CAP_CONF_FLUSH_TO: | 3398 | case L2CAP_CONF_FLUSH_TO: |
3180 | chan->flush_to = val; | 3399 | chan->flush_to = val; |
3181 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, | 3400 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_FLUSH_TO, |
3182 | 2, chan->flush_to); | 3401 | 2, chan->flush_to); |
3183 | break; | 3402 | break; |
3184 | 3403 | ||
3185 | case L2CAP_CONF_RFC: | 3404 | case L2CAP_CONF_RFC: |
@@ -3187,13 +3406,13 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3187 | memcpy(&rfc, (void *)val, olen); | 3406 | memcpy(&rfc, (void *)val, olen); |
3188 | 3407 | ||
3189 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && | 3408 | if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && |
3190 | rfc.mode != chan->mode) | 3409 | rfc.mode != chan->mode) |
3191 | return -ECONNREFUSED; | 3410 | return -ECONNREFUSED; |
3192 | 3411 | ||
3193 | chan->fcs = 0; | 3412 | chan->fcs = 0; |
3194 | 3413 | ||
3195 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, | 3414 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, |
3196 | sizeof(rfc), (unsigned long) &rfc); | 3415 | sizeof(rfc), (unsigned long) &rfc); |
3197 | break; | 3416 | break; |
3198 | 3417 | ||
3199 | case L2CAP_CONF_EWS: | 3418 | case L2CAP_CONF_EWS: |
@@ -3207,12 +3426,12 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3207 | memcpy(&efs, (void *)val, olen); | 3426 | memcpy(&efs, (void *)val, olen); |
3208 | 3427 | ||
3209 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && | 3428 | if (chan->local_stype != L2CAP_SERV_NOTRAFIC && |
3210 | efs.stype != L2CAP_SERV_NOTRAFIC && | 3429 | efs.stype != L2CAP_SERV_NOTRAFIC && |
3211 | efs.stype != chan->local_stype) | 3430 | efs.stype != chan->local_stype) |
3212 | return -ECONNREFUSED; | 3431 | return -ECONNREFUSED; |
3213 | 3432 | ||
3214 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, | 3433 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, sizeof(efs), |
3215 | sizeof(efs), (unsigned long) &efs); | 3434 | (unsigned long) &efs); |
3216 | break; | 3435 | break; |
3217 | } | 3436 | } |
3218 | } | 3437 | } |
@@ -3235,10 +3454,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3235 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { | 3454 | if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { |
3236 | chan->local_msdu = le16_to_cpu(efs.msdu); | 3455 | chan->local_msdu = le16_to_cpu(efs.msdu); |
3237 | chan->local_sdu_itime = | 3456 | chan->local_sdu_itime = |
3238 | le32_to_cpu(efs.sdu_itime); | 3457 | le32_to_cpu(efs.sdu_itime); |
3239 | chan->local_acc_lat = le32_to_cpu(efs.acc_lat); | 3458 | chan->local_acc_lat = le32_to_cpu(efs.acc_lat); |
3240 | chan->local_flush_to = | 3459 | chan->local_flush_to = |
3241 | le32_to_cpu(efs.flush_to); | 3460 | le32_to_cpu(efs.flush_to); |
3242 | } | 3461 | } |
3243 | break; | 3462 | break; |
3244 | 3463 | ||
@@ -3253,7 +3472,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi | |||
3253 | return ptr - data; | 3472 | return ptr - data; |
3254 | } | 3473 | } |
3255 | 3474 | ||
3256 | static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result, u16 flags) | 3475 | static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, |
3476 | u16 result, u16 flags) | ||
3257 | { | 3477 | { |
3258 | struct l2cap_conf_rsp *rsp = data; | 3478 | struct l2cap_conf_rsp *rsp = data; |
3259 | void *ptr = rsp->data; | 3479 | void *ptr = rsp->data; |
@@ -3272,19 +3492,27 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan) | |||
3272 | struct l2cap_conn_rsp rsp; | 3492 | struct l2cap_conn_rsp rsp; |
3273 | struct l2cap_conn *conn = chan->conn; | 3493 | struct l2cap_conn *conn = chan->conn; |
3274 | u8 buf[128]; | 3494 | u8 buf[128]; |
3495 | u8 rsp_code; | ||
3275 | 3496 | ||
3276 | rsp.scid = cpu_to_le16(chan->dcid); | 3497 | rsp.scid = cpu_to_le16(chan->dcid); |
3277 | rsp.dcid = cpu_to_le16(chan->scid); | 3498 | rsp.dcid = cpu_to_le16(chan->scid); |
3278 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); | 3499 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); |
3279 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | 3500 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); |
3280 | l2cap_send_cmd(conn, chan->ident, | 3501 | |
3281 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 3502 | if (chan->hs_hcon) |
3503 | rsp_code = L2CAP_CREATE_CHAN_RSP; | ||
3504 | else | ||
3505 | rsp_code = L2CAP_CONN_RSP; | ||
3506 | |||
3507 | BT_DBG("chan %p rsp_code %u", chan, rsp_code); | ||
3508 | |||
3509 | l2cap_send_cmd(conn, chan->ident, rsp_code, sizeof(rsp), &rsp); | ||
3282 | 3510 | ||
3283 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) | 3511 | if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) |
3284 | return; | 3512 | return; |
3285 | 3513 | ||
3286 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3514 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3287 | l2cap_build_conf_req(chan, buf), buf); | 3515 | l2cap_build_conf_req(chan, buf), buf); |
3288 | chan->num_conf_req++; | 3516 | chan->num_conf_req++; |
3289 | } | 3517 | } |
3290 | 3518 | ||
@@ -3339,7 +3567,8 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len) | |||
3339 | } | 3567 | } |
3340 | } | 3568 | } |
3341 | 3569 | ||
3342 | static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3570 | static inline int l2cap_command_rej(struct l2cap_conn *conn, |
3571 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3343 | { | 3572 | { |
3344 | struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; | 3573 | struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data; |
3345 | 3574 | ||
@@ -3347,7 +3576,7 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3347 | return 0; | 3576 | return 0; |
3348 | 3577 | ||
3349 | if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && | 3578 | if ((conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) && |
3350 | cmd->ident == conn->info_ident) { | 3579 | cmd->ident == conn->info_ident) { |
3351 | cancel_delayed_work(&conn->info_timer); | 3580 | cancel_delayed_work(&conn->info_timer); |
3352 | 3581 | ||
3353 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 3582 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
@@ -3359,7 +3588,9 @@ static inline int l2cap_command_rej(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3359 | return 0; | 3588 | return 0; |
3360 | } | 3589 | } |
3361 | 3590 | ||
3362 | static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3591 | static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn, |
3592 | struct l2cap_cmd_hdr *cmd, | ||
3593 | u8 *data, u8 rsp_code, u8 amp_id) | ||
3363 | { | 3594 | { |
3364 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; | 3595 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; |
3365 | struct l2cap_conn_rsp rsp; | 3596 | struct l2cap_conn_rsp rsp; |
@@ -3386,7 +3617,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3386 | 3617 | ||
3387 | /* Check if the ACL is secure enough (if not SDP) */ | 3618 | /* Check if the ACL is secure enough (if not SDP) */ |
3388 | if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) && | 3619 | if (psm != __constant_cpu_to_le16(L2CAP_PSM_SDP) && |
3389 | !hci_conn_check_link_mode(conn->hcon)) { | 3620 | !hci_conn_check_link_mode(conn->hcon)) { |
3390 | conn->disc_reason = HCI_ERROR_AUTH_FAILURE; | 3621 | conn->disc_reason = HCI_ERROR_AUTH_FAILURE; |
3391 | result = L2CAP_CR_SEC_BLOCK; | 3622 | result = L2CAP_CR_SEC_BLOCK; |
3392 | goto response; | 3623 | goto response; |
@@ -3410,8 +3641,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3410 | bacpy(&bt_sk(sk)->dst, conn->dst); | 3641 | bacpy(&bt_sk(sk)->dst, conn->dst); |
3411 | chan->psm = psm; | 3642 | chan->psm = psm; |
3412 | chan->dcid = scid; | 3643 | chan->dcid = scid; |
3413 | 3644 | chan->local_amp_id = amp_id; | |
3414 | bt_accept_enqueue(parent, sk); | ||
3415 | 3645 | ||
3416 | __l2cap_chan_add(conn, chan); | 3646 | __l2cap_chan_add(conn, chan); |
3417 | 3647 | ||
@@ -3427,10 +3657,19 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3427 | __l2cap_state_change(chan, BT_CONNECT2); | 3657 | __l2cap_state_change(chan, BT_CONNECT2); |
3428 | result = L2CAP_CR_PEND; | 3658 | result = L2CAP_CR_PEND; |
3429 | status = L2CAP_CS_AUTHOR_PEND; | 3659 | status = L2CAP_CS_AUTHOR_PEND; |
3430 | parent->sk_data_ready(parent, 0); | 3660 | chan->ops->defer(chan); |
3431 | } else { | 3661 | } else { |
3432 | __l2cap_state_change(chan, BT_CONFIG); | 3662 | /* Force pending result for AMP controllers. |
3433 | result = L2CAP_CR_SUCCESS; | 3663 | * The connection will succeed after the |
3664 | * physical link is up. | ||
3665 | */ | ||
3666 | if (amp_id) { | ||
3667 | __l2cap_state_change(chan, BT_CONNECT2); | ||
3668 | result = L2CAP_CR_PEND; | ||
3669 | } else { | ||
3670 | __l2cap_state_change(chan, BT_CONFIG); | ||
3671 | result = L2CAP_CR_SUCCESS; | ||
3672 | } | ||
3434 | status = L2CAP_CS_NO_INFO; | 3673 | status = L2CAP_CS_NO_INFO; |
3435 | } | 3674 | } |
3436 | } else { | 3675 | } else { |
@@ -3453,7 +3692,7 @@ sendresp: | |||
3453 | rsp.dcid = cpu_to_le16(dcid); | 3692 | rsp.dcid = cpu_to_le16(dcid); |
3454 | rsp.result = cpu_to_le16(result); | 3693 | rsp.result = cpu_to_le16(result); |
3455 | rsp.status = cpu_to_le16(status); | 3694 | rsp.status = cpu_to_le16(status); |
3456 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 3695 | l2cap_send_cmd(conn, cmd->ident, rsp_code, sizeof(rsp), &rsp); |
3457 | 3696 | ||
3458 | if (result == L2CAP_CR_PEND && status == L2CAP_CS_NO_INFO) { | 3697 | if (result == L2CAP_CR_PEND && status == L2CAP_CS_NO_INFO) { |
3459 | struct l2cap_info_req info; | 3698 | struct l2cap_info_req info; |
@@ -3464,23 +3703,31 @@ sendresp: | |||
3464 | 3703 | ||
3465 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); | 3704 | schedule_delayed_work(&conn->info_timer, L2CAP_INFO_TIMEOUT); |
3466 | 3705 | ||
3467 | l2cap_send_cmd(conn, conn->info_ident, | 3706 | l2cap_send_cmd(conn, conn->info_ident, L2CAP_INFO_REQ, |
3468 | L2CAP_INFO_REQ, sizeof(info), &info); | 3707 | sizeof(info), &info); |
3469 | } | 3708 | } |
3470 | 3709 | ||
3471 | if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && | 3710 | if (chan && !test_bit(CONF_REQ_SENT, &chan->conf_state) && |
3472 | result == L2CAP_CR_SUCCESS) { | 3711 | result == L2CAP_CR_SUCCESS) { |
3473 | u8 buf[128]; | 3712 | u8 buf[128]; |
3474 | set_bit(CONF_REQ_SENT, &chan->conf_state); | 3713 | set_bit(CONF_REQ_SENT, &chan->conf_state); |
3475 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3714 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3476 | l2cap_build_conf_req(chan, buf), buf); | 3715 | l2cap_build_conf_req(chan, buf), buf); |
3477 | chan->num_conf_req++; | 3716 | chan->num_conf_req++; |
3478 | } | 3717 | } |
3479 | 3718 | ||
3719 | return chan; | ||
3720 | } | ||
3721 | |||
3722 | static int l2cap_connect_req(struct l2cap_conn *conn, | ||
3723 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3724 | { | ||
3725 | l2cap_connect(conn, cmd, data, L2CAP_CONN_RSP, 0); | ||
3480 | return 0; | 3726 | return 0; |
3481 | } | 3727 | } |
3482 | 3728 | ||
3483 | static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3729 | static int l2cap_connect_create_rsp(struct l2cap_conn *conn, |
3730 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3484 | { | 3731 | { |
3485 | struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; | 3732 | struct l2cap_conn_rsp *rsp = (struct l2cap_conn_rsp *) data; |
3486 | u16 scid, dcid, result, status; | 3733 | u16 scid, dcid, result, status; |
@@ -3494,7 +3741,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3494 | status = __le16_to_cpu(rsp->status); | 3741 | status = __le16_to_cpu(rsp->status); |
3495 | 3742 | ||
3496 | BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", | 3743 | BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", |
3497 | dcid, scid, result, status); | 3744 | dcid, scid, result, status); |
3498 | 3745 | ||
3499 | mutex_lock(&conn->chan_lock); | 3746 | mutex_lock(&conn->chan_lock); |
3500 | 3747 | ||
@@ -3527,7 +3774,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
3527 | break; | 3774 | break; |
3528 | 3775 | ||
3529 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3776 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3530 | l2cap_build_conf_req(chan, req), req); | 3777 | l2cap_build_conf_req(chan, req), req); |
3531 | chan->num_conf_req++; | 3778 | chan->num_conf_req++; |
3532 | break; | 3779 | break; |
3533 | 3780 | ||
@@ -3559,7 +3806,25 @@ static inline void set_default_fcs(struct l2cap_chan *chan) | |||
3559 | chan->fcs = L2CAP_FCS_CRC16; | 3806 | chan->fcs = L2CAP_FCS_CRC16; |
3560 | } | 3807 | } |
3561 | 3808 | ||
3562 | static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) | 3809 | static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data, |
3810 | u8 ident, u16 flags) | ||
3811 | { | ||
3812 | struct l2cap_conn *conn = chan->conn; | ||
3813 | |||
3814 | BT_DBG("conn %p chan %p ident %d flags 0x%4.4x", conn, chan, ident, | ||
3815 | flags); | ||
3816 | |||
3817 | clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); | ||
3818 | set_bit(CONF_OUTPUT_DONE, &chan->conf_state); | ||
3819 | |||
3820 | l2cap_send_cmd(conn, ident, L2CAP_CONF_RSP, | ||
3821 | l2cap_build_conf_rsp(chan, data, | ||
3822 | L2CAP_CONF_SUCCESS, flags), data); | ||
3823 | } | ||
3824 | |||
3825 | static inline int l2cap_config_req(struct l2cap_conn *conn, | ||
3826 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, | ||
3827 | u8 *data) | ||
3563 | { | 3828 | { |
3564 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; | 3829 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; |
3565 | u16 dcid, flags; | 3830 | u16 dcid, flags; |
@@ -3584,7 +3849,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3584 | rej.dcid = cpu_to_le16(chan->dcid); | 3849 | rej.dcid = cpu_to_le16(chan->dcid); |
3585 | 3850 | ||
3586 | l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ, | 3851 | l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ, |
3587 | sizeof(rej), &rej); | 3852 | sizeof(rej), &rej); |
3588 | goto unlock; | 3853 | goto unlock; |
3589 | } | 3854 | } |
3590 | 3855 | ||
@@ -3592,8 +3857,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3592 | len = cmd_len - sizeof(*req); | 3857 | len = cmd_len - sizeof(*req); |
3593 | if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { | 3858 | if (len < 0 || chan->conf_len + len > sizeof(chan->conf_req)) { |
3594 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3859 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, |
3595 | l2cap_build_conf_rsp(chan, rsp, | 3860 | l2cap_build_conf_rsp(chan, rsp, |
3596 | L2CAP_CONF_REJECT, flags), rsp); | 3861 | L2CAP_CONF_REJECT, flags), rsp); |
3597 | goto unlock; | 3862 | goto unlock; |
3598 | } | 3863 | } |
3599 | 3864 | ||
@@ -3604,8 +3869,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3604 | if (flags & L2CAP_CONF_FLAG_CONTINUATION) { | 3869 | if (flags & L2CAP_CONF_FLAG_CONTINUATION) { |
3605 | /* Incomplete config. Send empty response. */ | 3870 | /* Incomplete config. Send empty response. */ |
3606 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3871 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, |
3607 | l2cap_build_conf_rsp(chan, rsp, | 3872 | l2cap_build_conf_rsp(chan, rsp, |
3608 | L2CAP_CONF_SUCCESS, flags), rsp); | 3873 | L2CAP_CONF_SUCCESS, flags), rsp); |
3609 | goto unlock; | 3874 | goto unlock; |
3610 | } | 3875 | } |
3611 | 3876 | ||
@@ -3616,6 +3881,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3616 | goto unlock; | 3881 | goto unlock; |
3617 | } | 3882 | } |
3618 | 3883 | ||
3884 | chan->ident = cmd->ident; | ||
3619 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, len, rsp); | 3885 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, len, rsp); |
3620 | chan->num_conf_rsp++; | 3886 | chan->num_conf_rsp++; |
3621 | 3887 | ||
@@ -3643,23 +3909,22 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3643 | if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { | 3909 | if (!test_and_set_bit(CONF_REQ_SENT, &chan->conf_state)) { |
3644 | u8 buf[64]; | 3910 | u8 buf[64]; |
3645 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, | 3911 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, |
3646 | l2cap_build_conf_req(chan, buf), buf); | 3912 | l2cap_build_conf_req(chan, buf), buf); |
3647 | chan->num_conf_req++; | 3913 | chan->num_conf_req++; |
3648 | } | 3914 | } |
3649 | 3915 | ||
3650 | /* Got Conf Rsp PENDING from remote side and asume we sent | 3916 | /* Got Conf Rsp PENDING from remote side and asume we sent |
3651 | Conf Rsp PENDING in the code above */ | 3917 | Conf Rsp PENDING in the code above */ |
3652 | if (test_bit(CONF_REM_CONF_PEND, &chan->conf_state) && | 3918 | if (test_bit(CONF_REM_CONF_PEND, &chan->conf_state) && |
3653 | test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { | 3919 | test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { |
3654 | 3920 | ||
3655 | /* check compatibility */ | 3921 | /* check compatibility */ |
3656 | 3922 | ||
3657 | clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); | 3923 | /* Send rsp for BR/EDR channel */ |
3658 | set_bit(CONF_OUTPUT_DONE, &chan->conf_state); | 3924 | if (!chan->hs_hcon) |
3659 | 3925 | l2cap_send_efs_conf_rsp(chan, rsp, cmd->ident, flags); | |
3660 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3926 | else |
3661 | l2cap_build_conf_rsp(chan, rsp, | 3927 | chan->ident = cmd->ident; |
3662 | L2CAP_CONF_SUCCESS, flags), rsp); | ||
3663 | } | 3928 | } |
3664 | 3929 | ||
3665 | unlock: | 3930 | unlock: |
@@ -3667,7 +3932,8 @@ unlock: | |||
3667 | return err; | 3932 | return err; |
3668 | } | 3933 | } |
3669 | 3934 | ||
3670 | static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 3935 | static inline int l2cap_config_rsp(struct l2cap_conn *conn, |
3936 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3671 | { | 3937 | { |
3672 | struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; | 3938 | struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data; |
3673 | u16 scid, flags, result; | 3939 | u16 scid, flags, result; |
@@ -3699,20 +3965,21 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3699 | char buf[64]; | 3965 | char buf[64]; |
3700 | 3966 | ||
3701 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, | 3967 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
3702 | buf, &result); | 3968 | buf, &result); |
3703 | if (len < 0) { | 3969 | if (len < 0) { |
3704 | l2cap_send_disconn_req(conn, chan, ECONNRESET); | 3970 | l2cap_send_disconn_req(conn, chan, ECONNRESET); |
3705 | goto done; | 3971 | goto done; |
3706 | } | 3972 | } |
3707 | 3973 | ||
3708 | /* check compatibility */ | 3974 | if (!chan->hs_hcon) { |
3709 | 3975 | l2cap_send_efs_conf_rsp(chan, buf, cmd->ident, | |
3710 | clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); | 3976 | 0); |
3711 | set_bit(CONF_OUTPUT_DONE, &chan->conf_state); | 3977 | } else { |
3712 | 3978 | if (l2cap_check_efs(chan)) { | |
3713 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, | 3979 | amp_create_logical_link(chan); |
3714 | l2cap_build_conf_rsp(chan, buf, | 3980 | chan->ident = cmd->ident; |
3715 | L2CAP_CONF_SUCCESS, 0x0000), buf); | 3981 | } |
3982 | } | ||
3716 | } | 3983 | } |
3717 | goto done; | 3984 | goto done; |
3718 | 3985 | ||
@@ -3728,14 +3995,14 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
3728 | /* throw out any old stored conf requests */ | 3995 | /* throw out any old stored conf requests */ |
3729 | result = L2CAP_CONF_SUCCESS; | 3996 | result = L2CAP_CONF_SUCCESS; |
3730 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, | 3997 | len = l2cap_parse_conf_rsp(chan, rsp->data, len, |
3731 | req, &result); | 3998 | req, &result); |
3732 | if (len < 0) { | 3999 | if (len < 0) { |
3733 | l2cap_send_disconn_req(conn, chan, ECONNRESET); | 4000 | l2cap_send_disconn_req(conn, chan, ECONNRESET); |
3734 | goto done; | 4001 | goto done; |
3735 | } | 4002 | } |
3736 | 4003 | ||
3737 | l2cap_send_cmd(conn, l2cap_get_ident(conn), | 4004 | l2cap_send_cmd(conn, l2cap_get_ident(conn), |
3738 | L2CAP_CONF_REQ, len, req); | 4005 | L2CAP_CONF_REQ, len, req); |
3739 | chan->num_conf_req++; | 4006 | chan->num_conf_req++; |
3740 | if (result != L2CAP_CONF_SUCCESS) | 4007 | if (result != L2CAP_CONF_SUCCESS) |
3741 | goto done; | 4008 | goto done; |
@@ -3773,7 +4040,8 @@ done: | |||
3773 | return err; | 4040 | return err; |
3774 | } | 4041 | } |
3775 | 4042 | ||
3776 | static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 4043 | static inline int l2cap_disconnect_req(struct l2cap_conn *conn, |
4044 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3777 | { | 4045 | { |
3778 | struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; | 4046 | struct l2cap_disconn_req *req = (struct l2cap_disconn_req *) data; |
3779 | struct l2cap_disconn_rsp rsp; | 4047 | struct l2cap_disconn_rsp rsp; |
@@ -3819,7 +4087,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd | |||
3819 | return 0; | 4087 | return 0; |
3820 | } | 4088 | } |
3821 | 4089 | ||
3822 | static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 4090 | static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, |
4091 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3823 | { | 4092 | { |
3824 | struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; | 4093 | struct l2cap_disconn_rsp *rsp = (struct l2cap_disconn_rsp *) data; |
3825 | u16 dcid, scid; | 4094 | u16 dcid, scid; |
@@ -3853,7 +4122,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd | |||
3853 | return 0; | 4122 | return 0; |
3854 | } | 4123 | } |
3855 | 4124 | ||
3856 | static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 4125 | static inline int l2cap_information_req(struct l2cap_conn *conn, |
4126 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3857 | { | 4127 | { |
3858 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; | 4128 | struct l2cap_info_req *req = (struct l2cap_info_req *) data; |
3859 | u16 type; | 4129 | u16 type; |
@@ -3870,14 +4140,14 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm | |||
3870 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); | 4140 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); |
3871 | if (!disable_ertm) | 4141 | if (!disable_ertm) |
3872 | feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING | 4142 | feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING |
3873 | | L2CAP_FEAT_FCS; | 4143 | | L2CAP_FEAT_FCS; |
3874 | if (enable_hs) | 4144 | if (enable_hs) |
3875 | feat_mask |= L2CAP_FEAT_EXT_FLOW | 4145 | feat_mask |= L2CAP_FEAT_EXT_FLOW |
3876 | | L2CAP_FEAT_EXT_WINDOW; | 4146 | | L2CAP_FEAT_EXT_WINDOW; |
3877 | 4147 | ||
3878 | put_unaligned_le32(feat_mask, rsp->data); | 4148 | put_unaligned_le32(feat_mask, rsp->data); |
3879 | l2cap_send_cmd(conn, cmd->ident, | 4149 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), |
3880 | L2CAP_INFO_RSP, sizeof(buf), buf); | 4150 | buf); |
3881 | } else if (type == L2CAP_IT_FIXED_CHAN) { | 4151 | } else if (type == L2CAP_IT_FIXED_CHAN) { |
3882 | u8 buf[12]; | 4152 | u8 buf[12]; |
3883 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; | 4153 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; |
@@ -3890,20 +4160,21 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm | |||
3890 | rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN); | 4160 | rsp->type = __constant_cpu_to_le16(L2CAP_IT_FIXED_CHAN); |
3891 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); | 4161 | rsp->result = __constant_cpu_to_le16(L2CAP_IR_SUCCESS); |
3892 | memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); | 4162 | memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); |
3893 | l2cap_send_cmd(conn, cmd->ident, | 4163 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(buf), |
3894 | L2CAP_INFO_RSP, sizeof(buf), buf); | 4164 | buf); |
3895 | } else { | 4165 | } else { |
3896 | struct l2cap_info_rsp rsp; | 4166 | struct l2cap_info_rsp rsp; |
3897 | rsp.type = cpu_to_le16(type); | 4167 | rsp.type = cpu_to_le16(type); |
3898 | rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP); | 4168 | rsp.result = __constant_cpu_to_le16(L2CAP_IR_NOTSUPP); |
3899 | l2cap_send_cmd(conn, cmd->ident, | 4169 | l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), |
3900 | L2CAP_INFO_RSP, sizeof(rsp), &rsp); | 4170 | &rsp); |
3901 | } | 4171 | } |
3902 | 4172 | ||
3903 | return 0; | 4173 | return 0; |
3904 | } | 4174 | } |
3905 | 4175 | ||
3906 | static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) | 4176 | static inline int l2cap_information_rsp(struct l2cap_conn *conn, |
4177 | struct l2cap_cmd_hdr *cmd, u8 *data) | ||
3907 | { | 4178 | { |
3908 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; | 4179 | struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) data; |
3909 | u16 type, result; | 4180 | u16 type, result; |
@@ -3915,7 +4186,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
3915 | 4186 | ||
3916 | /* L2CAP Info req/rsp are unbound to channels, add extra checks */ | 4187 | /* L2CAP Info req/rsp are unbound to channels, add extra checks */ |
3917 | if (cmd->ident != conn->info_ident || | 4188 | if (cmd->ident != conn->info_ident || |
3918 | conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) | 4189 | conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) |
3919 | return 0; | 4190 | return 0; |
3920 | 4191 | ||
3921 | cancel_delayed_work(&conn->info_timer); | 4192 | cancel_delayed_work(&conn->info_timer); |
@@ -3940,7 +4211,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
3940 | conn->info_ident = l2cap_get_ident(conn); | 4211 | conn->info_ident = l2cap_get_ident(conn); |
3941 | 4212 | ||
3942 | l2cap_send_cmd(conn, conn->info_ident, | 4213 | l2cap_send_cmd(conn, conn->info_ident, |
3943 | L2CAP_INFO_REQ, sizeof(req), &req); | 4214 | L2CAP_INFO_REQ, sizeof(req), &req); |
3944 | } else { | 4215 | } else { |
3945 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; | 4216 | conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE; |
3946 | conn->info_ident = 0; | 4217 | conn->info_ident = 0; |
@@ -3961,12 +4232,14 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm | |||
3961 | return 0; | 4232 | return 0; |
3962 | } | 4233 | } |
3963 | 4234 | ||
3964 | static inline int l2cap_create_channel_req(struct l2cap_conn *conn, | 4235 | static int l2cap_create_channel_req(struct l2cap_conn *conn, |
3965 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, | 4236 | struct l2cap_cmd_hdr *cmd, |
3966 | void *data) | 4237 | u16 cmd_len, void *data) |
3967 | { | 4238 | { |
3968 | struct l2cap_create_chan_req *req = data; | 4239 | struct l2cap_create_chan_req *req = data; |
3969 | struct l2cap_create_chan_rsp rsp; | 4240 | struct l2cap_create_chan_rsp rsp; |
4241 | struct l2cap_chan *chan; | ||
4242 | struct hci_dev *hdev; | ||
3970 | u16 psm, scid; | 4243 | u16 psm, scid; |
3971 | 4244 | ||
3972 | if (cmd_len != sizeof(*req)) | 4245 | if (cmd_len != sizeof(*req)) |
@@ -3980,56 +4253,119 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn, | |||
3980 | 4253 | ||
3981 | BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id); | 4254 | BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id); |
3982 | 4255 | ||
3983 | /* Placeholder: Always reject */ | 4256 | /* For controller id 0 make BR/EDR connection */ |
4257 | if (req->amp_id == HCI_BREDR_ID) { | ||
4258 | l2cap_connect(conn, cmd, data, L2CAP_CREATE_CHAN_RSP, | ||
4259 | req->amp_id); | ||
4260 | return 0; | ||
4261 | } | ||
4262 | |||
4263 | /* Validate AMP controller id */ | ||
4264 | hdev = hci_dev_get(req->amp_id); | ||
4265 | if (!hdev) | ||
4266 | goto error; | ||
4267 | |||
4268 | if (hdev->dev_type != HCI_AMP || !test_bit(HCI_UP, &hdev->flags)) { | ||
4269 | hci_dev_put(hdev); | ||
4270 | goto error; | ||
4271 | } | ||
4272 | |||
4273 | chan = l2cap_connect(conn, cmd, data, L2CAP_CREATE_CHAN_RSP, | ||
4274 | req->amp_id); | ||
4275 | if (chan) { | ||
4276 | struct amp_mgr *mgr = conn->hcon->amp_mgr; | ||
4277 | struct hci_conn *hs_hcon; | ||
4278 | |||
4279 | hs_hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, conn->dst); | ||
4280 | if (!hs_hcon) { | ||
4281 | hci_dev_put(hdev); | ||
4282 | return -EFAULT; | ||
4283 | } | ||
4284 | |||
4285 | BT_DBG("mgr %p bredr_chan %p hs_hcon %p", mgr, chan, hs_hcon); | ||
4286 | |||
4287 | mgr->bredr_chan = chan; | ||
4288 | chan->hs_hcon = hs_hcon; | ||
4289 | chan->fcs = L2CAP_FCS_NONE; | ||
4290 | conn->mtu = hdev->block_mtu; | ||
4291 | } | ||
4292 | |||
4293 | hci_dev_put(hdev); | ||
4294 | |||
4295 | return 0; | ||
4296 | |||
4297 | error: | ||
3984 | rsp.dcid = 0; | 4298 | rsp.dcid = 0; |
3985 | rsp.scid = cpu_to_le16(scid); | 4299 | rsp.scid = cpu_to_le16(scid); |
3986 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_NO_MEM); | 4300 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_BAD_AMP); |
3987 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | 4301 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); |
3988 | 4302 | ||
3989 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP, | 4303 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP, |
3990 | sizeof(rsp), &rsp); | 4304 | sizeof(rsp), &rsp); |
3991 | 4305 | ||
3992 | return 0; | 4306 | return -EFAULT; |
3993 | } | 4307 | } |
3994 | 4308 | ||
3995 | static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn, | 4309 | static void l2cap_send_move_chan_req(struct l2cap_chan *chan, u8 dest_amp_id) |
3996 | struct l2cap_cmd_hdr *cmd, void *data) | ||
3997 | { | 4310 | { |
3998 | BT_DBG("conn %p", conn); | 4311 | struct l2cap_move_chan_req req; |
4312 | u8 ident; | ||
4313 | |||
4314 | BT_DBG("chan %p, dest_amp_id %d", chan, dest_amp_id); | ||
3999 | 4315 | ||
4000 | return l2cap_connect_rsp(conn, cmd, data); | 4316 | ident = l2cap_get_ident(chan->conn); |
4317 | chan->ident = ident; | ||
4318 | |||
4319 | req.icid = cpu_to_le16(chan->scid); | ||
4320 | req.dest_amp_id = dest_amp_id; | ||
4321 | |||
4322 | l2cap_send_cmd(chan->conn, ident, L2CAP_MOVE_CHAN_REQ, sizeof(req), | ||
4323 | &req); | ||
4324 | |||
4325 | __set_chan_timer(chan, L2CAP_MOVE_TIMEOUT); | ||
4001 | } | 4326 | } |
4002 | 4327 | ||
4003 | static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, | 4328 | static void l2cap_send_move_chan_rsp(struct l2cap_chan *chan, u16 result) |
4004 | u16 icid, u16 result) | ||
4005 | { | 4329 | { |
4006 | struct l2cap_move_chan_rsp rsp; | 4330 | struct l2cap_move_chan_rsp rsp; |
4007 | 4331 | ||
4008 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); | 4332 | BT_DBG("chan %p, result 0x%4.4x", chan, result); |
4009 | 4333 | ||
4010 | rsp.icid = cpu_to_le16(icid); | 4334 | rsp.icid = cpu_to_le16(chan->dcid); |
4011 | rsp.result = cpu_to_le16(result); | 4335 | rsp.result = cpu_to_le16(result); |
4012 | 4336 | ||
4013 | l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_RSP, sizeof(rsp), &rsp); | 4337 | l2cap_send_cmd(chan->conn, chan->ident, L2CAP_MOVE_CHAN_RSP, |
4338 | sizeof(rsp), &rsp); | ||
4014 | } | 4339 | } |
4015 | 4340 | ||
4016 | static void l2cap_send_move_chan_cfm(struct l2cap_conn *conn, | 4341 | static void l2cap_send_move_chan_cfm(struct l2cap_chan *chan, u16 result) |
4017 | struct l2cap_chan *chan, | ||
4018 | u16 icid, u16 result) | ||
4019 | { | 4342 | { |
4020 | struct l2cap_move_chan_cfm cfm; | 4343 | struct l2cap_move_chan_cfm cfm; |
4021 | u8 ident; | ||
4022 | 4344 | ||
4023 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); | 4345 | BT_DBG("chan %p, result 0x%4.4x", chan, result); |
4024 | 4346 | ||
4025 | ident = l2cap_get_ident(conn); | 4347 | chan->ident = l2cap_get_ident(chan->conn); |
4026 | if (chan) | ||
4027 | chan->ident = ident; | ||
4028 | 4348 | ||
4029 | cfm.icid = cpu_to_le16(icid); | 4349 | cfm.icid = cpu_to_le16(chan->scid); |
4030 | cfm.result = cpu_to_le16(result); | 4350 | cfm.result = cpu_to_le16(result); |
4031 | 4351 | ||
4032 | l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM, sizeof(cfm), &cfm); | 4352 | l2cap_send_cmd(chan->conn, chan->ident, L2CAP_MOVE_CHAN_CFM, |
4353 | sizeof(cfm), &cfm); | ||
4354 | |||
4355 | __set_chan_timer(chan, L2CAP_MOVE_TIMEOUT); | ||
4356 | } | ||
4357 | |||
4358 | static void l2cap_send_move_chan_cfm_icid(struct l2cap_conn *conn, u16 icid) | ||
4359 | { | ||
4360 | struct l2cap_move_chan_cfm cfm; | ||
4361 | |||
4362 | BT_DBG("conn %p, icid 0x%4.4x", conn, icid); | ||
4363 | |||
4364 | cfm.icid = cpu_to_le16(icid); | ||
4365 | cfm.result = __constant_cpu_to_le16(L2CAP_MC_UNCONFIRMED); | ||
4366 | |||
4367 | l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_MOVE_CHAN_CFM, | ||
4368 | sizeof(cfm), &cfm); | ||
4033 | } | 4369 | } |
4034 | 4370 | ||
4035 | static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, | 4371 | static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, |
@@ -4043,11 +4379,289 @@ static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, | |||
4043 | l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM_RSP, sizeof(rsp), &rsp); | 4379 | l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM_RSP, sizeof(rsp), &rsp); |
4044 | } | 4380 | } |
4045 | 4381 | ||
4382 | static void __release_logical_link(struct l2cap_chan *chan) | ||
4383 | { | ||
4384 | chan->hs_hchan = NULL; | ||
4385 | chan->hs_hcon = NULL; | ||
4386 | |||
4387 | /* Placeholder - release the logical link */ | ||
4388 | } | ||
4389 | |||
4390 | static void l2cap_logical_fail(struct l2cap_chan *chan) | ||
4391 | { | ||
4392 | /* Logical link setup failed */ | ||
4393 | if (chan->state != BT_CONNECTED) { | ||
4394 | /* Create channel failure, disconnect */ | ||
4395 | l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); | ||
4396 | return; | ||
4397 | } | ||
4398 | |||
4399 | switch (chan->move_role) { | ||
4400 | case L2CAP_MOVE_ROLE_RESPONDER: | ||
4401 | l2cap_move_done(chan); | ||
4402 | l2cap_send_move_chan_rsp(chan, L2CAP_MR_NOT_SUPP); | ||
4403 | break; | ||
4404 | case L2CAP_MOVE_ROLE_INITIATOR: | ||
4405 | if (chan->move_state == L2CAP_MOVE_WAIT_LOGICAL_COMP || | ||
4406 | chan->move_state == L2CAP_MOVE_WAIT_LOGICAL_CFM) { | ||
4407 | /* Remote has only sent pending or | ||
4408 | * success responses, clean up | ||
4409 | */ | ||
4410 | l2cap_move_done(chan); | ||
4411 | } | ||
4412 | |||
4413 | /* Other amp move states imply that the move | ||
4414 | * has already aborted | ||
4415 | */ | ||
4416 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_UNCONFIRMED); | ||
4417 | break; | ||
4418 | } | ||
4419 | } | ||
4420 | |||
4421 | static void l2cap_logical_finish_create(struct l2cap_chan *chan, | ||
4422 | struct hci_chan *hchan) | ||
4423 | { | ||
4424 | struct l2cap_conf_rsp rsp; | ||
4425 | |||
4426 | chan->hs_hchan = hchan; | ||
4427 | chan->hs_hcon->l2cap_data = chan->conn; | ||
4428 | |||
4429 | l2cap_send_efs_conf_rsp(chan, &rsp, chan->ident, 0); | ||
4430 | |||
4431 | if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) { | ||
4432 | int err; | ||
4433 | |||
4434 | set_default_fcs(chan); | ||
4435 | |||
4436 | err = l2cap_ertm_init(chan); | ||
4437 | if (err < 0) | ||
4438 | l2cap_send_disconn_req(chan->conn, chan, -err); | ||
4439 | else | ||
4440 | l2cap_chan_ready(chan); | ||
4441 | } | ||
4442 | } | ||
4443 | |||
4444 | static void l2cap_logical_finish_move(struct l2cap_chan *chan, | ||
4445 | struct hci_chan *hchan) | ||
4446 | { | ||
4447 | chan->hs_hcon = hchan->conn; | ||
4448 | chan->hs_hcon->l2cap_data = chan->conn; | ||
4449 | |||
4450 | BT_DBG("move_state %d", chan->move_state); | ||
4451 | |||
4452 | switch (chan->move_state) { | ||
4453 | case L2CAP_MOVE_WAIT_LOGICAL_COMP: | ||
4454 | /* Move confirm will be sent after a success | ||
4455 | * response is received | ||
4456 | */ | ||
4457 | chan->move_state = L2CAP_MOVE_WAIT_RSP_SUCCESS; | ||
4458 | break; | ||
4459 | case L2CAP_MOVE_WAIT_LOGICAL_CFM: | ||
4460 | if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { | ||
4461 | chan->move_state = L2CAP_MOVE_WAIT_LOCAL_BUSY; | ||
4462 | } else if (chan->move_role == L2CAP_MOVE_ROLE_INITIATOR) { | ||
4463 | chan->move_state = L2CAP_MOVE_WAIT_CONFIRM_RSP; | ||
4464 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_CONFIRMED); | ||
4465 | } else if (chan->move_role == L2CAP_MOVE_ROLE_RESPONDER) { | ||
4466 | chan->move_state = L2CAP_MOVE_WAIT_CONFIRM; | ||
4467 | l2cap_send_move_chan_rsp(chan, L2CAP_MR_SUCCESS); | ||
4468 | } | ||
4469 | break; | ||
4470 | default: | ||
4471 | /* Move was not in expected state, free the channel */ | ||
4472 | __release_logical_link(chan); | ||
4473 | |||
4474 | chan->move_state = L2CAP_MOVE_STABLE; | ||
4475 | } | ||
4476 | } | ||
4477 | |||
4478 | /* Call with chan locked */ | ||
4479 | void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan, | ||
4480 | u8 status) | ||
4481 | { | ||
4482 | BT_DBG("chan %p, hchan %p, status %d", chan, hchan, status); | ||
4483 | |||
4484 | if (status) { | ||
4485 | l2cap_logical_fail(chan); | ||
4486 | __release_logical_link(chan); | ||
4487 | return; | ||
4488 | } | ||
4489 | |||
4490 | if (chan->state != BT_CONNECTED) { | ||
4491 | /* Ignore logical link if channel is on BR/EDR */ | ||
4492 | if (chan->local_amp_id) | ||
4493 | l2cap_logical_finish_create(chan, hchan); | ||
4494 | } else { | ||
4495 | l2cap_logical_finish_move(chan, hchan); | ||
4496 | } | ||
4497 | } | ||
4498 | |||
4499 | void l2cap_move_start(struct l2cap_chan *chan) | ||
4500 | { | ||
4501 | BT_DBG("chan %p", chan); | ||
4502 | |||
4503 | if (chan->local_amp_id == HCI_BREDR_ID) { | ||
4504 | if (chan->chan_policy != BT_CHANNEL_POLICY_AMP_PREFERRED) | ||
4505 | return; | ||
4506 | chan->move_role = L2CAP_MOVE_ROLE_INITIATOR; | ||
4507 | chan->move_state = L2CAP_MOVE_WAIT_PREPARE; | ||
4508 | /* Placeholder - start physical link setup */ | ||
4509 | } else { | ||
4510 | chan->move_role = L2CAP_MOVE_ROLE_INITIATOR; | ||
4511 | chan->move_state = L2CAP_MOVE_WAIT_RSP_SUCCESS; | ||
4512 | chan->move_id = 0; | ||
4513 | l2cap_move_setup(chan); | ||
4514 | l2cap_send_move_chan_req(chan, 0); | ||
4515 | } | ||
4516 | } | ||
4517 | |||
4518 | static void l2cap_do_create(struct l2cap_chan *chan, int result, | ||
4519 | u8 local_amp_id, u8 remote_amp_id) | ||
4520 | { | ||
4521 | BT_DBG("chan %p state %s %u -> %u", chan, state_to_string(chan->state), | ||
4522 | local_amp_id, remote_amp_id); | ||
4523 | |||
4524 | chan->fcs = L2CAP_FCS_NONE; | ||
4525 | |||
4526 | /* Outgoing channel on AMP */ | ||
4527 | if (chan->state == BT_CONNECT) { | ||
4528 | if (result == L2CAP_CR_SUCCESS) { | ||
4529 | chan->local_amp_id = local_amp_id; | ||
4530 | l2cap_send_create_chan_req(chan, remote_amp_id); | ||
4531 | } else { | ||
4532 | /* Revert to BR/EDR connect */ | ||
4533 | l2cap_send_conn_req(chan); | ||
4534 | } | ||
4535 | |||
4536 | return; | ||
4537 | } | ||
4538 | |||
4539 | /* Incoming channel on AMP */ | ||
4540 | if (__l2cap_no_conn_pending(chan)) { | ||
4541 | struct l2cap_conn_rsp rsp; | ||
4542 | char buf[128]; | ||
4543 | rsp.scid = cpu_to_le16(chan->dcid); | ||
4544 | rsp.dcid = cpu_to_le16(chan->scid); | ||
4545 | |||
4546 | if (result == L2CAP_CR_SUCCESS) { | ||
4547 | /* Send successful response */ | ||
4548 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS); | ||
4549 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | ||
4550 | } else { | ||
4551 | /* Send negative response */ | ||
4552 | rsp.result = __constant_cpu_to_le16(L2CAP_CR_NO_MEM); | ||
4553 | rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO); | ||
4554 | } | ||
4555 | |||
4556 | l2cap_send_cmd(chan->conn, chan->ident, L2CAP_CREATE_CHAN_RSP, | ||
4557 | sizeof(rsp), &rsp); | ||
4558 | |||
4559 | if (result == L2CAP_CR_SUCCESS) { | ||
4560 | __l2cap_state_change(chan, BT_CONFIG); | ||
4561 | set_bit(CONF_REQ_SENT, &chan->conf_state); | ||
4562 | l2cap_send_cmd(chan->conn, l2cap_get_ident(chan->conn), | ||
4563 | L2CAP_CONF_REQ, | ||
4564 | l2cap_build_conf_req(chan, buf), buf); | ||
4565 | chan->num_conf_req++; | ||
4566 | } | ||
4567 | } | ||
4568 | } | ||
4569 | |||
4570 | static void l2cap_do_move_initiate(struct l2cap_chan *chan, u8 local_amp_id, | ||
4571 | u8 remote_amp_id) | ||
4572 | { | ||
4573 | l2cap_move_setup(chan); | ||
4574 | chan->move_id = local_amp_id; | ||
4575 | chan->move_state = L2CAP_MOVE_WAIT_RSP; | ||
4576 | |||
4577 | l2cap_send_move_chan_req(chan, remote_amp_id); | ||
4578 | } | ||
4579 | |||
4580 | static void l2cap_do_move_respond(struct l2cap_chan *chan, int result) | ||
4581 | { | ||
4582 | struct hci_chan *hchan = NULL; | ||
4583 | |||
4584 | /* Placeholder - get hci_chan for logical link */ | ||
4585 | |||
4586 | if (hchan) { | ||
4587 | if (hchan->state == BT_CONNECTED) { | ||
4588 | /* Logical link is ready to go */ | ||
4589 | chan->hs_hcon = hchan->conn; | ||
4590 | chan->hs_hcon->l2cap_data = chan->conn; | ||
4591 | chan->move_state = L2CAP_MOVE_WAIT_CONFIRM; | ||
4592 | l2cap_send_move_chan_rsp(chan, L2CAP_MR_SUCCESS); | ||
4593 | |||
4594 | l2cap_logical_cfm(chan, hchan, L2CAP_MR_SUCCESS); | ||
4595 | } else { | ||
4596 | /* Wait for logical link to be ready */ | ||
4597 | chan->move_state = L2CAP_MOVE_WAIT_LOGICAL_CFM; | ||
4598 | } | ||
4599 | } else { | ||
4600 | /* Logical link not available */ | ||
4601 | l2cap_send_move_chan_rsp(chan, L2CAP_MR_NOT_ALLOWED); | ||
4602 | } | ||
4603 | } | ||
4604 | |||
4605 | static void l2cap_do_move_cancel(struct l2cap_chan *chan, int result) | ||
4606 | { | ||
4607 | if (chan->move_role == L2CAP_MOVE_ROLE_RESPONDER) { | ||
4608 | u8 rsp_result; | ||
4609 | if (result == -EINVAL) | ||
4610 | rsp_result = L2CAP_MR_BAD_ID; | ||
4611 | else | ||
4612 | rsp_result = L2CAP_MR_NOT_ALLOWED; | ||
4613 | |||
4614 | l2cap_send_move_chan_rsp(chan, rsp_result); | ||
4615 | } | ||
4616 | |||
4617 | chan->move_role = L2CAP_MOVE_ROLE_NONE; | ||
4618 | chan->move_state = L2CAP_MOVE_STABLE; | ||
4619 | |||
4620 | /* Restart data transmission */ | ||
4621 | l2cap_ertm_send(chan); | ||
4622 | } | ||
4623 | |||
4624 | /* Invoke with locked chan */ | ||
4625 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result) | ||
4626 | { | ||
4627 | u8 local_amp_id = chan->local_amp_id; | ||
4628 | u8 remote_amp_id = chan->remote_amp_id; | ||
4629 | |||
4630 | BT_DBG("chan %p, result %d, local_amp_id %d, remote_amp_id %d", | ||
4631 | chan, result, local_amp_id, remote_amp_id); | ||
4632 | |||
4633 | if (chan->state == BT_DISCONN || chan->state == BT_CLOSED) { | ||
4634 | l2cap_chan_unlock(chan); | ||
4635 | return; | ||
4636 | } | ||
4637 | |||
4638 | if (chan->state != BT_CONNECTED) { | ||
4639 | l2cap_do_create(chan, result, local_amp_id, remote_amp_id); | ||
4640 | } else if (result != L2CAP_MR_SUCCESS) { | ||
4641 | l2cap_do_move_cancel(chan, result); | ||
4642 | } else { | ||
4643 | switch (chan->move_role) { | ||
4644 | case L2CAP_MOVE_ROLE_INITIATOR: | ||
4645 | l2cap_do_move_initiate(chan, local_amp_id, | ||
4646 | remote_amp_id); | ||
4647 | break; | ||
4648 | case L2CAP_MOVE_ROLE_RESPONDER: | ||
4649 | l2cap_do_move_respond(chan, result); | ||
4650 | break; | ||
4651 | default: | ||
4652 | l2cap_do_move_cancel(chan, result); | ||
4653 | break; | ||
4654 | } | ||
4655 | } | ||
4656 | } | ||
4657 | |||
4046 | static inline int l2cap_move_channel_req(struct l2cap_conn *conn, | 4658 | static inline int l2cap_move_channel_req(struct l2cap_conn *conn, |
4047 | struct l2cap_cmd_hdr *cmd, | 4659 | struct l2cap_cmd_hdr *cmd, |
4048 | u16 cmd_len, void *data) | 4660 | u16 cmd_len, void *data) |
4049 | { | 4661 | { |
4050 | struct l2cap_move_chan_req *req = data; | 4662 | struct l2cap_move_chan_req *req = data; |
4663 | struct l2cap_move_chan_rsp rsp; | ||
4664 | struct l2cap_chan *chan; | ||
4051 | u16 icid = 0; | 4665 | u16 icid = 0; |
4052 | u16 result = L2CAP_MR_NOT_ALLOWED; | 4666 | u16 result = L2CAP_MR_NOT_ALLOWED; |
4053 | 4667 | ||
@@ -4061,15 +4675,206 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn, | |||
4061 | if (!enable_hs) | 4675 | if (!enable_hs) |
4062 | return -EINVAL; | 4676 | return -EINVAL; |
4063 | 4677 | ||
4064 | /* Placeholder: Always refuse */ | 4678 | chan = l2cap_get_chan_by_dcid(conn, icid); |
4065 | l2cap_send_move_chan_rsp(conn, cmd->ident, icid, result); | 4679 | if (!chan) { |
4680 | rsp.icid = cpu_to_le16(icid); | ||
4681 | rsp.result = __constant_cpu_to_le16(L2CAP_MR_NOT_ALLOWED); | ||
4682 | l2cap_send_cmd(conn, cmd->ident, L2CAP_MOVE_CHAN_RSP, | ||
4683 | sizeof(rsp), &rsp); | ||
4684 | return 0; | ||
4685 | } | ||
4686 | |||
4687 | chan->ident = cmd->ident; | ||
4688 | |||
4689 | if (chan->scid < L2CAP_CID_DYN_START || | ||
4690 | chan->chan_policy == BT_CHANNEL_POLICY_BREDR_ONLY || | ||
4691 | (chan->mode != L2CAP_MODE_ERTM && | ||
4692 | chan->mode != L2CAP_MODE_STREAMING)) { | ||
4693 | result = L2CAP_MR_NOT_ALLOWED; | ||
4694 | goto send_move_response; | ||
4695 | } | ||
4696 | |||
4697 | if (chan->local_amp_id == req->dest_amp_id) { | ||
4698 | result = L2CAP_MR_SAME_ID; | ||
4699 | goto send_move_response; | ||
4700 | } | ||
4701 | |||
4702 | if (req->dest_amp_id) { | ||
4703 | struct hci_dev *hdev; | ||
4704 | hdev = hci_dev_get(req->dest_amp_id); | ||
4705 | if (!hdev || hdev->dev_type != HCI_AMP || | ||
4706 | !test_bit(HCI_UP, &hdev->flags)) { | ||
4707 | if (hdev) | ||
4708 | hci_dev_put(hdev); | ||
4709 | |||
4710 | result = L2CAP_MR_BAD_ID; | ||
4711 | goto send_move_response; | ||
4712 | } | ||
4713 | hci_dev_put(hdev); | ||
4714 | } | ||
4715 | |||
4716 | /* Detect a move collision. Only send a collision response | ||
4717 | * if this side has "lost", otherwise proceed with the move. | ||
4718 | * The winner has the larger bd_addr. | ||
4719 | */ | ||
4720 | if ((__chan_is_moving(chan) || | ||
4721 | chan->move_role != L2CAP_MOVE_ROLE_NONE) && | ||
4722 | bacmp(conn->src, conn->dst) > 0) { | ||
4723 | result = L2CAP_MR_COLLISION; | ||
4724 | goto send_move_response; | ||
4725 | } | ||
4726 | |||
4727 | chan->move_role = L2CAP_MOVE_ROLE_RESPONDER; | ||
4728 | l2cap_move_setup(chan); | ||
4729 | chan->move_id = req->dest_amp_id; | ||
4730 | icid = chan->dcid; | ||
4731 | |||
4732 | if (!req->dest_amp_id) { | ||
4733 | /* Moving to BR/EDR */ | ||
4734 | if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { | ||
4735 | chan->move_state = L2CAP_MOVE_WAIT_LOCAL_BUSY; | ||
4736 | result = L2CAP_MR_PEND; | ||
4737 | } else { | ||
4738 | chan->move_state = L2CAP_MOVE_WAIT_CONFIRM; | ||
4739 | result = L2CAP_MR_SUCCESS; | ||
4740 | } | ||
4741 | } else { | ||
4742 | chan->move_state = L2CAP_MOVE_WAIT_PREPARE; | ||
4743 | /* Placeholder - uncomment when amp functions are available */ | ||
4744 | /*amp_accept_physical(chan, req->dest_amp_id);*/ | ||
4745 | result = L2CAP_MR_PEND; | ||
4746 | } | ||
4747 | |||
4748 | send_move_response: | ||
4749 | l2cap_send_move_chan_rsp(chan, result); | ||
4750 | |||
4751 | l2cap_chan_unlock(chan); | ||
4066 | 4752 | ||
4067 | return 0; | 4753 | return 0; |
4068 | } | 4754 | } |
4069 | 4755 | ||
4070 | static inline int l2cap_move_channel_rsp(struct l2cap_conn *conn, | 4756 | static void l2cap_move_continue(struct l2cap_conn *conn, u16 icid, u16 result) |
4071 | struct l2cap_cmd_hdr *cmd, | 4757 | { |
4072 | u16 cmd_len, void *data) | 4758 | struct l2cap_chan *chan; |
4759 | struct hci_chan *hchan = NULL; | ||
4760 | |||
4761 | chan = l2cap_get_chan_by_scid(conn, icid); | ||
4762 | if (!chan) { | ||
4763 | l2cap_send_move_chan_cfm_icid(conn, icid); | ||
4764 | return; | ||
4765 | } | ||
4766 | |||
4767 | __clear_chan_timer(chan); | ||
4768 | if (result == L2CAP_MR_PEND) | ||
4769 | __set_chan_timer(chan, L2CAP_MOVE_ERTX_TIMEOUT); | ||
4770 | |||
4771 | switch (chan->move_state) { | ||
4772 | case L2CAP_MOVE_WAIT_LOGICAL_COMP: | ||
4773 | /* Move confirm will be sent when logical link | ||
4774 | * is complete. | ||
4775 | */ | ||
4776 | chan->move_state = L2CAP_MOVE_WAIT_LOGICAL_CFM; | ||
4777 | break; | ||
4778 | case L2CAP_MOVE_WAIT_RSP_SUCCESS: | ||
4779 | if (result == L2CAP_MR_PEND) { | ||
4780 | break; | ||
4781 | } else if (test_bit(CONN_LOCAL_BUSY, | ||
4782 | &chan->conn_state)) { | ||
4783 | chan->move_state = L2CAP_MOVE_WAIT_LOCAL_BUSY; | ||
4784 | } else { | ||
4785 | /* Logical link is up or moving to BR/EDR, | ||
4786 | * proceed with move | ||
4787 | */ | ||
4788 | chan->move_state = L2CAP_MOVE_WAIT_CONFIRM_RSP; | ||
4789 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_CONFIRMED); | ||
4790 | } | ||
4791 | break; | ||
4792 | case L2CAP_MOVE_WAIT_RSP: | ||
4793 | /* Moving to AMP */ | ||
4794 | if (result == L2CAP_MR_SUCCESS) { | ||
4795 | /* Remote is ready, send confirm immediately | ||
4796 | * after logical link is ready | ||
4797 | */ | ||
4798 | chan->move_state = L2CAP_MOVE_WAIT_LOGICAL_CFM; | ||
4799 | } else { | ||
4800 | /* Both logical link and move success | ||
4801 | * are required to confirm | ||
4802 | */ | ||
4803 | chan->move_state = L2CAP_MOVE_WAIT_LOGICAL_COMP; | ||
4804 | } | ||
4805 | |||
4806 | /* Placeholder - get hci_chan for logical link */ | ||
4807 | if (!hchan) { | ||
4808 | /* Logical link not available */ | ||
4809 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_UNCONFIRMED); | ||
4810 | break; | ||
4811 | } | ||
4812 | |||
4813 | /* If the logical link is not yet connected, do not | ||
4814 | * send confirmation. | ||
4815 | */ | ||
4816 | if (hchan->state != BT_CONNECTED) | ||
4817 | break; | ||
4818 | |||
4819 | /* Logical link is already ready to go */ | ||
4820 | |||
4821 | chan->hs_hcon = hchan->conn; | ||
4822 | chan->hs_hcon->l2cap_data = chan->conn; | ||
4823 | |||
4824 | if (result == L2CAP_MR_SUCCESS) { | ||
4825 | /* Can confirm now */ | ||
4826 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_CONFIRMED); | ||
4827 | } else { | ||
4828 | /* Now only need move success | ||
4829 | * to confirm | ||
4830 | */ | ||
4831 | chan->move_state = L2CAP_MOVE_WAIT_RSP_SUCCESS; | ||
4832 | } | ||
4833 | |||
4834 | l2cap_logical_cfm(chan, hchan, L2CAP_MR_SUCCESS); | ||
4835 | break; | ||
4836 | default: | ||
4837 | /* Any other amp move state means the move failed. */ | ||
4838 | chan->move_id = chan->local_amp_id; | ||
4839 | l2cap_move_done(chan); | ||
4840 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_UNCONFIRMED); | ||
4841 | } | ||
4842 | |||
4843 | l2cap_chan_unlock(chan); | ||
4844 | } | ||
4845 | |||
4846 | static void l2cap_move_fail(struct l2cap_conn *conn, u8 ident, u16 icid, | ||
4847 | u16 result) | ||
4848 | { | ||
4849 | struct l2cap_chan *chan; | ||
4850 | |||
4851 | chan = l2cap_get_chan_by_ident(conn, ident); | ||
4852 | if (!chan) { | ||
4853 | /* Could not locate channel, icid is best guess */ | ||
4854 | l2cap_send_move_chan_cfm_icid(conn, icid); | ||
4855 | return; | ||
4856 | } | ||
4857 | |||
4858 | __clear_chan_timer(chan); | ||
4859 | |||
4860 | if (chan->move_role == L2CAP_MOVE_ROLE_INITIATOR) { | ||
4861 | if (result == L2CAP_MR_COLLISION) { | ||
4862 | chan->move_role = L2CAP_MOVE_ROLE_RESPONDER; | ||
4863 | } else { | ||
4864 | /* Cleanup - cancel move */ | ||
4865 | chan->move_id = chan->local_amp_id; | ||
4866 | l2cap_move_done(chan); | ||
4867 | } | ||
4868 | } | ||
4869 | |||
4870 | l2cap_send_move_chan_cfm(chan, L2CAP_MC_UNCONFIRMED); | ||
4871 | |||
4872 | l2cap_chan_unlock(chan); | ||
4873 | } | ||
4874 | |||
4875 | static int l2cap_move_channel_rsp(struct l2cap_conn *conn, | ||
4876 | struct l2cap_cmd_hdr *cmd, | ||
4877 | u16 cmd_len, void *data) | ||
4073 | { | 4878 | { |
4074 | struct l2cap_move_chan_rsp *rsp = data; | 4879 | struct l2cap_move_chan_rsp *rsp = data; |
4075 | u16 icid, result; | 4880 | u16 icid, result; |
@@ -4082,17 +4887,20 @@ static inline int l2cap_move_channel_rsp(struct l2cap_conn *conn, | |||
4082 | 4887 | ||
4083 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); | 4888 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); |
4084 | 4889 | ||
4085 | /* Placeholder: Always unconfirmed */ | 4890 | if (result == L2CAP_MR_SUCCESS || result == L2CAP_MR_PEND) |
4086 | l2cap_send_move_chan_cfm(conn, NULL, icid, L2CAP_MC_UNCONFIRMED); | 4891 | l2cap_move_continue(conn, icid, result); |
4892 | else | ||
4893 | l2cap_move_fail(conn, cmd->ident, icid, result); | ||
4087 | 4894 | ||
4088 | return 0; | 4895 | return 0; |
4089 | } | 4896 | } |
4090 | 4897 | ||
4091 | static inline int l2cap_move_channel_confirm(struct l2cap_conn *conn, | 4898 | static int l2cap_move_channel_confirm(struct l2cap_conn *conn, |
4092 | struct l2cap_cmd_hdr *cmd, | 4899 | struct l2cap_cmd_hdr *cmd, |
4093 | u16 cmd_len, void *data) | 4900 | u16 cmd_len, void *data) |
4094 | { | 4901 | { |
4095 | struct l2cap_move_chan_cfm *cfm = data; | 4902 | struct l2cap_move_chan_cfm *cfm = data; |
4903 | struct l2cap_chan *chan; | ||
4096 | u16 icid, result; | 4904 | u16 icid, result; |
4097 | 4905 | ||
4098 | if (cmd_len != sizeof(*cfm)) | 4906 | if (cmd_len != sizeof(*cfm)) |
@@ -4103,8 +4911,29 @@ static inline int l2cap_move_channel_confirm(struct l2cap_conn *conn, | |||
4103 | 4911 | ||
4104 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); | 4912 | BT_DBG("icid 0x%4.4x, result 0x%4.4x", icid, result); |
4105 | 4913 | ||
4914 | chan = l2cap_get_chan_by_dcid(conn, icid); | ||
4915 | if (!chan) { | ||
4916 | /* Spec requires a response even if the icid was not found */ | ||
4917 | l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); | ||
4918 | return 0; | ||
4919 | } | ||
4920 | |||
4921 | if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM) { | ||
4922 | if (result == L2CAP_MC_CONFIRMED) { | ||
4923 | chan->local_amp_id = chan->move_id; | ||
4924 | if (!chan->local_amp_id) | ||
4925 | __release_logical_link(chan); | ||
4926 | } else { | ||
4927 | chan->move_id = chan->local_amp_id; | ||
4928 | } | ||
4929 | |||
4930 | l2cap_move_done(chan); | ||
4931 | } | ||
4932 | |||
4106 | l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); | 4933 | l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); |
4107 | 4934 | ||
4935 | l2cap_chan_unlock(chan); | ||
4936 | |||
4108 | return 0; | 4937 | return 0; |
4109 | } | 4938 | } |
4110 | 4939 | ||
@@ -4113,6 +4942,7 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, | |||
4113 | u16 cmd_len, void *data) | 4942 | u16 cmd_len, void *data) |
4114 | { | 4943 | { |
4115 | struct l2cap_move_chan_cfm_rsp *rsp = data; | 4944 | struct l2cap_move_chan_cfm_rsp *rsp = data; |
4945 | struct l2cap_chan *chan; | ||
4116 | u16 icid; | 4946 | u16 icid; |
4117 | 4947 | ||
4118 | if (cmd_len != sizeof(*rsp)) | 4948 | if (cmd_len != sizeof(*rsp)) |
@@ -4122,11 +4952,28 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, | |||
4122 | 4952 | ||
4123 | BT_DBG("icid 0x%4.4x", icid); | 4953 | BT_DBG("icid 0x%4.4x", icid); |
4124 | 4954 | ||
4955 | chan = l2cap_get_chan_by_scid(conn, icid); | ||
4956 | if (!chan) | ||
4957 | return 0; | ||
4958 | |||
4959 | __clear_chan_timer(chan); | ||
4960 | |||
4961 | if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM_RSP) { | ||
4962 | chan->local_amp_id = chan->move_id; | ||
4963 | |||
4964 | if (!chan->local_amp_id && chan->hs_hchan) | ||
4965 | __release_logical_link(chan); | ||
4966 | |||
4967 | l2cap_move_done(chan); | ||
4968 | } | ||
4969 | |||
4970 | l2cap_chan_unlock(chan); | ||
4971 | |||
4125 | return 0; | 4972 | return 0; |
4126 | } | 4973 | } |
4127 | 4974 | ||
4128 | static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, | 4975 | static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, |
4129 | u16 to_multiplier) | 4976 | u16 to_multiplier) |
4130 | { | 4977 | { |
4131 | u16 max_latency; | 4978 | u16 max_latency; |
4132 | 4979 | ||
@@ -4147,7 +4994,8 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency, | |||
4147 | } | 4994 | } |
4148 | 4995 | ||
4149 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | 4996 | static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, |
4150 | struct l2cap_cmd_hdr *cmd, u8 *data) | 4997 | struct l2cap_cmd_hdr *cmd, |
4998 | u8 *data) | ||
4151 | { | 4999 | { |
4152 | struct hci_conn *hcon = conn->hcon; | 5000 | struct hci_conn *hcon = conn->hcon; |
4153 | struct l2cap_conn_param_update_req *req; | 5001 | struct l2cap_conn_param_update_req *req; |
@@ -4169,7 +5017,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4169 | to_multiplier = __le16_to_cpu(req->to_multiplier); | 5017 | to_multiplier = __le16_to_cpu(req->to_multiplier); |
4170 | 5018 | ||
4171 | BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x", | 5019 | BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x", |
4172 | min, max, latency, to_multiplier); | 5020 | min, max, latency, to_multiplier); |
4173 | 5021 | ||
4174 | memset(&rsp, 0, sizeof(rsp)); | 5022 | memset(&rsp, 0, sizeof(rsp)); |
4175 | 5023 | ||
@@ -4180,7 +5028,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4180 | rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED); | 5028 | rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED); |
4181 | 5029 | ||
4182 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP, | 5030 | l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP, |
4183 | sizeof(rsp), &rsp); | 5031 | sizeof(rsp), &rsp); |
4184 | 5032 | ||
4185 | if (!err) | 5033 | if (!err) |
4186 | hci_le_conn_update(hcon, min, max, latency, to_multiplier); | 5034 | hci_le_conn_update(hcon, min, max, latency, to_multiplier); |
@@ -4189,7 +5037,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn, | |||
4189 | } | 5037 | } |
4190 | 5038 | ||
4191 | static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | 5039 | static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, |
4192 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) | 5040 | struct l2cap_cmd_hdr *cmd, u16 cmd_len, |
5041 | u8 *data) | ||
4193 | { | 5042 | { |
4194 | int err = 0; | 5043 | int err = 0; |
4195 | 5044 | ||
@@ -4203,7 +5052,8 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | |||
4203 | break; | 5052 | break; |
4204 | 5053 | ||
4205 | case L2CAP_CONN_RSP: | 5054 | case L2CAP_CONN_RSP: |
4206 | err = l2cap_connect_rsp(conn, cmd, data); | 5055 | case L2CAP_CREATE_CHAN_RSP: |
5056 | err = l2cap_connect_create_rsp(conn, cmd, data); | ||
4207 | break; | 5057 | break; |
4208 | 5058 | ||
4209 | case L2CAP_CONF_REQ: | 5059 | case L2CAP_CONF_REQ: |
@@ -4241,10 +5091,6 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | |||
4241 | err = l2cap_create_channel_req(conn, cmd, cmd_len, data); | 5091 | err = l2cap_create_channel_req(conn, cmd, cmd_len, data); |
4242 | break; | 5092 | break; |
4243 | 5093 | ||
4244 | case L2CAP_CREATE_CHAN_RSP: | ||
4245 | err = l2cap_create_channel_rsp(conn, cmd, data); | ||
4246 | break; | ||
4247 | |||
4248 | case L2CAP_MOVE_CHAN_REQ: | 5094 | case L2CAP_MOVE_CHAN_REQ: |
4249 | err = l2cap_move_channel_req(conn, cmd, cmd_len, data); | 5095 | err = l2cap_move_channel_req(conn, cmd, cmd_len, data); |
4250 | break; | 5096 | break; |
@@ -4271,7 +5117,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn, | |||
4271 | } | 5117 | } |
4272 | 5118 | ||
4273 | static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, | 5119 | static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, |
4274 | struct l2cap_cmd_hdr *cmd, u8 *data) | 5120 | struct l2cap_cmd_hdr *cmd, u8 *data) |
4275 | { | 5121 | { |
4276 | switch (cmd->code) { | 5122 | switch (cmd->code) { |
4277 | case L2CAP_COMMAND_REJ: | 5123 | case L2CAP_COMMAND_REJ: |
@@ -4290,7 +5136,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, | |||
4290 | } | 5136 | } |
4291 | 5137 | ||
4292 | static inline void l2cap_sig_channel(struct l2cap_conn *conn, | 5138 | static inline void l2cap_sig_channel(struct l2cap_conn *conn, |
4293 | struct sk_buff *skb) | 5139 | struct sk_buff *skb) |
4294 | { | 5140 | { |
4295 | u8 *data = skb->data; | 5141 | u8 *data = skb->data; |
4296 | int len = skb->len; | 5142 | int len = skb->len; |
@@ -4307,7 +5153,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, | |||
4307 | 5153 | ||
4308 | cmd_len = le16_to_cpu(cmd.len); | 5154 | cmd_len = le16_to_cpu(cmd.len); |
4309 | 5155 | ||
4310 | BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident); | 5156 | BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, |
5157 | cmd.ident); | ||
4311 | 5158 | ||
4312 | if (cmd_len > len || !cmd.ident) { | 5159 | if (cmd_len > len || !cmd.ident) { |
4313 | BT_DBG("corrupted command"); | 5160 | BT_DBG("corrupted command"); |
@@ -4326,7 +5173,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, | |||
4326 | 5173 | ||
4327 | /* FIXME: Map err to a valid reason */ | 5174 | /* FIXME: Map err to a valid reason */ |
4328 | rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD); | 5175 | rej.reason = __constant_cpu_to_le16(L2CAP_REJ_NOT_UNDERSTOOD); |
4329 | l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej); | 5176 | l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, |
5177 | sizeof(rej), &rej); | ||
4330 | } | 5178 | } |
4331 | 5179 | ||
4332 | data += cmd_len; | 5180 | data += cmd_len; |
@@ -4391,8 +5239,8 @@ static void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) | |||
4391 | } | 5239 | } |
4392 | } | 5240 | } |
4393 | 5241 | ||
4394 | static void append_skb_frag(struct sk_buff *skb, | 5242 | static void append_skb_frag(struct sk_buff *skb, struct sk_buff *new_frag, |
4395 | struct sk_buff *new_frag, struct sk_buff **last_frag) | 5243 | struct sk_buff **last_frag) |
4396 | { | 5244 | { |
4397 | /* skb->len reflects data in skb as well as all fragments | 5245 | /* skb->len reflects data in skb as well as all fragments |
4398 | * skb->data_len reflects only data in fragments | 5246 | * skb->data_len reflects only data in fragments |
@@ -4492,6 +5340,12 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, | |||
4492 | return err; | 5340 | return err; |
4493 | } | 5341 | } |
4494 | 5342 | ||
5343 | static int l2cap_resegment(struct l2cap_chan *chan) | ||
5344 | { | ||
5345 | /* Placeholder */ | ||
5346 | return 0; | ||
5347 | } | ||
5348 | |||
4495 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy) | 5349 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy) |
4496 | { | 5350 | { |
4497 | u8 event; | 5351 | u8 event; |
@@ -4641,7 +5495,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq) | |||
4641 | 5495 | ||
4642 | if (chan->rx_state == L2CAP_RX_STATE_SREJ_SENT) { | 5496 | if (chan->rx_state == L2CAP_RX_STATE_SREJ_SENT) { |
4643 | if (__seq_offset(chan, txseq, chan->last_acked_seq) >= | 5497 | if (__seq_offset(chan, txseq, chan->last_acked_seq) >= |
4644 | chan->tx_win) { | 5498 | chan->tx_win) { |
4645 | /* See notes below regarding "double poll" and | 5499 | /* See notes below regarding "double poll" and |
4646 | * invalid packets. | 5500 | * invalid packets. |
4647 | */ | 5501 | */ |
@@ -4682,8 +5536,7 @@ static u8 l2cap_classify_txseq(struct l2cap_chan *chan, u16 txseq) | |||
4682 | } | 5536 | } |
4683 | 5537 | ||
4684 | if (__seq_offset(chan, txseq, chan->last_acked_seq) < | 5538 | if (__seq_offset(chan, txseq, chan->last_acked_seq) < |
4685 | __seq_offset(chan, chan->expected_tx_seq, | 5539 | __seq_offset(chan, chan->expected_tx_seq, chan->last_acked_seq)) { |
4686 | chan->last_acked_seq)){ | ||
4687 | BT_DBG("Duplicate - expected_tx_seq later than txseq"); | 5540 | BT_DBG("Duplicate - expected_tx_seq later than txseq"); |
4688 | return L2CAP_TXSEQ_DUPLICATE; | 5541 | return L2CAP_TXSEQ_DUPLICATE; |
4689 | } | 5542 | } |
@@ -4808,8 +5661,8 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan, | |||
4808 | if (control->final) { | 5661 | if (control->final) { |
4809 | clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); | 5662 | clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); |
4810 | 5663 | ||
4811 | if (!test_and_clear_bit(CONN_REJ_ACT, | 5664 | if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state) && |
4812 | &chan->conn_state)) { | 5665 | !__chan_is_moving(chan)) { |
4813 | control->final = 0; | 5666 | control->final = 0; |
4814 | l2cap_retransmit_all(chan, control); | 5667 | l2cap_retransmit_all(chan, control); |
4815 | } | 5668 | } |
@@ -4998,6 +5851,96 @@ static int l2cap_rx_state_srej_sent(struct l2cap_chan *chan, | |||
4998 | return err; | 5851 | return err; |
4999 | } | 5852 | } |
5000 | 5853 | ||
5854 | static int l2cap_finish_move(struct l2cap_chan *chan) | ||
5855 | { | ||
5856 | BT_DBG("chan %p", chan); | ||
5857 | |||
5858 | chan->rx_state = L2CAP_RX_STATE_RECV; | ||
5859 | |||
5860 | if (chan->hs_hcon) | ||
5861 | chan->conn->mtu = chan->hs_hcon->hdev->block_mtu; | ||
5862 | else | ||
5863 | chan->conn->mtu = chan->conn->hcon->hdev->acl_mtu; | ||
5864 | |||
5865 | return l2cap_resegment(chan); | ||
5866 | } | ||
5867 | |||
5868 | static int l2cap_rx_state_wait_p(struct l2cap_chan *chan, | ||
5869 | struct l2cap_ctrl *control, | ||
5870 | struct sk_buff *skb, u8 event) | ||
5871 | { | ||
5872 | int err; | ||
5873 | |||
5874 | BT_DBG("chan %p, control %p, skb %p, event %d", chan, control, skb, | ||
5875 | event); | ||
5876 | |||
5877 | if (!control->poll) | ||
5878 | return -EPROTO; | ||
5879 | |||
5880 | l2cap_process_reqseq(chan, control->reqseq); | ||
5881 | |||
5882 | if (!skb_queue_empty(&chan->tx_q)) | ||
5883 | chan->tx_send_head = skb_peek(&chan->tx_q); | ||
5884 | else | ||
5885 | chan->tx_send_head = NULL; | ||
5886 | |||
5887 | /* Rewind next_tx_seq to the point expected | ||
5888 | * by the receiver. | ||
5889 | */ | ||
5890 | chan->next_tx_seq = control->reqseq; | ||
5891 | chan->unacked_frames = 0; | ||
5892 | |||
5893 | err = l2cap_finish_move(chan); | ||
5894 | if (err) | ||
5895 | return err; | ||
5896 | |||
5897 | set_bit(CONN_SEND_FBIT, &chan->conn_state); | ||
5898 | l2cap_send_i_or_rr_or_rnr(chan); | ||
5899 | |||
5900 | if (event == L2CAP_EV_RECV_IFRAME) | ||
5901 | return -EPROTO; | ||
5902 | |||
5903 | return l2cap_rx_state_recv(chan, control, NULL, event); | ||
5904 | } | ||
5905 | |||
5906 | static int l2cap_rx_state_wait_f(struct l2cap_chan *chan, | ||
5907 | struct l2cap_ctrl *control, | ||
5908 | struct sk_buff *skb, u8 event) | ||
5909 | { | ||
5910 | int err; | ||
5911 | |||
5912 | if (!control->final) | ||
5913 | return -EPROTO; | ||
5914 | |||
5915 | clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); | ||
5916 | |||
5917 | chan->rx_state = L2CAP_RX_STATE_RECV; | ||
5918 | l2cap_process_reqseq(chan, control->reqseq); | ||
5919 | |||
5920 | if (!skb_queue_empty(&chan->tx_q)) | ||
5921 | chan->tx_send_head = skb_peek(&chan->tx_q); | ||
5922 | else | ||
5923 | chan->tx_send_head = NULL; | ||
5924 | |||
5925 | /* Rewind next_tx_seq to the point expected | ||
5926 | * by the receiver. | ||
5927 | */ | ||
5928 | chan->next_tx_seq = control->reqseq; | ||
5929 | chan->unacked_frames = 0; | ||
5930 | |||
5931 | if (chan->hs_hcon) | ||
5932 | chan->conn->mtu = chan->hs_hcon->hdev->block_mtu; | ||
5933 | else | ||
5934 | chan->conn->mtu = chan->conn->hcon->hdev->acl_mtu; | ||
5935 | |||
5936 | err = l2cap_resegment(chan); | ||
5937 | |||
5938 | if (!err) | ||
5939 | err = l2cap_rx_state_recv(chan, control, skb, event); | ||
5940 | |||
5941 | return err; | ||
5942 | } | ||
5943 | |||
5001 | static bool __valid_reqseq(struct l2cap_chan *chan, u16 reqseq) | 5944 | static bool __valid_reqseq(struct l2cap_chan *chan, u16 reqseq) |
5002 | { | 5945 | { |
5003 | /* Make sure reqseq is for a packet that has been sent but not acked */ | 5946 | /* Make sure reqseq is for a packet that has been sent but not acked */ |
@@ -5024,6 +5967,12 @@ static int l2cap_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control, | |||
5024 | err = l2cap_rx_state_srej_sent(chan, control, skb, | 5967 | err = l2cap_rx_state_srej_sent(chan, control, skb, |
5025 | event); | 5968 | event); |
5026 | break; | 5969 | break; |
5970 | case L2CAP_RX_STATE_WAIT_P: | ||
5971 | err = l2cap_rx_state_wait_p(chan, control, skb, event); | ||
5972 | break; | ||
5973 | case L2CAP_RX_STATE_WAIT_F: | ||
5974 | err = l2cap_rx_state_wait_f(chan, control, skb, event); | ||
5975 | break; | ||
5027 | default: | 5976 | default: |
5028 | /* shut it down */ | 5977 | /* shut it down */ |
5029 | break; | 5978 | break; |
@@ -5143,7 +6092,7 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) | |||
5143 | control->super); | 6092 | control->super); |
5144 | 6093 | ||
5145 | if (len != 0) { | 6094 | if (len != 0) { |
5146 | BT_ERR("%d", len); | 6095 | BT_ERR("Trailing bytes: %d in sframe", len); |
5147 | l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); | 6096 | l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); |
5148 | goto drop; | 6097 | goto drop; |
5149 | } | 6098 | } |
@@ -5323,7 +6272,7 @@ int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
5323 | int exact = 0, lm1 = 0, lm2 = 0; | 6272 | int exact = 0, lm1 = 0, lm2 = 0; |
5324 | struct l2cap_chan *c; | 6273 | struct l2cap_chan *c; |
5325 | 6274 | ||
5326 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); | 6275 | BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr); |
5327 | 6276 | ||
5328 | /* Find listening sockets and check their link_mode */ | 6277 | /* Find listening sockets and check their link_mode */ |
5329 | read_lock(&chan_list_lock); | 6278 | read_lock(&chan_list_lock); |
@@ -5353,15 +6302,15 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status) | |||
5353 | { | 6302 | { |
5354 | struct l2cap_conn *conn; | 6303 | struct l2cap_conn *conn; |
5355 | 6304 | ||
5356 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); | 6305 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); |
5357 | 6306 | ||
5358 | if (!status) { | 6307 | if (!status) { |
5359 | conn = l2cap_conn_add(hcon, status); | 6308 | conn = l2cap_conn_add(hcon, status); |
5360 | if (conn) | 6309 | if (conn) |
5361 | l2cap_conn_ready(conn); | 6310 | l2cap_conn_ready(conn); |
5362 | } else | 6311 | } else { |
5363 | l2cap_conn_del(hcon, bt_to_errno(status)); | 6312 | l2cap_conn_del(hcon, bt_to_errno(status)); |
5364 | 6313 | } | |
5365 | } | 6314 | } |
5366 | 6315 | ||
5367 | int l2cap_disconn_ind(struct hci_conn *hcon) | 6316 | int l2cap_disconn_ind(struct hci_conn *hcon) |
@@ -5437,13 +6386,13 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5437 | continue; | 6386 | continue; |
5438 | } | 6387 | } |
5439 | 6388 | ||
5440 | if (test_bit(CONF_CONNECT_PEND, &chan->conf_state)) { | 6389 | if (!__l2cap_no_conn_pending(chan)) { |
5441 | l2cap_chan_unlock(chan); | 6390 | l2cap_chan_unlock(chan); |
5442 | continue; | 6391 | continue; |
5443 | } | 6392 | } |
5444 | 6393 | ||
5445 | if (!status && (chan->state == BT_CONNECTED || | 6394 | if (!status && (chan->state == BT_CONNECTED || |
5446 | chan->state == BT_CONFIG)) { | 6395 | chan->state == BT_CONFIG)) { |
5447 | struct sock *sk = chan->sk; | 6396 | struct sock *sk = chan->sk; |
5448 | 6397 | ||
5449 | clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); | 6398 | clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); |
@@ -5456,7 +6405,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5456 | 6405 | ||
5457 | if (chan->state == BT_CONNECT) { | 6406 | if (chan->state == BT_CONNECT) { |
5458 | if (!status) { | 6407 | if (!status) { |
5459 | l2cap_send_conn_req(chan); | 6408 | l2cap_start_connection(chan); |
5460 | } else { | 6409 | } else { |
5461 | __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); | 6410 | __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); |
5462 | } | 6411 | } |
@@ -5470,11 +6419,9 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5470 | if (!status) { | 6419 | if (!status) { |
5471 | if (test_bit(BT_SK_DEFER_SETUP, | 6420 | if (test_bit(BT_SK_DEFER_SETUP, |
5472 | &bt_sk(sk)->flags)) { | 6421 | &bt_sk(sk)->flags)) { |
5473 | struct sock *parent = bt_sk(sk)->parent; | ||
5474 | res = L2CAP_CR_PEND; | 6422 | res = L2CAP_CR_PEND; |
5475 | stat = L2CAP_CS_AUTHOR_PEND; | 6423 | stat = L2CAP_CS_AUTHOR_PEND; |
5476 | if (parent) | 6424 | chan->ops->defer(chan); |
5477 | parent->sk_data_ready(parent, 0); | ||
5478 | } else { | 6425 | } else { |
5479 | __l2cap_state_change(chan, BT_CONFIG); | 6426 | __l2cap_state_change(chan, BT_CONFIG); |
5480 | res = L2CAP_CR_SUCCESS; | 6427 | res = L2CAP_CR_SUCCESS; |
@@ -5494,7 +6441,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5494 | rsp.result = cpu_to_le16(res); | 6441 | rsp.result = cpu_to_le16(res); |
5495 | rsp.status = cpu_to_le16(stat); | 6442 | rsp.status = cpu_to_le16(stat); |
5496 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, | 6443 | l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, |
5497 | sizeof(rsp), &rsp); | 6444 | sizeof(rsp), &rsp); |
5498 | 6445 | ||
5499 | if (!test_bit(CONF_REQ_SENT, &chan->conf_state) && | 6446 | if (!test_bit(CONF_REQ_SENT, &chan->conf_state) && |
5500 | res == L2CAP_CR_SUCCESS) { | 6447 | res == L2CAP_CR_SUCCESS) { |
@@ -5519,6 +6466,12 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
5519 | int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | 6466 | int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) |
5520 | { | 6467 | { |
5521 | struct l2cap_conn *conn = hcon->l2cap_data; | 6468 | struct l2cap_conn *conn = hcon->l2cap_data; |
6469 | struct l2cap_hdr *hdr; | ||
6470 | int len; | ||
6471 | |||
6472 | /* For AMP controller do not create l2cap conn */ | ||
6473 | if (!conn && hcon->hdev->dev_type != HCI_BREDR) | ||
6474 | goto drop; | ||
5522 | 6475 | ||
5523 | if (!conn) | 6476 | if (!conn) |
5524 | conn = l2cap_conn_add(hcon, 0); | 6477 | conn = l2cap_conn_add(hcon, 0); |
@@ -5528,10 +6481,10 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5528 | 6481 | ||
5529 | BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags); | 6482 | BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags); |
5530 | 6483 | ||
5531 | if (!(flags & ACL_CONT)) { | 6484 | switch (flags) { |
5532 | struct l2cap_hdr *hdr; | 6485 | case ACL_START: |
5533 | int len; | 6486 | case ACL_START_NO_FLUSH: |
5534 | 6487 | case ACL_COMPLETE: | |
5535 | if (conn->rx_len) { | 6488 | if (conn->rx_len) { |
5536 | BT_ERR("Unexpected start frame (len %d)", skb->len); | 6489 | BT_ERR("Unexpected start frame (len %d)", skb->len); |
5537 | kfree_skb(conn->rx_skb); | 6490 | kfree_skb(conn->rx_skb); |
@@ -5560,20 +6513,22 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5560 | 6513 | ||
5561 | if (skb->len > len) { | 6514 | if (skb->len > len) { |
5562 | BT_ERR("Frame is too long (len %d, expected len %d)", | 6515 | BT_ERR("Frame is too long (len %d, expected len %d)", |
5563 | skb->len, len); | 6516 | skb->len, len); |
5564 | l2cap_conn_unreliable(conn, ECOMM); | 6517 | l2cap_conn_unreliable(conn, ECOMM); |
5565 | goto drop; | 6518 | goto drop; |
5566 | } | 6519 | } |
5567 | 6520 | ||
5568 | /* Allocate skb for the complete frame (with header) */ | 6521 | /* Allocate skb for the complete frame (with header) */ |
5569 | conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC); | 6522 | conn->rx_skb = bt_skb_alloc(len, GFP_KERNEL); |
5570 | if (!conn->rx_skb) | 6523 | if (!conn->rx_skb) |
5571 | goto drop; | 6524 | goto drop; |
5572 | 6525 | ||
5573 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), | 6526 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), |
5574 | skb->len); | 6527 | skb->len); |
5575 | conn->rx_len = len - skb->len; | 6528 | conn->rx_len = len - skb->len; |
5576 | } else { | 6529 | break; |
6530 | |||
6531 | case ACL_CONT: | ||
5577 | BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len); | 6532 | BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len); |
5578 | 6533 | ||
5579 | if (!conn->rx_len) { | 6534 | if (!conn->rx_len) { |
@@ -5584,7 +6539,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5584 | 6539 | ||
5585 | if (skb->len > conn->rx_len) { | 6540 | if (skb->len > conn->rx_len) { |
5586 | BT_ERR("Fragment is too long (len %d, expected %d)", | 6541 | BT_ERR("Fragment is too long (len %d, expected %d)", |
5587 | skb->len, conn->rx_len); | 6542 | skb->len, conn->rx_len); |
5588 | kfree_skb(conn->rx_skb); | 6543 | kfree_skb(conn->rx_skb); |
5589 | conn->rx_skb = NULL; | 6544 | conn->rx_skb = NULL; |
5590 | conn->rx_len = 0; | 6545 | conn->rx_len = 0; |
@@ -5593,7 +6548,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5593 | } | 6548 | } |
5594 | 6549 | ||
5595 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), | 6550 | skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), |
5596 | skb->len); | 6551 | skb->len); |
5597 | conn->rx_len -= skb->len; | 6552 | conn->rx_len -= skb->len; |
5598 | 6553 | ||
5599 | if (!conn->rx_len) { | 6554 | if (!conn->rx_len) { |
@@ -5601,6 +6556,7 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) | |||
5601 | l2cap_recv_frame(conn, conn->rx_skb); | 6556 | l2cap_recv_frame(conn, conn->rx_skb); |
5602 | conn->rx_skb = NULL; | 6557 | conn->rx_skb = NULL; |
5603 | } | 6558 | } |
6559 | break; | ||
5604 | } | 6560 | } |
5605 | 6561 | ||
5606 | drop: | 6562 | drop: |
@@ -5617,12 +6573,11 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p) | |||
5617 | list_for_each_entry(c, &chan_list, global_l) { | 6573 | list_for_each_entry(c, &chan_list, global_l) { |
5618 | struct sock *sk = c->sk; | 6574 | struct sock *sk = c->sk; |
5619 | 6575 | ||
5620 | seq_printf(f, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n", | 6576 | seq_printf(f, "%pMR %pMR %d %d 0x%4.4x 0x%4.4x %d %d %d %d\n", |
5621 | batostr(&bt_sk(sk)->src), | 6577 | &bt_sk(sk)->src, &bt_sk(sk)->dst, |
5622 | batostr(&bt_sk(sk)->dst), | 6578 | c->state, __le16_to_cpu(c->psm), |
5623 | c->state, __le16_to_cpu(c->psm), | 6579 | c->scid, c->dcid, c->imtu, c->omtu, |
5624 | c->scid, c->dcid, c->imtu, c->omtu, | 6580 | c->sec_level, c->mode); |
5625 | c->sec_level, c->mode); | ||
5626 | } | 6581 | } |
5627 | 6582 | ||
5628 | read_unlock(&chan_list_lock); | 6583 | read_unlock(&chan_list_lock); |
@@ -5653,8 +6608,8 @@ int __init l2cap_init(void) | |||
5653 | return err; | 6608 | return err; |
5654 | 6609 | ||
5655 | if (bt_debugfs) { | 6610 | if (bt_debugfs) { |
5656 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, | 6611 | l2cap_debugfs = debugfs_create_file("l2cap", 0444, bt_debugfs, |
5657 | bt_debugfs, NULL, &l2cap_debugfs_fops); | 6612 | NULL, &l2cap_debugfs_fops); |
5658 | if (!l2cap_debugfs) | 6613 | if (!l2cap_debugfs) |
5659 | BT_ERR("Failed to create L2CAP debug file"); | 6614 | BT_ERR("Failed to create L2CAP debug file"); |
5660 | } | 6615 | } |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 083f2bf065d4..1bcfb8422fdc 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -40,7 +40,8 @@ static struct bt_sock_list l2cap_sk_list = { | |||
40 | 40 | ||
41 | static const struct proto_ops l2cap_sock_ops; | 41 | static const struct proto_ops l2cap_sock_ops; |
42 | static void l2cap_sock_init(struct sock *sk, struct sock *parent); | 42 | static void l2cap_sock_init(struct sock *sk, struct sock *parent); |
43 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio); | 43 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
44 | int proto, gfp_t prio); | ||
44 | 45 | ||
45 | static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) | 46 | static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen) |
46 | { | 47 | { |
@@ -106,7 +107,8 @@ done: | |||
106 | return err; | 107 | return err; |
107 | } | 108 | } |
108 | 109 | ||
109 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int alen, int flags) | 110 | static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, |
111 | int alen, int flags) | ||
110 | { | 112 | { |
111 | struct sock *sk = sock->sk; | 113 | struct sock *sk = sock->sk; |
112 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 114 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -134,7 +136,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al | |||
134 | lock_sock(sk); | 136 | lock_sock(sk); |
135 | 137 | ||
136 | err = bt_sock_wait_state(sk, BT_CONNECTED, | 138 | err = bt_sock_wait_state(sk, BT_CONNECTED, |
137 | sock_sndtimeo(sk, flags & O_NONBLOCK)); | 139 | sock_sndtimeo(sk, flags & O_NONBLOCK)); |
138 | 140 | ||
139 | release_sock(sk); | 141 | release_sock(sk); |
140 | 142 | ||
@@ -185,7 +187,8 @@ done: | |||
185 | return err; | 187 | return err; |
186 | } | 188 | } |
187 | 189 | ||
188 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int flags) | 190 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, |
191 | int flags) | ||
189 | { | 192 | { |
190 | DECLARE_WAITQUEUE(wait, current); | 193 | DECLARE_WAITQUEUE(wait, current); |
191 | struct sock *sk = sock->sk, *nsk; | 194 | struct sock *sk = sock->sk, *nsk; |
@@ -241,7 +244,8 @@ done: | |||
241 | return err; | 244 | return err; |
242 | } | 245 | } |
243 | 246 | ||
244 | static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *len, int peer) | 247 | static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, |
248 | int *len, int peer) | ||
245 | { | 249 | { |
246 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; | 250 | struct sockaddr_l2 *la = (struct sockaddr_l2 *) addr; |
247 | struct sock *sk = sock->sk; | 251 | struct sock *sk = sock->sk; |
@@ -266,7 +270,8 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l | |||
266 | return 0; | 270 | return 0; |
267 | } | 271 | } |
268 | 272 | ||
269 | static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __user *optval, int __user *optlen) | 273 | static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, |
274 | char __user *optval, int __user *optlen) | ||
270 | { | 275 | { |
271 | struct sock *sk = sock->sk; | 276 | struct sock *sk = sock->sk; |
272 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 277 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -309,7 +314,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us | |||
309 | break; | 314 | break; |
310 | case BT_SECURITY_HIGH: | 315 | case BT_SECURITY_HIGH: |
311 | opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | | 316 | opt = L2CAP_LM_AUTH | L2CAP_LM_ENCRYPT | |
312 | L2CAP_LM_SECURE; | 317 | L2CAP_LM_SECURE; |
313 | break; | 318 | break; |
314 | default: | 319 | default: |
315 | opt = 0; | 320 | opt = 0; |
@@ -353,7 +358,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us | |||
353 | return err; | 358 | return err; |
354 | } | 359 | } |
355 | 360 | ||
356 | static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) | 361 | static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, |
362 | char __user *optval, int __user *optlen) | ||
357 | { | 363 | { |
358 | struct sock *sk = sock->sk; | 364 | struct sock *sk = sock->sk; |
359 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 365 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -377,19 +383,20 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
377 | switch (optname) { | 383 | switch (optname) { |
378 | case BT_SECURITY: | 384 | case BT_SECURITY: |
379 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 385 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
380 | chan->chan_type != L2CAP_CHAN_RAW) { | 386 | chan->chan_type != L2CAP_CHAN_RAW) { |
381 | err = -EINVAL; | 387 | err = -EINVAL; |
382 | break; | 388 | break; |
383 | } | 389 | } |
384 | 390 | ||
385 | memset(&sec, 0, sizeof(sec)); | 391 | memset(&sec, 0, sizeof(sec)); |
386 | if (chan->conn) | 392 | if (chan->conn) { |
387 | sec.level = chan->conn->hcon->sec_level; | 393 | sec.level = chan->conn->hcon->sec_level; |
388 | else | ||
389 | sec.level = chan->sec_level; | ||
390 | 394 | ||
391 | if (sk->sk_state == BT_CONNECTED) | 395 | if (sk->sk_state == BT_CONNECTED) |
392 | sec.key_size = chan->conn->hcon->enc_key_size; | 396 | sec.key_size = chan->conn->hcon->enc_key_size; |
397 | } else { | ||
398 | sec.level = chan->sec_level; | ||
399 | } | ||
393 | 400 | ||
394 | len = min_t(unsigned int, len, sizeof(sec)); | 401 | len = min_t(unsigned int, len, sizeof(sec)); |
395 | if (copy_to_user(optval, (char *) &sec, len)) | 402 | if (copy_to_user(optval, (char *) &sec, len)) |
@@ -411,14 +418,14 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch | |||
411 | 418 | ||
412 | case BT_FLUSHABLE: | 419 | case BT_FLUSHABLE: |
413 | if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), | 420 | if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), |
414 | (u32 __user *) optval)) | 421 | (u32 __user *) optval)) |
415 | err = -EFAULT; | 422 | err = -EFAULT; |
416 | 423 | ||
417 | break; | 424 | break; |
418 | 425 | ||
419 | case BT_POWER: | 426 | case BT_POWER: |
420 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM | 427 | if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM |
421 | && sk->sk_type != SOCK_RAW) { | 428 | && sk->sk_type != SOCK_RAW) { |
422 | err = -EINVAL; | 429 | err = -EINVAL; |
423 | break; | 430 | break; |
424 | } | 431 | } |
@@ -466,7 +473,8 @@ static bool l2cap_valid_mtu(struct l2cap_chan *chan, u16 mtu) | |||
466 | return true; | 473 | return true; |
467 | } | 474 | } |
468 | 475 | ||
469 | static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __user *optval, unsigned int optlen) | 476 | static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, |
477 | char __user *optval, unsigned int optlen) | ||
470 | { | 478 | { |
471 | struct sock *sk = sock->sk; | 479 | struct sock *sk = sock->sk; |
472 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 480 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -529,6 +537,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
529 | chan->fcs = opts.fcs; | 537 | chan->fcs = opts.fcs; |
530 | chan->max_tx = opts.max_tx; | 538 | chan->max_tx = opts.max_tx; |
531 | chan->tx_win = opts.txwin_size; | 539 | chan->tx_win = opts.txwin_size; |
540 | chan->flush_to = opts.flush_to; | ||
532 | break; | 541 | break; |
533 | 542 | ||
534 | case L2CAP_LM: | 543 | case L2CAP_LM: |
@@ -564,7 +573,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
564 | return err; | 573 | return err; |
565 | } | 574 | } |
566 | 575 | ||
567 | static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) | 576 | static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, |
577 | char __user *optval, unsigned int optlen) | ||
568 | { | 578 | { |
569 | struct sock *sk = sock->sk; | 579 | struct sock *sk = sock->sk; |
570 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 580 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -587,7 +597,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
587 | switch (optname) { | 597 | switch (optname) { |
588 | case BT_SECURITY: | 598 | case BT_SECURITY: |
589 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 599 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
590 | chan->chan_type != L2CAP_CHAN_RAW) { | 600 | chan->chan_type != L2CAP_CHAN_RAW) { |
591 | err = -EINVAL; | 601 | err = -EINVAL; |
592 | break; | 602 | break; |
593 | } | 603 | } |
@@ -601,7 +611,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
601 | } | 611 | } |
602 | 612 | ||
603 | if (sec.level < BT_SECURITY_LOW || | 613 | if (sec.level < BT_SECURITY_LOW || |
604 | sec.level > BT_SECURITY_HIGH) { | 614 | sec.level > BT_SECURITY_HIGH) { |
605 | err = -EINVAL; | 615 | err = -EINVAL; |
606 | break; | 616 | break; |
607 | } | 617 | } |
@@ -627,7 +637,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
627 | 637 | ||
628 | /* or for ACL link */ | 638 | /* or for ACL link */ |
629 | } else if ((sk->sk_state == BT_CONNECT2 && | 639 | } else if ((sk->sk_state == BT_CONNECT2 && |
630 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || | 640 | test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) || |
631 | sk->sk_state == BT_CONNECTED) { | 641 | sk->sk_state == BT_CONNECTED) { |
632 | if (!l2cap_chan_check_security(chan)) | 642 | if (!l2cap_chan_check_security(chan)) |
633 | set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); | 643 | set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags); |
@@ -684,7 +694,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
684 | 694 | ||
685 | case BT_POWER: | 695 | case BT_POWER: |
686 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && | 696 | if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED && |
687 | chan->chan_type != L2CAP_CHAN_RAW) { | 697 | chan->chan_type != L2CAP_CHAN_RAW) { |
688 | err = -EINVAL; | 698 | err = -EINVAL; |
689 | break; | 699 | break; |
690 | } | 700 | } |
@@ -720,12 +730,17 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
720 | } | 730 | } |
721 | 731 | ||
722 | if (chan->mode != L2CAP_MODE_ERTM && | 732 | if (chan->mode != L2CAP_MODE_ERTM && |
723 | chan->mode != L2CAP_MODE_STREAMING) { | 733 | chan->mode != L2CAP_MODE_STREAMING) { |
724 | err = -EOPNOTSUPP; | 734 | err = -EOPNOTSUPP; |
725 | break; | 735 | break; |
726 | } | 736 | } |
727 | 737 | ||
728 | chan->chan_policy = (u8) opt; | 738 | chan->chan_policy = (u8) opt; |
739 | |||
740 | if (sk->sk_state == BT_CONNECTED && | ||
741 | chan->move_role == L2CAP_MOVE_ROLE_NONE) | ||
742 | l2cap_move_start(chan); | ||
743 | |||
729 | break; | 744 | break; |
730 | 745 | ||
731 | default: | 746 | default: |
@@ -737,7 +752,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch | |||
737 | return err; | 752 | return err; |
738 | } | 753 | } |
739 | 754 | ||
740 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) | 755 | static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, |
756 | struct msghdr *msg, size_t len) | ||
741 | { | 757 | { |
742 | struct sock *sk = sock->sk; | 758 | struct sock *sk = sock->sk; |
743 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; | 759 | struct l2cap_chan *chan = l2cap_pi(sk)->chan; |
@@ -762,7 +778,8 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms | |||
762 | return err; | 778 | return err; |
763 | } | 779 | } |
764 | 780 | ||
765 | static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) | 781 | static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, |
782 | struct msghdr *msg, size_t len, int flags) | ||
766 | { | 783 | { |
767 | struct sock *sk = sock->sk; | 784 | struct sock *sk = sock->sk; |
768 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 785 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
@@ -866,7 +883,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how) | |||
866 | 883 | ||
867 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) | 884 | if (sock_flag(sk, SOCK_LINGER) && sk->sk_lingertime) |
868 | err = bt_sock_wait_state(sk, BT_CLOSED, | 885 | err = bt_sock_wait_state(sk, BT_CLOSED, |
869 | sk->sk_lingertime); | 886 | sk->sk_lingertime); |
870 | } | 887 | } |
871 | 888 | ||
872 | if (!err && sk->sk_err) | 889 | if (!err && sk->sk_err) |
@@ -930,7 +947,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan) | |||
930 | } | 947 | } |
931 | 948 | ||
932 | sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, | 949 | sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, |
933 | GFP_ATOMIC); | 950 | GFP_ATOMIC); |
934 | if (!sk) | 951 | if (!sk) |
935 | return NULL; | 952 | return NULL; |
936 | 953 | ||
@@ -938,6 +955,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan) | |||
938 | 955 | ||
939 | l2cap_sock_init(sk, parent); | 956 | l2cap_sock_init(sk, parent); |
940 | 957 | ||
958 | bt_accept_enqueue(parent, sk); | ||
959 | |||
941 | return l2cap_pi(sk)->chan; | 960 | return l2cap_pi(sk)->chan; |
942 | } | 961 | } |
943 | 962 | ||
@@ -1068,6 +1087,15 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan) | |||
1068 | release_sock(sk); | 1087 | release_sock(sk); |
1069 | } | 1088 | } |
1070 | 1089 | ||
1090 | static void l2cap_sock_defer_cb(struct l2cap_chan *chan) | ||
1091 | { | ||
1092 | struct sock *sk = chan->data; | ||
1093 | struct sock *parent = bt_sk(sk)->parent; | ||
1094 | |||
1095 | if (parent) | ||
1096 | parent->sk_data_ready(parent, 0); | ||
1097 | } | ||
1098 | |||
1071 | static struct l2cap_ops l2cap_chan_ops = { | 1099 | static struct l2cap_ops l2cap_chan_ops = { |
1072 | .name = "L2CAP Socket Interface", | 1100 | .name = "L2CAP Socket Interface", |
1073 | .new_connection = l2cap_sock_new_connection_cb, | 1101 | .new_connection = l2cap_sock_new_connection_cb, |
@@ -1076,6 +1104,7 @@ static struct l2cap_ops l2cap_chan_ops = { | |||
1076 | .teardown = l2cap_sock_teardown_cb, | 1104 | .teardown = l2cap_sock_teardown_cb, |
1077 | .state_change = l2cap_sock_state_change_cb, | 1105 | .state_change = l2cap_sock_state_change_cb, |
1078 | .ready = l2cap_sock_ready_cb, | 1106 | .ready = l2cap_sock_ready_cb, |
1107 | .defer = l2cap_sock_defer_cb, | ||
1079 | .alloc_skb = l2cap_sock_alloc_skb_cb, | 1108 | .alloc_skb = l2cap_sock_alloc_skb_cb, |
1080 | }; | 1109 | }; |
1081 | 1110 | ||
@@ -1083,7 +1112,8 @@ static void l2cap_sock_destruct(struct sock *sk) | |||
1083 | { | 1112 | { |
1084 | BT_DBG("sk %p", sk); | 1113 | BT_DBG("sk %p", sk); |
1085 | 1114 | ||
1086 | l2cap_chan_put(l2cap_pi(sk)->chan); | 1115 | if (l2cap_pi(sk)->chan) |
1116 | l2cap_chan_put(l2cap_pi(sk)->chan); | ||
1087 | if (l2cap_pi(sk)->rx_busy_skb) { | 1117 | if (l2cap_pi(sk)->rx_busy_skb) { |
1088 | kfree_skb(l2cap_pi(sk)->rx_busy_skb); | 1118 | kfree_skb(l2cap_pi(sk)->rx_busy_skb); |
1089 | l2cap_pi(sk)->rx_busy_skb = NULL; | 1119 | l2cap_pi(sk)->rx_busy_skb = NULL; |
@@ -1159,7 +1189,8 @@ static struct proto l2cap_proto = { | |||
1159 | .obj_size = sizeof(struct l2cap_pinfo) | 1189 | .obj_size = sizeof(struct l2cap_pinfo) |
1160 | }; | 1190 | }; |
1161 | 1191 | ||
1162 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio) | 1192 | static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
1193 | int proto, gfp_t prio) | ||
1163 | { | 1194 | { |
1164 | struct sock *sk; | 1195 | struct sock *sk; |
1165 | struct l2cap_chan *chan; | 1196 | struct l2cap_chan *chan; |
@@ -1204,7 +1235,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, | |||
1204 | sock->state = SS_UNCONNECTED; | 1235 | sock->state = SS_UNCONNECTED; |
1205 | 1236 | ||
1206 | if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && | 1237 | if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM && |
1207 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) | 1238 | sock->type != SOCK_DGRAM && sock->type != SOCK_RAW) |
1208 | return -ESOCKTNOSUPPORT; | 1239 | return -ESOCKTNOSUPPORT; |
1209 | 1240 | ||
1210 | if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) | 1241 | if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW)) |
@@ -1261,7 +1292,8 @@ int __init l2cap_init_sockets(void) | |||
1261 | goto error; | 1292 | goto error; |
1262 | } | 1293 | } |
1263 | 1294 | ||
1264 | err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, NULL); | 1295 | err = bt_procfs_init(THIS_MODULE, &init_net, "l2cap", &l2cap_sk_list, |
1296 | NULL); | ||
1265 | if (err < 0) { | 1297 | if (err < 0) { |
1266 | BT_ERR("Failed to create L2CAP proc file"); | 1298 | BT_ERR("Failed to create L2CAP proc file"); |
1267 | bt_sock_unregister(BTPROTO_L2CAP); | 1299 | bt_sock_unregister(BTPROTO_L2CAP); |
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c index e1c97527e16c..b3fbc73516c4 100644 --- a/net/bluetooth/lib.c +++ b/net/bluetooth/lib.c | |||
@@ -41,20 +41,6 @@ void baswap(bdaddr_t *dst, bdaddr_t *src) | |||
41 | } | 41 | } |
42 | EXPORT_SYMBOL(baswap); | 42 | EXPORT_SYMBOL(baswap); |
43 | 43 | ||
44 | char *batostr(bdaddr_t *ba) | ||
45 | { | ||
46 | static char str[2][18]; | ||
47 | static int i = 1; | ||
48 | |||
49 | i ^= 1; | ||
50 | sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", | ||
51 | ba->b[5], ba->b[4], ba->b[3], | ||
52 | ba->b[2], ba->b[1], ba->b[0]); | ||
53 | |||
54 | return str[i]; | ||
55 | } | ||
56 | EXPORT_SYMBOL(batostr); | ||
57 | |||
58 | /* Bluetooth error codes to Unix errno mapping */ | 44 | /* Bluetooth error codes to Unix errno mapping */ |
59 | int bt_to_errno(__u16 code) | 45 | int bt_to_errno(__u16 code) |
60 | { | 46 | { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index aa2ea0a8142c..142764aec2af 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -222,7 +222,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) | |||
222 | 222 | ||
223 | hdr = (void *) skb_put(skb, sizeof(*hdr)); | 223 | hdr = (void *) skb_put(skb, sizeof(*hdr)); |
224 | 224 | ||
225 | hdr->opcode = cpu_to_le16(MGMT_EV_CMD_STATUS); | 225 | hdr->opcode = __constant_cpu_to_le16(MGMT_EV_CMD_STATUS); |
226 | hdr->index = cpu_to_le16(index); | 226 | hdr->index = cpu_to_le16(index); |
227 | hdr->len = cpu_to_le16(sizeof(*ev)); | 227 | hdr->len = cpu_to_le16(sizeof(*ev)); |
228 | 228 | ||
@@ -253,7 +253,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, | |||
253 | 253 | ||
254 | hdr = (void *) skb_put(skb, sizeof(*hdr)); | 254 | hdr = (void *) skb_put(skb, sizeof(*hdr)); |
255 | 255 | ||
256 | hdr->opcode = cpu_to_le16(MGMT_EV_CMD_COMPLETE); | 256 | hdr->opcode = __constant_cpu_to_le16(MGMT_EV_CMD_COMPLETE); |
257 | hdr->index = cpu_to_le16(index); | 257 | hdr->index = cpu_to_le16(index); |
258 | hdr->len = cpu_to_le16(sizeof(*ev) + rp_len); | 258 | hdr->len = cpu_to_le16(sizeof(*ev) + rp_len); |
259 | 259 | ||
@@ -326,7 +326,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
326 | struct hci_dev *d; | 326 | struct hci_dev *d; |
327 | size_t rp_len; | 327 | size_t rp_len; |
328 | u16 count; | 328 | u16 count; |
329 | int i, err; | 329 | int err; |
330 | 330 | ||
331 | BT_DBG("sock %p", sk); | 331 | BT_DBG("sock %p", sk); |
332 | 332 | ||
@@ -347,9 +347,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
347 | return -ENOMEM; | 347 | return -ENOMEM; |
348 | } | 348 | } |
349 | 349 | ||
350 | rp->num_controllers = cpu_to_le16(count); | 350 | count = 0; |
351 | |||
352 | i = 0; | ||
353 | list_for_each_entry(d, &hci_dev_list, list) { | 351 | list_for_each_entry(d, &hci_dev_list, list) { |
354 | if (test_bit(HCI_SETUP, &d->dev_flags)) | 352 | if (test_bit(HCI_SETUP, &d->dev_flags)) |
355 | continue; | 353 | continue; |
@@ -357,10 +355,13 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
357 | if (!mgmt_valid_hdev(d)) | 355 | if (!mgmt_valid_hdev(d)) |
358 | continue; | 356 | continue; |
359 | 357 | ||
360 | rp->index[i++] = cpu_to_le16(d->id); | 358 | rp->index[count++] = cpu_to_le16(d->id); |
361 | BT_DBG("Added hci%u", d->id); | 359 | BT_DBG("Added hci%u", d->id); |
362 | } | 360 | } |
363 | 361 | ||
362 | rp->num_controllers = cpu_to_le16(count); | ||
363 | rp_len = sizeof(*rp) + (2 * count); | ||
364 | |||
364 | read_unlock(&hci_dev_list_lock); | 365 | read_unlock(&hci_dev_list_lock); |
365 | 366 | ||
366 | err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, | 367 | err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, |
@@ -376,15 +377,15 @@ static u32 get_supported_settings(struct hci_dev *hdev) | |||
376 | u32 settings = 0; | 377 | u32 settings = 0; |
377 | 378 | ||
378 | settings |= MGMT_SETTING_POWERED; | 379 | settings |= MGMT_SETTING_POWERED; |
379 | settings |= MGMT_SETTING_CONNECTABLE; | ||
380 | settings |= MGMT_SETTING_FAST_CONNECTABLE; | ||
381 | settings |= MGMT_SETTING_DISCOVERABLE; | ||
382 | settings |= MGMT_SETTING_PAIRABLE; | 380 | settings |= MGMT_SETTING_PAIRABLE; |
383 | 381 | ||
384 | if (lmp_ssp_capable(hdev)) | 382 | if (lmp_ssp_capable(hdev)) |
385 | settings |= MGMT_SETTING_SSP; | 383 | settings |= MGMT_SETTING_SSP; |
386 | 384 | ||
387 | if (lmp_bredr_capable(hdev)) { | 385 | if (lmp_bredr_capable(hdev)) { |
386 | settings |= MGMT_SETTING_CONNECTABLE; | ||
387 | settings |= MGMT_SETTING_FAST_CONNECTABLE; | ||
388 | settings |= MGMT_SETTING_DISCOVERABLE; | ||
388 | settings |= MGMT_SETTING_BREDR; | 389 | settings |= MGMT_SETTING_BREDR; |
389 | settings |= MGMT_SETTING_LINK_SECURITY; | 390 | settings |= MGMT_SETTING_LINK_SECURITY; |
390 | } | 391 | } |
@@ -484,7 +485,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data) | |||
484 | ptr += (name_len + 2); | 485 | ptr += (name_len + 2); |
485 | } | 486 | } |
486 | 487 | ||
487 | if (hdev->inq_tx_power) { | 488 | if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) { |
488 | ptr[0] = 2; | 489 | ptr[0] = 2; |
489 | ptr[1] = EIR_TX_POWER; | 490 | ptr[1] = EIR_TX_POWER; |
490 | ptr[2] = (u8) hdev->inq_tx_power; | 491 | ptr[2] = (u8) hdev->inq_tx_power; |
@@ -565,7 +566,7 @@ static int update_eir(struct hci_dev *hdev) | |||
565 | if (!hdev_is_powered(hdev)) | 566 | if (!hdev_is_powered(hdev)) |
566 | return 0; | 567 | return 0; |
567 | 568 | ||
568 | if (!(hdev->features[6] & LMP_EXT_INQ)) | 569 | if (!lmp_ext_inq_capable(hdev)) |
569 | return 0; | 570 | return 0; |
570 | 571 | ||
571 | if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) | 572 | if (!test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) |
@@ -832,7 +833,7 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 data_len, | |||
832 | if (hdev) | 833 | if (hdev) |
833 | hdr->index = cpu_to_le16(hdev->id); | 834 | hdr->index = cpu_to_le16(hdev->id); |
834 | else | 835 | else |
835 | hdr->index = cpu_to_le16(MGMT_INDEX_NONE); | 836 | hdr->index = __constant_cpu_to_le16(MGMT_INDEX_NONE); |
836 | hdr->len = cpu_to_le16(data_len); | 837 | hdr->len = cpu_to_le16(data_len); |
837 | 838 | ||
838 | if (data) | 839 | if (data) |
@@ -867,6 +868,10 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
867 | 868 | ||
868 | BT_DBG("request for %s", hdev->name); | 869 | BT_DBG("request for %s", hdev->name); |
869 | 870 | ||
871 | if (!lmp_bredr_capable(hdev)) | ||
872 | return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, | ||
873 | MGMT_STATUS_NOT_SUPPORTED); | ||
874 | |||
870 | timeout = __le16_to_cpu(cp->timeout); | 875 | timeout = __le16_to_cpu(cp->timeout); |
871 | if (!cp->val && timeout > 0) | 876 | if (!cp->val && timeout > 0) |
872 | return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, | 877 | return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE, |
@@ -962,6 +967,10 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data, | |||
962 | 967 | ||
963 | BT_DBG("request for %s", hdev->name); | 968 | BT_DBG("request for %s", hdev->name); |
964 | 969 | ||
970 | if (!lmp_bredr_capable(hdev)) | ||
971 | return cmd_status(sk, hdev->id, MGMT_OP_SET_CONNECTABLE, | ||
972 | MGMT_STATUS_NOT_SUPPORTED); | ||
973 | |||
965 | hci_dev_lock(hdev); | 974 | hci_dev_lock(hdev); |
966 | 975 | ||
967 | if (!hdev_is_powered(hdev)) { | 976 | if (!hdev_is_powered(hdev)) { |
@@ -1060,6 +1069,10 @@ static int set_link_security(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1060 | 1069 | ||
1061 | BT_DBG("request for %s", hdev->name); | 1070 | BT_DBG("request for %s", hdev->name); |
1062 | 1071 | ||
1072 | if (!lmp_bredr_capable(hdev)) | ||
1073 | return cmd_status(sk, hdev->id, MGMT_OP_SET_LINK_SECURITY, | ||
1074 | MGMT_STATUS_NOT_SUPPORTED); | ||
1075 | |||
1063 | hci_dev_lock(hdev); | 1076 | hci_dev_lock(hdev); |
1064 | 1077 | ||
1065 | if (!hdev_is_powered(hdev)) { | 1078 | if (!hdev_is_powered(hdev)) { |
@@ -1213,7 +1226,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
1213 | } | 1226 | } |
1214 | 1227 | ||
1215 | val = !!cp->val; | 1228 | val = !!cp->val; |
1216 | enabled = !!(hdev->host_features[0] & LMP_HOST_LE); | 1229 | enabled = !!lmp_host_le_capable(hdev); |
1217 | 1230 | ||
1218 | if (!hdev_is_powered(hdev) || val == enabled) { | 1231 | if (!hdev_is_powered(hdev) || val == enabled) { |
1219 | bool changed = false; | 1232 | bool changed = false; |
@@ -1249,7 +1262,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
1249 | 1262 | ||
1250 | if (val) { | 1263 | if (val) { |
1251 | hci_cp.le = val; | 1264 | hci_cp.le = val; |
1252 | hci_cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); | 1265 | hci_cp.simul = !!lmp_le_br_capable(hdev); |
1253 | } | 1266 | } |
1254 | 1267 | ||
1255 | err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), | 1268 | err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), |
@@ -1366,6 +1379,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data, | |||
1366 | continue; | 1379 | continue; |
1367 | 1380 | ||
1368 | list_del(&match->list); | 1381 | list_del(&match->list); |
1382 | kfree(match); | ||
1369 | found++; | 1383 | found++; |
1370 | } | 1384 | } |
1371 | 1385 | ||
@@ -2594,6 +2608,10 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev, | |||
2594 | 2608 | ||
2595 | BT_DBG("%s", hdev->name); | 2609 | BT_DBG("%s", hdev->name); |
2596 | 2610 | ||
2611 | if (!lmp_bredr_capable(hdev)) | ||
2612 | return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, | ||
2613 | MGMT_STATUS_NOT_SUPPORTED); | ||
2614 | |||
2597 | if (!hdev_is_powered(hdev)) | 2615 | if (!hdev_is_powered(hdev)) |
2598 | return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, | 2616 | return cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, |
2599 | MGMT_STATUS_NOT_POWERED); | 2617 | MGMT_STATUS_NOT_POWERED); |
@@ -2871,6 +2889,21 @@ static void settings_rsp(struct pending_cmd *cmd, void *data) | |||
2871 | mgmt_pending_free(cmd); | 2889 | mgmt_pending_free(cmd); |
2872 | } | 2890 | } |
2873 | 2891 | ||
2892 | static int set_bredr_scan(struct hci_dev *hdev) | ||
2893 | { | ||
2894 | u8 scan = 0; | ||
2895 | |||
2896 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | ||
2897 | scan |= SCAN_PAGE; | ||
2898 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | ||
2899 | scan |= SCAN_INQUIRY; | ||
2900 | |||
2901 | if (!scan) | ||
2902 | return 0; | ||
2903 | |||
2904 | return hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); | ||
2905 | } | ||
2906 | |||
2874 | int mgmt_powered(struct hci_dev *hdev, u8 powered) | 2907 | int mgmt_powered(struct hci_dev *hdev, u8 powered) |
2875 | { | 2908 | { |
2876 | struct cmd_lookup match = { NULL, hdev }; | 2909 | struct cmd_lookup match = { NULL, hdev }; |
@@ -2882,17 +2915,8 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
2882 | mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); | 2915 | mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match); |
2883 | 2916 | ||
2884 | if (powered) { | 2917 | if (powered) { |
2885 | u8 scan = 0; | 2918 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && |
2886 | 2919 | !lmp_host_ssp_capable(hdev)) { | |
2887 | if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) | ||
2888 | scan |= SCAN_PAGE; | ||
2889 | if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) | ||
2890 | scan |= SCAN_INQUIRY; | ||
2891 | |||
2892 | if (scan) | ||
2893 | hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); | ||
2894 | |||
2895 | if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags)) { | ||
2896 | u8 ssp = 1; | 2920 | u8 ssp = 1; |
2897 | 2921 | ||
2898 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, 1, &ssp); | 2922 | hci_send_cmd(hdev, HCI_OP_WRITE_SSP_MODE, 1, &ssp); |
@@ -2902,15 +2926,24 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered) | |||
2902 | struct hci_cp_write_le_host_supported cp; | 2926 | struct hci_cp_write_le_host_supported cp; |
2903 | 2927 | ||
2904 | cp.le = 1; | 2928 | cp.le = 1; |
2905 | cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR); | 2929 | cp.simul = !!lmp_le_br_capable(hdev); |
2906 | 2930 | ||
2907 | hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, | 2931 | /* Check first if we already have the right |
2908 | sizeof(cp), &cp); | 2932 | * host state (host features set) |
2933 | */ | ||
2934 | if (cp.le != !!lmp_host_le_capable(hdev) || | ||
2935 | cp.simul != !!lmp_host_le_br_capable(hdev)) | ||
2936 | hci_send_cmd(hdev, | ||
2937 | HCI_OP_WRITE_LE_HOST_SUPPORTED, | ||
2938 | sizeof(cp), &cp); | ||
2909 | } | 2939 | } |
2910 | 2940 | ||
2911 | update_class(hdev); | 2941 | if (lmp_bredr_capable(hdev)) { |
2912 | update_name(hdev, hdev->dev_name); | 2942 | set_bredr_scan(hdev); |
2913 | update_eir(hdev); | 2943 | update_class(hdev); |
2944 | update_name(hdev, hdev->dev_name); | ||
2945 | update_eir(hdev); | ||
2946 | } | ||
2914 | } else { | 2947 | } else { |
2915 | u8 status = MGMT_STATUS_NOT_POWERED; | 2948 | u8 status = MGMT_STATUS_NOT_POWERED; |
2916 | mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); | 2949 | mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); |
@@ -3125,6 +3158,9 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
3125 | struct pending_cmd *cmd; | 3158 | struct pending_cmd *cmd; |
3126 | int err; | 3159 | int err; |
3127 | 3160 | ||
3161 | mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, | ||
3162 | hdev); | ||
3163 | |||
3128 | cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); | 3164 | cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); |
3129 | if (!cmd) | 3165 | if (!cmd) |
3130 | return -ENOENT; | 3166 | return -ENOENT; |
@@ -3137,8 +3173,6 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | |||
3137 | 3173 | ||
3138 | mgmt_pending_remove(cmd); | 3174 | mgmt_pending_remove(cmd); |
3139 | 3175 | ||
3140 | mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, | ||
3141 | hdev); | ||
3142 | return err; | 3176 | return err; |
3143 | } | 3177 | } |
3144 | 3178 | ||
@@ -3358,7 +3392,7 @@ static int clear_eir(struct hci_dev *hdev) | |||
3358 | { | 3392 | { |
3359 | struct hci_cp_write_eir cp; | 3393 | struct hci_cp_write_eir cp; |
3360 | 3394 | ||
3361 | if (!(hdev->features[6] & LMP_EXT_INQ)) | 3395 | if (!lmp_ext_inq_capable(hdev)) |
3362 | return 0; | 3396 | return 0; |
3363 | 3397 | ||
3364 | memset(hdev->eir, 0, sizeof(hdev->eir)); | 3398 | memset(hdev->eir, 0, sizeof(hdev->eir)); |
@@ -3490,7 +3524,12 @@ send_event: | |||
3490 | err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, | 3524 | err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, |
3491 | sizeof(ev), cmd ? cmd->sk : NULL); | 3525 | sizeof(ev), cmd ? cmd->sk : NULL); |
3492 | 3526 | ||
3493 | update_eir(hdev); | 3527 | /* EIR is taken care of separately when powering on the |
3528 | * adapter so only update them here if this is a name change | ||
3529 | * unrelated to power on. | ||
3530 | */ | ||
3531 | if (!test_bit(HCI_INIT, &hdev->flags)) | ||
3532 | update_eir(hdev); | ||
3494 | 3533 | ||
3495 | failed: | 3534 | failed: |
3496 | if (cmd) | 3535 | if (cmd) |
@@ -3585,9 +3624,9 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | |||
3585 | ev->addr.type = link_to_bdaddr(link_type, addr_type); | 3624 | ev->addr.type = link_to_bdaddr(link_type, addr_type); |
3586 | ev->rssi = rssi; | 3625 | ev->rssi = rssi; |
3587 | if (cfm_name) | 3626 | if (cfm_name) |
3588 | ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME); | 3627 | ev->flags |= __constant_cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME); |
3589 | if (!ssp) | 3628 | if (!ssp) |
3590 | ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING); | 3629 | ev->flags |= __constant_cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING); |
3591 | 3630 | ||
3592 | if (eir_len > 0) | 3631 | if (eir_len > 0) |
3593 | memcpy(ev->eir, eir, eir_len); | 3632 | memcpy(ev->eir, eir, eir_len); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index c75107ef8920..201fdf737209 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -377,8 +377,8 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, | |||
377 | int err = 0; | 377 | int err = 0; |
378 | u8 dlci; | 378 | u8 dlci; |
379 | 379 | ||
380 | BT_DBG("dlc %p state %ld %s %s channel %d", | 380 | BT_DBG("dlc %p state %ld %pMR -> %pMR channel %d", |
381 | d, d->state, batostr(src), batostr(dst), channel); | 381 | d, d->state, src, dst, channel); |
382 | 382 | ||
383 | if (channel < 1 || channel > 30) | 383 | if (channel < 1 || channel > 30) |
384 | return -EINVAL; | 384 | return -EINVAL; |
@@ -676,7 +676,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, | |||
676 | struct socket *sock; | 676 | struct socket *sock; |
677 | struct sock *sk; | 677 | struct sock *sk; |
678 | 678 | ||
679 | BT_DBG("%s %s", batostr(src), batostr(dst)); | 679 | BT_DBG("%pMR -> %pMR", src, dst); |
680 | 680 | ||
681 | *err = rfcomm_l2sock_create(&sock); | 681 | *err = rfcomm_l2sock_create(&sock); |
682 | if (*err < 0) | 682 | if (*err < 0) |
@@ -709,7 +709,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, | |||
709 | 709 | ||
710 | bacpy(&addr.l2_bdaddr, dst); | 710 | bacpy(&addr.l2_bdaddr, dst); |
711 | addr.l2_family = AF_BLUETOOTH; | 711 | addr.l2_family = AF_BLUETOOTH; |
712 | addr.l2_psm = cpu_to_le16(RFCOMM_PSM); | 712 | addr.l2_psm = __constant_cpu_to_le16(RFCOMM_PSM); |
713 | addr.l2_cid = 0; | 713 | addr.l2_cid = 0; |
714 | *err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK); | 714 | *err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK); |
715 | if (*err == 0 || *err == -EINPROGRESS) | 715 | if (*err == 0 || *err == -EINPROGRESS) |
@@ -1987,7 +1987,7 @@ static int rfcomm_add_listener(bdaddr_t *ba) | |||
1987 | /* Bind socket */ | 1987 | /* Bind socket */ |
1988 | bacpy(&addr.l2_bdaddr, ba); | 1988 | bacpy(&addr.l2_bdaddr, ba); |
1989 | addr.l2_family = AF_BLUETOOTH; | 1989 | addr.l2_family = AF_BLUETOOTH; |
1990 | addr.l2_psm = cpu_to_le16(RFCOMM_PSM); | 1990 | addr.l2_psm = __constant_cpu_to_le16(RFCOMM_PSM); |
1991 | addr.l2_cid = 0; | 1991 | addr.l2_cid = 0; |
1992 | err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr)); | 1992 | err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr)); |
1993 | if (err < 0) { | 1993 | if (err < 0) { |
@@ -2125,11 +2125,10 @@ static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) | |||
2125 | list_for_each_entry(d, &s->dlcs, list) { | 2125 | list_for_each_entry(d, &s->dlcs, list) { |
2126 | struct sock *sk = s->sock->sk; | 2126 | struct sock *sk = s->sock->sk; |
2127 | 2127 | ||
2128 | seq_printf(f, "%s %s %ld %d %d %d %d\n", | 2128 | seq_printf(f, "%pMR %pMR %ld %d %d %d %d\n", |
2129 | batostr(&bt_sk(sk)->src), | 2129 | &bt_sk(sk)->src, &bt_sk(sk)->dst, |
2130 | batostr(&bt_sk(sk)->dst), | 2130 | d->state, d->dlci, d->mtu, |
2131 | d->state, d->dlci, d->mtu, | 2131 | d->rx_credits, d->tx_credits); |
2132 | d->rx_credits, d->tx_credits); | ||
2133 | } | 2132 | } |
2134 | } | 2133 | } |
2135 | 2134 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index b3226f3658cf..4ddef57d03a7 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -334,7 +334,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr | |||
334 | struct sock *sk = sock->sk; | 334 | struct sock *sk = sock->sk; |
335 | int err = 0; | 335 | int err = 0; |
336 | 336 | ||
337 | BT_DBG("sk %p %s", sk, batostr(&sa->rc_bdaddr)); | 337 | BT_DBG("sk %p %pMR", sk, &sa->rc_bdaddr); |
338 | 338 | ||
339 | if (!addr || addr->sa_family != AF_BLUETOOTH) | 339 | if (!addr || addr->sa_family != AF_BLUETOOTH) |
340 | return -EINVAL; | 340 | return -EINVAL; |
@@ -975,10 +975,9 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p) | |||
975 | read_lock(&rfcomm_sk_list.lock); | 975 | read_lock(&rfcomm_sk_list.lock); |
976 | 976 | ||
977 | sk_for_each(sk, node, &rfcomm_sk_list.head) { | 977 | sk_for_each(sk, node, &rfcomm_sk_list.head) { |
978 | seq_printf(f, "%s %s %d %d\n", | 978 | seq_printf(f, "%pMR %pMR %d %d\n", |
979 | batostr(&bt_sk(sk)->src), | 979 | &bt_sk(sk)->src, &bt_sk(sk)->dst, |
980 | batostr(&bt_sk(sk)->dst), | 980 | sk->sk_state, rfcomm_pi(sk)->channel); |
981 | sk->sk_state, rfcomm_pi(sk)->channel); | ||
982 | } | 981 | } |
983 | 982 | ||
984 | read_unlock(&rfcomm_sk_list.lock); | 983 | read_unlock(&rfcomm_sk_list.lock); |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index ccc248791d50..bd6fd0f43d2b 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -166,7 +166,7 @@ static struct device *rfcomm_get_device(struct rfcomm_dev *dev) | |||
166 | static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf) | 166 | static ssize_t show_address(struct device *tty_dev, struct device_attribute *attr, char *buf) |
167 | { | 167 | { |
168 | struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); | 168 | struct rfcomm_dev *dev = dev_get_drvdata(tty_dev); |
169 | return sprintf(buf, "%s\n", batostr(&dev->dst)); | 169 | return sprintf(buf, "%pMR\n", &dev->dst); |
170 | } | 170 | } |
171 | 171 | ||
172 | static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf) | 172 | static ssize_t show_channel(struct device *tty_dev, struct device_attribute *attr, char *buf) |
@@ -663,8 +663,8 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
663 | if (!dev) | 663 | if (!dev) |
664 | return -ENODEV; | 664 | return -ENODEV; |
665 | 665 | ||
666 | BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst), | 666 | BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, |
667 | dev->channel, dev->port.count); | 667 | dev->channel, dev->port.count); |
668 | 668 | ||
669 | spin_lock_irqsave(&dev->port.lock, flags); | 669 | spin_lock_irqsave(&dev->port.lock, flags); |
670 | if (++dev->port.count > 1) { | 670 | if (++dev->port.count > 1) { |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index dc42b917aaaf..450cdcd88e5c 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -172,7 +172,7 @@ static int sco_connect(struct sock *sk) | |||
172 | struct hci_dev *hdev; | 172 | struct hci_dev *hdev; |
173 | int err, type; | 173 | int err, type; |
174 | 174 | ||
175 | BT_DBG("%s -> %s", batostr(src), batostr(dst)); | 175 | BT_DBG("%pMR -> %pMR", src, dst); |
176 | 176 | ||
177 | hdev = hci_get_route(dst, src); | 177 | hdev = hci_get_route(dst, src); |
178 | if (!hdev) | 178 | if (!hdev) |
@@ -460,7 +460,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le | |||
460 | struct sock *sk = sock->sk; | 460 | struct sock *sk = sock->sk; |
461 | int err = 0; | 461 | int err = 0; |
462 | 462 | ||
463 | BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr)); | 463 | BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr); |
464 | 464 | ||
465 | if (!addr || addr->sa_family != AF_BLUETOOTH) | 465 | if (!addr || addr->sa_family != AF_BLUETOOTH) |
466 | return -EINVAL; | 466 | return -EINVAL; |
@@ -893,7 +893,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
893 | struct hlist_node *node; | 893 | struct hlist_node *node; |
894 | int lm = 0; | 894 | int lm = 0; |
895 | 895 | ||
896 | BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); | 896 | BT_DBG("hdev %s, bdaddr %pMR", hdev->name, bdaddr); |
897 | 897 | ||
898 | /* Find listening sockets */ | 898 | /* Find listening sockets */ |
899 | read_lock(&sco_sk_list.lock); | 899 | read_lock(&sco_sk_list.lock); |
@@ -914,7 +914,7 @@ int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr) | |||
914 | 914 | ||
915 | void sco_connect_cfm(struct hci_conn *hcon, __u8 status) | 915 | void sco_connect_cfm(struct hci_conn *hcon, __u8 status) |
916 | { | 916 | { |
917 | BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); | 917 | BT_DBG("hcon %p bdaddr %pMR status %d", hcon, &hcon->dst, status); |
918 | if (!status) { | 918 | if (!status) { |
919 | struct sco_conn *conn; | 919 | struct sco_conn *conn; |
920 | 920 | ||
@@ -959,8 +959,8 @@ static int sco_debugfs_show(struct seq_file *f, void *p) | |||
959 | read_lock(&sco_sk_list.lock); | 959 | read_lock(&sco_sk_list.lock); |
960 | 960 | ||
961 | sk_for_each(sk, node, &sco_sk_list.head) { | 961 | sk_for_each(sk, node, &sco_sk_list.head) { |
962 | seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src), | 962 | seq_printf(f, "%pMR %pMR %d\n", &bt_sk(sk)->src, |
963 | batostr(&bt_sk(sk)->dst), sk->sk_state); | 963 | &bt_sk(sk)->dst, sk->sk_state); |
964 | } | 964 | } |
965 | 965 | ||
966 | read_unlock(&sco_sk_list.lock); | 966 | read_unlock(&sco_sk_list.lock); |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 8c225ef349cd..68a9587c9694 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -32,6 +32,8 @@ | |||
32 | 32 | ||
33 | #define SMP_TIMEOUT msecs_to_jiffies(30000) | 33 | #define SMP_TIMEOUT msecs_to_jiffies(30000) |
34 | 34 | ||
35 | #define AUTH_REQ_MASK 0x07 | ||
36 | |||
35 | static inline void swap128(u8 src[16], u8 dst[16]) | 37 | static inline void swap128(u8 src[16], u8 dst[16]) |
36 | { | 38 | { |
37 | int i; | 39 | int i; |
@@ -165,7 +167,7 @@ static struct sk_buff *smp_build_cmd(struct l2cap_conn *conn, u8 code, | |||
165 | 167 | ||
166 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); | 168 | lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); |
167 | lh->len = cpu_to_le16(sizeof(code) + dlen); | 169 | lh->len = cpu_to_le16(sizeof(code) + dlen); |
168 | lh->cid = cpu_to_le16(L2CAP_CID_SMP); | 170 | lh->cid = __constant_cpu_to_le16(L2CAP_CID_SMP); |
169 | 171 | ||
170 | memcpy(skb_put(skb, sizeof(code)), &code, sizeof(code)); | 172 | memcpy(skb_put(skb, sizeof(code)), &code, sizeof(code)); |
171 | 173 | ||
@@ -230,7 +232,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
230 | req->max_key_size = SMP_MAX_ENC_KEY_SIZE; | 232 | req->max_key_size = SMP_MAX_ENC_KEY_SIZE; |
231 | req->init_key_dist = 0; | 233 | req->init_key_dist = 0; |
232 | req->resp_key_dist = dist_keys; | 234 | req->resp_key_dist = dist_keys; |
233 | req->auth_req = authreq; | 235 | req->auth_req = (authreq & AUTH_REQ_MASK); |
234 | return; | 236 | return; |
235 | } | 237 | } |
236 | 238 | ||
@@ -239,7 +241,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn, | |||
239 | rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE; | 241 | rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE; |
240 | rsp->init_key_dist = 0; | 242 | rsp->init_key_dist = 0; |
241 | rsp->resp_key_dist = req->resp_key_dist & dist_keys; | 243 | rsp->resp_key_dist = req->resp_key_dist & dist_keys; |
242 | rsp->auth_req = authreq; | 244 | rsp->auth_req = (authreq & AUTH_REQ_MASK); |
243 | } | 245 | } |
244 | 246 | ||
245 | static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) | 247 | static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) |
@@ -265,7 +267,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) | |||
265 | 267 | ||
266 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); | 268 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); |
267 | mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, | 269 | mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, |
268 | hcon->dst_type, reason); | 270 | hcon->dst_type, HCI_ERROR_AUTH_FAILURE); |
269 | 271 | ||
270 | cancel_delayed_work_sync(&conn->security_timer); | 272 | cancel_delayed_work_sync(&conn->security_timer); |
271 | 273 | ||
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index bcf02f608cbf..017a8bacfb27 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
@@ -429,6 +429,17 @@ static struct attribute_group netstat_group = { | |||
429 | .name = "statistics", | 429 | .name = "statistics", |
430 | .attrs = netstat_attrs, | 430 | .attrs = netstat_attrs, |
431 | }; | 431 | }; |
432 | |||
433 | #if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211) | ||
434 | static struct attribute *wireless_attrs[] = { | ||
435 | NULL | ||
436 | }; | ||
437 | |||
438 | static struct attribute_group wireless_group = { | ||
439 | .name = "wireless", | ||
440 | .attrs = wireless_attrs, | ||
441 | }; | ||
442 | #endif | ||
432 | #endif /* CONFIG_SYSFS */ | 443 | #endif /* CONFIG_SYSFS */ |
433 | 444 | ||
434 | #ifdef CONFIG_RPS | 445 | #ifdef CONFIG_RPS |
@@ -1409,6 +1420,15 @@ int netdev_register_kobject(struct net_device *net) | |||
1409 | groups++; | 1420 | groups++; |
1410 | 1421 | ||
1411 | *groups++ = &netstat_group; | 1422 | *groups++ = &netstat_group; |
1423 | |||
1424 | #if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211) | ||
1425 | if (net->ieee80211_ptr) | ||
1426 | *groups++ = &wireless_group; | ||
1427 | #if IS_ENABLED(CONFIG_WIRELESS_EXT) | ||
1428 | else if (net->wireless_handlers) | ||
1429 | *groups++ = &wireless_group; | ||
1430 | #endif | ||
1431 | #endif | ||
1412 | #endif /* CONFIG_SYSFS */ | 1432 | #endif /* CONFIG_SYSFS */ |
1413 | 1433 | ||
1414 | error = device_add(dev); | 1434 | error = device_add(dev); |
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig index 63af25458fda..b4ecf267a34b 100644 --- a/net/mac80211/Kconfig +++ b/net/mac80211/Kconfig | |||
@@ -248,7 +248,7 @@ config MAC80211_MHWMP_DEBUG | |||
248 | Do not select this option. | 248 | Do not select this option. |
249 | 249 | ||
250 | config MAC80211_MESH_SYNC_DEBUG | 250 | config MAC80211_MESH_SYNC_DEBUG |
251 | bool "Verbose mesh mesh synchronization debugging" | 251 | bool "Verbose mesh synchronization debugging" |
252 | depends on MAC80211_DEBUG_MENU | 252 | depends on MAC80211_DEBUG_MENU |
253 | depends on MAC80211_MESH | 253 | depends on MAC80211_MESH |
254 | ---help--- | 254 | ---help--- |
diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index a7dd110faafa..4911202334d9 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile | |||
@@ -8,6 +8,7 @@ mac80211-y := \ | |||
8 | wpa.o \ | 8 | wpa.o \ |
9 | scan.o offchannel.o \ | 9 | scan.o offchannel.o \ |
10 | ht.o agg-tx.o agg-rx.o \ | 10 | ht.o agg-tx.o agg-rx.o \ |
11 | vht.o \ | ||
11 | ibss.o \ | 12 | ibss.o \ |
12 | iface.o \ | 13 | iface.o \ |
13 | rate.o \ | 14 | rate.o \ |
diff --git a/net/mac80211/aes_cmac.c b/net/mac80211/aes_cmac.c index a04752e91023..537488cbf941 100644 --- a/net/mac80211/aes_cmac.c +++ b/net/mac80211/aes_cmac.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/crypto.h> | 12 | #include <linux/crypto.h> |
13 | #include <linux/export.h> | ||
13 | #include <linux/err.h> | 14 | #include <linux/err.h> |
14 | #include <crypto/aes.h> | 15 | #include <crypto/aes.h> |
15 | 16 | ||
@@ -126,3 +127,20 @@ void ieee80211_aes_cmac_key_free(struct crypto_cipher *tfm) | |||
126 | { | 127 | { |
127 | crypto_free_cipher(tfm); | 128 | crypto_free_cipher(tfm); |
128 | } | 129 | } |
130 | |||
131 | void ieee80211_aes_cmac_calculate_k1_k2(struct ieee80211_key_conf *keyconf, | ||
132 | u8 *k1, u8 *k2) | ||
133 | { | ||
134 | u8 l[AES_BLOCK_SIZE] = {}; | ||
135 | struct ieee80211_key *key = | ||
136 | container_of(keyconf, struct ieee80211_key, conf); | ||
137 | |||
138 | crypto_cipher_encrypt_one(key->u.aes_cmac.tfm, l, l); | ||
139 | |||
140 | memcpy(k1, l, AES_BLOCK_SIZE); | ||
141 | gf_mulx(k1); | ||
142 | |||
143 | memcpy(k2, k1, AES_BLOCK_SIZE); | ||
144 | gf_mulx(k2); | ||
145 | } | ||
146 | EXPORT_SYMBOL(ieee80211_aes_cmac_calculate_k1_k2); | ||
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 05f3a313db88..c46d4ee1c298 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -372,10 +372,11 @@ static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy, | |||
372 | 372 | ||
373 | static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx) | 373 | static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx) |
374 | { | 374 | { |
375 | enum ieee80211_band band = ieee80211_get_sdata_band(sta->sdata); | ||
376 | |||
375 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { | 377 | if (!(rate->flags & RATE_INFO_FLAGS_MCS)) { |
376 | struct ieee80211_supported_band *sband; | 378 | struct ieee80211_supported_band *sband; |
377 | sband = sta->local->hw.wiphy->bands[ | 379 | sband = sta->local->hw.wiphy->bands[band]; |
378 | sta->local->oper_channel->band]; | ||
379 | rate->legacy = sband->bitrates[idx].bitrate; | 380 | rate->legacy = sband->bitrates[idx].bitrate; |
380 | } else | 381 | } else |
381 | rate->mcs = idx; | 382 | rate->mcs = idx; |
@@ -532,6 +533,8 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy, | |||
532 | u64 *data) | 533 | u64 *data) |
533 | { | 534 | { |
534 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 535 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
536 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
537 | struct ieee80211_channel *channel; | ||
535 | struct sta_info *sta; | 538 | struct sta_info *sta; |
536 | struct ieee80211_local *local = sdata->local; | 539 | struct ieee80211_local *local = sdata->local; |
537 | struct station_info sinfo; | 540 | struct station_info sinfo; |
@@ -607,19 +610,26 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy, | |||
607 | do_survey: | 610 | do_survey: |
608 | i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; | 611 | i = STA_STATS_LEN - STA_STATS_SURVEY_LEN; |
609 | /* Get survey stats for current channel */ | 612 | /* Get survey stats for current channel */ |
610 | q = 0; | 613 | survey.filled = 0; |
611 | while (true) { | ||
612 | survey.filled = 0; | ||
613 | if (drv_get_survey(local, q, &survey) != 0) { | ||
614 | survey.filled = 0; | ||
615 | break; | ||
616 | } | ||
617 | 614 | ||
618 | if (survey.channel && | 615 | rcu_read_lock(); |
619 | (local->oper_channel->center_freq == | 616 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
620 | survey.channel->center_freq)) | 617 | if (chanctx_conf) |
621 | break; | 618 | channel = chanctx_conf->channel; |
622 | q++; | 619 | else |
620 | channel = NULL; | ||
621 | rcu_read_unlock(); | ||
622 | |||
623 | if (channel) { | ||
624 | q = 0; | ||
625 | do { | ||
626 | survey.filled = 0; | ||
627 | if (drv_get_survey(local, q, &survey) != 0) { | ||
628 | survey.filled = 0; | ||
629 | break; | ||
630 | } | ||
631 | q++; | ||
632 | } while (channel != survey.channel); | ||
623 | } | 633 | } |
624 | 634 | ||
625 | if (survey.filled) | 635 | if (survey.filled) |
@@ -724,47 +734,42 @@ static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev, | |||
724 | return ret; | 734 | return ret; |
725 | } | 735 | } |
726 | 736 | ||
727 | static int ieee80211_set_channel(struct wiphy *wiphy, | 737 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, |
728 | struct net_device *netdev, | 738 | struct ieee80211_channel *chan, |
729 | struct ieee80211_channel *chan, | 739 | enum nl80211_channel_type channel_type) |
730 | enum nl80211_channel_type channel_type) | ||
731 | { | 740 | { |
732 | struct ieee80211_local *local = wiphy_priv(wiphy); | 741 | struct ieee80211_local *local = wiphy_priv(wiphy); |
733 | struct ieee80211_sub_if_data *sdata = NULL; | 742 | struct ieee80211_sub_if_data *sdata; |
734 | 743 | int ret = 0; | |
735 | if (netdev) | ||
736 | sdata = IEEE80211_DEV_TO_SUB_IF(netdev); | ||
737 | |||
738 | switch (ieee80211_get_channel_mode(local, NULL)) { | ||
739 | case CHAN_MODE_HOPPING: | ||
740 | return -EBUSY; | ||
741 | case CHAN_MODE_FIXED: | ||
742 | if (local->oper_channel != chan || | ||
743 | (!sdata && local->_oper_channel_type != channel_type)) | ||
744 | return -EBUSY; | ||
745 | if (!sdata && local->_oper_channel_type == channel_type) | ||
746 | return 0; | ||
747 | break; | ||
748 | case CHAN_MODE_UNDEFINED: | ||
749 | break; | ||
750 | } | ||
751 | |||
752 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) | ||
753 | return -EBUSY; | ||
754 | 744 | ||
755 | local->oper_channel = chan; | 745 | if (local->monitor_channel == chan && |
746 | local->monitor_channel_type == channel_type) | ||
747 | return 0; | ||
756 | 748 | ||
757 | /* auto-detects changes */ | 749 | mutex_lock(&local->iflist_mtx); |
758 | ieee80211_hw_config(local, 0); | 750 | if (local->use_chanctx) { |
751 | sdata = rcu_dereference_protected( | ||
752 | local->monitor_sdata, | ||
753 | lockdep_is_held(&local->iflist_mtx)); | ||
754 | if (sdata) { | ||
755 | ieee80211_vif_release_channel(sdata); | ||
756 | ret = ieee80211_vif_use_channel( | ||
757 | sdata, chan, channel_type, | ||
758 | IEEE80211_CHANCTX_EXCLUSIVE); | ||
759 | } | ||
760 | } else if (local->open_count == local->monitors) { | ||
761 | local->_oper_channel = chan; | ||
762 | local->_oper_channel_type = channel_type; | ||
763 | ieee80211_hw_config(local, 0); | ||
764 | } | ||
759 | 765 | ||
760 | return 0; | 766 | if (ret == 0) { |
761 | } | 767 | local->monitor_channel = chan; |
768 | local->monitor_channel_type = channel_type; | ||
769 | } | ||
770 | mutex_unlock(&local->iflist_mtx); | ||
762 | 771 | ||
763 | static int ieee80211_set_monitor_channel(struct wiphy *wiphy, | 772 | return ret; |
764 | struct ieee80211_channel *chan, | ||
765 | enum nl80211_channel_type channel_type) | ||
766 | { | ||
767 | return ieee80211_set_channel(wiphy, NULL, chan, channel_type); | ||
768 | } | 773 | } |
769 | 774 | ||
770 | static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, | 775 | static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, |
@@ -879,8 +884,13 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, | |||
879 | if (old) | 884 | if (old) |
880 | return -EALREADY; | 885 | return -EALREADY; |
881 | 886 | ||
882 | err = ieee80211_set_channel(wiphy, dev, params->channel, | 887 | /* TODO: make hostapd tell us what it wants */ |
883 | params->channel_type); | 888 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
889 | sdata->needed_rx_chains = sdata->local->rx_chains; | ||
890 | |||
891 | err = ieee80211_vif_use_channel(sdata, params->channel, | ||
892 | params->channel_type, | ||
893 | IEEE80211_CHANCTX_SHARED); | ||
884 | if (err) | 894 | if (err) |
885 | return err; | 895 | return err; |
886 | 896 | ||
@@ -912,6 +922,15 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev, | |||
912 | return err; | 922 | return err; |
913 | changed |= err; | 923 | changed |= err; |
914 | 924 | ||
925 | err = drv_start_ap(sdata->local, sdata); | ||
926 | if (err) { | ||
927 | old = rtnl_dereference(sdata->u.ap.beacon); | ||
928 | if (old) | ||
929 | kfree_rcu(old, rcu_head); | ||
930 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); | ||
931 | return err; | ||
932 | } | ||
933 | |||
915 | ieee80211_bss_info_change_notify(sdata, changed); | 934 | ieee80211_bss_info_change_notify(sdata, changed); |
916 | 935 | ||
917 | netif_carrier_on(dev); | 936 | netif_carrier_on(dev); |
@@ -943,26 +962,40 @@ static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev, | |||
943 | 962 | ||
944 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) | 963 | static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
945 | { | 964 | { |
946 | struct ieee80211_sub_if_data *sdata, *vlan; | 965 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
947 | struct beacon_data *old; | 966 | struct ieee80211_sub_if_data *vlan; |
948 | 967 | struct ieee80211_local *local = sdata->local; | |
949 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 968 | struct beacon_data *old_beacon; |
969 | struct probe_resp *old_probe_resp; | ||
950 | 970 | ||
951 | old = rtnl_dereference(sdata->u.ap.beacon); | 971 | old_beacon = rtnl_dereference(sdata->u.ap.beacon); |
952 | if (!old) | 972 | if (!old_beacon) |
953 | return -ENOENT; | 973 | return -ENOENT; |
974 | old_probe_resp = rtnl_dereference(sdata->u.ap.probe_resp); | ||
954 | 975 | ||
976 | /* turn off carrier for this interface and dependent VLANs */ | ||
955 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) | 977 | list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) |
956 | netif_carrier_off(vlan->dev); | 978 | netif_carrier_off(vlan->dev); |
957 | netif_carrier_off(dev); | 979 | netif_carrier_off(dev); |
958 | 980 | ||
981 | /* remove beacon and probe response */ | ||
959 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); | 982 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); |
983 | RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); | ||
984 | kfree_rcu(old_beacon, rcu_head); | ||
985 | if (old_probe_resp) | ||
986 | kfree_rcu(old_probe_resp, rcu_head); | ||
960 | 987 | ||
961 | kfree_rcu(old, rcu_head); | 988 | sta_info_flush(local, sdata); |
962 | |||
963 | sta_info_flush(sdata->local, sdata); | ||
964 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); | 989 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
965 | 990 | ||
991 | drv_stop_ap(sdata->local, sdata); | ||
992 | |||
993 | /* free all potentially still buffered bcast frames */ | ||
994 | local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps.bc_buf); | ||
995 | skb_queue_purge(&sdata->u.ap.ps.bc_buf); | ||
996 | |||
997 | ieee80211_vif_release_channel(sdata); | ||
998 | |||
966 | return 0; | 999 | return 0; |
967 | } | 1000 | } |
968 | 1001 | ||
@@ -1019,9 +1052,10 @@ static int sta_apply_parameters(struct ieee80211_local *local, | |||
1019 | int i, j; | 1052 | int i, j; |
1020 | struct ieee80211_supported_band *sband; | 1053 | struct ieee80211_supported_band *sband; |
1021 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 1054 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
1055 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
1022 | u32 mask, set; | 1056 | u32 mask, set; |
1023 | 1057 | ||
1024 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 1058 | sband = local->hw.wiphy->bands[band]; |
1025 | 1059 | ||
1026 | mask = params->sta_flags_mask; | 1060 | mask = params->sta_flags_mask; |
1027 | set = params->sta_flags_set; | 1061 | set = params->sta_flags_set; |
@@ -1136,7 +1170,7 @@ static int sta_apply_parameters(struct ieee80211_local *local, | |||
1136 | rates |= BIT(j); | 1170 | rates |= BIT(j); |
1137 | } | 1171 | } |
1138 | } | 1172 | } |
1139 | sta->sta.supp_rates[local->oper_channel->band] = rates; | 1173 | sta->sta.supp_rates[band] = rates; |
1140 | } | 1174 | } |
1141 | 1175 | ||
1142 | if (params->ht_capa) | 1176 | if (params->ht_capa) |
@@ -1144,6 +1178,11 @@ static int sta_apply_parameters(struct ieee80211_local *local, | |||
1144 | params->ht_capa, | 1178 | params->ht_capa, |
1145 | &sta->sta.ht_cap); | 1179 | &sta->sta.ht_cap); |
1146 | 1180 | ||
1181 | if (params->vht_capa) | ||
1182 | ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, | ||
1183 | params->vht_capa, | ||
1184 | &sta->sta.vht_cap); | ||
1185 | |||
1147 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | 1186 | if (ieee80211_vif_is_mesh(&sdata->vif)) { |
1148 | #ifdef CONFIG_MAC80211_MESH | 1187 | #ifdef CONFIG_MAC80211_MESH |
1149 | if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) | 1188 | if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED) |
@@ -1664,8 +1703,13 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev, | |||
1664 | if (err) | 1703 | if (err) |
1665 | return err; | 1704 | return err; |
1666 | 1705 | ||
1667 | err = ieee80211_set_channel(wiphy, dev, setup->channel, | 1706 | /* can mesh use other SMPS modes? */ |
1668 | setup->channel_type); | 1707 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
1708 | sdata->needed_rx_chains = sdata->local->rx_chains; | ||
1709 | |||
1710 | err = ieee80211_vif_use_channel(sdata, setup->channel, | ||
1711 | setup->channel_type, | ||
1712 | IEEE80211_CHANCTX_SHARED); | ||
1669 | if (err) | 1713 | if (err) |
1670 | return err; | 1714 | return err; |
1671 | 1715 | ||
@@ -1679,6 +1723,7 @@ static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev) | |||
1679 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1723 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1680 | 1724 | ||
1681 | ieee80211_stop_mesh(sdata); | 1725 | ieee80211_stop_mesh(sdata); |
1726 | ieee80211_vif_release_channel(sdata); | ||
1682 | 1727 | ||
1683 | return 0; | 1728 | return 0; |
1684 | } | 1729 | } |
@@ -1688,10 +1733,14 @@ static int ieee80211_change_bss(struct wiphy *wiphy, | |||
1688 | struct net_device *dev, | 1733 | struct net_device *dev, |
1689 | struct bss_parameters *params) | 1734 | struct bss_parameters *params) |
1690 | { | 1735 | { |
1691 | struct ieee80211_sub_if_data *sdata; | 1736 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1737 | enum ieee80211_band band; | ||
1692 | u32 changed = 0; | 1738 | u32 changed = 0; |
1693 | 1739 | ||
1694 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1740 | if (!rtnl_dereference(sdata->u.ap.beacon)) |
1741 | return -ENOENT; | ||
1742 | |||
1743 | band = ieee80211_get_sdata_band(sdata); | ||
1695 | 1744 | ||
1696 | if (params->use_cts_prot >= 0) { | 1745 | if (params->use_cts_prot >= 0) { |
1697 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; | 1746 | sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; |
@@ -1704,7 +1753,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy, | |||
1704 | } | 1753 | } |
1705 | 1754 | ||
1706 | if (!sdata->vif.bss_conf.use_short_slot && | 1755 | if (!sdata->vif.bss_conf.use_short_slot && |
1707 | sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) { | 1756 | band == IEEE80211_BAND_5GHZ) { |
1708 | sdata->vif.bss_conf.use_short_slot = true; | 1757 | sdata->vif.bss_conf.use_short_slot = true; |
1709 | changed |= BSS_CHANGED_ERP_SLOT; | 1758 | changed |= BSS_CHANGED_ERP_SLOT; |
1710 | } | 1759 | } |
@@ -1718,9 +1767,7 @@ static int ieee80211_change_bss(struct wiphy *wiphy, | |||
1718 | if (params->basic_rates) { | 1767 | if (params->basic_rates) { |
1719 | int i, j; | 1768 | int i, j; |
1720 | u32 rates = 0; | 1769 | u32 rates = 0; |
1721 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1770 | struct ieee80211_supported_band *sband = wiphy->bands[band]; |
1722 | struct ieee80211_supported_band *sband = | ||
1723 | wiphy->bands[local->oper_channel->band]; | ||
1724 | 1771 | ||
1725 | for (i = 0; i < params->basic_rates_len; i++) { | 1772 | for (i = 0; i < params->basic_rates_len; i++) { |
1726 | int rate = (params->basic_rates[i] & 0x7f) * 5; | 1773 | int rate = (params->basic_rates[i] & 0x7f) * 5; |
@@ -1829,7 +1876,16 @@ static int ieee80211_scan(struct wiphy *wiphy, | |||
1829 | * beaconing hasn't been configured yet | 1876 | * beaconing hasn't been configured yet |
1830 | */ | 1877 | */ |
1831 | case NL80211_IFTYPE_AP: | 1878 | case NL80211_IFTYPE_AP: |
1832 | if (sdata->u.ap.beacon) | 1879 | /* |
1880 | * If the scan has been forced (and the driver supports | ||
1881 | * forcing), don't care about being beaconing already. | ||
1882 | * This will create problems to the attached stations (e.g. all | ||
1883 | * the frames sent while scanning on other channel will be | ||
1884 | * lost) | ||
1885 | */ | ||
1886 | if (sdata->u.ap.beacon && | ||
1887 | (!(wiphy->features & NL80211_FEATURE_AP_SCAN) || | ||
1888 | !(req->flags & NL80211_SCAN_FLAG_AP))) | ||
1833 | return -EOPNOTSUPP; | 1889 | return -EOPNOTSUPP; |
1834 | break; | 1890 | break; |
1835 | default: | 1891 | default: |
@@ -1872,20 +1928,6 @@ static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev, | |||
1872 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, | 1928 | static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev, |
1873 | struct cfg80211_assoc_request *req) | 1929 | struct cfg80211_assoc_request *req) |
1874 | { | 1930 | { |
1875 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
1876 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1877 | |||
1878 | switch (ieee80211_get_channel_mode(local, sdata)) { | ||
1879 | case CHAN_MODE_HOPPING: | ||
1880 | return -EBUSY; | ||
1881 | case CHAN_MODE_FIXED: | ||
1882 | if (local->oper_channel == req->bss->channel) | ||
1883 | break; | ||
1884 | return -EBUSY; | ||
1885 | case CHAN_MODE_UNDEFINED: | ||
1886 | break; | ||
1887 | } | ||
1888 | |||
1889 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); | 1931 | return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req); |
1890 | } | 1932 | } |
1891 | 1933 | ||
@@ -1904,30 +1946,22 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, | |||
1904 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, | 1946 | static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
1905 | struct cfg80211_ibss_params *params) | 1947 | struct cfg80211_ibss_params *params) |
1906 | { | 1948 | { |
1907 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1949 | return ieee80211_ibss_join(IEEE80211_DEV_TO_SUB_IF(dev), params); |
1908 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
1909 | |||
1910 | switch (ieee80211_get_channel_mode(local, sdata)) { | ||
1911 | case CHAN_MODE_HOPPING: | ||
1912 | return -EBUSY; | ||
1913 | case CHAN_MODE_FIXED: | ||
1914 | if (!params->channel_fixed) | ||
1915 | return -EBUSY; | ||
1916 | if (local->oper_channel == params->channel) | ||
1917 | break; | ||
1918 | return -EBUSY; | ||
1919 | case CHAN_MODE_UNDEFINED: | ||
1920 | break; | ||
1921 | } | ||
1922 | |||
1923 | return ieee80211_ibss_join(sdata, params); | ||
1924 | } | 1950 | } |
1925 | 1951 | ||
1926 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | 1952 | static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
1927 | { | 1953 | { |
1954 | return ieee80211_ibss_leave(IEEE80211_DEV_TO_SUB_IF(dev)); | ||
1955 | } | ||
1956 | |||
1957 | static int ieee80211_set_mcast_rate(struct wiphy *wiphy, struct net_device *dev, | ||
1958 | int rate[IEEE80211_NUM_BANDS]) | ||
1959 | { | ||
1928 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 1960 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
1929 | 1961 | ||
1930 | return ieee80211_ibss_leave(sdata); | 1962 | memcpy(sdata->vif.bss_conf.mcast_rate, rate, sizeof(rate)); |
1963 | |||
1964 | return 0; | ||
1931 | } | 1965 | } |
1932 | 1966 | ||
1933 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) | 1967 | static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
@@ -1968,41 +2002,65 @@ static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) | |||
1968 | } | 2002 | } |
1969 | 2003 | ||
1970 | static int ieee80211_set_tx_power(struct wiphy *wiphy, | 2004 | static int ieee80211_set_tx_power(struct wiphy *wiphy, |
2005 | struct wireless_dev *wdev, | ||
1971 | enum nl80211_tx_power_setting type, int mbm) | 2006 | enum nl80211_tx_power_setting type, int mbm) |
1972 | { | 2007 | { |
1973 | struct ieee80211_local *local = wiphy_priv(wiphy); | 2008 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1974 | struct ieee80211_channel *chan = local->oper_channel; | 2009 | struct ieee80211_sub_if_data *sdata; |
1975 | u32 changes = 0; | 2010 | |
2011 | if (wdev) { | ||
2012 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | ||
2013 | |||
2014 | switch (type) { | ||
2015 | case NL80211_TX_POWER_AUTOMATIC: | ||
2016 | sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL; | ||
2017 | break; | ||
2018 | case NL80211_TX_POWER_LIMITED: | ||
2019 | case NL80211_TX_POWER_FIXED: | ||
2020 | if (mbm < 0 || (mbm % 100)) | ||
2021 | return -EOPNOTSUPP; | ||
2022 | sdata->user_power_level = MBM_TO_DBM(mbm); | ||
2023 | break; | ||
2024 | } | ||
2025 | |||
2026 | ieee80211_recalc_txpower(sdata); | ||
2027 | |||
2028 | return 0; | ||
2029 | } | ||
1976 | 2030 | ||
1977 | switch (type) { | 2031 | switch (type) { |
1978 | case NL80211_TX_POWER_AUTOMATIC: | 2032 | case NL80211_TX_POWER_AUTOMATIC: |
1979 | local->user_power_level = -1; | 2033 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
1980 | break; | 2034 | break; |
1981 | case NL80211_TX_POWER_LIMITED: | 2035 | case NL80211_TX_POWER_LIMITED: |
1982 | if (mbm < 0 || (mbm % 100)) | ||
1983 | return -EOPNOTSUPP; | ||
1984 | local->user_power_level = MBM_TO_DBM(mbm); | ||
1985 | break; | ||
1986 | case NL80211_TX_POWER_FIXED: | 2036 | case NL80211_TX_POWER_FIXED: |
1987 | if (mbm < 0 || (mbm % 100)) | 2037 | if (mbm < 0 || (mbm % 100)) |
1988 | return -EOPNOTSUPP; | 2038 | return -EOPNOTSUPP; |
1989 | /* TODO: move to cfg80211 when it knows the channel */ | ||
1990 | if (MBM_TO_DBM(mbm) > chan->max_power) | ||
1991 | return -EINVAL; | ||
1992 | local->user_power_level = MBM_TO_DBM(mbm); | 2039 | local->user_power_level = MBM_TO_DBM(mbm); |
1993 | break; | 2040 | break; |
1994 | } | 2041 | } |
1995 | 2042 | ||
1996 | ieee80211_hw_config(local, changes); | 2043 | mutex_lock(&local->iflist_mtx); |
2044 | list_for_each_entry(sdata, &local->interfaces, list) | ||
2045 | sdata->user_power_level = local->user_power_level; | ||
2046 | list_for_each_entry(sdata, &local->interfaces, list) | ||
2047 | ieee80211_recalc_txpower(sdata); | ||
2048 | mutex_unlock(&local->iflist_mtx); | ||
1997 | 2049 | ||
1998 | return 0; | 2050 | return 0; |
1999 | } | 2051 | } |
2000 | 2052 | ||
2001 | static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm) | 2053 | static int ieee80211_get_tx_power(struct wiphy *wiphy, |
2054 | struct wireless_dev *wdev, | ||
2055 | int *dbm) | ||
2002 | { | 2056 | { |
2003 | struct ieee80211_local *local = wiphy_priv(wiphy); | 2057 | struct ieee80211_local *local = wiphy_priv(wiphy); |
2058 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | ||
2004 | 2059 | ||
2005 | *dbm = local->hw.conf.power_level; | 2060 | if (!local->use_chanctx) |
2061 | *dbm = local->hw.conf.power_level; | ||
2062 | else | ||
2063 | *dbm = sdata->vif.bss_conf.txpower; | ||
2006 | 2064 | ||
2007 | return 0; | 2065 | return 0; |
2008 | } | 2066 | } |
@@ -2067,13 +2125,12 @@ int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, | |||
2067 | 2125 | ||
2068 | /* | 2126 | /* |
2069 | * If not associated, or current association is not an HT | 2127 | * If not associated, or current association is not an HT |
2070 | * association, there's no need to send an action frame. | 2128 | * association, there's no need to do anything, just store |
2129 | * the new value until we associate. | ||
2071 | */ | 2130 | */ |
2072 | if (!sdata->u.mgd.associated || | 2131 | if (!sdata->u.mgd.associated || |
2073 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) { | 2132 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) |
2074 | ieee80211_recalc_smps(sdata->local); | ||
2075 | return 0; | 2133 | return 0; |
2076 | } | ||
2077 | 2134 | ||
2078 | ap = sdata->u.mgd.associated->bssid; | 2135 | ap = sdata->u.mgd.associated->bssid; |
2079 | 2136 | ||
@@ -2189,6 +2246,9 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local, | |||
2189 | 2246 | ||
2190 | lockdep_assert_held(&local->mtx); | 2247 | lockdep_assert_held(&local->mtx); |
2191 | 2248 | ||
2249 | if (local->use_chanctx && !local->ops->remain_on_channel) | ||
2250 | return -EOPNOTSUPP; | ||
2251 | |||
2192 | roc = kzalloc(sizeof(*roc), GFP_KERNEL); | 2252 | roc = kzalloc(sizeof(*roc), GFP_KERNEL); |
2193 | if (!roc) | 2253 | if (!roc) |
2194 | return -ENOMEM; | 2254 | return -ENOMEM; |
@@ -2332,13 +2392,22 @@ static int ieee80211_start_roc_work(struct ieee80211_local *local, | |||
2332 | list_add_tail(&roc->list, &local->roc_list); | 2392 | list_add_tail(&roc->list, &local->roc_list); |
2333 | 2393 | ||
2334 | /* | 2394 | /* |
2335 | * cookie is either the roc (for normal roc) | 2395 | * cookie is either the roc cookie (for normal roc) |
2336 | * or the SKB (for mgmt TX) | 2396 | * or the SKB (for mgmt TX) |
2337 | */ | 2397 | */ |
2338 | if (txskb) | 2398 | if (!txskb) { |
2399 | /* local->mtx protects this */ | ||
2400 | local->roc_cookie_counter++; | ||
2401 | roc->cookie = local->roc_cookie_counter; | ||
2402 | /* wow, you wrapped 64 bits ... more likely a bug */ | ||
2403 | if (WARN_ON(roc->cookie == 0)) { | ||
2404 | roc->cookie = 1; | ||
2405 | local->roc_cookie_counter++; | ||
2406 | } | ||
2407 | *cookie = roc->cookie; | ||
2408 | } else { | ||
2339 | *cookie = (unsigned long)txskb; | 2409 | *cookie = (unsigned long)txskb; |
2340 | else | 2410 | } |
2341 | *cookie = (unsigned long)roc; | ||
2342 | 2411 | ||
2343 | return 0; | 2412 | return 0; |
2344 | } | 2413 | } |
@@ -2373,7 +2442,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local, | |||
2373 | struct ieee80211_roc_work *dep, *tmp2; | 2442 | struct ieee80211_roc_work *dep, *tmp2; |
2374 | 2443 | ||
2375 | list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) { | 2444 | list_for_each_entry_safe(dep, tmp2, &roc->dependents, list) { |
2376 | if (!mgmt_tx && (unsigned long)dep != cookie) | 2445 | if (!mgmt_tx && dep->cookie != cookie) |
2377 | continue; | 2446 | continue; |
2378 | else if (mgmt_tx && dep->mgmt_tx_cookie != cookie) | 2447 | else if (mgmt_tx && dep->mgmt_tx_cookie != cookie) |
2379 | continue; | 2448 | continue; |
@@ -2385,7 +2454,7 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local, | |||
2385 | return 0; | 2454 | return 0; |
2386 | } | 2455 | } |
2387 | 2456 | ||
2388 | if (!mgmt_tx && (unsigned long)roc != cookie) | 2457 | if (!mgmt_tx && roc->cookie != cookie) |
2389 | continue; | 2458 | continue; |
2390 | else if (mgmt_tx && roc->mgmt_tx_cookie != cookie) | 2459 | else if (mgmt_tx && roc->mgmt_tx_cookie != cookie) |
2391 | continue; | 2460 | continue; |
@@ -2515,10 +2584,20 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
2515 | 2584 | ||
2516 | /* Check if the operating channel is the requested channel */ | 2585 | /* Check if the operating channel is the requested channel */ |
2517 | if (!need_offchan) { | 2586 | if (!need_offchan) { |
2518 | need_offchan = chan != local->oper_channel; | 2587 | struct ieee80211_chanctx_conf *chanctx_conf; |
2519 | if (channel_type_valid && | 2588 | |
2520 | channel_type != local->_oper_channel_type) | 2589 | rcu_read_lock(); |
2590 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
2591 | |||
2592 | if (chanctx_conf) { | ||
2593 | need_offchan = chan != chanctx_conf->channel; | ||
2594 | if (channel_type_valid && | ||
2595 | channel_type != chanctx_conf->channel_type) | ||
2596 | need_offchan = true; | ||
2597 | } else { | ||
2521 | need_offchan = true; | 2598 | need_offchan = true; |
2599 | } | ||
2600 | rcu_read_unlock(); | ||
2522 | } | 2601 | } |
2523 | 2602 | ||
2524 | if (need_offchan && !offchan) { | 2603 | if (need_offchan && !offchan) { |
@@ -2594,6 +2673,9 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy, | |||
2594 | else | 2673 | else |
2595 | local->probe_req_reg--; | 2674 | local->probe_req_reg--; |
2596 | 2675 | ||
2676 | if (!local->open_count) | ||
2677 | break; | ||
2678 | |||
2597 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); | 2679 | ieee80211_queue_work(&local->hw, &local->reconfig_filter); |
2598 | break; | 2680 | break; |
2599 | default: | 2681 | default: |
@@ -2667,7 +2749,7 @@ static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata) | |||
2667 | u16 capab; | 2749 | u16 capab; |
2668 | 2750 | ||
2669 | capab = 0; | 2751 | capab = 0; |
2670 | if (local->oper_channel->band != IEEE80211_BAND_2GHZ) | 2752 | if (ieee80211_get_sdata_band(sdata) != IEEE80211_BAND_2GHZ) |
2671 | return capab; | 2753 | return capab; |
2672 | 2754 | ||
2673 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) | 2755 | if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) |
@@ -2699,7 +2781,7 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | |||
2699 | u16 status_code, struct sk_buff *skb) | 2781 | u16 status_code, struct sk_buff *skb) |
2700 | { | 2782 | { |
2701 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2783 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2702 | struct ieee80211_local *local = sdata->local; | 2784 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
2703 | struct ieee80211_tdls_data *tf; | 2785 | struct ieee80211_tdls_data *tf; |
2704 | 2786 | ||
2705 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); | 2787 | tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u)); |
@@ -2719,10 +2801,8 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | |||
2719 | tf->u.setup_req.capability = | 2801 | tf->u.setup_req.capability = |
2720 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | 2802 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
2721 | 2803 | ||
2722 | ieee80211_add_srates_ie(sdata, skb, false, | 2804 | ieee80211_add_srates_ie(sdata, skb, false, band); |
2723 | local->oper_channel->band); | 2805 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
2724 | ieee80211_add_ext_srates_ie(sdata, skb, false, | ||
2725 | local->oper_channel->band); | ||
2726 | ieee80211_tdls_add_ext_capab(skb); | 2806 | ieee80211_tdls_add_ext_capab(skb); |
2727 | break; | 2807 | break; |
2728 | case WLAN_TDLS_SETUP_RESPONSE: | 2808 | case WLAN_TDLS_SETUP_RESPONSE: |
@@ -2735,10 +2815,8 @@ ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev, | |||
2735 | tf->u.setup_resp.capability = | 2815 | tf->u.setup_resp.capability = |
2736 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | 2816 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
2737 | 2817 | ||
2738 | ieee80211_add_srates_ie(sdata, skb, false, | 2818 | ieee80211_add_srates_ie(sdata, skb, false, band); |
2739 | local->oper_channel->band); | 2819 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
2740 | ieee80211_add_ext_srates_ie(sdata, skb, false, | ||
2741 | local->oper_channel->band); | ||
2742 | ieee80211_tdls_add_ext_capab(skb); | 2820 | ieee80211_tdls_add_ext_capab(skb); |
2743 | break; | 2821 | break; |
2744 | case WLAN_TDLS_SETUP_CONFIRM: | 2822 | case WLAN_TDLS_SETUP_CONFIRM: |
@@ -2776,7 +2854,7 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, | |||
2776 | u16 status_code, struct sk_buff *skb) | 2854 | u16 status_code, struct sk_buff *skb) |
2777 | { | 2855 | { |
2778 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2856 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2779 | struct ieee80211_local *local = sdata->local; | 2857 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
2780 | struct ieee80211_mgmt *mgmt; | 2858 | struct ieee80211_mgmt *mgmt; |
2781 | 2859 | ||
2782 | mgmt = (void *)skb_put(skb, 24); | 2860 | mgmt = (void *)skb_put(skb, 24); |
@@ -2799,10 +2877,8 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev, | |||
2799 | mgmt->u.action.u.tdls_discover_resp.capability = | 2877 | mgmt->u.action.u.tdls_discover_resp.capability = |
2800 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); | 2878 | cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata)); |
2801 | 2879 | ||
2802 | ieee80211_add_srates_ie(sdata, skb, false, | 2880 | ieee80211_add_srates_ie(sdata, skb, false, band); |
2803 | local->oper_channel->band); | 2881 | ieee80211_add_ext_srates_ie(sdata, skb, false, band); |
2804 | ieee80211_add_ext_srates_ie(sdata, skb, false, | ||
2805 | local->oper_channel->band); | ||
2806 | ieee80211_tdls_add_ext_capab(skb); | 2882 | ieee80211_tdls_add_ext_capab(skb); |
2807 | break; | 2883 | break; |
2808 | default: | 2884 | default: |
@@ -2819,7 +2895,6 @@ static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | |||
2819 | { | 2895 | { |
2820 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 2896 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
2821 | struct ieee80211_local *local = sdata->local; | 2897 | struct ieee80211_local *local = sdata->local; |
2822 | struct ieee80211_tx_info *info; | ||
2823 | struct sk_buff *skb = NULL; | 2898 | struct sk_buff *skb = NULL; |
2824 | bool send_direct; | 2899 | bool send_direct; |
2825 | int ret; | 2900 | int ret; |
@@ -2845,7 +2920,6 @@ static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, | |||
2845 | if (!skb) | 2920 | if (!skb) |
2846 | return -ENOMEM; | 2921 | return -ENOMEM; |
2847 | 2922 | ||
2848 | info = IEEE80211_SKB_CB(skb); | ||
2849 | skb_reserve(skb, local->hw.extra_tx_headroom); | 2923 | skb_reserve(skb, local->hw.extra_tx_headroom); |
2850 | 2924 | ||
2851 | switch (action_code) { | 2925 | switch (action_code) { |
@@ -2982,12 +3056,19 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, | |||
2982 | bool qos; | 3056 | bool qos; |
2983 | struct ieee80211_tx_info *info; | 3057 | struct ieee80211_tx_info *info; |
2984 | struct sta_info *sta; | 3058 | struct sta_info *sta; |
3059 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
3060 | enum ieee80211_band band; | ||
2985 | 3061 | ||
2986 | rcu_read_lock(); | 3062 | rcu_read_lock(); |
3063 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
3064 | if (WARN_ON(!chanctx_conf)) { | ||
3065 | rcu_read_unlock(); | ||
3066 | return -EINVAL; | ||
3067 | } | ||
3068 | band = chanctx_conf->channel->band; | ||
2987 | sta = sta_info_get(sdata, peer); | 3069 | sta = sta_info_get(sdata, peer); |
2988 | if (sta) { | 3070 | if (sta) { |
2989 | qos = test_sta_flag(sta, WLAN_STA_WME); | 3071 | qos = test_sta_flag(sta, WLAN_STA_WME); |
2990 | rcu_read_unlock(); | ||
2991 | } else { | 3072 | } else { |
2992 | rcu_read_unlock(); | 3073 | rcu_read_unlock(); |
2993 | return -ENOLINK; | 3074 | return -ENOLINK; |
@@ -3005,8 +3086,10 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, | |||
3005 | } | 3086 | } |
3006 | 3087 | ||
3007 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); | 3088 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); |
3008 | if (!skb) | 3089 | if (!skb) { |
3090 | rcu_read_unlock(); | ||
3009 | return -ENOMEM; | 3091 | return -ENOMEM; |
3092 | } | ||
3010 | 3093 | ||
3011 | skb->dev = dev; | 3094 | skb->dev = dev; |
3012 | 3095 | ||
@@ -3031,8 +3114,9 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, | |||
3031 | nullfunc->qos_ctrl = cpu_to_le16(7); | 3114 | nullfunc->qos_ctrl = cpu_to_le16(7); |
3032 | 3115 | ||
3033 | local_bh_disable(); | 3116 | local_bh_disable(); |
3034 | ieee80211_xmit(sdata, skb); | 3117 | ieee80211_xmit(sdata, skb, band); |
3035 | local_bh_enable(); | 3118 | local_bh_enable(); |
3119 | rcu_read_unlock(); | ||
3036 | 3120 | ||
3037 | *cookie = (unsigned long) skb; | 3121 | *cookie = (unsigned long) skb; |
3038 | return 0; | 3122 | return 0; |
@@ -3042,10 +3126,19 @@ static struct ieee80211_channel * | |||
3042 | ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, | 3126 | ieee80211_cfg_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, |
3043 | enum nl80211_channel_type *type) | 3127 | enum nl80211_channel_type *type) |
3044 | { | 3128 | { |
3045 | struct ieee80211_local *local = wiphy_priv(wiphy); | 3129 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
3130 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
3131 | struct ieee80211_channel *chan = NULL; | ||
3132 | |||
3133 | rcu_read_lock(); | ||
3134 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
3135 | if (chanctx_conf) { | ||
3136 | *type = chanctx_conf->channel_type; | ||
3137 | chan = chanctx_conf->channel; | ||
3138 | } | ||
3139 | rcu_read_unlock(); | ||
3046 | 3140 | ||
3047 | *type = local->_oper_channel_type; | 3141 | return chan; |
3048 | return local->oper_channel; | ||
3049 | } | 3142 | } |
3050 | 3143 | ||
3051 | #ifdef CONFIG_PM | 3144 | #ifdef CONFIG_PM |
@@ -3100,6 +3193,7 @@ struct cfg80211_ops mac80211_config_ops = { | |||
3100 | .disassoc = ieee80211_disassoc, | 3193 | .disassoc = ieee80211_disassoc, |
3101 | .join_ibss = ieee80211_join_ibss, | 3194 | .join_ibss = ieee80211_join_ibss, |
3102 | .leave_ibss = ieee80211_leave_ibss, | 3195 | .leave_ibss = ieee80211_leave_ibss, |
3196 | .set_mcast_rate = ieee80211_set_mcast_rate, | ||
3103 | .set_wiphy_params = ieee80211_set_wiphy_params, | 3197 | .set_wiphy_params = ieee80211_set_wiphy_params, |
3104 | .set_tx_power = ieee80211_set_tx_power, | 3198 | .set_tx_power = ieee80211_set_tx_power, |
3105 | .get_tx_power = ieee80211_get_tx_power, | 3199 | .get_tx_power = ieee80211_get_tx_power, |
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 0bfc914ddd15..a2b06d40aebf 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c | |||
@@ -3,108 +3,10 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/nl80211.h> | 5 | #include <linux/nl80211.h> |
6 | #include <linux/export.h> | ||
6 | #include <net/cfg80211.h> | 7 | #include <net/cfg80211.h> |
7 | #include "ieee80211_i.h" | 8 | #include "ieee80211_i.h" |
8 | 9 | #include "driver-ops.h" | |
9 | static enum ieee80211_chan_mode | ||
10 | __ieee80211_get_channel_mode(struct ieee80211_local *local, | ||
11 | struct ieee80211_sub_if_data *ignore) | ||
12 | { | ||
13 | struct ieee80211_sub_if_data *sdata; | ||
14 | |||
15 | lockdep_assert_held(&local->iflist_mtx); | ||
16 | |||
17 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
18 | if (sdata == ignore) | ||
19 | continue; | ||
20 | |||
21 | if (!ieee80211_sdata_running(sdata)) | ||
22 | continue; | ||
23 | |||
24 | switch (sdata->vif.type) { | ||
25 | case NL80211_IFTYPE_MONITOR: | ||
26 | continue; | ||
27 | case NL80211_IFTYPE_STATION: | ||
28 | if (!sdata->u.mgd.associated) | ||
29 | continue; | ||
30 | break; | ||
31 | case NL80211_IFTYPE_ADHOC: | ||
32 | if (!sdata->u.ibss.ssid_len) | ||
33 | continue; | ||
34 | if (!sdata->u.ibss.fixed_channel) | ||
35 | return CHAN_MODE_HOPPING; | ||
36 | break; | ||
37 | case NL80211_IFTYPE_AP_VLAN: | ||
38 | /* will also have _AP interface */ | ||
39 | continue; | ||
40 | case NL80211_IFTYPE_AP: | ||
41 | if (!sdata->u.ap.beacon) | ||
42 | continue; | ||
43 | break; | ||
44 | case NL80211_IFTYPE_MESH_POINT: | ||
45 | if (!sdata->wdev.mesh_id_len) | ||
46 | continue; | ||
47 | break; | ||
48 | default: | ||
49 | break; | ||
50 | } | ||
51 | |||
52 | return CHAN_MODE_FIXED; | ||
53 | } | ||
54 | |||
55 | return CHAN_MODE_UNDEFINED; | ||
56 | } | ||
57 | |||
58 | enum ieee80211_chan_mode | ||
59 | ieee80211_get_channel_mode(struct ieee80211_local *local, | ||
60 | struct ieee80211_sub_if_data *ignore) | ||
61 | { | ||
62 | enum ieee80211_chan_mode mode; | ||
63 | |||
64 | mutex_lock(&local->iflist_mtx); | ||
65 | mode = __ieee80211_get_channel_mode(local, ignore); | ||
66 | mutex_unlock(&local->iflist_mtx); | ||
67 | |||
68 | return mode; | ||
69 | } | ||
70 | |||
71 | static enum nl80211_channel_type | ||
72 | ieee80211_get_superchan(struct ieee80211_local *local, | ||
73 | struct ieee80211_sub_if_data *sdata) | ||
74 | { | ||
75 | enum nl80211_channel_type superchan = NL80211_CHAN_NO_HT; | ||
76 | struct ieee80211_sub_if_data *tmp; | ||
77 | |||
78 | mutex_lock(&local->iflist_mtx); | ||
79 | list_for_each_entry(tmp, &local->interfaces, list) { | ||
80 | if (tmp == sdata) | ||
81 | continue; | ||
82 | |||
83 | if (!ieee80211_sdata_running(tmp)) | ||
84 | continue; | ||
85 | |||
86 | switch (tmp->vif.bss_conf.channel_type) { | ||
87 | case NL80211_CHAN_NO_HT: | ||
88 | case NL80211_CHAN_HT20: | ||
89 | if (superchan > tmp->vif.bss_conf.channel_type) | ||
90 | break; | ||
91 | |||
92 | superchan = tmp->vif.bss_conf.channel_type; | ||
93 | break; | ||
94 | case NL80211_CHAN_HT40PLUS: | ||
95 | WARN_ON(superchan == NL80211_CHAN_HT40MINUS); | ||
96 | superchan = NL80211_CHAN_HT40PLUS; | ||
97 | break; | ||
98 | case NL80211_CHAN_HT40MINUS: | ||
99 | WARN_ON(superchan == NL80211_CHAN_HT40PLUS); | ||
100 | superchan = NL80211_CHAN_HT40MINUS; | ||
101 | break; | ||
102 | } | ||
103 | } | ||
104 | mutex_unlock(&local->iflist_mtx); | ||
105 | |||
106 | return superchan; | ||
107 | } | ||
108 | 10 | ||
109 | static bool | 11 | static bool |
110 | ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1, | 12 | ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1, |
@@ -148,23 +50,352 @@ ieee80211_channel_types_are_compatible(enum nl80211_channel_type chantype1, | |||
148 | return true; | 50 | return true; |
149 | } | 51 | } |
150 | 52 | ||
151 | bool ieee80211_set_channel_type(struct ieee80211_local *local, | 53 | static void ieee80211_change_chantype(struct ieee80211_local *local, |
152 | struct ieee80211_sub_if_data *sdata, | 54 | struct ieee80211_chanctx *ctx, |
153 | enum nl80211_channel_type chantype) | 55 | enum nl80211_channel_type chantype) |
154 | { | 56 | { |
155 | enum nl80211_channel_type superchan; | 57 | if (chantype == ctx->conf.channel_type) |
156 | enum nl80211_channel_type compatchan; | 58 | return; |
157 | 59 | ||
158 | superchan = ieee80211_get_superchan(local, sdata); | 60 | ctx->conf.channel_type = chantype; |
159 | if (!ieee80211_channel_types_are_compatible(superchan, chantype, | 61 | drv_change_chanctx(local, ctx, IEEE80211_CHANCTX_CHANGE_CHANNEL_TYPE); |
160 | &compatchan)) | ||
161 | return false; | ||
162 | 62 | ||
163 | local->_oper_channel_type = compatchan; | 63 | if (!local->use_chanctx) { |
64 | local->_oper_channel_type = chantype; | ||
65 | ieee80211_hw_config(local, 0); | ||
66 | } | ||
67 | } | ||
164 | 68 | ||
165 | if (sdata) | 69 | static struct ieee80211_chanctx * |
166 | sdata->vif.bss_conf.channel_type = chantype; | 70 | ieee80211_find_chanctx(struct ieee80211_local *local, |
71 | struct ieee80211_channel *channel, | ||
72 | enum nl80211_channel_type channel_type, | ||
73 | enum ieee80211_chanctx_mode mode) | ||
74 | { | ||
75 | struct ieee80211_chanctx *ctx; | ||
76 | enum nl80211_channel_type compat_type; | ||
167 | 77 | ||
168 | return true; | 78 | lockdep_assert_held(&local->chanctx_mtx); |
79 | |||
80 | if (mode == IEEE80211_CHANCTX_EXCLUSIVE) | ||
81 | return NULL; | ||
82 | if (WARN_ON(!channel)) | ||
83 | return NULL; | ||
84 | |||
85 | list_for_each_entry(ctx, &local->chanctx_list, list) { | ||
86 | compat_type = ctx->conf.channel_type; | ||
87 | |||
88 | if (ctx->mode == IEEE80211_CHANCTX_EXCLUSIVE) | ||
89 | continue; | ||
90 | if (ctx->conf.channel != channel) | ||
91 | continue; | ||
92 | if (!ieee80211_channel_types_are_compatible(ctx->conf.channel_type, | ||
93 | channel_type, | ||
94 | &compat_type)) | ||
95 | continue; | ||
96 | |||
97 | ieee80211_change_chantype(local, ctx, compat_type); | ||
98 | |||
99 | return ctx; | ||
100 | } | ||
101 | |||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | static struct ieee80211_chanctx * | ||
106 | ieee80211_new_chanctx(struct ieee80211_local *local, | ||
107 | struct ieee80211_channel *channel, | ||
108 | enum nl80211_channel_type channel_type, | ||
109 | enum ieee80211_chanctx_mode mode) | ||
110 | { | ||
111 | struct ieee80211_chanctx *ctx; | ||
112 | int err; | ||
113 | |||
114 | lockdep_assert_held(&local->chanctx_mtx); | ||
115 | |||
116 | ctx = kzalloc(sizeof(*ctx) + local->hw.chanctx_data_size, GFP_KERNEL); | ||
117 | if (!ctx) | ||
118 | return ERR_PTR(-ENOMEM); | ||
119 | |||
120 | ctx->conf.channel = channel; | ||
121 | ctx->conf.channel_type = channel_type; | ||
122 | ctx->conf.rx_chains_static = 1; | ||
123 | ctx->conf.rx_chains_dynamic = 1; | ||
124 | ctx->mode = mode; | ||
125 | |||
126 | if (!local->use_chanctx) { | ||
127 | local->_oper_channel_type = channel_type; | ||
128 | local->_oper_channel = channel; | ||
129 | ieee80211_hw_config(local, 0); | ||
130 | } else { | ||
131 | err = drv_add_chanctx(local, ctx); | ||
132 | if (err) { | ||
133 | kfree(ctx); | ||
134 | return ERR_PTR(err); | ||
135 | } | ||
136 | } | ||
137 | |||
138 | list_add_rcu(&ctx->list, &local->chanctx_list); | ||
139 | |||
140 | return ctx; | ||
141 | } | ||
142 | |||
143 | static void ieee80211_free_chanctx(struct ieee80211_local *local, | ||
144 | struct ieee80211_chanctx *ctx) | ||
145 | { | ||
146 | lockdep_assert_held(&local->chanctx_mtx); | ||
147 | |||
148 | WARN_ON_ONCE(ctx->refcount != 0); | ||
149 | |||
150 | if (!local->use_chanctx) { | ||
151 | local->_oper_channel_type = NL80211_CHAN_NO_HT; | ||
152 | ieee80211_hw_config(local, 0); | ||
153 | } else { | ||
154 | drv_remove_chanctx(local, ctx); | ||
155 | } | ||
156 | |||
157 | list_del_rcu(&ctx->list); | ||
158 | kfree_rcu(ctx, rcu_head); | ||
159 | } | ||
160 | |||
161 | static int ieee80211_assign_vif_chanctx(struct ieee80211_sub_if_data *sdata, | ||
162 | struct ieee80211_chanctx *ctx) | ||
163 | { | ||
164 | struct ieee80211_local *local = sdata->local; | ||
165 | int ret; | ||
166 | |||
167 | lockdep_assert_held(&local->chanctx_mtx); | ||
168 | |||
169 | ret = drv_assign_vif_chanctx(local, sdata, ctx); | ||
170 | if (ret) | ||
171 | return ret; | ||
172 | |||
173 | rcu_assign_pointer(sdata->vif.chanctx_conf, &ctx->conf); | ||
174 | ctx->refcount++; | ||
175 | |||
176 | ieee80211_recalc_txpower(sdata); | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static enum nl80211_channel_type | ||
182 | ieee80211_calc_chantype(struct ieee80211_local *local, | ||
183 | struct ieee80211_chanctx *ctx) | ||
184 | { | ||
185 | struct ieee80211_chanctx_conf *conf = &ctx->conf; | ||
186 | struct ieee80211_sub_if_data *sdata; | ||
187 | enum nl80211_channel_type result = NL80211_CHAN_NO_HT; | ||
188 | |||
189 | lockdep_assert_held(&local->chanctx_mtx); | ||
190 | |||
191 | rcu_read_lock(); | ||
192 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
193 | if (!ieee80211_sdata_running(sdata)) | ||
194 | continue; | ||
195 | if (rcu_access_pointer(sdata->vif.chanctx_conf) != conf) | ||
196 | continue; | ||
197 | |||
198 | WARN_ON_ONCE(!ieee80211_channel_types_are_compatible( | ||
199 | sdata->vif.bss_conf.channel_type, | ||
200 | result, &result)); | ||
201 | } | ||
202 | rcu_read_unlock(); | ||
203 | |||
204 | return result; | ||
205 | } | ||
206 | |||
207 | static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, | ||
208 | struct ieee80211_chanctx *ctx) | ||
209 | { | ||
210 | enum nl80211_channel_type chantype; | ||
211 | |||
212 | lockdep_assert_held(&local->chanctx_mtx); | ||
213 | |||
214 | chantype = ieee80211_calc_chantype(local, ctx); | ||
215 | ieee80211_change_chantype(local, ctx, chantype); | ||
216 | } | ||
217 | |||
218 | static void ieee80211_unassign_vif_chanctx(struct ieee80211_sub_if_data *sdata, | ||
219 | struct ieee80211_chanctx *ctx) | ||
220 | { | ||
221 | struct ieee80211_local *local = sdata->local; | ||
222 | |||
223 | lockdep_assert_held(&local->chanctx_mtx); | ||
224 | |||
225 | ctx->refcount--; | ||
226 | rcu_assign_pointer(sdata->vif.chanctx_conf, NULL); | ||
227 | |||
228 | drv_unassign_vif_chanctx(local, sdata, ctx); | ||
229 | |||
230 | if (ctx->refcount > 0) { | ||
231 | ieee80211_recalc_chanctx_chantype(sdata->local, ctx); | ||
232 | ieee80211_recalc_smps_chanctx(local, ctx); | ||
233 | } | ||
234 | } | ||
235 | |||
236 | static void __ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata) | ||
237 | { | ||
238 | struct ieee80211_local *local = sdata->local; | ||
239 | struct ieee80211_chanctx_conf *conf; | ||
240 | struct ieee80211_chanctx *ctx; | ||
241 | |||
242 | lockdep_assert_held(&local->chanctx_mtx); | ||
243 | |||
244 | conf = rcu_dereference_protected(sdata->vif.chanctx_conf, | ||
245 | lockdep_is_held(&local->chanctx_mtx)); | ||
246 | if (!conf) | ||
247 | return; | ||
248 | |||
249 | ctx = container_of(conf, struct ieee80211_chanctx, conf); | ||
250 | |||
251 | ieee80211_unassign_vif_chanctx(sdata, ctx); | ||
252 | if (ctx->refcount == 0) | ||
253 | ieee80211_free_chanctx(local, ctx); | ||
254 | } | ||
255 | |||
256 | void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, | ||
257 | struct ieee80211_chanctx *chanctx) | ||
258 | { | ||
259 | struct ieee80211_sub_if_data *sdata; | ||
260 | u8 rx_chains_static, rx_chains_dynamic; | ||
261 | |||
262 | lockdep_assert_held(&local->chanctx_mtx); | ||
263 | |||
264 | rx_chains_static = 1; | ||
265 | rx_chains_dynamic = 1; | ||
266 | |||
267 | rcu_read_lock(); | ||
268 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
269 | u8 needed_static, needed_dynamic; | ||
270 | |||
271 | if (!ieee80211_sdata_running(sdata)) | ||
272 | continue; | ||
273 | |||
274 | if (rcu_access_pointer(sdata->vif.chanctx_conf) != | ||
275 | &chanctx->conf) | ||
276 | continue; | ||
277 | |||
278 | switch (sdata->vif.type) { | ||
279 | case NL80211_IFTYPE_P2P_DEVICE: | ||
280 | continue; | ||
281 | case NL80211_IFTYPE_STATION: | ||
282 | if (!sdata->u.mgd.associated) | ||
283 | continue; | ||
284 | break; | ||
285 | case NL80211_IFTYPE_AP_VLAN: | ||
286 | continue; | ||
287 | case NL80211_IFTYPE_AP: | ||
288 | case NL80211_IFTYPE_ADHOC: | ||
289 | case NL80211_IFTYPE_WDS: | ||
290 | case NL80211_IFTYPE_MESH_POINT: | ||
291 | break; | ||
292 | default: | ||
293 | WARN_ON_ONCE(1); | ||
294 | } | ||
295 | |||
296 | switch (sdata->smps_mode) { | ||
297 | default: | ||
298 | WARN_ONCE(1, "Invalid SMPS mode %d\n", | ||
299 | sdata->smps_mode); | ||
300 | /* fall through */ | ||
301 | case IEEE80211_SMPS_OFF: | ||
302 | needed_static = sdata->needed_rx_chains; | ||
303 | needed_dynamic = sdata->needed_rx_chains; | ||
304 | break; | ||
305 | case IEEE80211_SMPS_DYNAMIC: | ||
306 | needed_static = 1; | ||
307 | needed_dynamic = sdata->needed_rx_chains; | ||
308 | break; | ||
309 | case IEEE80211_SMPS_STATIC: | ||
310 | needed_static = 1; | ||
311 | needed_dynamic = 1; | ||
312 | break; | ||
313 | } | ||
314 | |||
315 | rx_chains_static = max(rx_chains_static, needed_static); | ||
316 | rx_chains_dynamic = max(rx_chains_dynamic, needed_dynamic); | ||
317 | } | ||
318 | rcu_read_unlock(); | ||
319 | |||
320 | if (!local->use_chanctx) { | ||
321 | if (rx_chains_static > 1) | ||
322 | local->smps_mode = IEEE80211_SMPS_OFF; | ||
323 | else if (rx_chains_dynamic > 1) | ||
324 | local->smps_mode = IEEE80211_SMPS_DYNAMIC; | ||
325 | else | ||
326 | local->smps_mode = IEEE80211_SMPS_STATIC; | ||
327 | ieee80211_hw_config(local, 0); | ||
328 | } | ||
329 | |||
330 | if (rx_chains_static == chanctx->conf.rx_chains_static && | ||
331 | rx_chains_dynamic == chanctx->conf.rx_chains_dynamic) | ||
332 | return; | ||
333 | |||
334 | chanctx->conf.rx_chains_static = rx_chains_static; | ||
335 | chanctx->conf.rx_chains_dynamic = rx_chains_dynamic; | ||
336 | drv_change_chanctx(local, chanctx, IEEE80211_CHANCTX_CHANGE_RX_CHAINS); | ||
337 | } | ||
338 | |||
339 | int ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata, | ||
340 | struct ieee80211_channel *channel, | ||
341 | enum nl80211_channel_type channel_type, | ||
342 | enum ieee80211_chanctx_mode mode) | ||
343 | { | ||
344 | struct ieee80211_local *local = sdata->local; | ||
345 | struct ieee80211_chanctx *ctx; | ||
346 | int ret; | ||
347 | |||
348 | WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev)); | ||
349 | |||
350 | mutex_lock(&local->chanctx_mtx); | ||
351 | __ieee80211_vif_release_channel(sdata); | ||
352 | |||
353 | ctx = ieee80211_find_chanctx(local, channel, channel_type, mode); | ||
354 | if (!ctx) | ||
355 | ctx = ieee80211_new_chanctx(local, channel, channel_type, mode); | ||
356 | if (IS_ERR(ctx)) { | ||
357 | ret = PTR_ERR(ctx); | ||
358 | goto out; | ||
359 | } | ||
360 | |||
361 | sdata->vif.bss_conf.channel_type = channel_type; | ||
362 | |||
363 | ret = ieee80211_assign_vif_chanctx(sdata, ctx); | ||
364 | if (ret) { | ||
365 | /* if assign fails refcount stays the same */ | ||
366 | if (ctx->refcount == 0) | ||
367 | ieee80211_free_chanctx(local, ctx); | ||
368 | goto out; | ||
369 | } | ||
370 | |||
371 | ieee80211_recalc_smps_chanctx(local, ctx); | ||
372 | out: | ||
373 | mutex_unlock(&local->chanctx_mtx); | ||
374 | return ret; | ||
375 | } | ||
376 | |||
377 | void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata) | ||
378 | { | ||
379 | WARN_ON(sdata->dev && netif_carrier_ok(sdata->dev)); | ||
380 | |||
381 | mutex_lock(&sdata->local->chanctx_mtx); | ||
382 | __ieee80211_vif_release_channel(sdata); | ||
383 | mutex_unlock(&sdata->local->chanctx_mtx); | ||
384 | } | ||
385 | |||
386 | void ieee80211_iter_chan_contexts_atomic( | ||
387 | struct ieee80211_hw *hw, | ||
388 | void (*iter)(struct ieee80211_hw *hw, | ||
389 | struct ieee80211_chanctx_conf *chanctx_conf, | ||
390 | void *data), | ||
391 | void *iter_data) | ||
392 | { | ||
393 | struct ieee80211_local *local = hw_to_local(hw); | ||
394 | struct ieee80211_chanctx *ctx; | ||
169 | 395 | ||
396 | rcu_read_lock(); | ||
397 | list_for_each_entry_rcu(ctx, &local->chanctx_list, list) | ||
398 | iter(hw, &ctx->conf, iter_data); | ||
399 | rcu_read_unlock(); | ||
170 | } | 400 | } |
401 | EXPORT_SYMBOL_GPL(ieee80211_iter_chan_contexts_atomic); | ||
diff --git a/net/mac80211/debugfs.h b/net/mac80211/debugfs.h index 9be4e6d71d00..214ed4ecd739 100644 --- a/net/mac80211/debugfs.h +++ b/net/mac80211/debugfs.h | |||
@@ -2,9 +2,9 @@ | |||
2 | #define __MAC80211_DEBUGFS_H | 2 | #define __MAC80211_DEBUGFS_H |
3 | 3 | ||
4 | #ifdef CONFIG_MAC80211_DEBUGFS | 4 | #ifdef CONFIG_MAC80211_DEBUGFS |
5 | extern void debugfs_hw_add(struct ieee80211_local *local); | 5 | void debugfs_hw_add(struct ieee80211_local *local); |
6 | extern int mac80211_format_buffer(char __user *userbuf, size_t count, | 6 | int __printf(4, 5) mac80211_format_buffer(char __user *userbuf, size_t count, |
7 | loff_t *ppos, char *fmt, ...); | 7 | loff_t *ppos, char *fmt, ...); |
8 | #else | 8 | #else |
9 | static inline void debugfs_hw_add(struct ieee80211_local *local) | 9 | static inline void debugfs_hw_add(struct ieee80211_local *local) |
10 | { | 10 | { |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 6d5aec9418ee..ba9bd0ef119a 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/device.h> | 11 | #include <linux/device.h> |
12 | #include <linux/if.h> | 12 | #include <linux/if.h> |
13 | #include <linux/if_ether.h> | ||
13 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
14 | #include <linux/netdevice.h> | 15 | #include <linux/netdevice.h> |
15 | #include <linux/rtnetlink.h> | 16 | #include <linux/rtnetlink.h> |
@@ -168,6 +169,29 @@ IEEE80211_IF_FILE(rc_rateidx_mcs_mask_5ghz, | |||
168 | IEEE80211_IF_FILE(flags, flags, HEX); | 169 | IEEE80211_IF_FILE(flags, flags, HEX); |
169 | IEEE80211_IF_FILE(state, state, LHEX); | 170 | IEEE80211_IF_FILE(state, state, LHEX); |
170 | IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC); | 171 | IEEE80211_IF_FILE(channel_type, vif.bss_conf.channel_type, DEC); |
172 | IEEE80211_IF_FILE(txpower, vif.bss_conf.txpower, DEC); | ||
173 | IEEE80211_IF_FILE(ap_power_level, ap_power_level, DEC); | ||
174 | IEEE80211_IF_FILE(user_power_level, user_power_level, DEC); | ||
175 | |||
176 | static ssize_t | ||
177 | ieee80211_if_fmt_hw_queues(const struct ieee80211_sub_if_data *sdata, | ||
178 | char *buf, int buflen) | ||
179 | { | ||
180 | int len; | ||
181 | |||
182 | len = scnprintf(buf, buflen, "AC queues: VO:%d VI:%d BE:%d BK:%d\n", | ||
183 | sdata->vif.hw_queue[IEEE80211_AC_VO], | ||
184 | sdata->vif.hw_queue[IEEE80211_AC_VI], | ||
185 | sdata->vif.hw_queue[IEEE80211_AC_BE], | ||
186 | sdata->vif.hw_queue[IEEE80211_AC_BK]); | ||
187 | |||
188 | if (sdata->vif.type == NL80211_IFTYPE_AP) | ||
189 | len += scnprintf(buf + len, buflen - len, "cab queue: %d\n", | ||
190 | sdata->vif.cab_queue); | ||
191 | |||
192 | return len; | ||
193 | } | ||
194 | __IEEE80211_IF_FILE(hw_queues, NULL); | ||
171 | 195 | ||
172 | /* STA attributes */ | 196 | /* STA attributes */ |
173 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); | 197 | IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); |
@@ -217,7 +241,7 @@ static ssize_t ieee80211_if_fmt_smps(const struct ieee80211_sub_if_data *sdata, | |||
217 | 241 | ||
218 | return snprintf(buf, buflen, "request: %s\nused: %s\n", | 242 | return snprintf(buf, buflen, "request: %s\nused: %s\n", |
219 | smps_modes[sdata->u.mgd.req_smps], | 243 | smps_modes[sdata->u.mgd.req_smps], |
220 | smps_modes[sdata->u.mgd.ap_smps]); | 244 | smps_modes[sdata->smps_mode]); |
221 | } | 245 | } |
222 | 246 | ||
223 | static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, | 247 | static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata, |
@@ -245,27 +269,6 @@ static ssize_t ieee80211_if_fmt_tkip_mic_test( | |||
245 | return -EOPNOTSUPP; | 269 | return -EOPNOTSUPP; |
246 | } | 270 | } |
247 | 271 | ||
248 | static int hwaddr_aton(const char *txt, u8 *addr) | ||
249 | { | ||
250 | int i; | ||
251 | |||
252 | for (i = 0; i < ETH_ALEN; i++) { | ||
253 | int a, b; | ||
254 | |||
255 | a = hex_to_bin(*txt++); | ||
256 | if (a < 0) | ||
257 | return -1; | ||
258 | b = hex_to_bin(*txt++); | ||
259 | if (b < 0) | ||
260 | return -1; | ||
261 | *addr++ = (a << 4) | b; | ||
262 | if (i < 5 && *txt++ != ':') | ||
263 | return -1; | ||
264 | } | ||
265 | |||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | static ssize_t ieee80211_if_parse_tkip_mic_test( | 272 | static ssize_t ieee80211_if_parse_tkip_mic_test( |
270 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) | 273 | struct ieee80211_sub_if_data *sdata, const char *buf, int buflen) |
271 | { | 274 | { |
@@ -275,13 +278,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test( | |||
275 | struct ieee80211_hdr *hdr; | 278 | struct ieee80211_hdr *hdr; |
276 | __le16 fc; | 279 | __le16 fc; |
277 | 280 | ||
278 | /* | 281 | if (!mac_pton(buf, addr)) |
279 | * Assume colon-delimited MAC address with possible white space | ||
280 | * following. | ||
281 | */ | ||
282 | if (buflen < 3 * ETH_ALEN - 1) | ||
283 | return -EINVAL; | ||
284 | if (hwaddr_aton(buf, addr) < 0) | ||
285 | return -EINVAL; | 282 | return -EINVAL; |
286 | 283 | ||
287 | if (!ieee80211_sdata_running(sdata)) | 284 | if (!ieee80211_sdata_running(sdata)) |
@@ -307,13 +304,16 @@ static ssize_t ieee80211_if_parse_tkip_mic_test( | |||
307 | case NL80211_IFTYPE_STATION: | 304 | case NL80211_IFTYPE_STATION: |
308 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); | 305 | fc |= cpu_to_le16(IEEE80211_FCTL_TODS); |
309 | /* BSSID SA DA */ | 306 | /* BSSID SA DA */ |
310 | if (sdata->vif.bss_conf.bssid == NULL) { | 307 | mutex_lock(&sdata->u.mgd.mtx); |
308 | if (!sdata->u.mgd.associated) { | ||
309 | mutex_unlock(&sdata->u.mgd.mtx); | ||
311 | dev_kfree_skb(skb); | 310 | dev_kfree_skb(skb); |
312 | return -ENOTCONN; | 311 | return -ENOTCONN; |
313 | } | 312 | } |
314 | memcpy(hdr->addr1, sdata->vif.bss_conf.bssid, ETH_ALEN); | 313 | memcpy(hdr->addr1, sdata->u.mgd.associated->bssid, ETH_ALEN); |
315 | memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); | 314 | memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN); |
316 | memcpy(hdr->addr3, addr, ETH_ALEN); | 315 | memcpy(hdr->addr3, addr, ETH_ALEN); |
316 | mutex_unlock(&sdata->u.mgd.mtx); | ||
317 | break; | 317 | break; |
318 | default: | 318 | default: |
319 | dev_kfree_skb(skb); | 319 | dev_kfree_skb(skb); |
@@ -395,14 +395,14 @@ __IEEE80211_IF_FILE_W(uapsd_max_sp_len); | |||
395 | 395 | ||
396 | /* AP attributes */ | 396 | /* AP attributes */ |
397 | IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); | 397 | IEEE80211_IF_FILE(num_mcast_sta, u.ap.num_mcast_sta, ATOMIC); |
398 | IEEE80211_IF_FILE(num_sta_ps, u.ap.num_sta_ps, ATOMIC); | 398 | IEEE80211_IF_FILE(num_sta_ps, u.ap.ps.num_sta_ps, ATOMIC); |
399 | IEEE80211_IF_FILE(dtim_count, u.ap.dtim_count, DEC); | 399 | IEEE80211_IF_FILE(dtim_count, u.ap.ps.dtim_count, DEC); |
400 | 400 | ||
401 | static ssize_t ieee80211_if_fmt_num_buffered_multicast( | 401 | static ssize_t ieee80211_if_fmt_num_buffered_multicast( |
402 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) | 402 | const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) |
403 | { | 403 | { |
404 | return scnprintf(buf, buflen, "%u\n", | 404 | return scnprintf(buf, buflen, "%u\n", |
405 | skb_queue_len(&sdata->u.ap.ps_bc_buf)); | 405 | skb_queue_len(&sdata->u.ap.ps.bc_buf)); |
406 | } | 406 | } |
407 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); | 407 | __IEEE80211_IF_FILE(num_buffered_multicast, NULL); |
408 | 408 | ||
@@ -443,7 +443,7 @@ static ssize_t ieee80211_if_parse_tsf( | |||
443 | } | 443 | } |
444 | ret = kstrtoull(buf, 10, &tsf); | 444 | ret = kstrtoull(buf, 10, &tsf); |
445 | if (ret < 0) | 445 | if (ret < 0) |
446 | return -EINVAL; | 446 | return ret; |
447 | if (tsf_is_delta) | 447 | if (tsf_is_delta) |
448 | tsf = drv_get_tsf(local, sdata) + tsf_is_delta * tsf; | 448 | tsf = drv_get_tsf(local, sdata) + tsf_is_delta * tsf; |
449 | if (local->ops->set_tsf) { | 449 | if (local->ops->set_tsf) { |
@@ -471,7 +471,7 @@ IEEE80211_IF_FILE(dropped_frames_congestion, | |||
471 | u.mesh.mshstats.dropped_frames_congestion, DEC); | 471 | u.mesh.mshstats.dropped_frames_congestion, DEC); |
472 | IEEE80211_IF_FILE(dropped_frames_no_route, | 472 | IEEE80211_IF_FILE(dropped_frames_no_route, |
473 | u.mesh.mshstats.dropped_frames_no_route, DEC); | 473 | u.mesh.mshstats.dropped_frames_no_route, DEC); |
474 | IEEE80211_IF_FILE(estab_plinks, u.mesh.mshstats.estab_plinks, ATOMIC); | 474 | IEEE80211_IF_FILE(estab_plinks, u.mesh.estab_plinks, ATOMIC); |
475 | 475 | ||
476 | /* Mesh parameters */ | 476 | /* Mesh parameters */ |
477 | IEEE80211_IF_FILE(dot11MeshMaxRetries, | 477 | IEEE80211_IF_FILE(dot11MeshMaxRetries, |
@@ -531,6 +531,7 @@ static void add_common_files(struct ieee80211_sub_if_data *sdata) | |||
531 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); | 531 | DEBUGFS_ADD(rc_rateidx_mask_5ghz); |
532 | DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); | 532 | DEBUGFS_ADD(rc_rateidx_mcs_mask_2ghz); |
533 | DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); | 533 | DEBUGFS_ADD(rc_rateidx_mcs_mask_5ghz); |
534 | DEBUGFS_ADD(hw_queues); | ||
534 | } | 535 | } |
535 | 536 | ||
536 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) | 537 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) |
@@ -632,6 +633,9 @@ static void add_files(struct ieee80211_sub_if_data *sdata) | |||
632 | DEBUGFS_ADD(flags); | 633 | DEBUGFS_ADD(flags); |
633 | DEBUGFS_ADD(state); | 634 | DEBUGFS_ADD(state); |
634 | DEBUGFS_ADD(channel_type); | 635 | DEBUGFS_ADD(channel_type); |
636 | DEBUGFS_ADD(txpower); | ||
637 | DEBUGFS_ADD(user_power_level); | ||
638 | DEBUGFS_ADD(ap_power_level); | ||
635 | 639 | ||
636 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) | 640 | if (sdata->vif.type != NL80211_IFTYPE_MONITOR) |
637 | add_common_files(sdata); | 641 | add_common_files(sdata); |
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index da9003b20004..4dc2577886ff 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h | |||
@@ -871,4 +871,104 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local, | |||
871 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); | 871 | local->ops->mgd_prepare_tx(&local->hw, &sdata->vif); |
872 | trace_drv_return_void(local); | 872 | trace_drv_return_void(local); |
873 | } | 873 | } |
874 | |||
875 | static inline int drv_add_chanctx(struct ieee80211_local *local, | ||
876 | struct ieee80211_chanctx *ctx) | ||
877 | { | ||
878 | int ret = -EOPNOTSUPP; | ||
879 | |||
880 | trace_drv_add_chanctx(local, ctx); | ||
881 | if (local->ops->add_chanctx) | ||
882 | ret = local->ops->add_chanctx(&local->hw, &ctx->conf); | ||
883 | trace_drv_return_int(local, ret); | ||
884 | |||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | static inline void drv_remove_chanctx(struct ieee80211_local *local, | ||
889 | struct ieee80211_chanctx *ctx) | ||
890 | { | ||
891 | trace_drv_remove_chanctx(local, ctx); | ||
892 | if (local->ops->remove_chanctx) | ||
893 | local->ops->remove_chanctx(&local->hw, &ctx->conf); | ||
894 | trace_drv_return_void(local); | ||
895 | } | ||
896 | |||
897 | static inline void drv_change_chanctx(struct ieee80211_local *local, | ||
898 | struct ieee80211_chanctx *ctx, | ||
899 | u32 changed) | ||
900 | { | ||
901 | trace_drv_change_chanctx(local, ctx, changed); | ||
902 | if (local->ops->change_chanctx) | ||
903 | local->ops->change_chanctx(&local->hw, &ctx->conf, changed); | ||
904 | trace_drv_return_void(local); | ||
905 | } | ||
906 | |||
907 | static inline int drv_assign_vif_chanctx(struct ieee80211_local *local, | ||
908 | struct ieee80211_sub_if_data *sdata, | ||
909 | struct ieee80211_chanctx *ctx) | ||
910 | { | ||
911 | int ret = 0; | ||
912 | |||
913 | check_sdata_in_driver(sdata); | ||
914 | |||
915 | trace_drv_assign_vif_chanctx(local, sdata, ctx); | ||
916 | if (local->ops->assign_vif_chanctx) | ||
917 | ret = local->ops->assign_vif_chanctx(&local->hw, | ||
918 | &sdata->vif, | ||
919 | &ctx->conf); | ||
920 | trace_drv_return_int(local, ret); | ||
921 | |||
922 | return ret; | ||
923 | } | ||
924 | |||
925 | static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local, | ||
926 | struct ieee80211_sub_if_data *sdata, | ||
927 | struct ieee80211_chanctx *ctx) | ||
928 | { | ||
929 | check_sdata_in_driver(sdata); | ||
930 | |||
931 | trace_drv_unassign_vif_chanctx(local, sdata, ctx); | ||
932 | if (local->ops->unassign_vif_chanctx) | ||
933 | local->ops->unassign_vif_chanctx(&local->hw, | ||
934 | &sdata->vif, | ||
935 | &ctx->conf); | ||
936 | trace_drv_return_void(local); | ||
937 | } | ||
938 | |||
939 | static inline int drv_start_ap(struct ieee80211_local *local, | ||
940 | struct ieee80211_sub_if_data *sdata) | ||
941 | { | ||
942 | int ret = 0; | ||
943 | |||
944 | check_sdata_in_driver(sdata); | ||
945 | |||
946 | trace_drv_start_ap(local, sdata, &sdata->vif.bss_conf); | ||
947 | if (local->ops->start_ap) | ||
948 | ret = local->ops->start_ap(&local->hw, &sdata->vif); | ||
949 | trace_drv_return_int(local, ret); | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | static inline void drv_stop_ap(struct ieee80211_local *local, | ||
954 | struct ieee80211_sub_if_data *sdata) | ||
955 | { | ||
956 | check_sdata_in_driver(sdata); | ||
957 | |||
958 | trace_drv_stop_ap(local, sdata); | ||
959 | if (local->ops->stop_ap) | ||
960 | local->ops->stop_ap(&local->hw, &sdata->vif); | ||
961 | trace_drv_return_void(local); | ||
962 | } | ||
963 | |||
964 | static inline void drv_restart_complete(struct ieee80211_local *local) | ||
965 | { | ||
966 | might_sleep(); | ||
967 | |||
968 | trace_drv_restart_complete(local); | ||
969 | if (local->ops->restart_complete) | ||
970 | local->ops->restart_complete(&local->hw); | ||
971 | trace_drv_return_void(local); | ||
972 | } | ||
973 | |||
874 | #endif /* __MAC80211_DRIVER_OPS */ | 974 | #endif /* __MAC80211_DRIVER_OPS */ |
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c index 5f3620f0bc0a..67774b053535 100644 --- a/net/mac80211/ibss.c +++ b/net/mac80211/ibss.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "rate.h" | 26 | #include "rate.h" |
27 | 27 | ||
28 | #define IEEE80211_SCAN_INTERVAL (2 * HZ) | 28 | #define IEEE80211_SCAN_INTERVAL (2 * HZ) |
29 | #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) | ||
30 | #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) | 29 | #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) |
31 | 30 | ||
32 | #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) | 31 | #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) |
@@ -39,7 +38,8 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
39 | const u8 *bssid, const int beacon_int, | 38 | const u8 *bssid, const int beacon_int, |
40 | struct ieee80211_channel *chan, | 39 | struct ieee80211_channel *chan, |
41 | const u32 basic_rates, | 40 | const u32 basic_rates, |
42 | const u16 capability, u64 tsf) | 41 | const u16 capability, u64 tsf, |
42 | bool creator) | ||
43 | { | 43 | { |
44 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 44 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
45 | struct ieee80211_local *local = sdata->local; | 45 | struct ieee80211_local *local = sdata->local; |
@@ -72,25 +72,27 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
72 | /* if merging, indicate to driver that we leave the old IBSS */ | 72 | /* if merging, indicate to driver that we leave the old IBSS */ |
73 | if (sdata->vif.bss_conf.ibss_joined) { | 73 | if (sdata->vif.bss_conf.ibss_joined) { |
74 | sdata->vif.bss_conf.ibss_joined = false; | 74 | sdata->vif.bss_conf.ibss_joined = false; |
75 | sdata->vif.bss_conf.ibss_creator = false; | ||
75 | netif_carrier_off(sdata->dev); | 76 | netif_carrier_off(sdata->dev); |
76 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); | 77 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); |
77 | } | 78 | } |
78 | 79 | ||
79 | memcpy(ifibss->bssid, bssid, ETH_ALEN); | ||
80 | |||
81 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; | 80 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; |
82 | 81 | ||
83 | local->oper_channel = chan; | ||
84 | channel_type = ifibss->channel_type; | 82 | channel_type = ifibss->channel_type; |
85 | if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type)) | 83 | if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type)) |
86 | channel_type = NL80211_CHAN_HT20; | 84 | channel_type = NL80211_CHAN_HT20; |
87 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) { | 85 | |
88 | /* can only fail due to HT40+/- mismatch */ | 86 | ieee80211_vif_release_channel(sdata); |
89 | channel_type = NL80211_CHAN_HT20; | 87 | if (ieee80211_vif_use_channel(sdata, chan, channel_type, |
90 | WARN_ON(!ieee80211_set_channel_type(local, sdata, | 88 | ifibss->fixed_channel ? |
91 | NL80211_CHAN_HT20)); | 89 | IEEE80211_CHANCTX_SHARED : |
90 | IEEE80211_CHANCTX_EXCLUSIVE)) { | ||
91 | sdata_info(sdata, "Failed to join IBSS, no channel context\n"); | ||
92 | return; | ||
92 | } | 93 | } |
93 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); | 94 | |
95 | memcpy(ifibss->bssid, bssid, ETH_ALEN); | ||
94 | 96 | ||
95 | sband = local->hw.wiphy->bands[chan->band]; | 97 | sband = local->hw.wiphy->bands[chan->band]; |
96 | 98 | ||
@@ -197,6 +199,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
197 | bss_change |= BSS_CHANGED_HT; | 199 | bss_change |= BSS_CHANGED_HT; |
198 | bss_change |= BSS_CHANGED_IBSS; | 200 | bss_change |= BSS_CHANGED_IBSS; |
199 | sdata->vif.bss_conf.ibss_joined = true; | 201 | sdata->vif.bss_conf.ibss_joined = true; |
202 | sdata->vif.bss_conf.ibss_creator = creator; | ||
200 | ieee80211_bss_info_change_notify(sdata, bss_change); | 203 | ieee80211_bss_info_change_notify(sdata, bss_change); |
201 | 204 | ||
202 | ieee80211_sta_def_wmm_params(sdata, sband->n_bitrates, supp_rates); | 205 | ieee80211_sta_def_wmm_params(sdata, sband->n_bitrates, supp_rates); |
@@ -249,7 +252,8 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, | |||
249 | cbss->channel, | 252 | cbss->channel, |
250 | basic_rates, | 253 | basic_rates, |
251 | cbss->capability, | 254 | cbss->capability, |
252 | cbss->tsf); | 255 | cbss->tsf, |
256 | false); | ||
253 | } | 257 | } |
254 | 258 | ||
255 | static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, | 259 | static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, |
@@ -279,7 +283,7 @@ static struct sta_info *ieee80211_ibss_finish_sta(struct sta_info *sta, | |||
279 | ibss_dbg(sdata, | 283 | ibss_dbg(sdata, |
280 | "TX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=1)\n", | 284 | "TX Auth SA=%pM DA=%pM BSSID=%pM (auth_transaction=1)\n", |
281 | sdata->vif.addr, addr, sdata->u.ibss.bssid); | 285 | sdata->vif.addr, addr, sdata->u.ibss.bssid); |
282 | ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, NULL, 0, | 286 | ieee80211_send_auth(sdata, 1, WLAN_AUTH_OPEN, 0, NULL, 0, |
283 | addr, sdata->u.ibss.bssid, NULL, 0, 0); | 287 | addr, sdata->u.ibss.bssid, NULL, 0, 0); |
284 | } | 288 | } |
285 | return sta; | 289 | return sta; |
@@ -294,7 +298,8 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
294 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 298 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
295 | struct ieee80211_local *local = sdata->local; | 299 | struct ieee80211_local *local = sdata->local; |
296 | struct sta_info *sta; | 300 | struct sta_info *sta; |
297 | int band = local->oper_channel->band; | 301 | struct ieee80211_chanctx_conf *chanctx_conf; |
302 | int band; | ||
298 | 303 | ||
299 | /* | 304 | /* |
300 | * XXX: Consider removing the least recently used entry and | 305 | * XXX: Consider removing the least recently used entry and |
@@ -317,6 +322,13 @@ ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, | |||
317 | return NULL; | 322 | return NULL; |
318 | } | 323 | } |
319 | 324 | ||
325 | rcu_read_lock(); | ||
326 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
327 | if (WARN_ON_ONCE(!chanctx_conf)) | ||
328 | return NULL; | ||
329 | band = chanctx_conf->channel->band; | ||
330 | rcu_read_unlock(); | ||
331 | |||
320 | sta = sta_info_alloc(sdata, addr, GFP_KERNEL); | 332 | sta = sta_info_alloc(sdata, addr, GFP_KERNEL); |
321 | if (!sta) { | 333 | if (!sta) { |
322 | rcu_read_lock(); | 334 | rcu_read_lock(); |
@@ -389,7 +401,7 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, | |||
389 | * However, try to reply to authentication attempts if someone | 401 | * However, try to reply to authentication attempts if someone |
390 | * has actually implemented this. | 402 | * has actually implemented this. |
391 | */ | 403 | */ |
392 | ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, | 404 | ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, 0, NULL, 0, |
393 | mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0); | 405 | mgmt->sa, sdata->u.ibss.bssid, NULL, 0, 0); |
394 | } | 406 | } |
395 | 407 | ||
@@ -517,7 +529,8 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, | |||
517 | goto put_bss; | 529 | goto put_bss; |
518 | 530 | ||
519 | /* different channel */ | 531 | /* different channel */ |
520 | if (cbss->channel != local->oper_channel) | 532 | if (sdata->u.ibss.fixed_channel && |
533 | sdata->u.ibss.channel != cbss->channel) | ||
521 | goto put_bss; | 534 | goto put_bss; |
522 | 535 | ||
523 | /* different SSID */ | 536 | /* different SSID */ |
@@ -592,7 +605,8 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata, | |||
592 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; | 605 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
593 | struct ieee80211_local *local = sdata->local; | 606 | struct ieee80211_local *local = sdata->local; |
594 | struct sta_info *sta; | 607 | struct sta_info *sta; |
595 | int band = local->oper_channel->band; | 608 | struct ieee80211_chanctx_conf *chanctx_conf; |
609 | int band; | ||
596 | 610 | ||
597 | /* | 611 | /* |
598 | * XXX: Consider removing the least recently used entry and | 612 | * XXX: Consider removing the least recently used entry and |
@@ -610,6 +624,15 @@ void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata, | |||
610 | if (!ether_addr_equal(bssid, sdata->u.ibss.bssid)) | 624 | if (!ether_addr_equal(bssid, sdata->u.ibss.bssid)) |
611 | return; | 625 | return; |
612 | 626 | ||
627 | rcu_read_lock(); | ||
628 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
629 | if (WARN_ON_ONCE(!chanctx_conf)) { | ||
630 | rcu_read_unlock(); | ||
631 | return; | ||
632 | } | ||
633 | band = chanctx_conf->channel->band; | ||
634 | rcu_read_unlock(); | ||
635 | |||
613 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); | 636 | sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); |
614 | if (!sta) | 637 | if (!sta) |
615 | return; | 638 | return; |
@@ -715,7 +738,7 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) | |||
715 | 738 | ||
716 | __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, | 739 | __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, |
717 | ifibss->channel, ifibss->basic_rates, | 740 | ifibss->channel, ifibss->basic_rates, |
718 | capability, 0); | 741 | capability, 0, true); |
719 | } | 742 | } |
720 | 743 | ||
721 | /* | 744 | /* |
@@ -784,18 +807,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) | |||
784 | int interval = IEEE80211_SCAN_INTERVAL; | 807 | int interval = IEEE80211_SCAN_INTERVAL; |
785 | 808 | ||
786 | if (time_after(jiffies, ifibss->ibss_join_req + | 809 | if (time_after(jiffies, ifibss->ibss_join_req + |
787 | IEEE80211_IBSS_JOIN_TIMEOUT)) { | 810 | IEEE80211_IBSS_JOIN_TIMEOUT)) |
788 | if (!(local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)) { | 811 | ieee80211_sta_create_ibss(sdata); |
789 | ieee80211_sta_create_ibss(sdata); | ||
790 | return; | ||
791 | } | ||
792 | sdata_info(sdata, "IBSS not allowed on %d MHz\n", | ||
793 | local->oper_channel->center_freq); | ||
794 | |||
795 | /* No IBSS found - decrease scan interval and continue | ||
796 | * scanning. */ | ||
797 | interval = IEEE80211_SCAN_INTERVAL_SLOW; | ||
798 | } | ||
799 | 812 | ||
800 | mod_timer(&ifibss->timer, | 813 | mod_timer(&ifibss->timer, |
801 | round_jiffies(jiffies + interval)); | 814 | round_jiffies(jiffies + interval)); |
@@ -1086,17 +1099,6 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
1086 | sdata->u.ibss.channel_type = params->channel_type; | 1099 | sdata->u.ibss.channel_type = params->channel_type; |
1087 | sdata->u.ibss.fixed_channel = params->channel_fixed; | 1100 | sdata->u.ibss.fixed_channel = params->channel_fixed; |
1088 | 1101 | ||
1089 | /* fix ourselves to that channel now already */ | ||
1090 | if (params->channel_fixed) { | ||
1091 | sdata->local->oper_channel = params->channel; | ||
1092 | if (!ieee80211_set_channel_type(sdata->local, sdata, | ||
1093 | params->channel_type)) { | ||
1094 | mutex_unlock(&sdata->u.ibss.mtx); | ||
1095 | kfree_skb(skb); | ||
1096 | return -EINVAL; | ||
1097 | } | ||
1098 | } | ||
1099 | |||
1100 | if (params->ie) { | 1102 | if (params->ie) { |
1101 | sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len, | 1103 | sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len, |
1102 | GFP_KERNEL); | 1104 | GFP_KERNEL); |
@@ -1108,7 +1110,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
1108 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; | 1110 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; |
1109 | sdata->u.ibss.ibss_join_req = jiffies; | 1111 | sdata->u.ibss.ibss_join_req = jiffies; |
1110 | 1112 | ||
1111 | memcpy(sdata->u.ibss.ssid, params->ssid, IEEE80211_MAX_SSID_LEN); | 1113 | memcpy(sdata->u.ibss.ssid, params->ssid, params->ssid_len); |
1112 | sdata->u.ibss.ssid_len = params->ssid_len; | 1114 | sdata->u.ibss.ssid_len = params->ssid_len; |
1113 | 1115 | ||
1114 | mutex_unlock(&sdata->u.ibss.mtx); | 1116 | mutex_unlock(&sdata->u.ibss.mtx); |
@@ -1134,6 +1136,9 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, | |||
1134 | changed |= BSS_CHANGED_HT; | 1136 | changed |= BSS_CHANGED_HT; |
1135 | ieee80211_bss_info_change_notify(sdata, changed); | 1137 | ieee80211_bss_info_change_notify(sdata, changed); |
1136 | 1138 | ||
1139 | sdata->smps_mode = IEEE80211_SMPS_OFF; | ||
1140 | sdata->needed_rx_chains = sdata->local->rx_chains; | ||
1141 | |||
1137 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); | 1142 | ieee80211_queue_work(&sdata->local->hw, &sdata->work); |
1138 | 1143 | ||
1139 | return 0; | 1144 | return 0; |
@@ -1151,10 +1156,6 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | |||
1151 | 1156 | ||
1152 | mutex_lock(&sdata->u.ibss.mtx); | 1157 | mutex_lock(&sdata->u.ibss.mtx); |
1153 | 1158 | ||
1154 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; | ||
1155 | memset(sdata->u.ibss.bssid, 0, ETH_ALEN); | ||
1156 | sdata->u.ibss.ssid_len = 0; | ||
1157 | |||
1158 | active_ibss = ieee80211_sta_active_ibss(sdata); | 1159 | active_ibss = ieee80211_sta_active_ibss(sdata); |
1159 | 1160 | ||
1160 | if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) { | 1161 | if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) { |
@@ -1175,6 +1176,10 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | |||
1175 | } | 1176 | } |
1176 | } | 1177 | } |
1177 | 1178 | ||
1179 | ifibss->state = IEEE80211_IBSS_MLME_SEARCH; | ||
1180 | memset(ifibss->bssid, 0, ETH_ALEN); | ||
1181 | ifibss->ssid_len = 0; | ||
1182 | |||
1178 | sta_info_flush(sdata->local, sdata); | 1183 | sta_info_flush(sdata->local, sdata); |
1179 | 1184 | ||
1180 | spin_lock_bh(&ifibss->incomplete_lock); | 1185 | spin_lock_bh(&ifibss->incomplete_lock); |
@@ -1197,6 +1202,7 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) | |||
1197 | lockdep_is_held(&sdata->u.ibss.mtx)); | 1202 | lockdep_is_held(&sdata->u.ibss.mtx)); |
1198 | RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); | 1203 | RCU_INIT_POINTER(sdata->u.ibss.presp, NULL); |
1199 | sdata->vif.bss_conf.ibss_joined = false; | 1204 | sdata->vif.bss_conf.ibss_joined = false; |
1205 | sdata->vif.bss_conf.ibss_creator = false; | ||
1200 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | | 1206 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | |
1201 | BSS_CHANGED_IBSS); | 1207 | BSS_CHANGED_IBSS); |
1202 | synchronize_rcu(); | 1208 | synchronize_rcu(); |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 8c804550465b..74748896d77b 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -56,6 +56,9 @@ struct ieee80211_local; | |||
56 | #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024)) | 56 | #define TU_TO_JIFFIES(x) (usecs_to_jiffies((x) * 1024)) |
57 | #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x)) | 57 | #define TU_TO_EXP_TIME(x) (jiffies + TU_TO_JIFFIES(x)) |
58 | 58 | ||
59 | /* power level hasn't been configured (or set to automatic) */ | ||
60 | #define IEEE80211_UNSET_POWER_LEVEL INT_MIN | ||
61 | |||
59 | /* | 62 | /* |
60 | * Some APs experience problems when working with U-APSD. Decrease the | 63 | * Some APs experience problems when working with U-APSD. Decrease the |
61 | * probability of that happening by using legacy mode for all ACs but VO. | 64 | * probability of that happening by using legacy mode for all ACs but VO. |
@@ -280,23 +283,27 @@ struct probe_resp { | |||
280 | u8 data[0]; | 283 | u8 data[0]; |
281 | }; | 284 | }; |
282 | 285 | ||
283 | struct ieee80211_if_ap { | 286 | struct ps_data { |
284 | struct beacon_data __rcu *beacon; | ||
285 | struct probe_resp __rcu *probe_resp; | ||
286 | |||
287 | struct list_head vlans; | ||
288 | |||
289 | /* yes, this looks ugly, but guarantees that we can later use | 287 | /* yes, this looks ugly, but guarantees that we can later use |
290 | * bitmap_empty :) | 288 | * bitmap_empty :) |
291 | * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ | 289 | * NB: don't touch this bitmap, use sta_info_{set,clear}_tim_bit */ |
292 | u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; | 290 | u8 tim[sizeof(unsigned long) * BITS_TO_LONGS(IEEE80211_MAX_AID + 1)]; |
293 | struct sk_buff_head ps_bc_buf; | 291 | struct sk_buff_head bc_buf; |
294 | atomic_t num_sta_ps; /* number of stations in PS mode */ | 292 | atomic_t num_sta_ps; /* number of stations in PS mode */ |
295 | atomic_t num_mcast_sta; /* number of stations receiving multicast */ | ||
296 | int dtim_count; | 293 | int dtim_count; |
297 | bool dtim_bc_mc; | 294 | bool dtim_bc_mc; |
298 | }; | 295 | }; |
299 | 296 | ||
297 | struct ieee80211_if_ap { | ||
298 | struct beacon_data __rcu *beacon; | ||
299 | struct probe_resp __rcu *probe_resp; | ||
300 | |||
301 | struct list_head vlans; | ||
302 | |||
303 | struct ps_data ps; | ||
304 | atomic_t num_mcast_sta; /* number of stations receiving multicast */ | ||
305 | }; | ||
306 | |||
300 | struct ieee80211_if_wds { | 307 | struct ieee80211_if_wds { |
301 | struct sta_info *sta; | 308 | struct sta_info *sta; |
302 | u8 remote_addr[ETH_ALEN]; | 309 | u8 remote_addr[ETH_ALEN]; |
@@ -316,7 +323,6 @@ struct mesh_stats { | |||
316 | __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ | 323 | __u32 dropped_frames_ttl; /* Not transmitted since mesh_ttl == 0*/ |
317 | __u32 dropped_frames_no_route; /* Not transmitted, no route found */ | 324 | __u32 dropped_frames_no_route; /* Not transmitted, no route found */ |
318 | __u32 dropped_frames_congestion;/* Not forwarded due to congestion */ | 325 | __u32 dropped_frames_congestion;/* Not forwarded due to congestion */ |
319 | atomic_t estab_plinks; | ||
320 | }; | 326 | }; |
321 | 327 | ||
322 | #define PREQ_Q_F_START 0x1 | 328 | #define PREQ_Q_F_START 0x1 |
@@ -350,7 +356,7 @@ struct ieee80211_roc_work { | |||
350 | 356 | ||
351 | u32 duration, req_duration; | 357 | u32 duration, req_duration; |
352 | struct sk_buff *frame; | 358 | struct sk_buff *frame; |
353 | u64 mgmt_tx_cookie; | 359 | u64 cookie, mgmt_tx_cookie; |
354 | }; | 360 | }; |
355 | 361 | ||
356 | /* flags used in struct ieee80211_if_managed.flags */ | 362 | /* flags used in struct ieee80211_if_managed.flags */ |
@@ -378,8 +384,9 @@ struct ieee80211_mgd_auth_data { | |||
378 | u8 key_len, key_idx; | 384 | u8 key_len, key_idx; |
379 | bool done; | 385 | bool done; |
380 | 386 | ||
381 | size_t ie_len; | 387 | u16 sae_trans, sae_status; |
382 | u8 ie[]; | 388 | size_t data_len; |
389 | u8 data[]; | ||
383 | }; | 390 | }; |
384 | 391 | ||
385 | struct ieee80211_mgd_assoc_data { | 392 | struct ieee80211_mgd_assoc_data { |
@@ -433,7 +440,6 @@ struct ieee80211_if_managed { | |||
433 | bool powersave; /* powersave requested for this iface */ | 440 | bool powersave; /* powersave requested for this iface */ |
434 | bool broken_ap; /* AP is broken -- turn off powersave */ | 441 | bool broken_ap; /* AP is broken -- turn off powersave */ |
435 | enum ieee80211_smps_mode req_smps, /* requested smps mode */ | 442 | enum ieee80211_smps_mode req_smps, /* requested smps mode */ |
436 | ap_smps, /* smps mode AP thinks we're in */ | ||
437 | driver_smps_mode; /* smps mode request */ | 443 | driver_smps_mode; /* smps mode request */ |
438 | 444 | ||
439 | struct work_struct request_smps_work; | 445 | struct work_struct request_smps_work; |
@@ -467,6 +473,8 @@ struct ieee80211_if_managed { | |||
467 | 473 | ||
468 | u8 use_4addr; | 474 | u8 use_4addr; |
469 | 475 | ||
476 | u8 p2p_noa_index; | ||
477 | |||
470 | /* Signal strength from the last Beacon frame in the current BSS. */ | 478 | /* Signal strength from the last Beacon frame in the current BSS. */ |
471 | int last_beacon_signal; | 479 | int last_beacon_signal; |
472 | 480 | ||
@@ -599,6 +607,7 @@ struct ieee80211_if_mesh { | |||
599 | int preq_queue_len; | 607 | int preq_queue_len; |
600 | struct mesh_stats mshstats; | 608 | struct mesh_stats mshstats; |
601 | struct mesh_config mshcfg; | 609 | struct mesh_config mshcfg; |
610 | atomic_t estab_plinks; | ||
602 | u32 mesh_seqnum; | 611 | u32 mesh_seqnum; |
603 | bool accepting_plinks; | 612 | bool accepting_plinks; |
604 | int num_gates; | 613 | int num_gates; |
@@ -610,7 +619,7 @@ struct ieee80211_if_mesh { | |||
610 | IEEE80211_MESH_SEC_SECURED = 0x2, | 619 | IEEE80211_MESH_SEC_SECURED = 0x2, |
611 | } security; | 620 | } security; |
612 | /* Extensible Synchronization Framework */ | 621 | /* Extensible Synchronization Framework */ |
613 | struct ieee80211_mesh_sync_ops *sync_ops; | 622 | const struct ieee80211_mesh_sync_ops *sync_ops; |
614 | s64 sync_offset_clockdrift_max; | 623 | s64 sync_offset_clockdrift_max; |
615 | spinlock_t sync_offset_lock; | 624 | spinlock_t sync_offset_lock; |
616 | bool adjusting_tbtt; | 625 | bool adjusting_tbtt; |
@@ -658,6 +667,30 @@ enum ieee80211_sdata_state_bits { | |||
658 | SDATA_STATE_OFFCHANNEL, | 667 | SDATA_STATE_OFFCHANNEL, |
659 | }; | 668 | }; |
660 | 669 | ||
670 | /** | ||
671 | * enum ieee80211_chanctx_mode - channel context configuration mode | ||
672 | * | ||
673 | * @IEEE80211_CHANCTX_SHARED: channel context may be used by | ||
674 | * multiple interfaces | ||
675 | * @IEEE80211_CHANCTX_EXCLUSIVE: channel context can be used | ||
676 | * only by a single interface. This can be used for example for | ||
677 | * non-fixed channel IBSS. | ||
678 | */ | ||
679 | enum ieee80211_chanctx_mode { | ||
680 | IEEE80211_CHANCTX_SHARED, | ||
681 | IEEE80211_CHANCTX_EXCLUSIVE | ||
682 | }; | ||
683 | |||
684 | struct ieee80211_chanctx { | ||
685 | struct list_head list; | ||
686 | struct rcu_head rcu_head; | ||
687 | |||
688 | enum ieee80211_chanctx_mode mode; | ||
689 | int refcount; | ||
690 | |||
691 | struct ieee80211_chanctx_conf conf; | ||
692 | }; | ||
693 | |||
661 | struct ieee80211_sub_if_data { | 694 | struct ieee80211_sub_if_data { |
662 | struct list_head list; | 695 | struct list_head list; |
663 | 696 | ||
@@ -704,11 +737,20 @@ struct ieee80211_sub_if_data { | |||
704 | 737 | ||
705 | struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; | 738 | struct ieee80211_tx_queue_params tx_conf[IEEE80211_NUM_ACS]; |
706 | 739 | ||
740 | /* used to reconfigure hardware SM PS */ | ||
741 | struct work_struct recalc_smps; | ||
742 | |||
707 | struct work_struct work; | 743 | struct work_struct work; |
708 | struct sk_buff_head skb_queue; | 744 | struct sk_buff_head skb_queue; |
709 | 745 | ||
710 | bool arp_filter_state; | 746 | bool arp_filter_state; |
711 | 747 | ||
748 | u8 needed_rx_chains; | ||
749 | enum ieee80211_smps_mode smps_mode; | ||
750 | |||
751 | int user_power_level; /* in dBm */ | ||
752 | int ap_power_level; /* in dBm */ | ||
753 | |||
712 | /* | 754 | /* |
713 | * AP this belongs to: self in AP mode and | 755 | * AP this belongs to: self in AP mode and |
714 | * corresponding AP in VLAN mode, NULL for | 756 | * corresponding AP in VLAN mode, NULL for |
@@ -749,6 +791,21 @@ struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p) | |||
749 | return container_of(p, struct ieee80211_sub_if_data, vif); | 791 | return container_of(p, struct ieee80211_sub_if_data, vif); |
750 | } | 792 | } |
751 | 793 | ||
794 | static inline enum ieee80211_band | ||
795 | ieee80211_get_sdata_band(struct ieee80211_sub_if_data *sdata) | ||
796 | { | ||
797 | enum ieee80211_band band = IEEE80211_BAND_2GHZ; | ||
798 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
799 | |||
800 | rcu_read_lock(); | ||
801 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
802 | if (!WARN_ON(!chanctx_conf)) | ||
803 | band = chanctx_conf->channel->band; | ||
804 | rcu_read_unlock(); | ||
805 | |||
806 | return band; | ||
807 | } | ||
808 | |||
752 | enum sdata_queue_type { | 809 | enum sdata_queue_type { |
753 | IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0, | 810 | IEEE80211_SDATA_QUEUE_TYPE_FRAME = 0, |
754 | IEEE80211_SDATA_QUEUE_AGG_START = 1, | 811 | IEEE80211_SDATA_QUEUE_AGG_START = 1, |
@@ -821,6 +878,7 @@ enum { | |||
821 | * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to | 878 | * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to |
822 | * send out data | 879 | * send out data |
823 | * @SCAN_RESUME: Resume the scan and scan the next channel | 880 | * @SCAN_RESUME: Resume the scan and scan the next channel |
881 | * @SCAN_ABORT: Abort the scan and go back to operating channel | ||
824 | */ | 882 | */ |
825 | enum mac80211_scan_state { | 883 | enum mac80211_scan_state { |
826 | SCAN_DECISION, | 884 | SCAN_DECISION, |
@@ -828,6 +886,7 @@ enum mac80211_scan_state { | |||
828 | SCAN_SEND_PROBE, | 886 | SCAN_SEND_PROBE, |
829 | SCAN_SUSPEND, | 887 | SCAN_SUSPEND, |
830 | SCAN_RESUME, | 888 | SCAN_RESUME, |
889 | SCAN_ABORT, | ||
831 | }; | 890 | }; |
832 | 891 | ||
833 | struct ieee80211_local { | 892 | struct ieee80211_local { |
@@ -858,15 +917,14 @@ struct ieee80211_local { | |||
858 | 917 | ||
859 | bool wiphy_ciphers_allocated; | 918 | bool wiphy_ciphers_allocated; |
860 | 919 | ||
920 | bool use_chanctx; | ||
921 | |||
861 | /* protects the aggregated multicast list and filter calls */ | 922 | /* protects the aggregated multicast list and filter calls */ |
862 | spinlock_t filter_lock; | 923 | spinlock_t filter_lock; |
863 | 924 | ||
864 | /* used for uploading changed mc list */ | 925 | /* used for uploading changed mc list */ |
865 | struct work_struct reconfig_filter; | 926 | struct work_struct reconfig_filter; |
866 | 927 | ||
867 | /* used to reconfigure hardware SM PS */ | ||
868 | struct work_struct recalc_smps; | ||
869 | |||
870 | /* aggregated multicast list */ | 928 | /* aggregated multicast list */ |
871 | struct netdev_hw_addr_list mc_list; | 929 | struct netdev_hw_addr_list mc_list; |
872 | 930 | ||
@@ -903,6 +961,9 @@ struct ieee80211_local { | |||
903 | /* wowlan is enabled -- don't reconfig on resume */ | 961 | /* wowlan is enabled -- don't reconfig on resume */ |
904 | bool wowlan; | 962 | bool wowlan; |
905 | 963 | ||
964 | /* number of RX chains the hardware has */ | ||
965 | u8 rx_chains; | ||
966 | |||
906 | int tx_headroom; /* required headroom for hardware/radiotap */ | 967 | int tx_headroom; /* required headroom for hardware/radiotap */ |
907 | 968 | ||
908 | /* Tasklet and skb queue to process calls from IRQ mode. All frames | 969 | /* Tasklet and skb queue to process calls from IRQ mode. All frames |
@@ -980,13 +1041,19 @@ struct ieee80211_local { | |||
980 | enum mac80211_scan_state next_scan_state; | 1041 | enum mac80211_scan_state next_scan_state; |
981 | struct delayed_work scan_work; | 1042 | struct delayed_work scan_work; |
982 | struct ieee80211_sub_if_data __rcu *scan_sdata; | 1043 | struct ieee80211_sub_if_data __rcu *scan_sdata; |
1044 | struct ieee80211_channel *csa_channel; | ||
1045 | /* For backward compatibility only -- do not use */ | ||
1046 | struct ieee80211_channel *_oper_channel; | ||
983 | enum nl80211_channel_type _oper_channel_type; | 1047 | enum nl80211_channel_type _oper_channel_type; |
984 | struct ieee80211_channel *oper_channel, *csa_channel; | ||
985 | 1048 | ||
986 | /* Temporary remain-on-channel for off-channel operations */ | 1049 | /* Temporary remain-on-channel for off-channel operations */ |
987 | struct ieee80211_channel *tmp_channel; | 1050 | struct ieee80211_channel *tmp_channel; |
988 | enum nl80211_channel_type tmp_channel_type; | 1051 | enum nl80211_channel_type tmp_channel_type; |
989 | 1052 | ||
1053 | /* channel contexts */ | ||
1054 | struct list_head chanctx_list; | ||
1055 | struct mutex chanctx_mtx; | ||
1056 | |||
990 | /* SNMP counters */ | 1057 | /* SNMP counters */ |
991 | /* dot11CountersTable */ | 1058 | /* dot11CountersTable */ |
992 | u32 dot11TransmittedFragmentCount; | 1059 | u32 dot11TransmittedFragmentCount; |
@@ -1058,8 +1125,7 @@ struct ieee80211_local { | |||
1058 | int dynamic_ps_user_timeout; | 1125 | int dynamic_ps_user_timeout; |
1059 | bool disable_dynamic_ps; | 1126 | bool disable_dynamic_ps; |
1060 | 1127 | ||
1061 | int user_power_level; /* in dBm */ | 1128 | int user_power_level; /* in dBm, for all interfaces */ |
1062 | int ap_power_level; /* in dBm */ | ||
1063 | 1129 | ||
1064 | enum ieee80211_smps_mode smps_mode; | 1130 | enum ieee80211_smps_mode smps_mode; |
1065 | 1131 | ||
@@ -1078,6 +1144,7 @@ struct ieee80211_local { | |||
1078 | struct list_head roc_list; | 1144 | struct list_head roc_list; |
1079 | struct work_struct hw_roc_start, hw_roc_done; | 1145 | struct work_struct hw_roc_start, hw_roc_done; |
1080 | unsigned long hw_roc_start_time; | 1146 | unsigned long hw_roc_start_time; |
1147 | u64 roc_cookie_counter; | ||
1081 | 1148 | ||
1082 | struct idr ack_status_frames; | 1149 | struct idr ack_status_frames; |
1083 | spinlock_t ack_status_lock; | 1150 | spinlock_t ack_status_lock; |
@@ -1091,6 +1158,8 @@ struct ieee80211_local { | |||
1091 | 1158 | ||
1092 | /* virtual monitor interface */ | 1159 | /* virtual monitor interface */ |
1093 | struct ieee80211_sub_if_data __rcu *monitor_sdata; | 1160 | struct ieee80211_sub_if_data __rcu *monitor_sdata; |
1161 | struct ieee80211_channel *monitor_channel; | ||
1162 | enum nl80211_channel_type monitor_channel_type; | ||
1094 | }; | 1163 | }; |
1095 | 1164 | ||
1096 | static inline struct ieee80211_sub_if_data * | 1165 | static inline struct ieee80211_sub_if_data * |
@@ -1133,6 +1202,8 @@ struct ieee802_11_elems { | |||
1133 | u8 *wmm_param; | 1202 | u8 *wmm_param; |
1134 | struct ieee80211_ht_cap *ht_cap_elem; | 1203 | struct ieee80211_ht_cap *ht_cap_elem; |
1135 | struct ieee80211_ht_operation *ht_operation; | 1204 | struct ieee80211_ht_operation *ht_operation; |
1205 | struct ieee80211_vht_cap *vht_cap_elem; | ||
1206 | struct ieee80211_vht_operation *vht_operation; | ||
1136 | struct ieee80211_meshconf_ie *mesh_config; | 1207 | struct ieee80211_meshconf_ie *mesh_config; |
1137 | u8 *mesh_id; | 1208 | u8 *mesh_id; |
1138 | u8 *peering; | 1209 | u8 *peering; |
@@ -1302,6 +1373,9 @@ void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata, | |||
1302 | int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up); | 1373 | int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up); |
1303 | void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata); | 1374 | void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata); |
1304 | 1375 | ||
1376 | bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); | ||
1377 | void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata); | ||
1378 | |||
1305 | static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) | 1379 | static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata) |
1306 | { | 1380 | { |
1307 | return test_bit(SDATA_STATE_RUNNING, &sdata->state); | 1381 | return test_bit(SDATA_STATE_RUNNING, &sdata->state); |
@@ -1314,6 +1388,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1314 | struct net_device *dev); | 1388 | struct net_device *dev); |
1315 | netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | 1389 | netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, |
1316 | struct net_device *dev); | 1390 | struct net_device *dev); |
1391 | void ieee80211_purge_tx_queue(struct ieee80211_hw *hw, | ||
1392 | struct sk_buff_head *skbs); | ||
1317 | 1393 | ||
1318 | /* HT */ | 1394 | /* HT */ |
1319 | void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, | 1395 | void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, |
@@ -1359,6 +1435,13 @@ void ieee80211_ba_session_work(struct work_struct *work); | |||
1359 | void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid); | 1435 | void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid); |
1360 | void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid); | 1436 | void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid); |
1361 | 1437 | ||
1438 | u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs); | ||
1439 | |||
1440 | /* VHT */ | ||
1441 | void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, | ||
1442 | struct ieee80211_supported_band *sband, | ||
1443 | struct ieee80211_vht_cap *vht_cap_ie, | ||
1444 | struct ieee80211_sta_vht_cap *vht_cap); | ||
1362 | /* Spectrum management */ | 1445 | /* Spectrum management */ |
1363 | void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, | 1446 | void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, |
1364 | struct ieee80211_mgmt *mgmt, | 1447 | struct ieee80211_mgmt *mgmt, |
@@ -1393,11 +1476,42 @@ void mac80211_ev_michael_mic_failure(struct ieee80211_sub_if_data *sdata, int ke | |||
1393 | gfp_t gfp); | 1476 | gfp_t gfp); |
1394 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, | 1477 | void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, |
1395 | bool bss_notify); | 1478 | bool bss_notify); |
1396 | void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb); | 1479 | void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, |
1480 | enum ieee80211_band band); | ||
1481 | |||
1482 | void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, | ||
1483 | struct sk_buff *skb, int tid, | ||
1484 | enum ieee80211_band band); | ||
1485 | |||
1486 | static inline void | ||
1487 | ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, | ||
1488 | struct sk_buff *skb, int tid, | ||
1489 | enum ieee80211_band band) | ||
1490 | { | ||
1491 | rcu_read_lock(); | ||
1492 | __ieee80211_tx_skb_tid_band(sdata, skb, tid, band); | ||
1493 | rcu_read_unlock(); | ||
1494 | } | ||
1397 | 1495 | ||
1398 | void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, | 1496 | static inline void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, |
1399 | struct sk_buff *skb, int tid); | 1497 | struct sk_buff *skb, int tid) |
1400 | static void inline ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, | 1498 | { |
1499 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
1500 | |||
1501 | rcu_read_lock(); | ||
1502 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1503 | if (WARN_ON(!chanctx_conf)) { | ||
1504 | rcu_read_unlock(); | ||
1505 | kfree_skb(skb); | ||
1506 | return; | ||
1507 | } | ||
1508 | |||
1509 | __ieee80211_tx_skb_tid_band(sdata, skb, tid, | ||
1510 | chanctx_conf->channel->band); | ||
1511 | rcu_read_unlock(); | ||
1512 | } | ||
1513 | |||
1514 | static inline void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, | ||
1401 | struct sk_buff *skb) | 1515 | struct sk_buff *skb) |
1402 | { | 1516 | { |
1403 | /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */ | 1517 | /* Send all internal mgmt frames on VO. Accordingly set TID to 7. */ |
@@ -1444,7 +1558,7 @@ static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local, | |||
1444 | } | 1558 | } |
1445 | 1559 | ||
1446 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | 1560 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, |
1447 | u16 transaction, u16 auth_alg, | 1561 | u16 transaction, u16 auth_alg, u16 status, |
1448 | u8 *extra, size_t extra_len, const u8 *bssid, | 1562 | u8 *extra, size_t extra_len, const u8 *bssid, |
1449 | const u8 *da, const u8 *key, u8 key_len, u8 key_idx); | 1563 | const u8 *da, const u8 *key, u8 key_len, u8 key_idx); |
1450 | void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, | 1564 | void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, |
@@ -1464,7 +1578,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | |||
1464 | const u8 *ssid, size_t ssid_len, | 1578 | const u8 *ssid, size_t ssid_len, |
1465 | const u8 *ie, size_t ie_len, | 1579 | const u8 *ie, size_t ie_len, |
1466 | u32 ratemask, bool directed, bool no_cck, | 1580 | u32 ratemask, bool directed, bool no_cck, |
1467 | struct ieee80211_channel *channel); | 1581 | struct ieee80211_channel *channel, bool scan); |
1468 | 1582 | ||
1469 | void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | 1583 | void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, |
1470 | const size_t supp_rates_len, | 1584 | const size_t supp_rates_len, |
@@ -1474,7 +1588,7 @@ u32 ieee80211_sta_get_rates(struct ieee80211_local *local, | |||
1474 | enum ieee80211_band band, u32 *basic_rates); | 1588 | enum ieee80211_band band, u32 *basic_rates); |
1475 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, | 1589 | int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata, |
1476 | enum ieee80211_smps_mode smps_mode); | 1590 | enum ieee80211_smps_mode smps_mode); |
1477 | void ieee80211_recalc_smps(struct ieee80211_local *local); | 1591 | void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata); |
1478 | 1592 | ||
1479 | size_t ieee80211_ie_split(const u8 *ies, size_t ielen, | 1593 | size_t ieee80211_ie_split(const u8 *ies, size_t ielen, |
1480 | const u8 *ids, int n_ids, size_t offset); | 1594 | const u8 *ids, int n_ids, size_t offset); |
@@ -1495,21 +1609,19 @@ int ieee80211_add_ext_srates_ie(struct ieee80211_sub_if_data *sdata, | |||
1495 | enum ieee80211_band band); | 1609 | enum ieee80211_band band); |
1496 | 1610 | ||
1497 | /* channel management */ | 1611 | /* channel management */ |
1498 | enum ieee80211_chan_mode { | ||
1499 | CHAN_MODE_UNDEFINED, | ||
1500 | CHAN_MODE_HOPPING, | ||
1501 | CHAN_MODE_FIXED, | ||
1502 | }; | ||
1503 | |||
1504 | enum ieee80211_chan_mode | ||
1505 | ieee80211_get_channel_mode(struct ieee80211_local *local, | ||
1506 | struct ieee80211_sub_if_data *ignore); | ||
1507 | bool ieee80211_set_channel_type(struct ieee80211_local *local, | ||
1508 | struct ieee80211_sub_if_data *sdata, | ||
1509 | enum nl80211_channel_type chantype); | ||
1510 | enum nl80211_channel_type | 1612 | enum nl80211_channel_type |
1511 | ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper); | 1613 | ieee80211_ht_oper_to_channel_type(struct ieee80211_ht_operation *ht_oper); |
1512 | 1614 | ||
1615 | int __must_check | ||
1616 | ieee80211_vif_use_channel(struct ieee80211_sub_if_data *sdata, | ||
1617 | struct ieee80211_channel *channel, | ||
1618 | enum nl80211_channel_type channel_type, | ||
1619 | enum ieee80211_chanctx_mode mode); | ||
1620 | void ieee80211_vif_release_channel(struct ieee80211_sub_if_data *sdata); | ||
1621 | |||
1622 | void ieee80211_recalc_smps_chanctx(struct ieee80211_local *local, | ||
1623 | struct ieee80211_chanctx *chanctx); | ||
1624 | |||
1513 | #ifdef CONFIG_MAC80211_NOINLINE | 1625 | #ifdef CONFIG_MAC80211_NOINLINE |
1514 | #define debug_noinline noinline | 1626 | #define debug_noinline noinline |
1515 | #else | 1627 | #else |
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 6f8a73c64fb3..80ce90b29d9d 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c | |||
@@ -42,6 +42,41 @@ | |||
42 | * by either the RTNL, the iflist_mtx or RCU. | 42 | * by either the RTNL, the iflist_mtx or RCU. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata) | ||
46 | { | ||
47 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
48 | int power; | ||
49 | |||
50 | rcu_read_lock(); | ||
51 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
52 | if (!chanctx_conf) { | ||
53 | rcu_read_unlock(); | ||
54 | return false; | ||
55 | } | ||
56 | |||
57 | power = chanctx_conf->channel->max_power; | ||
58 | rcu_read_unlock(); | ||
59 | |||
60 | if (sdata->user_power_level != IEEE80211_UNSET_POWER_LEVEL) | ||
61 | power = min(power, sdata->user_power_level); | ||
62 | |||
63 | if (sdata->ap_power_level != IEEE80211_UNSET_POWER_LEVEL) | ||
64 | power = min(power, sdata->ap_power_level); | ||
65 | |||
66 | if (power != sdata->vif.bss_conf.txpower) { | ||
67 | sdata->vif.bss_conf.txpower = power; | ||
68 | ieee80211_hw_config(sdata->local, 0); | ||
69 | return true; | ||
70 | } | ||
71 | |||
72 | return false; | ||
73 | } | ||
74 | |||
75 | void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata) | ||
76 | { | ||
77 | if (__ieee80211_recalc_txpower(sdata)) | ||
78 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER); | ||
79 | } | ||
45 | 80 | ||
46 | static u32 ieee80211_idle_off(struct ieee80211_local *local, | 81 | static u32 ieee80211_idle_off(struct ieee80211_local *local, |
47 | const char *reason) | 82 | const char *reason) |
@@ -380,6 +415,15 @@ static int ieee80211_add_virtual_monitor(struct ieee80211_local *local) | |||
380 | goto out_unlock; | 415 | goto out_unlock; |
381 | } | 416 | } |
382 | 417 | ||
418 | ret = ieee80211_vif_use_channel(sdata, local->monitor_channel, | ||
419 | local->monitor_channel_type, | ||
420 | IEEE80211_CHANCTX_EXCLUSIVE); | ||
421 | if (ret) { | ||
422 | drv_remove_interface(local, sdata); | ||
423 | kfree(sdata); | ||
424 | goto out_unlock; | ||
425 | } | ||
426 | |||
383 | rcu_assign_pointer(local->monitor_sdata, sdata); | 427 | rcu_assign_pointer(local->monitor_sdata, sdata); |
384 | out_unlock: | 428 | out_unlock: |
385 | mutex_unlock(&local->iflist_mtx); | 429 | mutex_unlock(&local->iflist_mtx); |
@@ -403,6 +447,8 @@ static void ieee80211_del_virtual_monitor(struct ieee80211_local *local) | |||
403 | rcu_assign_pointer(local->monitor_sdata, NULL); | 447 | rcu_assign_pointer(local->monitor_sdata, NULL); |
404 | synchronize_net(); | 448 | synchronize_net(); |
405 | 449 | ||
450 | ieee80211_vif_release_channel(sdata); | ||
451 | |||
406 | drv_remove_interface(local, sdata); | 452 | drv_remove_interface(local, sdata); |
407 | 453 | ||
408 | kfree(sdata); | 454 | kfree(sdata); |
@@ -665,7 +711,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
665 | struct sk_buff *skb, *tmp; | 711 | struct sk_buff *skb, *tmp; |
666 | u32 hw_reconf_flags = 0; | 712 | u32 hw_reconf_flags = 0; |
667 | int i; | 713 | int i; |
668 | enum nl80211_channel_type orig_ct; | ||
669 | 714 | ||
670 | clear_bit(SDATA_STATE_RUNNING, &sdata->state); | 715 | clear_bit(SDATA_STATE_RUNNING, &sdata->state); |
671 | 716 | ||
@@ -729,34 +774,17 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
729 | del_timer_sync(&local->dynamic_ps_timer); | 774 | del_timer_sync(&local->dynamic_ps_timer); |
730 | cancel_work_sync(&local->dynamic_ps_enable_work); | 775 | cancel_work_sync(&local->dynamic_ps_enable_work); |
731 | 776 | ||
777 | cancel_work_sync(&sdata->recalc_smps); | ||
778 | |||
732 | /* APs need special treatment */ | 779 | /* APs need special treatment */ |
733 | if (sdata->vif.type == NL80211_IFTYPE_AP) { | 780 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
734 | struct ieee80211_sub_if_data *vlan, *tmpsdata; | 781 | struct ieee80211_sub_if_data *vlan, *tmpsdata; |
735 | struct beacon_data *old_beacon = | ||
736 | rtnl_dereference(sdata->u.ap.beacon); | ||
737 | struct probe_resp *old_probe_resp = | ||
738 | rtnl_dereference(sdata->u.ap.probe_resp); | ||
739 | |||
740 | /* sdata_running will return false, so this will disable */ | ||
741 | ieee80211_bss_info_change_notify(sdata, | ||
742 | BSS_CHANGED_BEACON_ENABLED); | ||
743 | |||
744 | /* remove beacon and probe response */ | ||
745 | RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); | ||
746 | RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); | ||
747 | synchronize_rcu(); | ||
748 | kfree(old_beacon); | ||
749 | kfree(old_probe_resp); | ||
750 | 782 | ||
751 | /* down all dependent devices, that is VLANs */ | 783 | /* down all dependent devices, that is VLANs */ |
752 | list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, | 784 | list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, |
753 | u.vlan.list) | 785 | u.vlan.list) |
754 | dev_close(vlan->dev); | 786 | dev_close(vlan->dev); |
755 | WARN_ON(!list_empty(&sdata->u.ap.vlans)); | 787 | WARN_ON(!list_empty(&sdata->u.ap.vlans)); |
756 | |||
757 | /* free all potentially still buffered bcast frames */ | ||
758 | local->total_ps_buffered -= skb_queue_len(&sdata->u.ap.ps_bc_buf); | ||
759 | skb_queue_purge(&sdata->u.ap.ps_bc_buf); | ||
760 | } else if (sdata->vif.type == NL80211_IFTYPE_STATION) { | 788 | } else if (sdata->vif.type == NL80211_IFTYPE_STATION) { |
761 | ieee80211_mgd_stop(sdata); | 789 | ieee80211_mgd_stop(sdata); |
762 | } | 790 | } |
@@ -837,14 +865,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
837 | hw_reconf_flags = 0; | 865 | hw_reconf_flags = 0; |
838 | } | 866 | } |
839 | 867 | ||
840 | /* Re-calculate channel-type, in case there are multiple vifs | ||
841 | * on different channel types. | ||
842 | */ | ||
843 | orig_ct = local->_oper_channel_type; | ||
844 | ieee80211_set_channel_type(local, NULL, NL80211_CHAN_NO_HT); | ||
845 | |||
846 | /* do after stop to avoid reconfiguring when we stop anyway */ | 868 | /* do after stop to avoid reconfiguring when we stop anyway */ |
847 | if (hw_reconf_flags || (orig_ct != local->_oper_channel_type)) | 869 | if (hw_reconf_flags) |
848 | ieee80211_hw_config(local, hw_reconf_flags); | 870 | ieee80211_hw_config(local, hw_reconf_flags); |
849 | 871 | ||
850 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); | 872 | spin_lock_irqsave(&local->queue_stop_reason_lock, flags); |
@@ -853,7 +875,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, | |||
853 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 875 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
854 | if (info->control.vif == &sdata->vif) { | 876 | if (info->control.vif == &sdata->vif) { |
855 | __skb_unlink(skb, &local->pending[i]); | 877 | __skb_unlink(skb, &local->pending[i]); |
856 | dev_kfree_skb_irq(skb); | 878 | ieee80211_free_txskb(&local->hw, skb); |
857 | } | 879 | } |
858 | } | 880 | } |
859 | } | 881 | } |
@@ -1121,6 +1143,13 @@ static void ieee80211_iface_work(struct work_struct *work) | |||
1121 | } | 1143 | } |
1122 | } | 1144 | } |
1123 | 1145 | ||
1146 | static void ieee80211_recalc_smps_work(struct work_struct *work) | ||
1147 | { | ||
1148 | struct ieee80211_sub_if_data *sdata = | ||
1149 | container_of(work, struct ieee80211_sub_if_data, recalc_smps); | ||
1150 | |||
1151 | ieee80211_recalc_smps(sdata); | ||
1152 | } | ||
1124 | 1153 | ||
1125 | /* | 1154 | /* |
1126 | * Helper function to initialise an interface to a specific type. | 1155 | * Helper function to initialise an interface to a specific type. |
@@ -1149,6 +1178,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, | |||
1149 | 1178 | ||
1150 | skb_queue_head_init(&sdata->skb_queue); | 1179 | skb_queue_head_init(&sdata->skb_queue); |
1151 | INIT_WORK(&sdata->work, ieee80211_iface_work); | 1180 | INIT_WORK(&sdata->work, ieee80211_iface_work); |
1181 | INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work); | ||
1152 | 1182 | ||
1153 | switch (type) { | 1183 | switch (type) { |
1154 | case NL80211_IFTYPE_P2P_GO: | 1184 | case NL80211_IFTYPE_P2P_GO: |
@@ -1157,7 +1187,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata, | |||
1157 | sdata->vif.p2p = true; | 1187 | sdata->vif.p2p = true; |
1158 | /* fall through */ | 1188 | /* fall through */ |
1159 | case NL80211_IFTYPE_AP: | 1189 | case NL80211_IFTYPE_AP: |
1160 | skb_queue_head_init(&sdata->u.ap.ps_bc_buf); | 1190 | skb_queue_head_init(&sdata->u.ap.ps.bc_buf); |
1161 | INIT_LIST_HEAD(&sdata->u.ap.vlans); | 1191 | INIT_LIST_HEAD(&sdata->u.ap.vlans); |
1162 | break; | 1192 | break; |
1163 | case NL80211_IFTYPE_P2P_CLIENT: | 1193 | case NL80211_IFTYPE_P2P_CLIENT: |
@@ -1282,11 +1312,6 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, | |||
1282 | if (type == ieee80211_vif_type_p2p(&sdata->vif)) | 1312 | if (type == ieee80211_vif_type_p2p(&sdata->vif)) |
1283 | return 0; | 1313 | return 0; |
1284 | 1314 | ||
1285 | /* Setting ad-hoc mode on non-IBSS channel is not supported. */ | ||
1286 | if (sdata->local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS && | ||
1287 | type == NL80211_IFTYPE_ADHOC) | ||
1288 | return -EOPNOTSUPP; | ||
1289 | |||
1290 | if (ieee80211_sdata_running(sdata)) { | 1315 | if (ieee80211_sdata_running(sdata)) { |
1291 | ret = ieee80211_runtime_change_iftype(sdata, type); | 1316 | ret = ieee80211_runtime_change_iftype(sdata, type); |
1292 | if (ret) | 1317 | if (ret) |
@@ -1298,9 +1323,6 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata, | |||
1298 | } | 1323 | } |
1299 | 1324 | ||
1300 | /* reset some values that shouldn't be kept across type changes */ | 1325 | /* reset some values that shouldn't be kept across type changes */ |
1301 | sdata->vif.bss_conf.basic_rates = | ||
1302 | ieee80211_mandatory_rates(sdata->local, | ||
1303 | sdata->local->oper_channel->band); | ||
1304 | sdata->drop_unencrypted = 0; | 1326 | sdata->drop_unencrypted = 0; |
1305 | if (type == NL80211_IFTYPE_STATION) | 1327 | if (type == NL80211_IFTYPE_STATION) |
1306 | sdata->u.mgd.use_4addr = false; | 1328 | sdata->u.mgd.use_4addr = false; |
@@ -1523,6 +1545,9 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, | |||
1523 | 1545 | ||
1524 | ieee80211_set_default_queues(sdata); | 1546 | ieee80211_set_default_queues(sdata); |
1525 | 1547 | ||
1548 | sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; | ||
1549 | sdata->user_power_level = local->user_power_level; | ||
1550 | |||
1526 | /* setup type-dependent data */ | 1551 | /* setup type-dependent data */ |
1527 | ieee80211_setup_sdata(sdata, type); | 1552 | ieee80211_setup_sdata(sdata, type); |
1528 | 1553 | ||
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index c80c4490351c..da2f41610125 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -93,15 +93,15 @@ static void ieee80211_reconfig_filter(struct work_struct *work) | |||
93 | ieee80211_configure_filter(local); | 93 | ieee80211_configure_filter(local); |
94 | } | 94 | } |
95 | 95 | ||
96 | int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | 96 | static u32 ieee80211_hw_conf_chan(struct ieee80211_local *local) |
97 | { | 97 | { |
98 | struct ieee80211_sub_if_data *sdata; | ||
98 | struct ieee80211_channel *chan; | 99 | struct ieee80211_channel *chan; |
99 | int ret = 0; | 100 | u32 changed = 0; |
100 | int power; | 101 | int power; |
101 | enum nl80211_channel_type channel_type; | 102 | enum nl80211_channel_type channel_type; |
102 | u32 offchannel_flag; | 103 | u32 offchannel_flag; |
103 | 104 | bool scanning = false; | |
104 | might_sleep(); | ||
105 | 105 | ||
106 | offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; | 106 | offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; |
107 | if (local->scan_channel) { | 107 | if (local->scan_channel) { |
@@ -109,7 +109,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | |||
109 | /* If scanning on oper channel, use whatever channel-type | 109 | /* If scanning on oper channel, use whatever channel-type |
110 | * is currently in use. | 110 | * is currently in use. |
111 | */ | 111 | */ |
112 | if (chan == local->oper_channel) | 112 | if (chan == local->_oper_channel) |
113 | channel_type = local->_oper_channel_type; | 113 | channel_type = local->_oper_channel_type; |
114 | else | 114 | else |
115 | channel_type = NL80211_CHAN_NO_HT; | 115 | channel_type = NL80211_CHAN_NO_HT; |
@@ -117,11 +117,11 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | |||
117 | chan = local->tmp_channel; | 117 | chan = local->tmp_channel; |
118 | channel_type = local->tmp_channel_type; | 118 | channel_type = local->tmp_channel_type; |
119 | } else { | 119 | } else { |
120 | chan = local->oper_channel; | 120 | chan = local->_oper_channel; |
121 | channel_type = local->_oper_channel_type; | 121 | channel_type = local->_oper_channel_type; |
122 | } | 122 | } |
123 | 123 | ||
124 | if (chan != local->oper_channel || | 124 | if (chan != local->_oper_channel || |
125 | channel_type != local->_oper_channel_type) | 125 | channel_type != local->_oper_channel_type) |
126 | local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; | 126 | local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; |
127 | else | 127 | else |
@@ -148,22 +148,39 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | |||
148 | changed |= IEEE80211_CONF_CHANGE_SMPS; | 148 | changed |= IEEE80211_CONF_CHANGE_SMPS; |
149 | } | 149 | } |
150 | 150 | ||
151 | if (test_bit(SCAN_SW_SCANNING, &local->scanning) || | 151 | scanning = test_bit(SCAN_SW_SCANNING, &local->scanning) || |
152 | test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) || | 152 | test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning) || |
153 | test_bit(SCAN_HW_SCANNING, &local->scanning) || | 153 | test_bit(SCAN_HW_SCANNING, &local->scanning); |
154 | !local->ap_power_level) | 154 | power = chan->max_power; |
155 | power = chan->max_power; | ||
156 | else | ||
157 | power = min(chan->max_power, local->ap_power_level); | ||
158 | 155 | ||
159 | if (local->user_power_level >= 0) | 156 | rcu_read_lock(); |
160 | power = min(power, local->user_power_level); | 157 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
158 | if (!rcu_access_pointer(sdata->vif.chanctx_conf)) | ||
159 | continue; | ||
160 | power = min(power, sdata->vif.bss_conf.txpower); | ||
161 | } | ||
162 | rcu_read_unlock(); | ||
161 | 163 | ||
162 | if (local->hw.conf.power_level != power) { | 164 | if (local->hw.conf.power_level != power) { |
163 | changed |= IEEE80211_CONF_CHANGE_POWER; | 165 | changed |= IEEE80211_CONF_CHANGE_POWER; |
164 | local->hw.conf.power_level = power; | 166 | local->hw.conf.power_level = power; |
165 | } | 167 | } |
166 | 168 | ||
169 | return changed; | ||
170 | } | ||
171 | |||
172 | int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) | ||
173 | { | ||
174 | int ret = 0; | ||
175 | |||
176 | might_sleep(); | ||
177 | |||
178 | if (!local->use_chanctx) | ||
179 | changed |= ieee80211_hw_conf_chan(local); | ||
180 | else | ||
181 | changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL | | ||
182 | IEEE80211_CONF_CHANGE_POWER); | ||
183 | |||
167 | if (changed && local->open_count) { | 184 | if (changed && local->open_count) { |
168 | ret = drv_config(local, changed); | 185 | ret = drv_config(local, changed); |
169 | /* | 186 | /* |
@@ -359,14 +376,6 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw) | |||
359 | } | 376 | } |
360 | EXPORT_SYMBOL(ieee80211_restart_hw); | 377 | EXPORT_SYMBOL(ieee80211_restart_hw); |
361 | 378 | ||
362 | static void ieee80211_recalc_smps_work(struct work_struct *work) | ||
363 | { | ||
364 | struct ieee80211_local *local = | ||
365 | container_of(work, struct ieee80211_local, recalc_smps); | ||
366 | |||
367 | ieee80211_recalc_smps(local); | ||
368 | } | ||
369 | |||
370 | #ifdef CONFIG_INET | 379 | #ifdef CONFIG_INET |
371 | static int ieee80211_ifa_changed(struct notifier_block *nb, | 380 | static int ieee80211_ifa_changed(struct notifier_block *nb, |
372 | unsigned long data, void *arg) | 381 | unsigned long data, void *arg) |
@@ -540,6 +549,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
540 | struct ieee80211_local *local; | 549 | struct ieee80211_local *local; |
541 | int priv_size, i; | 550 | int priv_size, i; |
542 | struct wiphy *wiphy; | 551 | struct wiphy *wiphy; |
552 | bool use_chanctx; | ||
543 | 553 | ||
544 | if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config || | 554 | if (WARN_ON(!ops->tx || !ops->start || !ops->stop || !ops->config || |
545 | !ops->add_interface || !ops->remove_interface || | 555 | !ops->add_interface || !ops->remove_interface || |
@@ -549,6 +559,14 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
549 | if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) | 559 | if (WARN_ON(ops->sta_state && (ops->sta_add || ops->sta_remove))) |
550 | return NULL; | 560 | return NULL; |
551 | 561 | ||
562 | /* check all or no channel context operations exist */ | ||
563 | i = !!ops->add_chanctx + !!ops->remove_chanctx + | ||
564 | !!ops->change_chanctx + !!ops->assign_vif_chanctx + | ||
565 | !!ops->unassign_vif_chanctx; | ||
566 | if (WARN_ON(i != 0 && i != 5)) | ||
567 | return NULL; | ||
568 | use_chanctx = i == 5; | ||
569 | |||
552 | /* Ensure 32-byte alignment of our private data and hw private data. | 570 | /* Ensure 32-byte alignment of our private data and hw private data. |
553 | * We use the wiphy priv data for both our ieee80211_local and for | 571 | * We use the wiphy priv data for both our ieee80211_local and for |
554 | * the driver's private data | 572 | * the driver's private data |
@@ -584,8 +602,15 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
584 | if (ops->remain_on_channel) | 602 | if (ops->remain_on_channel) |
585 | wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; | 603 | wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
586 | 604 | ||
587 | wiphy->features = NL80211_FEATURE_SK_TX_STATUS | | 605 | wiphy->features |= NL80211_FEATURE_SK_TX_STATUS | |
588 | NL80211_FEATURE_HT_IBSS; | 606 | NL80211_FEATURE_SAE | |
607 | NL80211_FEATURE_HT_IBSS | | ||
608 | NL80211_FEATURE_VIF_TXPOWER; | ||
609 | |||
610 | if (!ops->hw_scan) | ||
611 | wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN | | ||
612 | NL80211_FEATURE_AP_SCAN; | ||
613 | |||
589 | 614 | ||
590 | if (!ops->set_key) | 615 | if (!ops->set_key) |
591 | wiphy->flags |= WIPHY_FLAG_IBSS_RSN; | 616 | wiphy->flags |= WIPHY_FLAG_IBSS_RSN; |
@@ -599,6 +624,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
599 | local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); | 624 | local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); |
600 | 625 | ||
601 | local->ops = ops; | 626 | local->ops = ops; |
627 | local->use_chanctx = use_chanctx; | ||
602 | 628 | ||
603 | /* set up some defaults */ | 629 | /* set up some defaults */ |
604 | local->hw.queues = 1; | 630 | local->hw.queues = 1; |
@@ -612,7 +638,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
612 | local->hw.radiotap_mcs_details = IEEE80211_RADIOTAP_MCS_HAVE_MCS | | 638 | local->hw.radiotap_mcs_details = IEEE80211_RADIOTAP_MCS_HAVE_MCS | |
613 | IEEE80211_RADIOTAP_MCS_HAVE_GI | | 639 | IEEE80211_RADIOTAP_MCS_HAVE_GI | |
614 | IEEE80211_RADIOTAP_MCS_HAVE_BW; | 640 | IEEE80211_RADIOTAP_MCS_HAVE_BW; |
615 | local->user_power_level = -1; | 641 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
616 | wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; | 642 | wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask; |
617 | 643 | ||
618 | INIT_LIST_HEAD(&local->interfaces); | 644 | INIT_LIST_HEAD(&local->interfaces); |
@@ -626,6 +652,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
626 | spin_lock_init(&local->filter_lock); | 652 | spin_lock_init(&local->filter_lock); |
627 | spin_lock_init(&local->queue_stop_reason_lock); | 653 | spin_lock_init(&local->queue_stop_reason_lock); |
628 | 654 | ||
655 | INIT_LIST_HEAD(&local->chanctx_list); | ||
656 | mutex_init(&local->chanctx_mtx); | ||
657 | |||
629 | /* | 658 | /* |
630 | * The rx_skb_queue is only accessed from tasklets, | 659 | * The rx_skb_queue is only accessed from tasklets, |
631 | * but other SKB queues are used from within IRQ | 660 | * but other SKB queues are used from within IRQ |
@@ -641,7 +670,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
641 | INIT_WORK(&local->restart_work, ieee80211_restart_work); | 670 | INIT_WORK(&local->restart_work, ieee80211_restart_work); |
642 | 671 | ||
643 | INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); | 672 | INIT_WORK(&local->reconfig_filter, ieee80211_reconfig_filter); |
644 | INIT_WORK(&local->recalc_smps, ieee80211_recalc_smps_work); | ||
645 | local->smps_mode = IEEE80211_SMPS_OFF; | 673 | local->smps_mode = IEEE80211_SMPS_OFF; |
646 | 674 | ||
647 | INIT_WORK(&local->dynamic_ps_enable_work, | 675 | INIT_WORK(&local->dynamic_ps_enable_work, |
@@ -719,6 +747,25 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
719 | if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan) | 747 | if ((hw->flags & IEEE80211_HW_SCAN_WHILE_IDLE) && !local->ops->hw_scan) |
720 | return -EINVAL; | 748 | return -EINVAL; |
721 | 749 | ||
750 | if (!local->use_chanctx) { | ||
751 | for (i = 0; i < local->hw.wiphy->n_iface_combinations; i++) { | ||
752 | const struct ieee80211_iface_combination *comb; | ||
753 | |||
754 | comb = &local->hw.wiphy->iface_combinations[i]; | ||
755 | |||
756 | if (comb->num_different_channels > 1) | ||
757 | return -EINVAL; | ||
758 | } | ||
759 | } else { | ||
760 | /* | ||
761 | * WDS is currently prohibited when channel contexts are used | ||
762 | * because there's no clear definition of which channel WDS | ||
763 | * type interfaces use | ||
764 | */ | ||
765 | if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_WDS)) | ||
766 | return -EINVAL; | ||
767 | } | ||
768 | |||
722 | /* Only HW csum features are currently compatible with mac80211 */ | 769 | /* Only HW csum features are currently compatible with mac80211 */ |
723 | feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | | 770 | feature_whitelist = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | |
724 | NETIF_F_HW_CSUM; | 771 | NETIF_F_HW_CSUM; |
@@ -728,6 +775,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
728 | if (hw->max_report_rates == 0) | 775 | if (hw->max_report_rates == 0) |
729 | hw->max_report_rates = hw->max_rates; | 776 | hw->max_report_rates = hw->max_rates; |
730 | 777 | ||
778 | local->rx_chains = 1; | ||
779 | |||
731 | /* | 780 | /* |
732 | * generic code guarantees at least one band, | 781 | * generic code guarantees at least one band, |
733 | * set this very early because much code assumes | 782 | * set this very early because much code assumes |
@@ -743,18 +792,29 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
743 | sband = local->hw.wiphy->bands[band]; | 792 | sband = local->hw.wiphy->bands[band]; |
744 | if (!sband) | 793 | if (!sband) |
745 | continue; | 794 | continue; |
746 | if (!local->oper_channel) { | 795 | if (!local->use_chanctx && !local->_oper_channel) { |
747 | /* init channel we're on */ | 796 | /* init channel we're on */ |
748 | local->hw.conf.channel = | 797 | local->hw.conf.channel = |
749 | local->oper_channel = &sband->channels[0]; | 798 | local->_oper_channel = &sband->channels[0]; |
750 | local->hw.conf.channel_type = NL80211_CHAN_NO_HT; | 799 | local->hw.conf.channel_type = NL80211_CHAN_NO_HT; |
751 | } | 800 | } |
801 | if (!local->monitor_channel) { | ||
802 | local->monitor_channel = &sband->channels[0]; | ||
803 | local->monitor_channel_type = NL80211_CHAN_NO_HT; | ||
804 | } | ||
752 | channels += sband->n_channels; | 805 | channels += sband->n_channels; |
753 | 806 | ||
754 | if (max_bitrates < sband->n_bitrates) | 807 | if (max_bitrates < sband->n_bitrates) |
755 | max_bitrates = sband->n_bitrates; | 808 | max_bitrates = sband->n_bitrates; |
756 | supp_ht = supp_ht || sband->ht_cap.ht_supported; | 809 | supp_ht = supp_ht || sband->ht_cap.ht_supported; |
757 | supp_vht = supp_vht || sband->vht_cap.vht_supported; | 810 | supp_vht = supp_vht || sband->vht_cap.vht_supported; |
811 | |||
812 | if (sband->ht_cap.ht_supported) | ||
813 | local->rx_chains = | ||
814 | max(ieee80211_mcs_to_chains(&sband->ht_cap.mcs), | ||
815 | local->rx_chains); | ||
816 | |||
817 | /* TODO: consider VHT for RX chains, hopefully it's the same */ | ||
758 | } | 818 | } |
759 | 819 | ||
760 | local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + | 820 | local->int_scan_req = kzalloc(sizeof(*local->int_scan_req) + |
@@ -778,19 +838,13 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
778 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); | 838 | hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); |
779 | hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR); | 839 | hw->wiphy->software_iftypes |= BIT(NL80211_IFTYPE_MONITOR); |
780 | 840 | ||
781 | /* | 841 | /* mac80211 doesn't support more than one IBSS interface right now */ |
782 | * mac80211 doesn't support more than 1 channel, and also not more | ||
783 | * than one IBSS interface | ||
784 | */ | ||
785 | for (i = 0; i < hw->wiphy->n_iface_combinations; i++) { | 842 | for (i = 0; i < hw->wiphy->n_iface_combinations; i++) { |
786 | const struct ieee80211_iface_combination *c; | 843 | const struct ieee80211_iface_combination *c; |
787 | int j; | 844 | int j; |
788 | 845 | ||
789 | c = &hw->wiphy->iface_combinations[i]; | 846 | c = &hw->wiphy->iface_combinations[i]; |
790 | 847 | ||
791 | if (c->num_different_channels > 1) | ||
792 | return -EINVAL; | ||
793 | |||
794 | for (j = 0; j < c->n_limits; j++) | 848 | for (j = 0; j < c->n_limits; j++) |
795 | if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && | 849 | if ((c->limits[j].types & BIT(NL80211_IFTYPE_ADHOC)) && |
796 | c->limits[j].max > 1) | 850 | c->limits[j].max > 1) |
@@ -832,7 +886,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
832 | 886 | ||
833 | if (supp_vht) | 887 | if (supp_vht) |
834 | local->scan_ies_len += | 888 | local->scan_ies_len += |
835 | 2 + sizeof(struct ieee80211_vht_capabilities); | 889 | 2 + sizeof(struct ieee80211_vht_cap); |
836 | 890 | ||
837 | if (!local->ops->hw_scan) { | 891 | if (!local->ops->hw_scan) { |
838 | /* For hw_scan, driver needs to set these up. */ | 892 | /* For hw_scan, driver needs to set these up. */ |
@@ -871,8 +925,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
871 | local->hw.wiphy->cipher_suites, | 925 | local->hw.wiphy->cipher_suites, |
872 | sizeof(u32) * local->hw.wiphy->n_cipher_suites, | 926 | sizeof(u32) * local->hw.wiphy->n_cipher_suites, |
873 | GFP_KERNEL); | 927 | GFP_KERNEL); |
874 | if (!suites) | 928 | if (!suites) { |
875 | return -ENOMEM; | 929 | result = -ENOMEM; |
930 | goto fail_wiphy_register; | ||
931 | } | ||
876 | for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) { | 932 | for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) { |
877 | u32 suite = local->hw.wiphy->cipher_suites[r]; | 933 | u32 suite = local->hw.wiphy->cipher_suites[r]; |
878 | if (suite == WLAN_CIPHER_SUITE_WEP40 || | 934 | if (suite == WLAN_CIPHER_SUITE_WEP40 || |
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index ff0296c7bab8..a350cab4b339 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -97,7 +97,7 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, | |||
97 | (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) | 97 | (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) |
98 | goto mismatch; | 98 | goto mismatch; |
99 | 99 | ||
100 | ieee80211_sta_get_rates(local, ie, local->oper_channel->band, | 100 | ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata), |
101 | &basic_rates); | 101 | &basic_rates); |
102 | 102 | ||
103 | if (sdata->vif.bss_conf.basic_rates != basic_rates) | 103 | if (sdata->vif.bss_conf.basic_rates != basic_rates) |
@@ -264,7 +264,7 @@ mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) | |||
264 | /* Authentication Protocol identifier */ | 264 | /* Authentication Protocol identifier */ |
265 | *pos++ = ifmsh->mesh_auth_id; | 265 | *pos++ = ifmsh->mesh_auth_id; |
266 | /* Mesh Formation Info - number of neighbors */ | 266 | /* Mesh Formation Info - number of neighbors */ |
267 | neighbors = atomic_read(&ifmsh->mshstats.estab_plinks); | 267 | neighbors = atomic_read(&ifmsh->estab_plinks); |
268 | /* Number of neighbor mesh STAs or 15 whichever is smaller */ | 268 | /* Number of neighbor mesh STAs or 15 whichever is smaller */ |
269 | neighbors = (neighbors > 15) ? 15 : neighbors; | 269 | neighbors = (neighbors > 15) ? 15 : neighbors; |
270 | *pos++ = neighbors << 1; | 270 | *pos++ = neighbors << 1; |
@@ -355,12 +355,22 @@ int mesh_add_ds_params_ie(struct sk_buff *skb, | |||
355 | { | 355 | { |
356 | struct ieee80211_local *local = sdata->local; | 356 | struct ieee80211_local *local = sdata->local; |
357 | struct ieee80211_supported_band *sband; | 357 | struct ieee80211_supported_band *sband; |
358 | struct ieee80211_channel *chan = local->oper_channel; | 358 | struct ieee80211_chanctx_conf *chanctx_conf; |
359 | struct ieee80211_channel *chan; | ||
359 | u8 *pos; | 360 | u8 *pos; |
360 | 361 | ||
361 | if (skb_tailroom(skb) < 3) | 362 | if (skb_tailroom(skb) < 3) |
362 | return -ENOMEM; | 363 | return -ENOMEM; |
363 | 364 | ||
365 | rcu_read_lock(); | ||
366 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
367 | if (WARN_ON(!chanctx_conf)) { | ||
368 | rcu_read_unlock(); | ||
369 | return -EINVAL; | ||
370 | } | ||
371 | chan = chanctx_conf->channel; | ||
372 | rcu_read_unlock(); | ||
373 | |||
364 | sband = local->hw.wiphy->bands[chan->band]; | 374 | sband = local->hw.wiphy->bands[chan->band]; |
365 | if (sband->band == IEEE80211_BAND_2GHZ) { | 375 | if (sband->band == IEEE80211_BAND_2GHZ) { |
366 | pos = skb_put(skb, 2 + 1); | 376 | pos = skb_put(skb, 2 + 1); |
@@ -376,10 +386,11 @@ int mesh_add_ht_cap_ie(struct sk_buff *skb, | |||
376 | struct ieee80211_sub_if_data *sdata) | 386 | struct ieee80211_sub_if_data *sdata) |
377 | { | 387 | { |
378 | struct ieee80211_local *local = sdata->local; | 388 | struct ieee80211_local *local = sdata->local; |
389 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
379 | struct ieee80211_supported_band *sband; | 390 | struct ieee80211_supported_band *sband; |
380 | u8 *pos; | 391 | u8 *pos; |
381 | 392 | ||
382 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 393 | sband = local->hw.wiphy->bands[band]; |
383 | if (!sband->ht_cap.ht_supported || | 394 | if (!sband->ht_cap.ht_supported || |
384 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) | 395 | sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) |
385 | return 0; | 396 | return 0; |
@@ -397,14 +408,26 @@ int mesh_add_ht_oper_ie(struct sk_buff *skb, | |||
397 | struct ieee80211_sub_if_data *sdata) | 408 | struct ieee80211_sub_if_data *sdata) |
398 | { | 409 | { |
399 | struct ieee80211_local *local = sdata->local; | 410 | struct ieee80211_local *local = sdata->local; |
400 | struct ieee80211_channel *channel = local->oper_channel; | 411 | struct ieee80211_chanctx_conf *chanctx_conf; |
412 | struct ieee80211_channel *channel; | ||
401 | enum nl80211_channel_type channel_type = | 413 | enum nl80211_channel_type channel_type = |
402 | sdata->vif.bss_conf.channel_type; | 414 | sdata->vif.bss_conf.channel_type; |
403 | struct ieee80211_supported_band *sband = | 415 | struct ieee80211_supported_band *sband; |
404 | local->hw.wiphy->bands[channel->band]; | 416 | struct ieee80211_sta_ht_cap *ht_cap; |
405 | struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; | ||
406 | u8 *pos; | 417 | u8 *pos; |
407 | 418 | ||
419 | rcu_read_lock(); | ||
420 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
421 | if (WARN_ON(!chanctx_conf)) { | ||
422 | rcu_read_unlock(); | ||
423 | return -EINVAL; | ||
424 | } | ||
425 | channel = chanctx_conf->channel; | ||
426 | rcu_read_unlock(); | ||
427 | |||
428 | sband = local->hw.wiphy->bands[channel->band]; | ||
429 | ht_cap = &sband->ht_cap; | ||
430 | |||
408 | if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) | 431 | if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) |
409 | return 0; | 432 | return 0; |
410 | 433 | ||
@@ -610,7 +633,7 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata) | |||
610 | sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL; | 633 | sdata->vif.bss_conf.beacon_int = MESH_DEFAULT_BEACON_INTERVAL; |
611 | sdata->vif.bss_conf.basic_rates = | 634 | sdata->vif.bss_conf.basic_rates = |
612 | ieee80211_mandatory_rates(sdata->local, | 635 | ieee80211_mandatory_rates(sdata->local, |
613 | sdata->local->oper_channel->band); | 636 | ieee80211_get_sdata_band(sdata)); |
614 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | | 637 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON | |
615 | BSS_CHANGED_BEACON_ENABLED | | 638 | BSS_CHANGED_BEACON_ENABLED | |
616 | BSS_CHANGED_HT | | 639 | BSS_CHANGED_HT | |
@@ -680,8 +703,10 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
680 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, | 703 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
681 | &elems); | 704 | &elems); |
682 | 705 | ||
683 | /* ignore beacons from secure mesh peers if our security is off */ | 706 | /* ignore non-mesh or secure / unsecure mismatch */ |
684 | if (elems.rsn_len && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) | 707 | if ((!elems.mesh_id || !elems.mesh_config) || |
708 | (elems.rsn && sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) || | ||
709 | (!elems.rsn && sdata->u.mesh.security != IEEE80211_MESH_SEC_NONE)) | ||
685 | return; | 710 | return; |
686 | 711 | ||
687 | if (elems.ds_params && elems.ds_params_len == 1) | 712 | if (elems.ds_params && elems.ds_params_len == 1) |
@@ -694,8 +719,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | |||
694 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) | 719 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) |
695 | return; | 720 | return; |
696 | 721 | ||
697 | if (elems.mesh_id && elems.mesh_config && | 722 | if (mesh_matches_local(sdata, &elems)) |
698 | mesh_matches_local(sdata, &elems)) | ||
699 | mesh_neighbour_update(sdata, mgmt->sa, &elems); | 723 | mesh_neighbour_update(sdata, mgmt->sa, &elems); |
700 | 724 | ||
701 | if (ifmsh->sync_ops) | 725 | if (ifmsh->sync_ops) |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 25d0f17dec71..9285f3f67e66 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -256,7 +256,7 @@ void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); | |||
256 | void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); | 256 | void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); |
257 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); | 257 | void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); |
258 | void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh); | 258 | void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh); |
259 | struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method); | 259 | const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method); |
260 | 260 | ||
261 | /* Mesh paths */ | 261 | /* Mesh paths */ |
262 | int mesh_nexthop_lookup(struct sk_buff *skb, | 262 | int mesh_nexthop_lookup(struct sk_buff *skb, |
@@ -324,7 +324,7 @@ extern int mesh_allocated; | |||
324 | static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata) | 324 | static inline int mesh_plink_free_count(struct ieee80211_sub_if_data *sdata) |
325 | { | 325 | { |
326 | return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks - | 326 | return sdata->u.mesh.mshcfg.dot11MeshMaxPeerLinks - |
327 | atomic_read(&sdata->u.mesh.mshstats.estab_plinks); | 327 | atomic_read(&sdata->u.mesh.estab_plinks); |
328 | } | 328 | } |
329 | 329 | ||
330 | static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata) | 330 | static inline bool mesh_plink_availables(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 3ab34d816897..234fe755968b 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -50,14 +50,14 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, | |||
50 | static inline | 50 | static inline |
51 | u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata) | 51 | u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata) |
52 | { | 52 | { |
53 | atomic_inc(&sdata->u.mesh.mshstats.estab_plinks); | 53 | atomic_inc(&sdata->u.mesh.estab_plinks); |
54 | return mesh_accept_plinks_update(sdata); | 54 | return mesh_accept_plinks_update(sdata); |
55 | } | 55 | } |
56 | 56 | ||
57 | static inline | 57 | static inline |
58 | u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata) | 58 | u32 mesh_plink_dec_estab_count(struct ieee80211_sub_if_data *sdata) |
59 | { | 59 | { |
60 | atomic_dec(&sdata->u.mesh.mshstats.estab_plinks); | 60 | atomic_dec(&sdata->u.mesh.estab_plinks); |
61 | return mesh_accept_plinks_update(sdata); | 61 | return mesh_accept_plinks_update(sdata); |
62 | } | 62 | } |
63 | 63 | ||
@@ -252,6 +252,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, | |||
252 | mgmt->u.action.u.self_prot.action_code = action; | 252 | mgmt->u.action.u.self_prot.action_code = action; |
253 | 253 | ||
254 | if (action != WLAN_SP_MESH_PEERING_CLOSE) { | 254 | if (action != WLAN_SP_MESH_PEERING_CLOSE) { |
255 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); | ||
256 | |||
255 | /* capability info */ | 257 | /* capability info */ |
256 | pos = skb_put(skb, 2); | 258 | pos = skb_put(skb, 2); |
257 | memset(pos, 0, 2); | 259 | memset(pos, 0, 2); |
@@ -260,10 +262,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, | |||
260 | pos = skb_put(skb, 2); | 262 | pos = skb_put(skb, 2); |
261 | memcpy(pos + 2, &plid, 2); | 263 | memcpy(pos + 2, &plid, 2); |
262 | } | 264 | } |
263 | if (ieee80211_add_srates_ie(sdata, skb, true, | 265 | if (ieee80211_add_srates_ie(sdata, skb, true, band) || |
264 | local->oper_channel->band) || | 266 | ieee80211_add_ext_srates_ie(sdata, skb, true, band) || |
265 | ieee80211_add_ext_srates_ie(sdata, skb, true, | ||
266 | local->oper_channel->band) || | ||
267 | mesh_add_rsn_ie(skb, sdata) || | 267 | mesh_add_rsn_ie(skb, sdata) || |
268 | mesh_add_meshid_ie(skb, sdata) || | 268 | mesh_add_meshid_ie(skb, sdata) || |
269 | mesh_add_meshconf_ie(skb, sdata)) | 269 | mesh_add_meshconf_ie(skb, sdata)) |
@@ -343,7 +343,7 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, | |||
343 | struct ieee802_11_elems *elems) | 343 | struct ieee802_11_elems *elems) |
344 | { | 344 | { |
345 | struct ieee80211_local *local = sdata->local; | 345 | struct ieee80211_local *local = sdata->local; |
346 | enum ieee80211_band band = local->oper_channel->band; | 346 | enum ieee80211_band band = ieee80211_get_sdata_band(sdata); |
347 | struct ieee80211_supported_band *sband; | 347 | struct ieee80211_supported_band *sband; |
348 | u32 rates, basic_rates = 0; | 348 | u32 rates, basic_rates = 0; |
349 | struct sta_info *sta; | 349 | struct sta_info *sta; |
diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c index a16b7b4b1e02..407c8705e10d 100644 --- a/net/mac80211/mesh_sync.c +++ b/net/mac80211/mesh_sync.c | |||
@@ -234,49 +234,7 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata) | |||
234 | spin_unlock_bh(&ifmsh->sync_offset_lock); | 234 | spin_unlock_bh(&ifmsh->sync_offset_lock); |
235 | } | 235 | } |
236 | 236 | ||
237 | static const u8 *mesh_get_vendor_oui(struct ieee80211_sub_if_data *sdata) | 237 | static const struct sync_method sync_methods[] = { |
238 | { | ||
239 | struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; | ||
240 | u8 offset; | ||
241 | |||
242 | if (!ifmsh->ie || !ifmsh->ie_len) | ||
243 | return NULL; | ||
244 | |||
245 | offset = ieee80211_ie_split_vendor(ifmsh->ie, | ||
246 | ifmsh->ie_len, 0); | ||
247 | |||
248 | if (!offset) | ||
249 | return NULL; | ||
250 | |||
251 | return ifmsh->ie + offset + 2; | ||
252 | } | ||
253 | |||
254 | static void mesh_sync_vendor_rx_bcn_presp(struct ieee80211_sub_if_data *sdata, | ||
255 | u16 stype, | ||
256 | struct ieee80211_mgmt *mgmt, | ||
257 | struct ieee802_11_elems *elems, | ||
258 | struct ieee80211_rx_status *rx_status) | ||
259 | { | ||
260 | const u8 *oui; | ||
261 | |||
262 | WARN_ON(sdata->u.mesh.mesh_sp_id != IEEE80211_SYNC_METHOD_VENDOR); | ||
263 | msync_dbg(sdata, "called mesh_sync_vendor_rx_bcn_presp\n"); | ||
264 | oui = mesh_get_vendor_oui(sdata); | ||
265 | /* here you would implement the vendor offset tracking for this oui */ | ||
266 | } | ||
267 | |||
268 | static void mesh_sync_vendor_adjust_tbtt(struct ieee80211_sub_if_data *sdata) | ||
269 | { | ||
270 | const u8 *oui; | ||
271 | |||
272 | WARN_ON(sdata->u.mesh.mesh_sp_id != IEEE80211_SYNC_METHOD_VENDOR); | ||
273 | msync_dbg(sdata, "called mesh_sync_vendor_adjust_tbtt\n"); | ||
274 | oui = mesh_get_vendor_oui(sdata); | ||
275 | /* here you would implement the vendor tsf adjustment for this oui */ | ||
276 | } | ||
277 | |||
278 | /* global variable */ | ||
279 | static struct sync_method sync_methods[] = { | ||
280 | { | 238 | { |
281 | .method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET, | 239 | .method = IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET, |
282 | .ops = { | 240 | .ops = { |
@@ -284,18 +242,11 @@ static struct sync_method sync_methods[] = { | |||
284 | .adjust_tbtt = &mesh_sync_offset_adjust_tbtt, | 242 | .adjust_tbtt = &mesh_sync_offset_adjust_tbtt, |
285 | } | 243 | } |
286 | }, | 244 | }, |
287 | { | ||
288 | .method = IEEE80211_SYNC_METHOD_VENDOR, | ||
289 | .ops = { | ||
290 | .rx_bcn_presp = &mesh_sync_vendor_rx_bcn_presp, | ||
291 | .adjust_tbtt = &mesh_sync_vendor_adjust_tbtt, | ||
292 | } | ||
293 | }, | ||
294 | }; | 245 | }; |
295 | 246 | ||
296 | struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) | 247 | const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) |
297 | { | 248 | { |
298 | struct ieee80211_mesh_sync_ops *ops = NULL; | 249 | const struct ieee80211_mesh_sync_ops *ops = NULL; |
299 | u8 i; | 250 | u8 i; |
300 | 251 | ||
301 | for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { | 252 | for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index e714ed8bb198..61614461e089 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -178,20 +178,30 @@ static u32 ieee80211_config_ht_tx(struct ieee80211_sub_if_data *sdata, | |||
178 | { | 178 | { |
179 | struct ieee80211_local *local = sdata->local; | 179 | struct ieee80211_local *local = sdata->local; |
180 | struct ieee80211_supported_band *sband; | 180 | struct ieee80211_supported_band *sband; |
181 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
182 | struct ieee80211_channel *chan; | ||
181 | struct sta_info *sta; | 183 | struct sta_info *sta; |
182 | u32 changed = 0; | 184 | u32 changed = 0; |
183 | u16 ht_opmode; | 185 | u16 ht_opmode; |
184 | bool disable_40 = false; | 186 | bool disable_40 = false; |
185 | 187 | ||
186 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 188 | rcu_read_lock(); |
189 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
190 | if (WARN_ON(!chanctx_conf)) { | ||
191 | rcu_read_unlock(); | ||
192 | return 0; | ||
193 | } | ||
194 | chan = chanctx_conf->channel; | ||
195 | rcu_read_unlock(); | ||
196 | sband = local->hw.wiphy->bands[chan->band]; | ||
187 | 197 | ||
188 | switch (sdata->vif.bss_conf.channel_type) { | 198 | switch (sdata->vif.bss_conf.channel_type) { |
189 | case NL80211_CHAN_HT40PLUS: | 199 | case NL80211_CHAN_HT40PLUS: |
190 | if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40PLUS) | 200 | if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) |
191 | disable_40 = true; | 201 | disable_40 = true; |
192 | break; | 202 | break; |
193 | case NL80211_CHAN_HT40MINUS: | 203 | case NL80211_CHAN_HT40MINUS: |
194 | if (local->oper_channel->flags & IEEE80211_CHAN_NO_HT40MINUS) | 204 | if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) |
195 | disable_40 = true; | 205 | disable_40 = true; |
196 | break; | 206 | break; |
197 | default: | 207 | default: |
@@ -343,7 +353,7 @@ static void ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, | |||
343 | cap = vht_cap.cap; | 353 | cap = vht_cap.cap; |
344 | 354 | ||
345 | /* reserve and fill IE */ | 355 | /* reserve and fill IE */ |
346 | pos = skb_put(skb, sizeof(struct ieee80211_vht_capabilities) + 2); | 356 | pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2); |
347 | ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); | 357 | ieee80211_ie_build_vht_cap(pos, &vht_cap, cap); |
348 | } | 358 | } |
349 | 359 | ||
@@ -359,11 +369,21 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
359 | int i, count, rates_len, supp_rates_len; | 369 | int i, count, rates_len, supp_rates_len; |
360 | u16 capab; | 370 | u16 capab; |
361 | struct ieee80211_supported_band *sband; | 371 | struct ieee80211_supported_band *sband; |
372 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
373 | struct ieee80211_channel *chan; | ||
362 | u32 rates = 0; | 374 | u32 rates = 0; |
363 | 375 | ||
364 | lockdep_assert_held(&ifmgd->mtx); | 376 | lockdep_assert_held(&ifmgd->mtx); |
365 | 377 | ||
366 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 378 | rcu_read_lock(); |
379 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
380 | if (WARN_ON(!chanctx_conf)) { | ||
381 | rcu_read_unlock(); | ||
382 | return; | ||
383 | } | ||
384 | chan = chanctx_conf->channel; | ||
385 | rcu_read_unlock(); | ||
386 | sband = local->hw.wiphy->bands[chan->band]; | ||
367 | 387 | ||
368 | if (assoc_data->supp_rates_len) { | 388 | if (assoc_data->supp_rates_len) { |
369 | /* | 389 | /* |
@@ -392,7 +412,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
392 | 4 + /* power capability */ | 412 | 4 + /* power capability */ |
393 | 2 + 2 * sband->n_channels + /* supported channels */ | 413 | 2 + 2 * sband->n_channels + /* supported channels */ |
394 | 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ | 414 | 2 + sizeof(struct ieee80211_ht_cap) + /* HT */ |
395 | 2 + sizeof(struct ieee80211_vht_capabilities) + /* VHT */ | 415 | 2 + sizeof(struct ieee80211_vht_cap) + /* VHT */ |
396 | assoc_data->ie_len + /* extra IEs */ | 416 | assoc_data->ie_len + /* extra IEs */ |
397 | 9, /* WMM */ | 417 | 9, /* WMM */ |
398 | GFP_KERNEL); | 418 | GFP_KERNEL); |
@@ -485,7 +505,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
485 | *pos++ = WLAN_EID_PWR_CAPABILITY; | 505 | *pos++ = WLAN_EID_PWR_CAPABILITY; |
486 | *pos++ = 2; | 506 | *pos++ = 2; |
487 | *pos++ = 0; /* min tx power */ | 507 | *pos++ = 0; /* min tx power */ |
488 | *pos++ = local->oper_channel->max_power; /* max tx power */ | 508 | *pos++ = chan->max_power; /* max tx power */ |
489 | 509 | ||
490 | /* 2. supported channels */ | 510 | /* 2. supported channels */ |
491 | /* TODO: get this in reg domain format */ | 511 | /* TODO: get this in reg domain format */ |
@@ -523,7 +543,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) | |||
523 | 543 | ||
524 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) | 544 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
525 | ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, | 545 | ieee80211_add_ht_ie(sdata, skb, assoc_data->ap_ht_param, |
526 | sband, local->oper_channel, ifmgd->ap_smps); | 546 | sband, chan, sdata->smps_mode); |
527 | 547 | ||
528 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) | 548 | if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) |
529 | ieee80211_add_vht_ie(sdata, skb, sband); | 549 | ieee80211_add_vht_ie(sdata, skb, sband); |
@@ -657,18 +677,18 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
657 | if (!ifmgd->associated) | 677 | if (!ifmgd->associated) |
658 | goto out; | 678 | goto out; |
659 | 679 | ||
660 | sdata->local->oper_channel = sdata->local->csa_channel; | 680 | sdata->local->_oper_channel = sdata->local->csa_channel; |
661 | if (!sdata->local->ops->channel_switch) { | 681 | if (!sdata->local->ops->channel_switch) { |
662 | /* call "hw_config" only if doing sw channel switch */ | 682 | /* call "hw_config" only if doing sw channel switch */ |
663 | ieee80211_hw_config(sdata->local, | 683 | ieee80211_hw_config(sdata->local, |
664 | IEEE80211_CONF_CHANGE_CHANNEL); | 684 | IEEE80211_CONF_CHANGE_CHANNEL); |
665 | } else { | 685 | } else { |
666 | /* update the device channel directly */ | 686 | /* update the device channel directly */ |
667 | sdata->local->hw.conf.channel = sdata->local->oper_channel; | 687 | sdata->local->hw.conf.channel = sdata->local->_oper_channel; |
668 | } | 688 | } |
669 | 689 | ||
670 | /* XXX: shouldn't really modify cfg80211-owned data! */ | 690 | /* XXX: shouldn't really modify cfg80211-owned data! */ |
671 | ifmgd->associated->channel = sdata->local->oper_channel; | 691 | ifmgd->associated->channel = sdata->local->_oper_channel; |
672 | 692 | ||
673 | /* XXX: wait for a beacon first? */ | 693 | /* XXX: wait for a beacon first? */ |
674 | ieee80211_wake_queues_by_reason(&sdata->local->hw, | 694 | ieee80211_wake_queues_by_reason(&sdata->local->hw, |
@@ -680,11 +700,8 @@ static void ieee80211_chswitch_work(struct work_struct *work) | |||
680 | 700 | ||
681 | void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success) | 701 | void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success) |
682 | { | 702 | { |
683 | struct ieee80211_sub_if_data *sdata; | 703 | struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); |
684 | struct ieee80211_if_managed *ifmgd; | 704 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
685 | |||
686 | sdata = vif_to_sdata(vif); | ||
687 | ifmgd = &sdata->u.mgd; | ||
688 | 705 | ||
689 | trace_api_chswitch_done(sdata, success); | 706 | trace_api_chswitch_done(sdata, success); |
690 | if (!success) { | 707 | if (!success) { |
@@ -723,6 +740,7 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
723 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 740 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
724 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num, | 741 | int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num, |
725 | cbss->channel->band); | 742 | cbss->channel->band); |
743 | struct ieee80211_chanctx *chanctx; | ||
726 | 744 | ||
727 | ASSERT_MGD_MTX(ifmgd); | 745 | ASSERT_MGD_MTX(ifmgd); |
728 | 746 | ||
@@ -748,10 +766,34 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
748 | return; | 766 | return; |
749 | } | 767 | } |
750 | 768 | ||
751 | sdata->local->csa_channel = new_ch; | ||
752 | |||
753 | ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; | 769 | ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; |
754 | 770 | ||
771 | if (sdata->local->use_chanctx) { | ||
772 | sdata_info(sdata, | ||
773 | "not handling channel switch with channel contexts\n"); | ||
774 | ieee80211_queue_work(&sdata->local->hw, | ||
775 | &ifmgd->csa_connection_drop_work); | ||
776 | } | ||
777 | |||
778 | mutex_lock(&sdata->local->chanctx_mtx); | ||
779 | if (WARN_ON(!rcu_access_pointer(sdata->vif.chanctx_conf))) { | ||
780 | mutex_unlock(&sdata->local->chanctx_mtx); | ||
781 | return; | ||
782 | } | ||
783 | chanctx = container_of(rcu_access_pointer(sdata->vif.chanctx_conf), | ||
784 | struct ieee80211_chanctx, conf); | ||
785 | if (chanctx->refcount > 1) { | ||
786 | sdata_info(sdata, | ||
787 | "channel switch with multiple interfaces on the same channel, disconnecting\n"); | ||
788 | ieee80211_queue_work(&sdata->local->hw, | ||
789 | &ifmgd->csa_connection_drop_work); | ||
790 | mutex_unlock(&sdata->local->chanctx_mtx); | ||
791 | return; | ||
792 | } | ||
793 | mutex_unlock(&sdata->local->chanctx_mtx); | ||
794 | |||
795 | sdata->local->csa_channel = new_ch; | ||
796 | |||
755 | if (sw_elem->mode) | 797 | if (sw_elem->mode) |
756 | ieee80211_stop_queues_by_reason(&sdata->local->hw, | 798 | ieee80211_stop_queues_by_reason(&sdata->local->hw, |
757 | IEEE80211_QUEUE_STOP_REASON_CSA); | 799 | IEEE80211_QUEUE_STOP_REASON_CSA); |
@@ -778,10 +820,10 @@ void ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata, | |||
778 | cbss->beacon_interval)); | 820 | cbss->beacon_interval)); |
779 | } | 821 | } |
780 | 822 | ||
781 | static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, | 823 | static u32 ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, |
782 | struct ieee80211_channel *channel, | 824 | struct ieee80211_channel *channel, |
783 | const u8 *country_ie, u8 country_ie_len, | 825 | const u8 *country_ie, u8 country_ie_len, |
784 | const u8 *pwr_constr_elem) | 826 | const u8 *pwr_constr_elem) |
785 | { | 827 | { |
786 | struct ieee80211_country_ie_triplet *triplet; | 828 | struct ieee80211_country_ie_triplet *triplet; |
787 | int chan = ieee80211_frequency_to_channel(channel->center_freq); | 829 | int chan = ieee80211_frequency_to_channel(channel->center_freq); |
@@ -790,7 +832,7 @@ static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, | |||
790 | 832 | ||
791 | /* Invalid IE */ | 833 | /* Invalid IE */ |
792 | if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) | 834 | if (country_ie_len % 2 || country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) |
793 | return; | 835 | return 0; |
794 | 836 | ||
795 | triplet = (void *)(country_ie + 3); | 837 | triplet = (void *)(country_ie + 3); |
796 | country_ie_len -= 3; | 838 | country_ie_len -= 3; |
@@ -831,19 +873,21 @@ static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, | |||
831 | } | 873 | } |
832 | 874 | ||
833 | if (!have_chan_pwr) | 875 | if (!have_chan_pwr) |
834 | return; | 876 | return 0; |
835 | 877 | ||
836 | new_ap_level = max_t(int, 0, chan_pwr - *pwr_constr_elem); | 878 | new_ap_level = max_t(int, 0, chan_pwr - *pwr_constr_elem); |
837 | 879 | ||
838 | if (sdata->local->ap_power_level == new_ap_level) | 880 | if (sdata->ap_power_level == new_ap_level) |
839 | return; | 881 | return 0; |
840 | 882 | ||
841 | sdata_info(sdata, | 883 | sdata_info(sdata, |
842 | "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", | 884 | "Limiting TX power to %d (%d - %d) dBm as advertised by %pM\n", |
843 | new_ap_level, chan_pwr, *pwr_constr_elem, | 885 | new_ap_level, chan_pwr, *pwr_constr_elem, |
844 | sdata->u.mgd.bssid); | 886 | sdata->u.mgd.bssid); |
845 | sdata->local->ap_power_level = new_ap_level; | 887 | sdata->ap_power_level = new_ap_level; |
846 | ieee80211_hw_config(sdata->local, 0); | 888 | if (__ieee80211_recalc_txpower(sdata)) |
889 | return BSS_CHANGED_TXPOWER; | ||
890 | return 0; | ||
847 | } | 891 | } |
848 | 892 | ||
849 | void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif) | 893 | void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif) |
@@ -1280,7 +1324,7 @@ static u32 ieee80211_handle_bss_capability(struct ieee80211_sub_if_data *sdata, | |||
1280 | } | 1324 | } |
1281 | 1325 | ||
1282 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); | 1326 | use_short_slot = !!(capab & WLAN_CAPABILITY_SHORT_SLOT_TIME); |
1283 | if (sdata->local->oper_channel->band == IEEE80211_BAND_5GHZ) | 1327 | if (ieee80211_get_sdata_band(sdata) == IEEE80211_BAND_5GHZ) |
1284 | use_short_slot = true; | 1328 | use_short_slot = true; |
1285 | 1329 | ||
1286 | if (use_protection != bss_conf->use_cts_prot) { | 1330 | if (use_protection != bss_conf->use_cts_prot) { |
@@ -1321,6 +1365,22 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
1321 | 1365 | ||
1322 | sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE; | 1366 | sdata->u.mgd.flags |= IEEE80211_STA_RESET_SIGNAL_AVE; |
1323 | 1367 | ||
1368 | if (sdata->vif.p2p) { | ||
1369 | u8 noa[2]; | ||
1370 | int ret; | ||
1371 | |||
1372 | ret = cfg80211_get_p2p_attr(cbss->information_elements, | ||
1373 | cbss->len_information_elements, | ||
1374 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, | ||
1375 | noa, sizeof(noa)); | ||
1376 | if (ret >= 2) { | ||
1377 | bss_conf->p2p_oppps = noa[1] & 0x80; | ||
1378 | bss_conf->p2p_ctwindow = noa[1] & 0x7f; | ||
1379 | bss_info_changed |= BSS_CHANGED_P2P_PS; | ||
1380 | sdata->u.mgd.p2p_noa_index = noa[0]; | ||
1381 | } | ||
1382 | } | ||
1383 | |||
1324 | /* just to be sure */ | 1384 | /* just to be sure */ |
1325 | ieee80211_stop_poll(sdata); | 1385 | ieee80211_stop_poll(sdata); |
1326 | 1386 | ||
@@ -1350,7 +1410,7 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, | |||
1350 | ieee80211_recalc_ps(local, -1); | 1410 | ieee80211_recalc_ps(local, -1); |
1351 | mutex_unlock(&local->iflist_mtx); | 1411 | mutex_unlock(&local->iflist_mtx); |
1352 | 1412 | ||
1353 | ieee80211_recalc_smps(local); | 1413 | ieee80211_recalc_smps(sdata); |
1354 | ieee80211_recalc_ps_vif(sdata); | 1414 | ieee80211_recalc_ps_vif(sdata); |
1355 | 1415 | ||
1356 | netif_tx_start_all_queues(sdata->dev); | 1416 | netif_tx_start_all_queues(sdata->dev); |
@@ -1443,11 +1503,14 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1443 | changed |= BSS_CHANGED_ASSOC; | 1503 | changed |= BSS_CHANGED_ASSOC; |
1444 | sdata->vif.bss_conf.assoc = false; | 1504 | sdata->vif.bss_conf.assoc = false; |
1445 | 1505 | ||
1506 | sdata->vif.bss_conf.p2p_ctwindow = 0; | ||
1507 | sdata->vif.bss_conf.p2p_oppps = false; | ||
1508 | |||
1446 | /* on the next assoc, re-program HT parameters */ | 1509 | /* on the next assoc, re-program HT parameters */ |
1447 | memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); | 1510 | memset(&ifmgd->ht_capa, 0, sizeof(ifmgd->ht_capa)); |
1448 | memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); | 1511 | memset(&ifmgd->ht_capa_mask, 0, sizeof(ifmgd->ht_capa_mask)); |
1449 | 1512 | ||
1450 | local->ap_power_level = 0; | 1513 | sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL; |
1451 | 1514 | ||
1452 | del_timer_sync(&local->dynamic_ps_timer); | 1515 | del_timer_sync(&local->dynamic_ps_timer); |
1453 | cancel_work_sync(&local->dynamic_ps_enable_work); | 1516 | cancel_work_sync(&local->dynamic_ps_enable_work); |
@@ -1465,9 +1528,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, | |||
1465 | changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; | 1528 | changed |= BSS_CHANGED_BSSID | BSS_CHANGED_HT; |
1466 | ieee80211_bss_info_change_notify(sdata, changed); | 1529 | ieee80211_bss_info_change_notify(sdata, changed); |
1467 | 1530 | ||
1468 | /* channel(_type) changes are handled by ieee80211_hw_config */ | 1531 | ieee80211_vif_release_channel(sdata); |
1469 | WARN_ON(!ieee80211_set_channel_type(local, sdata, NL80211_CHAN_NO_HT)); | ||
1470 | ieee80211_hw_config(local, 0); | ||
1471 | 1532 | ||
1472 | /* disassociated - set to defaults now */ | 1533 | /* disassociated - set to defaults now */ |
1473 | ieee80211_set_wmm_default(sdata, false); | 1534 | ieee80211_set_wmm_default(sdata, false); |
@@ -1589,7 +1650,7 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) | |||
1589 | 1650 | ||
1590 | ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, | 1651 | ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, |
1591 | 0, (u32) -1, true, false, | 1652 | 0, (u32) -1, true, false, |
1592 | ifmgd->associated->channel); | 1653 | ifmgd->associated->channel, false); |
1593 | } | 1654 | } |
1594 | 1655 | ||
1595 | ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); | 1656 | ifmgd->probe_timeout = jiffies + msecs_to_jiffies(probe_wait_ms); |
@@ -1692,8 +1753,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, | |||
1692 | ssid_len = ssid[1]; | 1753 | ssid_len = ssid[1]; |
1693 | 1754 | ||
1694 | skb = ieee80211_build_probe_req(sdata, cbss->bssid, | 1755 | skb = ieee80211_build_probe_req(sdata, cbss->bssid, |
1695 | (u32) -1, | 1756 | (u32) -1, cbss->channel, |
1696 | sdata->local->oper_channel, | ||
1697 | ssid + 2, ssid_len, | 1757 | ssid + 2, ssid_len, |
1698 | NULL, 0, true); | 1758 | NULL, 0, true); |
1699 | 1759 | ||
@@ -1804,6 +1864,7 @@ static void ieee80211_destroy_auth_data(struct ieee80211_sub_if_data *sdata, | |||
1804 | 1864 | ||
1805 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); | 1865 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); |
1806 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); | 1866 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
1867 | ieee80211_vif_release_channel(sdata); | ||
1807 | } | 1868 | } |
1808 | 1869 | ||
1809 | cfg80211_put_bss(auth_data->bss); | 1870 | cfg80211_put_bss(auth_data->bss); |
@@ -1824,7 +1885,7 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, | |||
1824 | return; | 1885 | return; |
1825 | auth_data->expected_transaction = 4; | 1886 | auth_data->expected_transaction = 4; |
1826 | drv_mgd_prepare_tx(sdata->local, sdata); | 1887 | drv_mgd_prepare_tx(sdata->local, sdata); |
1827 | ieee80211_send_auth(sdata, 3, auth_data->algorithm, | 1888 | ieee80211_send_auth(sdata, 3, auth_data->algorithm, 0, |
1828 | elems.challenge - 2, elems.challenge_len + 2, | 1889 | elems.challenge - 2, elems.challenge_len + 2, |
1829 | auth_data->bss->bssid, auth_data->bss->bssid, | 1890 | auth_data->bss->bssid, auth_data->bss->bssid, |
1830 | auth_data->key, auth_data->key_len, | 1891 | auth_data->key, auth_data->key_len, |
@@ -1858,8 +1919,13 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | |||
1858 | status_code = le16_to_cpu(mgmt->u.auth.status_code); | 1919 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
1859 | 1920 | ||
1860 | if (auth_alg != ifmgd->auth_data->algorithm || | 1921 | if (auth_alg != ifmgd->auth_data->algorithm || |
1861 | auth_transaction != ifmgd->auth_data->expected_transaction) | 1922 | auth_transaction != ifmgd->auth_data->expected_transaction) { |
1923 | sdata_info(sdata, "%pM unexpected authentication state: alg %d (expected %d) transact %d (expected %d)\n", | ||
1924 | mgmt->sa, auth_alg, ifmgd->auth_data->algorithm, | ||
1925 | auth_transaction, | ||
1926 | ifmgd->auth_data->expected_transaction); | ||
1862 | return RX_MGMT_NONE; | 1927 | return RX_MGMT_NONE; |
1928 | } | ||
1863 | 1929 | ||
1864 | if (status_code != WLAN_STATUS_SUCCESS) { | 1930 | if (status_code != WLAN_STATUS_SUCCESS) { |
1865 | sdata_info(sdata, "%pM denied authentication (status %d)\n", | 1931 | sdata_info(sdata, "%pM denied authentication (status %d)\n", |
@@ -1872,6 +1938,7 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | |||
1872 | case WLAN_AUTH_OPEN: | 1938 | case WLAN_AUTH_OPEN: |
1873 | case WLAN_AUTH_LEAP: | 1939 | case WLAN_AUTH_LEAP: |
1874 | case WLAN_AUTH_FT: | 1940 | case WLAN_AUTH_FT: |
1941 | case WLAN_AUTH_SAE: | ||
1875 | break; | 1942 | break; |
1876 | case WLAN_AUTH_SHARED_KEY: | 1943 | case WLAN_AUTH_SHARED_KEY: |
1877 | if (ifmgd->auth_data->expected_transaction != 4) { | 1944 | if (ifmgd->auth_data->expected_transaction != 4) { |
@@ -1891,6 +1958,15 @@ ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, | |||
1891 | ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; | 1958 | ifmgd->auth_data->timeout = jiffies + IEEE80211_AUTH_WAIT_ASSOC; |
1892 | run_again(ifmgd, ifmgd->auth_data->timeout); | 1959 | run_again(ifmgd, ifmgd->auth_data->timeout); |
1893 | 1960 | ||
1961 | if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE && | ||
1962 | ifmgd->auth_data->expected_transaction != 2) { | ||
1963 | /* | ||
1964 | * Report auth frame to user space for processing since another | ||
1965 | * round of Authentication frames is still needed. | ||
1966 | */ | ||
1967 | return RX_MGMT_CFG80211_RX_AUTH; | ||
1968 | } | ||
1969 | |||
1894 | /* move station state to auth */ | 1970 | /* move station state to auth */ |
1895 | mutex_lock(&sdata->local->sta_mtx); | 1971 | mutex_lock(&sdata->local->sta_mtx); |
1896 | sta = sta_info_get(sdata, bssid); | 1972 | sta = sta_info_get(sdata, bssid); |
@@ -2030,6 +2106,7 @@ static void ieee80211_destroy_assoc_data(struct ieee80211_sub_if_data *sdata, | |||
2030 | 2106 | ||
2031 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); | 2107 | memset(sdata->u.mgd.bssid, 0, ETH_ALEN); |
2032 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); | 2108 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BSSID); |
2109 | ieee80211_vif_release_channel(sdata); | ||
2033 | } | 2110 | } |
2034 | 2111 | ||
2035 | kfree(assoc_data); | 2112 | kfree(assoc_data); |
@@ -2091,7 +2168,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, | |||
2091 | return false; | 2168 | return false; |
2092 | } | 2169 | } |
2093 | 2170 | ||
2094 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 2171 | sband = local->hw.wiphy->bands[ieee80211_get_sdata_band(sdata)]; |
2095 | 2172 | ||
2096 | if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) | 2173 | if (elems.ht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
2097 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, | 2174 | ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband, |
@@ -2100,6 +2177,11 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, | |||
2100 | sta->supports_40mhz = | 2177 | sta->supports_40mhz = |
2101 | sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; | 2178 | sta->sta.ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
2102 | 2179 | ||
2180 | if (elems.vht_cap_elem && !(ifmgd->flags & IEEE80211_STA_DISABLE_VHT)) | ||
2181 | ieee80211_vht_cap_ie_to_sta_vht_cap(sdata, sband, | ||
2182 | elems.vht_cap_elem, | ||
2183 | &sta->sta.vht_cap); | ||
2184 | |||
2103 | rate_control_rate_init(sta); | 2185 | rate_control_rate_init(sta); |
2104 | 2186 | ||
2105 | if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) | 2187 | if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) |
@@ -2369,8 +2451,10 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2369 | size_t baselen; | 2451 | size_t baselen; |
2370 | struct ieee802_11_elems elems; | 2452 | struct ieee802_11_elems elems; |
2371 | struct ieee80211_local *local = sdata->local; | 2453 | struct ieee80211_local *local = sdata->local; |
2454 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
2455 | struct ieee80211_channel *chan; | ||
2372 | u32 changed = 0; | 2456 | u32 changed = 0; |
2373 | bool erp_valid, directed_tim = false; | 2457 | bool erp_valid; |
2374 | u8 erp_value = 0; | 2458 | u8 erp_value = 0; |
2375 | u32 ncrc; | 2459 | u32 ncrc; |
2376 | u8 *bssid; | 2460 | u8 *bssid; |
@@ -2382,8 +2466,19 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2382 | if (baselen > len) | 2466 | if (baselen > len) |
2383 | return; | 2467 | return; |
2384 | 2468 | ||
2385 | if (rx_status->freq != local->oper_channel->center_freq) | 2469 | rcu_read_lock(); |
2470 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
2471 | if (!chanctx_conf) { | ||
2472 | rcu_read_unlock(); | ||
2386 | return; | 2473 | return; |
2474 | } | ||
2475 | |||
2476 | if (rx_status->freq != chanctx_conf->channel->center_freq) { | ||
2477 | rcu_read_unlock(); | ||
2478 | return; | ||
2479 | } | ||
2480 | chan = chanctx_conf->channel; | ||
2481 | rcu_read_unlock(); | ||
2387 | 2482 | ||
2388 | if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && | 2483 | if (ifmgd->assoc_data && !ifmgd->assoc_data->have_beacon && |
2389 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { | 2484 | ether_addr_equal(mgmt->bssid, ifmgd->assoc_data->bss->bssid)) { |
@@ -2490,11 +2585,10 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2490 | len - baselen, &elems, | 2585 | len - baselen, &elems, |
2491 | care_about_ies, ncrc); | 2586 | care_about_ies, ncrc); |
2492 | 2587 | ||
2493 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) | ||
2494 | directed_tim = ieee80211_check_tim(elems.tim, elems.tim_len, | ||
2495 | ifmgd->aid); | ||
2496 | |||
2497 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { | 2588 | if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) { |
2589 | bool directed_tim = ieee80211_check_tim(elems.tim, | ||
2590 | elems.tim_len, | ||
2591 | ifmgd->aid); | ||
2498 | if (directed_tim) { | 2592 | if (directed_tim) { |
2499 | if (local->hw.conf.dynamic_ps_timeout > 0) { | 2593 | if (local->hw.conf.dynamic_ps_timeout > 0) { |
2500 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { | 2594 | if (local->hw.conf.flags & IEEE80211_CONF_PS) { |
@@ -2519,6 +2613,27 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2519 | } | 2613 | } |
2520 | } | 2614 | } |
2521 | 2615 | ||
2616 | if (sdata->vif.p2p) { | ||
2617 | u8 noa[2]; | ||
2618 | int ret; | ||
2619 | |||
2620 | ret = cfg80211_get_p2p_attr(mgmt->u.beacon.variable, | ||
2621 | len - baselen, | ||
2622 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, | ||
2623 | noa, sizeof(noa)); | ||
2624 | if (ret >= 2 && sdata->u.mgd.p2p_noa_index != noa[0]) { | ||
2625 | bss_conf->p2p_oppps = noa[1] & 0x80; | ||
2626 | bss_conf->p2p_ctwindow = noa[1] & 0x7f; | ||
2627 | changed |= BSS_CHANGED_P2P_PS; | ||
2628 | sdata->u.mgd.p2p_noa_index = noa[0]; | ||
2629 | /* | ||
2630 | * make sure we update all information, the CRC | ||
2631 | * mechanism doesn't look at P2P attributes. | ||
2632 | */ | ||
2633 | ifmgd->beacon_crc_valid = false; | ||
2634 | } | ||
2635 | } | ||
2636 | |||
2522 | if (ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid) | 2637 | if (ncrc == ifmgd->beacon_crc && ifmgd->beacon_crc_valid) |
2523 | return; | 2638 | return; |
2524 | ifmgd->beacon_crc = ncrc; | 2639 | ifmgd->beacon_crc = ncrc; |
@@ -2543,22 +2658,17 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, | |||
2543 | 2658 | ||
2544 | 2659 | ||
2545 | if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param && | 2660 | if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param && |
2546 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) { | 2661 | !(ifmgd->flags & IEEE80211_STA_DISABLE_11N)) |
2547 | struct ieee80211_supported_band *sband; | ||
2548 | |||
2549 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | ||
2550 | |||
2551 | changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, | 2662 | changed |= ieee80211_config_ht_tx(sdata, elems.ht_operation, |
2552 | bssid, true); | 2663 | bssid, true); |
2553 | } | ||
2554 | 2664 | ||
2555 | if (elems.country_elem && elems.pwr_constr_elem && | 2665 | if (elems.country_elem && elems.pwr_constr_elem && |
2556 | mgmt->u.probe_resp.capab_info & | 2666 | mgmt->u.probe_resp.capab_info & |
2557 | cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT)) | 2667 | cpu_to_le16(WLAN_CAPABILITY_SPECTRUM_MGMT)) |
2558 | ieee80211_handle_pwr_constr(sdata, local->oper_channel, | 2668 | changed |= ieee80211_handle_pwr_constr(sdata, chan, |
2559 | elems.country_elem, | 2669 | elems.country_elem, |
2560 | elems.country_elem_len, | 2670 | elems.country_elem_len, |
2561 | elems.pwr_constr_elem); | 2671 | elems.pwr_constr_elem); |
2562 | 2672 | ||
2563 | ieee80211_bss_info_change_notify(sdata, changed); | 2673 | ieee80211_bss_info_change_notify(sdata, changed); |
2564 | } | 2674 | } |
@@ -2703,13 +2813,23 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) | |||
2703 | drv_mgd_prepare_tx(local, sdata); | 2813 | drv_mgd_prepare_tx(local, sdata); |
2704 | 2814 | ||
2705 | if (auth_data->bss->proberesp_ies) { | 2815 | if (auth_data->bss->proberesp_ies) { |
2816 | u16 trans = 1; | ||
2817 | u16 status = 0; | ||
2818 | |||
2706 | sdata_info(sdata, "send auth to %pM (try %d/%d)\n", | 2819 | sdata_info(sdata, "send auth to %pM (try %d/%d)\n", |
2707 | auth_data->bss->bssid, auth_data->tries, | 2820 | auth_data->bss->bssid, auth_data->tries, |
2708 | IEEE80211_AUTH_MAX_TRIES); | 2821 | IEEE80211_AUTH_MAX_TRIES); |
2709 | 2822 | ||
2710 | auth_data->expected_transaction = 2; | 2823 | auth_data->expected_transaction = 2; |
2711 | ieee80211_send_auth(sdata, 1, auth_data->algorithm, | 2824 | |
2712 | auth_data->ie, auth_data->ie_len, | 2825 | if (auth_data->algorithm == WLAN_AUTH_SAE) { |
2826 | trans = auth_data->sae_trans; | ||
2827 | status = auth_data->sae_status; | ||
2828 | auth_data->expected_transaction = trans; | ||
2829 | } | ||
2830 | |||
2831 | ieee80211_send_auth(sdata, trans, auth_data->algorithm, status, | ||
2832 | auth_data->data, auth_data->data_len, | ||
2713 | auth_data->bss->bssid, | 2833 | auth_data->bss->bssid, |
2714 | auth_data->bss->bssid, NULL, 0, 0); | 2834 | auth_data->bss->bssid, NULL, 0, 0); |
2715 | } else { | 2835 | } else { |
@@ -2728,7 +2848,7 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata) | |||
2728 | */ | 2848 | */ |
2729 | ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], | 2849 | ieee80211_send_probe_req(sdata, NULL, ssidie + 2, ssidie[1], |
2730 | NULL, 0, (u32) -1, true, false, | 2850 | NULL, 0, (u32) -1, true, false, |
2731 | auth_data->bss->channel); | 2851 | auth_data->bss->channel, false); |
2732 | } | 2852 | } |
2733 | 2853 | ||
2734 | auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; | 2854 | auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; |
@@ -3099,39 +3219,57 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata, | |||
3099 | ht_cfreq, ht_oper->primary_chan, | 3219 | ht_cfreq, ht_oper->primary_chan, |
3100 | cbss->channel->band); | 3220 | cbss->channel->band); |
3101 | ht_oper = NULL; | 3221 | ht_oper = NULL; |
3222 | } else { | ||
3223 | channel_type = NL80211_CHAN_HT20; | ||
3102 | } | 3224 | } |
3103 | } | 3225 | } |
3104 | 3226 | ||
3105 | if (ht_oper) { | 3227 | if (ht_oper && sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { |
3228 | /* | ||
3229 | * cfg80211 already verified that the channel itself can | ||
3230 | * be used, but it didn't check that we can do the right | ||
3231 | * HT type, so do that here as well. If HT40 isn't allowed | ||
3232 | * on this channel, disable 40 MHz operation. | ||
3233 | */ | ||
3234 | const u8 *ht_cap_ie; | ||
3235 | const struct ieee80211_ht_cap *ht_cap; | ||
3236 | u8 chains = 1; | ||
3237 | |||
3106 | channel_type = NL80211_CHAN_HT20; | 3238 | channel_type = NL80211_CHAN_HT20; |
3107 | 3239 | ||
3108 | if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { | 3240 | switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
3109 | switch (ht_oper->ht_param & | 3241 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
3110 | IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { | 3242 | if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40PLUS) |
3111 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: | 3243 | ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ; |
3244 | else | ||
3112 | channel_type = NL80211_CHAN_HT40PLUS; | 3245 | channel_type = NL80211_CHAN_HT40PLUS; |
3113 | break; | 3246 | break; |
3114 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: | 3247 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
3248 | if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40MINUS) | ||
3249 | ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ; | ||
3250 | else | ||
3115 | channel_type = NL80211_CHAN_HT40MINUS; | 3251 | channel_type = NL80211_CHAN_HT40MINUS; |
3116 | break; | 3252 | break; |
3117 | } | ||
3118 | } | 3253 | } |
3119 | } | ||
3120 | 3254 | ||
3121 | if (!ieee80211_set_channel_type(local, sdata, channel_type)) { | 3255 | ht_cap_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, |
3122 | /* can only fail due to HT40+/- mismatch */ | 3256 | cbss->information_elements, |
3123 | channel_type = NL80211_CHAN_HT20; | 3257 | cbss->len_information_elements); |
3124 | sdata_info(sdata, | 3258 | if (ht_cap_ie && ht_cap_ie[1] >= sizeof(*ht_cap)) { |
3125 | "disabling 40 MHz due to multi-vif mismatch\n"); | 3259 | ht_cap = (void *)(ht_cap_ie + 2); |
3126 | ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ; | 3260 | chains = ieee80211_mcs_to_chains(&ht_cap->mcs); |
3127 | WARN_ON(!ieee80211_set_channel_type(local, sdata, | 3261 | } |
3128 | channel_type)); | 3262 | sdata->needed_rx_chains = min(chains, local->rx_chains); |
3263 | } else { | ||
3264 | sdata->needed_rx_chains = 1; | ||
3129 | } | 3265 | } |
3130 | 3266 | ||
3131 | local->oper_channel = cbss->channel; | 3267 | /* will change later if needed */ |
3132 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); | 3268 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
3133 | 3269 | ||
3134 | return 0; | 3270 | ieee80211_vif_release_channel(sdata); |
3271 | return ieee80211_vif_use_channel(sdata, cbss->channel, channel_type, | ||
3272 | IEEE80211_CHANCTX_SHARED); | ||
3135 | } | 3273 | } |
3136 | 3274 | ||
3137 | static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, | 3275 | static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, |
@@ -3201,7 +3339,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, | |||
3201 | sdata->vif.bss_conf.basic_rates = basic_rates; | 3339 | sdata->vif.bss_conf.basic_rates = basic_rates; |
3202 | 3340 | ||
3203 | /* cf. IEEE 802.11 9.2.12 */ | 3341 | /* cf. IEEE 802.11 9.2.12 */ |
3204 | if (local->oper_channel->band == IEEE80211_BAND_2GHZ && | 3342 | if (cbss->channel->band == IEEE80211_BAND_2GHZ && |
3205 | have_higher_than_11mbit) | 3343 | have_higher_than_11mbit) |
3206 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; | 3344 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; |
3207 | else | 3345 | else |
@@ -3263,19 +3401,33 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata, | |||
3263 | case NL80211_AUTHTYPE_NETWORK_EAP: | 3401 | case NL80211_AUTHTYPE_NETWORK_EAP: |
3264 | auth_alg = WLAN_AUTH_LEAP; | 3402 | auth_alg = WLAN_AUTH_LEAP; |
3265 | break; | 3403 | break; |
3404 | case NL80211_AUTHTYPE_SAE: | ||
3405 | auth_alg = WLAN_AUTH_SAE; | ||
3406 | break; | ||
3266 | default: | 3407 | default: |
3267 | return -EOPNOTSUPP; | 3408 | return -EOPNOTSUPP; |
3268 | } | 3409 | } |
3269 | 3410 | ||
3270 | auth_data = kzalloc(sizeof(*auth_data) + req->ie_len, GFP_KERNEL); | 3411 | auth_data = kzalloc(sizeof(*auth_data) + req->sae_data_len + |
3412 | req->ie_len, GFP_KERNEL); | ||
3271 | if (!auth_data) | 3413 | if (!auth_data) |
3272 | return -ENOMEM; | 3414 | return -ENOMEM; |
3273 | 3415 | ||
3274 | auth_data->bss = req->bss; | 3416 | auth_data->bss = req->bss; |
3275 | 3417 | ||
3418 | if (req->sae_data_len >= 4) { | ||
3419 | __le16 *pos = (__le16 *) req->sae_data; | ||
3420 | auth_data->sae_trans = le16_to_cpu(pos[0]); | ||
3421 | auth_data->sae_status = le16_to_cpu(pos[1]); | ||
3422 | memcpy(auth_data->data, req->sae_data + 4, | ||
3423 | req->sae_data_len - 4); | ||
3424 | auth_data->data_len += req->sae_data_len - 4; | ||
3425 | } | ||
3426 | |||
3276 | if (req->ie && req->ie_len) { | 3427 | if (req->ie && req->ie_len) { |
3277 | memcpy(auth_data->ie, req->ie, req->ie_len); | 3428 | memcpy(&auth_data->data[auth_data->data_len], |
3278 | auth_data->ie_len = req->ie_len; | 3429 | req->ie, req->ie_len); |
3430 | auth_data->data_len += req->ie_len; | ||
3279 | } | 3431 | } |
3280 | 3432 | ||
3281 | if (req->key && req->key_len) { | 3433 | if (req->key && req->key_len) { |
@@ -3442,11 +3594,11 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata, | |||
3442 | 3594 | ||
3443 | if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { | 3595 | if (ifmgd->req_smps == IEEE80211_SMPS_AUTOMATIC) { |
3444 | if (ifmgd->powersave) | 3596 | if (ifmgd->powersave) |
3445 | ifmgd->ap_smps = IEEE80211_SMPS_DYNAMIC; | 3597 | sdata->smps_mode = IEEE80211_SMPS_DYNAMIC; |
3446 | else | 3598 | else |
3447 | ifmgd->ap_smps = IEEE80211_SMPS_OFF; | 3599 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
3448 | } else | 3600 | } else |
3449 | ifmgd->ap_smps = ifmgd->req_smps; | 3601 | sdata->smps_mode = ifmgd->req_smps; |
3450 | 3602 | ||
3451 | assoc_data->capability = req->bss->capability; | 3603 | assoc_data->capability = req->bss->capability; |
3452 | assoc_data->wmm = bss->wmm_used && | 3604 | assoc_data->wmm = bss->wmm_used && |
@@ -3549,40 +3701,45 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, | |||
3549 | { | 3701 | { |
3550 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 3702 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
3551 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; | 3703 | u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; |
3704 | bool tx = !req->local_state_change; | ||
3705 | bool sent_frame = false; | ||
3552 | 3706 | ||
3553 | mutex_lock(&ifmgd->mtx); | 3707 | mutex_lock(&ifmgd->mtx); |
3554 | 3708 | ||
3555 | if (ifmgd->auth_data) { | ||
3556 | ieee80211_destroy_auth_data(sdata, false); | ||
3557 | mutex_unlock(&ifmgd->mtx); | ||
3558 | return 0; | ||
3559 | } | ||
3560 | |||
3561 | sdata_info(sdata, | 3709 | sdata_info(sdata, |
3562 | "deauthenticating from %pM by local choice (reason=%d)\n", | 3710 | "deauthenticating from %pM by local choice (reason=%d)\n", |
3563 | req->bssid, req->reason_code); | 3711 | req->bssid, req->reason_code); |
3564 | 3712 | ||
3565 | if (ifmgd->associated && | 3713 | if (ifmgd->auth_data) { |
3566 | ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { | ||
3567 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, | ||
3568 | req->reason_code, true, frame_buf); | ||
3569 | } else { | ||
3570 | drv_mgd_prepare_tx(sdata->local, sdata); | 3714 | drv_mgd_prepare_tx(sdata->local, sdata); |
3571 | ieee80211_send_deauth_disassoc(sdata, req->bssid, | 3715 | ieee80211_send_deauth_disassoc(sdata, req->bssid, |
3572 | IEEE80211_STYPE_DEAUTH, | 3716 | IEEE80211_STYPE_DEAUTH, |
3573 | req->reason_code, true, | 3717 | req->reason_code, tx, |
3574 | frame_buf); | 3718 | frame_buf); |
3719 | ieee80211_destroy_auth_data(sdata, false); | ||
3720 | mutex_unlock(&ifmgd->mtx); | ||
3721 | |||
3722 | sent_frame = tx; | ||
3723 | goto out; | ||
3575 | } | 3724 | } |
3576 | 3725 | ||
3726 | if (ifmgd->associated && | ||
3727 | ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { | ||
3728 | ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, | ||
3729 | req->reason_code, tx, frame_buf); | ||
3730 | sent_frame = tx; | ||
3731 | } | ||
3577 | mutex_unlock(&ifmgd->mtx); | 3732 | mutex_unlock(&ifmgd->mtx); |
3578 | 3733 | ||
3579 | __cfg80211_send_deauth(sdata->dev, frame_buf, | 3734 | out: |
3580 | IEEE80211_DEAUTH_FRAME_LEN); | ||
3581 | |||
3582 | mutex_lock(&sdata->local->mtx); | 3735 | mutex_lock(&sdata->local->mtx); |
3583 | ieee80211_recalc_idle(sdata->local); | 3736 | ieee80211_recalc_idle(sdata->local); |
3584 | mutex_unlock(&sdata->local->mtx); | 3737 | mutex_unlock(&sdata->local->mtx); |
3585 | 3738 | ||
3739 | if (sent_frame) | ||
3740 | __cfg80211_send_deauth(sdata->dev, frame_buf, | ||
3741 | IEEE80211_DEAUTH_FRAME_LEN); | ||
3742 | |||
3586 | return 0; | 3743 | return 0; |
3587 | } | 3744 | } |
3588 | 3745 | ||
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c index 83608ac16780..0cd42d52880c 100644 --- a/net/mac80211/offchannel.c +++ b/net/mac80211/offchannel.c | |||
@@ -107,6 +107,9 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local, | |||
107 | { | 107 | { |
108 | struct ieee80211_sub_if_data *sdata; | 108 | struct ieee80211_sub_if_data *sdata; |
109 | 109 | ||
110 | if (WARN_ON(local->use_chanctx)) | ||
111 | return; | ||
112 | |||
110 | /* | 113 | /* |
111 | * notify the AP about us leaving the channel and stop all | 114 | * notify the AP about us leaving the channel and stop all |
112 | * STA interfaces. | 115 | * STA interfaces. |
@@ -145,6 +148,9 @@ void ieee80211_offchannel_return(struct ieee80211_local *local, | |||
145 | { | 148 | { |
146 | struct ieee80211_sub_if_data *sdata; | 149 | struct ieee80211_sub_if_data *sdata; |
147 | 150 | ||
151 | if (WARN_ON(local->use_chanctx)) | ||
152 | return; | ||
153 | |||
148 | mutex_lock(&local->iflist_mtx); | 154 | mutex_lock(&local->iflist_mtx); |
149 | list_for_each_entry(sdata, &local->interfaces, list) { | 155 | list_for_each_entry(sdata, &local->interfaces, list) { |
150 | if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) | 156 | if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) |
@@ -193,11 +199,12 @@ void ieee80211_handle_roc_started(struct ieee80211_roc_work *roc) | |||
193 | 199 | ||
194 | if (roc->mgmt_tx_cookie) { | 200 | if (roc->mgmt_tx_cookie) { |
195 | if (!WARN_ON(!roc->frame)) { | 201 | if (!WARN_ON(!roc->frame)) { |
196 | ieee80211_tx_skb(roc->sdata, roc->frame); | 202 | ieee80211_tx_skb_tid_band(roc->sdata, roc->frame, 7, |
203 | roc->chan->band); | ||
197 | roc->frame = NULL; | 204 | roc->frame = NULL; |
198 | } | 205 | } |
199 | } else { | 206 | } else { |
200 | cfg80211_ready_on_channel(&roc->sdata->wdev, (unsigned long)roc, | 207 | cfg80211_ready_on_channel(&roc->sdata->wdev, roc->cookie, |
201 | roc->chan, roc->chan_type, | 208 | roc->chan, roc->chan_type, |
202 | roc->req_duration, GFP_KERNEL); | 209 | roc->req_duration, GFP_KERNEL); |
203 | } | 210 | } |
@@ -313,9 +320,8 @@ void ieee80211_roc_notify_destroy(struct ieee80211_roc_work *roc) | |||
313 | 320 | ||
314 | if (!roc->mgmt_tx_cookie) | 321 | if (!roc->mgmt_tx_cookie) |
315 | cfg80211_remain_on_channel_expired(&roc->sdata->wdev, | 322 | cfg80211_remain_on_channel_expired(&roc->sdata->wdev, |
316 | (unsigned long)roc, | 323 | roc->cookie, roc->chan, |
317 | roc->chan, roc->chan_type, | 324 | roc->chan_type, GFP_KERNEL); |
318 | GFP_KERNEL); | ||
319 | 325 | ||
320 | list_for_each_entry_safe(dep, tmp, &roc->dependents, list) | 326 | list_for_each_entry_safe(dep, tmp, &roc->dependents, list) |
321 | ieee80211_roc_notify_destroy(dep); | 327 | ieee80211_roc_notify_destroy(dep); |
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index 5c572e7a1a71..0f1c434638bc 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c | |||
@@ -135,6 +135,12 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) | |||
135 | ieee80211_bss_info_change_notify(sdata, | 135 | ieee80211_bss_info_change_notify(sdata, |
136 | BSS_CHANGED_BEACON_ENABLED); | 136 | BSS_CHANGED_BEACON_ENABLED); |
137 | 137 | ||
138 | if (sdata->vif.type == NL80211_IFTYPE_AP && | ||
139 | rcu_access_pointer(sdata->u.ap.beacon)) | ||
140 | drv_stop_ap(local, sdata); | ||
141 | |||
142 | /* the interface is leaving the channel and is removed */ | ||
143 | ieee80211_vif_release_channel(sdata); | ||
138 | drv_remove_interface(local, sdata); | 144 | drv_remove_interface(local, sdata); |
139 | } | 145 | } |
140 | 146 | ||
diff --git a/net/mac80211/rate.h b/net/mac80211/rate.h index 10de668eb9f6..ec198ef6aa8a 100644 --- a/net/mac80211/rate.h +++ b/net/mac80211/rate.h | |||
@@ -52,11 +52,21 @@ static inline void rate_control_rate_init(struct sta_info *sta) | |||
52 | struct ieee80211_sta *ista = &sta->sta; | 52 | struct ieee80211_sta *ista = &sta->sta; |
53 | void *priv_sta = sta->rate_ctrl_priv; | 53 | void *priv_sta = sta->rate_ctrl_priv; |
54 | struct ieee80211_supported_band *sband; | 54 | struct ieee80211_supported_band *sband; |
55 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
55 | 56 | ||
56 | if (!ref) | 57 | if (!ref) |
57 | return; | 58 | return; |
58 | 59 | ||
59 | sband = local->hw.wiphy->bands[local->oper_channel->band]; | 60 | rcu_read_lock(); |
61 | |||
62 | chanctx_conf = rcu_dereference(sta->sdata->vif.chanctx_conf); | ||
63 | if (WARN_ON(!chanctx_conf)) { | ||
64 | rcu_read_unlock(); | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | sband = local->hw.wiphy->bands[chanctx_conf->channel->band]; | ||
69 | rcu_read_unlock(); | ||
60 | 70 | ||
61 | ref->ops->rate_init(ref->priv, sband, ista, priv_sta); | 71 | ref->ops->rate_init(ref->priv, sband, ista, priv_sta); |
62 | set_sta_flag(sta, WLAN_STA_RATE_CONTROL); | 72 | set_sta_flag(sta, WLAN_STA_RATE_CONTROL); |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 61c621e9273f..6ad330341b71 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -54,8 +54,7 @@ static struct sk_buff *remove_monitor_info(struct ieee80211_local *local, | |||
54 | return skb; | 54 | return skb; |
55 | } | 55 | } |
56 | 56 | ||
57 | static inline int should_drop_frame(struct sk_buff *skb, | 57 | static inline int should_drop_frame(struct sk_buff *skb, int present_fcs_len) |
58 | int present_fcs_len) | ||
59 | { | 58 | { |
60 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 59 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
61 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | 60 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
@@ -130,15 +129,14 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, | |||
130 | (1 << IEEE80211_RADIOTAP_RX_FLAGS)); | 129 | (1 << IEEE80211_RADIOTAP_RX_FLAGS)); |
131 | rthdr->it_len = cpu_to_le16(rtap_len); | 130 | rthdr->it_len = cpu_to_le16(rtap_len); |
132 | 131 | ||
133 | pos = (unsigned char *)(rthdr+1); | 132 | pos = (unsigned char *)(rthdr + 1); |
134 | 133 | ||
135 | /* the order of the following fields is important */ | 134 | /* the order of the following fields is important */ |
136 | 135 | ||
137 | /* IEEE80211_RADIOTAP_TSFT */ | 136 | /* IEEE80211_RADIOTAP_TSFT */ |
138 | if (status->flag & RX_FLAG_MACTIME_MPDU) { | 137 | if (status->flag & RX_FLAG_MACTIME_MPDU) { |
139 | put_unaligned_le64(status->mactime, pos); | 138 | put_unaligned_le64(status->mactime, pos); |
140 | rthdr->it_present |= | 139 | rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); |
141 | cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT); | ||
142 | pos += 8; | 140 | pos += 8; |
143 | } | 141 | } |
144 | 142 | ||
@@ -374,7 +372,6 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, | |||
374 | return origskb; | 372 | return origskb; |
375 | } | 373 | } |
376 | 374 | ||
377 | |||
378 | static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) | 375 | static void ieee80211_parse_qos(struct ieee80211_rx_data *rx) |
379 | { | 376 | { |
380 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 377 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
@@ -481,8 +478,7 @@ static int ieee80211_get_mmie_keyidx(struct sk_buff *skb) | |||
481 | struct ieee80211_mgmt *hdr = (struct ieee80211_mgmt *) skb->data; | 478 | struct ieee80211_mgmt *hdr = (struct ieee80211_mgmt *) skb->data; |
482 | struct ieee80211_mmie *mmie; | 479 | struct ieee80211_mmie *mmie; |
483 | 480 | ||
484 | if (skb->len < 24 + sizeof(*mmie) || | 481 | if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da)) |
485 | !is_multicast_ether_addr(hdr->da)) | ||
486 | return -1; | 482 | return -1; |
487 | 483 | ||
488 | if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr)) | 484 | if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr)) |
@@ -497,9 +493,7 @@ static int ieee80211_get_mmie_keyidx(struct sk_buff *skb) | |||
497 | return le16_to_cpu(mmie->key_id); | 493 | return le16_to_cpu(mmie->key_id); |
498 | } | 494 | } |
499 | 495 | ||
500 | 496 | static ieee80211_rx_result ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |
501 | static ieee80211_rx_result | ||
502 | ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | ||
503 | { | 497 | { |
504 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 498 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
505 | char *dev_addr = rx->sdata->vif.addr; | 499 | char *dev_addr = rx->sdata->vif.addr; |
@@ -507,7 +501,7 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
507 | if (ieee80211_is_data(hdr->frame_control)) { | 501 | if (ieee80211_is_data(hdr->frame_control)) { |
508 | if (is_multicast_ether_addr(hdr->addr1)) { | 502 | if (is_multicast_ether_addr(hdr->addr1)) { |
509 | if (ieee80211_has_tods(hdr->frame_control) || | 503 | if (ieee80211_has_tods(hdr->frame_control) || |
510 | !ieee80211_has_fromds(hdr->frame_control)) | 504 | !ieee80211_has_fromds(hdr->frame_control)) |
511 | return RX_DROP_MONITOR; | 505 | return RX_DROP_MONITOR; |
512 | if (ether_addr_equal(hdr->addr3, dev_addr)) | 506 | if (ether_addr_equal(hdr->addr3, dev_addr)) |
513 | return RX_DROP_MONITOR; | 507 | return RX_DROP_MONITOR; |
@@ -531,10 +525,15 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
531 | 525 | ||
532 | if (ieee80211_is_action(hdr->frame_control)) { | 526 | if (ieee80211_is_action(hdr->frame_control)) { |
533 | u8 category; | 527 | u8 category; |
528 | |||
529 | /* make sure category field is present */ | ||
530 | if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE) | ||
531 | return RX_DROP_MONITOR; | ||
532 | |||
534 | mgmt = (struct ieee80211_mgmt *)hdr; | 533 | mgmt = (struct ieee80211_mgmt *)hdr; |
535 | category = mgmt->u.action.category; | 534 | category = mgmt->u.action.category; |
536 | if (category != WLAN_CATEGORY_MESH_ACTION && | 535 | if (category != WLAN_CATEGORY_MESH_ACTION && |
537 | category != WLAN_CATEGORY_SELF_PROTECTED) | 536 | category != WLAN_CATEGORY_SELF_PROTECTED) |
538 | return RX_DROP_MONITOR; | 537 | return RX_DROP_MONITOR; |
539 | return RX_CONTINUE; | 538 | return RX_CONTINUE; |
540 | } | 539 | } |
@@ -546,7 +545,6 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx) | |||
546 | return RX_CONTINUE; | 545 | return RX_CONTINUE; |
547 | 546 | ||
548 | return RX_DROP_MONITOR; | 547 | return RX_DROP_MONITOR; |
549 | |||
550 | } | 548 | } |
551 | 549 | ||
552 | return RX_CONTINUE; | 550 | return RX_CONTINUE; |
@@ -570,7 +568,6 @@ static inline u16 seq_sub(u16 sq1, u16 sq2) | |||
570 | return (sq1 - sq2) & SEQ_MASK; | 568 | return (sq1 - sq2) & SEQ_MASK; |
571 | } | 569 | } |
572 | 570 | ||
573 | |||
574 | static void ieee80211_release_reorder_frame(struct ieee80211_sub_if_data *sdata, | 571 | static void ieee80211_release_reorder_frame(struct ieee80211_sub_if_data *sdata, |
575 | struct tid_ampdu_rx *tid_agg_rx, | 572 | struct tid_ampdu_rx *tid_agg_rx, |
576 | int index) | 573 | int index) |
@@ -883,14 +880,16 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx) | |||
883 | */ | 880 | */ |
884 | if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION && | 881 | if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION && |
885 | ieee80211_is_data_present(hdr->frame_control)) { | 882 | ieee80211_is_data_present(hdr->frame_control)) { |
886 | u16 ethertype; | 883 | unsigned int hdrlen; |
887 | u8 *payload; | 884 | __be16 ethertype; |
888 | 885 | ||
889 | payload = rx->skb->data + | 886 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
890 | ieee80211_hdrlen(hdr->frame_control); | 887 | |
891 | ethertype = (payload[6] << 8) | payload[7]; | 888 | if (rx->skb->len < hdrlen + 8) |
892 | if (cpu_to_be16(ethertype) == | 889 | return RX_DROP_MONITOR; |
893 | rx->sdata->control_port_protocol) | 890 | |
891 | skb_copy_bits(rx->skb, hdrlen + 6, ðertype, 2); | ||
892 | if (ethertype == rx->sdata->control_port_protocol) | ||
894 | return RX_CONTINUE; | 893 | return RX_CONTINUE; |
895 | } | 894 | } |
896 | 895 | ||
@@ -1141,12 +1140,19 @@ ieee80211_rx_h_check_more_data(struct ieee80211_rx_data *rx) | |||
1141 | return RX_CONTINUE; | 1140 | return RX_CONTINUE; |
1142 | } | 1141 | } |
1143 | 1142 | ||
1144 | static void ap_sta_ps_start(struct sta_info *sta) | 1143 | static void sta_ps_start(struct sta_info *sta) |
1145 | { | 1144 | { |
1146 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 1145 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
1147 | struct ieee80211_local *local = sdata->local; | 1146 | struct ieee80211_local *local = sdata->local; |
1147 | struct ps_data *ps; | ||
1148 | 1148 | ||
1149 | atomic_inc(&sdata->bss->num_sta_ps); | 1149 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
1150 | sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | ||
1151 | ps = &sdata->bss->ps; | ||
1152 | else | ||
1153 | return; | ||
1154 | |||
1155 | atomic_inc(&ps->num_sta_ps); | ||
1150 | set_sta_flag(sta, WLAN_STA_PS_STA); | 1156 | set_sta_flag(sta, WLAN_STA_PS_STA); |
1151 | if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS)) | 1157 | if (!(local->hw.flags & IEEE80211_HW_AP_LINK_PS)) |
1152 | drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); | 1158 | drv_sta_notify(local, sdata, STA_NOTIFY_SLEEP, &sta->sta); |
@@ -1154,7 +1160,7 @@ static void ap_sta_ps_start(struct sta_info *sta) | |||
1154 | sta->sta.addr, sta->sta.aid); | 1160 | sta->sta.addr, sta->sta.aid); |
1155 | } | 1161 | } |
1156 | 1162 | ||
1157 | static void ap_sta_ps_end(struct sta_info *sta) | 1163 | static void sta_ps_end(struct sta_info *sta) |
1158 | { | 1164 | { |
1159 | ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n", | 1165 | ps_dbg(sta->sdata, "STA %pM aid %d exits power save mode\n", |
1160 | sta->sta.addr, sta->sta.aid); | 1166 | sta->sta.addr, sta->sta.aid); |
@@ -1181,9 +1187,9 @@ int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start) | |||
1181 | return -EINVAL; | 1187 | return -EINVAL; |
1182 | 1188 | ||
1183 | if (start) | 1189 | if (start) |
1184 | ap_sta_ps_start(sta_inf); | 1190 | sta_ps_start(sta_inf); |
1185 | else | 1191 | else |
1186 | ap_sta_ps_end(sta_inf); | 1192 | sta_ps_end(sta_inf); |
1187 | 1193 | ||
1188 | return 0; | 1194 | return 0; |
1189 | } | 1195 | } |
@@ -1335,10 +1341,10 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx) | |||
1335 | */ | 1341 | */ |
1336 | if (ieee80211_is_data(hdr->frame_control) && | 1342 | if (ieee80211_is_data(hdr->frame_control) && |
1337 | !ieee80211_has_pm(hdr->frame_control)) | 1343 | !ieee80211_has_pm(hdr->frame_control)) |
1338 | ap_sta_ps_end(sta); | 1344 | sta_ps_end(sta); |
1339 | } else { | 1345 | } else { |
1340 | if (ieee80211_has_pm(hdr->frame_control)) | 1346 | if (ieee80211_has_pm(hdr->frame_control)) |
1341 | ap_sta_ps_start(sta); | 1347 | sta_ps_start(sta); |
1342 | } | 1348 | } |
1343 | } | 1349 | } |
1344 | 1350 | ||
@@ -1384,9 +1390,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata, | |||
1384 | struct sk_buff **skb) | 1390 | struct sk_buff **skb) |
1385 | { | 1391 | { |
1386 | struct ieee80211_fragment_entry *entry; | 1392 | struct ieee80211_fragment_entry *entry; |
1387 | int idx; | ||
1388 | 1393 | ||
1389 | idx = sdata->fragment_next; | ||
1390 | entry = &sdata->fragments[sdata->fragment_next++]; | 1394 | entry = &sdata->fragments[sdata->fragment_next++]; |
1391 | if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX) | 1395 | if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX) |
1392 | sdata->fragment_next = 0; | 1396 | sdata->fragment_next = 0; |
@@ -1462,11 +1466,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1462 | 1466 | ||
1463 | hdr = (struct ieee80211_hdr *)rx->skb->data; | 1467 | hdr = (struct ieee80211_hdr *)rx->skb->data; |
1464 | fc = hdr->frame_control; | 1468 | fc = hdr->frame_control; |
1469 | |||
1470 | if (ieee80211_is_ctl(fc)) | ||
1471 | return RX_CONTINUE; | ||
1472 | |||
1465 | sc = le16_to_cpu(hdr->seq_ctrl); | 1473 | sc = le16_to_cpu(hdr->seq_ctrl); |
1466 | frag = sc & IEEE80211_SCTL_FRAG; | 1474 | frag = sc & IEEE80211_SCTL_FRAG; |
1467 | 1475 | ||
1468 | if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || | 1476 | if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || |
1469 | (rx->skb)->len < 24 || | ||
1470 | is_multicast_ether_addr(hdr->addr1))) { | 1477 | is_multicast_ether_addr(hdr->addr1))) { |
1471 | /* not fragmented */ | 1478 | /* not fragmented */ |
1472 | goto out; | 1479 | goto out; |
@@ -1570,18 +1577,15 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx) | |||
1570 | return RX_CONTINUE; | 1577 | return RX_CONTINUE; |
1571 | } | 1578 | } |
1572 | 1579 | ||
1573 | static int | 1580 | static int ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) |
1574 | ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) | ||
1575 | { | 1581 | { |
1576 | if (unlikely(!rx->sta || | 1582 | if (unlikely(!rx->sta || !test_sta_flag(rx->sta, WLAN_STA_AUTHORIZED))) |
1577 | !test_sta_flag(rx->sta, WLAN_STA_AUTHORIZED))) | ||
1578 | return -EACCES; | 1583 | return -EACCES; |
1579 | 1584 | ||
1580 | return 0; | 1585 | return 0; |
1581 | } | 1586 | } |
1582 | 1587 | ||
1583 | static int | 1588 | static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) |
1584 | ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) | ||
1585 | { | 1589 | { |
1586 | struct sk_buff *skb = rx->skb; | 1590 | struct sk_buff *skb = rx->skb; |
1587 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 1591 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
@@ -1603,8 +1607,7 @@ ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) | |||
1603 | return 0; | 1607 | return 0; |
1604 | } | 1608 | } |
1605 | 1609 | ||
1606 | static int | 1610 | static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx) |
1607 | ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx) | ||
1608 | { | 1611 | { |
1609 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; | 1612 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)rx->skb->data; |
1610 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); | 1613 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb); |
@@ -1889,6 +1892,20 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1889 | 1892 | ||
1890 | hdr = (struct ieee80211_hdr *) skb->data; | 1893 | hdr = (struct ieee80211_hdr *) skb->data; |
1891 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | 1894 | hdrlen = ieee80211_hdrlen(hdr->frame_control); |
1895 | |||
1896 | /* make sure fixed part of mesh header is there, also checks skb len */ | ||
1897 | if (!pskb_may_pull(rx->skb, hdrlen + 6)) | ||
1898 | return RX_DROP_MONITOR; | ||
1899 | |||
1900 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); | ||
1901 | |||
1902 | /* make sure full mesh header is there, also checks skb len */ | ||
1903 | if (!pskb_may_pull(rx->skb, | ||
1904 | hdrlen + ieee80211_get_mesh_hdrlen(mesh_hdr))) | ||
1905 | return RX_DROP_MONITOR; | ||
1906 | |||
1907 | /* reload pointers */ | ||
1908 | hdr = (struct ieee80211_hdr *) skb->data; | ||
1892 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); | 1909 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); |
1893 | 1910 | ||
1894 | /* frame is in RMC, don't forward */ | 1911 | /* frame is in RMC, don't forward */ |
@@ -1897,7 +1914,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1897 | mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata)) | 1914 | mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata)) |
1898 | return RX_DROP_MONITOR; | 1915 | return RX_DROP_MONITOR; |
1899 | 1916 | ||
1900 | if (!ieee80211_is_data(hdr->frame_control)) | 1917 | if (!ieee80211_is_data(hdr->frame_control) || |
1918 | !(status->rx_flags & IEEE80211_RX_RA_MATCH)) | ||
1901 | return RX_CONTINUE; | 1919 | return RX_CONTINUE; |
1902 | 1920 | ||
1903 | if (!mesh_hdr->ttl) | 1921 | if (!mesh_hdr->ttl) |
@@ -1911,9 +1929,12 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1911 | if (is_multicast_ether_addr(hdr->addr1)) { | 1929 | if (is_multicast_ether_addr(hdr->addr1)) { |
1912 | mpp_addr = hdr->addr3; | 1930 | mpp_addr = hdr->addr3; |
1913 | proxied_addr = mesh_hdr->eaddr1; | 1931 | proxied_addr = mesh_hdr->eaddr1; |
1914 | } else { | 1932 | } else if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6) { |
1933 | /* has_a4 already checked in ieee80211_rx_mesh_check */ | ||
1915 | mpp_addr = hdr->addr4; | 1934 | mpp_addr = hdr->addr4; |
1916 | proxied_addr = mesh_hdr->eaddr2; | 1935 | proxied_addr = mesh_hdr->eaddr2; |
1936 | } else { | ||
1937 | return RX_DROP_MONITOR; | ||
1917 | } | 1938 | } |
1918 | 1939 | ||
1919 | rcu_read_lock(); | 1940 | rcu_read_lock(); |
@@ -1941,12 +1962,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1941 | } | 1962 | } |
1942 | skb_set_queue_mapping(skb, q); | 1963 | skb_set_queue_mapping(skb, q); |
1943 | 1964 | ||
1944 | if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) | ||
1945 | goto out; | ||
1946 | |||
1947 | if (!--mesh_hdr->ttl) { | 1965 | if (!--mesh_hdr->ttl) { |
1948 | IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl); | 1966 | IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl); |
1949 | return RX_DROP_MONITOR; | 1967 | goto out; |
1950 | } | 1968 | } |
1951 | 1969 | ||
1952 | if (!ifmsh->mshcfg.dot11MeshForwarding) | 1970 | if (!ifmsh->mshcfg.dot11MeshForwarding) |
@@ -1973,7 +1991,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | |||
1973 | } else { | 1991 | } else { |
1974 | /* unable to resolve next hop */ | 1992 | /* unable to resolve next hop */ |
1975 | mesh_path_error_tx(ifmsh->mshcfg.element_ttl, fwd_hdr->addr3, | 1993 | mesh_path_error_tx(ifmsh->mshcfg.element_ttl, fwd_hdr->addr3, |
1976 | 0, reason, fwd_hdr->addr2, sdata); | 1994 | 0, reason, fwd_hdr->addr2, sdata); |
1977 | IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route); | 1995 | IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route); |
1978 | kfree_skb(fwd_skb); | 1996 | kfree_skb(fwd_skb); |
1979 | return RX_DROP_MONITOR; | 1997 | return RX_DROP_MONITOR; |
@@ -2182,7 +2200,7 @@ ieee80211_rx_h_mgmt_check(struct ieee80211_rx_data *rx) | |||
2182 | 2200 | ||
2183 | cfg80211_report_obss_beacon(rx->local->hw.wiphy, | 2201 | cfg80211_report_obss_beacon(rx->local->hw.wiphy, |
2184 | rx->skb->data, rx->skb->len, | 2202 | rx->skb->data, rx->skb->len, |
2185 | status->freq, sig, GFP_ATOMIC); | 2203 | status->freq, sig); |
2186 | rx->flags |= IEEE80211_RX_BEACON_REPORTED; | 2204 | rx->flags |= IEEE80211_RX_BEACON_REPORTED; |
2187 | } | 2205 | } |
2188 | 2206 | ||
@@ -2353,6 +2371,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2353 | } | 2371 | } |
2354 | break; | 2372 | break; |
2355 | case WLAN_CATEGORY_SELF_PROTECTED: | 2373 | case WLAN_CATEGORY_SELF_PROTECTED: |
2374 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2375 | sizeof(mgmt->u.action.u.self_prot.action_code))) | ||
2376 | break; | ||
2377 | |||
2356 | switch (mgmt->u.action.u.self_prot.action_code) { | 2378 | switch (mgmt->u.action.u.self_prot.action_code) { |
2357 | case WLAN_SP_MESH_PEERING_OPEN: | 2379 | case WLAN_SP_MESH_PEERING_OPEN: |
2358 | case WLAN_SP_MESH_PEERING_CLOSE: | 2380 | case WLAN_SP_MESH_PEERING_CLOSE: |
@@ -2371,10 +2393,14 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) | |||
2371 | } | 2393 | } |
2372 | break; | 2394 | break; |
2373 | case WLAN_CATEGORY_MESH_ACTION: | 2395 | case WLAN_CATEGORY_MESH_ACTION: |
2396 | if (len < (IEEE80211_MIN_ACTION_SIZE + | ||
2397 | sizeof(mgmt->u.action.u.mesh_action.action_code))) | ||
2398 | break; | ||
2399 | |||
2374 | if (!ieee80211_vif_is_mesh(&sdata->vif)) | 2400 | if (!ieee80211_vif_is_mesh(&sdata->vif)) |
2375 | break; | 2401 | break; |
2376 | if (mesh_action_is_path_sel(mgmt) && | 2402 | if (mesh_action_is_path_sel(mgmt) && |
2377 | (!mesh_path_sel_is_hwmp(sdata))) | 2403 | !mesh_path_sel_is_hwmp(sdata)) |
2378 | break; | 2404 | break; |
2379 | goto queue; | 2405 | goto queue; |
2380 | } | 2406 | } |
@@ -2430,7 +2456,6 @@ ieee80211_rx_h_userspace_mgmt(struct ieee80211_rx_data *rx) | |||
2430 | return RX_QUEUED; | 2456 | return RX_QUEUED; |
2431 | } | 2457 | } |
2432 | 2458 | ||
2433 | |||
2434 | return RX_CONTINUE; | 2459 | return RX_CONTINUE; |
2435 | } | 2460 | } |
2436 | 2461 | ||
@@ -2913,10 +2938,15 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, | |||
2913 | if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) | 2938 | if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) |
2914 | local->dot11ReceivedFragmentCount++; | 2939 | local->dot11ReceivedFragmentCount++; |
2915 | 2940 | ||
2916 | if (ieee80211_is_mgmt(fc)) | 2941 | if (ieee80211_is_mgmt(fc)) { |
2917 | err = skb_linearize(skb); | 2942 | /* drop frame if too short for header */ |
2918 | else | 2943 | if (skb->len < ieee80211_hdrlen(fc)) |
2944 | err = -ENOBUFS; | ||
2945 | else | ||
2946 | err = skb_linearize(skb); | ||
2947 | } else { | ||
2919 | err = !pskb_may_pull(skb, ieee80211_hdrlen(fc)); | 2948 | err = !pskb_may_pull(skb, ieee80211_hdrlen(fc)); |
2949 | } | ||
2920 | 2950 | ||
2921 | if (err) { | 2951 | if (err) { |
2922 | dev_kfree_skb(skb); | 2952 | dev_kfree_skb(skb); |
@@ -3010,8 +3040,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
3010 | 3040 | ||
3011 | WARN_ON_ONCE(softirq_count() == 0); | 3041 | WARN_ON_ONCE(softirq_count() == 0); |
3012 | 3042 | ||
3013 | if (WARN_ON(status->band < 0 || | 3043 | if (WARN_ON(status->band >= IEEE80211_NUM_BANDS)) |
3014 | status->band >= IEEE80211_NUM_BANDS)) | ||
3015 | goto drop; | 3044 | goto drop; |
3016 | 3045 | ||
3017 | sband = local->hw.wiphy->bands[status->band]; | 3046 | sband = local->hw.wiphy->bands[status->band]; |
@@ -3056,8 +3085,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
3056 | * hardware error. The driver should catch hardware | 3085 | * hardware error. The driver should catch hardware |
3057 | * errors. | 3086 | * errors. |
3058 | */ | 3087 | */ |
3059 | if (WARN((status->rate_idx < 0 || | 3088 | if (WARN(status->rate_idx > 76, |
3060 | status->rate_idx > 76), | ||
3061 | "Rate marked as an HT rate but passed " | 3089 | "Rate marked as an HT rate but passed " |
3062 | "status->rate_idx is not " | 3090 | "status->rate_idx is not " |
3063 | "an MCS index [0-76]: %d (0x%02x)\n", | 3091 | "an MCS index [0-76]: %d (0x%02x)\n", |
@@ -3065,8 +3093,7 @@ void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
3065 | status->rate_idx)) | 3093 | status->rate_idx)) |
3066 | goto drop; | 3094 | goto drop; |
3067 | } else { | 3095 | } else { |
3068 | if (WARN_ON(status->rate_idx < 0 || | 3096 | if (WARN_ON(status->rate_idx >= sband->n_bitrates)) |
3069 | status->rate_idx >= sband->n_bitrates)) | ||
3070 | goto drop; | 3097 | goto drop; |
3071 | rate = &sband->bitrates[status->rate_idx]; | 3098 | rate = &sband->bitrates[status->rate_idx]; |
3072 | } | 3099 | } |
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index c4cdbde24fd3..8e9bb168b73b 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
@@ -336,6 +336,10 @@ EXPORT_SYMBOL(ieee80211_scan_completed); | |||
336 | 336 | ||
337 | static int ieee80211_start_sw_scan(struct ieee80211_local *local) | 337 | static int ieee80211_start_sw_scan(struct ieee80211_local *local) |
338 | { | 338 | { |
339 | /* Software scan is not supported in multi-channel cases */ | ||
340 | if (local->use_chanctx) | ||
341 | return -EOPNOTSUPP; | ||
342 | |||
339 | /* | 343 | /* |
340 | * Hardware/driver doesn't support hw_scan, so use software | 344 | * Hardware/driver doesn't support hw_scan, so use software |
341 | * scanning instead. First send a nullfunc frame with power save | 345 | * scanning instead. First send a nullfunc frame with power save |
@@ -417,7 +421,7 @@ static void ieee80211_scan_state_send_probe(struct ieee80211_local *local, | |||
417 | local->scan_req->ie, local->scan_req->ie_len, | 421 | local->scan_req->ie, local->scan_req->ie_len, |
418 | local->scan_req->rates[band], false, | 422 | local->scan_req->rates[band], false, |
419 | local->scan_req->no_cck, | 423 | local->scan_req->no_cck, |
420 | local->hw.conf.channel); | 424 | local->hw.conf.channel, true); |
421 | 425 | ||
422 | /* | 426 | /* |
423 | * After sending probe requests, wait for probe responses | 427 | * After sending probe requests, wait for probe responses |
@@ -462,6 +466,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
462 | sizeof(*local->hw_scan_req) + | 466 | sizeof(*local->hw_scan_req) + |
463 | req->n_channels * sizeof(req->channels[0]); | 467 | req->n_channels * sizeof(req->channels[0]); |
464 | local->hw_scan_req->ie = ies; | 468 | local->hw_scan_req->ie = ies; |
469 | local->hw_scan_req->flags = req->flags; | ||
465 | 470 | ||
466 | local->hw_scan_band = 0; | 471 | local->hw_scan_band = 0; |
467 | 472 | ||
@@ -480,7 +485,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, | |||
480 | if (local->ops->hw_scan) { | 485 | if (local->ops->hw_scan) { |
481 | __set_bit(SCAN_HW_SCANNING, &local->scanning); | 486 | __set_bit(SCAN_HW_SCANNING, &local->scanning); |
482 | } else if ((req->n_channels == 1) && | 487 | } else if ((req->n_channels == 1) && |
483 | (req->channels[0] == local->oper_channel)) { | 488 | (req->channels[0] == local->_oper_channel)) { |
484 | /* | 489 | /* |
485 | * If we are scanning only on the operating channel | 490 | * If we are scanning only on the operating channel |
486 | * then we do not need to stop normal activities | 491 | * then we do not need to stop normal activities |
@@ -562,6 +567,7 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, | |||
562 | unsigned long min_beacon_int = 0; | 567 | unsigned long min_beacon_int = 0; |
563 | struct ieee80211_sub_if_data *sdata; | 568 | struct ieee80211_sub_if_data *sdata; |
564 | struct ieee80211_channel *next_chan; | 569 | struct ieee80211_channel *next_chan; |
570 | enum mac80211_scan_state next_scan_state; | ||
565 | 571 | ||
566 | /* | 572 | /* |
567 | * check if at least one STA interface is associated, | 573 | * check if at least one STA interface is associated, |
@@ -620,10 +626,18 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local, | |||
620 | usecs_to_jiffies(min_beacon_int * 1024) * | 626 | usecs_to_jiffies(min_beacon_int * 1024) * |
621 | local->hw.conf.listen_interval); | 627 | local->hw.conf.listen_interval); |
622 | 628 | ||
623 | if (associated && (!tx_empty || bad_latency || listen_int_exceeded)) | 629 | if (associated && !tx_empty) { |
624 | local->next_scan_state = SCAN_SUSPEND; | 630 | if (local->scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) |
625 | else | 631 | next_scan_state = SCAN_ABORT; |
626 | local->next_scan_state = SCAN_SET_CHANNEL; | 632 | else |
633 | next_scan_state = SCAN_SUSPEND; | ||
634 | } else if (associated && (bad_latency || listen_int_exceeded)) { | ||
635 | next_scan_state = SCAN_SUSPEND; | ||
636 | } else { | ||
637 | next_scan_state = SCAN_SET_CHANNEL; | ||
638 | } | ||
639 | |||
640 | local->next_scan_state = next_scan_state; | ||
627 | 641 | ||
628 | *next_delay = 0; | 642 | *next_delay = 0; |
629 | } | 643 | } |
@@ -794,6 +808,9 @@ void ieee80211_scan_work(struct work_struct *work) | |||
794 | case SCAN_RESUME: | 808 | case SCAN_RESUME: |
795 | ieee80211_scan_state_resume(local, &next_delay); | 809 | ieee80211_scan_state_resume(local, &next_delay); |
796 | break; | 810 | break; |
811 | case SCAN_ABORT: | ||
812 | aborted = true; | ||
813 | goto out_complete; | ||
797 | } | 814 | } |
798 | } while (next_delay == 0); | 815 | } while (next_delay == 0); |
799 | 816 | ||
@@ -917,7 +934,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | |||
917 | struct cfg80211_sched_scan_request *req) | 934 | struct cfg80211_sched_scan_request *req) |
918 | { | 935 | { |
919 | struct ieee80211_local *local = sdata->local; | 936 | struct ieee80211_local *local = sdata->local; |
920 | struct ieee80211_sched_scan_ies sched_scan_ies; | 937 | struct ieee80211_sched_scan_ies sched_scan_ies = {}; |
921 | int ret, i; | 938 | int ret, i; |
922 | 939 | ||
923 | mutex_lock(&local->mtx); | 940 | mutex_lock(&local->mtx); |
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 797dd36a220d..e9d57689c05f 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
@@ -98,6 +98,7 @@ static void free_sta_work(struct work_struct *wk) | |||
98 | struct tid_ampdu_tx *tid_tx; | 98 | struct tid_ampdu_tx *tid_tx; |
99 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 99 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
100 | struct ieee80211_local *local = sdata->local; | 100 | struct ieee80211_local *local = sdata->local; |
101 | struct ps_data *ps; | ||
101 | 102 | ||
102 | /* | 103 | /* |
103 | * At this point, when being called as call_rcu callback, | 104 | * At this point, when being called as call_rcu callback, |
@@ -107,18 +108,22 @@ static void free_sta_work(struct work_struct *wk) | |||
107 | */ | 108 | */ |
108 | 109 | ||
109 | if (test_sta_flag(sta, WLAN_STA_PS_STA)) { | 110 | if (test_sta_flag(sta, WLAN_STA_PS_STA)) { |
110 | BUG_ON(!sdata->bss); | 111 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || |
112 | sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | ||
113 | ps = &sdata->bss->ps; | ||
114 | else | ||
115 | return; | ||
111 | 116 | ||
112 | clear_sta_flag(sta, WLAN_STA_PS_STA); | 117 | clear_sta_flag(sta, WLAN_STA_PS_STA); |
113 | 118 | ||
114 | atomic_dec(&sdata->bss->num_sta_ps); | 119 | atomic_dec(&ps->num_sta_ps); |
115 | sta_info_recalc_tim(sta); | 120 | sta_info_recalc_tim(sta); |
116 | } | 121 | } |
117 | 122 | ||
118 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { | 123 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
119 | local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); | 124 | local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); |
120 | __skb_queue_purge(&sta->ps_tx_buf[ac]); | 125 | ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]); |
121 | __skb_queue_purge(&sta->tx_filtered[ac]); | 126 | ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]); |
122 | } | 127 | } |
123 | 128 | ||
124 | #ifdef CONFIG_MAC80211_MESH | 129 | #ifdef CONFIG_MAC80211_MESH |
@@ -141,7 +146,7 @@ static void free_sta_work(struct work_struct *wk) | |||
141 | tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); | 146 | tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); |
142 | if (!tid_tx) | 147 | if (!tid_tx) |
143 | continue; | 148 | continue; |
144 | __skb_queue_purge(&tid_tx->pending); | 149 | ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); |
145 | kfree(tid_tx); | 150 | kfree(tid_tx); |
146 | } | 151 | } |
147 | 152 | ||
@@ -502,22 +507,22 @@ int sta_info_insert(struct sta_info *sta) | |||
502 | return err; | 507 | return err; |
503 | } | 508 | } |
504 | 509 | ||
505 | static inline void __bss_tim_set(struct ieee80211_if_ap *bss, u16 aid) | 510 | static inline void __bss_tim_set(u8 *tim, u16 id) |
506 | { | 511 | { |
507 | /* | 512 | /* |
508 | * This format has been mandated by the IEEE specifications, | 513 | * This format has been mandated by the IEEE specifications, |
509 | * so this line may not be changed to use the __set_bit() format. | 514 | * so this line may not be changed to use the __set_bit() format. |
510 | */ | 515 | */ |
511 | bss->tim[aid / 8] |= (1 << (aid % 8)); | 516 | tim[id / 8] |= (1 << (id % 8)); |
512 | } | 517 | } |
513 | 518 | ||
514 | static inline void __bss_tim_clear(struct ieee80211_if_ap *bss, u16 aid) | 519 | static inline void __bss_tim_clear(u8 *tim, u16 id) |
515 | { | 520 | { |
516 | /* | 521 | /* |
517 | * This format has been mandated by the IEEE specifications, | 522 | * This format has been mandated by the IEEE specifications, |
518 | * so this line may not be changed to use the __clear_bit() format. | 523 | * so this line may not be changed to use the __clear_bit() format. |
519 | */ | 524 | */ |
520 | bss->tim[aid / 8] &= ~(1 << (aid % 8)); | 525 | tim[id / 8] &= ~(1 << (id % 8)); |
521 | } | 526 | } |
522 | 527 | ||
523 | static unsigned long ieee80211_tids_for_ac(int ac) | 528 | static unsigned long ieee80211_tids_for_ac(int ac) |
@@ -541,14 +546,23 @@ static unsigned long ieee80211_tids_for_ac(int ac) | |||
541 | void sta_info_recalc_tim(struct sta_info *sta) | 546 | void sta_info_recalc_tim(struct sta_info *sta) |
542 | { | 547 | { |
543 | struct ieee80211_local *local = sta->local; | 548 | struct ieee80211_local *local = sta->local; |
544 | struct ieee80211_if_ap *bss = sta->sdata->bss; | 549 | struct ps_data *ps; |
545 | unsigned long flags; | 550 | unsigned long flags; |
546 | bool indicate_tim = false; | 551 | bool indicate_tim = false; |
547 | u8 ignore_for_tim = sta->sta.uapsd_queues; | 552 | u8 ignore_for_tim = sta->sta.uapsd_queues; |
548 | int ac; | 553 | int ac; |
554 | u16 id; | ||
555 | |||
556 | if (sta->sdata->vif.type == NL80211_IFTYPE_AP || | ||
557 | sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { | ||
558 | if (WARN_ON_ONCE(!sta->sdata->bss)) | ||
559 | return; | ||
549 | 560 | ||
550 | if (WARN_ON_ONCE(!sta->sdata->bss)) | 561 | ps = &sta->sdata->bss->ps; |
562 | id = sta->sta.aid; | ||
563 | } else { | ||
551 | return; | 564 | return; |
565 | } | ||
552 | 566 | ||
553 | /* No need to do anything if the driver does all */ | 567 | /* No need to do anything if the driver does all */ |
554 | if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) | 568 | if (local->hw.flags & IEEE80211_HW_AP_LINK_PS) |
@@ -587,9 +601,9 @@ void sta_info_recalc_tim(struct sta_info *sta) | |||
587 | spin_lock_irqsave(&local->tim_lock, flags); | 601 | spin_lock_irqsave(&local->tim_lock, flags); |
588 | 602 | ||
589 | if (indicate_tim) | 603 | if (indicate_tim) |
590 | __bss_tim_set(bss, sta->sta.aid); | 604 | __bss_tim_set(ps->tim, id); |
591 | else | 605 | else |
592 | __bss_tim_clear(bss, sta->sta.aid); | 606 | __bss_tim_clear(ps->tim, id); |
593 | 607 | ||
594 | if (local->ops->set_tim) { | 608 | if (local->ops->set_tim) { |
595 | local->tim_in_locked_section = true; | 609 | local->tim_in_locked_section = true; |
@@ -650,7 +664,7 @@ static bool sta_info_cleanup_expire_buffered_ac(struct ieee80211_local *local, | |||
650 | */ | 664 | */ |
651 | if (!skb) | 665 | if (!skb) |
652 | break; | 666 | break; |
653 | dev_kfree_skb(skb); | 667 | ieee80211_free_txskb(&local->hw, skb); |
654 | } | 668 | } |
655 | 669 | ||
656 | /* | 670 | /* |
@@ -679,7 +693,7 @@ static bool sta_info_cleanup_expire_buffered_ac(struct ieee80211_local *local, | |||
679 | local->total_ps_buffered--; | 693 | local->total_ps_buffered--; |
680 | ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", | 694 | ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", |
681 | sta->sta.addr); | 695 | sta->sta.addr); |
682 | dev_kfree_skb(skb); | 696 | ieee80211_free_txskb(&local->hw, skb); |
683 | } | 697 | } |
684 | 698 | ||
685 | /* | 699 | /* |
@@ -893,8 +907,8 @@ void ieee80211_sta_expire(struct ieee80211_sub_if_data *sdata, | |||
893 | continue; | 907 | continue; |
894 | 908 | ||
895 | if (time_after(jiffies, sta->last_rx + exp_time)) { | 909 | if (time_after(jiffies, sta->last_rx + exp_time)) { |
896 | ibss_dbg(sdata, "expiring inactive STA %pM\n", | 910 | sta_dbg(sta->sdata, "expiring inactive STA %pM\n", |
897 | sta->sta.addr); | 911 | sta->sta.addr); |
898 | WARN_ON(__sta_info_destroy(sta)); | 912 | WARN_ON(__sta_info_destroy(sta)); |
899 | } | 913 | } |
900 | } | 914 | } |
@@ -948,10 +962,17 @@ static void clear_sta_ps_flags(void *_sta) | |||
948 | { | 962 | { |
949 | struct sta_info *sta = _sta; | 963 | struct sta_info *sta = _sta; |
950 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 964 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
965 | struct ps_data *ps; | ||
966 | |||
967 | if (sdata->vif.type == NL80211_IFTYPE_AP || | ||
968 | sdata->vif.type == NL80211_IFTYPE_AP_VLAN) | ||
969 | ps = &sdata->bss->ps; | ||
970 | else | ||
971 | return; | ||
951 | 972 | ||
952 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); | 973 | clear_sta_flag(sta, WLAN_STA_PS_DRIVER); |
953 | if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA)) | 974 | if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA)) |
954 | atomic_dec(&sdata->bss->num_sta_ps); | 975 | atomic_dec(&ps->num_sta_ps); |
955 | } | 976 | } |
956 | 977 | ||
957 | /* powersave support code */ | 978 | /* powersave support code */ |
@@ -961,6 +982,7 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) | |||
961 | struct ieee80211_local *local = sdata->local; | 982 | struct ieee80211_local *local = sdata->local; |
962 | struct sk_buff_head pending; | 983 | struct sk_buff_head pending; |
963 | int filtered = 0, buffered = 0, ac; | 984 | int filtered = 0, buffered = 0, ac; |
985 | unsigned long flags; | ||
964 | 986 | ||
965 | clear_sta_flag(sta, WLAN_STA_SP); | 987 | clear_sta_flag(sta, WLAN_STA_SP); |
966 | 988 | ||
@@ -976,12 +998,16 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta) | |||
976 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { | 998 | for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { |
977 | int count = skb_queue_len(&pending), tmp; | 999 | int count = skb_queue_len(&pending), tmp; |
978 | 1000 | ||
1001 | spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags); | ||
979 | skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); | 1002 | skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); |
1003 | spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags); | ||
980 | tmp = skb_queue_len(&pending); | 1004 | tmp = skb_queue_len(&pending); |
981 | filtered += tmp - count; | 1005 | filtered += tmp - count; |
982 | count = tmp; | 1006 | count = tmp; |
983 | 1007 | ||
1008 | spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags); | ||
984 | skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); | 1009 | skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); |
1010 | spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags); | ||
985 | tmp = skb_queue_len(&pending); | 1011 | tmp = skb_queue_len(&pending); |
986 | buffered += tmp - count; | 1012 | buffered += tmp - count; |
987 | } | 1013 | } |
@@ -1008,6 +1034,7 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, | |||
1008 | __le16 fc; | 1034 | __le16 fc; |
1009 | bool qos = test_sta_flag(sta, WLAN_STA_WME); | 1035 | bool qos = test_sta_flag(sta, WLAN_STA_WME); |
1010 | struct ieee80211_tx_info *info; | 1036 | struct ieee80211_tx_info *info; |
1037 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
1011 | 1038 | ||
1012 | if (qos) { | 1039 | if (qos) { |
1013 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | | 1040 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | |
@@ -1057,7 +1084,16 @@ static void ieee80211_send_null_response(struct ieee80211_sub_if_data *sdata, | |||
1057 | 1084 | ||
1058 | drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); | 1085 | drv_allow_buffered_frames(local, sta, BIT(tid), 1, reason, false); |
1059 | 1086 | ||
1060 | ieee80211_xmit(sdata, skb); | 1087 | rcu_read_lock(); |
1088 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1089 | if (WARN_ON(!chanctx_conf)) { | ||
1090 | rcu_read_unlock(); | ||
1091 | kfree_skb(skb); | ||
1092 | return; | ||
1093 | } | ||
1094 | |||
1095 | ieee80211_xmit(sdata, skb, chanctx_conf->channel->band); | ||
1096 | rcu_read_unlock(); | ||
1061 | } | 1097 | } |
1062 | 1098 | ||
1063 | static void | 1099 | static void |
diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 3af0cc4130f1..ab63237107c8 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c | |||
@@ -189,30 +189,31 @@ static void ieee80211_frame_acked(struct sta_info *sta, struct sk_buff *skb) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | if (ieee80211_is_action(mgmt->frame_control) && | 191 | if (ieee80211_is_action(mgmt->frame_control) && |
192 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
193 | mgmt->u.action.category == WLAN_CATEGORY_HT && | 192 | mgmt->u.action.category == WLAN_CATEGORY_HT && |
194 | mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS) { | 193 | mgmt->u.action.u.ht_smps.action == WLAN_HT_ACTION_SMPS && |
194 | sdata->vif.type == NL80211_IFTYPE_STATION && | ||
195 | ieee80211_sdata_running(sdata)) { | ||
195 | /* | 196 | /* |
196 | * This update looks racy, but isn't -- if we come | 197 | * This update looks racy, but isn't -- if we come |
197 | * here we've definitely got a station that we're | 198 | * here we've definitely got a station that we're |
198 | * talking to, and on a managed interface that can | 199 | * talking to, and on a managed interface that can |
199 | * only be the AP. And the only other place updating | 200 | * only be the AP. And the only other place updating |
200 | * this variable is before we're associated. | 201 | * this variable in managed mode is before association. |
201 | */ | 202 | */ |
202 | switch (mgmt->u.action.u.ht_smps.smps_control) { | 203 | switch (mgmt->u.action.u.ht_smps.smps_control) { |
203 | case WLAN_HT_SMPS_CONTROL_DYNAMIC: | 204 | case WLAN_HT_SMPS_CONTROL_DYNAMIC: |
204 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_DYNAMIC; | 205 | sdata->smps_mode = IEEE80211_SMPS_DYNAMIC; |
205 | break; | 206 | break; |
206 | case WLAN_HT_SMPS_CONTROL_STATIC: | 207 | case WLAN_HT_SMPS_CONTROL_STATIC: |
207 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_STATIC; | 208 | sdata->smps_mode = IEEE80211_SMPS_STATIC; |
208 | break; | 209 | break; |
209 | case WLAN_HT_SMPS_CONTROL_DISABLED: | 210 | case WLAN_HT_SMPS_CONTROL_DISABLED: |
210 | default: /* shouldn't happen since we don't send that */ | 211 | default: /* shouldn't happen since we don't send that */ |
211 | sta->sdata->u.mgd.ap_smps = IEEE80211_SMPS_OFF; | 212 | sdata->smps_mode = IEEE80211_SMPS_OFF; |
212 | break; | 213 | break; |
213 | } | 214 | } |
214 | 215 | ||
215 | ieee80211_queue_work(&local->hw, &local->recalc_smps); | 216 | ieee80211_queue_work(&local->hw, &sdata->recalc_smps); |
216 | } | 217 | } |
217 | } | 218 | } |
218 | 219 | ||
@@ -324,6 +325,75 @@ static void ieee80211_add_tx_radiotap_header(struct ieee80211_supported_band | |||
324 | 325 | ||
325 | } | 326 | } |
326 | 327 | ||
328 | static void ieee80211_report_used_skb(struct ieee80211_local *local, | ||
329 | struct sk_buff *skb, bool dropped) | ||
330 | { | ||
331 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
332 | struct ieee80211_hdr *hdr = (void *)skb->data; | ||
333 | bool acked = info->flags & IEEE80211_TX_STAT_ACK; | ||
334 | |||
335 | if (dropped) | ||
336 | acked = false; | ||
337 | |||
338 | if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) { | ||
339 | struct ieee80211_sub_if_data *sdata = NULL; | ||
340 | struct ieee80211_sub_if_data *iter_sdata; | ||
341 | u64 cookie = (unsigned long)skb; | ||
342 | |||
343 | rcu_read_lock(); | ||
344 | |||
345 | if (skb->dev) { | ||
346 | list_for_each_entry_rcu(iter_sdata, &local->interfaces, | ||
347 | list) { | ||
348 | if (!iter_sdata->dev) | ||
349 | continue; | ||
350 | |||
351 | if (skb->dev == iter_sdata->dev) { | ||
352 | sdata = iter_sdata; | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | } else { | ||
357 | sdata = rcu_dereference(local->p2p_sdata); | ||
358 | } | ||
359 | |||
360 | if (!sdata) | ||
361 | skb->dev = NULL; | ||
362 | else if (ieee80211_is_nullfunc(hdr->frame_control) || | ||
363 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { | ||
364 | cfg80211_probe_status(sdata->dev, hdr->addr1, | ||
365 | cookie, acked, GFP_ATOMIC); | ||
366 | } else { | ||
367 | cfg80211_mgmt_tx_status(&sdata->wdev, cookie, skb->data, | ||
368 | skb->len, acked, GFP_ATOMIC); | ||
369 | } | ||
370 | |||
371 | rcu_read_unlock(); | ||
372 | } | ||
373 | |||
374 | if (unlikely(info->ack_frame_id)) { | ||
375 | struct sk_buff *ack_skb; | ||
376 | unsigned long flags; | ||
377 | |||
378 | spin_lock_irqsave(&local->ack_status_lock, flags); | ||
379 | ack_skb = idr_find(&local->ack_status_frames, | ||
380 | info->ack_frame_id); | ||
381 | if (ack_skb) | ||
382 | idr_remove(&local->ack_status_frames, | ||
383 | info->ack_frame_id); | ||
384 | spin_unlock_irqrestore(&local->ack_status_lock, flags); | ||
385 | |||
386 | if (ack_skb) { | ||
387 | if (!dropped) { | ||
388 | /* consumes ack_skb */ | ||
389 | skb_complete_wifi_ack(ack_skb, acked); | ||
390 | } else { | ||
391 | dev_kfree_skb_any(ack_skb); | ||
392 | } | ||
393 | } | ||
394 | } | ||
395 | } | ||
396 | |||
327 | /* | 397 | /* |
328 | * Use a static threshold for now, best value to be determined | 398 | * Use a static threshold for now, best value to be determined |
329 | * by testing ... | 399 | * by testing ... |
@@ -515,62 +585,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
515 | msecs_to_jiffies(10)); | 585 | msecs_to_jiffies(10)); |
516 | } | 586 | } |
517 | 587 | ||
518 | if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) { | 588 | ieee80211_report_used_skb(local, skb, false); |
519 | u64 cookie = (unsigned long)skb; | ||
520 | bool found = false; | ||
521 | |||
522 | acked = info->flags & IEEE80211_TX_STAT_ACK; | ||
523 | |||
524 | rcu_read_lock(); | ||
525 | |||
526 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | ||
527 | if (!sdata->dev) | ||
528 | continue; | ||
529 | |||
530 | if (skb->dev != sdata->dev) | ||
531 | continue; | ||
532 | |||
533 | found = true; | ||
534 | break; | ||
535 | } | ||
536 | |||
537 | if (!skb->dev) { | ||
538 | sdata = rcu_dereference(local->p2p_sdata); | ||
539 | if (sdata) | ||
540 | found = true; | ||
541 | } | ||
542 | |||
543 | if (!found) | ||
544 | skb->dev = NULL; | ||
545 | else if (ieee80211_is_nullfunc(hdr->frame_control) || | ||
546 | ieee80211_is_qos_nullfunc(hdr->frame_control)) { | ||
547 | cfg80211_probe_status(sdata->dev, hdr->addr1, | ||
548 | cookie, acked, GFP_ATOMIC); | ||
549 | } else { | ||
550 | cfg80211_mgmt_tx_status(&sdata->wdev, cookie, skb->data, | ||
551 | skb->len, acked, GFP_ATOMIC); | ||
552 | } | ||
553 | |||
554 | rcu_read_unlock(); | ||
555 | } | ||
556 | |||
557 | if (unlikely(info->ack_frame_id)) { | ||
558 | struct sk_buff *ack_skb; | ||
559 | unsigned long flags; | ||
560 | |||
561 | spin_lock_irqsave(&local->ack_status_lock, flags); | ||
562 | ack_skb = idr_find(&local->ack_status_frames, | ||
563 | info->ack_frame_id); | ||
564 | if (ack_skb) | ||
565 | idr_remove(&local->ack_status_frames, | ||
566 | info->ack_frame_id); | ||
567 | spin_unlock_irqrestore(&local->ack_status_lock, flags); | ||
568 | |||
569 | /* consumes ack_skb */ | ||
570 | if (ack_skb) | ||
571 | skb_complete_wifi_ack(ack_skb, | ||
572 | info->flags & IEEE80211_TX_STAT_ACK); | ||
573 | } | ||
574 | 589 | ||
575 | /* this was a transmitted frame, but now we want to reuse it */ | 590 | /* this was a transmitted frame, but now we want to reuse it */ |
576 | skb_orphan(skb); | 591 | skb_orphan(skb); |
@@ -646,25 +661,17 @@ EXPORT_SYMBOL(ieee80211_report_low_ack); | |||
646 | void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) | 661 | void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) |
647 | { | 662 | { |
648 | struct ieee80211_local *local = hw_to_local(hw); | 663 | struct ieee80211_local *local = hw_to_local(hw); |
649 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
650 | |||
651 | if (unlikely(info->ack_frame_id)) { | ||
652 | struct sk_buff *ack_skb; | ||
653 | unsigned long flags; | ||
654 | |||
655 | spin_lock_irqsave(&local->ack_status_lock, flags); | ||
656 | ack_skb = idr_find(&local->ack_status_frames, | ||
657 | info->ack_frame_id); | ||
658 | if (ack_skb) | ||
659 | idr_remove(&local->ack_status_frames, | ||
660 | info->ack_frame_id); | ||
661 | spin_unlock_irqrestore(&local->ack_status_lock, flags); | ||
662 | |||
663 | /* consumes ack_skb */ | ||
664 | if (ack_skb) | ||
665 | dev_kfree_skb_any(ack_skb); | ||
666 | } | ||
667 | 664 | ||
665 | ieee80211_report_used_skb(local, skb, true); | ||
668 | dev_kfree_skb_any(skb); | 666 | dev_kfree_skb_any(skb); |
669 | } | 667 | } |
670 | EXPORT_SYMBOL(ieee80211_free_txskb); | 668 | EXPORT_SYMBOL(ieee80211_free_txskb); |
669 | |||
670 | void ieee80211_purge_tx_queue(struct ieee80211_hw *hw, | ||
671 | struct sk_buff_head *skbs) | ||
672 | { | ||
673 | struct sk_buff *skb; | ||
674 | |||
675 | while ((skb = __skb_dequeue(skbs))) | ||
676 | ieee80211_free_txskb(hw, skb); | ||
677 | } | ||
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index 18d9c8a52e9e..758836c85a80 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h | |||
@@ -28,6 +28,20 @@ | |||
28 | #define VIF_PR_FMT " vif:%s(%d%s)" | 28 | #define VIF_PR_FMT " vif:%s(%d%s)" |
29 | #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" | 29 | #define VIF_PR_ARG __get_str(vif_name), __entry->vif_type, __entry->p2p ? "/p2p" : "" |
30 | 30 | ||
31 | #define CHANCTX_ENTRY __field(int, freq) \ | ||
32 | __field(int, chantype) \ | ||
33 | __field(u8, rx_chains_static) \ | ||
34 | __field(u8, rx_chains_dynamic) | ||
35 | #define CHANCTX_ASSIGN __entry->freq = ctx->conf.channel->center_freq; \ | ||
36 | __entry->chantype = ctx->conf.channel_type; \ | ||
37 | __entry->rx_chains_static = ctx->conf.rx_chains_static; \ | ||
38 | __entry->rx_chains_dynamic = ctx->conf.rx_chains_dynamic | ||
39 | #define CHANCTX_PR_FMT " freq:%d MHz chantype:%d chains:%d/%d" | ||
40 | #define CHANCTX_PR_ARG __entry->freq, __entry->chantype, \ | ||
41 | __entry->rx_chains_static, __entry->rx_chains_dynamic | ||
42 | |||
43 | |||
44 | |||
31 | /* | 45 | /* |
32 | * Tracing for driver callbacks. | 46 | * Tracing for driver callbacks. |
33 | */ | 47 | */ |
@@ -301,20 +315,36 @@ TRACE_EVENT(drv_bss_info_changed, | |||
301 | TP_STRUCT__entry( | 315 | TP_STRUCT__entry( |
302 | LOCAL_ENTRY | 316 | LOCAL_ENTRY |
303 | VIF_ENTRY | 317 | VIF_ENTRY |
318 | __field(u32, changed) | ||
304 | __field(bool, assoc) | 319 | __field(bool, assoc) |
320 | __field(bool, ibss_joined) | ||
321 | __field(bool, ibss_creator) | ||
305 | __field(u16, aid) | 322 | __field(u16, aid) |
306 | __field(bool, cts) | 323 | __field(bool, cts) |
307 | __field(bool, shortpre) | 324 | __field(bool, shortpre) |
308 | __field(bool, shortslot) | 325 | __field(bool, shortslot) |
326 | __field(bool, enable_beacon) | ||
309 | __field(u8, dtimper) | 327 | __field(u8, dtimper) |
310 | __field(u16, bcnint) | 328 | __field(u16, bcnint) |
311 | __field(u16, assoc_cap) | 329 | __field(u16, assoc_cap) |
312 | __field(u64, sync_tsf) | 330 | __field(u64, sync_tsf) |
313 | __field(u32, sync_device_ts) | 331 | __field(u32, sync_device_ts) |
314 | __field(u32, basic_rates) | 332 | __field(u32, basic_rates) |
315 | __field(u32, changed) | 333 | __array(int, mcast_rate, IEEE80211_NUM_BANDS) |
316 | __field(bool, enable_beacon) | ||
317 | __field(u16, ht_operation_mode) | 334 | __field(u16, ht_operation_mode) |
335 | __field(s32, cqm_rssi_thold); | ||
336 | __field(s32, cqm_rssi_hyst); | ||
337 | __field(u32, channel_type); | ||
338 | __dynamic_array(u32, arp_addr_list, info->arp_addr_cnt); | ||
339 | __field(bool, arp_filter_enabled); | ||
340 | __field(bool, qos); | ||
341 | __field(bool, idle); | ||
342 | __field(bool, ps); | ||
343 | __dynamic_array(u8, ssid, info->ssid_len); | ||
344 | __field(bool, hidden_ssid); | ||
345 | __field(int, txpower) | ||
346 | __field(u8, p2p_ctwindow) | ||
347 | __field(bool, p2p_oppps) | ||
318 | ), | 348 | ), |
319 | 349 | ||
320 | TP_fast_assign( | 350 | TP_fast_assign( |
@@ -323,17 +353,35 @@ TRACE_EVENT(drv_bss_info_changed, | |||
323 | __entry->changed = changed; | 353 | __entry->changed = changed; |
324 | __entry->aid = info->aid; | 354 | __entry->aid = info->aid; |
325 | __entry->assoc = info->assoc; | 355 | __entry->assoc = info->assoc; |
356 | __entry->ibss_joined = info->ibss_joined; | ||
357 | __entry->ibss_creator = info->ibss_creator; | ||
326 | __entry->shortpre = info->use_short_preamble; | 358 | __entry->shortpre = info->use_short_preamble; |
327 | __entry->cts = info->use_cts_prot; | 359 | __entry->cts = info->use_cts_prot; |
328 | __entry->shortslot = info->use_short_slot; | 360 | __entry->shortslot = info->use_short_slot; |
361 | __entry->enable_beacon = info->enable_beacon; | ||
329 | __entry->dtimper = info->dtim_period; | 362 | __entry->dtimper = info->dtim_period; |
330 | __entry->bcnint = info->beacon_int; | 363 | __entry->bcnint = info->beacon_int; |
331 | __entry->assoc_cap = info->assoc_capability; | 364 | __entry->assoc_cap = info->assoc_capability; |
332 | __entry->sync_tsf = info->sync_tsf; | 365 | __entry->sync_tsf = info->sync_tsf; |
333 | __entry->sync_device_ts = info->sync_device_ts; | 366 | __entry->sync_device_ts = info->sync_device_ts; |
334 | __entry->basic_rates = info->basic_rates; | 367 | __entry->basic_rates = info->basic_rates; |
335 | __entry->enable_beacon = info->enable_beacon; | 368 | memcpy(__entry->mcast_rate, info->mcast_rate, |
369 | sizeof(__entry->mcast_rate)); | ||
336 | __entry->ht_operation_mode = info->ht_operation_mode; | 370 | __entry->ht_operation_mode = info->ht_operation_mode; |
371 | __entry->cqm_rssi_thold = info->cqm_rssi_thold; | ||
372 | __entry->cqm_rssi_hyst = info->cqm_rssi_hyst; | ||
373 | __entry->channel_type = info->channel_type; | ||
374 | memcpy(__get_dynamic_array(arp_addr_list), info->arp_addr_list, | ||
375 | sizeof(u32) * info->arp_addr_cnt); | ||
376 | __entry->arp_filter_enabled = info->arp_filter_enabled; | ||
377 | __entry->qos = info->qos; | ||
378 | __entry->idle = info->idle; | ||
379 | __entry->ps = info->ps; | ||
380 | memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len); | ||
381 | __entry->hidden_ssid = info->hidden_ssid; | ||
382 | __entry->txpower = info->txpower; | ||
383 | __entry->p2p_ctwindow = info->p2p_ctwindow; | ||
384 | __entry->p2p_oppps = info->p2p_oppps; | ||
337 | ), | 385 | ), |
338 | 386 | ||
339 | TP_printk( | 387 | TP_printk( |
@@ -1001,34 +1049,6 @@ DEFINE_EVENT(local_only_evt, drv_cancel_remain_on_channel, | |||
1001 | TP_ARGS(local) | 1049 | TP_ARGS(local) |
1002 | ); | 1050 | ); |
1003 | 1051 | ||
1004 | TRACE_EVENT(drv_offchannel_tx, | ||
1005 | TP_PROTO(struct ieee80211_local *local, struct sk_buff *skb, | ||
1006 | struct ieee80211_channel *chan, | ||
1007 | enum nl80211_channel_type channel_type, | ||
1008 | unsigned int wait), | ||
1009 | |||
1010 | TP_ARGS(local, skb, chan, channel_type, wait), | ||
1011 | |||
1012 | TP_STRUCT__entry( | ||
1013 | LOCAL_ENTRY | ||
1014 | __field(int, center_freq) | ||
1015 | __field(int, channel_type) | ||
1016 | __field(unsigned int, wait) | ||
1017 | ), | ||
1018 | |||
1019 | TP_fast_assign( | ||
1020 | LOCAL_ASSIGN; | ||
1021 | __entry->center_freq = chan->center_freq; | ||
1022 | __entry->channel_type = channel_type; | ||
1023 | __entry->wait = wait; | ||
1024 | ), | ||
1025 | |||
1026 | TP_printk( | ||
1027 | LOCAL_PR_FMT " freq:%dMHz, wait:%dms", | ||
1028 | LOCAL_PR_ARG, __entry->center_freq, __entry->wait | ||
1029 | ) | ||
1030 | ); | ||
1031 | |||
1032 | TRACE_EVENT(drv_set_ringparam, | 1052 | TRACE_EVENT(drv_set_ringparam, |
1033 | TP_PROTO(struct ieee80211_local *local, u32 tx, u32 rx), | 1053 | TP_PROTO(struct ieee80211_local *local, u32 tx, u32 rx), |
1034 | 1054 | ||
@@ -1256,6 +1276,146 @@ DEFINE_EVENT(local_sdata_evt, drv_mgd_prepare_tx, | |||
1256 | TP_ARGS(local, sdata) | 1276 | TP_ARGS(local, sdata) |
1257 | ); | 1277 | ); |
1258 | 1278 | ||
1279 | DECLARE_EVENT_CLASS(local_chanctx, | ||
1280 | TP_PROTO(struct ieee80211_local *local, | ||
1281 | struct ieee80211_chanctx *ctx), | ||
1282 | |||
1283 | TP_ARGS(local, ctx), | ||
1284 | |||
1285 | TP_STRUCT__entry( | ||
1286 | LOCAL_ENTRY | ||
1287 | CHANCTX_ENTRY | ||
1288 | ), | ||
1289 | |||
1290 | TP_fast_assign( | ||
1291 | LOCAL_ASSIGN; | ||
1292 | CHANCTX_ASSIGN; | ||
1293 | ), | ||
1294 | |||
1295 | TP_printk( | ||
1296 | LOCAL_PR_FMT CHANCTX_PR_FMT, | ||
1297 | LOCAL_PR_ARG, CHANCTX_PR_ARG | ||
1298 | ) | ||
1299 | ); | ||
1300 | |||
1301 | DEFINE_EVENT(local_chanctx, drv_add_chanctx, | ||
1302 | TP_PROTO(struct ieee80211_local *local, | ||
1303 | struct ieee80211_chanctx *ctx), | ||
1304 | TP_ARGS(local, ctx) | ||
1305 | ); | ||
1306 | |||
1307 | DEFINE_EVENT(local_chanctx, drv_remove_chanctx, | ||
1308 | TP_PROTO(struct ieee80211_local *local, | ||
1309 | struct ieee80211_chanctx *ctx), | ||
1310 | TP_ARGS(local, ctx) | ||
1311 | ); | ||
1312 | |||
1313 | TRACE_EVENT(drv_change_chanctx, | ||
1314 | TP_PROTO(struct ieee80211_local *local, | ||
1315 | struct ieee80211_chanctx *ctx, | ||
1316 | u32 changed), | ||
1317 | |||
1318 | TP_ARGS(local, ctx, changed), | ||
1319 | |||
1320 | TP_STRUCT__entry( | ||
1321 | LOCAL_ENTRY | ||
1322 | CHANCTX_ENTRY | ||
1323 | __field(u32, changed) | ||
1324 | ), | ||
1325 | |||
1326 | TP_fast_assign( | ||
1327 | LOCAL_ASSIGN; | ||
1328 | CHANCTX_ASSIGN; | ||
1329 | __entry->changed = changed; | ||
1330 | ), | ||
1331 | |||
1332 | TP_printk( | ||
1333 | LOCAL_PR_FMT CHANCTX_PR_FMT " changed:%#x", | ||
1334 | LOCAL_PR_ARG, CHANCTX_PR_ARG, __entry->changed | ||
1335 | ) | ||
1336 | ); | ||
1337 | |||
1338 | DECLARE_EVENT_CLASS(local_sdata_chanctx, | ||
1339 | TP_PROTO(struct ieee80211_local *local, | ||
1340 | struct ieee80211_sub_if_data *sdata, | ||
1341 | struct ieee80211_chanctx *ctx), | ||
1342 | |||
1343 | TP_ARGS(local, sdata, ctx), | ||
1344 | |||
1345 | TP_STRUCT__entry( | ||
1346 | LOCAL_ENTRY | ||
1347 | VIF_ENTRY | ||
1348 | CHANCTX_ENTRY | ||
1349 | ), | ||
1350 | |||
1351 | TP_fast_assign( | ||
1352 | LOCAL_ASSIGN; | ||
1353 | VIF_ASSIGN; | ||
1354 | CHANCTX_ASSIGN; | ||
1355 | ), | ||
1356 | |||
1357 | TP_printk( | ||
1358 | LOCAL_PR_FMT VIF_PR_FMT CHANCTX_PR_FMT, | ||
1359 | LOCAL_PR_ARG, VIF_PR_ARG, CHANCTX_PR_ARG | ||
1360 | ) | ||
1361 | ); | ||
1362 | |||
1363 | DEFINE_EVENT(local_sdata_chanctx, drv_assign_vif_chanctx, | ||
1364 | TP_PROTO(struct ieee80211_local *local, | ||
1365 | struct ieee80211_sub_if_data *sdata, | ||
1366 | struct ieee80211_chanctx *ctx), | ||
1367 | TP_ARGS(local, sdata, ctx) | ||
1368 | ); | ||
1369 | |||
1370 | DEFINE_EVENT(local_sdata_chanctx, drv_unassign_vif_chanctx, | ||
1371 | TP_PROTO(struct ieee80211_local *local, | ||
1372 | struct ieee80211_sub_if_data *sdata, | ||
1373 | struct ieee80211_chanctx *ctx), | ||
1374 | TP_ARGS(local, sdata, ctx) | ||
1375 | ); | ||
1376 | |||
1377 | TRACE_EVENT(drv_start_ap, | ||
1378 | TP_PROTO(struct ieee80211_local *local, | ||
1379 | struct ieee80211_sub_if_data *sdata, | ||
1380 | struct ieee80211_bss_conf *info), | ||
1381 | |||
1382 | TP_ARGS(local, sdata, info), | ||
1383 | |||
1384 | TP_STRUCT__entry( | ||
1385 | LOCAL_ENTRY | ||
1386 | VIF_ENTRY | ||
1387 | __field(u8, dtimper) | ||
1388 | __field(u16, bcnint) | ||
1389 | __dynamic_array(u8, ssid, info->ssid_len); | ||
1390 | __field(bool, hidden_ssid); | ||
1391 | ), | ||
1392 | |||
1393 | TP_fast_assign( | ||
1394 | LOCAL_ASSIGN; | ||
1395 | VIF_ASSIGN; | ||
1396 | __entry->dtimper = info->dtim_period; | ||
1397 | __entry->bcnint = info->beacon_int; | ||
1398 | memcpy(__get_dynamic_array(ssid), info->ssid, info->ssid_len); | ||
1399 | __entry->hidden_ssid = info->hidden_ssid; | ||
1400 | ), | ||
1401 | |||
1402 | TP_printk( | ||
1403 | LOCAL_PR_FMT VIF_PR_FMT, | ||
1404 | LOCAL_PR_ARG, VIF_PR_ARG | ||
1405 | ) | ||
1406 | ); | ||
1407 | |||
1408 | DEFINE_EVENT(local_sdata_evt, drv_stop_ap, | ||
1409 | TP_PROTO(struct ieee80211_local *local, | ||
1410 | struct ieee80211_sub_if_data *sdata), | ||
1411 | TP_ARGS(local, sdata) | ||
1412 | ); | ||
1413 | |||
1414 | DEFINE_EVENT(local_only_evt, drv_restart_complete, | ||
1415 | TP_PROTO(struct ieee80211_local *local), | ||
1416 | TP_ARGS(local) | ||
1417 | ); | ||
1418 | |||
1259 | /* | 1419 | /* |
1260 | * Tracing for API calls that drivers call. | 1420 | * Tracing for API calls that drivers call. |
1261 | */ | 1421 | */ |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index c9bf83f36657..04076250264b 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -324,22 +324,20 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
324 | struct ieee80211_sub_if_data *sdata; | 324 | struct ieee80211_sub_if_data *sdata; |
325 | struct sta_info *sta; | 325 | struct sta_info *sta; |
326 | 326 | ||
327 | /* | ||
328 | * virtual interfaces are protected by RCU | ||
329 | */ | ||
330 | rcu_read_lock(); | ||
331 | |||
332 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { | 327 | list_for_each_entry_rcu(sdata, &local->interfaces, list) { |
333 | struct ieee80211_if_ap *ap; | 328 | struct ps_data *ps; |
334 | if (sdata->vif.type != NL80211_IFTYPE_AP) | 329 | |
330 | if (sdata->vif.type == NL80211_IFTYPE_AP) | ||
331 | ps = &sdata->u.ap.ps; | ||
332 | else | ||
335 | continue; | 333 | continue; |
336 | ap = &sdata->u.ap; | 334 | |
337 | skb = skb_dequeue(&ap->ps_bc_buf); | 335 | skb = skb_dequeue(&ps->bc_buf); |
338 | if (skb) { | 336 | if (skb) { |
339 | purged++; | 337 | purged++; |
340 | dev_kfree_skb(skb); | 338 | dev_kfree_skb(skb); |
341 | } | 339 | } |
342 | total += skb_queue_len(&ap->ps_bc_buf); | 340 | total += skb_queue_len(&ps->bc_buf); |
343 | } | 341 | } |
344 | 342 | ||
345 | /* | 343 | /* |
@@ -360,8 +358,6 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
360 | } | 358 | } |
361 | } | 359 | } |
362 | 360 | ||
363 | rcu_read_unlock(); | ||
364 | |||
365 | local->total_ps_buffered = total; | 361 | local->total_ps_buffered = total; |
366 | ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); | 362 | ps_dbg_hw(&local->hw, "PS buffers full - purged %d frames\n", purged); |
367 | } | 363 | } |
@@ -371,6 +367,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
371 | { | 367 | { |
372 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 368 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
373 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | 369 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; |
370 | struct ps_data *ps; | ||
374 | 371 | ||
375 | /* | 372 | /* |
376 | * broadcast/multicast frame | 373 | * broadcast/multicast frame |
@@ -380,16 +377,24 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
380 | * This is done either by the hardware or us. | 377 | * This is done either by the hardware or us. |
381 | */ | 378 | */ |
382 | 379 | ||
383 | /* powersaving STAs only in AP/VLAN mode */ | 380 | /* powersaving STAs currently only in AP/VLAN mode */ |
384 | if (!tx->sdata->bss) | 381 | if (tx->sdata->vif.type == NL80211_IFTYPE_AP || |
382 | tx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { | ||
383 | if (!tx->sdata->bss) | ||
384 | return TX_CONTINUE; | ||
385 | |||
386 | ps = &tx->sdata->bss->ps; | ||
387 | } else { | ||
385 | return TX_CONTINUE; | 388 | return TX_CONTINUE; |
389 | } | ||
390 | |||
386 | 391 | ||
387 | /* no buffering for ordered frames */ | 392 | /* no buffering for ordered frames */ |
388 | if (ieee80211_has_order(hdr->frame_control)) | 393 | if (ieee80211_has_order(hdr->frame_control)) |
389 | return TX_CONTINUE; | 394 | return TX_CONTINUE; |
390 | 395 | ||
391 | /* no stations in PS mode */ | 396 | /* no stations in PS mode */ |
392 | if (!atomic_read(&tx->sdata->bss->num_sta_ps)) | 397 | if (!atomic_read(&ps->num_sta_ps)) |
393 | return TX_CONTINUE; | 398 | return TX_CONTINUE; |
394 | 399 | ||
395 | info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; | 400 | info->flags |= IEEE80211_TX_CTL_SEND_AFTER_DTIM; |
@@ -404,14 +409,14 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
404 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | 409 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
405 | purge_old_ps_buffers(tx->local); | 410 | purge_old_ps_buffers(tx->local); |
406 | 411 | ||
407 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= AP_MAX_BC_BUFFER) { | 412 | if (skb_queue_len(&ps->bc_buf) >= AP_MAX_BC_BUFFER) { |
408 | ps_dbg(tx->sdata, | 413 | ps_dbg(tx->sdata, |
409 | "BC TX buffer full - dropping the oldest frame\n"); | 414 | "BC TX buffer full - dropping the oldest frame\n"); |
410 | dev_kfree_skb(skb_dequeue(&tx->sdata->bss->ps_bc_buf)); | 415 | dev_kfree_skb(skb_dequeue(&ps->bc_buf)); |
411 | } else | 416 | } else |
412 | tx->local->total_ps_buffered++; | 417 | tx->local->total_ps_buffered++; |
413 | 418 | ||
414 | skb_queue_tail(&tx->sdata->bss->ps_bc_buf, tx->skb); | 419 | skb_queue_tail(&ps->bc_buf, tx->skb); |
415 | 420 | ||
416 | return TX_QUEUED; | 421 | return TX_QUEUED; |
417 | } | 422 | } |
@@ -951,7 +956,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
951 | fragnum = 0; | 956 | fragnum = 0; |
952 | 957 | ||
953 | skb_queue_walk(&tx->skbs, skb) { | 958 | skb_queue_walk(&tx->skbs, skb) { |
954 | int next_len; | ||
955 | const __le16 morefrags = cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); | 959 | const __le16 morefrags = cpu_to_le16(IEEE80211_FCTL_MOREFRAGS); |
956 | 960 | ||
957 | hdr = (void *)skb->data; | 961 | hdr = (void *)skb->data; |
@@ -970,7 +974,6 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
970 | info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; | 974 | info->flags &= ~IEEE80211_TX_CTL_RATE_CTRL_PROBE; |
971 | } else { | 975 | } else { |
972 | hdr->frame_control &= ~morefrags; | 976 | hdr->frame_control &= ~morefrags; |
973 | next_len = 0; | ||
974 | } | 977 | } |
975 | hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); | 978 | hdr->seq_ctrl |= cpu_to_le16(fragnum & IEEE80211_SCTL_FRAG); |
976 | fragnum++; | 979 | fragnum++; |
@@ -1358,7 +1361,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1358 | if (tx->skb) | 1361 | if (tx->skb) |
1359 | ieee80211_free_txskb(&tx->local->hw, tx->skb); | 1362 | ieee80211_free_txskb(&tx->local->hw, tx->skb); |
1360 | else | 1363 | else |
1361 | __skb_queue_purge(&tx->skbs); | 1364 | ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs); |
1362 | return -1; | 1365 | return -1; |
1363 | } else if (unlikely(res == TX_QUEUED)) { | 1366 | } else if (unlikely(res == TX_QUEUED)) { |
1364 | I802_DEBUG_INC(tx->local->tx_handlers_queued); | 1367 | I802_DEBUG_INC(tx->local->tx_handlers_queued); |
@@ -1372,7 +1375,8 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx) | |||
1372 | * Returns false if the frame couldn't be transmitted but was queued instead. | 1375 | * Returns false if the frame couldn't be transmitted but was queued instead. |
1373 | */ | 1376 | */ |
1374 | static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, | 1377 | static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, |
1375 | struct sk_buff *skb, bool txpending) | 1378 | struct sk_buff *skb, bool txpending, |
1379 | enum ieee80211_band band) | ||
1376 | { | 1380 | { |
1377 | struct ieee80211_local *local = sdata->local; | 1381 | struct ieee80211_local *local = sdata->local; |
1378 | struct ieee80211_tx_data tx; | 1382 | struct ieee80211_tx_data tx; |
@@ -1386,20 +1390,18 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, | |||
1386 | return true; | 1390 | return true; |
1387 | } | 1391 | } |
1388 | 1392 | ||
1389 | rcu_read_lock(); | ||
1390 | |||
1391 | /* initialises tx */ | 1393 | /* initialises tx */ |
1392 | led_len = skb->len; | 1394 | led_len = skb->len; |
1393 | res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); | 1395 | res_prepare = ieee80211_tx_prepare(sdata, &tx, skb); |
1394 | 1396 | ||
1395 | if (unlikely(res_prepare == TX_DROP)) { | 1397 | if (unlikely(res_prepare == TX_DROP)) { |
1396 | ieee80211_free_txskb(&local->hw, skb); | 1398 | ieee80211_free_txskb(&local->hw, skb); |
1397 | goto out; | 1399 | return true; |
1398 | } else if (unlikely(res_prepare == TX_QUEUED)) { | 1400 | } else if (unlikely(res_prepare == TX_QUEUED)) { |
1399 | goto out; | 1401 | return true; |
1400 | } | 1402 | } |
1401 | 1403 | ||
1402 | info->band = local->hw.conf.channel->band; | 1404 | info->band = band; |
1403 | 1405 | ||
1404 | /* set up hw_queue value early */ | 1406 | /* set up hw_queue value early */ |
1405 | if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || | 1407 | if (!(info->flags & IEEE80211_TX_CTL_TX_OFFCHAN) || |
@@ -1410,8 +1412,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata, | |||
1410 | if (!invoke_tx_handlers(&tx)) | 1412 | if (!invoke_tx_handlers(&tx)) |
1411 | result = __ieee80211_tx(local, &tx.skbs, led_len, | 1413 | result = __ieee80211_tx(local, &tx.skbs, led_len, |
1412 | tx.sta, txpending); | 1414 | tx.sta, txpending); |
1413 | out: | 1415 | |
1414 | rcu_read_unlock(); | ||
1415 | return result; | 1416 | return result; |
1416 | } | 1417 | } |
1417 | 1418 | ||
@@ -1446,7 +1447,8 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata, | |||
1446 | return 0; | 1447 | return 0; |
1447 | } | 1448 | } |
1448 | 1449 | ||
1449 | void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | 1450 | void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, |
1451 | enum ieee80211_band band) | ||
1450 | { | 1452 | { |
1451 | struct ieee80211_local *local = sdata->local; | 1453 | struct ieee80211_local *local = sdata->local; |
1452 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1454 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
@@ -1454,8 +1456,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | |||
1454 | int headroom; | 1456 | int headroom; |
1455 | bool may_encrypt; | 1457 | bool may_encrypt; |
1456 | 1458 | ||
1457 | rcu_read_lock(); | ||
1458 | |||
1459 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); | 1459 | may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT); |
1460 | 1460 | ||
1461 | headroom = local->tx_headroom; | 1461 | headroom = local->tx_headroom; |
@@ -1466,7 +1466,6 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | |||
1466 | 1466 | ||
1467 | if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { | 1467 | if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) { |
1468 | ieee80211_free_txskb(&local->hw, skb); | 1468 | ieee80211_free_txskb(&local->hw, skb); |
1469 | rcu_read_unlock(); | ||
1470 | return; | 1469 | return; |
1471 | } | 1470 | } |
1472 | 1471 | ||
@@ -1478,13 +1477,11 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) | |||
1478 | !is_multicast_ether_addr(hdr->addr1) && | 1477 | !is_multicast_ether_addr(hdr->addr1) && |
1479 | mesh_nexthop_resolve(skb, sdata)) { | 1478 | mesh_nexthop_resolve(skb, sdata)) { |
1480 | /* skb queued: don't free */ | 1479 | /* skb queued: don't free */ |
1481 | rcu_read_unlock(); | ||
1482 | return; | 1480 | return; |
1483 | } | 1481 | } |
1484 | 1482 | ||
1485 | ieee80211_set_qos_hdr(sdata, skb); | 1483 | ieee80211_set_qos_hdr(sdata, skb); |
1486 | ieee80211_tx(sdata, skb, false); | 1484 | ieee80211_tx(sdata, skb, false, band); |
1487 | rcu_read_unlock(); | ||
1488 | } | 1485 | } |
1489 | 1486 | ||
1490 | static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) | 1487 | static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) |
@@ -1574,7 +1571,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1574 | struct net_device *dev) | 1571 | struct net_device *dev) |
1575 | { | 1572 | { |
1576 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1573 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1577 | struct ieee80211_channel *chan = local->hw.conf.channel; | 1574 | struct ieee80211_chanctx_conf *chanctx_conf; |
1575 | struct ieee80211_channel *chan; | ||
1578 | struct ieee80211_radiotap_header *prthdr = | 1576 | struct ieee80211_radiotap_header *prthdr = |
1579 | (struct ieee80211_radiotap_header *)skb->data; | 1577 | (struct ieee80211_radiotap_header *)skb->data; |
1580 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1578 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
@@ -1583,26 +1581,6 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1583 | u16 len_rthdr; | 1581 | u16 len_rthdr; |
1584 | int hdrlen; | 1582 | int hdrlen; |
1585 | 1583 | ||
1586 | /* | ||
1587 | * Frame injection is not allowed if beaconing is not allowed | ||
1588 | * or if we need radar detection. Beaconing is usually not allowed when | ||
1589 | * the mode or operation (Adhoc, AP, Mesh) does not support DFS. | ||
1590 | * Passive scan is also used in world regulatory domains where | ||
1591 | * your country is not known and as such it should be treated as | ||
1592 | * NO TX unless the channel is explicitly allowed in which case | ||
1593 | * your current regulatory domain would not have the passive scan | ||
1594 | * flag. | ||
1595 | * | ||
1596 | * Since AP mode uses monitor interfaces to inject/TX management | ||
1597 | * frames we can make AP mode the exception to this rule once it | ||
1598 | * supports radar detection as its implementation can deal with | ||
1599 | * radar detection by itself. We can do that later by adding a | ||
1600 | * monitor flag interfaces used for AP support. | ||
1601 | */ | ||
1602 | if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR | | ||
1603 | IEEE80211_CHAN_PASSIVE_SCAN))) | ||
1604 | goto fail; | ||
1605 | |||
1606 | /* check for not even having the fixed radiotap header part */ | 1584 | /* check for not even having the fixed radiotap header part */ |
1607 | if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) | 1585 | if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) |
1608 | goto fail; /* too short to be possibly valid */ | 1586 | goto fail; /* too short to be possibly valid */ |
@@ -1688,11 +1666,45 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1688 | } | 1666 | } |
1689 | } | 1667 | } |
1690 | 1668 | ||
1691 | ieee80211_xmit(sdata, skb); | 1669 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
1670 | if (!chanctx_conf) { | ||
1671 | tmp_sdata = rcu_dereference(local->monitor_sdata); | ||
1672 | if (tmp_sdata) | ||
1673 | chanctx_conf = | ||
1674 | rcu_dereference(tmp_sdata->vif.chanctx_conf); | ||
1675 | } | ||
1676 | if (!chanctx_conf) | ||
1677 | goto fail_rcu; | ||
1678 | |||
1679 | chan = chanctx_conf->channel; | ||
1680 | |||
1681 | /* | ||
1682 | * Frame injection is not allowed if beaconing is not allowed | ||
1683 | * or if we need radar detection. Beaconing is usually not allowed when | ||
1684 | * the mode or operation (Adhoc, AP, Mesh) does not support DFS. | ||
1685 | * Passive scan is also used in world regulatory domains where | ||
1686 | * your country is not known and as such it should be treated as | ||
1687 | * NO TX unless the channel is explicitly allowed in which case | ||
1688 | * your current regulatory domain would not have the passive scan | ||
1689 | * flag. | ||
1690 | * | ||
1691 | * Since AP mode uses monitor interfaces to inject/TX management | ||
1692 | * frames we can make AP mode the exception to this rule once it | ||
1693 | * supports radar detection as its implementation can deal with | ||
1694 | * radar detection by itself. We can do that later by adding a | ||
1695 | * monitor flag interfaces used for AP support. | ||
1696 | */ | ||
1697 | if ((chan->flags & (IEEE80211_CHAN_NO_IBSS | IEEE80211_CHAN_RADAR | | ||
1698 | IEEE80211_CHAN_PASSIVE_SCAN))) | ||
1699 | goto fail_rcu; | ||
1700 | |||
1701 | ieee80211_xmit(sdata, skb, chan->band); | ||
1692 | rcu_read_unlock(); | 1702 | rcu_read_unlock(); |
1693 | 1703 | ||
1694 | return NETDEV_TX_OK; | 1704 | return NETDEV_TX_OK; |
1695 | 1705 | ||
1706 | fail_rcu: | ||
1707 | rcu_read_unlock(); | ||
1696 | fail: | 1708 | fail: |
1697 | dev_kfree_skb(skb); | 1709 | dev_kfree_skb(skb); |
1698 | return NETDEV_TX_OK; /* meaning, we dealt with the skb */ | 1710 | return NETDEV_TX_OK; /* meaning, we dealt with the skb */ |
@@ -1734,6 +1746,9 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1734 | bool multicast; | 1746 | bool multicast; |
1735 | u32 info_flags = 0; | 1747 | u32 info_flags = 0; |
1736 | u16 info_id = 0; | 1748 | u16 info_id = 0; |
1749 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
1750 | struct ieee80211_sub_if_data *ap_sdata; | ||
1751 | enum ieee80211_band band; | ||
1737 | 1752 | ||
1738 | if (unlikely(skb->len < ETH_HLEN)) | 1753 | if (unlikely(skb->len < ETH_HLEN)) |
1739 | goto fail; | 1754 | goto fail; |
@@ -1743,9 +1758,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1743 | ethertype = (skb->data[12] << 8) | skb->data[13]; | 1758 | ethertype = (skb->data[12] << 8) | skb->data[13]; |
1744 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); | 1759 | fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA); |
1745 | 1760 | ||
1761 | rcu_read_lock(); | ||
1762 | |||
1746 | switch (sdata->vif.type) { | 1763 | switch (sdata->vif.type) { |
1747 | case NL80211_IFTYPE_AP_VLAN: | 1764 | case NL80211_IFTYPE_AP_VLAN: |
1748 | rcu_read_lock(); | ||
1749 | sta = rcu_dereference(sdata->u.vlan.sta); | 1765 | sta = rcu_dereference(sdata->u.vlan.sta); |
1750 | if (sta) { | 1766 | if (sta) { |
1751 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1767 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
@@ -1758,7 +1774,12 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1758 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); | 1774 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); |
1759 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); | 1775 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); |
1760 | } | 1776 | } |
1761 | rcu_read_unlock(); | 1777 | ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, |
1778 | u.ap); | ||
1779 | chanctx_conf = rcu_dereference(ap_sdata->vif.chanctx_conf); | ||
1780 | if (!chanctx_conf) | ||
1781 | goto fail_rcu; | ||
1782 | band = chanctx_conf->channel->band; | ||
1762 | if (sta) | 1783 | if (sta) |
1763 | break; | 1784 | break; |
1764 | /* fall through */ | 1785 | /* fall through */ |
@@ -1769,6 +1790,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1769 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); | 1790 | memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN); |
1770 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); | 1791 | memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN); |
1771 | hdrlen = 24; | 1792 | hdrlen = 24; |
1793 | if (sdata->vif.type == NL80211_IFTYPE_AP) | ||
1794 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1795 | if (!chanctx_conf) | ||
1796 | goto fail_rcu; | ||
1797 | band = chanctx_conf->channel->band; | ||
1772 | break; | 1798 | break; |
1773 | case NL80211_IFTYPE_WDS: | 1799 | case NL80211_IFTYPE_WDS: |
1774 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1800 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
@@ -1778,15 +1804,20 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1778 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1804 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1779 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1805 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1780 | hdrlen = 30; | 1806 | hdrlen = 30; |
1807 | /* | ||
1808 | * This is the exception! WDS style interfaces are prohibited | ||
1809 | * when channel contexts are in used so this must be valid | ||
1810 | */ | ||
1811 | band = local->hw.conf.channel->band; | ||
1781 | break; | 1812 | break; |
1782 | #ifdef CONFIG_MAC80211_MESH | 1813 | #ifdef CONFIG_MAC80211_MESH |
1783 | case NL80211_IFTYPE_MESH_POINT: | 1814 | case NL80211_IFTYPE_MESH_POINT: |
1784 | if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { | 1815 | if (!sdata->u.mesh.mshcfg.dot11MeshTTL) { |
1785 | /* Do not send frames with mesh_ttl == 0 */ | 1816 | /* Do not send frames with mesh_ttl == 0 */ |
1786 | sdata->u.mesh.mshstats.dropped_frames_ttl++; | 1817 | sdata->u.mesh.mshstats.dropped_frames_ttl++; |
1787 | goto fail; | 1818 | goto fail_rcu; |
1788 | } | 1819 | } |
1789 | rcu_read_lock(); | 1820 | |
1790 | if (!is_multicast_ether_addr(skb->data)) { | 1821 | if (!is_multicast_ether_addr(skb->data)) { |
1791 | mpath = mesh_path_lookup(skb->data, sdata); | 1822 | mpath = mesh_path_lookup(skb->data, sdata); |
1792 | if (!mpath) | 1823 | if (!mpath) |
@@ -1803,7 +1834,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1803 | !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { | 1834 | !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { |
1804 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, | 1835 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, |
1805 | skb->data, skb->data + ETH_ALEN); | 1836 | skb->data, skb->data + ETH_ALEN); |
1806 | rcu_read_unlock(); | ||
1807 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, | 1837 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, |
1808 | sdata, NULL, NULL); | 1838 | sdata, NULL, NULL); |
1809 | } else { | 1839 | } else { |
@@ -1819,7 +1849,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1819 | mesh_da = mppath->mpp; | 1849 | mesh_da = mppath->mpp; |
1820 | else if (mpath) | 1850 | else if (mpath) |
1821 | mesh_da = mpath->dst; | 1851 | mesh_da = mpath->dst; |
1822 | rcu_read_unlock(); | ||
1823 | 1852 | ||
1824 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, | 1853 | hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, |
1825 | mesh_da, sdata->vif.addr); | 1854 | mesh_da, sdata->vif.addr); |
@@ -1839,13 +1868,16 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1839 | skb->data + ETH_ALEN); | 1868 | skb->data + ETH_ALEN); |
1840 | 1869 | ||
1841 | } | 1870 | } |
1871 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1872 | if (!chanctx_conf) | ||
1873 | goto fail_rcu; | ||
1874 | band = chanctx_conf->channel->band; | ||
1842 | break; | 1875 | break; |
1843 | #endif | 1876 | #endif |
1844 | case NL80211_IFTYPE_STATION: | 1877 | case NL80211_IFTYPE_STATION: |
1845 | if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { | 1878 | if (sdata->wdev.wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS) { |
1846 | bool tdls_peer = false; | 1879 | bool tdls_peer = false; |
1847 | 1880 | ||
1848 | rcu_read_lock(); | ||
1849 | sta = sta_info_get(sdata, skb->data); | 1881 | sta = sta_info_get(sdata, skb->data); |
1850 | if (sta) { | 1882 | if (sta) { |
1851 | authorized = test_sta_flag(sta, | 1883 | authorized = test_sta_flag(sta, |
@@ -1856,7 +1888,6 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1856 | tdls_auth = test_sta_flag(sta, | 1888 | tdls_auth = test_sta_flag(sta, |
1857 | WLAN_STA_TDLS_PEER_AUTH); | 1889 | WLAN_STA_TDLS_PEER_AUTH); |
1858 | } | 1890 | } |
1859 | rcu_read_unlock(); | ||
1860 | 1891 | ||
1861 | /* | 1892 | /* |
1862 | * If the TDLS link is enabled, send everything | 1893 | * If the TDLS link is enabled, send everything |
@@ -1871,7 +1902,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1871 | if (tdls_direct) { | 1902 | if (tdls_direct) { |
1872 | /* link during setup - throw out frames to peer */ | 1903 | /* link during setup - throw out frames to peer */ |
1873 | if (!tdls_auth) | 1904 | if (!tdls_auth) |
1874 | goto fail; | 1905 | goto fail_rcu; |
1875 | 1906 | ||
1876 | /* DA SA BSSID */ | 1907 | /* DA SA BSSID */ |
1877 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | 1908 | memcpy(hdr.addr1, skb->data, ETH_ALEN); |
@@ -1896,6 +1927,10 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1896 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1927 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1897 | hdrlen = 24; | 1928 | hdrlen = 24; |
1898 | } | 1929 | } |
1930 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1931 | if (!chanctx_conf) | ||
1932 | goto fail_rcu; | ||
1933 | band = chanctx_conf->channel->band; | ||
1899 | break; | 1934 | break; |
1900 | case NL80211_IFTYPE_ADHOC: | 1935 | case NL80211_IFTYPE_ADHOC: |
1901 | /* DA SA BSSID */ | 1936 | /* DA SA BSSID */ |
@@ -1903,9 +1938,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1903 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); | 1938 | memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); |
1904 | memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); | 1939 | memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); |
1905 | hdrlen = 24; | 1940 | hdrlen = 24; |
1941 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
1942 | if (!chanctx_conf) | ||
1943 | goto fail_rcu; | ||
1944 | band = chanctx_conf->channel->band; | ||
1906 | break; | 1945 | break; |
1907 | default: | 1946 | default: |
1908 | goto fail; | 1947 | goto fail_rcu; |
1909 | } | 1948 | } |
1910 | 1949 | ||
1911 | /* | 1950 | /* |
@@ -1915,13 +1954,11 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1915 | */ | 1954 | */ |
1916 | multicast = is_multicast_ether_addr(hdr.addr1); | 1955 | multicast = is_multicast_ether_addr(hdr.addr1); |
1917 | if (!multicast) { | 1956 | if (!multicast) { |
1918 | rcu_read_lock(); | ||
1919 | sta = sta_info_get(sdata, hdr.addr1); | 1957 | sta = sta_info_get(sdata, hdr.addr1); |
1920 | if (sta) { | 1958 | if (sta) { |
1921 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); | 1959 | authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED); |
1922 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); | 1960 | wme_sta = test_sta_flag(sta, WLAN_STA_WME); |
1923 | } | 1961 | } |
1924 | rcu_read_unlock(); | ||
1925 | } | 1962 | } |
1926 | 1963 | ||
1927 | /* For mesh, the use of the QoS header is mandatory */ | 1964 | /* For mesh, the use of the QoS header is mandatory */ |
@@ -1949,7 +1986,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1949 | 1986 | ||
1950 | I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); | 1987 | I802_DEBUG_INC(local->tx_handlers_drop_unauth_port); |
1951 | 1988 | ||
1952 | goto fail; | 1989 | goto fail_rcu; |
1953 | } | 1990 | } |
1954 | 1991 | ||
1955 | if (unlikely(!multicast && skb->sk && | 1992 | if (unlikely(!multicast && skb->sk && |
@@ -2004,7 +2041,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
2004 | kfree_skb(tmp_skb); | 2041 | kfree_skb(tmp_skb); |
2005 | 2042 | ||
2006 | if (!skb) | 2043 | if (!skb) |
2007 | goto fail; | 2044 | goto fail_rcu; |
2008 | } | 2045 | } |
2009 | 2046 | ||
2010 | hdr.frame_control = fc; | 2047 | hdr.frame_control = fc; |
@@ -2052,7 +2089,8 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
2052 | head_need = max_t(int, 0, head_need); | 2089 | head_need = max_t(int, 0, head_need); |
2053 | if (ieee80211_skb_resize(sdata, skb, head_need, true)) { | 2090 | if (ieee80211_skb_resize(sdata, skb, head_need, true)) { |
2054 | ieee80211_free_txskb(&local->hw, skb); | 2091 | ieee80211_free_txskb(&local->hw, skb); |
2055 | return NETDEV_TX_OK; | 2092 | skb = NULL; |
2093 | goto fail_rcu; | ||
2056 | } | 2094 | } |
2057 | } | 2095 | } |
2058 | 2096 | ||
@@ -2104,10 +2142,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
2104 | info->flags = info_flags; | 2142 | info->flags = info_flags; |
2105 | info->ack_frame_id = info_id; | 2143 | info->ack_frame_id = info_id; |
2106 | 2144 | ||
2107 | ieee80211_xmit(sdata, skb); | 2145 | ieee80211_xmit(sdata, skb, band); |
2146 | rcu_read_unlock(); | ||
2108 | 2147 | ||
2109 | return NETDEV_TX_OK; | 2148 | return NETDEV_TX_OK; |
2110 | 2149 | ||
2150 | fail_rcu: | ||
2151 | rcu_read_unlock(); | ||
2111 | fail: | 2152 | fail: |
2112 | dev_kfree_skb(skb); | 2153 | dev_kfree_skb(skb); |
2113 | return NETDEV_TX_OK; | 2154 | return NETDEV_TX_OK; |
@@ -2120,10 +2161,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
2120 | */ | 2161 | */ |
2121 | void ieee80211_clear_tx_pending(struct ieee80211_local *local) | 2162 | void ieee80211_clear_tx_pending(struct ieee80211_local *local) |
2122 | { | 2163 | { |
2164 | struct sk_buff *skb; | ||
2123 | int i; | 2165 | int i; |
2124 | 2166 | ||
2125 | for (i = 0; i < local->hw.queues; i++) | 2167 | for (i = 0; i < local->hw.queues; i++) { |
2126 | skb_queue_purge(&local->pending[i]); | 2168 | while ((skb = skb_dequeue(&local->pending[i])) != NULL) |
2169 | ieee80211_free_txskb(&local->hw, skb); | ||
2170 | } | ||
2127 | } | 2171 | } |
2128 | 2172 | ||
2129 | /* | 2173 | /* |
@@ -2139,11 +2183,18 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local, | |||
2139 | struct sta_info *sta; | 2183 | struct sta_info *sta; |
2140 | struct ieee80211_hdr *hdr; | 2184 | struct ieee80211_hdr *hdr; |
2141 | bool result; | 2185 | bool result; |
2186 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
2142 | 2187 | ||
2143 | sdata = vif_to_sdata(info->control.vif); | 2188 | sdata = vif_to_sdata(info->control.vif); |
2144 | 2189 | ||
2145 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { | 2190 | if (info->flags & IEEE80211_TX_INTFL_NEED_TXPROCESSING) { |
2146 | result = ieee80211_tx(sdata, skb, true); | 2191 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
2192 | if (unlikely(!chanctx_conf)) { | ||
2193 | dev_kfree_skb(skb); | ||
2194 | return true; | ||
2195 | } | ||
2196 | result = ieee80211_tx(sdata, skb, true, | ||
2197 | chanctx_conf->channel->band); | ||
2147 | } else { | 2198 | } else { |
2148 | struct sk_buff_head skbs; | 2199 | struct sk_buff_head skbs; |
2149 | 2200 | ||
@@ -2211,9 +2262,8 @@ void ieee80211_tx_pending(unsigned long data) | |||
2211 | /* functions for drivers to get certain frames */ | 2262 | /* functions for drivers to get certain frames */ |
2212 | 2263 | ||
2213 | static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | 2264 | static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, |
2214 | struct ieee80211_if_ap *bss, | 2265 | struct ps_data *ps, |
2215 | struct sk_buff *skb, | 2266 | struct sk_buff *skb) |
2216 | struct beacon_data *beacon) | ||
2217 | { | 2267 | { |
2218 | u8 *pos, *tim; | 2268 | u8 *pos, *tim; |
2219 | int aid0 = 0; | 2269 | int aid0 = 0; |
@@ -2221,27 +2271,27 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2221 | 2271 | ||
2222 | /* Generate bitmap for TIM only if there are any STAs in power save | 2272 | /* Generate bitmap for TIM only if there are any STAs in power save |
2223 | * mode. */ | 2273 | * mode. */ |
2224 | if (atomic_read(&bss->num_sta_ps) > 0) | 2274 | if (atomic_read(&ps->num_sta_ps) > 0) |
2225 | /* in the hope that this is faster than | 2275 | /* in the hope that this is faster than |
2226 | * checking byte-for-byte */ | 2276 | * checking byte-for-byte */ |
2227 | have_bits = !bitmap_empty((unsigned long*)bss->tim, | 2277 | have_bits = !bitmap_empty((unsigned long*)ps->tim, |
2228 | IEEE80211_MAX_AID+1); | 2278 | IEEE80211_MAX_AID+1); |
2229 | 2279 | ||
2230 | if (bss->dtim_count == 0) | 2280 | if (ps->dtim_count == 0) |
2231 | bss->dtim_count = sdata->vif.bss_conf.dtim_period - 1; | 2281 | ps->dtim_count = sdata->vif.bss_conf.dtim_period - 1; |
2232 | else | 2282 | else |
2233 | bss->dtim_count--; | 2283 | ps->dtim_count--; |
2234 | 2284 | ||
2235 | tim = pos = (u8 *) skb_put(skb, 6); | 2285 | tim = pos = (u8 *) skb_put(skb, 6); |
2236 | *pos++ = WLAN_EID_TIM; | 2286 | *pos++ = WLAN_EID_TIM; |
2237 | *pos++ = 4; | 2287 | *pos++ = 4; |
2238 | *pos++ = bss->dtim_count; | 2288 | *pos++ = ps->dtim_count; |
2239 | *pos++ = sdata->vif.bss_conf.dtim_period; | 2289 | *pos++ = sdata->vif.bss_conf.dtim_period; |
2240 | 2290 | ||
2241 | if (bss->dtim_count == 0 && !skb_queue_empty(&bss->ps_bc_buf)) | 2291 | if (ps->dtim_count == 0 && !skb_queue_empty(&ps->bc_buf)) |
2242 | aid0 = 1; | 2292 | aid0 = 1; |
2243 | 2293 | ||
2244 | bss->dtim_bc_mc = aid0 == 1; | 2294 | ps->dtim_bc_mc = aid0 == 1; |
2245 | 2295 | ||
2246 | if (have_bits) { | 2296 | if (have_bits) { |
2247 | /* Find largest even number N1 so that bits numbered 1 through | 2297 | /* Find largest even number N1 so that bits numbered 1 through |
@@ -2249,14 +2299,14 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2249 | * (N2 + 1) x 8 through 2007 are 0. */ | 2299 | * (N2 + 1) x 8 through 2007 are 0. */ |
2250 | n1 = 0; | 2300 | n1 = 0; |
2251 | for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) { | 2301 | for (i = 0; i < IEEE80211_MAX_TIM_LEN; i++) { |
2252 | if (bss->tim[i]) { | 2302 | if (ps->tim[i]) { |
2253 | n1 = i & 0xfe; | 2303 | n1 = i & 0xfe; |
2254 | break; | 2304 | break; |
2255 | } | 2305 | } |
2256 | } | 2306 | } |
2257 | n2 = n1; | 2307 | n2 = n1; |
2258 | for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { | 2308 | for (i = IEEE80211_MAX_TIM_LEN - 1; i >= n1; i--) { |
2259 | if (bss->tim[i]) { | 2309 | if (ps->tim[i]) { |
2260 | n2 = i; | 2310 | n2 = i; |
2261 | break; | 2311 | break; |
2262 | } | 2312 | } |
@@ -2266,7 +2316,7 @@ static void ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, | |||
2266 | *pos++ = n1 | aid0; | 2316 | *pos++ = n1 | aid0; |
2267 | /* Part Virt Bitmap */ | 2317 | /* Part Virt Bitmap */ |
2268 | skb_put(skb, n2 - n1); | 2318 | skb_put(skb, n2 - n1); |
2269 | memcpy(pos, bss->tim + n1, n2 - n1 + 1); | 2319 | memcpy(pos, ps->tim + n1, n2 - n1 + 1); |
2270 | 2320 | ||
2271 | tim[1] = n2 - n1 + 4; | 2321 | tim[1] = n2 - n1 + 4; |
2272 | } else { | 2322 | } else { |
@@ -2283,16 +2333,16 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2283 | struct sk_buff *skb = NULL; | 2333 | struct sk_buff *skb = NULL; |
2284 | struct ieee80211_tx_info *info; | 2334 | struct ieee80211_tx_info *info; |
2285 | struct ieee80211_sub_if_data *sdata = NULL; | 2335 | struct ieee80211_sub_if_data *sdata = NULL; |
2286 | struct ieee80211_if_ap *ap = NULL; | 2336 | enum ieee80211_band band; |
2287 | struct beacon_data *beacon; | ||
2288 | enum ieee80211_band band = local->oper_channel->band; | ||
2289 | struct ieee80211_tx_rate_control txrc; | 2337 | struct ieee80211_tx_rate_control txrc; |
2338 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
2290 | 2339 | ||
2291 | rcu_read_lock(); | 2340 | rcu_read_lock(); |
2292 | 2341 | ||
2293 | sdata = vif_to_sdata(vif); | 2342 | sdata = vif_to_sdata(vif); |
2343 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
2294 | 2344 | ||
2295 | if (!ieee80211_sdata_running(sdata)) | 2345 | if (!ieee80211_sdata_running(sdata) || !chanctx_conf) |
2296 | goto out; | 2346 | goto out; |
2297 | 2347 | ||
2298 | if (tim_offset) | 2348 | if (tim_offset) |
@@ -2301,8 +2351,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2301 | *tim_length = 0; | 2351 | *tim_length = 0; |
2302 | 2352 | ||
2303 | if (sdata->vif.type == NL80211_IFTYPE_AP) { | 2353 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
2304 | ap = &sdata->u.ap; | 2354 | struct ieee80211_if_ap *ap = &sdata->u.ap; |
2305 | beacon = rcu_dereference(ap->beacon); | 2355 | struct beacon_data *beacon = rcu_dereference(ap->beacon); |
2356 | |||
2306 | if (beacon) { | 2357 | if (beacon) { |
2307 | /* | 2358 | /* |
2308 | * headroom, head length, | 2359 | * headroom, head length, |
@@ -2326,14 +2377,12 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2326 | * of the tim bitmap in mac80211 and the driver. | 2377 | * of the tim bitmap in mac80211 and the driver. |
2327 | */ | 2378 | */ |
2328 | if (local->tim_in_locked_section) { | 2379 | if (local->tim_in_locked_section) { |
2329 | ieee80211_beacon_add_tim(sdata, ap, skb, | 2380 | ieee80211_beacon_add_tim(sdata, &ap->ps, skb); |
2330 | beacon); | ||
2331 | } else { | 2381 | } else { |
2332 | unsigned long flags; | 2382 | unsigned long flags; |
2333 | 2383 | ||
2334 | spin_lock_irqsave(&local->tim_lock, flags); | 2384 | spin_lock_irqsave(&local->tim_lock, flags); |
2335 | ieee80211_beacon_add_tim(sdata, ap, skb, | 2385 | ieee80211_beacon_add_tim(sdata, &ap->ps, skb); |
2336 | beacon); | ||
2337 | spin_unlock_irqrestore(&local->tim_lock, flags); | 2386 | spin_unlock_irqrestore(&local->tim_lock, flags); |
2338 | } | 2387 | } |
2339 | 2388 | ||
@@ -2409,6 +2458,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2409 | *pos++ = WLAN_EID_SSID; | 2458 | *pos++ = WLAN_EID_SSID; |
2410 | *pos++ = 0x0; | 2459 | *pos++ = 0x0; |
2411 | 2460 | ||
2461 | band = chanctx_conf->channel->band; | ||
2462 | |||
2412 | if (ieee80211_add_srates_ie(sdata, skb, true, band) || | 2463 | if (ieee80211_add_srates_ie(sdata, skb, true, band) || |
2413 | mesh_add_ds_params_ie(skb, sdata) || | 2464 | mesh_add_ds_params_ie(skb, sdata) || |
2414 | ieee80211_add_ext_srates_ie(sdata, skb, true, band) || | 2465 | ieee80211_add_ext_srates_ie(sdata, skb, true, band) || |
@@ -2426,6 +2477,8 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, | |||
2426 | goto out; | 2477 | goto out; |
2427 | } | 2478 | } |
2428 | 2479 | ||
2480 | band = chanctx_conf->channel->band; | ||
2481 | |||
2429 | info = IEEE80211_SKB_CB(skb); | 2482 | info = IEEE80211_SKB_CB(skb); |
2430 | 2483 | ||
2431 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; | 2484 | info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
@@ -2653,29 +2706,40 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2653 | struct sk_buff *skb = NULL; | 2706 | struct sk_buff *skb = NULL; |
2654 | struct ieee80211_tx_data tx; | 2707 | struct ieee80211_tx_data tx; |
2655 | struct ieee80211_sub_if_data *sdata; | 2708 | struct ieee80211_sub_if_data *sdata; |
2656 | struct ieee80211_if_ap *bss = NULL; | 2709 | struct ps_data *ps; |
2657 | struct beacon_data *beacon; | ||
2658 | struct ieee80211_tx_info *info; | 2710 | struct ieee80211_tx_info *info; |
2711 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
2659 | 2712 | ||
2660 | sdata = vif_to_sdata(vif); | 2713 | sdata = vif_to_sdata(vif); |
2661 | bss = &sdata->u.ap; | ||
2662 | 2714 | ||
2663 | rcu_read_lock(); | 2715 | rcu_read_lock(); |
2664 | beacon = rcu_dereference(bss->beacon); | 2716 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); |
2717 | |||
2718 | if (!chanctx_conf) | ||
2719 | goto out; | ||
2665 | 2720 | ||
2666 | if (sdata->vif.type != NL80211_IFTYPE_AP || !beacon || !beacon->head) | 2721 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
2722 | struct beacon_data *beacon = | ||
2723 | rcu_dereference(sdata->u.ap.beacon); | ||
2724 | |||
2725 | if (!beacon || !beacon->head) | ||
2726 | goto out; | ||
2727 | |||
2728 | ps = &sdata->u.ap.ps; | ||
2729 | } else { | ||
2667 | goto out; | 2730 | goto out; |
2731 | } | ||
2668 | 2732 | ||
2669 | if (bss->dtim_count != 0 || !bss->dtim_bc_mc) | 2733 | if (ps->dtim_count != 0 || !ps->dtim_bc_mc) |
2670 | goto out; /* send buffered bc/mc only after DTIM beacon */ | 2734 | goto out; /* send buffered bc/mc only after DTIM beacon */ |
2671 | 2735 | ||
2672 | while (1) { | 2736 | while (1) { |
2673 | skb = skb_dequeue(&bss->ps_bc_buf); | 2737 | skb = skb_dequeue(&ps->bc_buf); |
2674 | if (!skb) | 2738 | if (!skb) |
2675 | goto out; | 2739 | goto out; |
2676 | local->total_ps_buffered--; | 2740 | local->total_ps_buffered--; |
2677 | 2741 | ||
2678 | if (!skb_queue_empty(&bss->ps_bc_buf) && skb->len >= 2) { | 2742 | if (!skb_queue_empty(&ps->bc_buf) && skb->len >= 2) { |
2679 | struct ieee80211_hdr *hdr = | 2743 | struct ieee80211_hdr *hdr = |
2680 | (struct ieee80211_hdr *) skb->data; | 2744 | (struct ieee80211_hdr *) skb->data; |
2681 | /* more buffered multicast/broadcast frames ==> set | 2745 | /* more buffered multicast/broadcast frames ==> set |
@@ -2693,7 +2757,7 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2693 | info = IEEE80211_SKB_CB(skb); | 2757 | info = IEEE80211_SKB_CB(skb); |
2694 | 2758 | ||
2695 | tx.flags |= IEEE80211_TX_PS_BUFFERED; | 2759 | tx.flags |= IEEE80211_TX_PS_BUFFERED; |
2696 | info->band = local->oper_channel->band; | 2760 | info->band = chanctx_conf->channel->band; |
2697 | 2761 | ||
2698 | if (invoke_tx_handlers(&tx)) | 2762 | if (invoke_tx_handlers(&tx)) |
2699 | skb = NULL; | 2763 | skb = NULL; |
@@ -2704,8 +2768,9 @@ ieee80211_get_buffered_bc(struct ieee80211_hw *hw, | |||
2704 | } | 2768 | } |
2705 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); | 2769 | EXPORT_SYMBOL(ieee80211_get_buffered_bc); |
2706 | 2770 | ||
2707 | void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, | 2771 | void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata, |
2708 | struct sk_buff *skb, int tid) | 2772 | struct sk_buff *skb, int tid, |
2773 | enum ieee80211_band band) | ||
2709 | { | 2774 | { |
2710 | int ac = ieee802_1d_to_ac[tid & 7]; | 2775 | int ac = ieee802_1d_to_ac[tid & 7]; |
2711 | 2776 | ||
@@ -2722,6 +2787,6 @@ void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata, | |||
2722 | * requirements are that we do not come into tx with bhs on. | 2787 | * requirements are that we do not come into tx with bhs on. |
2723 | */ | 2788 | */ |
2724 | local_bh_disable(); | 2789 | local_bh_disable(); |
2725 | ieee80211_xmit(sdata, skb); | 2790 | ieee80211_xmit(sdata, skb, band); |
2726 | local_bh_enable(); | 2791 | local_bh_enable(); |
2727 | } | 2792 | } |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 22ca35054dd0..c4a60bfb9f14 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -406,7 +406,7 @@ void ieee80211_add_pending_skb(struct ieee80211_local *local, | |||
406 | int queue = info->hw_queue; | 406 | int queue = info->hw_queue; |
407 | 407 | ||
408 | if (WARN_ON(!info->control.vif)) { | 408 | if (WARN_ON(!info->control.vif)) { |
409 | kfree_skb(skb); | 409 | ieee80211_free_txskb(&local->hw, skb); |
410 | return; | 410 | return; |
411 | } | 411 | } |
412 | 412 | ||
@@ -431,7 +431,7 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local, | |||
431 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 431 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
432 | 432 | ||
433 | if (WARN_ON(!info->control.vif)) { | 433 | if (WARN_ON(!info->control.vif)) { |
434 | kfree_skb(skb); | 434 | ieee80211_free_txskb(&local->hw, skb); |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | 437 | ||
@@ -512,7 +512,7 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw) | |||
512 | EXPORT_SYMBOL(ieee80211_wake_queues); | 512 | EXPORT_SYMBOL(ieee80211_wake_queues); |
513 | 513 | ||
514 | void ieee80211_iterate_active_interfaces( | 514 | void ieee80211_iterate_active_interfaces( |
515 | struct ieee80211_hw *hw, | 515 | struct ieee80211_hw *hw, u32 iter_flags, |
516 | void (*iterator)(void *data, u8 *mac, | 516 | void (*iterator)(void *data, u8 *mac, |
517 | struct ieee80211_vif *vif), | 517 | struct ieee80211_vif *vif), |
518 | void *data) | 518 | void *data) |
@@ -530,6 +530,9 @@ void ieee80211_iterate_active_interfaces( | |||
530 | default: | 530 | default: |
531 | break; | 531 | break; |
532 | } | 532 | } |
533 | if (!(iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL) && | ||
534 | !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) | ||
535 | continue; | ||
533 | if (ieee80211_sdata_running(sdata)) | 536 | if (ieee80211_sdata_running(sdata)) |
534 | iterator(data, sdata->vif.addr, | 537 | iterator(data, sdata->vif.addr, |
535 | &sdata->vif); | 538 | &sdata->vif); |
@@ -537,7 +540,9 @@ void ieee80211_iterate_active_interfaces( | |||
537 | 540 | ||
538 | sdata = rcu_dereference_protected(local->monitor_sdata, | 541 | sdata = rcu_dereference_protected(local->monitor_sdata, |
539 | lockdep_is_held(&local->iflist_mtx)); | 542 | lockdep_is_held(&local->iflist_mtx)); |
540 | if (sdata) | 543 | if (sdata && |
544 | (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL || | ||
545 | sdata->flags & IEEE80211_SDATA_IN_DRIVER)) | ||
541 | iterator(data, sdata->vif.addr, &sdata->vif); | 546 | iterator(data, sdata->vif.addr, &sdata->vif); |
542 | 547 | ||
543 | mutex_unlock(&local->iflist_mtx); | 548 | mutex_unlock(&local->iflist_mtx); |
@@ -545,7 +550,7 @@ void ieee80211_iterate_active_interfaces( | |||
545 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces); | 550 | EXPORT_SYMBOL_GPL(ieee80211_iterate_active_interfaces); |
546 | 551 | ||
547 | void ieee80211_iterate_active_interfaces_atomic( | 552 | void ieee80211_iterate_active_interfaces_atomic( |
548 | struct ieee80211_hw *hw, | 553 | struct ieee80211_hw *hw, u32 iter_flags, |
549 | void (*iterator)(void *data, u8 *mac, | 554 | void (*iterator)(void *data, u8 *mac, |
550 | struct ieee80211_vif *vif), | 555 | struct ieee80211_vif *vif), |
551 | void *data) | 556 | void *data) |
@@ -563,13 +568,18 @@ void ieee80211_iterate_active_interfaces_atomic( | |||
563 | default: | 568 | default: |
564 | break; | 569 | break; |
565 | } | 570 | } |
571 | if (!(iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL) && | ||
572 | !(sdata->flags & IEEE80211_SDATA_IN_DRIVER)) | ||
573 | continue; | ||
566 | if (ieee80211_sdata_running(sdata)) | 574 | if (ieee80211_sdata_running(sdata)) |
567 | iterator(data, sdata->vif.addr, | 575 | iterator(data, sdata->vif.addr, |
568 | &sdata->vif); | 576 | &sdata->vif); |
569 | } | 577 | } |
570 | 578 | ||
571 | sdata = rcu_dereference(local->monitor_sdata); | 579 | sdata = rcu_dereference(local->monitor_sdata); |
572 | if (sdata) | 580 | if (sdata && |
581 | (iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL || | ||
582 | sdata->flags & IEEE80211_SDATA_IN_DRIVER)) | ||
573 | iterator(data, sdata->vif.addr, &sdata->vif); | 583 | iterator(data, sdata->vif.addr, &sdata->vif); |
574 | 584 | ||
575 | rcu_read_unlock(); | 585 | rcu_read_unlock(); |
@@ -643,13 +653,41 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
643 | break; | 653 | break; |
644 | } | 654 | } |
645 | 655 | ||
646 | if (id != WLAN_EID_VENDOR_SPECIFIC && | 656 | switch (id) { |
647 | id != WLAN_EID_QUIET && | 657 | case WLAN_EID_SSID: |
648 | test_bit(id, seen_elems)) { | 658 | case WLAN_EID_SUPP_RATES: |
649 | elems->parse_error = true; | 659 | case WLAN_EID_FH_PARAMS: |
650 | left -= elen; | 660 | case WLAN_EID_DS_PARAMS: |
651 | pos += elen; | 661 | case WLAN_EID_CF_PARAMS: |
652 | continue; | 662 | case WLAN_EID_TIM: |
663 | case WLAN_EID_IBSS_PARAMS: | ||
664 | case WLAN_EID_CHALLENGE: | ||
665 | case WLAN_EID_RSN: | ||
666 | case WLAN_EID_ERP_INFO: | ||
667 | case WLAN_EID_EXT_SUPP_RATES: | ||
668 | case WLAN_EID_HT_CAPABILITY: | ||
669 | case WLAN_EID_HT_OPERATION: | ||
670 | case WLAN_EID_VHT_CAPABILITY: | ||
671 | case WLAN_EID_VHT_OPERATION: | ||
672 | case WLAN_EID_MESH_ID: | ||
673 | case WLAN_EID_MESH_CONFIG: | ||
674 | case WLAN_EID_PEER_MGMT: | ||
675 | case WLAN_EID_PREQ: | ||
676 | case WLAN_EID_PREP: | ||
677 | case WLAN_EID_PERR: | ||
678 | case WLAN_EID_RANN: | ||
679 | case WLAN_EID_CHANNEL_SWITCH: | ||
680 | case WLAN_EID_EXT_CHANSWITCH_ANN: | ||
681 | case WLAN_EID_COUNTRY: | ||
682 | case WLAN_EID_PWR_CONSTRAINT: | ||
683 | case WLAN_EID_TIMEOUT_INTERVAL: | ||
684 | if (test_bit(id, seen_elems)) { | ||
685 | elems->parse_error = true; | ||
686 | left -= elen; | ||
687 | pos += elen; | ||
688 | continue; | ||
689 | } | ||
690 | break; | ||
653 | } | 691 | } |
654 | 692 | ||
655 | if (calc_crc && id < 64 && (filter & (1ULL << id))) | 693 | if (calc_crc && id < 64 && (filter & (1ULL << id))) |
@@ -741,6 +779,18 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
741 | else | 779 | else |
742 | elem_parse_failed = true; | 780 | elem_parse_failed = true; |
743 | break; | 781 | break; |
782 | case WLAN_EID_VHT_CAPABILITY: | ||
783 | if (elen >= sizeof(struct ieee80211_vht_cap)) | ||
784 | elems->vht_cap_elem = (void *)pos; | ||
785 | else | ||
786 | elem_parse_failed = true; | ||
787 | break; | ||
788 | case WLAN_EID_VHT_OPERATION: | ||
789 | if (elen >= sizeof(struct ieee80211_vht_operation)) | ||
790 | elems->vht_operation = (void *)pos; | ||
791 | else | ||
792 | elem_parse_failed = true; | ||
793 | break; | ||
744 | case WLAN_EID_MESH_ID: | 794 | case WLAN_EID_MESH_ID: |
745 | elems->mesh_id = pos; | 795 | elems->mesh_id = pos; |
746 | elems->mesh_id_len = elen; | 796 | elems->mesh_id_len = elen; |
@@ -809,7 +859,7 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, | |||
809 | if (elem_parse_failed) | 859 | if (elem_parse_failed) |
810 | elems->parse_error = true; | 860 | elems->parse_error = true; |
811 | else | 861 | else |
812 | set_bit(id, seen_elems); | 862 | __set_bit(id, seen_elems); |
813 | 863 | ||
814 | left -= elen; | 864 | left -= elen; |
815 | pos += elen; | 865 | pos += elen; |
@@ -832,6 +882,7 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, | |||
832 | { | 882 | { |
833 | struct ieee80211_local *local = sdata->local; | 883 | struct ieee80211_local *local = sdata->local; |
834 | struct ieee80211_tx_queue_params qparam; | 884 | struct ieee80211_tx_queue_params qparam; |
885 | struct ieee80211_chanctx_conf *chanctx_conf; | ||
835 | int ac; | 886 | int ac; |
836 | bool use_11b, enable_qos; | 887 | bool use_11b, enable_qos; |
837 | int aCWmin, aCWmax; | 888 | int aCWmin, aCWmax; |
@@ -844,8 +895,12 @@ void ieee80211_set_wmm_default(struct ieee80211_sub_if_data *sdata, | |||
844 | 895 | ||
845 | memset(&qparam, 0, sizeof(qparam)); | 896 | memset(&qparam, 0, sizeof(qparam)); |
846 | 897 | ||
847 | use_11b = (local->oper_channel->band == IEEE80211_BAND_2GHZ) && | 898 | rcu_read_lock(); |
899 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
900 | use_11b = (chanctx_conf && | ||
901 | chanctx_conf->channel->band == IEEE80211_BAND_2GHZ) && | ||
848 | !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); | 902 | !(sdata->flags & IEEE80211_SDATA_OPERATING_GMODE); |
903 | rcu_read_unlock(); | ||
849 | 904 | ||
850 | /* | 905 | /* |
851 | * By default disable QoS in STA mode for old access points, which do | 906 | * By default disable QoS in STA mode for old access points, which do |
@@ -924,7 +979,7 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | |||
924 | const size_t supp_rates_len, | 979 | const size_t supp_rates_len, |
925 | const u8 *supp_rates) | 980 | const u8 *supp_rates) |
926 | { | 981 | { |
927 | struct ieee80211_local *local = sdata->local; | 982 | struct ieee80211_chanctx_conf *chanctx_conf; |
928 | int i, have_higher_than_11mbit = 0; | 983 | int i, have_higher_than_11mbit = 0; |
929 | 984 | ||
930 | /* cf. IEEE 802.11 9.2.12 */ | 985 | /* cf. IEEE 802.11 9.2.12 */ |
@@ -932,11 +987,16 @@ void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, | |||
932 | if ((supp_rates[i] & 0x7f) * 5 > 110) | 987 | if ((supp_rates[i] & 0x7f) * 5 > 110) |
933 | have_higher_than_11mbit = 1; | 988 | have_higher_than_11mbit = 1; |
934 | 989 | ||
935 | if (local->oper_channel->band == IEEE80211_BAND_2GHZ && | 990 | rcu_read_lock(); |
991 | chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); | ||
992 | |||
993 | if (chanctx_conf && | ||
994 | chanctx_conf->channel->band == IEEE80211_BAND_2GHZ && | ||
936 | have_higher_than_11mbit) | 995 | have_higher_than_11mbit) |
937 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; | 996 | sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; |
938 | else | 997 | else |
939 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; | 998 | sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; |
999 | rcu_read_unlock(); | ||
940 | 1000 | ||
941 | ieee80211_set_wmm_default(sdata, true); | 1001 | ieee80211_set_wmm_default(sdata, true); |
942 | } | 1002 | } |
@@ -968,7 +1028,7 @@ u32 ieee80211_mandatory_rates(struct ieee80211_local *local, | |||
968 | } | 1028 | } |
969 | 1029 | ||
970 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | 1030 | void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, |
971 | u16 transaction, u16 auth_alg, | 1031 | u16 transaction, u16 auth_alg, u16 status, |
972 | u8 *extra, size_t extra_len, const u8 *da, | 1032 | u8 *extra, size_t extra_len, const u8 *da, |
973 | const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx) | 1033 | const u8 *bssid, const u8 *key, u8 key_len, u8 key_idx) |
974 | { | 1034 | { |
@@ -993,7 +1053,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
993 | memcpy(mgmt->bssid, bssid, ETH_ALEN); | 1053 | memcpy(mgmt->bssid, bssid, ETH_ALEN); |
994 | mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); | 1054 | mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); |
995 | mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); | 1055 | mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); |
996 | mgmt->u.auth.status_code = cpu_to_le16(0); | 1056 | mgmt->u.auth.status_code = cpu_to_le16(status); |
997 | if (extra) | 1057 | if (extra) |
998 | memcpy(skb_put(skb, extra_len), extra, extra_len); | 1058 | memcpy(skb_put(skb, extra_len), extra, extra_len); |
999 | 1059 | ||
@@ -1206,7 +1266,7 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | |||
1206 | const u8 *ssid, size_t ssid_len, | 1266 | const u8 *ssid, size_t ssid_len, |
1207 | const u8 *ie, size_t ie_len, | 1267 | const u8 *ie, size_t ie_len, |
1208 | u32 ratemask, bool directed, bool no_cck, | 1268 | u32 ratemask, bool directed, bool no_cck, |
1209 | struct ieee80211_channel *channel) | 1269 | struct ieee80211_channel *channel, bool scan) |
1210 | { | 1270 | { |
1211 | struct sk_buff *skb; | 1271 | struct sk_buff *skb; |
1212 | 1272 | ||
@@ -1217,7 +1277,10 @@ void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, | |||
1217 | if (no_cck) | 1277 | if (no_cck) |
1218 | IEEE80211_SKB_CB(skb)->flags |= | 1278 | IEEE80211_SKB_CB(skb)->flags |= |
1219 | IEEE80211_TX_CTL_NO_CCK_RATE; | 1279 | IEEE80211_TX_CTL_NO_CCK_RATE; |
1220 | ieee80211_tx_skb(sdata, skb); | 1280 | if (scan) |
1281 | ieee80211_tx_skb_tid_band(sdata, skb, 7, channel->band); | ||
1282 | else | ||
1283 | ieee80211_tx_skb(sdata, skb); | ||
1221 | } | 1284 | } |
1222 | } | 1285 | } |
1223 | 1286 | ||
@@ -1280,6 +1343,7 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1280 | { | 1343 | { |
1281 | struct ieee80211_hw *hw = &local->hw; | 1344 | struct ieee80211_hw *hw = &local->hw; |
1282 | struct ieee80211_sub_if_data *sdata; | 1345 | struct ieee80211_sub_if_data *sdata; |
1346 | struct ieee80211_chanctx *ctx; | ||
1283 | struct sta_info *sta; | 1347 | struct sta_info *sta; |
1284 | int res, i; | 1348 | int res, i; |
1285 | 1349 | ||
@@ -1352,6 +1416,29 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1352 | res = drv_add_interface(local, sdata); | 1416 | res = drv_add_interface(local, sdata); |
1353 | } | 1417 | } |
1354 | 1418 | ||
1419 | /* add channel contexts */ | ||
1420 | mutex_lock(&local->chanctx_mtx); | ||
1421 | list_for_each_entry(ctx, &local->chanctx_list, list) | ||
1422 | WARN_ON(drv_add_chanctx(local, ctx)); | ||
1423 | mutex_unlock(&local->chanctx_mtx); | ||
1424 | |||
1425 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
1426 | struct ieee80211_chanctx_conf *ctx_conf; | ||
1427 | |||
1428 | if (!ieee80211_sdata_running(sdata)) | ||
1429 | continue; | ||
1430 | |||
1431 | mutex_lock(&local->chanctx_mtx); | ||
1432 | ctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, | ||
1433 | lockdep_is_held(&local->chanctx_mtx)); | ||
1434 | if (ctx_conf) { | ||
1435 | ctx = container_of(ctx_conf, struct ieee80211_chanctx, | ||
1436 | conf); | ||
1437 | drv_assign_vif_chanctx(local, sdata, ctx); | ||
1438 | } | ||
1439 | mutex_unlock(&local->chanctx_mtx); | ||
1440 | } | ||
1441 | |||
1355 | /* add STAs back */ | 1442 | /* add STAs back */ |
1356 | mutex_lock(&local->sta_mtx); | 1443 | mutex_lock(&local->sta_mtx); |
1357 | list_for_each_entry(sta, &local->sta_list, list) { | 1444 | list_for_each_entry(sta, &local->sta_list, list) { |
@@ -1407,7 +1494,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1407 | BSS_CHANGED_BSSID | | 1494 | BSS_CHANGED_BSSID | |
1408 | BSS_CHANGED_CQM | | 1495 | BSS_CHANGED_CQM | |
1409 | BSS_CHANGED_QOS | | 1496 | BSS_CHANGED_QOS | |
1410 | BSS_CHANGED_IDLE; | 1497 | BSS_CHANGED_IDLE | |
1498 | BSS_CHANGED_TXPOWER; | ||
1411 | 1499 | ||
1412 | switch (sdata->vif.type) { | 1500 | switch (sdata->vif.type) { |
1413 | case NL80211_IFTYPE_STATION: | 1501 | case NL80211_IFTYPE_STATION: |
@@ -1424,9 +1512,13 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1424 | case NL80211_IFTYPE_AP: | 1512 | case NL80211_IFTYPE_AP: |
1425 | changed |= BSS_CHANGED_SSID; | 1513 | changed |= BSS_CHANGED_SSID; |
1426 | 1514 | ||
1427 | if (sdata->vif.type == NL80211_IFTYPE_AP) | 1515 | if (sdata->vif.type == NL80211_IFTYPE_AP) { |
1428 | changed |= BSS_CHANGED_AP_PROBE_RESP; | 1516 | changed |= BSS_CHANGED_AP_PROBE_RESP; |
1429 | 1517 | ||
1518 | if (rcu_access_pointer(sdata->u.ap.beacon)) | ||
1519 | drv_start_ap(local, sdata); | ||
1520 | } | ||
1521 | |||
1430 | /* fall through */ | 1522 | /* fall through */ |
1431 | case NL80211_IFTYPE_MESH_POINT: | 1523 | case NL80211_IFTYPE_MESH_POINT: |
1432 | changed |= BSS_CHANGED_BEACON | | 1524 | changed |= BSS_CHANGED_BEACON | |
@@ -1463,6 +1555,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1463 | list_for_each_entry(sdata, &local->interfaces, list) { | 1555 | list_for_each_entry(sdata, &local->interfaces, list) { |
1464 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | 1556 | if (sdata->vif.type != NL80211_IFTYPE_STATION) |
1465 | continue; | 1557 | continue; |
1558 | if (!sdata->u.mgd.associated) | ||
1559 | continue; | ||
1466 | 1560 | ||
1467 | ieee80211_send_nullfunc(local, sdata, 0); | 1561 | ieee80211_send_nullfunc(local, sdata, 0); |
1468 | } | 1562 | } |
@@ -1523,8 +1617,10 @@ int ieee80211_reconfig(struct ieee80211_local *local) | |||
1523 | * If this is for hw restart things are still running. | 1617 | * If this is for hw restart things are still running. |
1524 | * We may want to change that later, however. | 1618 | * We may want to change that later, however. |
1525 | */ | 1619 | */ |
1526 | if (!local->suspended) | 1620 | if (!local->suspended) { |
1621 | drv_restart_complete(local); | ||
1527 | return 0; | 1622 | return 0; |
1623 | } | ||
1528 | 1624 | ||
1529 | #ifdef CONFIG_PM | 1625 | #ifdef CONFIG_PM |
1530 | /* first set suspended false, then resuming */ | 1626 | /* first set suspended false, then resuming */ |
@@ -1587,68 +1683,24 @@ void ieee80211_resume_disconnect(struct ieee80211_vif *vif) | |||
1587 | } | 1683 | } |
1588 | EXPORT_SYMBOL_GPL(ieee80211_resume_disconnect); | 1684 | EXPORT_SYMBOL_GPL(ieee80211_resume_disconnect); |
1589 | 1685 | ||
1590 | static int check_mgd_smps(struct ieee80211_if_managed *ifmgd, | 1686 | void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata) |
1591 | enum ieee80211_smps_mode *smps_mode) | ||
1592 | { | ||
1593 | if (ifmgd->associated) { | ||
1594 | *smps_mode = ifmgd->ap_smps; | ||
1595 | |||
1596 | if (*smps_mode == IEEE80211_SMPS_AUTOMATIC) { | ||
1597 | if (ifmgd->powersave) | ||
1598 | *smps_mode = IEEE80211_SMPS_DYNAMIC; | ||
1599 | else | ||
1600 | *smps_mode = IEEE80211_SMPS_OFF; | ||
1601 | } | ||
1602 | |||
1603 | return 1; | ||
1604 | } | ||
1605 | |||
1606 | return 0; | ||
1607 | } | ||
1608 | |||
1609 | void ieee80211_recalc_smps(struct ieee80211_local *local) | ||
1610 | { | 1687 | { |
1611 | struct ieee80211_sub_if_data *sdata; | 1688 | struct ieee80211_local *local = sdata->local; |
1612 | enum ieee80211_smps_mode smps_mode = IEEE80211_SMPS_OFF; | 1689 | struct ieee80211_chanctx_conf *chanctx_conf; |
1613 | int count = 0; | 1690 | struct ieee80211_chanctx *chanctx; |
1614 | |||
1615 | mutex_lock(&local->iflist_mtx); | ||
1616 | |||
1617 | /* | ||
1618 | * This function could be improved to handle multiple | ||
1619 | * interfaces better, but right now it makes any | ||
1620 | * non-station interfaces force SM PS to be turned | ||
1621 | * off. If there are multiple station interfaces it | ||
1622 | * could also use the best possible mode, e.g. if | ||
1623 | * one is in static and the other in dynamic then | ||
1624 | * dynamic is ok. | ||
1625 | */ | ||
1626 | |||
1627 | list_for_each_entry(sdata, &local->interfaces, list) { | ||
1628 | if (!ieee80211_sdata_running(sdata)) | ||
1629 | continue; | ||
1630 | if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) | ||
1631 | continue; | ||
1632 | if (sdata->vif.type != NL80211_IFTYPE_STATION) | ||
1633 | goto set; | ||
1634 | 1691 | ||
1635 | count += check_mgd_smps(&sdata->u.mgd, &smps_mode); | 1692 | mutex_lock(&local->chanctx_mtx); |
1636 | 1693 | ||
1637 | if (count > 1) { | 1694 | chanctx_conf = rcu_dereference_protected(sdata->vif.chanctx_conf, |
1638 | smps_mode = IEEE80211_SMPS_OFF; | 1695 | lockdep_is_held(&local->chanctx_mtx)); |
1639 | break; | ||
1640 | } | ||
1641 | } | ||
1642 | 1696 | ||
1643 | if (smps_mode == local->smps_mode) | 1697 | if (WARN_ON_ONCE(!chanctx_conf)) |
1644 | goto unlock; | 1698 | goto unlock; |
1645 | 1699 | ||
1646 | set: | 1700 | chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf); |
1647 | local->smps_mode = smps_mode; | 1701 | ieee80211_recalc_smps_chanctx(local, chanctx); |
1648 | /* changed flag is auto-detected for this */ | ||
1649 | ieee80211_hw_config(local, 0); | ||
1650 | unlock: | 1702 | unlock: |
1651 | mutex_unlock(&local->iflist_mtx); | 1703 | mutex_unlock(&local->chanctx_mtx); |
1652 | } | 1704 | } |
1653 | 1705 | ||
1654 | static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id) | 1706 | static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id) |
@@ -1788,8 +1840,8 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap, | |||
1788 | __le32 tmp; | 1840 | __le32 tmp; |
1789 | 1841 | ||
1790 | *pos++ = WLAN_EID_VHT_CAPABILITY; | 1842 | *pos++ = WLAN_EID_VHT_CAPABILITY; |
1791 | *pos++ = sizeof(struct ieee80211_vht_capabilities); | 1843 | *pos++ = sizeof(struct ieee80211_vht_cap); |
1792 | memset(pos, 0, sizeof(struct ieee80211_vht_capabilities)); | 1844 | memset(pos, 0, sizeof(struct ieee80211_vht_cap)); |
1793 | 1845 | ||
1794 | /* capability flags */ | 1846 | /* capability flags */ |
1795 | tmp = cpu_to_le32(cap); | 1847 | tmp = cpu_to_le32(cap); |
@@ -1947,3 +1999,19 @@ int ieee80211_ave_rssi(struct ieee80211_vif *vif) | |||
1947 | return ifmgd->ave_beacon_signal; | 1999 | return ifmgd->ave_beacon_signal; |
1948 | } | 2000 | } |
1949 | EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); | 2001 | EXPORT_SYMBOL_GPL(ieee80211_ave_rssi); |
2002 | |||
2003 | u8 ieee80211_mcs_to_chains(const struct ieee80211_mcs_info *mcs) | ||
2004 | { | ||
2005 | if (!mcs) | ||
2006 | return 1; | ||
2007 | |||
2008 | /* TODO: consider rx_highest */ | ||
2009 | |||
2010 | if (mcs->rx_mask[3]) | ||
2011 | return 4; | ||
2012 | if (mcs->rx_mask[2]) | ||
2013 | return 3; | ||
2014 | if (mcs->rx_mask[1]) | ||
2015 | return 2; | ||
2016 | return 1; | ||
2017 | } | ||
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c new file mode 100644 index 000000000000..f311388aeedf --- /dev/null +++ b/net/mac80211/vht.c | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * VHT handling | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/ieee80211.h> | ||
10 | #include <linux/export.h> | ||
11 | #include <net/mac80211.h> | ||
12 | #include "ieee80211_i.h" | ||
13 | |||
14 | |||
15 | void ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, | ||
16 | struct ieee80211_supported_band *sband, | ||
17 | struct ieee80211_vht_cap *vht_cap_ie, | ||
18 | struct ieee80211_sta_vht_cap *vht_cap) | ||
19 | { | ||
20 | if (WARN_ON_ONCE(!vht_cap)) | ||
21 | return; | ||
22 | |||
23 | memset(vht_cap, 0, sizeof(*vht_cap)); | ||
24 | |||
25 | if (!vht_cap_ie || !sband->vht_cap.vht_supported) | ||
26 | return; | ||
27 | |||
28 | vht_cap->vht_supported = true; | ||
29 | |||
30 | vht_cap->cap = le32_to_cpu(vht_cap_ie->vht_cap_info); | ||
31 | |||
32 | /* Copy peer MCS info, the driver might need them. */ | ||
33 | memcpy(&vht_cap->vht_mcs, &vht_cap_ie->supp_mcs, | ||
34 | sizeof(struct ieee80211_vht_mcs_info)); | ||
35 | } | ||
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c index bdb53aba888e..8bd2f5c6a56e 100644 --- a/net/mac80211/wpa.c +++ b/net/mac80211/wpa.c | |||
@@ -106,7 +106,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx) | |||
106 | if (status->flag & RX_FLAG_MMIC_ERROR) | 106 | if (status->flag & RX_FLAG_MMIC_ERROR) |
107 | goto mic_fail; | 107 | goto mic_fail; |
108 | 108 | ||
109 | if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key) | 109 | if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key && |
110 | rx->key->conf.cipher == WLAN_CIPHER_SUITE_TKIP) | ||
110 | goto update_iv; | 111 | goto update_iv; |
111 | 112 | ||
112 | return RX_CONTINUE; | 113 | return RX_CONTINUE; |
@@ -545,14 +546,19 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx) | |||
545 | 546 | ||
546 | static void bip_aad(struct sk_buff *skb, u8 *aad) | 547 | static void bip_aad(struct sk_buff *skb, u8 *aad) |
547 | { | 548 | { |
549 | __le16 mask_fc; | ||
550 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
551 | |||
548 | /* BIP AAD: FC(masked) || A1 || A2 || A3 */ | 552 | /* BIP AAD: FC(masked) || A1 || A2 || A3 */ |
549 | 553 | ||
550 | /* FC type/subtype */ | 554 | /* FC type/subtype */ |
551 | aad[0] = skb->data[0]; | ||
552 | /* Mask FC Retry, PwrMgt, MoreData flags to zero */ | 555 | /* Mask FC Retry, PwrMgt, MoreData flags to zero */ |
553 | aad[1] = skb->data[1] & ~(BIT(4) | BIT(5) | BIT(6)); | 556 | mask_fc = hdr->frame_control; |
557 | mask_fc &= ~cpu_to_le16(IEEE80211_FCTL_RETRY | IEEE80211_FCTL_PM | | ||
558 | IEEE80211_FCTL_MOREDATA); | ||
559 | put_unaligned(mask_fc, (__le16 *) &aad[0]); | ||
554 | /* A1 || A2 || A3 */ | 560 | /* A1 || A2 || A3 */ |
555 | memcpy(aad + 2, skb->data + 4, 3 * ETH_ALEN); | 561 | memcpy(aad + 2, &hdr->addr1, 3 * ETH_ALEN); |
556 | } | 562 | } |
557 | 563 | ||
558 | 564 | ||
diff --git a/net/nfc/Kconfig b/net/nfc/Kconfig index 8d8d9bc4b6ff..60c3bbb63e8e 100644 --- a/net/nfc/Kconfig +++ b/net/nfc/Kconfig | |||
@@ -3,8 +3,8 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | menuconfig NFC | 5 | menuconfig NFC |
6 | depends on NET && EXPERIMENTAL | 6 | depends on NET |
7 | tristate "NFC subsystem support (EXPERIMENTAL)" | 7 | tristate "NFC subsystem support" |
8 | default n | 8 | default n |
9 | help | 9 | help |
10 | Say Y here if you want to build support for NFC (Near field | 10 | Say Y here if you want to build support for NFC (Near field |
diff --git a/net/nfc/core.c b/net/nfc/core.c index 479bee36dc3e..aa64ea441676 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -40,6 +40,9 @@ | |||
40 | int nfc_devlist_generation; | 40 | int nfc_devlist_generation; |
41 | DEFINE_MUTEX(nfc_devlist_mutex); | 41 | DEFINE_MUTEX(nfc_devlist_mutex); |
42 | 42 | ||
43 | /* NFC device ID bitmap */ | ||
44 | static DEFINE_IDA(nfc_index_ida); | ||
45 | |||
43 | /** | 46 | /** |
44 | * nfc_dev_up - turn on the NFC device | 47 | * nfc_dev_up - turn on the NFC device |
45 | * | 48 | * |
@@ -181,6 +184,7 @@ int nfc_stop_poll(struct nfc_dev *dev) | |||
181 | 184 | ||
182 | dev->ops->stop_poll(dev); | 185 | dev->ops->stop_poll(dev); |
183 | dev->polling = false; | 186 | dev->polling = false; |
187 | dev->rf_mode = NFC_RF_NONE; | ||
184 | 188 | ||
185 | error: | 189 | error: |
186 | device_unlock(&dev->dev); | 190 | device_unlock(&dev->dev); |
@@ -194,7 +198,7 @@ static struct nfc_target *nfc_find_target(struct nfc_dev *dev, u32 target_idx) | |||
194 | if (dev->n_targets == 0) | 198 | if (dev->n_targets == 0) |
195 | return NULL; | 199 | return NULL; |
196 | 200 | ||
197 | for (i = 0; i < dev->n_targets ; i++) { | 201 | for (i = 0; i < dev->n_targets; i++) { |
198 | if (dev->targets[i].idx == target_idx) | 202 | if (dev->targets[i].idx == target_idx) |
199 | return &dev->targets[i]; | 203 | return &dev->targets[i]; |
200 | } | 204 | } |
@@ -274,12 +278,14 @@ int nfc_dep_link_down(struct nfc_dev *dev) | |||
274 | if (!rc) { | 278 | if (!rc) { |
275 | dev->dep_link_up = false; | 279 | dev->dep_link_up = false; |
276 | dev->active_target = NULL; | 280 | dev->active_target = NULL; |
281 | dev->rf_mode = NFC_RF_NONE; | ||
277 | nfc_llcp_mac_is_down(dev); | 282 | nfc_llcp_mac_is_down(dev); |
278 | nfc_genl_dep_link_down_event(dev); | 283 | nfc_genl_dep_link_down_event(dev); |
279 | } | 284 | } |
280 | 285 | ||
281 | error: | 286 | error: |
282 | device_unlock(&dev->dev); | 287 | device_unlock(&dev->dev); |
288 | |||
283 | return rc; | 289 | return rc; |
284 | } | 290 | } |
285 | 291 | ||
@@ -503,6 +509,7 @@ EXPORT_SYMBOL(nfc_tm_activated); | |||
503 | int nfc_tm_deactivated(struct nfc_dev *dev) | 509 | int nfc_tm_deactivated(struct nfc_dev *dev) |
504 | { | 510 | { |
505 | dev->dep_link_up = false; | 511 | dev->dep_link_up = false; |
512 | dev->rf_mode = NFC_RF_NONE; | ||
506 | 513 | ||
507 | return nfc_genl_tm_deactivated(dev); | 514 | return nfc_genl_tm_deactivated(dev); |
508 | } | 515 | } |
@@ -697,6 +704,8 @@ static void nfc_check_pres_work(struct work_struct *work) | |||
697 | 704 | ||
698 | if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) { | 705 | if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) { |
699 | rc = dev->ops->check_presence(dev, dev->active_target); | 706 | rc = dev->ops->check_presence(dev, dev->active_target); |
707 | if (rc == -EOPNOTSUPP) | ||
708 | goto exit; | ||
700 | if (!rc) { | 709 | if (!rc) { |
701 | mod_timer(&dev->check_pres_timer, jiffies + | 710 | mod_timer(&dev->check_pres_timer, jiffies + |
702 | msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); | 711 | msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS)); |
@@ -708,6 +717,7 @@ static void nfc_check_pres_work(struct work_struct *work) | |||
708 | } | 717 | } |
709 | } | 718 | } |
710 | 719 | ||
720 | exit: | ||
711 | device_unlock(&dev->dev); | 721 | device_unlock(&dev->dev); |
712 | } | 722 | } |
713 | 723 | ||
@@ -753,7 +763,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | |||
753 | u32 supported_protocols, | 763 | u32 supported_protocols, |
754 | int tx_headroom, int tx_tailroom) | 764 | int tx_headroom, int tx_tailroom) |
755 | { | 765 | { |
756 | static atomic_t dev_no = ATOMIC_INIT(0); | ||
757 | struct nfc_dev *dev; | 766 | struct nfc_dev *dev; |
758 | 767 | ||
759 | if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || | 768 | if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || |
@@ -767,11 +776,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | |||
767 | if (!dev) | 776 | if (!dev) |
768 | return NULL; | 777 | return NULL; |
769 | 778 | ||
770 | dev->dev.class = &nfc_class; | ||
771 | dev->idx = atomic_inc_return(&dev_no) - 1; | ||
772 | dev_set_name(&dev->dev, "nfc%d", dev->idx); | ||
773 | device_initialize(&dev->dev); | ||
774 | |||
775 | dev->ops = ops; | 779 | dev->ops = ops; |
776 | dev->supported_protocols = supported_protocols; | 780 | dev->supported_protocols = supported_protocols; |
777 | dev->tx_headroom = tx_headroom; | 781 | dev->tx_headroom = tx_headroom; |
@@ -779,6 +783,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | |||
779 | 783 | ||
780 | nfc_genl_data_init(&dev->genl_data); | 784 | nfc_genl_data_init(&dev->genl_data); |
781 | 785 | ||
786 | dev->rf_mode = NFC_RF_NONE; | ||
782 | 787 | ||
783 | /* first generation must not be 0 */ | 788 | /* first generation must not be 0 */ |
784 | dev->targets_generation = 1; | 789 | dev->targets_generation = 1; |
@@ -806,6 +811,14 @@ int nfc_register_device(struct nfc_dev *dev) | |||
806 | 811 | ||
807 | pr_debug("dev_name=%s\n", dev_name(&dev->dev)); | 812 | pr_debug("dev_name=%s\n", dev_name(&dev->dev)); |
808 | 813 | ||
814 | dev->idx = ida_simple_get(&nfc_index_ida, 0, 0, GFP_KERNEL); | ||
815 | if (dev->idx < 0) | ||
816 | return dev->idx; | ||
817 | |||
818 | dev->dev.class = &nfc_class; | ||
819 | dev_set_name(&dev->dev, "nfc%d", dev->idx); | ||
820 | device_initialize(&dev->dev); | ||
821 | |||
809 | mutex_lock(&nfc_devlist_mutex); | 822 | mutex_lock(&nfc_devlist_mutex); |
810 | nfc_devlist_generation++; | 823 | nfc_devlist_generation++; |
811 | rc = device_add(&dev->dev); | 824 | rc = device_add(&dev->dev); |
@@ -834,10 +847,12 @@ EXPORT_SYMBOL(nfc_register_device); | |||
834 | */ | 847 | */ |
835 | void nfc_unregister_device(struct nfc_dev *dev) | 848 | void nfc_unregister_device(struct nfc_dev *dev) |
836 | { | 849 | { |
837 | int rc; | 850 | int rc, id; |
838 | 851 | ||
839 | pr_debug("dev_name=%s\n", dev_name(&dev->dev)); | 852 | pr_debug("dev_name=%s\n", dev_name(&dev->dev)); |
840 | 853 | ||
854 | id = dev->idx; | ||
855 | |||
841 | mutex_lock(&nfc_devlist_mutex); | 856 | mutex_lock(&nfc_devlist_mutex); |
842 | nfc_devlist_generation++; | 857 | nfc_devlist_generation++; |
843 | 858 | ||
@@ -856,6 +871,8 @@ void nfc_unregister_device(struct nfc_dev *dev) | |||
856 | pr_debug("The userspace won't be notified that the device %s was removed\n", | 871 | pr_debug("The userspace won't be notified that the device %s was removed\n", |
857 | dev_name(&dev->dev)); | 872 | dev_name(&dev->dev)); |
858 | 873 | ||
874 | ida_simple_remove(&nfc_index_ida, id); | ||
875 | |||
859 | } | 876 | } |
860 | EXPORT_SYMBOL(nfc_unregister_device); | 877 | EXPORT_SYMBOL(nfc_unregister_device); |
861 | 878 | ||
diff --git a/net/nfc/hci/command.c b/net/nfc/hci/command.c index 71c6a7086b8f..7d99410e6c1a 100644 --- a/net/nfc/hci/command.c +++ b/net/nfc/hci/command.c | |||
@@ -257,16 +257,16 @@ static u8 nfc_hci_create_pipe(struct nfc_hci_dev *hdev, u8 dest_host, | |||
257 | *result = nfc_hci_execute_cmd(hdev, NFC_HCI_ADMIN_PIPE, | 257 | *result = nfc_hci_execute_cmd(hdev, NFC_HCI_ADMIN_PIPE, |
258 | NFC_HCI_ADM_CREATE_PIPE, | 258 | NFC_HCI_ADM_CREATE_PIPE, |
259 | (u8 *) ¶ms, sizeof(params), &skb); | 259 | (u8 *) ¶ms, sizeof(params), &skb); |
260 | if (*result == 0) { | 260 | if (*result < 0) |
261 | resp = (struct hci_create_pipe_resp *)skb->data; | 261 | return NFC_HCI_INVALID_PIPE; |
262 | pipe = resp->pipe; | ||
263 | kfree_skb(skb); | ||
264 | 262 | ||
265 | pr_debug("pipe created=%d\n", pipe); | 263 | resp = (struct hci_create_pipe_resp *)skb->data; |
264 | pipe = resp->pipe; | ||
265 | kfree_skb(skb); | ||
266 | 266 | ||
267 | return pipe; | 267 | pr_debug("pipe created=%d\n", pipe); |
268 | } else | 268 | |
269 | return NFC_HCI_INVALID_PIPE; | 269 | return pipe; |
270 | } | 270 | } |
271 | 271 | ||
272 | static int nfc_hci_delete_pipe(struct nfc_hci_dev *hdev, u8 pipe) | 272 | static int nfc_hci_delete_pipe(struct nfc_hci_dev *hdev, u8 pipe) |
@@ -279,8 +279,6 @@ static int nfc_hci_delete_pipe(struct nfc_hci_dev *hdev, u8 pipe) | |||
279 | 279 | ||
280 | static int nfc_hci_clear_all_pipes(struct nfc_hci_dev *hdev) | 280 | static int nfc_hci_clear_all_pipes(struct nfc_hci_dev *hdev) |
281 | { | 281 | { |
282 | int r; | ||
283 | |||
284 | u8 param[2]; | 282 | u8 param[2]; |
285 | 283 | ||
286 | /* TODO: Find out what the identity reference data is | 284 | /* TODO: Find out what the identity reference data is |
@@ -288,10 +286,8 @@ static int nfc_hci_clear_all_pipes(struct nfc_hci_dev *hdev) | |||
288 | 286 | ||
289 | pr_debug("\n"); | 287 | pr_debug("\n"); |
290 | 288 | ||
291 | r = nfc_hci_execute_cmd(hdev, NFC_HCI_ADMIN_PIPE, | 289 | return nfc_hci_execute_cmd(hdev, NFC_HCI_ADMIN_PIPE, |
292 | NFC_HCI_ADM_CLEAR_ALL_PIPE, param, 2, NULL); | 290 | NFC_HCI_ADM_CLEAR_ALL_PIPE, param, 2, NULL); |
293 | |||
294 | return 0; | ||
295 | } | 291 | } |
296 | 292 | ||
297 | int nfc_hci_disconnect_gate(struct nfc_hci_dev *hdev, u8 gate) | 293 | int nfc_hci_disconnect_gate(struct nfc_hci_dev *hdev, u8 gate) |
@@ -348,7 +344,7 @@ int nfc_hci_connect_gate(struct nfc_hci_dev *hdev, u8 dest_host, u8 dest_gate, | |||
348 | return -EADDRINUSE; | 344 | return -EADDRINUSE; |
349 | 345 | ||
350 | if (pipe != NFC_HCI_INVALID_PIPE) | 346 | if (pipe != NFC_HCI_INVALID_PIPE) |
351 | goto pipe_is_open; | 347 | goto open_pipe; |
352 | 348 | ||
353 | switch (dest_gate) { | 349 | switch (dest_gate) { |
354 | case NFC_HCI_LINK_MGMT_GATE: | 350 | case NFC_HCI_LINK_MGMT_GATE: |
@@ -365,6 +361,7 @@ int nfc_hci_connect_gate(struct nfc_hci_dev *hdev, u8 dest_host, u8 dest_gate, | |||
365 | break; | 361 | break; |
366 | } | 362 | } |
367 | 363 | ||
364 | open_pipe: | ||
368 | r = nfc_hci_open_pipe(hdev, pipe); | 365 | r = nfc_hci_open_pipe(hdev, pipe); |
369 | if (r < 0) { | 366 | if (r < 0) { |
370 | if (pipe_created) | 367 | if (pipe_created) |
@@ -375,7 +372,6 @@ int nfc_hci_connect_gate(struct nfc_hci_dev *hdev, u8 dest_host, u8 dest_gate, | |||
375 | return r; | 372 | return r; |
376 | } | 373 | } |
377 | 374 | ||
378 | pipe_is_open: | ||
379 | hdev->gate2pipe[dest_gate] = pipe; | 375 | hdev->gate2pipe[dest_gate] = pipe; |
380 | 376 | ||
381 | return 0; | 377 | return 0; |
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index 5fbb6e40793e..7bea574d5934 100644 --- a/net/nfc/hci/core.c +++ b/net/nfc/hci/core.c | |||
@@ -33,17 +33,20 @@ | |||
33 | /* Largest headroom needed for outgoing HCI commands */ | 33 | /* Largest headroom needed for outgoing HCI commands */ |
34 | #define HCI_CMDS_HEADROOM 1 | 34 | #define HCI_CMDS_HEADROOM 1 |
35 | 35 | ||
36 | static int nfc_hci_result_to_errno(u8 result) | 36 | int nfc_hci_result_to_errno(u8 result) |
37 | { | 37 | { |
38 | switch (result) { | 38 | switch (result) { |
39 | case NFC_HCI_ANY_OK: | 39 | case NFC_HCI_ANY_OK: |
40 | return 0; | 40 | return 0; |
41 | case NFC_HCI_ANY_E_REG_PAR_UNKNOWN: | ||
42 | return -EOPNOTSUPP; | ||
41 | case NFC_HCI_ANY_E_TIMEOUT: | 43 | case NFC_HCI_ANY_E_TIMEOUT: |
42 | return -ETIME; | 44 | return -ETIME; |
43 | default: | 45 | default: |
44 | return -1; | 46 | return -1; |
45 | } | 47 | } |
46 | } | 48 | } |
49 | EXPORT_SYMBOL(nfc_hci_result_to_errno); | ||
47 | 50 | ||
48 | static void nfc_hci_msg_tx_work(struct work_struct *work) | 51 | static void nfc_hci_msg_tx_work(struct work_struct *work) |
49 | { | 52 | { |
@@ -65,8 +68,9 @@ static void nfc_hci_msg_tx_work(struct work_struct *work) | |||
65 | -ETIME); | 68 | -ETIME); |
66 | kfree(hdev->cmd_pending_msg); | 69 | kfree(hdev->cmd_pending_msg); |
67 | hdev->cmd_pending_msg = NULL; | 70 | hdev->cmd_pending_msg = NULL; |
68 | } else | 71 | } else { |
69 | goto exit; | 72 | goto exit; |
73 | } | ||
70 | } | 74 | } |
71 | 75 | ||
72 | next_msg: | 76 | next_msg: |
@@ -166,7 +170,7 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | |||
166 | kfree_skb(skb); | 170 | kfree_skb(skb); |
167 | } | 171 | } |
168 | 172 | ||
169 | static u32 nfc_hci_sak_to_protocol(u8 sak) | 173 | u32 nfc_hci_sak_to_protocol(u8 sak) |
170 | { | 174 | { |
171 | switch (NFC_HCI_TYPE_A_SEL_PROT(sak)) { | 175 | switch (NFC_HCI_TYPE_A_SEL_PROT(sak)) { |
172 | case NFC_HCI_TYPE_A_SEL_PROT_MIFARE: | 176 | case NFC_HCI_TYPE_A_SEL_PROT_MIFARE: |
@@ -181,8 +185,9 @@ static u32 nfc_hci_sak_to_protocol(u8 sak) | |||
181 | return 0xffffffff; | 185 | return 0xffffffff; |
182 | } | 186 | } |
183 | } | 187 | } |
188 | EXPORT_SYMBOL(nfc_hci_sak_to_protocol); | ||
184 | 189 | ||
185 | static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) | 190 | int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) |
186 | { | 191 | { |
187 | struct nfc_target *targets; | 192 | struct nfc_target *targets; |
188 | struct sk_buff *atqa_skb = NULL; | 193 | struct sk_buff *atqa_skb = NULL; |
@@ -263,7 +268,9 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) | |||
263 | break; | 268 | break; |
264 | } | 269 | } |
265 | 270 | ||
266 | targets->hci_reader_gate = gate; | 271 | /* if driver set the new gate, we will skip the old one */ |
272 | if (targets->hci_reader_gate == 0x00) | ||
273 | targets->hci_reader_gate = gate; | ||
267 | 274 | ||
268 | r = nfc_targets_found(hdev->ndev, targets, 1); | 275 | r = nfc_targets_found(hdev->ndev, targets, 1); |
269 | 276 | ||
@@ -275,11 +282,18 @@ exit: | |||
275 | 282 | ||
276 | return r; | 283 | return r; |
277 | } | 284 | } |
285 | EXPORT_SYMBOL(nfc_hci_target_discovered); | ||
278 | 286 | ||
279 | void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | 287 | void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, |
280 | struct sk_buff *skb) | 288 | struct sk_buff *skb) |
281 | { | 289 | { |
282 | int r = 0; | 290 | int r = 0; |
291 | u8 gate = nfc_hci_pipe2gate(hdev, pipe); | ||
292 | |||
293 | if (gate == 0xff) { | ||
294 | pr_err("Discarded event %x to unopened pipe %x\n", event, pipe); | ||
295 | goto exit; | ||
296 | } | ||
283 | 297 | ||
284 | switch (event) { | 298 | switch (event) { |
285 | case NFC_HCI_EVT_TARGET_DISCOVERED: | 299 | case NFC_HCI_EVT_TARGET_DISCOVERED: |
@@ -303,12 +317,14 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | |||
303 | goto exit; | 317 | goto exit; |
304 | } | 318 | } |
305 | 319 | ||
306 | r = nfc_hci_target_discovered(hdev, | 320 | r = nfc_hci_target_discovered(hdev, gate); |
307 | nfc_hci_pipe2gate(hdev, pipe)); | ||
308 | break; | 321 | break; |
309 | default: | 322 | default: |
310 | /* TODO: Unknown events are hardware specific | 323 | if (hdev->ops->event_received) { |
311 | * pass them to the driver (needs a new hci_ops) */ | 324 | hdev->ops->event_received(hdev, gate, event, skb); |
325 | return; | ||
326 | } | ||
327 | |||
312 | break; | 328 | break; |
313 | } | 329 | } |
314 | 330 | ||
@@ -410,6 +426,10 @@ static int hci_dev_version(struct nfc_hci_dev *hdev) | |||
410 | 426 | ||
411 | r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE, | 427 | r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE, |
412 | NFC_HCI_ID_MGMT_VERSION_SW, &skb); | 428 | NFC_HCI_ID_MGMT_VERSION_SW, &skb); |
429 | if (r == -EOPNOTSUPP) { | ||
430 | pr_info("Software/Hardware info not available\n"); | ||
431 | return 0; | ||
432 | } | ||
413 | if (r < 0) | 433 | if (r < 0) |
414 | return r; | 434 | return r; |
415 | 435 | ||
@@ -527,7 +547,8 @@ static int hci_start_poll(struct nfc_dev *nfc_dev, | |||
527 | return hdev->ops->start_poll(hdev, im_protocols, tm_protocols); | 547 | return hdev->ops->start_poll(hdev, im_protocols, tm_protocols); |
528 | else | 548 | else |
529 | return nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, | 549 | return nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE, |
530 | NFC_HCI_EVT_READER_REQUESTED, NULL, 0); | 550 | NFC_HCI_EVT_READER_REQUESTED, |
551 | NULL, 0); | ||
531 | } | 552 | } |
532 | 553 | ||
533 | static void hci_stop_poll(struct nfc_dev *nfc_dev) | 554 | static void hci_stop_poll(struct nfc_dev *nfc_dev) |
@@ -538,6 +559,28 @@ static void hci_stop_poll(struct nfc_dev *nfc_dev) | |||
538 | NFC_HCI_EVT_END_OPERATION, NULL, 0); | 559 | NFC_HCI_EVT_END_OPERATION, NULL, 0); |
539 | } | 560 | } |
540 | 561 | ||
562 | static int hci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | ||
563 | __u8 comm_mode, __u8 *gb, size_t gb_len) | ||
564 | { | ||
565 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | ||
566 | |||
567 | if (hdev->ops->dep_link_up) | ||
568 | return hdev->ops->dep_link_up(hdev, target, comm_mode, | ||
569 | gb, gb_len); | ||
570 | |||
571 | return 0; | ||
572 | } | ||
573 | |||
574 | static int hci_dep_link_down(struct nfc_dev *nfc_dev) | ||
575 | { | ||
576 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | ||
577 | |||
578 | if (hdev->ops->dep_link_down) | ||
579 | return hdev->ops->dep_link_down(hdev); | ||
580 | |||
581 | return 0; | ||
582 | } | ||
583 | |||
541 | static int hci_activate_target(struct nfc_dev *nfc_dev, | 584 | static int hci_activate_target(struct nfc_dev *nfc_dev, |
542 | struct nfc_target *target, u32 protocol) | 585 | struct nfc_target *target, u32 protocol) |
543 | { | 586 | { |
@@ -586,8 +629,8 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
586 | switch (target->hci_reader_gate) { | 629 | switch (target->hci_reader_gate) { |
587 | case NFC_HCI_RF_READER_A_GATE: | 630 | case NFC_HCI_RF_READER_A_GATE: |
588 | case NFC_HCI_RF_READER_B_GATE: | 631 | case NFC_HCI_RF_READER_B_GATE: |
589 | if (hdev->ops->data_exchange) { | 632 | if (hdev->ops->im_transceive) { |
590 | r = hdev->ops->data_exchange(hdev, target, skb, cb, | 633 | r = hdev->ops->im_transceive(hdev, target, skb, cb, |
591 | cb_context); | 634 | cb_context); |
592 | if (r <= 0) /* handled */ | 635 | if (r <= 0) /* handled */ |
593 | break; | 636 | break; |
@@ -604,14 +647,14 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
604 | skb->len, hci_transceive_cb, hdev); | 647 | skb->len, hci_transceive_cb, hdev); |
605 | break; | 648 | break; |
606 | default: | 649 | default: |
607 | if (hdev->ops->data_exchange) { | 650 | if (hdev->ops->im_transceive) { |
608 | r = hdev->ops->data_exchange(hdev, target, skb, cb, | 651 | r = hdev->ops->im_transceive(hdev, target, skb, cb, |
609 | cb_context); | 652 | cb_context); |
610 | if (r == 1) | 653 | if (r == 1) |
611 | r = -ENOTSUPP; | 654 | r = -ENOTSUPP; |
612 | } | 655 | } else { |
613 | else | ||
614 | r = -ENOTSUPP; | 656 | r = -ENOTSUPP; |
657 | } | ||
615 | break; | 658 | break; |
616 | } | 659 | } |
617 | 660 | ||
@@ -620,6 +663,16 @@ static int hci_transceive(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
620 | return r; | 663 | return r; |
621 | } | 664 | } |
622 | 665 | ||
666 | static int hci_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb) | ||
667 | { | ||
668 | struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev); | ||
669 | |||
670 | if (hdev->ops->tm_send) | ||
671 | return hdev->ops->tm_send(hdev, skb); | ||
672 | else | ||
673 | return -ENOTSUPP; | ||
674 | } | ||
675 | |||
623 | static int hci_check_presence(struct nfc_dev *nfc_dev, | 676 | static int hci_check_presence(struct nfc_dev *nfc_dev, |
624 | struct nfc_target *target) | 677 | struct nfc_target *target) |
625 | { | 678 | { |
@@ -723,9 +776,12 @@ static struct nfc_ops hci_nfc_ops = { | |||
723 | .dev_down = hci_dev_down, | 776 | .dev_down = hci_dev_down, |
724 | .start_poll = hci_start_poll, | 777 | .start_poll = hci_start_poll, |
725 | .stop_poll = hci_stop_poll, | 778 | .stop_poll = hci_stop_poll, |
779 | .dep_link_up = hci_dep_link_up, | ||
780 | .dep_link_down = hci_dep_link_down, | ||
726 | .activate_target = hci_activate_target, | 781 | .activate_target = hci_activate_target, |
727 | .deactivate_target = hci_deactivate_target, | 782 | .deactivate_target = hci_deactivate_target, |
728 | .im_transceive = hci_transceive, | 783 | .im_transceive = hci_transceive, |
784 | .tm_send = hci_tm_send, | ||
729 | .check_presence = hci_check_presence, | 785 | .check_presence = hci_check_presence, |
730 | }; | 786 | }; |
731 | 787 | ||
@@ -848,7 +904,7 @@ void nfc_hci_driver_failure(struct nfc_hci_dev *hdev, int err) | |||
848 | } | 904 | } |
849 | EXPORT_SYMBOL(nfc_hci_driver_failure); | 905 | EXPORT_SYMBOL(nfc_hci_driver_failure); |
850 | 906 | ||
851 | void inline nfc_hci_recv_frame(struct nfc_hci_dev *hdev, struct sk_buff *skb) | 907 | void nfc_hci_recv_frame(struct nfc_hci_dev *hdev, struct sk_buff *skb) |
852 | { | 908 | { |
853 | nfc_llc_rcv_from_drv(hdev->llc, skb); | 909 | nfc_llc_rcv_from_drv(hdev->llc, skb); |
854 | } | 910 | } |
diff --git a/net/nfc/hci/llc.c b/net/nfc/hci/llc.c index ae1205ded87f..fe5e966e5b88 100644 --- a/net/nfc/hci/llc.c +++ b/net/nfc/hci/llc.c | |||
@@ -72,7 +72,7 @@ int nfc_llc_register(const char *name, struct nfc_llc_ops *ops) | |||
72 | llc_engine->ops = ops; | 72 | llc_engine->ops = ops; |
73 | 73 | ||
74 | INIT_LIST_HEAD(&llc_engine->entry); | 74 | INIT_LIST_HEAD(&llc_engine->entry); |
75 | list_add_tail (&llc_engine->entry, &llc_engines); | 75 | list_add_tail(&llc_engine->entry, &llc_engines); |
76 | 76 | ||
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |
diff --git a/net/nfc/hci/llc_shdlc.c b/net/nfc/hci/llc_shdlc.c index 01cbc72943cd..27b313befc35 100644 --- a/net/nfc/hci/llc_shdlc.c +++ b/net/nfc/hci/llc_shdlc.c | |||
@@ -634,9 +634,9 @@ static void llc_shdlc_sm_work(struct work_struct *work) | |||
634 | r = llc_shdlc_connect_initiate(shdlc); | 634 | r = llc_shdlc_connect_initiate(shdlc); |
635 | else | 635 | else |
636 | r = -ETIME; | 636 | r = -ETIME; |
637 | if (r < 0) | 637 | if (r < 0) { |
638 | llc_shdlc_connect_complete(shdlc, r); | 638 | llc_shdlc_connect_complete(shdlc, r); |
639 | else { | 639 | } else { |
640 | mod_timer(&shdlc->connect_timer, jiffies + | 640 | mod_timer(&shdlc->connect_timer, jiffies + |
641 | msecs_to_jiffies(SHDLC_CONNECT_VALUE_MS)); | 641 | msecs_to_jiffies(SHDLC_CONNECT_VALUE_MS)); |
642 | 642 | ||
@@ -682,9 +682,8 @@ static void llc_shdlc_sm_work(struct work_struct *work) | |||
682 | llc_shdlc_handle_send_queue(shdlc); | 682 | llc_shdlc_handle_send_queue(shdlc); |
683 | } | 683 | } |
684 | 684 | ||
685 | if (shdlc->hard_fault) { | 685 | if (shdlc->hard_fault) |
686 | shdlc->llc_failure(shdlc->hdev, shdlc->hard_fault); | 686 | shdlc->llc_failure(shdlc->hdev, shdlc->hard_fault); |
687 | } | ||
688 | break; | 687 | break; |
689 | default: | 688 | default: |
690 | break; | 689 | break; |
diff --git a/net/nfc/llcp/Kconfig b/net/nfc/llcp/Kconfig index fbf5e8150908..a1a41cd68255 100644 --- a/net/nfc/llcp/Kconfig +++ b/net/nfc/llcp/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config NFC_LLCP | 1 | config NFC_LLCP |
2 | depends on NFC && EXPERIMENTAL | 2 | depends on NFC |
3 | bool "NFC LLCP support (EXPERIMENTAL)" | 3 | bool "NFC LLCP support" |
4 | default n | 4 | default n |
5 | help | 5 | help |
6 | Say Y here if you want to build support for a kernel NFC LLCP | 6 | Say Y here if you want to build support for a kernel NFC LLCP |
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index c45ccd6c094c..df24be48d4da 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c | |||
@@ -261,7 +261,6 @@ int nfc_llcp_disconnect(struct nfc_llcp_sock *sock) | |||
261 | struct sk_buff *skb; | 261 | struct sk_buff *skb; |
262 | struct nfc_dev *dev; | 262 | struct nfc_dev *dev; |
263 | struct nfc_llcp_local *local; | 263 | struct nfc_llcp_local *local; |
264 | u16 size = 0; | ||
265 | 264 | ||
266 | pr_debug("Sending DISC\n"); | 265 | pr_debug("Sending DISC\n"); |
267 | 266 | ||
@@ -273,17 +272,10 @@ int nfc_llcp_disconnect(struct nfc_llcp_sock *sock) | |||
273 | if (dev == NULL) | 272 | if (dev == NULL) |
274 | return -ENODEV; | 273 | return -ENODEV; |
275 | 274 | ||
276 | size += LLCP_HEADER_SIZE; | 275 | skb = llcp_allocate_pdu(sock, LLCP_PDU_DISC, 0); |
277 | size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE; | ||
278 | |||
279 | skb = alloc_skb(size, GFP_ATOMIC); | ||
280 | if (skb == NULL) | 276 | if (skb == NULL) |
281 | return -ENOMEM; | 277 | return -ENOMEM; |
282 | 278 | ||
283 | skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE); | ||
284 | |||
285 | skb = llcp_add_header(skb, sock->dsap, sock->ssap, LLCP_PDU_DISC); | ||
286 | |||
287 | skb_queue_tail(&local->tx_queue, skb); | 279 | skb_queue_tail(&local->tx_queue, skb); |
288 | 280 | ||
289 | return 0; | 281 | return 0; |
@@ -324,8 +316,7 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) | |||
324 | struct sk_buff *skb; | 316 | struct sk_buff *skb; |
325 | u8 *service_name_tlv = NULL, service_name_tlv_length; | 317 | u8 *service_name_tlv = NULL, service_name_tlv_length; |
326 | u8 *miux_tlv = NULL, miux_tlv_length; | 318 | u8 *miux_tlv = NULL, miux_tlv_length; |
327 | u8 *rw_tlv = NULL, rw_tlv_length, rw; | 319 | u8 *rw_tlv = NULL, rw_tlv_length; |
328 | __be16 miux; | ||
329 | int err; | 320 | int err; |
330 | u16 size = 0; | 321 | u16 size = 0; |
331 | 322 | ||
@@ -343,13 +334,11 @@ int nfc_llcp_send_connect(struct nfc_llcp_sock *sock) | |||
343 | size += service_name_tlv_length; | 334 | size += service_name_tlv_length; |
344 | } | 335 | } |
345 | 336 | ||
346 | miux = cpu_to_be16(LLCP_MAX_MIUX); | 337 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&local->miux, 0, |
347 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, | ||
348 | &miux_tlv_length); | 338 | &miux_tlv_length); |
349 | size += miux_tlv_length; | 339 | size += miux_tlv_length; |
350 | 340 | ||
351 | rw = LLCP_MAX_RW; | 341 | rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &local->rw, 0, &rw_tlv_length); |
352 | rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length); | ||
353 | size += rw_tlv_length; | 342 | size += rw_tlv_length; |
354 | 343 | ||
355 | pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len); | 344 | pr_debug("SKB size %d SN length %zu\n", size, sock->service_name_len); |
@@ -386,8 +375,7 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) | |||
386 | struct nfc_llcp_local *local; | 375 | struct nfc_llcp_local *local; |
387 | struct sk_buff *skb; | 376 | struct sk_buff *skb; |
388 | u8 *miux_tlv = NULL, miux_tlv_length; | 377 | u8 *miux_tlv = NULL, miux_tlv_length; |
389 | u8 *rw_tlv = NULL, rw_tlv_length, rw; | 378 | u8 *rw_tlv = NULL, rw_tlv_length; |
390 | __be16 miux; | ||
391 | int err; | 379 | int err; |
392 | u16 size = 0; | 380 | u16 size = 0; |
393 | 381 | ||
@@ -397,13 +385,11 @@ int nfc_llcp_send_cc(struct nfc_llcp_sock *sock) | |||
397 | if (local == NULL) | 385 | if (local == NULL) |
398 | return -ENODEV; | 386 | return -ENODEV; |
399 | 387 | ||
400 | miux = cpu_to_be16(LLCP_MAX_MIUX); | 388 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&local->miux, 0, |
401 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, | ||
402 | &miux_tlv_length); | 389 | &miux_tlv_length); |
403 | size += miux_tlv_length; | 390 | size += miux_tlv_length; |
404 | 391 | ||
405 | rw = LLCP_MAX_RW; | 392 | rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &local->rw, 0, &rw_tlv_length); |
406 | rw_tlv = nfc_llcp_build_tlv(LLCP_TLV_RW, &rw, 0, &rw_tlv_length); | ||
407 | size += rw_tlv_length; | 393 | size += rw_tlv_length; |
408 | 394 | ||
409 | skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size); | 395 | skb = llcp_allocate_pdu(sock, LLCP_PDU_CC, size); |
@@ -428,6 +414,52 @@ error_tlv: | |||
428 | return err; | 414 | return err; |
429 | } | 415 | } |
430 | 416 | ||
417 | int nfc_llcp_send_snl(struct nfc_llcp_local *local, u8 tid, u8 sap) | ||
418 | { | ||
419 | struct sk_buff *skb; | ||
420 | struct nfc_dev *dev; | ||
421 | u8 *sdres_tlv = NULL, sdres_tlv_length, sdres[2]; | ||
422 | u16 size = 0; | ||
423 | |||
424 | pr_debug("Sending SNL tid 0x%x sap 0x%x\n", tid, sap); | ||
425 | |||
426 | if (local == NULL) | ||
427 | return -ENODEV; | ||
428 | |||
429 | dev = local->dev; | ||
430 | if (dev == NULL) | ||
431 | return -ENODEV; | ||
432 | |||
433 | sdres[0] = tid; | ||
434 | sdres[1] = sap; | ||
435 | sdres_tlv = nfc_llcp_build_tlv(LLCP_TLV_SDRES, sdres, 0, | ||
436 | &sdres_tlv_length); | ||
437 | if (sdres_tlv == NULL) | ||
438 | return -ENOMEM; | ||
439 | |||
440 | size += LLCP_HEADER_SIZE; | ||
441 | size += dev->tx_headroom + dev->tx_tailroom + NFC_HEADER_SIZE; | ||
442 | size += sdres_tlv_length; | ||
443 | |||
444 | skb = alloc_skb(size, GFP_KERNEL); | ||
445 | if (skb == NULL) { | ||
446 | kfree(sdres_tlv); | ||
447 | return -ENOMEM; | ||
448 | } | ||
449 | |||
450 | skb_reserve(skb, dev->tx_headroom + NFC_HEADER_SIZE); | ||
451 | |||
452 | skb = llcp_add_header(skb, LLCP_SAP_SDP, LLCP_SAP_SDP, LLCP_PDU_SNL); | ||
453 | |||
454 | memcpy(skb_put(skb, sdres_tlv_length), sdres_tlv, sdres_tlv_length); | ||
455 | |||
456 | skb_queue_tail(&local->tx_queue, skb); | ||
457 | |||
458 | kfree(sdres_tlv); | ||
459 | |||
460 | return 0; | ||
461 | } | ||
462 | |||
431 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason) | 463 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason) |
432 | { | 464 | { |
433 | struct sk_buff *skb; | 465 | struct sk_buff *skb; |
@@ -496,6 +528,23 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
496 | if (local == NULL) | 528 | if (local == NULL) |
497 | return -ENODEV; | 529 | return -ENODEV; |
498 | 530 | ||
531 | /* Remote is ready but has not acknowledged our frames */ | ||
532 | if((sock->remote_ready && | ||
533 | skb_queue_len(&sock->tx_pending_queue) >= sock->rw && | ||
534 | skb_queue_len(&sock->tx_queue) >= 2 * sock->rw)) { | ||
535 | pr_err("Pending queue is full %d frames\n", | ||
536 | skb_queue_len(&sock->tx_pending_queue)); | ||
537 | return -ENOBUFS; | ||
538 | } | ||
539 | |||
540 | /* Remote is not ready and we've been queueing enough frames */ | ||
541 | if ((!sock->remote_ready && | ||
542 | skb_queue_len(&sock->tx_queue) >= 2 * sock->rw)) { | ||
543 | pr_err("Tx queue is full %d frames\n", | ||
544 | skb_queue_len(&sock->tx_queue)); | ||
545 | return -ENOBUFS; | ||
546 | } | ||
547 | |||
499 | msg_data = kzalloc(len, GFP_KERNEL); | 548 | msg_data = kzalloc(len, GFP_KERNEL); |
500 | if (msg_data == NULL) | 549 | if (msg_data == NULL) |
501 | return -ENOMEM; | 550 | return -ENOMEM; |
@@ -541,6 +590,63 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
541 | return len; | 590 | return len; |
542 | } | 591 | } |
543 | 592 | ||
593 | int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap, | ||
594 | struct msghdr *msg, size_t len) | ||
595 | { | ||
596 | struct sk_buff *pdu; | ||
597 | struct nfc_llcp_local *local; | ||
598 | size_t frag_len = 0, remaining_len; | ||
599 | u8 *msg_ptr, *msg_data; | ||
600 | int err; | ||
601 | |||
602 | pr_debug("Send UI frame len %zd\n", len); | ||
603 | |||
604 | local = sock->local; | ||
605 | if (local == NULL) | ||
606 | return -ENODEV; | ||
607 | |||
608 | msg_data = kzalloc(len, GFP_KERNEL); | ||
609 | if (msg_data == NULL) | ||
610 | return -ENOMEM; | ||
611 | |||
612 | if (memcpy_fromiovec(msg_data, msg->msg_iov, len)) { | ||
613 | kfree(msg_data); | ||
614 | return -EFAULT; | ||
615 | } | ||
616 | |||
617 | remaining_len = len; | ||
618 | msg_ptr = msg_data; | ||
619 | |||
620 | while (remaining_len > 0) { | ||
621 | |||
622 | frag_len = min_t(size_t, sock->miu, remaining_len); | ||
623 | |||
624 | pr_debug("Fragment %zd bytes remaining %zd", | ||
625 | frag_len, remaining_len); | ||
626 | |||
627 | pdu = nfc_alloc_send_skb(sock->dev, &sock->sk, MSG_DONTWAIT, | ||
628 | frag_len + LLCP_HEADER_SIZE, &err); | ||
629 | if (pdu == NULL) { | ||
630 | pr_err("Could not allocate PDU\n"); | ||
631 | continue; | ||
632 | } | ||
633 | |||
634 | pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI); | ||
635 | |||
636 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | ||
637 | |||
638 | /* No need to check for the peer RW for UI frames */ | ||
639 | skb_queue_tail(&local->tx_queue, pdu); | ||
640 | |||
641 | remaining_len -= frag_len; | ||
642 | msg_ptr += frag_len; | ||
643 | } | ||
644 | |||
645 | kfree(msg_data); | ||
646 | |||
647 | return len; | ||
648 | } | ||
649 | |||
544 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock) | 650 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock) |
545 | { | 651 | { |
546 | struct sk_buff *skb; | 652 | struct sk_buff *skb; |
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index cc10d073c338..2df87056c6df 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -45,12 +45,38 @@ void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *sk) | |||
45 | write_unlock(&l->lock); | 45 | write_unlock(&l->lock); |
46 | } | 46 | } |
47 | 47 | ||
48 | static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock) | ||
49 | { | ||
50 | struct nfc_llcp_local *local = sock->local; | ||
51 | struct sk_buff *s, *tmp; | ||
52 | |||
53 | pr_debug("%p\n", &sock->sk); | ||
54 | |||
55 | skb_queue_purge(&sock->tx_queue); | ||
56 | skb_queue_purge(&sock->tx_pending_queue); | ||
57 | skb_queue_purge(&sock->tx_backlog_queue); | ||
58 | |||
59 | if (local == NULL) | ||
60 | return; | ||
61 | |||
62 | /* Search for local pending SKBs that are related to this socket */ | ||
63 | skb_queue_walk_safe(&local->tx_queue, s, tmp) { | ||
64 | if (s->sk != &sock->sk) | ||
65 | continue; | ||
66 | |||
67 | skb_unlink(s, &local->tx_queue); | ||
68 | kfree_skb(s); | ||
69 | } | ||
70 | } | ||
71 | |||
48 | static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | 72 | static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) |
49 | { | 73 | { |
50 | struct sock *sk; | 74 | struct sock *sk; |
51 | struct hlist_node *node, *tmp; | 75 | struct hlist_node *node, *tmp; |
52 | struct nfc_llcp_sock *llcp_sock; | 76 | struct nfc_llcp_sock *llcp_sock; |
53 | 77 | ||
78 | skb_queue_purge(&local->tx_queue); | ||
79 | |||
54 | write_lock(&local->sockets.lock); | 80 | write_lock(&local->sockets.lock); |
55 | 81 | ||
56 | sk_for_each_safe(sk, node, tmp, &local->sockets.head) { | 82 | sk_for_each_safe(sk, node, tmp, &local->sockets.head) { |
@@ -58,6 +84,8 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
58 | 84 | ||
59 | bh_lock_sock(sk); | 85 | bh_lock_sock(sk); |
60 | 86 | ||
87 | nfc_llcp_socket_purge(llcp_sock); | ||
88 | |||
61 | if (sk->sk_state == LLCP_CONNECTED) | 89 | if (sk->sk_state == LLCP_CONNECTED) |
62 | nfc_put_device(llcp_sock->dev); | 90 | nfc_put_device(llcp_sock->dev); |
63 | 91 | ||
@@ -65,7 +93,8 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
65 | struct nfc_llcp_sock *lsk, *n; | 93 | struct nfc_llcp_sock *lsk, *n; |
66 | struct sock *accept_sk; | 94 | struct sock *accept_sk; |
67 | 95 | ||
68 | list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue, | 96 | list_for_each_entry_safe(lsk, n, |
97 | &llcp_sock->accept_queue, | ||
69 | accept_queue) { | 98 | accept_queue) { |
70 | accept_sk = &lsk->sk; | 99 | accept_sk = &lsk->sk; |
71 | bh_lock_sock(accept_sk); | 100 | bh_lock_sock(accept_sk); |
@@ -85,6 +114,16 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen) | |||
85 | } | 114 | } |
86 | } | 115 | } |
87 | 116 | ||
117 | /* | ||
118 | * If we have a connection less socket bound, we keep it alive | ||
119 | * if the device is still present. | ||
120 | */ | ||
121 | if (sk->sk_state == LLCP_BOUND && sk->sk_type == SOCK_DGRAM && | ||
122 | listen == true) { | ||
123 | bh_unlock_sock(sk); | ||
124 | continue; | ||
125 | } | ||
126 | |||
88 | sk->sk_state = LLCP_CLOSED; | 127 | sk->sk_state = LLCP_CLOSED; |
89 | 128 | ||
90 | bh_unlock_sock(sk); | 129 | bh_unlock_sock(sk); |
@@ -134,7 +173,7 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, | |||
134 | { | 173 | { |
135 | struct sock *sk; | 174 | struct sock *sk; |
136 | struct hlist_node *node; | 175 | struct hlist_node *node; |
137 | struct nfc_llcp_sock *llcp_sock; | 176 | struct nfc_llcp_sock *llcp_sock, *tmp_sock; |
138 | 177 | ||
139 | pr_debug("ssap dsap %d %d\n", ssap, dsap); | 178 | pr_debug("ssap dsap %d %d\n", ssap, dsap); |
140 | 179 | ||
@@ -146,10 +185,12 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, | |||
146 | llcp_sock = NULL; | 185 | llcp_sock = NULL; |
147 | 186 | ||
148 | sk_for_each(sk, node, &local->sockets.head) { | 187 | sk_for_each(sk, node, &local->sockets.head) { |
149 | llcp_sock = nfc_llcp_sock(sk); | 188 | tmp_sock = nfc_llcp_sock(sk); |
150 | 189 | ||
151 | if (llcp_sock->ssap == ssap && llcp_sock->dsap == dsap) | 190 | if (tmp_sock->ssap == ssap && tmp_sock->dsap == dsap) { |
191 | llcp_sock = tmp_sock; | ||
152 | break; | 192 | break; |
193 | } | ||
153 | } | 194 | } |
154 | 195 | ||
155 | read_unlock(&local->sockets.lock); | 196 | read_unlock(&local->sockets.lock); |
@@ -249,7 +290,12 @@ struct nfc_llcp_sock *nfc_llcp_sock_from_sn(struct nfc_llcp_local *local, | |||
249 | 290 | ||
250 | pr_debug("llcp sock %p\n", tmp_sock); | 291 | pr_debug("llcp sock %p\n", tmp_sock); |
251 | 292 | ||
252 | if (tmp_sock->sk.sk_state != LLCP_LISTEN) | 293 | if (tmp_sock->sk.sk_type == SOCK_STREAM && |
294 | tmp_sock->sk.sk_state != LLCP_LISTEN) | ||
295 | continue; | ||
296 | |||
297 | if (tmp_sock->sk.sk_type == SOCK_DGRAM && | ||
298 | tmp_sock->sk.sk_state != LLCP_BOUND) | ||
253 | continue; | 299 | continue; |
254 | 300 | ||
255 | if (tmp_sock->service_name == NULL || | 301 | if (tmp_sock->service_name == NULL || |
@@ -421,10 +467,9 @@ static u8 nfc_llcp_reserve_sdp_ssap(struct nfc_llcp_local *local) | |||
421 | static int nfc_llcp_build_gb(struct nfc_llcp_local *local) | 467 | static int nfc_llcp_build_gb(struct nfc_llcp_local *local) |
422 | { | 468 | { |
423 | u8 *gb_cur, *version_tlv, version, version_length; | 469 | u8 *gb_cur, *version_tlv, version, version_length; |
424 | u8 *lto_tlv, lto, lto_length; | 470 | u8 *lto_tlv, lto_length; |
425 | u8 *wks_tlv, wks_length; | 471 | u8 *wks_tlv, wks_length; |
426 | u8 *miux_tlv, miux_length; | 472 | u8 *miux_tlv, miux_length; |
427 | __be16 miux; | ||
428 | u8 gb_len = 0; | 473 | u8 gb_len = 0; |
429 | int ret = 0; | 474 | int ret = 0; |
430 | 475 | ||
@@ -433,9 +478,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) | |||
433 | 1, &version_length); | 478 | 1, &version_length); |
434 | gb_len += version_length; | 479 | gb_len += version_length; |
435 | 480 | ||
436 | /* 1500 ms */ | 481 | lto_tlv = nfc_llcp_build_tlv(LLCP_TLV_LTO, &local->lto, 1, <o_length); |
437 | lto = 150; | ||
438 | lto_tlv = nfc_llcp_build_tlv(LLCP_TLV_LTO, <o, 1, <o_length); | ||
439 | gb_len += lto_length; | 482 | gb_len += lto_length; |
440 | 483 | ||
441 | pr_debug("Local wks 0x%lx\n", local->local_wks); | 484 | pr_debug("Local wks 0x%lx\n", local->local_wks); |
@@ -443,8 +486,7 @@ static int nfc_llcp_build_gb(struct nfc_llcp_local *local) | |||
443 | &wks_length); | 486 | &wks_length); |
444 | gb_len += wks_length; | 487 | gb_len += wks_length; |
445 | 488 | ||
446 | miux = cpu_to_be16(LLCP_MAX_MIUX); | 489 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&local->miux, 0, |
447 | miux_tlv = nfc_llcp_build_tlv(LLCP_TLV_MIUX, (u8 *)&miux, 0, | ||
448 | &miux_length); | 490 | &miux_length); |
449 | gb_len += miux_length; | 491 | gb_len += miux_length; |
450 | 492 | ||
@@ -610,7 +652,12 @@ static void nfc_llcp_tx_work(struct work_struct *work) | |||
610 | if (skb != NULL) { | 652 | if (skb != NULL) { |
611 | sk = skb->sk; | 653 | sk = skb->sk; |
612 | llcp_sock = nfc_llcp_sock(sk); | 654 | llcp_sock = nfc_llcp_sock(sk); |
613 | if (llcp_sock != NULL) { | 655 | |
656 | if (llcp_sock == NULL && nfc_llcp_ptype(skb) == LLCP_PDU_I) { | ||
657 | nfc_llcp_send_symm(local->dev); | ||
658 | } else { | ||
659 | struct sk_buff *copy_skb = NULL; | ||
660 | u8 ptype = nfc_llcp_ptype(skb); | ||
614 | int ret; | 661 | int ret; |
615 | 662 | ||
616 | pr_debug("Sending pending skb\n"); | 663 | pr_debug("Sending pending skb\n"); |
@@ -618,24 +665,29 @@ static void nfc_llcp_tx_work(struct work_struct *work) | |||
618 | DUMP_PREFIX_OFFSET, 16, 1, | 665 | DUMP_PREFIX_OFFSET, 16, 1, |
619 | skb->data, skb->len, true); | 666 | skb->data, skb->len, true); |
620 | 667 | ||
668 | if (ptype == LLCP_PDU_I) | ||
669 | copy_skb = skb_copy(skb, GFP_ATOMIC); | ||
670 | |||
621 | nfc_llcp_send_to_raw_sock(local, skb, | 671 | nfc_llcp_send_to_raw_sock(local, skb, |
622 | NFC_LLCP_DIRECTION_TX); | 672 | NFC_LLCP_DIRECTION_TX); |
623 | 673 | ||
624 | ret = nfc_data_exchange(local->dev, local->target_idx, | 674 | ret = nfc_data_exchange(local->dev, local->target_idx, |
625 | skb, nfc_llcp_recv, local); | 675 | skb, nfc_llcp_recv, local); |
626 | 676 | ||
627 | if (!ret && nfc_llcp_ptype(skb) == LLCP_PDU_I) { | 677 | if (ret) { |
628 | skb = skb_get(skb); | 678 | kfree_skb(copy_skb); |
629 | skb_queue_tail(&llcp_sock->tx_pending_queue, | 679 | goto out; |
630 | skb); | ||
631 | } | 680 | } |
632 | } else { | 681 | |
633 | nfc_llcp_send_symm(local->dev); | 682 | if (ptype == LLCP_PDU_I && copy_skb) |
683 | skb_queue_tail(&llcp_sock->tx_pending_queue, | ||
684 | copy_skb); | ||
634 | } | 685 | } |
635 | } else { | 686 | } else { |
636 | nfc_llcp_send_symm(local->dev); | 687 | nfc_llcp_send_symm(local->dev); |
637 | } | 688 | } |
638 | 689 | ||
690 | out: | ||
639 | mod_timer(&local->link_timer, | 691 | mod_timer(&local->link_timer, |
640 | jiffies + msecs_to_jiffies(2 * local->remote_lto)); | 692 | jiffies + msecs_to_jiffies(2 * local->remote_lto)); |
641 | } | 693 | } |
@@ -704,6 +756,39 @@ static u8 *nfc_llcp_connect_sn(struct sk_buff *skb, size_t *sn_len) | |||
704 | return NULL; | 756 | return NULL; |
705 | } | 757 | } |
706 | 758 | ||
759 | static void nfc_llcp_recv_ui(struct nfc_llcp_local *local, | ||
760 | struct sk_buff *skb) | ||
761 | { | ||
762 | struct nfc_llcp_sock *llcp_sock; | ||
763 | struct nfc_llcp_ui_cb *ui_cb; | ||
764 | u8 dsap, ssap; | ||
765 | |||
766 | dsap = nfc_llcp_dsap(skb); | ||
767 | ssap = nfc_llcp_ssap(skb); | ||
768 | |||
769 | ui_cb = nfc_llcp_ui_skb_cb(skb); | ||
770 | ui_cb->dsap = dsap; | ||
771 | ui_cb->ssap = ssap; | ||
772 | |||
773 | printk("%s %d %d\n", __func__, dsap, ssap); | ||
774 | |||
775 | pr_debug("%d %d\n", dsap, ssap); | ||
776 | |||
777 | /* We're looking for a bound socket, not a client one */ | ||
778 | llcp_sock = nfc_llcp_sock_get(local, dsap, LLCP_SAP_SDP); | ||
779 | if (llcp_sock == NULL || llcp_sock->sk.sk_type != SOCK_DGRAM) | ||
780 | return; | ||
781 | |||
782 | /* There is no sequence with UI frames */ | ||
783 | skb_pull(skb, LLCP_HEADER_SIZE); | ||
784 | if (sock_queue_rcv_skb(&llcp_sock->sk, skb)) { | ||
785 | pr_err("receive queue is full\n"); | ||
786 | skb_queue_head(&llcp_sock->tx_backlog_queue, skb); | ||
787 | } | ||
788 | |||
789 | nfc_llcp_sock_put(llcp_sock); | ||
790 | } | ||
791 | |||
707 | static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | 792 | static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, |
708 | struct sk_buff *skb) | 793 | struct sk_buff *skb) |
709 | { | 794 | { |
@@ -823,9 +908,6 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, | |||
823 | fail: | 908 | fail: |
824 | /* Send DM */ | 909 | /* Send DM */ |
825 | nfc_llcp_send_dm(local, dsap, ssap, reason); | 910 | nfc_llcp_send_dm(local, dsap, ssap, reason); |
826 | |||
827 | return; | ||
828 | |||
829 | } | 911 | } |
830 | 912 | ||
831 | int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) | 913 | int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock) |
@@ -953,6 +1035,9 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, | |||
953 | 1035 | ||
954 | sk = &llcp_sock->sk; | 1036 | sk = &llcp_sock->sk; |
955 | lock_sock(sk); | 1037 | lock_sock(sk); |
1038 | |||
1039 | nfc_llcp_socket_purge(llcp_sock); | ||
1040 | |||
956 | if (sk->sk_state == LLCP_CLOSED) { | 1041 | if (sk->sk_state == LLCP_CLOSED) { |
957 | release_sock(sk); | 1042 | release_sock(sk); |
958 | nfc_llcp_sock_put(llcp_sock); | 1043 | nfc_llcp_sock_put(llcp_sock); |
@@ -1027,7 +1112,7 @@ static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, struct sk_buff *skb) | |||
1027 | } | 1112 | } |
1028 | 1113 | ||
1029 | if (llcp_sock == NULL) { | 1114 | if (llcp_sock == NULL) { |
1030 | pr_err("Invalid DM\n"); | 1115 | pr_debug("Already closed\n"); |
1031 | return; | 1116 | return; |
1032 | } | 1117 | } |
1033 | 1118 | ||
@@ -1038,8 +1123,100 @@ static void nfc_llcp_recv_dm(struct nfc_llcp_local *local, struct sk_buff *skb) | |||
1038 | sk->sk_state_change(sk); | 1123 | sk->sk_state_change(sk); |
1039 | 1124 | ||
1040 | nfc_llcp_sock_put(llcp_sock); | 1125 | nfc_llcp_sock_put(llcp_sock); |
1126 | } | ||
1041 | 1127 | ||
1042 | return; | 1128 | static void nfc_llcp_recv_snl(struct nfc_llcp_local *local, |
1129 | struct sk_buff *skb) | ||
1130 | { | ||
1131 | struct nfc_llcp_sock *llcp_sock; | ||
1132 | u8 dsap, ssap, *tlv, type, length, tid, sap; | ||
1133 | u16 tlv_len, offset; | ||
1134 | char *service_name; | ||
1135 | size_t service_name_len; | ||
1136 | |||
1137 | dsap = nfc_llcp_dsap(skb); | ||
1138 | ssap = nfc_llcp_ssap(skb); | ||
1139 | |||
1140 | pr_debug("%d %d\n", dsap, ssap); | ||
1141 | |||
1142 | if (dsap != LLCP_SAP_SDP || ssap != LLCP_SAP_SDP) { | ||
1143 | pr_err("Wrong SNL SAP\n"); | ||
1144 | return; | ||
1145 | } | ||
1146 | |||
1147 | tlv = &skb->data[LLCP_HEADER_SIZE]; | ||
1148 | tlv_len = skb->len - LLCP_HEADER_SIZE; | ||
1149 | offset = 0; | ||
1150 | |||
1151 | while (offset < tlv_len) { | ||
1152 | type = tlv[0]; | ||
1153 | length = tlv[1]; | ||
1154 | |||
1155 | switch (type) { | ||
1156 | case LLCP_TLV_SDREQ: | ||
1157 | tid = tlv[2]; | ||
1158 | service_name = (char *) &tlv[3]; | ||
1159 | service_name_len = length - 1; | ||
1160 | |||
1161 | pr_debug("Looking for %.16s\n", service_name); | ||
1162 | |||
1163 | if (service_name_len == strlen("urn:nfc:sn:sdp") && | ||
1164 | !strncmp(service_name, "urn:nfc:sn:sdp", | ||
1165 | service_name_len)) { | ||
1166 | sap = 1; | ||
1167 | goto send_snl; | ||
1168 | } | ||
1169 | |||
1170 | llcp_sock = nfc_llcp_sock_from_sn(local, service_name, | ||
1171 | service_name_len); | ||
1172 | if (!llcp_sock) { | ||
1173 | sap = 0; | ||
1174 | goto send_snl; | ||
1175 | } | ||
1176 | |||
1177 | /* | ||
1178 | * We found a socket but its ssap has not been reserved | ||
1179 | * yet. We need to assign it for good and send a reply. | ||
1180 | * The ssap will be freed when the socket is closed. | ||
1181 | */ | ||
1182 | if (llcp_sock->ssap == LLCP_SDP_UNBOUND) { | ||
1183 | atomic_t *client_count; | ||
1184 | |||
1185 | sap = nfc_llcp_reserve_sdp_ssap(local); | ||
1186 | |||
1187 | pr_debug("Reserving %d\n", sap); | ||
1188 | |||
1189 | if (sap == LLCP_SAP_MAX) { | ||
1190 | sap = 0; | ||
1191 | goto send_snl; | ||
1192 | } | ||
1193 | |||
1194 | client_count = | ||
1195 | &local->local_sdp_cnt[sap - | ||
1196 | LLCP_WKS_NUM_SAP]; | ||
1197 | |||
1198 | atomic_inc(client_count); | ||
1199 | |||
1200 | llcp_sock->ssap = sap; | ||
1201 | llcp_sock->reserved_ssap = sap; | ||
1202 | } else { | ||
1203 | sap = llcp_sock->ssap; | ||
1204 | } | ||
1205 | |||
1206 | pr_debug("%p %d\n", llcp_sock, sap); | ||
1207 | |||
1208 | send_snl: | ||
1209 | nfc_llcp_send_snl(local, tid, sap); | ||
1210 | break; | ||
1211 | |||
1212 | default: | ||
1213 | pr_err("Invalid SNL tlv value 0x%x\n", type); | ||
1214 | break; | ||
1215 | } | ||
1216 | |||
1217 | offset += length + 2; | ||
1218 | tlv += length + 2; | ||
1219 | } | ||
1043 | } | 1220 | } |
1044 | 1221 | ||
1045 | static void nfc_llcp_rx_work(struct work_struct *work) | 1222 | static void nfc_llcp_rx_work(struct work_struct *work) |
@@ -1072,6 +1249,11 @@ static void nfc_llcp_rx_work(struct work_struct *work) | |||
1072 | pr_debug("SYMM\n"); | 1249 | pr_debug("SYMM\n"); |
1073 | break; | 1250 | break; |
1074 | 1251 | ||
1252 | case LLCP_PDU_UI: | ||
1253 | pr_debug("UI\n"); | ||
1254 | nfc_llcp_recv_ui(local, skb); | ||
1255 | break; | ||
1256 | |||
1075 | case LLCP_PDU_CONNECT: | 1257 | case LLCP_PDU_CONNECT: |
1076 | pr_debug("CONNECT\n"); | 1258 | pr_debug("CONNECT\n"); |
1077 | nfc_llcp_recv_connect(local, skb); | 1259 | nfc_llcp_recv_connect(local, skb); |
@@ -1092,6 +1274,11 @@ static void nfc_llcp_rx_work(struct work_struct *work) | |||
1092 | nfc_llcp_recv_dm(local, skb); | 1274 | nfc_llcp_recv_dm(local, skb); |
1093 | break; | 1275 | break; |
1094 | 1276 | ||
1277 | case LLCP_PDU_SNL: | ||
1278 | pr_debug("SNL\n"); | ||
1279 | nfc_llcp_recv_snl(local, skb); | ||
1280 | break; | ||
1281 | |||
1095 | case LLCP_PDU_I: | 1282 | case LLCP_PDU_I: |
1096 | case LLCP_PDU_RR: | 1283 | case LLCP_PDU_RR: |
1097 | case LLCP_PDU_RNR: | 1284 | case LLCP_PDU_RNR: |
@@ -1104,8 +1291,6 @@ static void nfc_llcp_rx_work(struct work_struct *work) | |||
1104 | schedule_work(&local->tx_work); | 1291 | schedule_work(&local->tx_work); |
1105 | kfree_skb(local->rx_pending); | 1292 | kfree_skb(local->rx_pending); |
1106 | local->rx_pending = NULL; | 1293 | local->rx_pending = NULL; |
1107 | |||
1108 | return; | ||
1109 | } | 1294 | } |
1110 | 1295 | ||
1111 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err) | 1296 | void nfc_llcp_recv(void *data, struct sk_buff *skb, int err) |
@@ -1121,8 +1306,6 @@ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err) | |||
1121 | local->rx_pending = skb_get(skb); | 1306 | local->rx_pending = skb_get(skb); |
1122 | del_timer(&local->link_timer); | 1307 | del_timer(&local->link_timer); |
1123 | schedule_work(&local->rx_work); | 1308 | schedule_work(&local->rx_work); |
1124 | |||
1125 | return; | ||
1126 | } | 1309 | } |
1127 | 1310 | ||
1128 | int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb) | 1311 | int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb) |
@@ -1205,12 +1388,16 @@ int nfc_llcp_register_device(struct nfc_dev *ndev) | |||
1205 | rwlock_init(&local->connecting_sockets.lock); | 1388 | rwlock_init(&local->connecting_sockets.lock); |
1206 | rwlock_init(&local->raw_sockets.lock); | 1389 | rwlock_init(&local->raw_sockets.lock); |
1207 | 1390 | ||
1391 | local->lto = 150; /* 1500 ms */ | ||
1392 | local->rw = LLCP_MAX_RW; | ||
1393 | local->miux = cpu_to_be16(LLCP_MAX_MIUX); | ||
1394 | |||
1208 | nfc_llcp_build_gb(local); | 1395 | nfc_llcp_build_gb(local); |
1209 | 1396 | ||
1210 | local->remote_miu = LLCP_DEFAULT_MIU; | 1397 | local->remote_miu = LLCP_DEFAULT_MIU; |
1211 | local->remote_lto = LLCP_DEFAULT_LTO; | 1398 | local->remote_lto = LLCP_DEFAULT_LTO; |
1212 | 1399 | ||
1213 | list_add(&llcp_devices, &local->list); | 1400 | list_add(&local->list, &llcp_devices); |
1214 | 1401 | ||
1215 | return 0; | 1402 | return 0; |
1216 | } | 1403 | } |
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h index fdb2d24e60bd..0d62366f8cc3 100644 --- a/net/nfc/llcp/llcp.h +++ b/net/nfc/llcp/llcp.h | |||
@@ -64,6 +64,9 @@ struct nfc_llcp_local { | |||
64 | u32 target_idx; | 64 | u32 target_idx; |
65 | u8 rf_mode; | 65 | u8 rf_mode; |
66 | u8 comm_mode; | 66 | u8 comm_mode; |
67 | u8 lto; | ||
68 | u8 rw; | ||
69 | __be16 miux; | ||
67 | unsigned long local_wks; /* Well known services */ | 70 | unsigned long local_wks; /* Well known services */ |
68 | unsigned long local_sdp; /* Local services */ | 71 | unsigned long local_sdp; /* Local services */ |
69 | unsigned long local_sap; /* Local SAPs, not available for discovery */ | 72 | unsigned long local_sap; /* Local SAPs, not available for discovery */ |
@@ -124,6 +127,13 @@ struct nfc_llcp_sock { | |||
124 | struct sock *parent; | 127 | struct sock *parent; |
125 | }; | 128 | }; |
126 | 129 | ||
130 | struct nfc_llcp_ui_cb { | ||
131 | __u8 dsap; | ||
132 | __u8 ssap; | ||
133 | }; | ||
134 | |||
135 | #define nfc_llcp_ui_skb_cb(__skb) ((struct nfc_llcp_ui_cb *)&((__skb)->cb[0])) | ||
136 | |||
127 | #define nfc_llcp_sock(sk) ((struct nfc_llcp_sock *) (sk)) | 137 | #define nfc_llcp_sock(sk) ((struct nfc_llcp_sock *) (sk)) |
128 | #define nfc_llcp_dev(sk) (nfc_llcp_sock((sk))->dev) | 138 | #define nfc_llcp_dev(sk) (nfc_llcp_sock((sk))->dev) |
129 | 139 | ||
@@ -209,10 +219,13 @@ int nfc_llcp_disconnect(struct nfc_llcp_sock *sock); | |||
209 | int nfc_llcp_send_symm(struct nfc_dev *dev); | 219 | int nfc_llcp_send_symm(struct nfc_dev *dev); |
210 | int nfc_llcp_send_connect(struct nfc_llcp_sock *sock); | 220 | int nfc_llcp_send_connect(struct nfc_llcp_sock *sock); |
211 | int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); | 221 | int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); |
222 | int nfc_llcp_send_snl(struct nfc_llcp_local *local, u8 tid, u8 sap); | ||
212 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); | 223 | int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); |
213 | int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); | 224 | int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); |
214 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | 225 | int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, |
215 | struct msghdr *msg, size_t len); | 226 | struct msghdr *msg, size_t len); |
227 | int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap, | ||
228 | struct msghdr *msg, size_t len); | ||
216 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); | 229 | int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); |
217 | 230 | ||
218 | /* Socket API */ | 231 | /* Socket API */ |
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c index 63e4cdc92376..0fa1e92ceac8 100644 --- a/net/nfc/llcp/sock.c +++ b/net/nfc/llcp/sock.c | |||
@@ -205,8 +205,8 @@ static int llcp_sock_listen(struct socket *sock, int backlog) | |||
205 | 205 | ||
206 | lock_sock(sk); | 206 | lock_sock(sk); |
207 | 207 | ||
208 | if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) | 208 | if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM) || |
209 | || sk->sk_state != LLCP_BOUND) { | 209 | sk->sk_state != LLCP_BOUND) { |
210 | ret = -EBADFD; | 210 | ret = -EBADFD; |
211 | goto error; | 211 | goto error; |
212 | } | 212 | } |
@@ -608,6 +608,25 @@ static int llcp_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
608 | 608 | ||
609 | lock_sock(sk); | 609 | lock_sock(sk); |
610 | 610 | ||
611 | if (sk->sk_type == SOCK_DGRAM) { | ||
612 | struct sockaddr_nfc_llcp *addr = | ||
613 | (struct sockaddr_nfc_llcp *)msg->msg_name; | ||
614 | |||
615 | if (msg->msg_namelen < sizeof(*addr)) { | ||
616 | release_sock(sk); | ||
617 | |||
618 | pr_err("Invalid socket address length %d\n", | ||
619 | msg->msg_namelen); | ||
620 | |||
621 | return -EINVAL; | ||
622 | } | ||
623 | |||
624 | release_sock(sk); | ||
625 | |||
626 | return nfc_llcp_send_ui_frame(llcp_sock, addr->dsap, addr->ssap, | ||
627 | msg, len); | ||
628 | } | ||
629 | |||
611 | if (sk->sk_state != LLCP_CONNECTED) { | 630 | if (sk->sk_state != LLCP_CONNECTED) { |
612 | release_sock(sk); | 631 | release_sock(sk); |
613 | return -ENOTCONN; | 632 | return -ENOTCONN; |
@@ -663,11 +682,28 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
663 | return -EFAULT; | 682 | return -EFAULT; |
664 | } | 683 | } |
665 | 684 | ||
685 | if (sk->sk_type == SOCK_DGRAM && msg->msg_name) { | ||
686 | struct nfc_llcp_ui_cb *ui_cb = nfc_llcp_ui_skb_cb(skb); | ||
687 | struct sockaddr_nfc_llcp sockaddr; | ||
688 | |||
689 | pr_debug("Datagram socket %d %d\n", ui_cb->dsap, ui_cb->ssap); | ||
690 | |||
691 | sockaddr.sa_family = AF_NFC; | ||
692 | sockaddr.nfc_protocol = NFC_PROTO_NFC_DEP; | ||
693 | sockaddr.dsap = ui_cb->dsap; | ||
694 | sockaddr.ssap = ui_cb->ssap; | ||
695 | |||
696 | memcpy(msg->msg_name, &sockaddr, sizeof(sockaddr)); | ||
697 | msg->msg_namelen = sizeof(sockaddr); | ||
698 | } | ||
699 | |||
666 | /* Mark read part of skb as used */ | 700 | /* Mark read part of skb as used */ |
667 | if (!(flags & MSG_PEEK)) { | 701 | if (!(flags & MSG_PEEK)) { |
668 | 702 | ||
669 | /* SOCK_STREAM: re-queue skb if it contains unreceived data */ | 703 | /* SOCK_STREAM: re-queue skb if it contains unreceived data */ |
670 | if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_RAW) { | 704 | if (sk->sk_type == SOCK_STREAM || |
705 | sk->sk_type == SOCK_DGRAM || | ||
706 | sk->sk_type == SOCK_RAW) { | ||
671 | skb_pull(skb, copied); | 707 | skb_pull(skb, copied); |
672 | if (skb->len) { | 708 | if (skb->len) { |
673 | skb_queue_head(&sk->sk_receive_queue, skb); | 709 | skb_queue_head(&sk->sk_receive_queue, skb); |
diff --git a/net/nfc/nci/Kconfig b/net/nfc/nci/Kconfig index decdc49b26d8..6d69b5f0f19b 100644 --- a/net/nfc/nci/Kconfig +++ b/net/nfc/nci/Kconfig | |||
@@ -1,6 +1,6 @@ | |||
1 | config NFC_NCI | 1 | config NFC_NCI |
2 | depends on NFC && EXPERIMENTAL | 2 | depends on NFC |
3 | tristate "NCI protocol support (EXPERIMENTAL)" | 3 | tristate "NCI protocol support" |
4 | default n | 4 | default n |
5 | help | 5 | help |
6 | NCI (NFC Controller Interface) is a communication protocol between | 6 | NCI (NFC Controller Interface) is a communication protocol between |
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c index acf9abb7d99b..5f98dc1bf039 100644 --- a/net/nfc/nci/core.c +++ b/net/nfc/nci/core.c | |||
@@ -205,10 +205,10 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) | |||
205 | cmd.num_disc_configs = 0; | 205 | cmd.num_disc_configs = 0; |
206 | 206 | ||
207 | if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && | 207 | if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && |
208 | (protocols & NFC_PROTO_JEWEL_MASK | 208 | (protocols & NFC_PROTO_JEWEL_MASK || |
209 | || protocols & NFC_PROTO_MIFARE_MASK | 209 | protocols & NFC_PROTO_MIFARE_MASK || |
210 | || protocols & NFC_PROTO_ISO14443_MASK | 210 | protocols & NFC_PROTO_ISO14443_MASK || |
211 | || protocols & NFC_PROTO_NFC_DEP_MASK)) { | 211 | protocols & NFC_PROTO_NFC_DEP_MASK)) { |
212 | cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = | 212 | cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = |
213 | NCI_NFC_A_PASSIVE_POLL_MODE; | 213 | NCI_NFC_A_PASSIVE_POLL_MODE; |
214 | cmd.disc_configs[cmd.num_disc_configs].frequency = 1; | 214 | cmd.disc_configs[cmd.num_disc_configs].frequency = 1; |
@@ -224,8 +224,8 @@ static void nci_rf_discover_req(struct nci_dev *ndev, unsigned long opt) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && | 226 | if ((cmd.num_disc_configs < NCI_MAX_NUM_RF_CONFIGS) && |
227 | (protocols & NFC_PROTO_FELICA_MASK | 227 | (protocols & NFC_PROTO_FELICA_MASK || |
228 | || protocols & NFC_PROTO_NFC_DEP_MASK)) { | 228 | protocols & NFC_PROTO_NFC_DEP_MASK)) { |
229 | cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = | 229 | cmd.disc_configs[cmd.num_disc_configs].rf_tech_and_mode = |
230 | NCI_NFC_F_PASSIVE_POLL_MODE; | 230 | NCI_NFC_F_PASSIVE_POLL_MODE; |
231 | cmd.disc_configs[cmd.num_disc_configs].frequency = 1; | 231 | cmd.disc_configs[cmd.num_disc_configs].frequency = 1; |
@@ -414,13 +414,13 @@ static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) | |||
414 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); | 414 | struct nci_dev *ndev = nfc_get_drvdata(nfc_dev); |
415 | struct nci_set_config_param param; | 415 | struct nci_set_config_param param; |
416 | __u8 local_gb[NFC_MAX_GT_LEN]; | 416 | __u8 local_gb[NFC_MAX_GT_LEN]; |
417 | int i, rc = 0; | 417 | int i; |
418 | 418 | ||
419 | param.val = nfc_get_local_general_bytes(nfc_dev, ¶m.len); | 419 | param.val = nfc_get_local_general_bytes(nfc_dev, ¶m.len); |
420 | if ((param.val == NULL) || (param.len == 0)) | 420 | if ((param.val == NULL) || (param.len == 0)) |
421 | return rc; | 421 | return 0; |
422 | 422 | ||
423 | if (param.len > NCI_MAX_PARAM_LEN) | 423 | if (param.len > NFC_MAX_GT_LEN) |
424 | return -EINVAL; | 424 | return -EINVAL; |
425 | 425 | ||
426 | for (i = 0; i < param.len; i++) | 426 | for (i = 0; i < param.len; i++) |
@@ -429,10 +429,8 @@ static int nci_set_local_general_bytes(struct nfc_dev *nfc_dev) | |||
429 | param.id = NCI_PN_ATR_REQ_GEN_BYTES; | 429 | param.id = NCI_PN_ATR_REQ_GEN_BYTES; |
430 | param.val = local_gb; | 430 | param.val = local_gb; |
431 | 431 | ||
432 | rc = nci_request(ndev, nci_set_config_req, (unsigned long)¶m, | 432 | return nci_request(ndev, nci_set_config_req, (unsigned long)¶m, |
433 | msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT)); | 433 | msecs_to_jiffies(NCI_SET_CONFIG_TIMEOUT)); |
434 | |||
435 | return rc; | ||
436 | } | 434 | } |
437 | 435 | ||
438 | static int nci_start_poll(struct nfc_dev *nfc_dev, | 436 | static int nci_start_poll(struct nfc_dev *nfc_dev, |
@@ -579,7 +577,6 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, | |||
579 | } | 577 | } |
580 | } | 578 | } |
581 | 579 | ||
582 | |||
583 | static int nci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | 580 | static int nci_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, |
584 | __u8 comm_mode, __u8 *gb, size_t gb_len) | 581 | __u8 comm_mode, __u8 *gb, size_t gb_len) |
585 | { | 582 | { |
@@ -806,8 +803,8 @@ int nci_recv_frame(struct sk_buff *skb) | |||
806 | 803 | ||
807 | pr_debug("len %d\n", skb->len); | 804 | pr_debug("len %d\n", skb->len); |
808 | 805 | ||
809 | if (!ndev || (!test_bit(NCI_UP, &ndev->flags) | 806 | if (!ndev || (!test_bit(NCI_UP, &ndev->flags) && |
810 | && !test_bit(NCI_INIT, &ndev->flags))) { | 807 | !test_bit(NCI_INIT, &ndev->flags))) { |
811 | kfree_skb(skb); | 808 | kfree_skb(skb); |
812 | return -ENXIO; | 809 | return -ENXIO; |
813 | } | 810 | } |
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index c1b5285cbde7..3568ae16786d 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include "nfc.h" | 30 | #include "nfc.h" |
31 | 31 | ||
32 | #include "llcp/llcp.h" | ||
33 | |||
32 | static struct genl_multicast_group nfc_genl_event_mcgrp = { | 34 | static struct genl_multicast_group nfc_genl_event_mcgrp = { |
33 | .name = NFC_GENL_MCAST_EVENT_NAME, | 35 | .name = NFC_GENL_MCAST_EVENT_NAME, |
34 | }; | 36 | }; |
@@ -364,7 +366,8 @@ static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev, | |||
364 | if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) || | 366 | if (nla_put_string(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev)) || |
365 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) || | 367 | nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx) || |
366 | nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) || | 368 | nla_put_u32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols) || |
367 | nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up)) | 369 | nla_put_u8(msg, NFC_ATTR_DEVICE_POWERED, dev->dev_up) || |
370 | nla_put_u8(msg, NFC_ATTR_RF_MODE, dev->rf_mode)) | ||
368 | goto nla_put_failure; | 371 | goto nla_put_failure; |
369 | 372 | ||
370 | return genlmsg_end(msg, hdr); | 373 | return genlmsg_end(msg, hdr); |
@@ -590,7 +593,7 @@ static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info) | |||
590 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || | 593 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || |
591 | ((!info->attrs[NFC_ATTR_IM_PROTOCOLS] && | 594 | ((!info->attrs[NFC_ATTR_IM_PROTOCOLS] && |
592 | !info->attrs[NFC_ATTR_PROTOCOLS]) && | 595 | !info->attrs[NFC_ATTR_PROTOCOLS]) && |
593 | !info->attrs[NFC_ATTR_TM_PROTOCOLS])) | 596 | !info->attrs[NFC_ATTR_TM_PROTOCOLS])) |
594 | return -EINVAL; | 597 | return -EINVAL; |
595 | 598 | ||
596 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); | 599 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); |
@@ -715,6 +718,146 @@ static int nfc_genl_dep_link_down(struct sk_buff *skb, struct genl_info *info) | |||
715 | return rc; | 718 | return rc; |
716 | } | 719 | } |
717 | 720 | ||
721 | static int nfc_genl_send_params(struct sk_buff *msg, | ||
722 | struct nfc_llcp_local *local, | ||
723 | u32 portid, u32 seq) | ||
724 | { | ||
725 | void *hdr; | ||
726 | |||
727 | hdr = genlmsg_put(msg, portid, seq, &nfc_genl_family, 0, | ||
728 | NFC_CMD_LLC_GET_PARAMS); | ||
729 | if (!hdr) | ||
730 | return -EMSGSIZE; | ||
731 | |||
732 | if (nla_put_u32(msg, NFC_ATTR_DEVICE_INDEX, local->dev->idx) || | ||
733 | nla_put_u8(msg, NFC_ATTR_LLC_PARAM_LTO, local->lto) || | ||
734 | nla_put_u8(msg, NFC_ATTR_LLC_PARAM_RW, local->rw) || | ||
735 | nla_put_u16(msg, NFC_ATTR_LLC_PARAM_MIUX, be16_to_cpu(local->miux))) | ||
736 | goto nla_put_failure; | ||
737 | |||
738 | return genlmsg_end(msg, hdr); | ||
739 | |||
740 | nla_put_failure: | ||
741 | |||
742 | genlmsg_cancel(msg, hdr); | ||
743 | return -EMSGSIZE; | ||
744 | } | ||
745 | |||
746 | static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info) | ||
747 | { | ||
748 | struct nfc_dev *dev; | ||
749 | struct nfc_llcp_local *local; | ||
750 | int rc = 0; | ||
751 | struct sk_buff *msg = NULL; | ||
752 | u32 idx; | ||
753 | |||
754 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) | ||
755 | return -EINVAL; | ||
756 | |||
757 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); | ||
758 | |||
759 | dev = nfc_get_device(idx); | ||
760 | if (!dev) | ||
761 | return -ENODEV; | ||
762 | |||
763 | device_lock(&dev->dev); | ||
764 | |||
765 | local = nfc_llcp_find_local(dev); | ||
766 | if (!local) { | ||
767 | rc = -ENODEV; | ||
768 | goto exit; | ||
769 | } | ||
770 | |||
771 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); | ||
772 | if (!msg) { | ||
773 | rc = -ENOMEM; | ||
774 | goto exit; | ||
775 | } | ||
776 | |||
777 | rc = nfc_genl_send_params(msg, local, info->snd_portid, info->snd_seq); | ||
778 | |||
779 | exit: | ||
780 | device_unlock(&dev->dev); | ||
781 | |||
782 | nfc_put_device(dev); | ||
783 | |||
784 | if (rc < 0) { | ||
785 | if (msg) | ||
786 | nlmsg_free(msg); | ||
787 | |||
788 | return rc; | ||
789 | } | ||
790 | |||
791 | return genlmsg_reply(msg, info); | ||
792 | } | ||
793 | |||
794 | static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info) | ||
795 | { | ||
796 | struct nfc_dev *dev; | ||
797 | struct nfc_llcp_local *local; | ||
798 | u8 rw = 0; | ||
799 | u16 miux = 0; | ||
800 | u32 idx; | ||
801 | int rc = 0; | ||
802 | |||
803 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || | ||
804 | (!info->attrs[NFC_ATTR_LLC_PARAM_LTO] && | ||
805 | !info->attrs[NFC_ATTR_LLC_PARAM_RW] && | ||
806 | !info->attrs[NFC_ATTR_LLC_PARAM_MIUX])) | ||
807 | return -EINVAL; | ||
808 | |||
809 | if (info->attrs[NFC_ATTR_LLC_PARAM_RW]) { | ||
810 | rw = nla_get_u8(info->attrs[NFC_ATTR_LLC_PARAM_RW]); | ||
811 | |||
812 | if (rw > LLCP_MAX_RW) | ||
813 | return -EINVAL; | ||
814 | } | ||
815 | |||
816 | if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX]) { | ||
817 | miux = nla_get_u16(info->attrs[NFC_ATTR_LLC_PARAM_MIUX]); | ||
818 | |||
819 | if (miux > LLCP_MAX_MIUX) | ||
820 | return -EINVAL; | ||
821 | } | ||
822 | |||
823 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); | ||
824 | |||
825 | dev = nfc_get_device(idx); | ||
826 | if (!dev) | ||
827 | return -ENODEV; | ||
828 | |||
829 | device_lock(&dev->dev); | ||
830 | |||
831 | local = nfc_llcp_find_local(dev); | ||
832 | if (!local) { | ||
833 | nfc_put_device(dev); | ||
834 | rc = -ENODEV; | ||
835 | goto exit; | ||
836 | } | ||
837 | |||
838 | if (info->attrs[NFC_ATTR_LLC_PARAM_LTO]) { | ||
839 | if (dev->dep_link_up) { | ||
840 | rc = -EINPROGRESS; | ||
841 | goto exit; | ||
842 | } | ||
843 | |||
844 | local->lto = nla_get_u8(info->attrs[NFC_ATTR_LLC_PARAM_LTO]); | ||
845 | } | ||
846 | |||
847 | if (info->attrs[NFC_ATTR_LLC_PARAM_RW]) | ||
848 | local->rw = rw; | ||
849 | |||
850 | if (info->attrs[NFC_ATTR_LLC_PARAM_MIUX]) | ||
851 | local->miux = cpu_to_be16(miux); | ||
852 | |||
853 | exit: | ||
854 | device_unlock(&dev->dev); | ||
855 | |||
856 | nfc_put_device(dev); | ||
857 | |||
858 | return rc; | ||
859 | } | ||
860 | |||
718 | static struct genl_ops nfc_genl_ops[] = { | 861 | static struct genl_ops nfc_genl_ops[] = { |
719 | { | 862 | { |
720 | .cmd = NFC_CMD_GET_DEVICE, | 863 | .cmd = NFC_CMD_GET_DEVICE, |
@@ -759,6 +902,16 @@ static struct genl_ops nfc_genl_ops[] = { | |||
759 | .done = nfc_genl_dump_targets_done, | 902 | .done = nfc_genl_dump_targets_done, |
760 | .policy = nfc_genl_policy, | 903 | .policy = nfc_genl_policy, |
761 | }, | 904 | }, |
905 | { | ||
906 | .cmd = NFC_CMD_LLC_GET_PARAMS, | ||
907 | .doit = nfc_genl_llc_get_params, | ||
908 | .policy = nfc_genl_policy, | ||
909 | }, | ||
910 | { | ||
911 | .cmd = NFC_CMD_LLC_SET_PARAMS, | ||
912 | .doit = nfc_genl_llc_set_params, | ||
913 | .policy = nfc_genl_policy, | ||
914 | }, | ||
762 | }; | 915 | }; |
763 | 916 | ||
764 | 917 | ||
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index c5e42b79a418..87d914d2876a 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -56,6 +56,7 @@ void nfc_llcp_unregister_device(struct nfc_dev *dev); | |||
56 | int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); | 56 | int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); |
57 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); | 57 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); |
58 | int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb); | 58 | int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb); |
59 | struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); | ||
59 | int __init nfc_llcp_init(void); | 60 | int __init nfc_llcp_init(void); |
60 | void nfc_llcp_exit(void); | 61 | void nfc_llcp_exit(void); |
61 | 62 | ||
@@ -97,6 +98,11 @@ static inline int nfc_llcp_data_received(struct nfc_dev *dev, | |||
97 | return 0; | 98 | return 0; |
98 | } | 99 | } |
99 | 100 | ||
101 | static inline struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev) | ||
102 | { | ||
103 | return NULL; | ||
104 | } | ||
105 | |||
100 | static inline int nfc_llcp_init(void) | 106 | static inline int nfc_llcp_init(void) |
101 | { | 107 | { |
102 | return 0; | 108 | return 0; |
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c index 8b8a6a2b2bad..313bf1bc848a 100644 --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c | |||
@@ -256,7 +256,6 @@ static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
256 | return rc ? : copied; | 256 | return rc ? : copied; |
257 | } | 257 | } |
258 | 258 | ||
259 | |||
260 | static const struct proto_ops rawsock_ops = { | 259 | static const struct proto_ops rawsock_ops = { |
261 | .family = PF_NFC, | 260 | .family = PF_NFC, |
262 | .owner = THIS_MODULE, | 261 | .owner = THIS_MODULE, |
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index fe4adb12b3ef..16d08b399210 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
@@ -140,14 +140,13 @@ config CFG80211_WEXT | |||
140 | extensions with cfg80211-based drivers. | 140 | extensions with cfg80211-based drivers. |
141 | 141 | ||
142 | config LIB80211 | 142 | config LIB80211 |
143 | tristate "Common routines for IEEE802.11 drivers" | 143 | tristate |
144 | default n | 144 | default n |
145 | help | 145 | help |
146 | This options enables a library of common routines used | 146 | This options enables a library of common routines used |
147 | by IEEE802.11 wireless LAN drivers. | 147 | by IEEE802.11 wireless LAN drivers. |
148 | 148 | ||
149 | Drivers should select this themselves if needed. Say Y if | 149 | Drivers should select this themselves if needed. |
150 | you want this built into your kernel. | ||
151 | 150 | ||
152 | config LIB80211_CRYPT_WEP | 151 | config LIB80211_CRYPT_WEP |
153 | tristate | 152 | tristate |
diff --git a/net/wireless/Makefile b/net/wireless/Makefile index 0f7e0d621ab0..a761670af31d 100644 --- a/net/wireless/Makefile +++ b/net/wireless/Makefile | |||
@@ -10,11 +10,13 @@ obj-$(CONFIG_WEXT_SPY) += wext-spy.o | |||
10 | obj-$(CONFIG_WEXT_PRIV) += wext-priv.o | 10 | obj-$(CONFIG_WEXT_PRIV) += wext-priv.o |
11 | 11 | ||
12 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o | 12 | cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o |
13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o | 13 | cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o |
14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o | 14 | cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o |
15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o | 15 | cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o |
16 | cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o | 16 | cfg80211-$(CONFIG_CFG80211_INTERNAL_REGDB) += regdb.o |
17 | 17 | ||
18 | CFLAGS_trace.o := -I$(src) | ||
19 | |||
18 | ccflags-y += -D__CHECK_ENDIAN__ | 20 | ccflags-y += -D__CHECK_ENDIAN__ |
19 | 21 | ||
20 | $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk | 22 | $(obj)/regdb.c: $(src)/db.txt $(src)/genregdb.awk |
diff --git a/net/wireless/ap.c b/net/wireless/ap.c index fcc60d8dbefa..324e8d851dc4 100644 --- a/net/wireless/ap.c +++ b/net/wireless/ap.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <net/cfg80211.h> | 3 | #include <net/cfg80211.h> |
4 | #include "nl80211.h" | 4 | #include "nl80211.h" |
5 | #include "core.h" | 5 | #include "core.h" |
6 | #include "rdev-ops.h" | ||
6 | 7 | ||
7 | 8 | ||
8 | static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | 9 | static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, |
@@ -23,10 +24,11 @@ static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | |||
23 | if (!wdev->beacon_interval) | 24 | if (!wdev->beacon_interval) |
24 | return -ENOENT; | 25 | return -ENOENT; |
25 | 26 | ||
26 | err = rdev->ops->stop_ap(&rdev->wiphy, dev); | 27 | err = rdev_stop_ap(rdev, dev); |
27 | if (!err) { | 28 | if (!err) { |
28 | wdev->beacon_interval = 0; | 29 | wdev->beacon_interval = 0; |
29 | wdev->channel = NULL; | 30 | wdev->channel = NULL; |
31 | wdev->ssid_len = 0; | ||
30 | } | 32 | } |
31 | 33 | ||
32 | return err; | 34 | return err; |
diff --git a/net/wireless/chan.c b/net/wireless/chan.c index 2f876b9ee344..48febd2160ba 100644 --- a/net/wireless/chan.c +++ b/net/wireless/chan.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
10 | #include <net/cfg80211.h> | 10 | #include <net/cfg80211.h> |
11 | #include "core.h" | 11 | #include "core.h" |
12 | #include "rdev-ops.h" | ||
12 | 13 | ||
13 | struct ieee80211_channel * | 14 | struct ieee80211_channel * |
14 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, | 15 | rdev_freq_to_chan(struct cfg80211_registered_device *rdev, |
@@ -52,6 +53,8 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, | |||
52 | struct ieee80211_channel *sec_chan; | 53 | struct ieee80211_channel *sec_chan; |
53 | int diff; | 54 | int diff; |
54 | 55 | ||
56 | trace_cfg80211_can_beacon_sec_chan(wiphy, chan, channel_type); | ||
57 | |||
55 | switch (channel_type) { | 58 | switch (channel_type) { |
56 | case NL80211_CHAN_HT40PLUS: | 59 | case NL80211_CHAN_HT40PLUS: |
57 | diff = 20; | 60 | diff = 20; |
@@ -60,20 +63,25 @@ bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy, | |||
60 | diff = -20; | 63 | diff = -20; |
61 | break; | 64 | break; |
62 | default: | 65 | default: |
66 | trace_cfg80211_return_bool(true); | ||
63 | return true; | 67 | return true; |
64 | } | 68 | } |
65 | 69 | ||
66 | sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); | 70 | sec_chan = ieee80211_get_channel(wiphy, chan->center_freq + diff); |
67 | if (!sec_chan) | 71 | if (!sec_chan) { |
72 | trace_cfg80211_return_bool(false); | ||
68 | return false; | 73 | return false; |
74 | } | ||
69 | 75 | ||
70 | /* we'll need a DFS capability later */ | 76 | /* we'll need a DFS capability later */ |
71 | if (sec_chan->flags & (IEEE80211_CHAN_DISABLED | | 77 | if (sec_chan->flags & (IEEE80211_CHAN_DISABLED | |
72 | IEEE80211_CHAN_PASSIVE_SCAN | | 78 | IEEE80211_CHAN_PASSIVE_SCAN | |
73 | IEEE80211_CHAN_NO_IBSS | | 79 | IEEE80211_CHAN_NO_IBSS | |
74 | IEEE80211_CHAN_RADAR)) | 80 | IEEE80211_CHAN_RADAR)) { |
81 | trace_cfg80211_return_bool(false); | ||
75 | return false; | 82 | return false; |
76 | 83 | } | |
84 | trace_cfg80211_return_bool(true); | ||
77 | return true; | 85 | return true; |
78 | } | 86 | } |
79 | EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan); | 87 | EXPORT_SYMBOL(cfg80211_can_beacon_sec_chan); |
@@ -92,7 +100,7 @@ int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev, | |||
92 | if (!chan) | 100 | if (!chan) |
93 | return -EINVAL; | 101 | return -EINVAL; |
94 | 102 | ||
95 | return rdev->ops->set_monitor_channel(&rdev->wiphy, chan, chantype); | 103 | return rdev_set_monitor_channel(rdev, chan, chantype); |
96 | } | 104 | } |
97 | 105 | ||
98 | void | 106 | void |
diff --git a/net/wireless/core.c b/net/wireless/core.c index 443d4d7deea2..14d990400354 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "debugfs.h" | 26 | #include "debugfs.h" |
27 | #include "wext-compat.h" | 27 | #include "wext-compat.h" |
28 | #include "ethtool.h" | 28 | #include "ethtool.h" |
29 | #include "rdev-ops.h" | ||
29 | 30 | ||
30 | /* name for sysfs, %d is appended */ | 31 | /* name for sysfs, %d is appended */ |
31 | #define PHY_NAME "phy" | 32 | #define PHY_NAME "phy" |
@@ -216,7 +217,7 @@ static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data) | |||
216 | { | 217 | { |
217 | struct cfg80211_registered_device *rdev = data; | 218 | struct cfg80211_registered_device *rdev = data; |
218 | 219 | ||
219 | rdev->ops->rfkill_poll(&rdev->wiphy); | 220 | rdev_rfkill_poll(rdev); |
220 | } | 221 | } |
221 | 222 | ||
222 | static int cfg80211_rfkill_set_block(void *data, bool blocked) | 223 | static int cfg80211_rfkill_set_block(void *data, bool blocked) |
@@ -240,7 +241,7 @@ static int cfg80211_rfkill_set_block(void *data, bool blocked) | |||
240 | case NL80211_IFTYPE_P2P_DEVICE: | 241 | case NL80211_IFTYPE_P2P_DEVICE: |
241 | if (!wdev->p2p_started) | 242 | if (!wdev->p2p_started) |
242 | break; | 243 | break; |
243 | rdev->ops->stop_p2p_device(&rdev->wiphy, wdev); | 244 | rdev_stop_p2p_device(rdev, wdev); |
244 | wdev->p2p_started = false; | 245 | wdev->p2p_started = false; |
245 | rdev->opencount--; | 246 | rdev->opencount--; |
246 | break; | 247 | break; |
@@ -325,6 +326,8 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
325 | mutex_init(&rdev->devlist_mtx); | 326 | mutex_init(&rdev->devlist_mtx); |
326 | mutex_init(&rdev->sched_scan_mtx); | 327 | mutex_init(&rdev->sched_scan_mtx); |
327 | INIT_LIST_HEAD(&rdev->wdev_list); | 328 | INIT_LIST_HEAD(&rdev->wdev_list); |
329 | INIT_LIST_HEAD(&rdev->beacon_registrations); | ||
330 | spin_lock_init(&rdev->beacon_registrations_lock); | ||
328 | spin_lock_init(&rdev->bss_lock); | 331 | spin_lock_init(&rdev->bss_lock); |
329 | INIT_LIST_HEAD(&rdev->bss_list); | 332 | INIT_LIST_HEAD(&rdev->bss_list); |
330 | INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done); | 333 | INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done); |
@@ -370,6 +373,8 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) | |||
370 | rdev->wiphy.rts_threshold = (u32) -1; | 373 | rdev->wiphy.rts_threshold = (u32) -1; |
371 | rdev->wiphy.coverage_class = 0; | 374 | rdev->wiphy.coverage_class = 0; |
372 | 375 | ||
376 | rdev->wiphy.features = NL80211_FEATURE_SCAN_FLUSH; | ||
377 | |||
373 | return &rdev->wiphy; | 378 | return &rdev->wiphy; |
374 | } | 379 | } |
375 | EXPORT_SYMBOL(wiphy_new); | 380 | EXPORT_SYMBOL(wiphy_new); |
@@ -526,8 +531,7 @@ int wiphy_register(struct wiphy *wiphy) | |||
526 | for (i = 0; i < sband->n_channels; i++) { | 531 | for (i = 0; i < sband->n_channels; i++) { |
527 | sband->channels[i].orig_flags = | 532 | sband->channels[i].orig_flags = |
528 | sband->channels[i].flags; | 533 | sband->channels[i].flags; |
529 | sband->channels[i].orig_mag = | 534 | sband->channels[i].orig_mag = INT_MAX; |
530 | sband->channels[i].max_antenna_gain; | ||
531 | sband->channels[i].orig_mpwr = | 535 | sband->channels[i].orig_mpwr = |
532 | sband->channels[i].max_power; | 536 | sband->channels[i].max_power; |
533 | sband->channels[i].band = band; | 537 | sband->channels[i].band = band; |
@@ -688,7 +692,7 @@ void wiphy_unregister(struct wiphy *wiphy) | |||
688 | flush_work(&rdev->event_work); | 692 | flush_work(&rdev->event_work); |
689 | 693 | ||
690 | if (rdev->wowlan && rdev->ops->set_wakeup) | 694 | if (rdev->wowlan && rdev->ops->set_wakeup) |
691 | rdev->ops->set_wakeup(&rdev->wiphy, false); | 695 | rdev_set_wakeup(rdev, false); |
692 | cfg80211_rdev_free_wowlan(rdev); | 696 | cfg80211_rdev_free_wowlan(rdev); |
693 | } | 697 | } |
694 | EXPORT_SYMBOL(wiphy_unregister); | 698 | EXPORT_SYMBOL(wiphy_unregister); |
@@ -696,10 +700,15 @@ EXPORT_SYMBOL(wiphy_unregister); | |||
696 | void cfg80211_dev_free(struct cfg80211_registered_device *rdev) | 700 | void cfg80211_dev_free(struct cfg80211_registered_device *rdev) |
697 | { | 701 | { |
698 | struct cfg80211_internal_bss *scan, *tmp; | 702 | struct cfg80211_internal_bss *scan, *tmp; |
703 | struct cfg80211_beacon_registration *reg, *treg; | ||
699 | rfkill_destroy(rdev->rfkill); | 704 | rfkill_destroy(rdev->rfkill); |
700 | mutex_destroy(&rdev->mtx); | 705 | mutex_destroy(&rdev->mtx); |
701 | mutex_destroy(&rdev->devlist_mtx); | 706 | mutex_destroy(&rdev->devlist_mtx); |
702 | mutex_destroy(&rdev->sched_scan_mtx); | 707 | mutex_destroy(&rdev->sched_scan_mtx); |
708 | list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) { | ||
709 | list_del(®->list); | ||
710 | kfree(reg); | ||
711 | } | ||
703 | list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) | 712 | list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list) |
704 | cfg80211_put_bss(&scan->pub); | 713 | cfg80211_put_bss(&scan->pub); |
705 | kfree(rdev); | 714 | kfree(rdev); |
@@ -771,7 +780,7 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev) | |||
771 | case NL80211_IFTYPE_P2P_DEVICE: | 780 | case NL80211_IFTYPE_P2P_DEVICE: |
772 | if (!wdev->p2p_started) | 781 | if (!wdev->p2p_started) |
773 | break; | 782 | break; |
774 | rdev->ops->stop_p2p_device(&rdev->wiphy, wdev); | 783 | rdev_stop_p2p_device(rdev, wdev); |
775 | wdev->p2p_started = false; | 784 | wdev->p2p_started = false; |
776 | rdev->opencount--; | 785 | rdev->opencount--; |
777 | break; | 786 | break; |
@@ -962,9 +971,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, | |||
962 | if ((wdev->iftype == NL80211_IFTYPE_STATION || | 971 | if ((wdev->iftype == NL80211_IFTYPE_STATION || |
963 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && | 972 | wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) && |
964 | rdev->ops->set_power_mgmt) | 973 | rdev->ops->set_power_mgmt) |
965 | if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, | 974 | if (rdev_set_power_mgmt(rdev, dev, wdev->ps, |
966 | wdev->ps, | 975 | wdev->ps_timeout)) { |
967 | wdev->ps_timeout)) { | ||
968 | /* assume this means it's off */ | 976 | /* assume this means it's off */ |
969 | wdev->ps = false; | 977 | wdev->ps = false; |
970 | } | 978 | } |
diff --git a/net/wireless/core.h b/net/wireless/core.h index a343be4a52bd..e53831c876bb 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
@@ -55,7 +55,8 @@ struct cfg80211_registered_device { | |||
55 | int opencount; /* also protected by devlist_mtx */ | 55 | int opencount; /* also protected by devlist_mtx */ |
56 | wait_queue_head_t dev_wait; | 56 | wait_queue_head_t dev_wait; |
57 | 57 | ||
58 | u32 ap_beacons_nlportid; | 58 | struct list_head beacon_registrations; |
59 | spinlock_t beacon_registrations_lock; | ||
59 | 60 | ||
60 | /* protected by RTNL only */ | 61 | /* protected by RTNL only */ |
61 | int num_running_ifaces; | 62 | int num_running_ifaces; |
@@ -260,6 +261,10 @@ enum cfg80211_chan_mode { | |||
260 | CHAN_MODE_EXCLUSIVE, | 261 | CHAN_MODE_EXCLUSIVE, |
261 | }; | 262 | }; |
262 | 263 | ||
264 | struct cfg80211_beacon_registration { | ||
265 | struct list_head list; | ||
266 | u32 nlportid; | ||
267 | }; | ||
263 | 268 | ||
264 | /* free object */ | 269 | /* free object */ |
265 | extern void cfg80211_dev_free(struct cfg80211_registered_device *rdev); | 270 | extern void cfg80211_dev_free(struct cfg80211_registered_device *rdev); |
@@ -320,13 +325,15 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
320 | const u8 *bssid, | 325 | const u8 *bssid, |
321 | const u8 *ssid, int ssid_len, | 326 | const u8 *ssid, int ssid_len, |
322 | const u8 *ie, int ie_len, | 327 | const u8 *ie, int ie_len, |
323 | const u8 *key, int key_len, int key_idx); | 328 | const u8 *key, int key_len, int key_idx, |
329 | const u8 *sae_data, int sae_data_len); | ||
324 | int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | 330 | int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, |
325 | struct net_device *dev, struct ieee80211_channel *chan, | 331 | struct net_device *dev, struct ieee80211_channel *chan, |
326 | enum nl80211_auth_type auth_type, const u8 *bssid, | 332 | enum nl80211_auth_type auth_type, const u8 *bssid, |
327 | const u8 *ssid, int ssid_len, | 333 | const u8 *ssid, int ssid_len, |
328 | const u8 *ie, int ie_len, | 334 | const u8 *ie, int ie_len, |
329 | const u8 *key, int key_len, int key_idx); | 335 | const u8 *key, int key_len, int key_idx, |
336 | const u8 *sae_data, int sae_data_len); | ||
330 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | 337 | int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, |
331 | struct net_device *dev, | 338 | struct net_device *dev, |
332 | struct ieee80211_channel *chan, | 339 | struct ieee80211_channel *chan, |
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c index 7eecdf40cf80..48c48ffafa1d 100644 --- a/net/wireless/ethtool.c +++ b/net/wireless/ethtool.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <net/cfg80211.h> | 2 | #include <net/cfg80211.h> |
3 | #include "core.h" | 3 | #include "core.h" |
4 | #include "ethtool.h" | 4 | #include "ethtool.h" |
5 | #include "rdev-ops.h" | ||
5 | 6 | ||
6 | static void cfg80211_get_drvinfo(struct net_device *dev, | 7 | static void cfg80211_get_drvinfo(struct net_device *dev, |
7 | struct ethtool_drvinfo *info) | 8 | struct ethtool_drvinfo *info) |
@@ -47,9 +48,8 @@ static void cfg80211_get_ringparam(struct net_device *dev, | |||
47 | memset(rp, 0, sizeof(*rp)); | 48 | memset(rp, 0, sizeof(*rp)); |
48 | 49 | ||
49 | if (rdev->ops->get_ringparam) | 50 | if (rdev->ops->get_ringparam) |
50 | rdev->ops->get_ringparam(wdev->wiphy, | 51 | rdev_get_ringparam(rdev, &rp->tx_pending, &rp->tx_max_pending, |
51 | &rp->tx_pending, &rp->tx_max_pending, | 52 | &rp->rx_pending, &rp->rx_max_pending); |
52 | &rp->rx_pending, &rp->rx_max_pending); | ||
53 | } | 53 | } |
54 | 54 | ||
55 | static int cfg80211_set_ringparam(struct net_device *dev, | 55 | static int cfg80211_set_ringparam(struct net_device *dev, |
@@ -62,8 +62,7 @@ static int cfg80211_set_ringparam(struct net_device *dev, | |||
62 | return -EINVAL; | 62 | return -EINVAL; |
63 | 63 | ||
64 | if (rdev->ops->set_ringparam) | 64 | if (rdev->ops->set_ringparam) |
65 | return rdev->ops->set_ringparam(wdev->wiphy, | 65 | return rdev_set_ringparam(rdev, rp->tx_pending, rp->rx_pending); |
66 | rp->tx_pending, rp->rx_pending); | ||
67 | 66 | ||
68 | return -ENOTSUPP; | 67 | return -ENOTSUPP; |
69 | } | 68 | } |
@@ -73,7 +72,7 @@ static int cfg80211_get_sset_count(struct net_device *dev, int sset) | |||
73 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 72 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
74 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 73 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
75 | if (rdev->ops->get_et_sset_count) | 74 | if (rdev->ops->get_et_sset_count) |
76 | return rdev->ops->get_et_sset_count(wdev->wiphy, dev, sset); | 75 | return rdev_get_et_sset_count(rdev, dev, sset); |
77 | return -EOPNOTSUPP; | 76 | return -EOPNOTSUPP; |
78 | } | 77 | } |
79 | 78 | ||
@@ -83,7 +82,7 @@ static void cfg80211_get_stats(struct net_device *dev, | |||
83 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 82 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
84 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 83 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
85 | if (rdev->ops->get_et_stats) | 84 | if (rdev->ops->get_et_stats) |
86 | rdev->ops->get_et_stats(wdev->wiphy, dev, stats, data); | 85 | rdev_get_et_stats(rdev, dev, stats, data); |
87 | } | 86 | } |
88 | 87 | ||
89 | static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) | 88 | static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) |
@@ -91,7 +90,7 @@ static void cfg80211_get_strings(struct net_device *dev, u32 sset, u8 *data) | |||
91 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 90 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
92 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | 91 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); |
93 | if (rdev->ops->get_et_strings) | 92 | if (rdev->ops->get_et_strings) |
94 | rdev->ops->get_et_strings(wdev->wiphy, dev, sset, data); | 93 | rdev_get_et_strings(rdev, dev, sset, data); |
95 | } | 94 | } |
96 | 95 | ||
97 | const struct ethtool_ops cfg80211_ethtool_ops = { | 96 | const struct ethtool_ops cfg80211_ethtool_ops = { |
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c index ca5672f6ee2f..27941d5db72b 100644 --- a/net/wireless/ibss.c +++ b/net/wireless/ibss.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <net/cfg80211.h> | 11 | #include <net/cfg80211.h> |
12 | #include "wext-compat.h" | 12 | #include "wext-compat.h" |
13 | #include "nl80211.h" | 13 | #include "nl80211.h" |
14 | #include "rdev-ops.h" | ||
14 | 15 | ||
15 | 16 | ||
16 | void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) | 17 | void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid) |
@@ -61,6 +62,8 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp) | |||
61 | struct cfg80211_event *ev; | 62 | struct cfg80211_event *ev; |
62 | unsigned long flags; | 63 | unsigned long flags; |
63 | 64 | ||
65 | trace_cfg80211_ibss_joined(dev, bssid); | ||
66 | |||
64 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING); | 67 | CFG80211_DEV_WARN_ON(wdev->sme_state != CFG80211_SME_CONNECTING); |
65 | 68 | ||
66 | ev = kzalloc(sizeof(*ev), gfp); | 69 | ev = kzalloc(sizeof(*ev), gfp); |
@@ -128,7 +131,7 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, | |||
128 | return err; | 131 | return err; |
129 | } | 132 | } |
130 | 133 | ||
131 | err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); | 134 | err = rdev_join_ibss(rdev, dev, params); |
132 | if (err) { | 135 | if (err) { |
133 | wdev->connect_keys = NULL; | 136 | wdev->connect_keys = NULL; |
134 | wdev->sme_state = CFG80211_SME_IDLE; | 137 | wdev->sme_state = CFG80211_SME_IDLE; |
@@ -175,7 +178,7 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) | |||
175 | */ | 178 | */ |
176 | if (rdev->ops->del_key) | 179 | if (rdev->ops->del_key) |
177 | for (i = 0; i < 6; i++) | 180 | for (i = 0; i < 6; i++) |
178 | rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); | 181 | rdev_del_key(rdev, dev, i, false, NULL); |
179 | 182 | ||
180 | if (wdev->current_bss) { | 183 | if (wdev->current_bss) { |
181 | cfg80211_unhold_bss(wdev->current_bss); | 184 | cfg80211_unhold_bss(wdev->current_bss); |
@@ -211,7 +214,7 @@ int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, | |||
211 | if (!wdev->ssid_len) | 214 | if (!wdev->ssid_len) |
212 | return -ENOLINK; | 215 | return -ENOLINK; |
213 | 216 | ||
214 | err = rdev->ops->leave_ibss(&rdev->wiphy, dev); | 217 | err = rdev_leave_ibss(rdev, dev); |
215 | 218 | ||
216 | if (err) | 219 | if (err) |
217 | return err; | 220 | return err; |
diff --git a/net/wireless/mesh.c b/net/wireless/mesh.c index c384e77ff77a..966cfc4cd79d 100644 --- a/net/wireless/mesh.c +++ b/net/wireless/mesh.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <net/cfg80211.h> | 3 | #include <net/cfg80211.h> |
4 | #include "nl80211.h" | 4 | #include "nl80211.h" |
5 | #include "core.h" | 5 | #include "core.h" |
6 | #include "rdev-ops.h" | ||
6 | 7 | ||
7 | /* Default values, timeouts in ms */ | 8 | /* Default values, timeouts in ms */ |
8 | #define MESH_TTL 31 | 9 | #define MESH_TTL 31 |
@@ -160,7 +161,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, | |||
160 | if (err) | 161 | if (err) |
161 | return err; | 162 | return err; |
162 | 163 | ||
163 | err = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); | 164 | err = rdev_join_mesh(rdev, dev, conf, setup); |
164 | if (!err) { | 165 | if (!err) { |
165 | memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); | 166 | memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); |
166 | wdev->mesh_id_len = setup->mesh_id_len; | 167 | wdev->mesh_id_len = setup->mesh_id_len; |
@@ -220,9 +221,8 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev, | |||
220 | if (err) | 221 | if (err) |
221 | return err; | 222 | return err; |
222 | 223 | ||
223 | err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, | 224 | err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev, |
224 | wdev->netdev, | 225 | channel); |
225 | channel); | ||
226 | if (!err) | 226 | if (!err) |
227 | wdev->channel = channel; | 227 | wdev->channel = channel; |
228 | 228 | ||
@@ -242,6 +242,7 @@ void cfg80211_notify_new_peer_candidate(struct net_device *dev, | |||
242 | { | 242 | { |
243 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 243 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
244 | 244 | ||
245 | trace_cfg80211_notify_new_peer_candidate(dev, macaddr); | ||
245 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) | 246 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_MESH_POINT)) |
246 | return; | 247 | return; |
247 | 248 | ||
@@ -267,7 +268,7 @@ static int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev, | |||
267 | if (!wdev->mesh_id_len) | 268 | if (!wdev->mesh_id_len) |
268 | return -ENOTCONN; | 269 | return -ENOTCONN; |
269 | 270 | ||
270 | err = rdev->ops->leave_mesh(&rdev->wiphy, dev); | 271 | err = rdev_leave_mesh(rdev, dev); |
271 | if (!err) { | 272 | if (!err) { |
272 | wdev->mesh_id_len = 0; | 273 | wdev->mesh_id_len = 0; |
273 | wdev->channel = NULL; | 274 | wdev->channel = NULL; |
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c index 8016fee0752b..4bfd14f7c592 100644 --- a/net/wireless/mlme.c +++ b/net/wireless/mlme.c | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <net/iw_handler.h> | 15 | #include <net/iw_handler.h> |
16 | #include "core.h" | 16 | #include "core.h" |
17 | #include "nl80211.h" | 17 | #include "nl80211.h" |
18 | #include "rdev-ops.h" | ||
19 | |||
18 | 20 | ||
19 | void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) | 21 | void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) |
20 | { | 22 | { |
@@ -22,6 +24,7 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len) | |||
22 | struct wiphy *wiphy = wdev->wiphy; | 24 | struct wiphy *wiphy = wdev->wiphy; |
23 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 25 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
24 | 26 | ||
27 | trace_cfg80211_send_rx_auth(dev); | ||
25 | wdev_lock(wdev); | 28 | wdev_lock(wdev); |
26 | 29 | ||
27 | nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); | 30 | nl80211_send_rx_auth(rdev, dev, buf, len, GFP_KERNEL); |
@@ -42,6 +45,7 @@ void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | |||
42 | u8 *ie = mgmt->u.assoc_resp.variable; | 45 | u8 *ie = mgmt->u.assoc_resp.variable; |
43 | int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); | 46 | int ieoffs = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); |
44 | 47 | ||
48 | trace_cfg80211_send_rx_assoc(dev, bss); | ||
45 | wdev_lock(wdev); | 49 | wdev_lock(wdev); |
46 | 50 | ||
47 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); | 51 | status_code = le16_to_cpu(mgmt->u.assoc_resp.status_code); |
@@ -98,6 +102,7 @@ void __cfg80211_send_deauth(struct net_device *dev, | |||
98 | const u8 *bssid = mgmt->bssid; | 102 | const u8 *bssid = mgmt->bssid; |
99 | bool was_current = false; | 103 | bool was_current = false; |
100 | 104 | ||
105 | trace___cfg80211_send_deauth(dev); | ||
101 | ASSERT_WDEV_LOCK(wdev); | 106 | ASSERT_WDEV_LOCK(wdev); |
102 | 107 | ||
103 | if (wdev->current_bss && | 108 | if (wdev->current_bss && |
@@ -147,6 +152,7 @@ void __cfg80211_send_disassoc(struct net_device *dev, | |||
147 | u16 reason_code; | 152 | u16 reason_code; |
148 | bool from_ap; | 153 | bool from_ap; |
149 | 154 | ||
155 | trace___cfg80211_send_disassoc(dev); | ||
150 | ASSERT_WDEV_LOCK(wdev); | 156 | ASSERT_WDEV_LOCK(wdev); |
151 | 157 | ||
152 | nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); | 158 | nl80211_send_disassoc(rdev, dev, buf, len, GFP_KERNEL); |
@@ -188,6 +194,7 @@ void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, | |||
188 | struct wiphy *wiphy = wdev->wiphy; | 194 | struct wiphy *wiphy = wdev->wiphy; |
189 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 195 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
190 | 196 | ||
197 | trace_cfg80211_send_unprot_deauth(dev); | ||
191 | nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); | 198 | nl80211_send_unprot_deauth(rdev, dev, buf, len, GFP_ATOMIC); |
192 | } | 199 | } |
193 | EXPORT_SYMBOL(cfg80211_send_unprot_deauth); | 200 | EXPORT_SYMBOL(cfg80211_send_unprot_deauth); |
@@ -199,6 +206,7 @@ void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, | |||
199 | struct wiphy *wiphy = wdev->wiphy; | 206 | struct wiphy *wiphy = wdev->wiphy; |
200 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 207 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
201 | 208 | ||
209 | trace_cfg80211_send_unprot_disassoc(dev); | ||
202 | nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); | 210 | nl80211_send_unprot_disassoc(rdev, dev, buf, len, GFP_ATOMIC); |
203 | } | 211 | } |
204 | EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); | 212 | EXPORT_SYMBOL(cfg80211_send_unprot_disassoc); |
@@ -209,6 +217,7 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr) | |||
209 | struct wiphy *wiphy = wdev->wiphy; | 217 | struct wiphy *wiphy = wdev->wiphy; |
210 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 218 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
211 | 219 | ||
220 | trace_cfg80211_send_auth_timeout(dev, addr); | ||
212 | wdev_lock(wdev); | 221 | wdev_lock(wdev); |
213 | 222 | ||
214 | nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); | 223 | nl80211_send_auth_timeout(rdev, dev, addr, GFP_KERNEL); |
@@ -227,6 +236,7 @@ void cfg80211_send_assoc_timeout(struct net_device *dev, const u8 *addr) | |||
227 | struct wiphy *wiphy = wdev->wiphy; | 236 | struct wiphy *wiphy = wdev->wiphy; |
228 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 237 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
229 | 238 | ||
239 | trace_cfg80211_send_assoc_timeout(dev, addr); | ||
230 | wdev_lock(wdev); | 240 | wdev_lock(wdev); |
231 | 241 | ||
232 | nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL); | 242 | nl80211_send_assoc_timeout(rdev, dev, addr, GFP_KERNEL); |
@@ -261,6 +271,7 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, | |||
261 | } | 271 | } |
262 | #endif | 272 | #endif |
263 | 273 | ||
274 | trace_cfg80211_michael_mic_failure(dev, addr, key_type, key_id, tsc); | ||
264 | nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); | 275 | nl80211_michael_mic_failure(rdev, dev, addr, key_type, key_id, tsc, gfp); |
265 | } | 276 | } |
266 | EXPORT_SYMBOL(cfg80211_michael_mic_failure); | 277 | EXPORT_SYMBOL(cfg80211_michael_mic_failure); |
@@ -273,7 +284,8 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
273 | const u8 *bssid, | 284 | const u8 *bssid, |
274 | const u8 *ssid, int ssid_len, | 285 | const u8 *ssid, int ssid_len, |
275 | const u8 *ie, int ie_len, | 286 | const u8 *ie, int ie_len, |
276 | const u8 *key, int key_len, int key_idx) | 287 | const u8 *key, int key_len, int key_idx, |
288 | const u8 *sae_data, int sae_data_len) | ||
277 | { | 289 | { |
278 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 290 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
279 | struct cfg80211_auth_request req; | 291 | struct cfg80211_auth_request req; |
@@ -293,6 +305,8 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
293 | 305 | ||
294 | req.ie = ie; | 306 | req.ie = ie; |
295 | req.ie_len = ie_len; | 307 | req.ie_len = ie_len; |
308 | req.sae_data = sae_data; | ||
309 | req.sae_data_len = sae_data_len; | ||
296 | req.auth_type = auth_type; | 310 | req.auth_type = auth_type; |
297 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, | 311 | req.bss = cfg80211_get_bss(&rdev->wiphy, chan, bssid, ssid, ssid_len, |
298 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); | 312 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
@@ -307,7 +321,7 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
307 | if (err) | 321 | if (err) |
308 | goto out; | 322 | goto out; |
309 | 323 | ||
310 | err = rdev->ops->auth(&rdev->wiphy, dev, &req); | 324 | err = rdev_auth(rdev, dev, &req); |
311 | 325 | ||
312 | out: | 326 | out: |
313 | cfg80211_put_bss(req.bss); | 327 | cfg80211_put_bss(req.bss); |
@@ -319,7 +333,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
319 | enum nl80211_auth_type auth_type, const u8 *bssid, | 333 | enum nl80211_auth_type auth_type, const u8 *bssid, |
320 | const u8 *ssid, int ssid_len, | 334 | const u8 *ssid, int ssid_len, |
321 | const u8 *ie, int ie_len, | 335 | const u8 *ie, int ie_len, |
322 | const u8 *key, int key_len, int key_idx) | 336 | const u8 *key, int key_len, int key_idx, |
337 | const u8 *sae_data, int sae_data_len) | ||
323 | { | 338 | { |
324 | int err; | 339 | int err; |
325 | 340 | ||
@@ -327,7 +342,8 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, | |||
327 | wdev_lock(dev->ieee80211_ptr); | 342 | wdev_lock(dev->ieee80211_ptr); |
328 | err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, | 343 | err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, |
329 | ssid, ssid_len, ie, ie_len, | 344 | ssid, ssid_len, ie, ie_len, |
330 | key, key_len, key_idx); | 345 | key, key_len, key_idx, |
346 | sae_data, sae_data_len); | ||
331 | wdev_unlock(dev->ieee80211_ptr); | 347 | wdev_unlock(dev->ieee80211_ptr); |
332 | mutex_unlock(&rdev->devlist_mtx); | 348 | mutex_unlock(&rdev->devlist_mtx); |
333 | 349 | ||
@@ -410,7 +426,7 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, | |||
410 | if (err) | 426 | if (err) |
411 | goto out; | 427 | goto out; |
412 | 428 | ||
413 | err = rdev->ops->assoc(&rdev->wiphy, dev, &req); | 429 | err = rdev_assoc(rdev, dev, &req); |
414 | 430 | ||
415 | out: | 431 | out: |
416 | if (err) { | 432 | if (err) { |
@@ -457,22 +473,16 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | |||
457 | .reason_code = reason, | 473 | .reason_code = reason, |
458 | .ie = ie, | 474 | .ie = ie, |
459 | .ie_len = ie_len, | 475 | .ie_len = ie_len, |
476 | .local_state_change = local_state_change, | ||
460 | }; | 477 | }; |
461 | 478 | ||
462 | ASSERT_WDEV_LOCK(wdev); | 479 | ASSERT_WDEV_LOCK(wdev); |
463 | 480 | ||
464 | if (local_state_change) { | 481 | if (local_state_change && (!wdev->current_bss || |
465 | if (wdev->current_bss && | 482 | !ether_addr_equal(wdev->current_bss->pub.bssid, bssid))) |
466 | ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) { | ||
467 | cfg80211_unhold_bss(wdev->current_bss); | ||
468 | cfg80211_put_bss(&wdev->current_bss->pub); | ||
469 | wdev->current_bss = NULL; | ||
470 | } | ||
471 | |||
472 | return 0; | 483 | return 0; |
473 | } | ||
474 | 484 | ||
475 | return rdev->ops->deauth(&rdev->wiphy, dev, &req); | 485 | return rdev_deauth(rdev, dev, &req); |
476 | } | 486 | } |
477 | 487 | ||
478 | int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, | 488 | int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, |
@@ -517,7 +527,7 @@ static int __cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, | |||
517 | else | 527 | else |
518 | return -ENOTCONN; | 528 | return -ENOTCONN; |
519 | 529 | ||
520 | return rdev->ops->disassoc(&rdev->wiphy, dev, &req); | 530 | return rdev_disassoc(rdev, dev, &req); |
521 | } | 531 | } |
522 | 532 | ||
523 | int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, | 533 | int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev, |
@@ -558,7 +568,7 @@ void cfg80211_mlme_down(struct cfg80211_registered_device *rdev, | |||
558 | 568 | ||
559 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); | 569 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); |
560 | req.bssid = bssid; | 570 | req.bssid = bssid; |
561 | rdev->ops->deauth(&rdev->wiphy, dev, &req); | 571 | rdev_deauth(rdev, dev, &req); |
562 | 572 | ||
563 | if (wdev->current_bss) { | 573 | if (wdev->current_bss) { |
564 | cfg80211_unhold_bss(wdev->current_bss); | 574 | cfg80211_unhold_bss(wdev->current_bss); |
@@ -575,6 +585,8 @@ void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, | |||
575 | struct wiphy *wiphy = wdev->wiphy; | 585 | struct wiphy *wiphy = wdev->wiphy; |
576 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 586 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
577 | 587 | ||
588 | trace_cfg80211_ready_on_channel(wdev, cookie, chan, channel_type, | ||
589 | duration); | ||
578 | nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, channel_type, | 590 | nl80211_send_remain_on_channel(rdev, wdev, cookie, chan, channel_type, |
579 | duration, gfp); | 591 | duration, gfp); |
580 | } | 592 | } |
@@ -588,6 +600,8 @@ void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, | |||
588 | struct wiphy *wiphy = wdev->wiphy; | 600 | struct wiphy *wiphy = wdev->wiphy; |
589 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 601 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
590 | 602 | ||
603 | trace_cfg80211_ready_on_channel_expired(wdev, cookie, chan, | ||
604 | channel_type); | ||
591 | nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, | 605 | nl80211_send_remain_on_channel_cancel(rdev, wdev, cookie, chan, |
592 | channel_type, gfp); | 606 | channel_type, gfp); |
593 | } | 607 | } |
@@ -599,6 +613,7 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | |||
599 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | 613 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
600 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 614 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
601 | 615 | ||
616 | trace_cfg80211_new_sta(dev, mac_addr, sinfo); | ||
602 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); | 617 | nl80211_send_sta_event(rdev, dev, mac_addr, sinfo, gfp); |
603 | } | 618 | } |
604 | EXPORT_SYMBOL(cfg80211_new_sta); | 619 | EXPORT_SYMBOL(cfg80211_new_sta); |
@@ -608,6 +623,7 @@ void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp) | |||
608 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; | 623 | struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; |
609 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 624 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
610 | 625 | ||
626 | trace_cfg80211_del_sta(dev, mac_addr); | ||
611 | nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); | 627 | nl80211_send_sta_del_event(rdev, dev, mac_addr, gfp); |
612 | } | 628 | } |
613 | EXPORT_SYMBOL(cfg80211_del_sta); | 629 | EXPORT_SYMBOL(cfg80211_del_sta); |
@@ -688,7 +704,7 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid, | |||
688 | list_add(&nreg->list, &wdev->mgmt_registrations); | 704 | list_add(&nreg->list, &wdev->mgmt_registrations); |
689 | 705 | ||
690 | if (rdev->ops->mgmt_frame_register) | 706 | if (rdev->ops->mgmt_frame_register) |
691 | rdev->ops->mgmt_frame_register(wiphy, wdev, frame_type, true); | 707 | rdev_mgmt_frame_register(rdev, wdev, frame_type, true); |
692 | 708 | ||
693 | out: | 709 | out: |
694 | spin_unlock_bh(&wdev->mgmt_registrations_lock); | 710 | spin_unlock_bh(&wdev->mgmt_registrations_lock); |
@@ -711,8 +727,8 @@ void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlportid) | |||
711 | if (rdev->ops->mgmt_frame_register) { | 727 | if (rdev->ops->mgmt_frame_register) { |
712 | u16 frame_type = le16_to_cpu(reg->frame_type); | 728 | u16 frame_type = le16_to_cpu(reg->frame_type); |
713 | 729 | ||
714 | rdev->ops->mgmt_frame_register(wiphy, wdev, | 730 | rdev_mgmt_frame_register(rdev, wdev, |
715 | frame_type, false); | 731 | frame_type, false); |
716 | } | 732 | } |
717 | 733 | ||
718 | list_del(®->list); | 734 | list_del(®->list); |
@@ -838,10 +854,10 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, | |||
838 | return -EINVAL; | 854 | return -EINVAL; |
839 | 855 | ||
840 | /* Transmit the Action frame as requested by user space */ | 856 | /* Transmit the Action frame as requested by user space */ |
841 | return rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan, | 857 | return rdev_mgmt_tx(rdev, wdev, chan, offchan, |
842 | channel_type, channel_type_valid, | 858 | channel_type, channel_type_valid, |
843 | wait, buf, len, no_cck, dont_wait_for_ack, | 859 | wait, buf, len, no_cck, dont_wait_for_ack, |
844 | cookie); | 860 | cookie); |
845 | } | 861 | } |
846 | 862 | ||
847 | bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | 863 | bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, |
@@ -860,10 +876,13 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | |||
860 | cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); | 876 | cpu_to_le16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE); |
861 | u16 stype; | 877 | u16 stype; |
862 | 878 | ||
879 | trace_cfg80211_rx_mgmt(wdev, freq, sig_mbm); | ||
863 | stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; | 880 | stype = (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) >> 4; |
864 | 881 | ||
865 | if (!(stypes->rx & BIT(stype))) | 882 | if (!(stypes->rx & BIT(stype))) { |
883 | trace_cfg80211_return_bool(false); | ||
866 | return false; | 884 | return false; |
885 | } | ||
867 | 886 | ||
868 | data = buf + ieee80211_hdrlen(mgmt->frame_control); | 887 | data = buf + ieee80211_hdrlen(mgmt->frame_control); |
869 | data_len = len - ieee80211_hdrlen(mgmt->frame_control); | 888 | data_len = len - ieee80211_hdrlen(mgmt->frame_control); |
@@ -894,6 +913,7 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_mbm, | |||
894 | 913 | ||
895 | spin_unlock_bh(&wdev->mgmt_registrations_lock); | 914 | spin_unlock_bh(&wdev->mgmt_registrations_lock); |
896 | 915 | ||
916 | trace_cfg80211_return_bool(result); | ||
897 | return result; | 917 | return result; |
898 | } | 918 | } |
899 | EXPORT_SYMBOL(cfg80211_rx_mgmt); | 919 | EXPORT_SYMBOL(cfg80211_rx_mgmt); |
@@ -904,6 +924,8 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, | |||
904 | struct wiphy *wiphy = wdev->wiphy; | 924 | struct wiphy *wiphy = wdev->wiphy; |
905 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 925 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
906 | 926 | ||
927 | trace_cfg80211_mgmt_tx_status(wdev, cookie, ack); | ||
928 | |||
907 | /* Indicate TX status of the Action frame to user space */ | 929 | /* Indicate TX status of the Action frame to user space */ |
908 | nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); | 930 | nl80211_send_mgmt_tx_status(rdev, wdev, cookie, buf, len, ack, gfp); |
909 | } | 931 | } |
@@ -917,6 +939,8 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev, | |||
917 | struct wiphy *wiphy = wdev->wiphy; | 939 | struct wiphy *wiphy = wdev->wiphy; |
918 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 940 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
919 | 941 | ||
942 | trace_cfg80211_cqm_rssi_notify(dev, rssi_event); | ||
943 | |||
920 | /* Indicate roaming trigger event to user space */ | 944 | /* Indicate roaming trigger event to user space */ |
921 | nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); | 945 | nl80211_send_cqm_rssi_notify(rdev, dev, rssi_event, gfp); |
922 | } | 946 | } |
@@ -929,6 +953,8 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev, | |||
929 | struct wiphy *wiphy = wdev->wiphy; | 953 | struct wiphy *wiphy = wdev->wiphy; |
930 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 954 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
931 | 955 | ||
956 | trace_cfg80211_cqm_pktloss_notify(dev, peer, num_packets); | ||
957 | |||
932 | /* Indicate roaming trigger event to user space */ | 958 | /* Indicate roaming trigger event to user space */ |
933 | nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); | 959 | nl80211_send_cqm_pktloss_notify(rdev, dev, peer, num_packets, gfp); |
934 | } | 960 | } |
@@ -954,6 +980,7 @@ void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, | |||
954 | struct wiphy *wiphy = wdev->wiphy; | 980 | struct wiphy *wiphy = wdev->wiphy; |
955 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 981 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
956 | 982 | ||
983 | trace_cfg80211_gtk_rekey_notify(dev, bssid); | ||
957 | nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); | 984 | nl80211_gtk_rekey_notify(rdev, dev, bssid, replay_ctr, gfp); |
958 | } | 985 | } |
959 | EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); | 986 | EXPORT_SYMBOL(cfg80211_gtk_rekey_notify); |
@@ -965,6 +992,7 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, | |||
965 | struct wiphy *wiphy = wdev->wiphy; | 992 | struct wiphy *wiphy = wdev->wiphy; |
966 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 993 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
967 | 994 | ||
995 | trace_cfg80211_pmksa_candidate_notify(dev, index, bssid, preauth); | ||
968 | nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); | 996 | nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); |
969 | } | 997 | } |
970 | EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); | 998 | EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); |
@@ -977,6 +1005,8 @@ void cfg80211_ch_switch_notify(struct net_device *dev, int freq, | |||
977 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 1005 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
978 | struct ieee80211_channel *chan; | 1006 | struct ieee80211_channel *chan; |
979 | 1007 | ||
1008 | trace_cfg80211_ch_switch_notify(dev, freq, type); | ||
1009 | |||
980 | wdev_lock(wdev); | 1010 | wdev_lock(wdev); |
981 | 1011 | ||
982 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | 1012 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && |
@@ -999,12 +1029,18 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev, | |||
999 | const u8 *addr, gfp_t gfp) | 1029 | const u8 *addr, gfp_t gfp) |
1000 | { | 1030 | { |
1001 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1031 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1032 | bool ret; | ||
1033 | |||
1034 | trace_cfg80211_rx_spurious_frame(dev, addr); | ||
1002 | 1035 | ||
1003 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | 1036 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && |
1004 | wdev->iftype != NL80211_IFTYPE_P2P_GO)) | 1037 | wdev->iftype != NL80211_IFTYPE_P2P_GO)) { |
1038 | trace_cfg80211_return_bool(false); | ||
1005 | return false; | 1039 | return false; |
1006 | 1040 | } | |
1007 | return nl80211_unexpected_frame(dev, addr, gfp); | 1041 | ret = nl80211_unexpected_frame(dev, addr, gfp); |
1042 | trace_cfg80211_return_bool(ret); | ||
1043 | return ret; | ||
1008 | } | 1044 | } |
1009 | EXPORT_SYMBOL(cfg80211_rx_spurious_frame); | 1045 | EXPORT_SYMBOL(cfg80211_rx_spurious_frame); |
1010 | 1046 | ||
@@ -1012,12 +1048,18 @@ bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, | |||
1012 | const u8 *addr, gfp_t gfp) | 1048 | const u8 *addr, gfp_t gfp) |
1013 | { | 1049 | { |
1014 | struct wireless_dev *wdev = dev->ieee80211_ptr; | 1050 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
1051 | bool ret; | ||
1052 | |||
1053 | trace_cfg80211_rx_unexpected_4addr_frame(dev, addr); | ||
1015 | 1054 | ||
1016 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && | 1055 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && |
1017 | wdev->iftype != NL80211_IFTYPE_P2P_GO && | 1056 | wdev->iftype != NL80211_IFTYPE_P2P_GO && |
1018 | wdev->iftype != NL80211_IFTYPE_AP_VLAN)) | 1057 | wdev->iftype != NL80211_IFTYPE_AP_VLAN)) { |
1058 | trace_cfg80211_return_bool(false); | ||
1019 | return false; | 1059 | return false; |
1020 | 1060 | } | |
1021 | return nl80211_unexpected_4addr_frame(dev, addr, gfp); | 1061 | ret = nl80211_unexpected_4addr_frame(dev, addr, gfp); |
1062 | trace_cfg80211_return_bool(ret); | ||
1063 | return ret; | ||
1022 | } | 1064 | } |
1023 | EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); | 1065 | EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame); |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 0418a6d5c1a6..c18b2fc9d492 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -22,8 +22,8 @@ | |||
22 | #include "core.h" | 22 | #include "core.h" |
23 | #include "nl80211.h" | 23 | #include "nl80211.h" |
24 | #include "reg.h" | 24 | #include "reg.h" |
25 | #include "rdev-ops.h" | ||
25 | 26 | ||
26 | static bool nl80211_valid_auth_type(enum nl80211_auth_type auth_type); | ||
27 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | 27 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, |
28 | struct genl_info *info, | 28 | struct genl_info *info, |
29 | struct cfg80211_crypto_settings *settings, | 29 | struct cfg80211_crypto_settings *settings, |
@@ -355,6 +355,9 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = { | |||
355 | [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, | 355 | [NL80211_ATTR_BG_SCAN_PERIOD] = { .type = NLA_U16 }, |
356 | [NL80211_ATTR_WDEV] = { .type = NLA_U64 }, | 356 | [NL80211_ATTR_WDEV] = { .type = NLA_U64 }, |
357 | [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 }, | 357 | [NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 }, |
358 | [NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, }, | ||
359 | [NL80211_ATTR_VHT_CAPABILITY] = { .len = NL80211_VHT_CAPABILITY_LEN }, | ||
360 | [NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 }, | ||
358 | }; | 361 | }; |
359 | 362 | ||
360 | /* policy for the key attributes */ | 363 | /* policy for the key attributes */ |
@@ -690,7 +693,7 @@ static int nl80211_parse_key(struct genl_info *info, struct key_parse *k) | |||
690 | 693 | ||
691 | static struct cfg80211_cached_keys * | 694 | static struct cfg80211_cached_keys * |
692 | nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, | 695 | nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, |
693 | struct nlattr *keys) | 696 | struct nlattr *keys, bool *no_ht) |
694 | { | 697 | { |
695 | struct key_parse parse; | 698 | struct key_parse parse; |
696 | struct nlattr *key; | 699 | struct nlattr *key; |
@@ -733,6 +736,12 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, | |||
733 | result->params[parse.idx].key_len = parse.p.key_len; | 736 | result->params[parse.idx].key_len = parse.p.key_len; |
734 | result->params[parse.idx].key = result->data[parse.idx]; | 737 | result->params[parse.idx].key = result->data[parse.idx]; |
735 | memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); | 738 | memcpy(result->data[parse.idx], parse.p.key, parse.p.key_len); |
739 | |||
740 | if (parse.p.cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
741 | parse.p.cipher == WLAN_CIPHER_SUITE_WEP104) { | ||
742 | if (no_ht) | ||
743 | *no_ht = true; | ||
744 | } | ||
736 | } | 745 | } |
737 | 746 | ||
738 | return result; | 747 | return result; |
@@ -943,7 +952,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
943 | dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { | 952 | dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { |
944 | u32 tx_ant = 0, rx_ant = 0; | 953 | u32 tx_ant = 0, rx_ant = 0; |
945 | int res; | 954 | int res; |
946 | res = dev->ops->get_antenna(&dev->wiphy, &tx_ant, &rx_ant); | 955 | res = rdev_get_antenna(dev, &tx_ant, &rx_ant); |
947 | if (!res) { | 956 | if (!res) { |
948 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, | 957 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY_ANTENNA_TX, |
949 | tx_ant) || | 958 | tx_ant) || |
@@ -1101,6 +1110,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1101 | goto nla_put_failure; | 1110 | goto nla_put_failure; |
1102 | } | 1111 | } |
1103 | CMD(start_p2p_device, START_P2P_DEVICE); | 1112 | CMD(start_p2p_device, START_P2P_DEVICE); |
1113 | CMD(set_mcast_rate, SET_MCAST_RATE); | ||
1104 | 1114 | ||
1105 | #ifdef CONFIG_NL80211_TESTMODE | 1115 | #ifdef CONFIG_NL80211_TESTMODE |
1106 | CMD(testmode_cmd, TESTMODE); | 1116 | CMD(testmode_cmd, TESTMODE); |
@@ -1457,7 +1467,7 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, struct genl_info *info) | |||
1457 | return -EOPNOTSUPP; | 1467 | return -EOPNOTSUPP; |
1458 | 1468 | ||
1459 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1469 | bssid = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1460 | return rdev->ops->set_wds_peer(wdev->wiphy, dev, bssid); | 1470 | return rdev_set_wds_peer(rdev, dev, bssid); |
1461 | } | 1471 | } |
1462 | 1472 | ||
1463 | 1473 | ||
@@ -1507,10 +1517,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1507 | result = 0; | 1517 | result = 0; |
1508 | 1518 | ||
1509 | mutex_lock(&rdev->mtx); | 1519 | mutex_lock(&rdev->mtx); |
1510 | } else if (nl80211_can_set_dev_channel(netdev->ieee80211_ptr)) | 1520 | } else |
1511 | wdev = netdev->ieee80211_ptr; | 1521 | wdev = netdev->ieee80211_ptr; |
1512 | else | ||
1513 | wdev = NULL; | ||
1514 | 1522 | ||
1515 | /* | 1523 | /* |
1516 | * end workaround code, by now the rdev is available | 1524 | * end workaround code, by now the rdev is available |
@@ -1562,24 +1570,29 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1562 | if (result) | 1570 | if (result) |
1563 | goto bad_res; | 1571 | goto bad_res; |
1564 | 1572 | ||
1565 | result = rdev->ops->set_txq_params(&rdev->wiphy, | 1573 | result = rdev_set_txq_params(rdev, netdev, |
1566 | netdev, | 1574 | &txq_params); |
1567 | &txq_params); | ||
1568 | if (result) | 1575 | if (result) |
1569 | goto bad_res; | 1576 | goto bad_res; |
1570 | } | 1577 | } |
1571 | } | 1578 | } |
1572 | 1579 | ||
1573 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { | 1580 | if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { |
1574 | result = __nl80211_set_channel(rdev, wdev, info); | 1581 | result = __nl80211_set_channel(rdev, |
1582 | nl80211_can_set_dev_channel(wdev) ? wdev : NULL, | ||
1583 | info); | ||
1575 | if (result) | 1584 | if (result) |
1576 | goto bad_res; | 1585 | goto bad_res; |
1577 | } | 1586 | } |
1578 | 1587 | ||
1579 | if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) { | 1588 | if (info->attrs[NL80211_ATTR_WIPHY_TX_POWER_SETTING]) { |
1589 | struct wireless_dev *txp_wdev = wdev; | ||
1580 | enum nl80211_tx_power_setting type; | 1590 | enum nl80211_tx_power_setting type; |
1581 | int idx, mbm = 0; | 1591 | int idx, mbm = 0; |
1582 | 1592 | ||
1593 | if (!(rdev->wiphy.features & NL80211_FEATURE_VIF_TXPOWER)) | ||
1594 | txp_wdev = NULL; | ||
1595 | |||
1583 | if (!rdev->ops->set_tx_power) { | 1596 | if (!rdev->ops->set_tx_power) { |
1584 | result = -EOPNOTSUPP; | 1597 | result = -EOPNOTSUPP; |
1585 | goto bad_res; | 1598 | goto bad_res; |
@@ -1599,7 +1612,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1599 | mbm = nla_get_u32(info->attrs[idx]); | 1612 | mbm = nla_get_u32(info->attrs[idx]); |
1600 | } | 1613 | } |
1601 | 1614 | ||
1602 | result = rdev->ops->set_tx_power(&rdev->wiphy, type, mbm); | 1615 | result = rdev_set_tx_power(rdev, txp_wdev, type, mbm); |
1603 | if (result) | 1616 | if (result) |
1604 | goto bad_res; | 1617 | goto bad_res; |
1605 | } | 1618 | } |
@@ -1628,7 +1641,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1628 | tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; | 1641 | tx_ant = tx_ant & rdev->wiphy.available_antennas_tx; |
1629 | rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; | 1642 | rx_ant = rx_ant & rdev->wiphy.available_antennas_rx; |
1630 | 1643 | ||
1631 | result = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant); | 1644 | result = rdev_set_antenna(rdev, tx_ant, rx_ant); |
1632 | if (result) | 1645 | if (result) |
1633 | goto bad_res; | 1646 | goto bad_res; |
1634 | } | 1647 | } |
@@ -1713,7 +1726,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info) | |||
1713 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) | 1726 | if (changed & WIPHY_PARAM_COVERAGE_CLASS) |
1714 | rdev->wiphy.coverage_class = coverage_class; | 1727 | rdev->wiphy.coverage_class = coverage_class; |
1715 | 1728 | ||
1716 | result = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); | 1729 | result = rdev_set_wiphy_params(rdev, changed); |
1717 | if (result) { | 1730 | if (result) { |
1718 | rdev->wiphy.retry_short = old_retry_short; | 1731 | rdev->wiphy.retry_short = old_retry_short; |
1719 | rdev->wiphy.retry_long = old_retry_long; | 1732 | rdev->wiphy.retry_long = old_retry_long; |
@@ -1765,8 +1778,7 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1765 | struct ieee80211_channel *chan; | 1778 | struct ieee80211_channel *chan; |
1766 | enum nl80211_channel_type channel_type; | 1779 | enum nl80211_channel_type channel_type; |
1767 | 1780 | ||
1768 | chan = rdev->ops->get_channel(&rdev->wiphy, wdev, | 1781 | chan = rdev_get_channel(rdev, wdev, &channel_type); |
1769 | &channel_type); | ||
1770 | if (chan && | 1782 | if (chan && |
1771 | (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, | 1783 | (nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, |
1772 | chan->center_freq) || | 1784 | chan->center_freq) || |
@@ -1775,6 +1787,11 @@ static int nl80211_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flag | |||
1775 | goto nla_put_failure; | 1787 | goto nla_put_failure; |
1776 | } | 1788 | } |
1777 | 1789 | ||
1790 | if (wdev->ssid_len) { | ||
1791 | if (nla_put(msg, NL80211_ATTR_SSID, wdev->ssid_len, wdev->ssid)) | ||
1792 | goto nla_put_failure; | ||
1793 | } | ||
1794 | |||
1778 | return genlmsg_end(msg, hdr); | 1795 | return genlmsg_end(msg, hdr); |
1779 | 1796 | ||
1780 | nla_put_failure: | 1797 | nla_put_failure: |
@@ -2014,9 +2031,9 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) | |||
2014 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? | 2031 | err = parse_monitor_flags(type == NL80211_IFTYPE_MONITOR ? |
2015 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, | 2032 | info->attrs[NL80211_ATTR_MNTR_FLAGS] : NULL, |
2016 | &flags); | 2033 | &flags); |
2017 | wdev = rdev->ops->add_virtual_intf(&rdev->wiphy, | 2034 | wdev = rdev_add_virtual_intf(rdev, |
2018 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), | 2035 | nla_data(info->attrs[NL80211_ATTR_IFNAME]), |
2019 | type, err ? NULL : &flags, ¶ms); | 2036 | type, err ? NULL : &flags, ¶ms); |
2020 | if (IS_ERR(wdev)) { | 2037 | if (IS_ERR(wdev)) { |
2021 | nlmsg_free(msg); | 2038 | nlmsg_free(msg); |
2022 | return PTR_ERR(wdev); | 2039 | return PTR_ERR(wdev); |
@@ -2083,7 +2100,7 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) | |||
2083 | if (!wdev->netdev) | 2100 | if (!wdev->netdev) |
2084 | info->user_ptr[1] = NULL; | 2101 | info->user_ptr[1] = NULL; |
2085 | 2102 | ||
2086 | return rdev->ops->del_virtual_intf(&rdev->wiphy, wdev); | 2103 | return rdev_del_virtual_intf(rdev, wdev); |
2087 | } | 2104 | } |
2088 | 2105 | ||
2089 | static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) | 2106 | static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) |
@@ -2100,7 +2117,7 @@ static int nl80211_set_noack_map(struct sk_buff *skb, struct genl_info *info) | |||
2100 | 2117 | ||
2101 | noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]); | 2118 | noack_map = nla_get_u16(info->attrs[NL80211_ATTR_NOACK_MAP]); |
2102 | 2119 | ||
2103 | return rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map); | 2120 | return rdev_set_noack_map(rdev, dev, noack_map); |
2104 | } | 2121 | } |
2105 | 2122 | ||
2106 | struct get_key_cookie { | 2123 | struct get_key_cookie { |
@@ -2210,8 +2227,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
2210 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) | 2227 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
2211 | return -ENOENT; | 2228 | return -ENOENT; |
2212 | 2229 | ||
2213 | err = rdev->ops->get_key(&rdev->wiphy, dev, key_idx, pairwise, | 2230 | err = rdev_get_key(rdev, dev, key_idx, pairwise, mac_addr, &cookie, |
2214 | mac_addr, &cookie, get_key_callback); | 2231 | get_key_callback); |
2215 | 2232 | ||
2216 | if (err) | 2233 | if (err) |
2217 | goto free_msg; | 2234 | goto free_msg; |
@@ -2259,7 +2276,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info) | |||
2259 | if (err) | 2276 | if (err) |
2260 | goto out; | 2277 | goto out; |
2261 | 2278 | ||
2262 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, key.idx, | 2279 | err = rdev_set_default_key(rdev, dev, key.idx, |
2263 | key.def_uni, key.def_multi); | 2280 | key.def_uni, key.def_multi); |
2264 | 2281 | ||
2265 | if (err) | 2282 | if (err) |
@@ -2283,8 +2300,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info) | |||
2283 | if (err) | 2300 | if (err) |
2284 | goto out; | 2301 | goto out; |
2285 | 2302 | ||
2286 | err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, | 2303 | err = rdev_set_default_mgmt_key(rdev, dev, key.idx); |
2287 | dev, key.idx); | ||
2288 | if (err) | 2304 | if (err) |
2289 | goto out; | 2305 | goto out; |
2290 | 2306 | ||
@@ -2340,9 +2356,9 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) | |||
2340 | wdev_lock(dev->ieee80211_ptr); | 2356 | wdev_lock(dev->ieee80211_ptr); |
2341 | err = nl80211_key_allowed(dev->ieee80211_ptr); | 2357 | err = nl80211_key_allowed(dev->ieee80211_ptr); |
2342 | if (!err) | 2358 | if (!err) |
2343 | err = rdev->ops->add_key(&rdev->wiphy, dev, key.idx, | 2359 | err = rdev_add_key(rdev, dev, key.idx, |
2344 | key.type == NL80211_KEYTYPE_PAIRWISE, | 2360 | key.type == NL80211_KEYTYPE_PAIRWISE, |
2345 | mac_addr, &key.p); | 2361 | mac_addr, &key.p); |
2346 | wdev_unlock(dev->ieee80211_ptr); | 2362 | wdev_unlock(dev->ieee80211_ptr); |
2347 | 2363 | ||
2348 | return err; | 2364 | return err; |
@@ -2386,9 +2402,9 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) | |||
2386 | err = -ENOENT; | 2402 | err = -ENOENT; |
2387 | 2403 | ||
2388 | if (!err) | 2404 | if (!err) |
2389 | err = rdev->ops->del_key(&rdev->wiphy, dev, key.idx, | 2405 | err = rdev_del_key(rdev, dev, key.idx, |
2390 | key.type == NL80211_KEYTYPE_PAIRWISE, | 2406 | key.type == NL80211_KEYTYPE_PAIRWISE, |
2391 | mac_addr); | 2407 | mac_addr); |
2392 | 2408 | ||
2393 | #ifdef CONFIG_CFG80211_WEXT | 2409 | #ifdef CONFIG_CFG80211_WEXT |
2394 | if (!err) { | 2410 | if (!err) { |
@@ -2490,6 +2506,30 @@ static bool nl80211_get_ap_channel(struct cfg80211_registered_device *rdev, | |||
2490 | return ret; | 2506 | return ret; |
2491 | } | 2507 | } |
2492 | 2508 | ||
2509 | static bool nl80211_valid_auth_type(struct cfg80211_registered_device *rdev, | ||
2510 | enum nl80211_auth_type auth_type, | ||
2511 | enum nl80211_commands cmd) | ||
2512 | { | ||
2513 | if (auth_type > NL80211_AUTHTYPE_MAX) | ||
2514 | return false; | ||
2515 | |||
2516 | switch (cmd) { | ||
2517 | case NL80211_CMD_AUTHENTICATE: | ||
2518 | if (!(rdev->wiphy.features & NL80211_FEATURE_SAE) && | ||
2519 | auth_type == NL80211_AUTHTYPE_SAE) | ||
2520 | return false; | ||
2521 | return true; | ||
2522 | case NL80211_CMD_CONNECT: | ||
2523 | case NL80211_CMD_START_AP: | ||
2524 | /* SAE not supported yet */ | ||
2525 | if (auth_type == NL80211_AUTHTYPE_SAE) | ||
2526 | return false; | ||
2527 | return true; | ||
2528 | default: | ||
2529 | return false; | ||
2530 | } | ||
2531 | } | ||
2532 | |||
2493 | static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) | 2533 | static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) |
2494 | { | 2534 | { |
2495 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 2535 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
@@ -2559,7 +2599,8 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) | |||
2559 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { | 2599 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { |
2560 | params.auth_type = nla_get_u32( | 2600 | params.auth_type = nla_get_u32( |
2561 | info->attrs[NL80211_ATTR_AUTH_TYPE]); | 2601 | info->attrs[NL80211_ATTR_AUTH_TYPE]); |
2562 | if (!nl80211_valid_auth_type(params.auth_type)) | 2602 | if (!nl80211_valid_auth_type(rdev, params.auth_type, |
2603 | NL80211_CMD_START_AP)) | ||
2563 | return -EINVAL; | 2604 | return -EINVAL; |
2564 | } else | 2605 | } else |
2565 | params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | 2606 | params.auth_type = NL80211_AUTHTYPE_AUTOMATIC; |
@@ -2607,12 +2648,14 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) | |||
2607 | if (err) | 2648 | if (err) |
2608 | return err; | 2649 | return err; |
2609 | 2650 | ||
2610 | err = rdev->ops->start_ap(&rdev->wiphy, dev, ¶ms); | 2651 | err = rdev_start_ap(rdev, dev, ¶ms); |
2611 | if (!err) { | 2652 | if (!err) { |
2612 | wdev->preset_chan = params.channel; | 2653 | wdev->preset_chan = params.channel; |
2613 | wdev->preset_chantype = params.channel_type; | 2654 | wdev->preset_chantype = params.channel_type; |
2614 | wdev->beacon_interval = params.beacon_interval; | 2655 | wdev->beacon_interval = params.beacon_interval; |
2615 | wdev->channel = params.channel; | 2656 | wdev->channel = params.channel; |
2657 | wdev->ssid_len = params.ssid_len; | ||
2658 | memcpy(wdev->ssid, params.ssid, wdev->ssid_len); | ||
2616 | } | 2659 | } |
2617 | return err; | 2660 | return err; |
2618 | } | 2661 | } |
@@ -2639,7 +2682,7 @@ static int nl80211_set_beacon(struct sk_buff *skb, struct genl_info *info) | |||
2639 | if (err) | 2682 | if (err) |
2640 | return err; | 2683 | return err; |
2641 | 2684 | ||
2642 | return rdev->ops->change_beacon(&rdev->wiphy, dev, ¶ms); | 2685 | return rdev_change_beacon(rdev, dev, ¶ms); |
2643 | } | 2686 | } |
2644 | 2687 | ||
2645 | static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info) | 2688 | static int nl80211_stop_ap(struct sk_buff *skb, struct genl_info *info) |
@@ -2923,8 +2966,8 @@ static int nl80211_dump_station(struct sk_buff *skb, | |||
2923 | 2966 | ||
2924 | while (1) { | 2967 | while (1) { |
2925 | memset(&sinfo, 0, sizeof(sinfo)); | 2968 | memset(&sinfo, 0, sizeof(sinfo)); |
2926 | err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx, | 2969 | err = rdev_dump_station(dev, netdev, sta_idx, |
2927 | mac_addr, &sinfo); | 2970 | mac_addr, &sinfo); |
2928 | if (err == -ENOENT) | 2971 | if (err == -ENOENT) |
2929 | break; | 2972 | break; |
2930 | if (err) | 2973 | if (err) |
@@ -2969,7 +3012,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
2969 | if (!rdev->ops->get_station) | 3012 | if (!rdev->ops->get_station) |
2970 | return -EOPNOTSUPP; | 3013 | return -EOPNOTSUPP; |
2971 | 3014 | ||
2972 | err = rdev->ops->get_station(&rdev->wiphy, dev, mac_addr, &sinfo); | 3015 | err = rdev_get_station(rdev, dev, mac_addr, &sinfo); |
2973 | if (err) | 3016 | if (err) |
2974 | return err; | 3017 | return err; |
2975 | 3018 | ||
@@ -3146,7 +3189,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | |||
3146 | 3189 | ||
3147 | /* be aware of params.vlan when changing code here */ | 3190 | /* be aware of params.vlan when changing code here */ |
3148 | 3191 | ||
3149 | err = rdev->ops->change_station(&rdev->wiphy, dev, mac_addr, ¶ms); | 3192 | err = rdev_change_station(rdev, dev, mac_addr, ¶ms); |
3150 | 3193 | ||
3151 | if (params.vlan) | 3194 | if (params.vlan) |
3152 | dev_put(params.vlan); | 3195 | dev_put(params.vlan); |
@@ -3198,6 +3241,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
3198 | params.ht_capa = | 3241 | params.ht_capa = |
3199 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); | 3242 | nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]); |
3200 | 3243 | ||
3244 | if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) | ||
3245 | params.vht_capa = | ||
3246 | nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]); | ||
3247 | |||
3201 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) | 3248 | if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) |
3202 | params.plink_action = | 3249 | params.plink_action = |
3203 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); | 3250 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); |
@@ -3275,7 +3322,7 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
3275 | 3322 | ||
3276 | /* be aware of params.vlan when changing code here */ | 3323 | /* be aware of params.vlan when changing code here */ |
3277 | 3324 | ||
3278 | err = rdev->ops->add_station(&rdev->wiphy, dev, mac_addr, ¶ms); | 3325 | err = rdev_add_station(rdev, dev, mac_addr, ¶ms); |
3279 | 3326 | ||
3280 | if (params.vlan) | 3327 | if (params.vlan) |
3281 | dev_put(params.vlan); | 3328 | dev_put(params.vlan); |
@@ -3300,7 +3347,7 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info) | |||
3300 | if (!rdev->ops->del_station) | 3347 | if (!rdev->ops->del_station) |
3301 | return -EOPNOTSUPP; | 3348 | return -EOPNOTSUPP; |
3302 | 3349 | ||
3303 | return rdev->ops->del_station(&rdev->wiphy, dev, mac_addr); | 3350 | return rdev_del_station(rdev, dev, mac_addr); |
3304 | } | 3351 | } |
3305 | 3352 | ||
3306 | static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, | 3353 | static int nl80211_send_mpath(struct sk_buff *msg, u32 portid, u32 seq, |
@@ -3382,8 +3429,8 @@ static int nl80211_dump_mpath(struct sk_buff *skb, | |||
3382 | } | 3429 | } |
3383 | 3430 | ||
3384 | while (1) { | 3431 | while (1) { |
3385 | err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, | 3432 | err = rdev_dump_mpath(dev, netdev, path_idx, dst, next_hop, |
3386 | dst, next_hop, &pinfo); | 3433 | &pinfo); |
3387 | if (err == -ENOENT) | 3434 | if (err == -ENOENT) |
3388 | break; | 3435 | break; |
3389 | if (err) | 3436 | if (err) |
@@ -3430,7 +3477,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3430 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 3477 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3431 | return -EOPNOTSUPP; | 3478 | return -EOPNOTSUPP; |
3432 | 3479 | ||
3433 | err = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, &pinfo); | 3480 | err = rdev_get_mpath(rdev, dev, dst, next_hop, &pinfo); |
3434 | if (err) | 3481 | if (err) |
3435 | return err; | 3482 | return err; |
3436 | 3483 | ||
@@ -3469,7 +3516,7 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3469 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 3516 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3470 | return -EOPNOTSUPP; | 3517 | return -EOPNOTSUPP; |
3471 | 3518 | ||
3472 | return rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop); | 3519 | return rdev_change_mpath(rdev, dev, dst, next_hop); |
3473 | } | 3520 | } |
3474 | 3521 | ||
3475 | static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) | 3522 | static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) |
@@ -3494,7 +3541,7 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3494 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | 3541 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) |
3495 | return -EOPNOTSUPP; | 3542 | return -EOPNOTSUPP; |
3496 | 3543 | ||
3497 | return rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop); | 3544 | return rdev_add_mpath(rdev, dev, dst, next_hop); |
3498 | } | 3545 | } |
3499 | 3546 | ||
3500 | static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) | 3547 | static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) |
@@ -3509,7 +3556,7 @@ static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) | |||
3509 | if (!rdev->ops->del_mpath) | 3556 | if (!rdev->ops->del_mpath) |
3510 | return -EOPNOTSUPP; | 3557 | return -EOPNOTSUPP; |
3511 | 3558 | ||
3512 | return rdev->ops->del_mpath(&rdev->wiphy, dev, dst); | 3559 | return rdev_del_mpath(rdev, dev, dst); |
3513 | } | 3560 | } |
3514 | 3561 | ||
3515 | static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | 3562 | static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) |
@@ -3554,7 +3601,7 @@ static int nl80211_set_bss(struct sk_buff *skb, struct genl_info *info) | |||
3554 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | 3601 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) |
3555 | return -EOPNOTSUPP; | 3602 | return -EOPNOTSUPP; |
3556 | 3603 | ||
3557 | return rdev->ops->change_bss(&rdev->wiphy, dev, ¶ms); | 3604 | return rdev_change_bss(rdev, dev, ¶ms); |
3558 | } | 3605 | } |
3559 | 3606 | ||
3560 | static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = { | 3607 | static const struct nla_policy reg_rule_policy[NL80211_REG_RULE_ATTR_MAX + 1] = { |
@@ -3668,8 +3715,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb, | |||
3668 | if (!wdev->mesh_id_len) | 3715 | if (!wdev->mesh_id_len) |
3669 | memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); | 3716 | memcpy(&cur_params, &default_mesh_config, sizeof(cur_params)); |
3670 | else | 3717 | else |
3671 | err = rdev->ops->get_mesh_config(&rdev->wiphy, dev, | 3718 | err = rdev_get_mesh_config(rdev, dev, &cur_params); |
3672 | &cur_params); | ||
3673 | wdev_unlock(wdev); | 3719 | wdev_unlock(wdev); |
3674 | 3720 | ||
3675 | if (err) | 3721 | if (err) |
@@ -3971,8 +4017,7 @@ static int nl80211_update_mesh_config(struct sk_buff *skb, | |||
3971 | err = -ENOLINK; | 4017 | err = -ENOLINK; |
3972 | 4018 | ||
3973 | if (!err) | 4019 | if (!err) |
3974 | err = rdev->ops->update_mesh_config(&rdev->wiphy, dev, | 4020 | err = rdev_update_mesh_config(rdev, dev, mask, &cfg); |
3975 | mask, &cfg); | ||
3976 | 4021 | ||
3977 | wdev_unlock(wdev); | 4022 | wdev_unlock(wdev); |
3978 | 4023 | ||
@@ -4337,14 +4382,27 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) | |||
4337 | } | 4382 | } |
4338 | } | 4383 | } |
4339 | 4384 | ||
4385 | if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) { | ||
4386 | request->flags = nla_get_u32( | ||
4387 | info->attrs[NL80211_ATTR_SCAN_FLAGS]); | ||
4388 | if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) && | ||
4389 | !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) || | ||
4390 | ((request->flags & NL80211_SCAN_FLAG_FLUSH) && | ||
4391 | !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) { | ||
4392 | err = -EOPNOTSUPP; | ||
4393 | goto out_free; | ||
4394 | } | ||
4395 | } | ||
4396 | |||
4340 | request->no_cck = | 4397 | request->no_cck = |
4341 | nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); | 4398 | nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); |
4342 | 4399 | ||
4343 | request->wdev = wdev; | 4400 | request->wdev = wdev; |
4344 | request->wiphy = &rdev->wiphy; | 4401 | request->wiphy = &rdev->wiphy; |
4402 | request->scan_start = jiffies; | ||
4345 | 4403 | ||
4346 | rdev->scan_req = request; | 4404 | rdev->scan_req = request; |
4347 | err = rdev->ops->scan(&rdev->wiphy, request); | 4405 | err = rdev_scan(rdev, request); |
4348 | 4406 | ||
4349 | if (!err) { | 4407 | if (!err) { |
4350 | nl80211_send_scan_start(rdev, wdev); | 4408 | nl80211_send_scan_start(rdev, wdev); |
@@ -4568,11 +4626,24 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, | |||
4568 | request->ie_len); | 4626 | request->ie_len); |
4569 | } | 4627 | } |
4570 | 4628 | ||
4629 | if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) { | ||
4630 | request->flags = nla_get_u32( | ||
4631 | info->attrs[NL80211_ATTR_SCAN_FLAGS]); | ||
4632 | if (((request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY) && | ||
4633 | !(wiphy->features & NL80211_FEATURE_LOW_PRIORITY_SCAN)) || | ||
4634 | ((request->flags & NL80211_SCAN_FLAG_FLUSH) && | ||
4635 | !(wiphy->features & NL80211_FEATURE_SCAN_FLUSH))) { | ||
4636 | err = -EOPNOTSUPP; | ||
4637 | goto out_free; | ||
4638 | } | ||
4639 | } | ||
4640 | |||
4571 | request->dev = dev; | 4641 | request->dev = dev; |
4572 | request->wiphy = &rdev->wiphy; | 4642 | request->wiphy = &rdev->wiphy; |
4573 | request->interval = interval; | 4643 | request->interval = interval; |
4644 | request->scan_start = jiffies; | ||
4574 | 4645 | ||
4575 | err = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request); | 4646 | err = rdev_sched_scan_start(rdev, dev, request); |
4576 | if (!err) { | 4647 | if (!err) { |
4577 | rdev->sched_scan_req = request; | 4648 | rdev->sched_scan_req = request; |
4578 | nl80211_send_sched_scan(rdev, dev, | 4649 | nl80211_send_sched_scan(rdev, dev, |
@@ -4815,8 +4886,7 @@ static int nl80211_dump_survey(struct sk_buff *skb, | |||
4815 | while (1) { | 4886 | while (1) { |
4816 | struct ieee80211_channel *chan; | 4887 | struct ieee80211_channel *chan; |
4817 | 4888 | ||
4818 | res = dev->ops->dump_survey(&dev->wiphy, netdev, survey_idx, | 4889 | res = rdev_dump_survey(dev, netdev, survey_idx, &survey); |
4819 | &survey); | ||
4820 | if (res == -ENOENT) | 4890 | if (res == -ENOENT) |
4821 | break; | 4891 | break; |
4822 | if (res) | 4892 | if (res) |
@@ -4852,11 +4922,6 @@ static int nl80211_dump_survey(struct sk_buff *skb, | |||
4852 | return res; | 4922 | return res; |
4853 | } | 4923 | } |
4854 | 4924 | ||
4855 | static bool nl80211_valid_auth_type(enum nl80211_auth_type auth_type) | ||
4856 | { | ||
4857 | return auth_type <= NL80211_AUTHTYPE_MAX; | ||
4858 | } | ||
4859 | |||
4860 | static bool nl80211_valid_wpa_versions(u32 wpa_versions) | 4925 | static bool nl80211_valid_wpa_versions(u32 wpa_versions) |
4861 | { | 4926 | { |
4862 | return !(wpa_versions & ~(NL80211_WPA_VERSION_1 | | 4927 | return !(wpa_versions & ~(NL80211_WPA_VERSION_1 | |
@@ -4868,8 +4933,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | |||
4868 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 4933 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
4869 | struct net_device *dev = info->user_ptr[1]; | 4934 | struct net_device *dev = info->user_ptr[1]; |
4870 | struct ieee80211_channel *chan; | 4935 | struct ieee80211_channel *chan; |
4871 | const u8 *bssid, *ssid, *ie = NULL; | 4936 | const u8 *bssid, *ssid, *ie = NULL, *sae_data = NULL; |
4872 | int err, ssid_len, ie_len = 0; | 4937 | int err, ssid_len, ie_len = 0, sae_data_len = 0; |
4873 | enum nl80211_auth_type auth_type; | 4938 | enum nl80211_auth_type auth_type; |
4874 | struct key_parse key; | 4939 | struct key_parse key; |
4875 | bool local_state_change; | 4940 | bool local_state_change; |
@@ -4945,9 +5010,23 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | |||
4945 | } | 5010 | } |
4946 | 5011 | ||
4947 | auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); | 5012 | auth_type = nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); |
4948 | if (!nl80211_valid_auth_type(auth_type)) | 5013 | if (!nl80211_valid_auth_type(rdev, auth_type, NL80211_CMD_AUTHENTICATE)) |
5014 | return -EINVAL; | ||
5015 | |||
5016 | if (auth_type == NL80211_AUTHTYPE_SAE && | ||
5017 | !info->attrs[NL80211_ATTR_SAE_DATA]) | ||
4949 | return -EINVAL; | 5018 | return -EINVAL; |
4950 | 5019 | ||
5020 | if (info->attrs[NL80211_ATTR_SAE_DATA]) { | ||
5021 | if (auth_type != NL80211_AUTHTYPE_SAE) | ||
5022 | return -EINVAL; | ||
5023 | sae_data = nla_data(info->attrs[NL80211_ATTR_SAE_DATA]); | ||
5024 | sae_data_len = nla_len(info->attrs[NL80211_ATTR_SAE_DATA]); | ||
5025 | /* need to include at least Auth Transaction and Status Code */ | ||
5026 | if (sae_data_len < 4) | ||
5027 | return -EINVAL; | ||
5028 | } | ||
5029 | |||
4951 | local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; | 5030 | local_state_change = !!info->attrs[NL80211_ATTR_LOCAL_STATE_CHANGE]; |
4952 | 5031 | ||
4953 | /* | 5032 | /* |
@@ -4959,7 +5038,8 @@ static int nl80211_authenticate(struct sk_buff *skb, struct genl_info *info) | |||
4959 | 5038 | ||
4960 | return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, | 5039 | return cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, |
4961 | ssid, ssid_len, ie, ie_len, | 5040 | ssid, ssid_len, ie, ie_len, |
4962 | key.p.key, key.p.key_len, key.idx); | 5041 | key.p.key, key.p.key_len, key.idx, |
5042 | sae_data, sae_data_len); | ||
4963 | } | 5043 | } |
4964 | 5044 | ||
4965 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | 5045 | static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, |
@@ -5339,10 +5419,18 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5339 | return -EINVAL; | 5419 | return -EINVAL; |
5340 | 5420 | ||
5341 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { | 5421 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { |
5422 | bool no_ht = false; | ||
5423 | |||
5342 | connkeys = nl80211_parse_connkeys(rdev, | 5424 | connkeys = nl80211_parse_connkeys(rdev, |
5343 | info->attrs[NL80211_ATTR_KEYS]); | 5425 | info->attrs[NL80211_ATTR_KEYS], |
5426 | &no_ht); | ||
5344 | if (IS_ERR(connkeys)) | 5427 | if (IS_ERR(connkeys)) |
5345 | return PTR_ERR(connkeys); | 5428 | return PTR_ERR(connkeys); |
5429 | |||
5430 | if ((ibss.channel_type != NL80211_CHAN_NO_HT) && no_ht) { | ||
5431 | kfree(connkeys); | ||
5432 | return -EINVAL; | ||
5433 | } | ||
5346 | } | 5434 | } |
5347 | 5435 | ||
5348 | ibss.control_port = | 5436 | ibss.control_port = |
@@ -5368,6 +5456,36 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info) | |||
5368 | return cfg80211_leave_ibss(rdev, dev, false); | 5456 | return cfg80211_leave_ibss(rdev, dev, false); |
5369 | } | 5457 | } |
5370 | 5458 | ||
5459 | static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info) | ||
5460 | { | ||
5461 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | ||
5462 | struct net_device *dev = info->user_ptr[1]; | ||
5463 | int mcast_rate[IEEE80211_NUM_BANDS]; | ||
5464 | u32 nla_rate; | ||
5465 | int err; | ||
5466 | |||
5467 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_ADHOC && | ||
5468 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_MESH_POINT) | ||
5469 | return -EOPNOTSUPP; | ||
5470 | |||
5471 | if (!rdev->ops->set_mcast_rate) | ||
5472 | return -EOPNOTSUPP; | ||
5473 | |||
5474 | memset(mcast_rate, 0, sizeof(mcast_rate)); | ||
5475 | |||
5476 | if (!info->attrs[NL80211_ATTR_MCAST_RATE]) | ||
5477 | return -EINVAL; | ||
5478 | |||
5479 | nla_rate = nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); | ||
5480 | if (!nl80211_parse_mcast_rate(rdev, mcast_rate, nla_rate)) | ||
5481 | return -EINVAL; | ||
5482 | |||
5483 | err = rdev->ops->set_mcast_rate(&rdev->wiphy, dev, mcast_rate); | ||
5484 | |||
5485 | return err; | ||
5486 | } | ||
5487 | |||
5488 | |||
5371 | #ifdef CONFIG_NL80211_TESTMODE | 5489 | #ifdef CONFIG_NL80211_TESTMODE |
5372 | static struct genl_multicast_group nl80211_testmode_mcgrp = { | 5490 | static struct genl_multicast_group nl80211_testmode_mcgrp = { |
5373 | .name = "testmode", | 5491 | .name = "testmode", |
@@ -5384,7 +5502,7 @@ static int nl80211_testmode_do(struct sk_buff *skb, struct genl_info *info) | |||
5384 | err = -EOPNOTSUPP; | 5502 | err = -EOPNOTSUPP; |
5385 | if (rdev->ops->testmode_cmd) { | 5503 | if (rdev->ops->testmode_cmd) { |
5386 | rdev->testmode_info = info; | 5504 | rdev->testmode_info = info; |
5387 | err = rdev->ops->testmode_cmd(&rdev->wiphy, | 5505 | err = rdev_testmode_cmd(rdev, |
5388 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), | 5506 | nla_data(info->attrs[NL80211_ATTR_TESTDATA]), |
5389 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); | 5507 | nla_len(info->attrs[NL80211_ATTR_TESTDATA])); |
5390 | rdev->testmode_info = NULL; | 5508 | rdev->testmode_info = NULL; |
@@ -5466,8 +5584,7 @@ static int nl80211_testmode_dump(struct sk_buff *skb, | |||
5466 | genlmsg_cancel(skb, hdr); | 5584 | genlmsg_cancel(skb, hdr); |
5467 | break; | 5585 | break; |
5468 | } | 5586 | } |
5469 | err = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb, | 5587 | err = rdev_testmode_dump(rdev, skb, cb, data, data_len); |
5470 | data, data_len); | ||
5471 | nla_nest_end(skb, tmdata); | 5588 | nla_nest_end(skb, tmdata); |
5472 | 5589 | ||
5473 | if (err == -ENOBUFS || err == -ENOENT) { | 5590 | if (err == -ENOBUFS || err == -ENOENT) { |
@@ -5596,7 +5713,8 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
5596 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { | 5713 | if (info->attrs[NL80211_ATTR_AUTH_TYPE]) { |
5597 | connect.auth_type = | 5714 | connect.auth_type = |
5598 | nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); | 5715 | nla_get_u32(info->attrs[NL80211_ATTR_AUTH_TYPE]); |
5599 | if (!nl80211_valid_auth_type(connect.auth_type)) | 5716 | if (!nl80211_valid_auth_type(rdev, connect.auth_type, |
5717 | NL80211_CMD_CONNECT)) | ||
5600 | return -EINVAL; | 5718 | return -EINVAL; |
5601 | } else | 5719 | } else |
5602 | connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | 5720 | connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; |
@@ -5642,7 +5760,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info) | |||
5642 | 5760 | ||
5643 | if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { | 5761 | if (connect.privacy && info->attrs[NL80211_ATTR_KEYS]) { |
5644 | connkeys = nl80211_parse_connkeys(rdev, | 5762 | connkeys = nl80211_parse_connkeys(rdev, |
5645 | info->attrs[NL80211_ATTR_KEYS]); | 5763 | info->attrs[NL80211_ATTR_KEYS], NULL); |
5646 | if (IS_ERR(connkeys)) | 5764 | if (IS_ERR(connkeys)) |
5647 | return PTR_ERR(connkeys); | 5765 | return PTR_ERR(connkeys); |
5648 | } | 5766 | } |
@@ -5771,7 +5889,7 @@ static int nl80211_flush_pmksa(struct sk_buff *skb, struct genl_info *info) | |||
5771 | if (!rdev->ops->flush_pmksa) | 5889 | if (!rdev->ops->flush_pmksa) |
5772 | return -EOPNOTSUPP; | 5890 | return -EOPNOTSUPP; |
5773 | 5891 | ||
5774 | return rdev->ops->flush_pmksa(&rdev->wiphy, dev); | 5892 | return rdev_flush_pmksa(rdev, dev); |
5775 | } | 5893 | } |
5776 | 5894 | ||
5777 | static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info) | 5895 | static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info) |
@@ -5798,10 +5916,10 @@ static int nl80211_tdls_mgmt(struct sk_buff *skb, struct genl_info *info) | |||
5798 | status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); | 5916 | status_code = nla_get_u16(info->attrs[NL80211_ATTR_STATUS_CODE]); |
5799 | dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]); | 5917 | dialog_token = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_DIALOG_TOKEN]); |
5800 | 5918 | ||
5801 | return rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code, | 5919 | return rdev_tdls_mgmt(rdev, dev, peer, action_code, |
5802 | dialog_token, status_code, | 5920 | dialog_token, status_code, |
5803 | nla_data(info->attrs[NL80211_ATTR_IE]), | 5921 | nla_data(info->attrs[NL80211_ATTR_IE]), |
5804 | nla_len(info->attrs[NL80211_ATTR_IE])); | 5922 | nla_len(info->attrs[NL80211_ATTR_IE])); |
5805 | } | 5923 | } |
5806 | 5924 | ||
5807 | static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info) | 5925 | static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info) |
@@ -5822,7 +5940,7 @@ static int nl80211_tdls_oper(struct sk_buff *skb, struct genl_info *info) | |||
5822 | operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]); | 5940 | operation = nla_get_u8(info->attrs[NL80211_ATTR_TDLS_OPERATION]); |
5823 | peer = nla_data(info->attrs[NL80211_ATTR_MAC]); | 5941 | peer = nla_data(info->attrs[NL80211_ATTR_MAC]); |
5824 | 5942 | ||
5825 | return rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, operation); | 5943 | return rdev_tdls_oper(rdev, dev, peer, operation); |
5826 | } | 5944 | } |
5827 | 5945 | ||
5828 | static int nl80211_remain_on_channel(struct sk_buff *skb, | 5946 | static int nl80211_remain_on_channel(struct sk_buff *skb, |
@@ -5877,8 +5995,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, | |||
5877 | goto free_msg; | 5995 | goto free_msg; |
5878 | } | 5996 | } |
5879 | 5997 | ||
5880 | err = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan, | 5998 | err = rdev_remain_on_channel(rdev, wdev, chan, channel_type, duration, |
5881 | channel_type, duration, &cookie); | 5999 | &cookie); |
5882 | 6000 | ||
5883 | if (err) | 6001 | if (err) |
5884 | goto free_msg; | 6002 | goto free_msg; |
@@ -5912,7 +6030,7 @@ static int nl80211_cancel_remain_on_channel(struct sk_buff *skb, | |||
5912 | 6030 | ||
5913 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); | 6031 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); |
5914 | 6032 | ||
5915 | return rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); | 6033 | return rdev_cancel_remain_on_channel(rdev, wdev, cookie); |
5916 | } | 6034 | } |
5917 | 6035 | ||
5918 | static u32 rateset_to_mask(struct ieee80211_supported_band *sband, | 6036 | static u32 rateset_to_mask(struct ieee80211_supported_band *sband, |
@@ -6055,7 +6173,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff *skb, | |||
6055 | } | 6173 | } |
6056 | } | 6174 | } |
6057 | 6175 | ||
6058 | return rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, NULL, &mask); | 6176 | return rdev_set_bitrate_mask(rdev, dev, NULL, &mask); |
6059 | } | 6177 | } |
6060 | 6178 | ||
6061 | static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) | 6179 | static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info) |
@@ -6230,7 +6348,7 @@ static int nl80211_tx_mgmt_cancel_wait(struct sk_buff *skb, struct genl_info *in | |||
6230 | 6348 | ||
6231 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); | 6349 | cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]); |
6232 | 6350 | ||
6233 | return rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); | 6351 | return rdev_mgmt_tx_cancel_wait(rdev, wdev, cookie); |
6234 | } | 6352 | } |
6235 | 6353 | ||
6236 | static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) | 6354 | static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) |
@@ -6260,8 +6378,7 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info) | |||
6260 | if (state == wdev->ps) | 6378 | if (state == wdev->ps) |
6261 | return 0; | 6379 | return 0; |
6262 | 6380 | ||
6263 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, state, | 6381 | err = rdev_set_power_mgmt(rdev, dev, state, wdev->ps_timeout); |
6264 | wdev->ps_timeout); | ||
6265 | if (!err) | 6382 | if (!err) |
6266 | wdev->ps = state; | 6383 | wdev->ps = state; |
6267 | return err; | 6384 | return err; |
@@ -6341,8 +6458,7 @@ static int nl80211_set_cqm_txe(struct genl_info *info, | |||
6341 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) | 6458 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) |
6342 | return -EOPNOTSUPP; | 6459 | return -EOPNOTSUPP; |
6343 | 6460 | ||
6344 | return rdev->ops->set_cqm_txe_config(wdev->wiphy, dev, | 6461 | return rdev_set_cqm_txe_config(rdev, dev, rate, pkts, intvl); |
6345 | rate, pkts, intvl); | ||
6346 | } | 6462 | } |
6347 | 6463 | ||
6348 | static int nl80211_set_cqm_rssi(struct genl_info *info, | 6464 | static int nl80211_set_cqm_rssi(struct genl_info *info, |
@@ -6364,8 +6480,7 @@ static int nl80211_set_cqm_rssi(struct genl_info *info, | |||
6364 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) | 6480 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT) |
6365 | return -EOPNOTSUPP; | 6481 | return -EOPNOTSUPP; |
6366 | 6482 | ||
6367 | return rdev->ops->set_cqm_rssi_config(wdev->wiphy, dev, | 6483 | return rdev_set_cqm_rssi_config(rdev, dev, threshold, hysteresis); |
6368 | threshold, hysteresis); | ||
6369 | } | 6484 | } |
6370 | 6485 | ||
6371 | static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) | 6486 | static int nl80211_set_cqm(struct sk_buff *skb, struct genl_info *info) |
@@ -6690,7 +6805,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info) | |||
6690 | 6805 | ||
6691 | set_wakeup: | 6806 | set_wakeup: |
6692 | if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan) | 6807 | if (rdev->ops->set_wakeup && prev_enabled != !!rdev->wowlan) |
6693 | rdev->ops->set_wakeup(&rdev->wiphy, rdev->wowlan); | 6808 | rdev_set_wakeup(rdev, rdev->wowlan); |
6694 | 6809 | ||
6695 | return 0; | 6810 | return 0; |
6696 | error: | 6811 | error: |
@@ -6746,7 +6861,7 @@ static int nl80211_set_rekey_data(struct sk_buff *skb, struct genl_info *info) | |||
6746 | goto out; | 6861 | goto out; |
6747 | } | 6862 | } |
6748 | 6863 | ||
6749 | err = rdev->ops->set_rekey_data(&rdev->wiphy, dev, &rekey_data); | 6864 | err = rdev_set_rekey_data(rdev, dev, &rekey_data); |
6750 | out: | 6865 | out: |
6751 | wdev_unlock(wdev); | 6866 | wdev_unlock(wdev); |
6752 | return err; | 6867 | return err; |
@@ -6805,7 +6920,7 @@ static int nl80211_probe_client(struct sk_buff *skb, | |||
6805 | 6920 | ||
6806 | addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | 6921 | addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
6807 | 6922 | ||
6808 | err = rdev->ops->probe_client(&rdev->wiphy, dev, addr, &cookie); | 6923 | err = rdev_probe_client(rdev, dev, addr, &cookie); |
6809 | if (err) | 6924 | if (err) |
6810 | goto free_msg; | 6925 | goto free_msg; |
6811 | 6926 | ||
@@ -6826,16 +6941,35 @@ static int nl80211_probe_client(struct sk_buff *skb, | |||
6826 | static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) | 6941 | static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) |
6827 | { | 6942 | { |
6828 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 6943 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
6944 | struct cfg80211_beacon_registration *reg, *nreg; | ||
6945 | int rv; | ||
6829 | 6946 | ||
6830 | if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) | 6947 | if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) |
6831 | return -EOPNOTSUPP; | 6948 | return -EOPNOTSUPP; |
6832 | 6949 | ||
6833 | if (rdev->ap_beacons_nlportid) | 6950 | nreg = kzalloc(sizeof(*nreg), GFP_KERNEL); |
6834 | return -EBUSY; | 6951 | if (!nreg) |
6952 | return -ENOMEM; | ||
6835 | 6953 | ||
6836 | rdev->ap_beacons_nlportid = info->snd_portid; | 6954 | /* First, check if already registered. */ |
6955 | spin_lock_bh(&rdev->beacon_registrations_lock); | ||
6956 | list_for_each_entry(reg, &rdev->beacon_registrations, list) { | ||
6957 | if (reg->nlportid == info->snd_portid) { | ||
6958 | rv = -EALREADY; | ||
6959 | goto out_err; | ||
6960 | } | ||
6961 | } | ||
6962 | /* Add it to the list */ | ||
6963 | nreg->nlportid = info->snd_portid; | ||
6964 | list_add(&nreg->list, &rdev->beacon_registrations); | ||
6965 | |||
6966 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
6837 | 6967 | ||
6838 | return 0; | 6968 | return 0; |
6969 | out_err: | ||
6970 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
6971 | kfree(nreg); | ||
6972 | return rv; | ||
6839 | } | 6973 | } |
6840 | 6974 | ||
6841 | static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info) | 6975 | static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info) |
@@ -6859,7 +6993,7 @@ static int nl80211_start_p2p_device(struct sk_buff *skb, struct genl_info *info) | |||
6859 | if (err) | 6993 | if (err) |
6860 | return err; | 6994 | return err; |
6861 | 6995 | ||
6862 | err = rdev->ops->start_p2p_device(&rdev->wiphy, wdev); | 6996 | err = rdev_start_p2p_device(rdev, wdev); |
6863 | if (err) | 6997 | if (err) |
6864 | return err; | 6998 | return err; |
6865 | 6999 | ||
@@ -6885,7 +7019,7 @@ static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info) | |||
6885 | if (!wdev->p2p_started) | 7019 | if (!wdev->p2p_started) |
6886 | return 0; | 7020 | return 0; |
6887 | 7021 | ||
6888 | rdev->ops->stop_p2p_device(&rdev->wiphy, wdev); | 7022 | rdev_stop_p2p_device(rdev, wdev); |
6889 | wdev->p2p_started = false; | 7023 | wdev->p2p_started = false; |
6890 | 7024 | ||
6891 | mutex_lock(&rdev->devlist_mtx); | 7025 | mutex_lock(&rdev->devlist_mtx); |
@@ -7552,6 +7686,14 @@ static struct genl_ops nl80211_ops[] = { | |||
7552 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | | 7686 | .internal_flags = NL80211_FLAG_NEED_WDEV_UP | |
7553 | NL80211_FLAG_NEED_RTNL, | 7687 | NL80211_FLAG_NEED_RTNL, |
7554 | }, | 7688 | }, |
7689 | { | ||
7690 | .cmd = NL80211_CMD_SET_MCAST_RATE, | ||
7691 | .doit = nl80211_set_mcast_rate, | ||
7692 | .policy = nl80211_policy, | ||
7693 | .flags = GENL_ADMIN_PERM, | ||
7694 | .internal_flags = NL80211_FLAG_NEED_NETDEV | | ||
7695 | NL80211_FLAG_NEED_RTNL, | ||
7696 | }, | ||
7555 | }; | 7697 | }; |
7556 | 7698 | ||
7557 | static struct genl_multicast_group nl80211_mlme_mcgrp = { | 7699 | static struct genl_multicast_group nl80211_mlme_mcgrp = { |
@@ -7622,6 +7764,9 @@ static int nl80211_add_scan_req(struct sk_buff *msg, | |||
7622 | nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) | 7764 | nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) |
7623 | goto nla_put_failure; | 7765 | goto nla_put_failure; |
7624 | 7766 | ||
7767 | if (req->flags) | ||
7768 | nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags); | ||
7769 | |||
7625 | return 0; | 7770 | return 0; |
7626 | nla_put_failure: | 7771 | nla_put_failure: |
7627 | return -ENOBUFS; | 7772 | return -ENOBUFS; |
@@ -8800,7 +8945,10 @@ void cfg80211_probe_status(struct net_device *dev, const u8 *addr, | |||
8800 | void *hdr; | 8945 | void *hdr; |
8801 | int err; | 8946 | int err; |
8802 | 8947 | ||
8948 | trace_cfg80211_probe_status(dev, addr, cookie, acked); | ||
8949 | |||
8803 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); | 8950 | msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); |
8951 | |||
8804 | if (!msg) | 8952 | if (!msg) |
8805 | return; | 8953 | return; |
8806 | 8954 | ||
@@ -8835,41 +8983,46 @@ EXPORT_SYMBOL(cfg80211_probe_status); | |||
8835 | 8983 | ||
8836 | void cfg80211_report_obss_beacon(struct wiphy *wiphy, | 8984 | void cfg80211_report_obss_beacon(struct wiphy *wiphy, |
8837 | const u8 *frame, size_t len, | 8985 | const u8 *frame, size_t len, |
8838 | int freq, int sig_dbm, gfp_t gfp) | 8986 | int freq, int sig_dbm) |
8839 | { | 8987 | { |
8840 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 8988 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
8841 | struct sk_buff *msg; | 8989 | struct sk_buff *msg; |
8842 | void *hdr; | 8990 | void *hdr; |
8843 | u32 nlportid = ACCESS_ONCE(rdev->ap_beacons_nlportid); | 8991 | struct cfg80211_beacon_registration *reg; |
8844 | 8992 | ||
8845 | if (!nlportid) | 8993 | trace_cfg80211_report_obss_beacon(wiphy, frame, len, freq, sig_dbm); |
8846 | return; | ||
8847 | 8994 | ||
8848 | msg = nlmsg_new(len + 100, gfp); | 8995 | spin_lock_bh(&rdev->beacon_registrations_lock); |
8849 | if (!msg) | 8996 | list_for_each_entry(reg, &rdev->beacon_registrations, list) { |
8850 | return; | 8997 | msg = nlmsg_new(len + 100, GFP_ATOMIC); |
8998 | if (!msg) { | ||
8999 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
9000 | return; | ||
9001 | } | ||
8851 | 9002 | ||
8852 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME); | 9003 | hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME); |
8853 | if (!hdr) { | 9004 | if (!hdr) |
8854 | nlmsg_free(msg); | 9005 | goto nla_put_failure; |
8855 | return; | ||
8856 | } | ||
8857 | 9006 | ||
8858 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || | 9007 | if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || |
8859 | (freq && | 9008 | (freq && |
8860 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) || | 9009 | nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, freq)) || |
8861 | (sig_dbm && | 9010 | (sig_dbm && |
8862 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || | 9011 | nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, sig_dbm)) || |
8863 | nla_put(msg, NL80211_ATTR_FRAME, len, frame)) | 9012 | nla_put(msg, NL80211_ATTR_FRAME, len, frame)) |
8864 | goto nla_put_failure; | 9013 | goto nla_put_failure; |
8865 | 9014 | ||
8866 | genlmsg_end(msg, hdr); | 9015 | genlmsg_end(msg, hdr); |
8867 | 9016 | ||
8868 | genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlportid); | 9017 | genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, reg->nlportid); |
9018 | } | ||
9019 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
8869 | return; | 9020 | return; |
8870 | 9021 | ||
8871 | nla_put_failure: | 9022 | nla_put_failure: |
8872 | genlmsg_cancel(msg, hdr); | 9023 | spin_unlock_bh(&rdev->beacon_registrations_lock); |
9024 | if (hdr) | ||
9025 | genlmsg_cancel(msg, hdr); | ||
8873 | nlmsg_free(msg); | 9026 | nlmsg_free(msg); |
8874 | } | 9027 | } |
8875 | EXPORT_SYMBOL(cfg80211_report_obss_beacon); | 9028 | EXPORT_SYMBOL(cfg80211_report_obss_beacon); |
@@ -8881,6 +9034,7 @@ static int nl80211_netlink_notify(struct notifier_block * nb, | |||
8881 | struct netlink_notify *notify = _notify; | 9034 | struct netlink_notify *notify = _notify; |
8882 | struct cfg80211_registered_device *rdev; | 9035 | struct cfg80211_registered_device *rdev; |
8883 | struct wireless_dev *wdev; | 9036 | struct wireless_dev *wdev; |
9037 | struct cfg80211_beacon_registration *reg, *tmp; | ||
8884 | 9038 | ||
8885 | if (state != NETLINK_URELEASE) | 9039 | if (state != NETLINK_URELEASE) |
8886 | return NOTIFY_DONE; | 9040 | return NOTIFY_DONE; |
@@ -8890,8 +9044,17 @@ static int nl80211_netlink_notify(struct notifier_block * nb, | |||
8890 | list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { | 9044 | list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { |
8891 | list_for_each_entry_rcu(wdev, &rdev->wdev_list, list) | 9045 | list_for_each_entry_rcu(wdev, &rdev->wdev_list, list) |
8892 | cfg80211_mlme_unregister_socket(wdev, notify->portid); | 9046 | cfg80211_mlme_unregister_socket(wdev, notify->portid); |
8893 | if (rdev->ap_beacons_nlportid == notify->portid) | 9047 | |
8894 | rdev->ap_beacons_nlportid = 0; | 9048 | spin_lock_bh(&rdev->beacon_registrations_lock); |
9049 | list_for_each_entry_safe(reg, tmp, &rdev->beacon_registrations, | ||
9050 | list) { | ||
9051 | if (reg->nlportid == notify->portid) { | ||
9052 | list_del(®->list); | ||
9053 | kfree(reg); | ||
9054 | break; | ||
9055 | } | ||
9056 | } | ||
9057 | spin_unlock_bh(&rdev->beacon_registrations_lock); | ||
8895 | } | 9058 | } |
8896 | 9059 | ||
8897 | rcu_read_unlock(); | 9060 | rcu_read_unlock(); |
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h new file mode 100644 index 000000000000..6e5fa659068d --- /dev/null +++ b/net/wireless/rdev-ops.h | |||
@@ -0,0 +1,880 @@ | |||
1 | #ifndef __CFG80211_RDEV_OPS | ||
2 | #define __CFG80211_RDEV_OPS | ||
3 | |||
4 | #include <linux/rtnetlink.h> | ||
5 | #include <net/cfg80211.h> | ||
6 | #include "core.h" | ||
7 | #include "trace.h" | ||
8 | |||
9 | static inline int rdev_suspend(struct cfg80211_registered_device *rdev) | ||
10 | { | ||
11 | int ret; | ||
12 | trace_rdev_suspend(&rdev->wiphy, rdev->wowlan); | ||
13 | ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); | ||
14 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
15 | return ret; | ||
16 | } | ||
17 | |||
18 | static inline int rdev_resume(struct cfg80211_registered_device *rdev) | ||
19 | { | ||
20 | int ret; | ||
21 | trace_rdev_resume(&rdev->wiphy); | ||
22 | ret = rdev->ops->resume(&rdev->wiphy); | ||
23 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
24 | return ret; | ||
25 | } | ||
26 | |||
27 | static inline void rdev_set_wakeup(struct cfg80211_registered_device *rdev, | ||
28 | bool enabled) | ||
29 | { | ||
30 | trace_rdev_set_wakeup(&rdev->wiphy, enabled); | ||
31 | rdev->ops->set_wakeup(&rdev->wiphy, enabled); | ||
32 | trace_rdev_return_void(&rdev->wiphy); | ||
33 | } | ||
34 | |||
35 | static inline struct wireless_dev | ||
36 | *rdev_add_virtual_intf(struct cfg80211_registered_device *rdev, char *name, | ||
37 | enum nl80211_iftype type, u32 *flags, | ||
38 | struct vif_params *params) | ||
39 | { | ||
40 | struct wireless_dev *ret; | ||
41 | trace_rdev_add_virtual_intf(&rdev->wiphy, name, type); | ||
42 | ret = rdev->ops->add_virtual_intf(&rdev->wiphy, name, type, flags, | ||
43 | params); | ||
44 | trace_rdev_return_wdev(&rdev->wiphy, ret); | ||
45 | return ret; | ||
46 | } | ||
47 | |||
48 | static inline int | ||
49 | rdev_del_virtual_intf(struct cfg80211_registered_device *rdev, | ||
50 | struct wireless_dev *wdev) | ||
51 | { | ||
52 | int ret; | ||
53 | trace_rdev_del_virtual_intf(&rdev->wiphy, wdev); | ||
54 | ret = rdev->ops->del_virtual_intf(&rdev->wiphy, wdev); | ||
55 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static inline int | ||
60 | rdev_change_virtual_intf(struct cfg80211_registered_device *rdev, | ||
61 | struct net_device *dev, enum nl80211_iftype type, | ||
62 | u32 *flags, struct vif_params *params) | ||
63 | { | ||
64 | int ret; | ||
65 | trace_rdev_change_virtual_intf(&rdev->wiphy, dev, type); | ||
66 | ret = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, type, flags, | ||
67 | params); | ||
68 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | static inline int rdev_add_key(struct cfg80211_registered_device *rdev, | ||
73 | struct net_device *netdev, u8 key_index, | ||
74 | bool pairwise, const u8 *mac_addr, | ||
75 | struct key_params *params) | ||
76 | { | ||
77 | int ret; | ||
78 | trace_rdev_add_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
79 | ret = rdev->ops->add_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
80 | mac_addr, params); | ||
81 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static inline int | ||
86 | rdev_get_key(struct cfg80211_registered_device *rdev, struct net_device *netdev, | ||
87 | u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie, | ||
88 | void (*callback)(void *cookie, struct key_params*)) | ||
89 | { | ||
90 | int ret; | ||
91 | trace_rdev_get_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
92 | ret = rdev->ops->get_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
93 | mac_addr, cookie, callback); | ||
94 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | static inline int rdev_del_key(struct cfg80211_registered_device *rdev, | ||
99 | struct net_device *netdev, u8 key_index, | ||
100 | bool pairwise, const u8 *mac_addr) | ||
101 | { | ||
102 | int ret; | ||
103 | trace_rdev_del_key(&rdev->wiphy, netdev, key_index, pairwise, mac_addr); | ||
104 | ret = rdev->ops->del_key(&rdev->wiphy, netdev, key_index, pairwise, | ||
105 | mac_addr); | ||
106 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
107 | return ret; | ||
108 | } | ||
109 | |||
110 | static inline int | ||
111 | rdev_set_default_key(struct cfg80211_registered_device *rdev, | ||
112 | struct net_device *netdev, u8 key_index, bool unicast, | ||
113 | bool multicast) | ||
114 | { | ||
115 | int ret; | ||
116 | trace_rdev_set_default_key(&rdev->wiphy, netdev, key_index, | ||
117 | unicast, multicast); | ||
118 | ret = rdev->ops->set_default_key(&rdev->wiphy, netdev, key_index, | ||
119 | unicast, multicast); | ||
120 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | static inline int | ||
125 | rdev_set_default_mgmt_key(struct cfg80211_registered_device *rdev, | ||
126 | struct net_device *netdev, u8 key_index) | ||
127 | { | ||
128 | int ret; | ||
129 | trace_rdev_set_default_mgmt_key(&rdev->wiphy, netdev, key_index); | ||
130 | ret = rdev->ops->set_default_mgmt_key(&rdev->wiphy, netdev, | ||
131 | key_index); | ||
132 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | static inline int rdev_start_ap(struct cfg80211_registered_device *rdev, | ||
137 | struct net_device *dev, | ||
138 | struct cfg80211_ap_settings *settings) | ||
139 | { | ||
140 | int ret; | ||
141 | trace_rdev_start_ap(&rdev->wiphy, dev, settings); | ||
142 | ret = rdev->ops->start_ap(&rdev->wiphy, dev, settings); | ||
143 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | static inline int rdev_change_beacon(struct cfg80211_registered_device *rdev, | ||
148 | struct net_device *dev, | ||
149 | struct cfg80211_beacon_data *info) | ||
150 | { | ||
151 | int ret; | ||
152 | trace_rdev_change_beacon(&rdev->wiphy, dev, info); | ||
153 | ret = rdev->ops->change_beacon(&rdev->wiphy, dev, info); | ||
154 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
155 | return ret; | ||
156 | } | ||
157 | |||
158 | static inline int rdev_stop_ap(struct cfg80211_registered_device *rdev, | ||
159 | struct net_device *dev) | ||
160 | { | ||
161 | int ret; | ||
162 | trace_rdev_stop_ap(&rdev->wiphy, dev); | ||
163 | ret = rdev->ops->stop_ap(&rdev->wiphy, dev); | ||
164 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
165 | return ret; | ||
166 | } | ||
167 | |||
168 | static inline int rdev_add_station(struct cfg80211_registered_device *rdev, | ||
169 | struct net_device *dev, u8 *mac, | ||
170 | struct station_parameters *params) | ||
171 | { | ||
172 | int ret; | ||
173 | trace_rdev_add_station(&rdev->wiphy, dev, mac, params); | ||
174 | ret = rdev->ops->add_station(&rdev->wiphy, dev, mac, params); | ||
175 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
176 | return ret; | ||
177 | } | ||
178 | |||
179 | static inline int rdev_del_station(struct cfg80211_registered_device *rdev, | ||
180 | struct net_device *dev, u8 *mac) | ||
181 | { | ||
182 | int ret; | ||
183 | trace_rdev_del_station(&rdev->wiphy, dev, mac); | ||
184 | ret = rdev->ops->del_station(&rdev->wiphy, dev, mac); | ||
185 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
186 | return ret; | ||
187 | } | ||
188 | |||
189 | static inline int rdev_change_station(struct cfg80211_registered_device *rdev, | ||
190 | struct net_device *dev, u8 *mac, | ||
191 | struct station_parameters *params) | ||
192 | { | ||
193 | int ret; | ||
194 | trace_rdev_change_station(&rdev->wiphy, dev, mac, params); | ||
195 | ret = rdev->ops->change_station(&rdev->wiphy, dev, mac, params); | ||
196 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
197 | return ret; | ||
198 | } | ||
199 | |||
200 | static inline int rdev_get_station(struct cfg80211_registered_device *rdev, | ||
201 | struct net_device *dev, u8 *mac, | ||
202 | struct station_info *sinfo) | ||
203 | { | ||
204 | int ret; | ||
205 | trace_rdev_get_station(&rdev->wiphy, dev, mac); | ||
206 | ret = rdev->ops->get_station(&rdev->wiphy, dev, mac, sinfo); | ||
207 | trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo); | ||
208 | return ret; | ||
209 | } | ||
210 | |||
211 | static inline int rdev_dump_station(struct cfg80211_registered_device *rdev, | ||
212 | struct net_device *dev, int idx, u8 *mac, | ||
213 | struct station_info *sinfo) | ||
214 | { | ||
215 | int ret; | ||
216 | trace_rdev_dump_station(&rdev->wiphy, dev, idx, mac); | ||
217 | ret = rdev->ops->dump_station(&rdev->wiphy, dev, idx, mac, sinfo); | ||
218 | trace_rdev_return_int_station_info(&rdev->wiphy, ret, sinfo); | ||
219 | return ret; | ||
220 | } | ||
221 | |||
222 | static inline int rdev_add_mpath(struct cfg80211_registered_device *rdev, | ||
223 | struct net_device *dev, u8 *dst, u8 *next_hop) | ||
224 | { | ||
225 | int ret; | ||
226 | trace_rdev_add_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
227 | ret = rdev->ops->add_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
228 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
229 | return ret; | ||
230 | } | ||
231 | |||
232 | static inline int rdev_del_mpath(struct cfg80211_registered_device *rdev, | ||
233 | struct net_device *dev, u8 *dst) | ||
234 | { | ||
235 | int ret; | ||
236 | trace_rdev_del_mpath(&rdev->wiphy, dev, dst); | ||
237 | ret = rdev->ops->del_mpath(&rdev->wiphy, dev, dst); | ||
238 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static inline int rdev_change_mpath(struct cfg80211_registered_device *rdev, | ||
243 | struct net_device *dev, u8 *dst, | ||
244 | u8 *next_hop) | ||
245 | { | ||
246 | int ret; | ||
247 | trace_rdev_change_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
248 | ret = rdev->ops->change_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
249 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | static inline int rdev_get_mpath(struct cfg80211_registered_device *rdev, | ||
254 | struct net_device *dev, u8 *dst, u8 *next_hop, | ||
255 | struct mpath_info *pinfo) | ||
256 | { | ||
257 | int ret; | ||
258 | trace_rdev_get_mpath(&rdev->wiphy, dev, dst, next_hop); | ||
259 | ret = rdev->ops->get_mpath(&rdev->wiphy, dev, dst, next_hop, pinfo); | ||
260 | trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo); | ||
261 | return ret; | ||
262 | |||
263 | } | ||
264 | |||
265 | static inline int rdev_dump_mpath(struct cfg80211_registered_device *rdev, | ||
266 | struct net_device *dev, int idx, u8 *dst, | ||
267 | u8 *next_hop, struct mpath_info *pinfo) | ||
268 | |||
269 | { | ||
270 | int ret; | ||
271 | trace_rdev_dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop); | ||
272 | ret = rdev->ops->dump_mpath(&rdev->wiphy, dev, idx, dst, next_hop, | ||
273 | pinfo); | ||
274 | trace_rdev_return_int_mpath_info(&rdev->wiphy, ret, pinfo); | ||
275 | return ret; | ||
276 | } | ||
277 | |||
278 | static inline int | ||
279 | rdev_get_mesh_config(struct cfg80211_registered_device *rdev, | ||
280 | struct net_device *dev, struct mesh_config *conf) | ||
281 | { | ||
282 | int ret; | ||
283 | trace_rdev_get_mesh_config(&rdev->wiphy, dev); | ||
284 | ret = rdev->ops->get_mesh_config(&rdev->wiphy, dev, conf); | ||
285 | trace_rdev_return_int_mesh_config(&rdev->wiphy, ret, conf); | ||
286 | return ret; | ||
287 | } | ||
288 | |||
289 | static inline int | ||
290 | rdev_update_mesh_config(struct cfg80211_registered_device *rdev, | ||
291 | struct net_device *dev, u32 mask, | ||
292 | const struct mesh_config *nconf) | ||
293 | { | ||
294 | int ret; | ||
295 | trace_rdev_update_mesh_config(&rdev->wiphy, dev, mask, nconf); | ||
296 | ret = rdev->ops->update_mesh_config(&rdev->wiphy, dev, mask, nconf); | ||
297 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | static inline int rdev_join_mesh(struct cfg80211_registered_device *rdev, | ||
302 | struct net_device *dev, | ||
303 | const struct mesh_config *conf, | ||
304 | const struct mesh_setup *setup) | ||
305 | { | ||
306 | int ret; | ||
307 | trace_rdev_join_mesh(&rdev->wiphy, dev, conf, setup); | ||
308 | ret = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); | ||
309 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
310 | return ret; | ||
311 | } | ||
312 | |||
313 | |||
314 | static inline int rdev_leave_mesh(struct cfg80211_registered_device *rdev, | ||
315 | struct net_device *dev) | ||
316 | { | ||
317 | int ret; | ||
318 | trace_rdev_leave_mesh(&rdev->wiphy, dev); | ||
319 | ret = rdev->ops->leave_mesh(&rdev->wiphy, dev); | ||
320 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
321 | return ret; | ||
322 | } | ||
323 | |||
324 | static inline int rdev_change_bss(struct cfg80211_registered_device *rdev, | ||
325 | struct net_device *dev, | ||
326 | struct bss_parameters *params) | ||
327 | |||
328 | { | ||
329 | int ret; | ||
330 | trace_rdev_change_bss(&rdev->wiphy, dev, params); | ||
331 | ret = rdev->ops->change_bss(&rdev->wiphy, dev, params); | ||
332 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
333 | return ret; | ||
334 | } | ||
335 | |||
336 | static inline int rdev_set_txq_params(struct cfg80211_registered_device *rdev, | ||
337 | struct net_device *dev, | ||
338 | struct ieee80211_txq_params *params) | ||
339 | |||
340 | { | ||
341 | int ret; | ||
342 | trace_rdev_set_txq_params(&rdev->wiphy, dev, params); | ||
343 | ret = rdev->ops->set_txq_params(&rdev->wiphy, dev, params); | ||
344 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
345 | return ret; | ||
346 | } | ||
347 | |||
348 | static inline int | ||
349 | rdev_libertas_set_mesh_channel(struct cfg80211_registered_device *rdev, | ||
350 | struct net_device *dev, | ||
351 | struct ieee80211_channel *chan) | ||
352 | { | ||
353 | int ret; | ||
354 | trace_rdev_libertas_set_mesh_channel(&rdev->wiphy, dev, chan); | ||
355 | ret = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, dev, chan); | ||
356 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
357 | return ret; | ||
358 | } | ||
359 | |||
360 | static inline int | ||
361 | rdev_set_monitor_channel(struct cfg80211_registered_device *rdev, | ||
362 | struct ieee80211_channel *chan, | ||
363 | enum nl80211_channel_type channel_type) | ||
364 | { | ||
365 | int ret; | ||
366 | trace_rdev_set_monitor_channel(&rdev->wiphy, chan, channel_type); | ||
367 | ret = rdev->ops->set_monitor_channel(&rdev->wiphy, chan, channel_type); | ||
368 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
369 | return ret; | ||
370 | } | ||
371 | |||
372 | static inline int rdev_scan(struct cfg80211_registered_device *rdev, | ||
373 | struct cfg80211_scan_request *request) | ||
374 | { | ||
375 | int ret; | ||
376 | trace_rdev_scan(&rdev->wiphy, request); | ||
377 | ret = rdev->ops->scan(&rdev->wiphy, request); | ||
378 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | static inline int rdev_auth(struct cfg80211_registered_device *rdev, | ||
383 | struct net_device *dev, | ||
384 | struct cfg80211_auth_request *req) | ||
385 | { | ||
386 | int ret; | ||
387 | trace_rdev_auth(&rdev->wiphy, dev, req); | ||
388 | ret = rdev->ops->auth(&rdev->wiphy, dev, req); | ||
389 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
390 | return ret; | ||
391 | } | ||
392 | |||
393 | static inline int rdev_assoc(struct cfg80211_registered_device *rdev, | ||
394 | struct net_device *dev, | ||
395 | struct cfg80211_assoc_request *req) | ||
396 | { | ||
397 | int ret; | ||
398 | trace_rdev_assoc(&rdev->wiphy, dev, req); | ||
399 | ret = rdev->ops->assoc(&rdev->wiphy, dev, req); | ||
400 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
401 | return ret; | ||
402 | } | ||
403 | |||
404 | static inline int rdev_deauth(struct cfg80211_registered_device *rdev, | ||
405 | struct net_device *dev, | ||
406 | struct cfg80211_deauth_request *req) | ||
407 | { | ||
408 | int ret; | ||
409 | trace_rdev_deauth(&rdev->wiphy, dev, req); | ||
410 | ret = rdev->ops->deauth(&rdev->wiphy, dev, req); | ||
411 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
412 | return ret; | ||
413 | } | ||
414 | |||
415 | static inline int rdev_disassoc(struct cfg80211_registered_device *rdev, | ||
416 | struct net_device *dev, | ||
417 | struct cfg80211_disassoc_request *req) | ||
418 | { | ||
419 | int ret; | ||
420 | trace_rdev_disassoc(&rdev->wiphy, dev, req); | ||
421 | ret = rdev->ops->disassoc(&rdev->wiphy, dev, req); | ||
422 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
423 | return ret; | ||
424 | } | ||
425 | |||
426 | static inline int rdev_connect(struct cfg80211_registered_device *rdev, | ||
427 | struct net_device *dev, | ||
428 | struct cfg80211_connect_params *sme) | ||
429 | { | ||
430 | int ret; | ||
431 | trace_rdev_connect(&rdev->wiphy, dev, sme); | ||
432 | ret = rdev->ops->connect(&rdev->wiphy, dev, sme); | ||
433 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
434 | return ret; | ||
435 | } | ||
436 | |||
437 | static inline int rdev_disconnect(struct cfg80211_registered_device *rdev, | ||
438 | struct net_device *dev, u16 reason_code) | ||
439 | { | ||
440 | int ret; | ||
441 | trace_rdev_disconnect(&rdev->wiphy, dev, reason_code); | ||
442 | ret = rdev->ops->disconnect(&rdev->wiphy, dev, reason_code); | ||
443 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
444 | return ret; | ||
445 | } | ||
446 | |||
447 | static inline int rdev_join_ibss(struct cfg80211_registered_device *rdev, | ||
448 | struct net_device *dev, | ||
449 | struct cfg80211_ibss_params *params) | ||
450 | { | ||
451 | int ret; | ||
452 | trace_rdev_join_ibss(&rdev->wiphy, dev, params); | ||
453 | ret = rdev->ops->join_ibss(&rdev->wiphy, dev, params); | ||
454 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
455 | return ret; | ||
456 | } | ||
457 | |||
458 | static inline int rdev_leave_ibss(struct cfg80211_registered_device *rdev, | ||
459 | struct net_device *dev) | ||
460 | { | ||
461 | int ret; | ||
462 | trace_rdev_leave_ibss(&rdev->wiphy, dev); | ||
463 | ret = rdev->ops->leave_ibss(&rdev->wiphy, dev); | ||
464 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
465 | return ret; | ||
466 | } | ||
467 | |||
468 | static inline int | ||
469 | rdev_set_wiphy_params(struct cfg80211_registered_device *rdev, u32 changed) | ||
470 | { | ||
471 | int ret; | ||
472 | trace_rdev_set_wiphy_params(&rdev->wiphy, changed); | ||
473 | ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed); | ||
474 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
475 | return ret; | ||
476 | } | ||
477 | |||
478 | static inline int rdev_set_tx_power(struct cfg80211_registered_device *rdev, | ||
479 | struct wireless_dev *wdev, | ||
480 | enum nl80211_tx_power_setting type, int mbm) | ||
481 | { | ||
482 | int ret; | ||
483 | trace_rdev_set_tx_power(&rdev->wiphy, wdev, type, mbm); | ||
484 | ret = rdev->ops->set_tx_power(&rdev->wiphy, wdev, type, mbm); | ||
485 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
486 | return ret; | ||
487 | } | ||
488 | |||
489 | static inline int rdev_get_tx_power(struct cfg80211_registered_device *rdev, | ||
490 | struct wireless_dev *wdev, int *dbm) | ||
491 | { | ||
492 | int ret; | ||
493 | trace_rdev_get_tx_power(&rdev->wiphy, wdev); | ||
494 | ret = rdev->ops->get_tx_power(&rdev->wiphy, wdev, dbm); | ||
495 | trace_rdev_return_int_int(&rdev->wiphy, ret, *dbm); | ||
496 | return ret; | ||
497 | } | ||
498 | |||
499 | static inline int rdev_set_wds_peer(struct cfg80211_registered_device *rdev, | ||
500 | struct net_device *dev, const u8 *addr) | ||
501 | { | ||
502 | int ret; | ||
503 | trace_rdev_set_wds_peer(&rdev->wiphy, dev, addr); | ||
504 | ret = rdev->ops->set_wds_peer(&rdev->wiphy, dev, addr); | ||
505 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
506 | return ret; | ||
507 | } | ||
508 | |||
509 | static inline void rdev_rfkill_poll(struct cfg80211_registered_device *rdev) | ||
510 | { | ||
511 | trace_rdev_rfkill_poll(&rdev->wiphy); | ||
512 | rdev->ops->rfkill_poll(&rdev->wiphy); | ||
513 | trace_rdev_return_void(&rdev->wiphy); | ||
514 | } | ||
515 | |||
516 | |||
517 | #ifdef CONFIG_NL80211_TESTMODE | ||
518 | static inline int rdev_testmode_cmd(struct cfg80211_registered_device *rdev, | ||
519 | void *data, int len) | ||
520 | { | ||
521 | int ret; | ||
522 | trace_rdev_testmode_cmd(&rdev->wiphy); | ||
523 | ret = rdev->ops->testmode_cmd(&rdev->wiphy, data, len); | ||
524 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
525 | return ret; | ||
526 | } | ||
527 | |||
528 | static inline int rdev_testmode_dump(struct cfg80211_registered_device *rdev, | ||
529 | struct sk_buff *skb, | ||
530 | struct netlink_callback *cb, void *data, | ||
531 | int len) | ||
532 | { | ||
533 | int ret; | ||
534 | trace_rdev_testmode_dump(&rdev->wiphy); | ||
535 | ret = rdev->ops->testmode_dump(&rdev->wiphy, skb, cb, data, len); | ||
536 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
537 | return ret; | ||
538 | } | ||
539 | #endif | ||
540 | |||
541 | static inline int | ||
542 | rdev_set_bitrate_mask(struct cfg80211_registered_device *rdev, | ||
543 | struct net_device *dev, const u8 *peer, | ||
544 | const struct cfg80211_bitrate_mask *mask) | ||
545 | { | ||
546 | int ret; | ||
547 | trace_rdev_set_bitrate_mask(&rdev->wiphy, dev, peer, mask); | ||
548 | ret = rdev->ops->set_bitrate_mask(&rdev->wiphy, dev, peer, mask); | ||
549 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
550 | return ret; | ||
551 | } | ||
552 | |||
553 | static inline int rdev_dump_survey(struct cfg80211_registered_device *rdev, | ||
554 | struct net_device *netdev, int idx, | ||
555 | struct survey_info *info) | ||
556 | { | ||
557 | int ret; | ||
558 | trace_rdev_dump_survey(&rdev->wiphy, netdev, idx); | ||
559 | ret = rdev->ops->dump_survey(&rdev->wiphy, netdev, idx, info); | ||
560 | if (ret < 0) | ||
561 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
562 | else | ||
563 | trace_rdev_return_int_survey_info(&rdev->wiphy, ret, info); | ||
564 | return ret; | ||
565 | } | ||
566 | |||
567 | static inline int rdev_set_pmksa(struct cfg80211_registered_device *rdev, | ||
568 | struct net_device *netdev, | ||
569 | struct cfg80211_pmksa *pmksa) | ||
570 | { | ||
571 | int ret; | ||
572 | trace_rdev_set_pmksa(&rdev->wiphy, netdev, pmksa); | ||
573 | ret = rdev->ops->set_pmksa(&rdev->wiphy, netdev, pmksa); | ||
574 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
575 | return ret; | ||
576 | } | ||
577 | |||
578 | static inline int rdev_del_pmksa(struct cfg80211_registered_device *rdev, | ||
579 | struct net_device *netdev, | ||
580 | struct cfg80211_pmksa *pmksa) | ||
581 | { | ||
582 | int ret; | ||
583 | trace_rdev_del_pmksa(&rdev->wiphy, netdev, pmksa); | ||
584 | ret = rdev->ops->del_pmksa(&rdev->wiphy, netdev, pmksa); | ||
585 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
586 | return ret; | ||
587 | } | ||
588 | |||
589 | static inline int rdev_flush_pmksa(struct cfg80211_registered_device *rdev, | ||
590 | struct net_device *netdev) | ||
591 | { | ||
592 | int ret; | ||
593 | trace_rdev_flush_pmksa(&rdev->wiphy, netdev); | ||
594 | ret = rdev->ops->flush_pmksa(&rdev->wiphy, netdev); | ||
595 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
596 | return ret; | ||
597 | } | ||
598 | |||
599 | static inline int | ||
600 | rdev_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
601 | struct wireless_dev *wdev, | ||
602 | struct ieee80211_channel *chan, | ||
603 | enum nl80211_channel_type channel_type, | ||
604 | unsigned int duration, u64 *cookie) | ||
605 | { | ||
606 | int ret; | ||
607 | trace_rdev_remain_on_channel(&rdev->wiphy, wdev, chan, channel_type, | ||
608 | duration); | ||
609 | ret = rdev->ops->remain_on_channel(&rdev->wiphy, wdev, chan, | ||
610 | channel_type, duration, cookie); | ||
611 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
612 | return ret; | ||
613 | } | ||
614 | |||
615 | static inline int | ||
616 | rdev_cancel_remain_on_channel(struct cfg80211_registered_device *rdev, | ||
617 | struct wireless_dev *wdev, u64 cookie) | ||
618 | { | ||
619 | int ret; | ||
620 | trace_rdev_cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); | ||
621 | ret = rdev->ops->cancel_remain_on_channel(&rdev->wiphy, wdev, cookie); | ||
622 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
623 | return ret; | ||
624 | } | ||
625 | |||
626 | static inline int rdev_mgmt_tx(struct cfg80211_registered_device *rdev, | ||
627 | struct wireless_dev *wdev, | ||
628 | struct ieee80211_channel *chan, bool offchan, | ||
629 | enum nl80211_channel_type channel_type, | ||
630 | bool channel_type_valid, unsigned int wait, | ||
631 | const u8 *buf, size_t len, bool no_cck, | ||
632 | bool dont_wait_for_ack, u64 *cookie) | ||
633 | { | ||
634 | int ret; | ||
635 | trace_rdev_mgmt_tx(&rdev->wiphy, wdev, chan, offchan, channel_type, | ||
636 | channel_type_valid, wait, no_cck, dont_wait_for_ack); | ||
637 | ret = rdev->ops->mgmt_tx(&rdev->wiphy, wdev, chan, offchan, | ||
638 | channel_type, channel_type_valid, wait, buf, | ||
639 | len, no_cck, dont_wait_for_ack, cookie); | ||
640 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
641 | return ret; | ||
642 | } | ||
643 | |||
644 | static inline int | ||
645 | rdev_mgmt_tx_cancel_wait(struct cfg80211_registered_device *rdev, | ||
646 | struct wireless_dev *wdev, u64 cookie) | ||
647 | { | ||
648 | int ret; | ||
649 | trace_rdev_mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); | ||
650 | ret = rdev->ops->mgmt_tx_cancel_wait(&rdev->wiphy, wdev, cookie); | ||
651 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
652 | return ret; | ||
653 | } | ||
654 | |||
655 | static inline int rdev_set_power_mgmt(struct cfg80211_registered_device *rdev, | ||
656 | struct net_device *dev, bool enabled, | ||
657 | int timeout) | ||
658 | { | ||
659 | int ret; | ||
660 | trace_rdev_set_power_mgmt(&rdev->wiphy, dev, enabled, timeout); | ||
661 | ret = rdev->ops->set_power_mgmt(&rdev->wiphy, dev, enabled, timeout); | ||
662 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
663 | return ret; | ||
664 | } | ||
665 | |||
666 | static inline int | ||
667 | rdev_set_cqm_rssi_config(struct cfg80211_registered_device *rdev, | ||
668 | struct net_device *dev, s32 rssi_thold, u32 rssi_hyst) | ||
669 | { | ||
670 | int ret; | ||
671 | trace_rdev_set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold, | ||
672 | rssi_hyst); | ||
673 | ret = rdev->ops->set_cqm_rssi_config(&rdev->wiphy, dev, rssi_thold, | ||
674 | rssi_hyst); | ||
675 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
676 | return ret; | ||
677 | } | ||
678 | |||
679 | static inline int | ||
680 | rdev_set_cqm_txe_config(struct cfg80211_registered_device *rdev, | ||
681 | struct net_device *dev, u32 rate, u32 pkts, u32 intvl) | ||
682 | { | ||
683 | int ret; | ||
684 | trace_rdev_set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts, intvl); | ||
685 | ret = rdev->ops->set_cqm_txe_config(&rdev->wiphy, dev, rate, pkts, | ||
686 | intvl); | ||
687 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
688 | return ret; | ||
689 | } | ||
690 | |||
691 | static inline void | ||
692 | rdev_mgmt_frame_register(struct cfg80211_registered_device *rdev, | ||
693 | struct wireless_dev *wdev, u16 frame_type, bool reg) | ||
694 | { | ||
695 | trace_rdev_mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg); | ||
696 | rdev->ops->mgmt_frame_register(&rdev->wiphy, wdev , frame_type, reg); | ||
697 | trace_rdev_return_void(&rdev->wiphy); | ||
698 | } | ||
699 | |||
700 | static inline int rdev_set_antenna(struct cfg80211_registered_device *rdev, | ||
701 | u32 tx_ant, u32 rx_ant) | ||
702 | { | ||
703 | int ret; | ||
704 | trace_rdev_set_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
705 | ret = rdev->ops->set_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
706 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
707 | return ret; | ||
708 | } | ||
709 | |||
710 | static inline int rdev_get_antenna(struct cfg80211_registered_device *rdev, | ||
711 | u32 *tx_ant, u32 *rx_ant) | ||
712 | { | ||
713 | int ret; | ||
714 | trace_rdev_get_antenna(&rdev->wiphy); | ||
715 | ret = rdev->ops->get_antenna(&rdev->wiphy, tx_ant, rx_ant); | ||
716 | if (ret) | ||
717 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
718 | else | ||
719 | trace_rdev_return_int_tx_rx(&rdev->wiphy, ret, *tx_ant, | ||
720 | *rx_ant); | ||
721 | return ret; | ||
722 | } | ||
723 | |||
724 | static inline int rdev_set_ringparam(struct cfg80211_registered_device *rdev, | ||
725 | u32 tx, u32 rx) | ||
726 | { | ||
727 | int ret; | ||
728 | trace_rdev_set_ringparam(&rdev->wiphy, tx, rx); | ||
729 | ret = rdev->ops->set_ringparam(&rdev->wiphy, tx, rx); | ||
730 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
731 | return ret; | ||
732 | } | ||
733 | |||
734 | static inline void rdev_get_ringparam(struct cfg80211_registered_device *rdev, | ||
735 | u32 *tx, u32 *tx_max, u32 *rx, | ||
736 | u32 *rx_max) | ||
737 | { | ||
738 | trace_rdev_get_ringparam(&rdev->wiphy); | ||
739 | rdev->ops->get_ringparam(&rdev->wiphy, tx, tx_max, rx, rx_max); | ||
740 | trace_rdev_return_void_tx_rx(&rdev->wiphy, *tx, *tx_max, *rx, *rx_max); | ||
741 | } | ||
742 | |||
743 | static inline int | ||
744 | rdev_sched_scan_start(struct cfg80211_registered_device *rdev, | ||
745 | struct net_device *dev, | ||
746 | struct cfg80211_sched_scan_request *request) | ||
747 | { | ||
748 | int ret; | ||
749 | trace_rdev_sched_scan_start(&rdev->wiphy, dev, request); | ||
750 | ret = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request); | ||
751 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
752 | return ret; | ||
753 | } | ||
754 | |||
755 | static inline int rdev_sched_scan_stop(struct cfg80211_registered_device *rdev, | ||
756 | struct net_device *dev) | ||
757 | { | ||
758 | int ret; | ||
759 | trace_rdev_sched_scan_stop(&rdev->wiphy, dev); | ||
760 | ret = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); | ||
761 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
762 | return ret; | ||
763 | } | ||
764 | |||
765 | static inline int rdev_set_rekey_data(struct cfg80211_registered_device *rdev, | ||
766 | struct net_device *dev, | ||
767 | struct cfg80211_gtk_rekey_data *data) | ||
768 | { | ||
769 | int ret; | ||
770 | trace_rdev_set_rekey_data(&rdev->wiphy, dev); | ||
771 | ret = rdev->ops->set_rekey_data(&rdev->wiphy, dev, data); | ||
772 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
773 | return ret; | ||
774 | } | ||
775 | |||
776 | static inline int rdev_tdls_mgmt(struct cfg80211_registered_device *rdev, | ||
777 | struct net_device *dev, u8 *peer, | ||
778 | u8 action_code, u8 dialog_token, | ||
779 | u16 status_code, const u8 *buf, size_t len) | ||
780 | { | ||
781 | int ret; | ||
782 | trace_rdev_tdls_mgmt(&rdev->wiphy, dev, peer, action_code, | ||
783 | dialog_token, status_code, buf, len); | ||
784 | ret = rdev->ops->tdls_mgmt(&rdev->wiphy, dev, peer, action_code, | ||
785 | dialog_token, status_code, buf, len); | ||
786 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
787 | return ret; | ||
788 | } | ||
789 | |||
790 | static inline int rdev_tdls_oper(struct cfg80211_registered_device *rdev, | ||
791 | struct net_device *dev, u8 *peer, | ||
792 | enum nl80211_tdls_operation oper) | ||
793 | { | ||
794 | int ret; | ||
795 | trace_rdev_tdls_oper(&rdev->wiphy, dev, peer, oper); | ||
796 | ret = rdev->ops->tdls_oper(&rdev->wiphy, dev, peer, oper); | ||
797 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
798 | return ret; | ||
799 | } | ||
800 | |||
801 | static inline int rdev_probe_client(struct cfg80211_registered_device *rdev, | ||
802 | struct net_device *dev, const u8 *peer, | ||
803 | u64 *cookie) | ||
804 | { | ||
805 | int ret; | ||
806 | trace_rdev_probe_client(&rdev->wiphy, dev, peer); | ||
807 | ret = rdev->ops->probe_client(&rdev->wiphy, dev, peer, cookie); | ||
808 | trace_rdev_return_int_cookie(&rdev->wiphy, ret, *cookie); | ||
809 | return ret; | ||
810 | } | ||
811 | |||
812 | static inline int rdev_set_noack_map(struct cfg80211_registered_device *rdev, | ||
813 | struct net_device *dev, u16 noack_map) | ||
814 | { | ||
815 | int ret; | ||
816 | trace_rdev_set_noack_map(&rdev->wiphy, dev, noack_map); | ||
817 | ret = rdev->ops->set_noack_map(&rdev->wiphy, dev, noack_map); | ||
818 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
819 | return ret; | ||
820 | } | ||
821 | |||
822 | static inline int | ||
823 | rdev_get_et_sset_count(struct cfg80211_registered_device *rdev, | ||
824 | struct net_device *dev, int sset) | ||
825 | { | ||
826 | int ret; | ||
827 | trace_rdev_get_et_sset_count(&rdev->wiphy, dev, sset); | ||
828 | ret = rdev->ops->get_et_sset_count(&rdev->wiphy, dev, sset); | ||
829 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
830 | return ret; | ||
831 | } | ||
832 | |||
833 | static inline void rdev_get_et_stats(struct cfg80211_registered_device *rdev, | ||
834 | struct net_device *dev, | ||
835 | struct ethtool_stats *stats, u64 *data) | ||
836 | { | ||
837 | trace_rdev_get_et_stats(&rdev->wiphy, dev); | ||
838 | rdev->ops->get_et_stats(&rdev->wiphy, dev, stats, data); | ||
839 | trace_rdev_return_void(&rdev->wiphy); | ||
840 | } | ||
841 | |||
842 | static inline void rdev_get_et_strings(struct cfg80211_registered_device *rdev, | ||
843 | struct net_device *dev, u32 sset, | ||
844 | u8 *data) | ||
845 | { | ||
846 | trace_rdev_get_et_strings(&rdev->wiphy, dev, sset); | ||
847 | rdev->ops->get_et_strings(&rdev->wiphy, dev, sset, data); | ||
848 | trace_rdev_return_void(&rdev->wiphy); | ||
849 | } | ||
850 | |||
851 | static inline struct ieee80211_channel | ||
852 | *rdev_get_channel(struct cfg80211_registered_device *rdev, | ||
853 | struct wireless_dev *wdev, enum nl80211_channel_type *type) | ||
854 | { | ||
855 | struct ieee80211_channel *ret; | ||
856 | trace_rdev_get_channel(&rdev->wiphy, wdev); | ||
857 | ret = rdev->ops->get_channel(&rdev->wiphy, wdev, type); | ||
858 | trace_rdev_return_channel(&rdev->wiphy, ret, *type); | ||
859 | return ret; | ||
860 | } | ||
861 | |||
862 | static inline int rdev_start_p2p_device(struct cfg80211_registered_device *rdev, | ||
863 | struct wireless_dev *wdev) | ||
864 | { | ||
865 | int ret; | ||
866 | |||
867 | trace_rdev_start_p2p_device(&rdev->wiphy, wdev); | ||
868 | ret = rdev->ops->start_p2p_device(&rdev->wiphy, wdev); | ||
869 | trace_rdev_return_int(&rdev->wiphy, ret); | ||
870 | return ret; | ||
871 | } | ||
872 | |||
873 | static inline void rdev_stop_p2p_device(struct cfg80211_registered_device *rdev, | ||
874 | struct wireless_dev *wdev) | ||
875 | { | ||
876 | trace_rdev_stop_p2p_device(&rdev->wiphy, wdev); | ||
877 | rdev->ops->stop_p2p_device(&rdev->wiphy, wdev); | ||
878 | trace_rdev_return_void(&rdev->wiphy); | ||
879 | } | ||
880 | #endif /* __CFG80211_RDEV_OPS */ | ||
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 3b8cbbc214db..b75756b05af7 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -141,9 +141,8 @@ static const struct ieee80211_regdomain world_regdom = { | |||
141 | .reg_rules = { | 141 | .reg_rules = { |
142 | /* IEEE 802.11b/g, channels 1..11 */ | 142 | /* IEEE 802.11b/g, channels 1..11 */ |
143 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), | 143 | REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), |
144 | /* IEEE 802.11b/g, channels 12..13. No HT40 | 144 | /* IEEE 802.11b/g, channels 12..13. */ |
145 | * channel fits here. */ | 145 | REG_RULE(2467-10, 2472+10, 40, 6, 20, |
146 | REG_RULE(2467-10, 2472+10, 20, 6, 20, | ||
147 | NL80211_RRF_PASSIVE_SCAN | | 146 | NL80211_RRF_PASSIVE_SCAN | |
148 | NL80211_RRF_NO_IBSS), | 147 | NL80211_RRF_NO_IBSS), |
149 | /* IEEE 802.11 channel 14 - Only JP enables | 148 | /* IEEE 802.11 channel 14 - Only JP enables |
@@ -908,7 +907,7 @@ static void handle_channel(struct wiphy *wiphy, | |||
908 | map_regdom_flags(reg_rule->flags) | bw_flags; | 907 | map_regdom_flags(reg_rule->flags) | bw_flags; |
909 | chan->max_antenna_gain = chan->orig_mag = | 908 | chan->max_antenna_gain = chan->orig_mag = |
910 | (int) MBI_TO_DBI(power_rule->max_antenna_gain); | 909 | (int) MBI_TO_DBI(power_rule->max_antenna_gain); |
911 | chan->max_power = chan->orig_mpwr = | 910 | chan->max_reg_power = chan->max_power = chan->orig_mpwr = |
912 | (int) MBM_TO_DBM(power_rule->max_eirp); | 911 | (int) MBM_TO_DBM(power_rule->max_eirp); |
913 | return; | 912 | return; |
914 | } | 913 | } |
@@ -1331,7 +1330,8 @@ static void handle_channel_custom(struct wiphy *wiphy, | |||
1331 | 1330 | ||
1332 | chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; | 1331 | chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; |
1333 | chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); | 1332 | chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); |
1334 | chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); | 1333 | chan->max_reg_power = chan->max_power = |
1334 | (int) MBM_TO_DBM(power_rule->max_eirp); | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, | 1337 | static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 9730c9862bdc..7f97a087f452 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
@@ -17,9 +17,58 @@ | |||
17 | #include "core.h" | 17 | #include "core.h" |
18 | #include "nl80211.h" | 18 | #include "nl80211.h" |
19 | #include "wext-compat.h" | 19 | #include "wext-compat.h" |
20 | #include "rdev-ops.h" | ||
20 | 21 | ||
21 | #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) | 22 | #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) |
22 | 23 | ||
24 | static void bss_release(struct kref *ref) | ||
25 | { | ||
26 | struct cfg80211_internal_bss *bss; | ||
27 | |||
28 | bss = container_of(ref, struct cfg80211_internal_bss, ref); | ||
29 | if (bss->pub.free_priv) | ||
30 | bss->pub.free_priv(&bss->pub); | ||
31 | |||
32 | if (bss->beacon_ies_allocated) | ||
33 | kfree(bss->pub.beacon_ies); | ||
34 | if (bss->proberesp_ies_allocated) | ||
35 | kfree(bss->pub.proberesp_ies); | ||
36 | |||
37 | BUG_ON(atomic_read(&bss->hold)); | ||
38 | |||
39 | kfree(bss); | ||
40 | } | ||
41 | |||
42 | /* must hold dev->bss_lock! */ | ||
43 | static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, | ||
44 | struct cfg80211_internal_bss *bss) | ||
45 | { | ||
46 | list_del_init(&bss->list); | ||
47 | rb_erase(&bss->rbn, &dev->bss_tree); | ||
48 | kref_put(&bss->ref, bss_release); | ||
49 | } | ||
50 | |||
51 | /* must hold dev->bss_lock! */ | ||
52 | static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev, | ||
53 | unsigned long expire_time) | ||
54 | { | ||
55 | struct cfg80211_internal_bss *bss, *tmp; | ||
56 | bool expired = false; | ||
57 | |||
58 | list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { | ||
59 | if (atomic_read(&bss->hold)) | ||
60 | continue; | ||
61 | if (!time_after(expire_time, bss->ts)) | ||
62 | continue; | ||
63 | |||
64 | __cfg80211_unlink_bss(dev, bss); | ||
65 | expired = true; | ||
66 | } | ||
67 | |||
68 | if (expired) | ||
69 | dev->bss_generation++; | ||
70 | } | ||
71 | |||
23 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) | 72 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) |
24 | { | 73 | { |
25 | struct cfg80211_scan_request *request; | 74 | struct cfg80211_scan_request *request; |
@@ -45,10 +94,17 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak) | |||
45 | if (wdev->netdev) | 94 | if (wdev->netdev) |
46 | cfg80211_sme_scan_done(wdev->netdev); | 95 | cfg80211_sme_scan_done(wdev->netdev); |
47 | 96 | ||
48 | if (request->aborted) | 97 | if (request->aborted) { |
49 | nl80211_send_scan_aborted(rdev, wdev); | 98 | nl80211_send_scan_aborted(rdev, wdev); |
50 | else | 99 | } else { |
100 | if (request->flags & NL80211_SCAN_FLAG_FLUSH) { | ||
101 | /* flush entries from previous scans */ | ||
102 | spin_lock_bh(&rdev->bss_lock); | ||
103 | __cfg80211_bss_expire(rdev, request->scan_start); | ||
104 | spin_unlock_bh(&rdev->bss_lock); | ||
105 | } | ||
51 | nl80211_send_scan_done(rdev, wdev); | 106 | nl80211_send_scan_done(rdev, wdev); |
107 | } | ||
52 | 108 | ||
53 | #ifdef CONFIG_CFG80211_WEXT | 109 | #ifdef CONFIG_CFG80211_WEXT |
54 | if (wdev->netdev && !request->aborted) { | 110 | if (wdev->netdev && !request->aborted) { |
@@ -89,6 +145,7 @@ void __cfg80211_scan_done(struct work_struct *wk) | |||
89 | 145 | ||
90 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) | 146 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted) |
91 | { | 147 | { |
148 | trace_cfg80211_scan_done(request, aborted); | ||
92 | WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); | 149 | WARN_ON(request != wiphy_to_dev(request->wiphy)->scan_req); |
93 | 150 | ||
94 | request->aborted = aborted; | 151 | request->aborted = aborted; |
@@ -99,22 +156,34 @@ EXPORT_SYMBOL(cfg80211_scan_done); | |||
99 | void __cfg80211_sched_scan_results(struct work_struct *wk) | 156 | void __cfg80211_sched_scan_results(struct work_struct *wk) |
100 | { | 157 | { |
101 | struct cfg80211_registered_device *rdev; | 158 | struct cfg80211_registered_device *rdev; |
159 | struct cfg80211_sched_scan_request *request; | ||
102 | 160 | ||
103 | rdev = container_of(wk, struct cfg80211_registered_device, | 161 | rdev = container_of(wk, struct cfg80211_registered_device, |
104 | sched_scan_results_wk); | 162 | sched_scan_results_wk); |
105 | 163 | ||
164 | request = rdev->sched_scan_req; | ||
165 | |||
106 | mutex_lock(&rdev->sched_scan_mtx); | 166 | mutex_lock(&rdev->sched_scan_mtx); |
107 | 167 | ||
108 | /* we don't have sched_scan_req anymore if the scan is stopping */ | 168 | /* we don't have sched_scan_req anymore if the scan is stopping */ |
109 | if (rdev->sched_scan_req) | 169 | if (request) { |
110 | nl80211_send_sched_scan_results(rdev, | 170 | if (request->flags & NL80211_SCAN_FLAG_FLUSH) { |
111 | rdev->sched_scan_req->dev); | 171 | /* flush entries from previous scans */ |
172 | spin_lock_bh(&rdev->bss_lock); | ||
173 | __cfg80211_bss_expire(rdev, request->scan_start); | ||
174 | spin_unlock_bh(&rdev->bss_lock); | ||
175 | request->scan_start = | ||
176 | jiffies + msecs_to_jiffies(request->interval); | ||
177 | } | ||
178 | nl80211_send_sched_scan_results(rdev, request->dev); | ||
179 | } | ||
112 | 180 | ||
113 | mutex_unlock(&rdev->sched_scan_mtx); | 181 | mutex_unlock(&rdev->sched_scan_mtx); |
114 | } | 182 | } |
115 | 183 | ||
116 | void cfg80211_sched_scan_results(struct wiphy *wiphy) | 184 | void cfg80211_sched_scan_results(struct wiphy *wiphy) |
117 | { | 185 | { |
186 | trace_cfg80211_sched_scan_results(wiphy); | ||
118 | /* ignore if we're not scanning */ | 187 | /* ignore if we're not scanning */ |
119 | if (wiphy_to_dev(wiphy)->sched_scan_req) | 188 | if (wiphy_to_dev(wiphy)->sched_scan_req) |
120 | queue_work(cfg80211_wq, | 189 | queue_work(cfg80211_wq, |
@@ -126,6 +195,8 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy) | |||
126 | { | 195 | { |
127 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 196 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
128 | 197 | ||
198 | trace_cfg80211_sched_scan_stopped(wiphy); | ||
199 | |||
129 | mutex_lock(&rdev->sched_scan_mtx); | 200 | mutex_lock(&rdev->sched_scan_mtx); |
130 | __cfg80211_stop_sched_scan(rdev, true); | 201 | __cfg80211_stop_sched_scan(rdev, true); |
131 | mutex_unlock(&rdev->sched_scan_mtx); | 202 | mutex_unlock(&rdev->sched_scan_mtx); |
@@ -145,7 +216,7 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, | |||
145 | dev = rdev->sched_scan_req->dev; | 216 | dev = rdev->sched_scan_req->dev; |
146 | 217 | ||
147 | if (!driver_initiated) { | 218 | if (!driver_initiated) { |
148 | int err = rdev->ops->sched_scan_stop(&rdev->wiphy, dev); | 219 | int err = rdev_sched_scan_stop(rdev, dev); |
149 | if (err) | 220 | if (err) |
150 | return err; | 221 | return err; |
151 | } | 222 | } |
@@ -158,24 +229,6 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev, | |||
158 | return 0; | 229 | return 0; |
159 | } | 230 | } |
160 | 231 | ||
161 | static void bss_release(struct kref *ref) | ||
162 | { | ||
163 | struct cfg80211_internal_bss *bss; | ||
164 | |||
165 | bss = container_of(ref, struct cfg80211_internal_bss, ref); | ||
166 | if (bss->pub.free_priv) | ||
167 | bss->pub.free_priv(&bss->pub); | ||
168 | |||
169 | if (bss->beacon_ies_allocated) | ||
170 | kfree(bss->pub.beacon_ies); | ||
171 | if (bss->proberesp_ies_allocated) | ||
172 | kfree(bss->pub.proberesp_ies); | ||
173 | |||
174 | BUG_ON(atomic_read(&bss->hold)); | ||
175 | |||
176 | kfree(bss); | ||
177 | } | ||
178 | |||
179 | /* must hold dev->bss_lock! */ | 232 | /* must hold dev->bss_lock! */ |
180 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, | 233 | void cfg80211_bss_age(struct cfg80211_registered_device *dev, |
181 | unsigned long age_secs) | 234 | unsigned long age_secs) |
@@ -188,32 +241,9 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev, | |||
188 | } | 241 | } |
189 | } | 242 | } |
190 | 243 | ||
191 | /* must hold dev->bss_lock! */ | ||
192 | static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev, | ||
193 | struct cfg80211_internal_bss *bss) | ||
194 | { | ||
195 | list_del_init(&bss->list); | ||
196 | rb_erase(&bss->rbn, &dev->bss_tree); | ||
197 | kref_put(&bss->ref, bss_release); | ||
198 | } | ||
199 | |||
200 | /* must hold dev->bss_lock! */ | ||
201 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) | 244 | void cfg80211_bss_expire(struct cfg80211_registered_device *dev) |
202 | { | 245 | { |
203 | struct cfg80211_internal_bss *bss, *tmp; | 246 | __cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE); |
204 | bool expired = false; | ||
205 | |||
206 | list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) { | ||
207 | if (atomic_read(&bss->hold)) | ||
208 | continue; | ||
209 | if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE)) | ||
210 | continue; | ||
211 | __cfg80211_unlink_bss(dev, bss); | ||
212 | expired = true; | ||
213 | } | ||
214 | |||
215 | if (expired) | ||
216 | dev->bss_generation++; | ||
217 | } | 247 | } |
218 | 248 | ||
219 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) | 249 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len) |
@@ -459,6 +489,9 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | |||
459 | struct cfg80211_internal_bss *bss, *res = NULL; | 489 | struct cfg80211_internal_bss *bss, *res = NULL; |
460 | unsigned long now = jiffies; | 490 | unsigned long now = jiffies; |
461 | 491 | ||
492 | trace_cfg80211_get_bss(wiphy, channel, bssid, ssid, ssid_len, capa_mask, | ||
493 | capa_val); | ||
494 | |||
462 | spin_lock_bh(&dev->bss_lock); | 495 | spin_lock_bh(&dev->bss_lock); |
463 | 496 | ||
464 | list_for_each_entry(bss, &dev->bss_list, list) { | 497 | list_for_each_entry(bss, &dev->bss_list, list) { |
@@ -480,6 +513,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | |||
480 | spin_unlock_bh(&dev->bss_lock); | 513 | spin_unlock_bh(&dev->bss_lock); |
481 | if (!res) | 514 | if (!res) |
482 | return NULL; | 515 | return NULL; |
516 | trace_cfg80211_return_bss(&res->pub); | ||
483 | return &res->pub; | 517 | return &res->pub; |
484 | } | 518 | } |
485 | EXPORT_SYMBOL(cfg80211_get_bss); | 519 | EXPORT_SYMBOL(cfg80211_get_bss); |
@@ -792,6 +826,7 @@ cfg80211_inform_bss(struct wiphy *wiphy, | |||
792 | if (res->pub.capability & WLAN_CAPABILITY_ESS) | 826 | if (res->pub.capability & WLAN_CAPABILITY_ESS) |
793 | regulatory_hint_found_beacon(wiphy, channel, gfp); | 827 | regulatory_hint_found_beacon(wiphy, channel, gfp); |
794 | 828 | ||
829 | trace_cfg80211_return_bss(&res->pub); | ||
795 | /* cfg80211_bss_update gives us a referenced result */ | 830 | /* cfg80211_bss_update gives us a referenced result */ |
796 | return &res->pub; | 831 | return &res->pub; |
797 | } | 832 | } |
@@ -804,10 +839,13 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
804 | s32 signal, gfp_t gfp) | 839 | s32 signal, gfp_t gfp) |
805 | { | 840 | { |
806 | struct cfg80211_internal_bss *res; | 841 | struct cfg80211_internal_bss *res; |
842 | |||
807 | size_t ielen = len - offsetof(struct ieee80211_mgmt, | 843 | size_t ielen = len - offsetof(struct ieee80211_mgmt, |
808 | u.probe_resp.variable); | 844 | u.probe_resp.variable); |
809 | size_t privsz; | 845 | size_t privsz; |
810 | 846 | ||
847 | trace_cfg80211_inform_bss_frame(wiphy, channel, mgmt, len, signal); | ||
848 | |||
811 | if (WARN_ON(!mgmt)) | 849 | if (WARN_ON(!mgmt)) |
812 | return NULL; | 850 | return NULL; |
813 | 851 | ||
@@ -861,6 +899,7 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
861 | if (res->pub.capability & WLAN_CAPABILITY_ESS) | 899 | if (res->pub.capability & WLAN_CAPABILITY_ESS) |
862 | regulatory_hint_found_beacon(wiphy, channel, gfp); | 900 | regulatory_hint_found_beacon(wiphy, channel, gfp); |
863 | 901 | ||
902 | trace_cfg80211_return_bss(&res->pub); | ||
864 | /* cfg80211_bss_update gives us a referenced result */ | 903 | /* cfg80211_bss_update gives us a referenced result */ |
865 | return &res->pub; | 904 | return &res->pub; |
866 | } | 905 | } |
@@ -962,6 +1001,7 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
962 | creq->ssids = (void *)&creq->channels[n_channels]; | 1001 | creq->ssids = (void *)&creq->channels[n_channels]; |
963 | creq->n_channels = n_channels; | 1002 | creq->n_channels = n_channels; |
964 | creq->n_ssids = 1; | 1003 | creq->n_ssids = 1; |
1004 | creq->scan_start = jiffies; | ||
965 | 1005 | ||
966 | /* translate "Scan on frequencies" request */ | 1006 | /* translate "Scan on frequencies" request */ |
967 | i = 0; | 1007 | i = 0; |
@@ -1026,7 +1066,7 @@ int cfg80211_wext_siwscan(struct net_device *dev, | |||
1026 | creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; | 1066 | creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; |
1027 | 1067 | ||
1028 | rdev->scan_req = creq; | 1068 | rdev->scan_req = creq; |
1029 | err = rdev->ops->scan(wiphy, creq); | 1069 | err = rdev_scan(rdev, creq); |
1030 | if (err) { | 1070 | if (err) { |
1031 | rdev->scan_req = NULL; | 1071 | rdev->scan_req = NULL; |
1032 | /* creq will be freed below */ | 1072 | /* creq will be freed below */ |
diff --git a/net/wireless/sme.c b/net/wireless/sme.c index 6f39cb808302..c7490027237d 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <net/rtnetlink.h> | 16 | #include <net/rtnetlink.h> |
17 | #include "nl80211.h" | 17 | #include "nl80211.h" |
18 | #include "reg.h" | 18 | #include "reg.h" |
19 | #include "rdev-ops.h" | ||
19 | 20 | ||
20 | struct cfg80211_conn { | 21 | struct cfg80211_conn { |
21 | struct cfg80211_connect_params params; | 22 | struct cfg80211_connect_params params; |
@@ -138,10 +139,11 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev) | |||
138 | 139 | ||
139 | request->wdev = wdev; | 140 | request->wdev = wdev; |
140 | request->wiphy = &rdev->wiphy; | 141 | request->wiphy = &rdev->wiphy; |
142 | request->scan_start = jiffies; | ||
141 | 143 | ||
142 | rdev->scan_req = request; | 144 | rdev->scan_req = request; |
143 | 145 | ||
144 | err = rdev->ops->scan(wdev->wiphy, request); | 146 | err = rdev_scan(rdev, request); |
145 | if (!err) { | 147 | if (!err) { |
146 | wdev->conn->state = CFG80211_CONN_SCANNING; | 148 | wdev->conn->state = CFG80211_CONN_SCANNING; |
147 | nl80211_send_scan_start(rdev, wdev); | 149 | nl80211_send_scan_start(rdev, wdev); |
@@ -179,7 +181,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev) | |||
179 | params->ssid, params->ssid_len, | 181 | params->ssid, params->ssid_len, |
180 | NULL, 0, | 182 | NULL, 0, |
181 | params->key, params->key_len, | 183 | params->key, params->key_len, |
182 | params->key_idx); | 184 | params->key_idx, NULL, 0); |
183 | case CFG80211_CONN_ASSOCIATE_NEXT: | 185 | case CFG80211_CONN_ASSOCIATE_NEXT: |
184 | BUG_ON(!rdev->ops->assoc); | 186 | BUG_ON(!rdev->ops->assoc); |
185 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; | 187 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; |
@@ -716,7 +718,7 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, | |||
716 | */ | 718 | */ |
717 | if (rdev->ops->del_key) | 719 | if (rdev->ops->del_key) |
718 | for (i = 0; i < 6; i++) | 720 | for (i = 0; i < 6; i++) |
719 | rdev->ops->del_key(wdev->wiphy, dev, i, false, NULL); | 721 | rdev_del_key(rdev, dev, i, false, NULL); |
720 | 722 | ||
721 | #ifdef CONFIG_CFG80211_WEXT | 723 | #ifdef CONFIG_CFG80211_WEXT |
722 | memset(&wrqu, 0, sizeof(wrqu)); | 724 | memset(&wrqu, 0, sizeof(wrqu)); |
@@ -892,7 +894,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev, | |||
892 | } else { | 894 | } else { |
893 | wdev->sme_state = CFG80211_SME_CONNECTING; | 895 | wdev->sme_state = CFG80211_SME_CONNECTING; |
894 | wdev->connect_keys = connkeys; | 896 | wdev->connect_keys = connkeys; |
895 | err = rdev->ops->connect(&rdev->wiphy, dev, connect); | 897 | err = rdev_connect(rdev, dev, connect); |
896 | if (err) { | 898 | if (err) { |
897 | wdev->connect_keys = NULL; | 899 | wdev->connect_keys = NULL; |
898 | wdev->sme_state = CFG80211_SME_IDLE; | 900 | wdev->sme_state = CFG80211_SME_IDLE; |
@@ -964,7 +966,7 @@ int __cfg80211_disconnect(struct cfg80211_registered_device *rdev, | |||
964 | if (err) | 966 | if (err) |
965 | return err; | 967 | return err; |
966 | } else { | 968 | } else { |
967 | err = rdev->ops->disconnect(&rdev->wiphy, dev, reason); | 969 | err = rdev_disconnect(rdev, dev, reason); |
968 | if (err) | 970 | if (err) |
969 | return err; | 971 | return err; |
970 | } | 972 | } |
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index ff574597a854..9bf6d5e32166 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <net/cfg80211.h> | 16 | #include <net/cfg80211.h> |
17 | #include "sysfs.h" | 17 | #include "sysfs.h" |
18 | #include "core.h" | 18 | #include "core.h" |
19 | #include "rdev-ops.h" | ||
19 | 20 | ||
20 | static inline struct cfg80211_registered_device *dev_to_rdev( | 21 | static inline struct cfg80211_registered_device *dev_to_rdev( |
21 | struct device *dev) | 22 | struct device *dev) |
@@ -94,7 +95,7 @@ static int wiphy_suspend(struct device *dev, pm_message_t state) | |||
94 | if (rdev->ops->suspend) { | 95 | if (rdev->ops->suspend) { |
95 | rtnl_lock(); | 96 | rtnl_lock(); |
96 | if (rdev->wiphy.registered) | 97 | if (rdev->wiphy.registered) |
97 | ret = rdev->ops->suspend(&rdev->wiphy, rdev->wowlan); | 98 | ret = rdev_suspend(rdev); |
98 | rtnl_unlock(); | 99 | rtnl_unlock(); |
99 | } | 100 | } |
100 | 101 | ||
@@ -114,7 +115,7 @@ static int wiphy_resume(struct device *dev) | |||
114 | if (rdev->ops->resume) { | 115 | if (rdev->ops->resume) { |
115 | rtnl_lock(); | 116 | rtnl_lock(); |
116 | if (rdev->wiphy.registered) | 117 | if (rdev->wiphy.registered) |
117 | ret = rdev->ops->resume(&rdev->wiphy); | 118 | ret = rdev_resume(rdev); |
118 | rtnl_unlock(); | 119 | rtnl_unlock(); |
119 | } | 120 | } |
120 | 121 | ||
diff --git a/net/wireless/trace.c b/net/wireless/trace.c new file mode 100644 index 000000000000..95f997fad755 --- /dev/null +++ b/net/wireless/trace.c | |||
@@ -0,0 +1,7 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | #ifndef __CHECKER__ | ||
4 | #define CREATE_TRACE_POINTS | ||
5 | #include "trace.h" | ||
6 | |||
7 | #endif | ||
diff --git a/net/wireless/trace.h b/net/wireless/trace.h new file mode 100644 index 000000000000..8e03c6382a8a --- /dev/null +++ b/net/wireless/trace.h | |||
@@ -0,0 +1,2298 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM cfg80211 | ||
3 | |||
4 | #if !defined(__RDEV_OPS_TRACE) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define __RDEV_OPS_TRACE | ||
6 | |||
7 | #include <linux/tracepoint.h> | ||
8 | |||
9 | #include <linux/rtnetlink.h> | ||
10 | #include <net/cfg80211.h> | ||
11 | #include "core.h" | ||
12 | |||
13 | #define MAC_ENTRY(entry_mac) __array(u8, entry_mac, ETH_ALEN) | ||
14 | #define MAC_ASSIGN(entry_mac, given_mac) do { \ | ||
15 | if (given_mac) \ | ||
16 | memcpy(__entry->entry_mac, given_mac, ETH_ALEN); \ | ||
17 | else \ | ||
18 | memset(__entry->entry_mac, 0, ETH_ALEN); \ | ||
19 | } while (0) | ||
20 | #define MAC_PR_FMT "%pM" | ||
21 | #define MAC_PR_ARG(entry_mac) (__entry->entry_mac) | ||
22 | |||
23 | #define WIPHY_ENTRY MAC_ENTRY(wiphy_mac) | ||
24 | #define WIPHY_ASSIGN MAC_ASSIGN(wiphy_mac, wiphy->perm_addr) | ||
25 | #define WIPHY_PR_FMT "wiphy " MAC_PR_FMT | ||
26 | #define WIPHY_PR_ARG MAC_PR_ARG(wiphy_mac) | ||
27 | |||
28 | #define WDEV_ENTRY __field(u32, id) | ||
29 | #define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0) | ||
30 | #define WDEV_PR_FMT ", wdev id: %u" | ||
31 | #define WDEV_PR_ARG (__entry->id) | ||
32 | |||
33 | #define NETDEV_ENTRY __array(char, name, IFNAMSIZ) \ | ||
34 | MAC_ENTRY(netdev_addr) \ | ||
35 | __field(int, ifindex) | ||
36 | #define NETDEV_ASSIGN \ | ||
37 | do { \ | ||
38 | memcpy(__entry->name, netdev->name, IFNAMSIZ); \ | ||
39 | MAC_ASSIGN(netdev_addr, netdev->dev_addr); \ | ||
40 | (__entry->ifindex) = (netdev->ifindex); \ | ||
41 | } while (0) | ||
42 | #define NETDEV_PR_FMT ", netdev - name: %s, addr: " MAC_PR_FMT \ | ||
43 | ", intf index: %d" | ||
44 | #define NETDEV_PR_ARG (__entry->name), MAC_PR_ARG(netdev_addr), \ | ||
45 | (__entry->ifindex) | ||
46 | |||
47 | #define MESH_CFG_ENTRY __field(u16, dot11MeshRetryTimeout) \ | ||
48 | __field(u16, dot11MeshConfirmTimeout) \ | ||
49 | __field(u16, dot11MeshHoldingTimeout) \ | ||
50 | __field(u16, dot11MeshMaxPeerLinks) \ | ||
51 | __field(u8, dot11MeshMaxRetries) \ | ||
52 | __field(u8, dot11MeshTTL) \ | ||
53 | __field(u8, element_ttl) \ | ||
54 | __field(bool, auto_open_plinks) \ | ||
55 | __field(u32, dot11MeshNbrOffsetMaxNeighbor) \ | ||
56 | __field(u8, dot11MeshHWMPmaxPREQretries) \ | ||
57 | __field(u32, path_refresh_time) \ | ||
58 | __field(u32, dot11MeshHWMPactivePathTimeout) \ | ||
59 | __field(u16, min_discovery_timeout) \ | ||
60 | __field(u16, dot11MeshHWMPpreqMinInterval) \ | ||
61 | __field(u16, dot11MeshHWMPperrMinInterval) \ | ||
62 | __field(u16, dot11MeshHWMPnetDiameterTraversalTime) \ | ||
63 | __field(u8, dot11MeshHWMPRootMode) \ | ||
64 | __field(u16, dot11MeshHWMPRannInterval) \ | ||
65 | __field(bool, dot11MeshGateAnnouncementProtocol) \ | ||
66 | __field(bool, dot11MeshForwarding) \ | ||
67 | __field(s32, rssi_threshold) \ | ||
68 | __field(u16, ht_opmode) \ | ||
69 | __field(u32, dot11MeshHWMPactivePathToRootTimeout) \ | ||
70 | __field(u16, dot11MeshHWMProotInterval) \ | ||
71 | __field(u16, dot11MeshHWMPconfirmationInterval) | ||
72 | #define MESH_CFG_ASSIGN \ | ||
73 | do { \ | ||
74 | __entry->dot11MeshRetryTimeout = conf->dot11MeshRetryTimeout; \ | ||
75 | __entry->dot11MeshConfirmTimeout = \ | ||
76 | conf->dot11MeshConfirmTimeout; \ | ||
77 | __entry->dot11MeshHoldingTimeout = \ | ||
78 | conf->dot11MeshHoldingTimeout; \ | ||
79 | __entry->dot11MeshMaxPeerLinks = conf->dot11MeshMaxPeerLinks; \ | ||
80 | __entry->dot11MeshMaxRetries = conf->dot11MeshMaxRetries; \ | ||
81 | __entry->dot11MeshTTL = conf->dot11MeshTTL; \ | ||
82 | __entry->element_ttl = conf->element_ttl; \ | ||
83 | __entry->auto_open_plinks = conf->auto_open_plinks; \ | ||
84 | __entry->dot11MeshNbrOffsetMaxNeighbor = \ | ||
85 | conf->dot11MeshNbrOffsetMaxNeighbor; \ | ||
86 | __entry->dot11MeshHWMPmaxPREQretries = \ | ||
87 | conf->dot11MeshHWMPmaxPREQretries; \ | ||
88 | __entry->path_refresh_time = conf->path_refresh_time; \ | ||
89 | __entry->dot11MeshHWMPactivePathTimeout = \ | ||
90 | conf->dot11MeshHWMPactivePathTimeout; \ | ||
91 | __entry->min_discovery_timeout = conf->min_discovery_timeout; \ | ||
92 | __entry->dot11MeshHWMPpreqMinInterval = \ | ||
93 | conf->dot11MeshHWMPpreqMinInterval; \ | ||
94 | __entry->dot11MeshHWMPperrMinInterval = \ | ||
95 | conf->dot11MeshHWMPperrMinInterval; \ | ||
96 | __entry->dot11MeshHWMPnetDiameterTraversalTime = \ | ||
97 | conf->dot11MeshHWMPnetDiameterTraversalTime; \ | ||
98 | __entry->dot11MeshHWMPRootMode = conf->dot11MeshHWMPRootMode; \ | ||
99 | __entry->dot11MeshHWMPRannInterval = \ | ||
100 | conf->dot11MeshHWMPRannInterval; \ | ||
101 | __entry->dot11MeshGateAnnouncementProtocol = \ | ||
102 | conf->dot11MeshGateAnnouncementProtocol; \ | ||
103 | __entry->dot11MeshForwarding = conf->dot11MeshForwarding; \ | ||
104 | __entry->rssi_threshold = conf->rssi_threshold; \ | ||
105 | __entry->ht_opmode = conf->ht_opmode; \ | ||
106 | __entry->dot11MeshHWMPactivePathToRootTimeout = \ | ||
107 | conf->dot11MeshHWMPactivePathToRootTimeout; \ | ||
108 | __entry->dot11MeshHWMProotInterval = \ | ||
109 | conf->dot11MeshHWMProotInterval; \ | ||
110 | __entry->dot11MeshHWMPconfirmationInterval = \ | ||
111 | conf->dot11MeshHWMPconfirmationInterval; \ | ||
112 | } while (0) | ||
113 | |||
114 | #define CHAN_ENTRY __field(enum ieee80211_band, band) \ | ||
115 | __field(u16, center_freq) | ||
116 | #define CHAN_ASSIGN(chan) \ | ||
117 | do { \ | ||
118 | if (chan) { \ | ||
119 | __entry->band = chan->band; \ | ||
120 | __entry->center_freq = chan->center_freq; \ | ||
121 | } else { \ | ||
122 | __entry->band = 0; \ | ||
123 | __entry->center_freq = 0; \ | ||
124 | } \ | ||
125 | } while (0) | ||
126 | #define CHAN_PR_FMT ", band: %d, freq: %u" | ||
127 | #define CHAN_PR_ARG __entry->band, __entry->center_freq | ||
128 | |||
129 | #define SINFO_ENTRY __field(int, generation) \ | ||
130 | __field(u32, connected_time) \ | ||
131 | __field(u32, inactive_time) \ | ||
132 | __field(u32, rx_bytes) \ | ||
133 | __field(u32, tx_bytes) \ | ||
134 | __field(u32, rx_packets) \ | ||
135 | __field(u32, tx_packets) \ | ||
136 | __field(u32, tx_retries) \ | ||
137 | __field(u32, tx_failed) \ | ||
138 | __field(u32, rx_dropped_misc) \ | ||
139 | __field(u32, beacon_loss_count) \ | ||
140 | __field(u16, llid) \ | ||
141 | __field(u16, plid) \ | ||
142 | __field(u8, plink_state) | ||
143 | #define SINFO_ASSIGN \ | ||
144 | do { \ | ||
145 | __entry->generation = sinfo->generation; \ | ||
146 | __entry->connected_time = sinfo->connected_time; \ | ||
147 | __entry->inactive_time = sinfo->inactive_time; \ | ||
148 | __entry->rx_bytes = sinfo->rx_bytes; \ | ||
149 | __entry->tx_bytes = sinfo->tx_bytes; \ | ||
150 | __entry->rx_packets = sinfo->rx_packets; \ | ||
151 | __entry->tx_packets = sinfo->tx_packets; \ | ||
152 | __entry->tx_retries = sinfo->tx_retries; \ | ||
153 | __entry->tx_failed = sinfo->tx_failed; \ | ||
154 | __entry->rx_dropped_misc = sinfo->rx_dropped_misc; \ | ||
155 | __entry->beacon_loss_count = sinfo->beacon_loss_count; \ | ||
156 | __entry->llid = sinfo->llid; \ | ||
157 | __entry->plid = sinfo->plid; \ | ||
158 | __entry->plink_state = sinfo->plink_state; \ | ||
159 | } while (0) | ||
160 | |||
161 | #define BOOL_TO_STR(bo) (bo) ? "true" : "false" | ||
162 | |||
163 | /************************************************************* | ||
164 | * rdev->ops traces * | ||
165 | *************************************************************/ | ||
166 | |||
167 | TRACE_EVENT(rdev_suspend, | ||
168 | TP_PROTO(struct wiphy *wiphy, struct cfg80211_wowlan *wow), | ||
169 | TP_ARGS(wiphy, wow), | ||
170 | TP_STRUCT__entry( | ||
171 | WIPHY_ENTRY | ||
172 | __field(bool, any) | ||
173 | __field(bool, disconnect) | ||
174 | __field(bool, magic_pkt) | ||
175 | __field(bool, gtk_rekey_failure) | ||
176 | __field(bool, eap_identity_req) | ||
177 | __field(bool, four_way_handshake) | ||
178 | __field(bool, rfkill_release) | ||
179 | __field(bool, valid_wow) | ||
180 | ), | ||
181 | TP_fast_assign( | ||
182 | WIPHY_ASSIGN; | ||
183 | if (wow) { | ||
184 | __entry->any = wow->any; | ||
185 | __entry->disconnect = wow->disconnect; | ||
186 | __entry->magic_pkt = wow->magic_pkt; | ||
187 | __entry->gtk_rekey_failure = wow->gtk_rekey_failure; | ||
188 | __entry->eap_identity_req = wow->eap_identity_req; | ||
189 | __entry->four_way_handshake = wow->four_way_handshake; | ||
190 | __entry->rfkill_release = wow->rfkill_release; | ||
191 | __entry->valid_wow = true; | ||
192 | } else { | ||
193 | __entry->valid_wow = false; | ||
194 | } | ||
195 | ), | ||
196 | TP_printk(WIPHY_PR_FMT ", wow%s - any: %d, disconnect: %d, " | ||
197 | "magic pkt: %d, gtk rekey failure: %d, eap identify req: %d, " | ||
198 | "four way handshake: %d, rfkill release: %d.", | ||
199 | WIPHY_PR_ARG, __entry->valid_wow ? "" : "(Not configured!)", | ||
200 | __entry->any, __entry->disconnect, __entry->magic_pkt, | ||
201 | __entry->gtk_rekey_failure, __entry->eap_identity_req, | ||
202 | __entry->four_way_handshake, __entry->rfkill_release) | ||
203 | ); | ||
204 | |||
205 | TRACE_EVENT(rdev_return_int, | ||
206 | TP_PROTO(struct wiphy *wiphy, int ret), | ||
207 | TP_ARGS(wiphy, ret), | ||
208 | TP_STRUCT__entry( | ||
209 | WIPHY_ENTRY | ||
210 | __field(int, ret) | ||
211 | ), | ||
212 | TP_fast_assign( | ||
213 | WIPHY_ASSIGN; | ||
214 | __entry->ret = ret; | ||
215 | ), | ||
216 | TP_printk(WIPHY_PR_FMT ", returned: %d", WIPHY_PR_ARG, __entry->ret) | ||
217 | ); | ||
218 | |||
219 | TRACE_EVENT(rdev_scan, | ||
220 | TP_PROTO(struct wiphy *wiphy, struct cfg80211_scan_request *request), | ||
221 | TP_ARGS(wiphy, request), | ||
222 | TP_STRUCT__entry( | ||
223 | WIPHY_ENTRY | ||
224 | ), | ||
225 | TP_fast_assign( | ||
226 | WIPHY_ASSIGN; | ||
227 | ), | ||
228 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
229 | ); | ||
230 | |||
231 | DECLARE_EVENT_CLASS(wiphy_only_evt, | ||
232 | TP_PROTO(struct wiphy *wiphy), | ||
233 | TP_ARGS(wiphy), | ||
234 | TP_STRUCT__entry( | ||
235 | WIPHY_ENTRY | ||
236 | ), | ||
237 | TP_fast_assign( | ||
238 | WIPHY_ASSIGN; | ||
239 | ), | ||
240 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
241 | ); | ||
242 | |||
243 | DEFINE_EVENT(wiphy_only_evt, rdev_resume, | ||
244 | TP_PROTO(struct wiphy *wiphy), | ||
245 | TP_ARGS(wiphy) | ||
246 | ); | ||
247 | |||
248 | DEFINE_EVENT(wiphy_only_evt, rdev_return_void, | ||
249 | TP_PROTO(struct wiphy *wiphy), | ||
250 | TP_ARGS(wiphy) | ||
251 | ); | ||
252 | |||
253 | DEFINE_EVENT(wiphy_only_evt, rdev_get_ringparam, | ||
254 | TP_PROTO(struct wiphy *wiphy), | ||
255 | TP_ARGS(wiphy) | ||
256 | ); | ||
257 | |||
258 | DEFINE_EVENT(wiphy_only_evt, rdev_get_antenna, | ||
259 | TP_PROTO(struct wiphy *wiphy), | ||
260 | TP_ARGS(wiphy) | ||
261 | ); | ||
262 | |||
263 | DEFINE_EVENT(wiphy_only_evt, rdev_rfkill_poll, | ||
264 | TP_PROTO(struct wiphy *wiphy), | ||
265 | TP_ARGS(wiphy) | ||
266 | ); | ||
267 | |||
268 | DECLARE_EVENT_CLASS(wiphy_enabled_evt, | ||
269 | TP_PROTO(struct wiphy *wiphy, bool enabled), | ||
270 | TP_ARGS(wiphy, enabled), | ||
271 | TP_STRUCT__entry( | ||
272 | WIPHY_ENTRY | ||
273 | __field(bool, enabled) | ||
274 | ), | ||
275 | TP_fast_assign( | ||
276 | WIPHY_ASSIGN; | ||
277 | __entry->enabled = enabled; | ||
278 | ), | ||
279 | TP_printk(WIPHY_PR_FMT ", %senabled ", | ||
280 | WIPHY_PR_ARG, __entry->enabled ? "" : "not ") | ||
281 | ); | ||
282 | |||
283 | DEFINE_EVENT(wiphy_enabled_evt, rdev_set_wakeup, | ||
284 | TP_PROTO(struct wiphy *wiphy, bool enabled), | ||
285 | TP_ARGS(wiphy, enabled) | ||
286 | ); | ||
287 | |||
288 | TRACE_EVENT(rdev_add_virtual_intf, | ||
289 | TP_PROTO(struct wiphy *wiphy, char *name, enum nl80211_iftype type), | ||
290 | TP_ARGS(wiphy, name, type), | ||
291 | TP_STRUCT__entry( | ||
292 | WIPHY_ENTRY | ||
293 | __string(vir_intf_name, name ? name : "<noname>") | ||
294 | __field(enum nl80211_iftype, type) | ||
295 | ), | ||
296 | TP_fast_assign( | ||
297 | WIPHY_ASSIGN; | ||
298 | __assign_str(vir_intf_name, name ? name : "<noname>"); | ||
299 | __entry->type = type; | ||
300 | ), | ||
301 | TP_printk(WIPHY_PR_FMT ", virtual intf name: %s, type: %d", | ||
302 | WIPHY_PR_ARG, __get_str(vir_intf_name), __entry->type) | ||
303 | ); | ||
304 | |||
305 | DECLARE_EVENT_CLASS(wiphy_wdev_evt, | ||
306 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
307 | TP_ARGS(wiphy, wdev), | ||
308 | TP_STRUCT__entry( | ||
309 | WIPHY_ENTRY | ||
310 | WDEV_ENTRY | ||
311 | ), | ||
312 | TP_fast_assign( | ||
313 | WIPHY_ASSIGN; | ||
314 | WDEV_ASSIGN; | ||
315 | ), | ||
316 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT, WIPHY_PR_ARG, WDEV_PR_ARG) | ||
317 | ); | ||
318 | |||
319 | DEFINE_EVENT(wiphy_wdev_evt, rdev_return_wdev, | ||
320 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
321 | TP_ARGS(wiphy, wdev) | ||
322 | ); | ||
323 | |||
324 | DEFINE_EVENT(wiphy_wdev_evt, rdev_del_virtual_intf, | ||
325 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
326 | TP_ARGS(wiphy, wdev) | ||
327 | ); | ||
328 | |||
329 | TRACE_EVENT(rdev_change_virtual_intf, | ||
330 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
331 | enum nl80211_iftype type), | ||
332 | TP_ARGS(wiphy, netdev, type), | ||
333 | TP_STRUCT__entry( | ||
334 | WIPHY_ENTRY | ||
335 | NETDEV_ENTRY | ||
336 | __field(enum nl80211_iftype, type) | ||
337 | ), | ||
338 | TP_fast_assign( | ||
339 | WIPHY_ASSIGN; | ||
340 | NETDEV_ASSIGN; | ||
341 | __entry->type = type; | ||
342 | ), | ||
343 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", type: %d", | ||
344 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->type) | ||
345 | ); | ||
346 | |||
347 | DECLARE_EVENT_CLASS(key_handle, | ||
348 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
349 | bool pairwise, const u8 *mac_addr), | ||
350 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr), | ||
351 | TP_STRUCT__entry( | ||
352 | WIPHY_ENTRY | ||
353 | NETDEV_ENTRY | ||
354 | MAC_ENTRY(mac_addr) | ||
355 | __field(u8, key_index) | ||
356 | __field(bool, pairwise) | ||
357 | ), | ||
358 | TP_fast_assign( | ||
359 | WIPHY_ASSIGN; | ||
360 | NETDEV_ASSIGN; | ||
361 | MAC_ASSIGN(mac_addr, mac_addr); | ||
362 | __entry->key_index = key_index; | ||
363 | __entry->pairwise = pairwise; | ||
364 | ), | ||
365 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key_index: %u, pairwise: %s, mac addr: " MAC_PR_FMT, | ||
366 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index, | ||
367 | BOOL_TO_STR(__entry->pairwise), MAC_PR_ARG(mac_addr)) | ||
368 | ); | ||
369 | |||
370 | DEFINE_EVENT(key_handle, rdev_add_key, | ||
371 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
372 | bool pairwise, const u8 *mac_addr), | ||
373 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
374 | ); | ||
375 | |||
376 | DEFINE_EVENT(key_handle, rdev_get_key, | ||
377 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
378 | bool pairwise, const u8 *mac_addr), | ||
379 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
380 | ); | ||
381 | |||
382 | DEFINE_EVENT(key_handle, rdev_del_key, | ||
383 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
384 | bool pairwise, const u8 *mac_addr), | ||
385 | TP_ARGS(wiphy, netdev, key_index, pairwise, mac_addr) | ||
386 | ); | ||
387 | |||
388 | TRACE_EVENT(rdev_set_default_key, | ||
389 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, | ||
390 | bool unicast, bool multicast), | ||
391 | TP_ARGS(wiphy, netdev, key_index, unicast, multicast), | ||
392 | TP_STRUCT__entry( | ||
393 | WIPHY_ENTRY | ||
394 | NETDEV_ENTRY | ||
395 | __field(u8, key_index) | ||
396 | __field(bool, unicast) | ||
397 | __field(bool, multicast) | ||
398 | ), | ||
399 | TP_fast_assign( | ||
400 | WIPHY_ASSIGN; | ||
401 | NETDEV_ASSIGN; | ||
402 | __entry->key_index = key_index; | ||
403 | __entry->unicast = unicast; | ||
404 | __entry->multicast = multicast; | ||
405 | ), | ||
406 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key index: %u, unicast: %s, multicast: %s", | ||
407 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index, | ||
408 | BOOL_TO_STR(__entry->unicast), | ||
409 | BOOL_TO_STR(__entry->multicast)) | ||
410 | ); | ||
411 | |||
412 | TRACE_EVENT(rdev_set_default_mgmt_key, | ||
413 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 key_index), | ||
414 | TP_ARGS(wiphy, netdev, key_index), | ||
415 | TP_STRUCT__entry( | ||
416 | WIPHY_ENTRY | ||
417 | NETDEV_ENTRY | ||
418 | __field(u8, key_index) | ||
419 | ), | ||
420 | TP_fast_assign( | ||
421 | WIPHY_ASSIGN; | ||
422 | NETDEV_ASSIGN; | ||
423 | __entry->key_index = key_index; | ||
424 | ), | ||
425 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", key index: %u", | ||
426 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->key_index) | ||
427 | ); | ||
428 | |||
429 | TRACE_EVENT(rdev_start_ap, | ||
430 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
431 | struct cfg80211_ap_settings *settings), | ||
432 | TP_ARGS(wiphy, netdev, settings), | ||
433 | TP_STRUCT__entry( | ||
434 | WIPHY_ENTRY | ||
435 | NETDEV_ENTRY | ||
436 | CHAN_ENTRY | ||
437 | __field(int, beacon_interval) | ||
438 | __field(int, dtim_period) | ||
439 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
440 | __field(enum nl80211_hidden_ssid, hidden_ssid) | ||
441 | __field(u32, wpa_ver) | ||
442 | __field(bool, privacy) | ||
443 | __field(enum nl80211_auth_type, auth_type) | ||
444 | __field(int, inactivity_timeout) | ||
445 | ), | ||
446 | TP_fast_assign( | ||
447 | WIPHY_ASSIGN; | ||
448 | NETDEV_ASSIGN; | ||
449 | CHAN_ASSIGN(settings->channel); | ||
450 | __entry->beacon_interval = settings->beacon_interval; | ||
451 | __entry->dtim_period = settings->dtim_period; | ||
452 | __entry->hidden_ssid = settings->hidden_ssid; | ||
453 | __entry->wpa_ver = settings->crypto.wpa_versions; | ||
454 | __entry->privacy = settings->privacy; | ||
455 | __entry->auth_type = settings->auth_type; | ||
456 | __entry->inactivity_timeout = settings->inactivity_timeout; | ||
457 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
458 | memcpy(__entry->ssid, settings->ssid, settings->ssid_len); | ||
459 | ), | ||
460 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", AP settings - ssid: %s, " | ||
461 | CHAN_PR_FMT ", beacon interval: %d, dtim period: %d, " | ||
462 | "hidden ssid: %d, wpa versions: %u, privacy: %s, " | ||
463 | "auth type: %d, inactivity timeout: %d", | ||
464 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ssid, CHAN_PR_ARG, | ||
465 | __entry->beacon_interval, __entry->dtim_period, | ||
466 | __entry->hidden_ssid, __entry->wpa_ver, | ||
467 | BOOL_TO_STR(__entry->privacy), __entry->auth_type, | ||
468 | __entry->inactivity_timeout) | ||
469 | ); | ||
470 | |||
471 | TRACE_EVENT(rdev_change_beacon, | ||
472 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
473 | struct cfg80211_beacon_data *info), | ||
474 | TP_ARGS(wiphy, netdev, info), | ||
475 | TP_STRUCT__entry( | ||
476 | WIPHY_ENTRY | ||
477 | NETDEV_ENTRY | ||
478 | __dynamic_array(u8, head, info ? info->head_len : 0) | ||
479 | __dynamic_array(u8, tail, info ? info->tail_len : 0) | ||
480 | __dynamic_array(u8, beacon_ies, info ? info->beacon_ies_len : 0) | ||
481 | __dynamic_array(u8, proberesp_ies, | ||
482 | info ? info->proberesp_ies_len : 0) | ||
483 | __dynamic_array(u8, assocresp_ies, | ||
484 | info ? info->assocresp_ies_len : 0) | ||
485 | __dynamic_array(u8, probe_resp, info ? info->probe_resp_len : 0) | ||
486 | ), | ||
487 | TP_fast_assign( | ||
488 | WIPHY_ASSIGN; | ||
489 | NETDEV_ASSIGN; | ||
490 | if (info) { | ||
491 | if (info->head) | ||
492 | memcpy(__get_dynamic_array(head), info->head, | ||
493 | info->head_len); | ||
494 | if (info->tail) | ||
495 | memcpy(__get_dynamic_array(tail), info->tail, | ||
496 | info->tail_len); | ||
497 | if (info->beacon_ies) | ||
498 | memcpy(__get_dynamic_array(beacon_ies), | ||
499 | info->beacon_ies, info->beacon_ies_len); | ||
500 | if (info->proberesp_ies) | ||
501 | memcpy(__get_dynamic_array(proberesp_ies), | ||
502 | info->proberesp_ies, | ||
503 | info->proberesp_ies_len); | ||
504 | if (info->assocresp_ies) | ||
505 | memcpy(__get_dynamic_array(assocresp_ies), | ||
506 | info->assocresp_ies, | ||
507 | info->assocresp_ies_len); | ||
508 | if (info->probe_resp) | ||
509 | memcpy(__get_dynamic_array(probe_resp), | ||
510 | info->probe_resp, info->probe_resp_len); | ||
511 | } | ||
512 | ), | ||
513 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
514 | ); | ||
515 | |||
516 | DECLARE_EVENT_CLASS(wiphy_netdev_evt, | ||
517 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
518 | TP_ARGS(wiphy, netdev), | ||
519 | TP_STRUCT__entry( | ||
520 | WIPHY_ENTRY | ||
521 | NETDEV_ENTRY | ||
522 | ), | ||
523 | TP_fast_assign( | ||
524 | WIPHY_ASSIGN; | ||
525 | NETDEV_ASSIGN; | ||
526 | ), | ||
527 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
528 | ); | ||
529 | |||
530 | DEFINE_EVENT(wiphy_netdev_evt, rdev_stop_ap, | ||
531 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
532 | TP_ARGS(wiphy, netdev) | ||
533 | ); | ||
534 | |||
535 | DEFINE_EVENT(wiphy_netdev_evt, rdev_get_et_stats, | ||
536 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
537 | TP_ARGS(wiphy, netdev) | ||
538 | ); | ||
539 | |||
540 | DEFINE_EVENT(wiphy_netdev_evt, rdev_sched_scan_stop, | ||
541 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
542 | TP_ARGS(wiphy, netdev) | ||
543 | ); | ||
544 | |||
545 | DEFINE_EVENT(wiphy_netdev_evt, rdev_set_rekey_data, | ||
546 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
547 | TP_ARGS(wiphy, netdev) | ||
548 | ); | ||
549 | |||
550 | DEFINE_EVENT(wiphy_netdev_evt, rdev_get_mesh_config, | ||
551 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
552 | TP_ARGS(wiphy, netdev) | ||
553 | ); | ||
554 | |||
555 | DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_mesh, | ||
556 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
557 | TP_ARGS(wiphy, netdev) | ||
558 | ); | ||
559 | |||
560 | DEFINE_EVENT(wiphy_netdev_evt, rdev_leave_ibss, | ||
561 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
562 | TP_ARGS(wiphy, netdev) | ||
563 | ); | ||
564 | |||
565 | DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa, | ||
566 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), | ||
567 | TP_ARGS(wiphy, netdev) | ||
568 | ); | ||
569 | |||
570 | DECLARE_EVENT_CLASS(station_add_change, | ||
571 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
572 | struct station_parameters *params), | ||
573 | TP_ARGS(wiphy, netdev, mac, params), | ||
574 | TP_STRUCT__entry( | ||
575 | WIPHY_ENTRY | ||
576 | NETDEV_ENTRY | ||
577 | MAC_ENTRY(sta_mac) | ||
578 | __field(u32, sta_flags_mask) | ||
579 | __field(u32, sta_flags_set) | ||
580 | __field(u32, sta_modify_mask) | ||
581 | __field(int, listen_interval) | ||
582 | __field(u16, aid) | ||
583 | __field(u8, plink_action) | ||
584 | __field(u8, plink_state) | ||
585 | __field(u8, uapsd_queues) | ||
586 | __array(u8, ht_capa, (int)sizeof(struct ieee80211_ht_cap)) | ||
587 | ), | ||
588 | TP_fast_assign( | ||
589 | WIPHY_ASSIGN; | ||
590 | NETDEV_ASSIGN; | ||
591 | MAC_ASSIGN(sta_mac, mac); | ||
592 | __entry->sta_flags_mask = params->sta_flags_mask; | ||
593 | __entry->sta_flags_set = params->sta_flags_set; | ||
594 | __entry->sta_modify_mask = params->sta_modify_mask; | ||
595 | __entry->listen_interval = params->listen_interval; | ||
596 | __entry->aid = params->aid; | ||
597 | __entry->plink_action = params->plink_action; | ||
598 | __entry->plink_state = params->plink_state; | ||
599 | __entry->uapsd_queues = params->uapsd_queues; | ||
600 | memset(__entry->ht_capa, 0, sizeof(struct ieee80211_ht_cap)); | ||
601 | if (params->ht_capa) | ||
602 | memcpy(__entry->ht_capa, params->ht_capa, | ||
603 | sizeof(struct ieee80211_ht_cap)); | ||
604 | ), | ||
605 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", station mac: " MAC_PR_FMT | ||
606 | ", station flags mask: %u, station flags set: %u, " | ||
607 | "station modify mask: %u, listen interval: %d, aid: %u, " | ||
608 | "plink action: %u, plink state: %u, uapsd queues: %u", | ||
609 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac), | ||
610 | __entry->sta_flags_mask, __entry->sta_flags_set, | ||
611 | __entry->sta_modify_mask, __entry->listen_interval, | ||
612 | __entry->aid, __entry->plink_action, __entry->plink_state, | ||
613 | __entry->uapsd_queues) | ||
614 | ); | ||
615 | |||
616 | DEFINE_EVENT(station_add_change, rdev_add_station, | ||
617 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
618 | struct station_parameters *params), | ||
619 | TP_ARGS(wiphy, netdev, mac, params) | ||
620 | ); | ||
621 | |||
622 | DEFINE_EVENT(station_add_change, rdev_change_station, | ||
623 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, | ||
624 | struct station_parameters *params), | ||
625 | TP_ARGS(wiphy, netdev, mac, params) | ||
626 | ); | ||
627 | |||
628 | DECLARE_EVENT_CLASS(wiphy_netdev_mac_evt, | ||
629 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
630 | TP_ARGS(wiphy, netdev, mac), | ||
631 | TP_STRUCT__entry( | ||
632 | WIPHY_ENTRY | ||
633 | NETDEV_ENTRY | ||
634 | MAC_ENTRY(sta_mac) | ||
635 | ), | ||
636 | TP_fast_assign( | ||
637 | WIPHY_ASSIGN; | ||
638 | NETDEV_ASSIGN; | ||
639 | MAC_ASSIGN(sta_mac, mac); | ||
640 | ), | ||
641 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
642 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac)) | ||
643 | ); | ||
644 | |||
645 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_station, | ||
646 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
647 | TP_ARGS(wiphy, netdev, mac) | ||
648 | ); | ||
649 | |||
650 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_get_station, | ||
651 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
652 | TP_ARGS(wiphy, netdev, mac) | ||
653 | ); | ||
654 | |||
655 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_del_mpath, | ||
656 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
657 | TP_ARGS(wiphy, netdev, mac) | ||
658 | ); | ||
659 | |||
660 | DEFINE_EVENT(wiphy_netdev_mac_evt, rdev_set_wds_peer, | ||
661 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, const u8 *mac), | ||
662 | TP_ARGS(wiphy, netdev, mac) | ||
663 | ); | ||
664 | |||
665 | TRACE_EVENT(rdev_dump_station, | ||
666 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx, | ||
667 | u8 *mac), | ||
668 | TP_ARGS(wiphy, netdev, idx, mac), | ||
669 | TP_STRUCT__entry( | ||
670 | WIPHY_ENTRY | ||
671 | NETDEV_ENTRY | ||
672 | MAC_ENTRY(sta_mac) | ||
673 | __field(int, idx) | ||
674 | ), | ||
675 | TP_fast_assign( | ||
676 | WIPHY_ASSIGN; | ||
677 | NETDEV_ASSIGN; | ||
678 | MAC_ASSIGN(sta_mac, mac); | ||
679 | __entry->idx = idx; | ||
680 | ), | ||
681 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", station mac: " MAC_PR_FMT ", idx: %d", | ||
682 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(sta_mac), | ||
683 | __entry->idx) | ||
684 | ); | ||
685 | |||
686 | TRACE_EVENT(rdev_return_int_station_info, | ||
687 | TP_PROTO(struct wiphy *wiphy, int ret, struct station_info *sinfo), | ||
688 | TP_ARGS(wiphy, ret, sinfo), | ||
689 | TP_STRUCT__entry( | ||
690 | WIPHY_ENTRY | ||
691 | __field(int, ret) | ||
692 | SINFO_ENTRY | ||
693 | ), | ||
694 | TP_fast_assign( | ||
695 | WIPHY_ASSIGN; | ||
696 | __entry->ret = ret; | ||
697 | SINFO_ASSIGN; | ||
698 | ), | ||
699 | TP_printk(WIPHY_PR_FMT ", returned %d" , | ||
700 | WIPHY_PR_ARG, __entry->ret) | ||
701 | ); | ||
702 | |||
703 | DECLARE_EVENT_CLASS(mpath_evt, | ||
704 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
705 | u8 *next_hop), | ||
706 | TP_ARGS(wiphy, netdev, dst, next_hop), | ||
707 | TP_STRUCT__entry( | ||
708 | WIPHY_ENTRY | ||
709 | NETDEV_ENTRY | ||
710 | MAC_ENTRY(dst) | ||
711 | MAC_ENTRY(next_hop) | ||
712 | ), | ||
713 | TP_fast_assign( | ||
714 | WIPHY_ASSIGN; | ||
715 | NETDEV_ASSIGN; | ||
716 | MAC_ASSIGN(dst, dst); | ||
717 | MAC_ASSIGN(next_hop, next_hop); | ||
718 | ), | ||
719 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", destination: " MAC_PR_FMT ", next hop: " MAC_PR_FMT, | ||
720 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(dst), | ||
721 | MAC_PR_ARG(next_hop)) | ||
722 | ); | ||
723 | |||
724 | DEFINE_EVENT(mpath_evt, rdev_add_mpath, | ||
725 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
726 | u8 *next_hop), | ||
727 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
728 | ); | ||
729 | |||
730 | DEFINE_EVENT(mpath_evt, rdev_change_mpath, | ||
731 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
732 | u8 *next_hop), | ||
733 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
734 | ); | ||
735 | |||
736 | DEFINE_EVENT(mpath_evt, rdev_get_mpath, | ||
737 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *dst, | ||
738 | u8 *next_hop), | ||
739 | TP_ARGS(wiphy, netdev, dst, next_hop) | ||
740 | ); | ||
741 | |||
742 | TRACE_EVENT(rdev_dump_mpath, | ||
743 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx, | ||
744 | u8 *dst, u8 *next_hop), | ||
745 | TP_ARGS(wiphy, netdev, idx, dst, next_hop), | ||
746 | TP_STRUCT__entry( | ||
747 | WIPHY_ENTRY | ||
748 | NETDEV_ENTRY | ||
749 | MAC_ENTRY(dst) | ||
750 | MAC_ENTRY(next_hop) | ||
751 | __field(int, idx) | ||
752 | ), | ||
753 | TP_fast_assign( | ||
754 | WIPHY_ASSIGN; | ||
755 | NETDEV_ASSIGN; | ||
756 | MAC_ASSIGN(dst, dst); | ||
757 | MAC_ASSIGN(next_hop, next_hop); | ||
758 | __entry->idx = idx; | ||
759 | ), | ||
760 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", index: %d, destination: " | ||
761 | MAC_PR_FMT ", next hop: " MAC_PR_FMT, | ||
762 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx, MAC_PR_ARG(dst), | ||
763 | MAC_PR_ARG(next_hop)) | ||
764 | ); | ||
765 | |||
766 | TRACE_EVENT(rdev_return_int_mpath_info, | ||
767 | TP_PROTO(struct wiphy *wiphy, int ret, struct mpath_info *pinfo), | ||
768 | TP_ARGS(wiphy, ret, pinfo), | ||
769 | TP_STRUCT__entry( | ||
770 | WIPHY_ENTRY | ||
771 | __field(int, ret) | ||
772 | __field(int, generation) | ||
773 | __field(u32, filled) | ||
774 | __field(u32, frame_qlen) | ||
775 | __field(u32, sn) | ||
776 | __field(u32, metric) | ||
777 | __field(u32, exptime) | ||
778 | __field(u32, discovery_timeout) | ||
779 | __field(u8, discovery_retries) | ||
780 | __field(u8, flags) | ||
781 | ), | ||
782 | TP_fast_assign( | ||
783 | WIPHY_ASSIGN; | ||
784 | __entry->ret = ret; | ||
785 | __entry->generation = pinfo->generation; | ||
786 | __entry->filled = pinfo->filled; | ||
787 | __entry->frame_qlen = pinfo->frame_qlen; | ||
788 | __entry->sn = pinfo->sn; | ||
789 | __entry->metric = pinfo->metric; | ||
790 | __entry->exptime = pinfo->exptime; | ||
791 | __entry->discovery_timeout = pinfo->discovery_timeout; | ||
792 | __entry->discovery_retries = pinfo->discovery_retries; | ||
793 | __entry->flags = pinfo->flags; | ||
794 | ), | ||
795 | TP_printk(WIPHY_PR_FMT ", returned %d. mpath info - generation: %d, " | ||
796 | "filled: %u, frame qlen: %u, sn: %u, metric: %u, exptime: %u," | ||
797 | " discovery timeout: %u, discovery retries: %u, flags: %u", | ||
798 | WIPHY_PR_ARG, __entry->ret, __entry->generation, | ||
799 | __entry->filled, __entry->frame_qlen, __entry->sn, | ||
800 | __entry->metric, __entry->exptime, __entry->discovery_timeout, | ||
801 | __entry->discovery_retries, __entry->flags) | ||
802 | ); | ||
803 | |||
804 | TRACE_EVENT(rdev_return_int_mesh_config, | ||
805 | TP_PROTO(struct wiphy *wiphy, int ret, struct mesh_config *conf), | ||
806 | TP_ARGS(wiphy, ret, conf), | ||
807 | TP_STRUCT__entry( | ||
808 | WIPHY_ENTRY | ||
809 | MESH_CFG_ENTRY | ||
810 | __field(int, ret) | ||
811 | ), | ||
812 | TP_fast_assign( | ||
813 | WIPHY_ASSIGN; | ||
814 | MESH_CFG_ASSIGN; | ||
815 | __entry->ret = ret; | ||
816 | ), | ||
817 | TP_printk(WIPHY_PR_FMT ", returned: %d", | ||
818 | WIPHY_PR_ARG, __entry->ret) | ||
819 | ); | ||
820 | |||
821 | TRACE_EVENT(rdev_update_mesh_config, | ||
822 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 mask, | ||
823 | const struct mesh_config *conf), | ||
824 | TP_ARGS(wiphy, netdev, mask, conf), | ||
825 | TP_STRUCT__entry( | ||
826 | WIPHY_ENTRY | ||
827 | NETDEV_ENTRY | ||
828 | MESH_CFG_ENTRY | ||
829 | __field(u32, mask) | ||
830 | ), | ||
831 | TP_fast_assign( | ||
832 | WIPHY_ASSIGN; | ||
833 | NETDEV_ASSIGN; | ||
834 | MESH_CFG_ASSIGN; | ||
835 | __entry->mask = mask; | ||
836 | ), | ||
837 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", mask: %u", | ||
838 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->mask) | ||
839 | ); | ||
840 | |||
841 | TRACE_EVENT(rdev_join_mesh, | ||
842 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
843 | const struct mesh_config *conf, | ||
844 | const struct mesh_setup *setup), | ||
845 | TP_ARGS(wiphy, netdev, conf, setup), | ||
846 | TP_STRUCT__entry( | ||
847 | WIPHY_ENTRY | ||
848 | NETDEV_ENTRY | ||
849 | MESH_CFG_ENTRY | ||
850 | ), | ||
851 | TP_fast_assign( | ||
852 | WIPHY_ASSIGN; | ||
853 | NETDEV_ASSIGN; | ||
854 | MESH_CFG_ASSIGN; | ||
855 | ), | ||
856 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, | ||
857 | WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
858 | ); | ||
859 | |||
860 | TRACE_EVENT(rdev_change_bss, | ||
861 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
862 | struct bss_parameters *params), | ||
863 | TP_ARGS(wiphy, netdev, params), | ||
864 | TP_STRUCT__entry( | ||
865 | WIPHY_ENTRY | ||
866 | NETDEV_ENTRY | ||
867 | __field(int, use_cts_prot) | ||
868 | __field(int, use_short_preamble) | ||
869 | __field(int, use_short_slot_time) | ||
870 | __field(int, ap_isolate) | ||
871 | __field(int, ht_opmode) | ||
872 | ), | ||
873 | TP_fast_assign( | ||
874 | WIPHY_ASSIGN; | ||
875 | NETDEV_ASSIGN; | ||
876 | __entry->use_cts_prot = params->use_cts_prot; | ||
877 | __entry->use_short_preamble = params->use_short_preamble; | ||
878 | __entry->use_short_slot_time = params->use_short_slot_time; | ||
879 | __entry->ap_isolate = params->ap_isolate; | ||
880 | __entry->ht_opmode = params->ht_opmode; | ||
881 | ), | ||
882 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", use cts prot: %d, " | ||
883 | "use short preamble: %d, use short slot time: %d, " | ||
884 | "ap isolate: %d, ht opmode: %d", | ||
885 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->use_cts_prot, | ||
886 | __entry->use_short_preamble, __entry->use_short_slot_time, | ||
887 | __entry->ap_isolate, __entry->ht_opmode) | ||
888 | ); | ||
889 | |||
890 | TRACE_EVENT(rdev_set_txq_params, | ||
891 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
892 | struct ieee80211_txq_params *params), | ||
893 | TP_ARGS(wiphy, netdev, params), | ||
894 | TP_STRUCT__entry( | ||
895 | WIPHY_ENTRY | ||
896 | NETDEV_ENTRY | ||
897 | __field(enum nl80211_ac, ac) | ||
898 | __field(u16, txop) | ||
899 | __field(u16, cwmin) | ||
900 | __field(u16, cwmax) | ||
901 | __field(u8, aifs) | ||
902 | ), | ||
903 | TP_fast_assign( | ||
904 | WIPHY_ASSIGN; | ||
905 | NETDEV_ASSIGN; | ||
906 | __entry->ac = params->ac; | ||
907 | __entry->txop = params->txop; | ||
908 | __entry->cwmin = params->cwmin; | ||
909 | __entry->cwmax = params->cwmax; | ||
910 | __entry->aifs = params->aifs; | ||
911 | ), | ||
912 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", ac: %d, txop: %u, cwmin: %u, cwmax: %u, aifs: %u", | ||
913 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->ac, __entry->txop, | ||
914 | __entry->cwmin, __entry->cwmax, __entry->aifs) | ||
915 | ); | ||
916 | |||
917 | TRACE_EVENT(rdev_libertas_set_mesh_channel, | ||
918 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
919 | struct ieee80211_channel *chan), | ||
920 | TP_ARGS(wiphy, netdev, chan), | ||
921 | TP_STRUCT__entry( | ||
922 | WIPHY_ENTRY | ||
923 | NETDEV_ENTRY | ||
924 | CHAN_ENTRY | ||
925 | ), | ||
926 | TP_fast_assign( | ||
927 | WIPHY_ASSIGN; | ||
928 | NETDEV_ASSIGN; | ||
929 | CHAN_ASSIGN(chan); | ||
930 | ), | ||
931 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT CHAN_PR_FMT, WIPHY_PR_ARG, | ||
932 | NETDEV_PR_ARG, CHAN_PR_ARG) | ||
933 | ); | ||
934 | |||
935 | TRACE_EVENT(rdev_set_monitor_channel, | ||
936 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *chan, | ||
937 | enum nl80211_channel_type chan_type), | ||
938 | TP_ARGS(wiphy, chan, chan_type), | ||
939 | TP_STRUCT__entry( | ||
940 | WIPHY_ENTRY | ||
941 | CHAN_ENTRY | ||
942 | __field(enum nl80211_channel_type, chan_type) | ||
943 | ), | ||
944 | TP_fast_assign( | ||
945 | WIPHY_ASSIGN; | ||
946 | CHAN_ASSIGN(chan); | ||
947 | __entry->chan_type = chan_type; | ||
948 | ), | ||
949 | TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel type : %d", | ||
950 | WIPHY_PR_ARG, CHAN_PR_ARG, __entry->chan_type) | ||
951 | ); | ||
952 | |||
953 | TRACE_EVENT(rdev_auth, | ||
954 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
955 | struct cfg80211_auth_request *req), | ||
956 | TP_ARGS(wiphy, netdev, req), | ||
957 | TP_STRUCT__entry( | ||
958 | WIPHY_ENTRY | ||
959 | NETDEV_ENTRY | ||
960 | MAC_ENTRY(bssid) | ||
961 | __field(enum nl80211_auth_type, auth_type) | ||
962 | ), | ||
963 | TP_fast_assign( | ||
964 | WIPHY_ASSIGN; | ||
965 | NETDEV_ASSIGN; | ||
966 | if (req->bss) | ||
967 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
968 | else | ||
969 | memset(__entry->bssid, 0, ETH_ALEN); | ||
970 | __entry->auth_type = req->auth_type; | ||
971 | ), | ||
972 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", auth type: %d, bssid: " MAC_PR_FMT, | ||
973 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->auth_type, | ||
974 | MAC_PR_ARG(bssid)) | ||
975 | ); | ||
976 | |||
977 | TRACE_EVENT(rdev_assoc, | ||
978 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
979 | struct cfg80211_assoc_request *req), | ||
980 | TP_ARGS(wiphy, netdev, req), | ||
981 | TP_STRUCT__entry( | ||
982 | WIPHY_ENTRY | ||
983 | NETDEV_ENTRY | ||
984 | MAC_ENTRY(bssid) | ||
985 | MAC_ENTRY(prev_bssid) | ||
986 | __field(bool, use_mfp) | ||
987 | __field(u32, flags) | ||
988 | ), | ||
989 | TP_fast_assign( | ||
990 | WIPHY_ASSIGN; | ||
991 | NETDEV_ASSIGN; | ||
992 | if (req->bss) | ||
993 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
994 | else | ||
995 | memset(__entry->bssid, 0, ETH_ALEN); | ||
996 | MAC_ASSIGN(prev_bssid, req->prev_bssid); | ||
997 | __entry->use_mfp = req->use_mfp; | ||
998 | __entry->flags = req->flags; | ||
999 | ), | ||
1000 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1001 | ", previous bssid: " MAC_PR_FMT ", use mfp: %s, flags: %u", | ||
1002 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1003 | MAC_PR_ARG(prev_bssid), BOOL_TO_STR(__entry->use_mfp), | ||
1004 | __entry->flags) | ||
1005 | ); | ||
1006 | |||
1007 | TRACE_EVENT(rdev_deauth, | ||
1008 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1009 | struct cfg80211_deauth_request *req), | ||
1010 | TP_ARGS(wiphy, netdev, req), | ||
1011 | TP_STRUCT__entry( | ||
1012 | WIPHY_ENTRY | ||
1013 | NETDEV_ENTRY | ||
1014 | MAC_ENTRY(bssid) | ||
1015 | __field(u16, reason_code) | ||
1016 | ), | ||
1017 | TP_fast_assign( | ||
1018 | WIPHY_ASSIGN; | ||
1019 | NETDEV_ASSIGN; | ||
1020 | MAC_ASSIGN(bssid, req->bssid); | ||
1021 | __entry->reason_code = req->reason_code; | ||
1022 | ), | ||
1023 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", reason: %u", | ||
1024 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1025 | __entry->reason_code) | ||
1026 | ); | ||
1027 | |||
1028 | TRACE_EVENT(rdev_disassoc, | ||
1029 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1030 | struct cfg80211_disassoc_request *req), | ||
1031 | TP_ARGS(wiphy, netdev, req), | ||
1032 | TP_STRUCT__entry( | ||
1033 | WIPHY_ENTRY | ||
1034 | NETDEV_ENTRY | ||
1035 | MAC_ENTRY(bssid) | ||
1036 | __field(u16, reason_code) | ||
1037 | __field(bool, local_state_change) | ||
1038 | ), | ||
1039 | TP_fast_assign( | ||
1040 | WIPHY_ASSIGN; | ||
1041 | NETDEV_ASSIGN; | ||
1042 | if (req->bss) | ||
1043 | MAC_ASSIGN(bssid, req->bss->bssid); | ||
1044 | else | ||
1045 | memset(__entry->bssid, 0, ETH_ALEN); | ||
1046 | __entry->reason_code = req->reason_code; | ||
1047 | __entry->local_state_change = req->local_state_change; | ||
1048 | ), | ||
1049 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1050 | ", reason: %u, local state change: %s", | ||
1051 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), | ||
1052 | __entry->reason_code, | ||
1053 | BOOL_TO_STR(__entry->local_state_change)) | ||
1054 | ); | ||
1055 | |||
1056 | TRACE_EVENT(rdev_mgmt_tx_cancel_wait, | ||
1057 | TP_PROTO(struct wiphy *wiphy, | ||
1058 | struct wireless_dev *wdev, u64 cookie), | ||
1059 | TP_ARGS(wiphy, wdev, cookie), | ||
1060 | TP_STRUCT__entry( | ||
1061 | WIPHY_ENTRY | ||
1062 | WDEV_ENTRY | ||
1063 | __field(u64, cookie) | ||
1064 | ), | ||
1065 | TP_fast_assign( | ||
1066 | WIPHY_ASSIGN; | ||
1067 | WDEV_ASSIGN; | ||
1068 | __entry->cookie = cookie; | ||
1069 | ), | ||
1070 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", cookie: %llu ", | ||
1071 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie) | ||
1072 | ); | ||
1073 | |||
1074 | TRACE_EVENT(rdev_set_power_mgmt, | ||
1075 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1076 | bool enabled, int timeout), | ||
1077 | TP_ARGS(wiphy, netdev, enabled, timeout), | ||
1078 | TP_STRUCT__entry( | ||
1079 | WIPHY_ENTRY | ||
1080 | NETDEV_ENTRY | ||
1081 | __field(bool, enabled) | ||
1082 | __field(int, timeout) | ||
1083 | ), | ||
1084 | TP_fast_assign( | ||
1085 | WIPHY_ASSIGN; | ||
1086 | NETDEV_ASSIGN; | ||
1087 | __entry->enabled = enabled; | ||
1088 | __entry->timeout = timeout; | ||
1089 | ), | ||
1090 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", %senabled, timeout: %d ", | ||
1091 | WIPHY_PR_ARG, NETDEV_PR_ARG, | ||
1092 | __entry->enabled ? "" : "not ", __entry->timeout) | ||
1093 | ); | ||
1094 | |||
1095 | TRACE_EVENT(rdev_connect, | ||
1096 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1097 | struct cfg80211_connect_params *sme), | ||
1098 | TP_ARGS(wiphy, netdev, sme), | ||
1099 | TP_STRUCT__entry( | ||
1100 | WIPHY_ENTRY | ||
1101 | NETDEV_ENTRY | ||
1102 | MAC_ENTRY(bssid) | ||
1103 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
1104 | __field(enum nl80211_auth_type, auth_type) | ||
1105 | __field(bool, privacy) | ||
1106 | __field(u32, wpa_versions) | ||
1107 | __field(u32, flags) | ||
1108 | ), | ||
1109 | TP_fast_assign( | ||
1110 | WIPHY_ASSIGN; | ||
1111 | NETDEV_ASSIGN; | ||
1112 | MAC_ASSIGN(bssid, sme->bssid); | ||
1113 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
1114 | memcpy(__entry->ssid, sme->ssid, sme->ssid_len); | ||
1115 | __entry->auth_type = sme->auth_type; | ||
1116 | __entry->privacy = sme->privacy; | ||
1117 | __entry->wpa_versions = sme->crypto.wpa_versions; | ||
1118 | __entry->flags = sme->flags; | ||
1119 | ), | ||
1120 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT | ||
1121 | ", ssid: %s, auth type: %d, privacy: %s, wpa versions: %u, " | ||
1122 | "flags: %u", | ||
1123 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid, | ||
1124 | __entry->auth_type, BOOL_TO_STR(__entry->privacy), | ||
1125 | __entry->wpa_versions, __entry->flags) | ||
1126 | ); | ||
1127 | |||
1128 | TRACE_EVENT(rdev_set_cqm_rssi_config, | ||
1129 | TP_PROTO(struct wiphy *wiphy, | ||
1130 | struct net_device *netdev, s32 rssi_thold, | ||
1131 | u32 rssi_hyst), | ||
1132 | TP_ARGS(wiphy, netdev, rssi_thold, rssi_hyst), | ||
1133 | TP_STRUCT__entry( | ||
1134 | WIPHY_ENTRY | ||
1135 | NETDEV_ENTRY | ||
1136 | __field(s32, rssi_thold) | ||
1137 | __field(u32, rssi_hyst) | ||
1138 | ), | ||
1139 | TP_fast_assign( | ||
1140 | WIPHY_ASSIGN; | ||
1141 | NETDEV_ASSIGN; | ||
1142 | __entry->rssi_thold = rssi_thold; | ||
1143 | __entry->rssi_hyst = rssi_hyst; | ||
1144 | ), | ||
1145 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT | ||
1146 | ", rssi_thold: %d, rssi_hyst: %u ", | ||
1147 | WIPHY_PR_ARG, NETDEV_PR_ARG, | ||
1148 | __entry->rssi_thold, __entry->rssi_hyst) | ||
1149 | ); | ||
1150 | |||
1151 | TRACE_EVENT(rdev_set_cqm_txe_config, | ||
1152 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 rate, | ||
1153 | u32 pkts, u32 intvl), | ||
1154 | TP_ARGS(wiphy, netdev, rate, pkts, intvl), | ||
1155 | TP_STRUCT__entry( | ||
1156 | WIPHY_ENTRY | ||
1157 | NETDEV_ENTRY | ||
1158 | __field(u32, rate) | ||
1159 | __field(u32, pkts) | ||
1160 | __field(u32, intvl) | ||
1161 | ), | ||
1162 | TP_fast_assign( | ||
1163 | WIPHY_ASSIGN; | ||
1164 | NETDEV_ASSIGN; | ||
1165 | __entry->rate = rate; | ||
1166 | __entry->pkts = pkts; | ||
1167 | __entry->intvl = intvl; | ||
1168 | ), | ||
1169 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", rate: %u, packets: %u, interval: %u", | ||
1170 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->rate, __entry->pkts, | ||
1171 | __entry->intvl) | ||
1172 | ); | ||
1173 | |||
1174 | TRACE_EVENT(rdev_disconnect, | ||
1175 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1176 | u16 reason_code), | ||
1177 | TP_ARGS(wiphy, netdev, reason_code), | ||
1178 | TP_STRUCT__entry( | ||
1179 | WIPHY_ENTRY | ||
1180 | NETDEV_ENTRY | ||
1181 | __field(u16, reason_code) | ||
1182 | ), | ||
1183 | TP_fast_assign( | ||
1184 | WIPHY_ASSIGN; | ||
1185 | NETDEV_ASSIGN; | ||
1186 | __entry->reason_code = reason_code; | ||
1187 | ), | ||
1188 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", reason code: %u", WIPHY_PR_ARG, | ||
1189 | NETDEV_PR_ARG, __entry->reason_code) | ||
1190 | ); | ||
1191 | |||
1192 | TRACE_EVENT(rdev_join_ibss, | ||
1193 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1194 | struct cfg80211_ibss_params *params), | ||
1195 | TP_ARGS(wiphy, netdev, params), | ||
1196 | TP_STRUCT__entry( | ||
1197 | WIPHY_ENTRY | ||
1198 | NETDEV_ENTRY | ||
1199 | MAC_ENTRY(bssid) | ||
1200 | __array(char, ssid, IEEE80211_MAX_SSID_LEN + 1) | ||
1201 | ), | ||
1202 | TP_fast_assign( | ||
1203 | WIPHY_ASSIGN; | ||
1204 | NETDEV_ASSIGN; | ||
1205 | MAC_ASSIGN(bssid, params->bssid); | ||
1206 | memset(__entry->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); | ||
1207 | memcpy(__entry->ssid, params->ssid, params->ssid_len); | ||
1208 | ), | ||
1209 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", ssid: %s", | ||
1210 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid), __entry->ssid) | ||
1211 | ); | ||
1212 | |||
1213 | TRACE_EVENT(rdev_set_wiphy_params, | ||
1214 | TP_PROTO(struct wiphy *wiphy, u32 changed), | ||
1215 | TP_ARGS(wiphy, changed), | ||
1216 | TP_STRUCT__entry( | ||
1217 | WIPHY_ENTRY | ||
1218 | __field(u32, changed) | ||
1219 | ), | ||
1220 | TP_fast_assign( | ||
1221 | WIPHY_ASSIGN; | ||
1222 | __entry->changed = changed; | ||
1223 | ), | ||
1224 | TP_printk(WIPHY_PR_FMT ", changed: %u", | ||
1225 | WIPHY_PR_ARG, __entry->changed) | ||
1226 | ); | ||
1227 | |||
1228 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_tx_power, | ||
1229 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1230 | TP_ARGS(wiphy, wdev) | ||
1231 | ); | ||
1232 | |||
1233 | TRACE_EVENT(rdev_set_tx_power, | ||
1234 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1235 | enum nl80211_tx_power_setting type, int mbm), | ||
1236 | TP_ARGS(wiphy, wdev, type, mbm), | ||
1237 | TP_STRUCT__entry( | ||
1238 | WIPHY_ENTRY | ||
1239 | WDEV_ENTRY | ||
1240 | __field(enum nl80211_tx_power_setting, type) | ||
1241 | __field(int, mbm) | ||
1242 | ), | ||
1243 | TP_fast_assign( | ||
1244 | WIPHY_ASSIGN; | ||
1245 | WDEV_ASSIGN; | ||
1246 | __entry->type = type; | ||
1247 | __entry->mbm = mbm; | ||
1248 | ), | ||
1249 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", type: %d, mbm: %d", | ||
1250 | WIPHY_PR_ARG, WDEV_PR_ARG,__entry->type, __entry->mbm) | ||
1251 | ); | ||
1252 | |||
1253 | TRACE_EVENT(rdev_return_int_int, | ||
1254 | TP_PROTO(struct wiphy *wiphy, int func_ret, int func_fill), | ||
1255 | TP_ARGS(wiphy, func_ret, func_fill), | ||
1256 | TP_STRUCT__entry( | ||
1257 | WIPHY_ENTRY | ||
1258 | __field(int, func_ret) | ||
1259 | __field(int, func_fill) | ||
1260 | ), | ||
1261 | TP_fast_assign( | ||
1262 | WIPHY_ASSIGN; | ||
1263 | __entry->func_ret = func_ret; | ||
1264 | __entry->func_fill = func_fill; | ||
1265 | ), | ||
1266 | TP_printk(WIPHY_PR_FMT ", function returns: %d, function filled: %d", | ||
1267 | WIPHY_PR_ARG, __entry->func_ret, __entry->func_fill) | ||
1268 | ); | ||
1269 | |||
1270 | #ifdef CONFIG_NL80211_TESTMODE | ||
1271 | TRACE_EVENT(rdev_testmode_cmd, | ||
1272 | TP_PROTO(struct wiphy *wiphy), | ||
1273 | TP_ARGS(wiphy), | ||
1274 | TP_STRUCT__entry( | ||
1275 | WIPHY_ENTRY | ||
1276 | ), | ||
1277 | TP_fast_assign( | ||
1278 | WIPHY_ASSIGN; | ||
1279 | ), | ||
1280 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
1281 | ); | ||
1282 | |||
1283 | TRACE_EVENT(rdev_testmode_dump, | ||
1284 | TP_PROTO(struct wiphy *wiphy), | ||
1285 | TP_ARGS(wiphy), | ||
1286 | TP_STRUCT__entry( | ||
1287 | WIPHY_ENTRY | ||
1288 | ), | ||
1289 | TP_fast_assign( | ||
1290 | WIPHY_ASSIGN; | ||
1291 | ), | ||
1292 | TP_printk(WIPHY_PR_FMT, WIPHY_PR_ARG) | ||
1293 | ); | ||
1294 | #endif /* CONFIG_NL80211_TESTMODE */ | ||
1295 | |||
1296 | TRACE_EVENT(rdev_set_bitrate_mask, | ||
1297 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1298 | const u8 *peer, const struct cfg80211_bitrate_mask *mask), | ||
1299 | TP_ARGS(wiphy, netdev, peer, mask), | ||
1300 | TP_STRUCT__entry( | ||
1301 | WIPHY_ENTRY | ||
1302 | NETDEV_ENTRY | ||
1303 | MAC_ENTRY(peer) | ||
1304 | ), | ||
1305 | TP_fast_assign( | ||
1306 | WIPHY_ASSIGN; | ||
1307 | NETDEV_ASSIGN; | ||
1308 | MAC_ASSIGN(peer, peer); | ||
1309 | ), | ||
1310 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", peer: " MAC_PR_FMT, | ||
1311 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer)) | ||
1312 | ); | ||
1313 | |||
1314 | TRACE_EVENT(rdev_mgmt_frame_register, | ||
1315 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1316 | u16 frame_type, bool reg), | ||
1317 | TP_ARGS(wiphy, wdev, frame_type, reg), | ||
1318 | TP_STRUCT__entry( | ||
1319 | WIPHY_ENTRY | ||
1320 | WDEV_ENTRY | ||
1321 | __field(u16, frame_type) | ||
1322 | __field(bool, reg) | ||
1323 | ), | ||
1324 | TP_fast_assign( | ||
1325 | WIPHY_ASSIGN; | ||
1326 | WDEV_ASSIGN; | ||
1327 | __entry->frame_type = frame_type; | ||
1328 | __entry->reg = reg; | ||
1329 | ), | ||
1330 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", frame_type: %u, reg: %s ", | ||
1331 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->frame_type, | ||
1332 | __entry->reg ? "true" : "false") | ||
1333 | ); | ||
1334 | |||
1335 | TRACE_EVENT(rdev_return_int_tx_rx, | ||
1336 | TP_PROTO(struct wiphy *wiphy, int ret, u32 tx, u32 rx), | ||
1337 | TP_ARGS(wiphy, ret, tx, rx), | ||
1338 | TP_STRUCT__entry( | ||
1339 | WIPHY_ENTRY | ||
1340 | __field(int, ret) | ||
1341 | __field(u32, tx) | ||
1342 | __field(u32, rx) | ||
1343 | ), | ||
1344 | TP_fast_assign( | ||
1345 | WIPHY_ASSIGN; | ||
1346 | __entry->ret = ret; | ||
1347 | __entry->tx = tx; | ||
1348 | __entry->rx = rx; | ||
1349 | ), | ||
1350 | TP_printk(WIPHY_PR_FMT ", returned %d, tx: %u, rx: %u", | ||
1351 | WIPHY_PR_ARG, __entry->ret, __entry->tx, __entry->rx) | ||
1352 | ); | ||
1353 | |||
1354 | TRACE_EVENT(rdev_return_void_tx_rx, | ||
1355 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 tx_max, | ||
1356 | u32 rx, u32 rx_max), | ||
1357 | TP_ARGS(wiphy, tx, tx_max, rx, rx_max), | ||
1358 | TP_STRUCT__entry( | ||
1359 | WIPHY_ENTRY | ||
1360 | __field(u32, tx) | ||
1361 | __field(u32, tx_max) | ||
1362 | __field(u32, rx) | ||
1363 | __field(u32, rx_max) | ||
1364 | ), | ||
1365 | TP_fast_assign( | ||
1366 | WIPHY_ASSIGN; | ||
1367 | __entry->tx = tx; | ||
1368 | __entry->tx_max = tx_max; | ||
1369 | __entry->rx = rx; | ||
1370 | __entry->rx_max = rx_max; | ||
1371 | ), | ||
1372 | TP_printk(WIPHY_PR_FMT ", tx: %u, tx_max: %u, rx: %u, rx_max: %u ", | ||
1373 | WIPHY_PR_ARG, __entry->tx, __entry->tx_max, __entry->rx, | ||
1374 | __entry->rx_max) | ||
1375 | ); | ||
1376 | |||
1377 | DECLARE_EVENT_CLASS(tx_rx_evt, | ||
1378 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1379 | TP_ARGS(wiphy, rx, tx), | ||
1380 | TP_STRUCT__entry( | ||
1381 | WIPHY_ENTRY | ||
1382 | __field(u32, tx) | ||
1383 | __field(u32, rx) | ||
1384 | ), | ||
1385 | TP_fast_assign( | ||
1386 | WIPHY_ASSIGN; | ||
1387 | __entry->tx = tx; | ||
1388 | __entry->rx = rx; | ||
1389 | ), | ||
1390 | TP_printk(WIPHY_PR_FMT ", tx: %u, rx: %u ", | ||
1391 | WIPHY_PR_ARG, __entry->tx, __entry->rx) | ||
1392 | ); | ||
1393 | |||
1394 | DEFINE_EVENT(tx_rx_evt, rdev_set_ringparam, | ||
1395 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1396 | TP_ARGS(wiphy, rx, tx) | ||
1397 | ); | ||
1398 | |||
1399 | DEFINE_EVENT(tx_rx_evt, rdev_set_antenna, | ||
1400 | TP_PROTO(struct wiphy *wiphy, u32 tx, u32 rx), | ||
1401 | TP_ARGS(wiphy, rx, tx) | ||
1402 | ); | ||
1403 | |||
1404 | TRACE_EVENT(rdev_sched_scan_start, | ||
1405 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1406 | struct cfg80211_sched_scan_request *request), | ||
1407 | TP_ARGS(wiphy, netdev, request), | ||
1408 | TP_STRUCT__entry( | ||
1409 | WIPHY_ENTRY | ||
1410 | NETDEV_ENTRY | ||
1411 | ), | ||
1412 | TP_fast_assign( | ||
1413 | WIPHY_ASSIGN; | ||
1414 | NETDEV_ASSIGN; | ||
1415 | ), | ||
1416 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT, | ||
1417 | WIPHY_PR_ARG, NETDEV_PR_ARG) | ||
1418 | ); | ||
1419 | |||
1420 | TRACE_EVENT(rdev_tdls_mgmt, | ||
1421 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1422 | u8 *peer, u8 action_code, u8 dialog_token, | ||
1423 | u16 status_code, const u8 *buf, size_t len), | ||
1424 | TP_ARGS(wiphy, netdev, peer, action_code, dialog_token, status_code, | ||
1425 | buf, len), | ||
1426 | TP_STRUCT__entry( | ||
1427 | WIPHY_ENTRY | ||
1428 | NETDEV_ENTRY | ||
1429 | MAC_ENTRY(peer) | ||
1430 | __field(u8, action_code) | ||
1431 | __field(u8, dialog_token) | ||
1432 | __field(u16, status_code) | ||
1433 | __dynamic_array(u8, buf, len) | ||
1434 | ), | ||
1435 | TP_fast_assign( | ||
1436 | WIPHY_ASSIGN; | ||
1437 | NETDEV_ASSIGN; | ||
1438 | MAC_ASSIGN(peer, peer); | ||
1439 | __entry->action_code = action_code; | ||
1440 | __entry->dialog_token = dialog_token; | ||
1441 | __entry->status_code = status_code; | ||
1442 | memcpy(__get_dynamic_array(buf), buf, len); | ||
1443 | ), | ||
1444 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT ", action_code: %u, " | ||
1445 | "dialog_token: %u, status_code: %u, buf: %#.2x ", | ||
1446 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), | ||
1447 | __entry->action_code, __entry->dialog_token, | ||
1448 | __entry->status_code, ((u8 *)__get_dynamic_array(buf))[0]) | ||
1449 | ); | ||
1450 | |||
1451 | TRACE_EVENT(rdev_dump_survey, | ||
1452 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int idx), | ||
1453 | TP_ARGS(wiphy, netdev, idx), | ||
1454 | TP_STRUCT__entry( | ||
1455 | WIPHY_ENTRY | ||
1456 | NETDEV_ENTRY | ||
1457 | __field(int, idx) | ||
1458 | ), | ||
1459 | TP_fast_assign( | ||
1460 | WIPHY_ASSIGN; | ||
1461 | NETDEV_ASSIGN; | ||
1462 | __entry->idx = idx; | ||
1463 | ), | ||
1464 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", index: %d", | ||
1465 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->idx) | ||
1466 | ); | ||
1467 | |||
1468 | TRACE_EVENT(rdev_return_int_survey_info, | ||
1469 | TP_PROTO(struct wiphy *wiphy, int ret, struct survey_info *info), | ||
1470 | TP_ARGS(wiphy, ret, info), | ||
1471 | TP_STRUCT__entry( | ||
1472 | WIPHY_ENTRY | ||
1473 | CHAN_ENTRY | ||
1474 | __field(int, ret) | ||
1475 | __field(u64, channel_time) | ||
1476 | __field(u64, channel_time_busy) | ||
1477 | __field(u64, channel_time_ext_busy) | ||
1478 | __field(u64, channel_time_rx) | ||
1479 | __field(u64, channel_time_tx) | ||
1480 | __field(u32, filled) | ||
1481 | __field(s8, noise) | ||
1482 | ), | ||
1483 | TP_fast_assign( | ||
1484 | WIPHY_ASSIGN; | ||
1485 | CHAN_ASSIGN(info->channel); | ||
1486 | __entry->ret = ret; | ||
1487 | __entry->channel_time = info->channel_time; | ||
1488 | __entry->channel_time_busy = info->channel_time_busy; | ||
1489 | __entry->channel_time_ext_busy = info->channel_time_ext_busy; | ||
1490 | __entry->channel_time_rx = info->channel_time_rx; | ||
1491 | __entry->channel_time_tx = info->channel_time_tx; | ||
1492 | __entry->filled = info->filled; | ||
1493 | __entry->noise = info->noise; | ||
1494 | ), | ||
1495 | TP_printk(WIPHY_PR_FMT ", returned: %d, " CHAN_PR_FMT | ||
1496 | ", channel time: %llu, channel time busy: %llu, " | ||
1497 | "channel time extension busy: %llu, channel time rx: %llu, " | ||
1498 | "channel time tx: %llu, filled: %u, noise: %d", | ||
1499 | WIPHY_PR_ARG, __entry->ret, CHAN_PR_ARG, | ||
1500 | __entry->channel_time, __entry->channel_time_busy, | ||
1501 | __entry->channel_time_ext_busy, __entry->channel_time_rx, | ||
1502 | __entry->channel_time_tx, __entry->filled, __entry->noise) | ||
1503 | ); | ||
1504 | |||
1505 | TRACE_EVENT(rdev_tdls_oper, | ||
1506 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1507 | u8 *peer, enum nl80211_tdls_operation oper), | ||
1508 | TP_ARGS(wiphy, netdev, peer, oper), | ||
1509 | TP_STRUCT__entry( | ||
1510 | WIPHY_ENTRY | ||
1511 | NETDEV_ENTRY | ||
1512 | MAC_ENTRY(peer) | ||
1513 | __field(enum nl80211_tdls_operation, oper) | ||
1514 | ), | ||
1515 | TP_fast_assign( | ||
1516 | WIPHY_ASSIGN; | ||
1517 | NETDEV_ASSIGN; | ||
1518 | MAC_ASSIGN(peer, peer); | ||
1519 | __entry->oper = oper; | ||
1520 | ), | ||
1521 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT ", oper: %d", | ||
1522 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->oper) | ||
1523 | ); | ||
1524 | |||
1525 | DECLARE_EVENT_CLASS(rdev_pmksa, | ||
1526 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1527 | struct cfg80211_pmksa *pmksa), | ||
1528 | TP_ARGS(wiphy, netdev, pmksa), | ||
1529 | TP_STRUCT__entry( | ||
1530 | WIPHY_ENTRY | ||
1531 | NETDEV_ENTRY | ||
1532 | MAC_ENTRY(bssid) | ||
1533 | ), | ||
1534 | TP_fast_assign( | ||
1535 | WIPHY_ASSIGN; | ||
1536 | NETDEV_ASSIGN; | ||
1537 | MAC_ASSIGN(bssid, pmksa->bssid); | ||
1538 | ), | ||
1539 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", bssid: " MAC_PR_FMT, | ||
1540 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(bssid)) | ||
1541 | ); | ||
1542 | |||
1543 | TRACE_EVENT(rdev_probe_client, | ||
1544 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1545 | const u8 *peer), | ||
1546 | TP_ARGS(wiphy, netdev, peer), | ||
1547 | TP_STRUCT__entry( | ||
1548 | WIPHY_ENTRY | ||
1549 | NETDEV_ENTRY | ||
1550 | MAC_ENTRY(peer) | ||
1551 | ), | ||
1552 | TP_fast_assign( | ||
1553 | WIPHY_ASSIGN; | ||
1554 | NETDEV_ASSIGN; | ||
1555 | MAC_ASSIGN(peer, peer); | ||
1556 | ), | ||
1557 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT MAC_PR_FMT, | ||
1558 | WIPHY_PR_ARG, NETDEV_PR_ARG, MAC_PR_ARG(peer)) | ||
1559 | ); | ||
1560 | |||
1561 | DEFINE_EVENT(rdev_pmksa, rdev_set_pmksa, | ||
1562 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1563 | struct cfg80211_pmksa *pmksa), | ||
1564 | TP_ARGS(wiphy, netdev, pmksa) | ||
1565 | ); | ||
1566 | |||
1567 | DEFINE_EVENT(rdev_pmksa, rdev_del_pmksa, | ||
1568 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1569 | struct cfg80211_pmksa *pmksa), | ||
1570 | TP_ARGS(wiphy, netdev, pmksa) | ||
1571 | ); | ||
1572 | |||
1573 | TRACE_EVENT(rdev_remain_on_channel, | ||
1574 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1575 | struct ieee80211_channel *chan, | ||
1576 | enum nl80211_channel_type channel_type, unsigned int duration), | ||
1577 | TP_ARGS(wiphy, wdev, chan, channel_type, duration), | ||
1578 | TP_STRUCT__entry( | ||
1579 | WIPHY_ENTRY | ||
1580 | WDEV_ENTRY | ||
1581 | CHAN_ENTRY | ||
1582 | __field(enum nl80211_channel_type, channel_type) | ||
1583 | __field(unsigned int, duration) | ||
1584 | ), | ||
1585 | TP_fast_assign( | ||
1586 | WIPHY_ASSIGN; | ||
1587 | WDEV_ASSIGN; | ||
1588 | CHAN_ASSIGN(chan); | ||
1589 | __entry->channel_type = channel_type; | ||
1590 | __entry->duration = duration; | ||
1591 | ), | ||
1592 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT CHAN_PR_FMT ", channel type: %d, duration: %u", | ||
1593 | WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG, __entry->channel_type, | ||
1594 | __entry->duration) | ||
1595 | ); | ||
1596 | |||
1597 | TRACE_EVENT(rdev_return_int_cookie, | ||
1598 | TP_PROTO(struct wiphy *wiphy, int ret, u64 cookie), | ||
1599 | TP_ARGS(wiphy, ret, cookie), | ||
1600 | TP_STRUCT__entry( | ||
1601 | WIPHY_ENTRY | ||
1602 | __field(int, ret) | ||
1603 | __field(u64, cookie) | ||
1604 | ), | ||
1605 | TP_fast_assign( | ||
1606 | WIPHY_ASSIGN; | ||
1607 | __entry->ret = ret; | ||
1608 | __entry->cookie = cookie; | ||
1609 | ), | ||
1610 | TP_printk(WIPHY_PR_FMT ", returned %d, cookie: %llu", | ||
1611 | WIPHY_PR_ARG, __entry->ret, __entry->cookie) | ||
1612 | ); | ||
1613 | |||
1614 | TRACE_EVENT(rdev_cancel_remain_on_channel, | ||
1615 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie), | ||
1616 | TP_ARGS(wiphy, wdev, cookie), | ||
1617 | TP_STRUCT__entry( | ||
1618 | WIPHY_ENTRY | ||
1619 | WDEV_ENTRY | ||
1620 | __field(u64, cookie) | ||
1621 | ), | ||
1622 | TP_fast_assign( | ||
1623 | WIPHY_ASSIGN; | ||
1624 | WDEV_ASSIGN; | ||
1625 | __entry->cookie = cookie; | ||
1626 | ), | ||
1627 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT ", cookie: %llu", | ||
1628 | WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie) | ||
1629 | ); | ||
1630 | |||
1631 | TRACE_EVENT(rdev_mgmt_tx, | ||
1632 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev, | ||
1633 | struct ieee80211_channel *chan, bool offchan, | ||
1634 | enum nl80211_channel_type channel_type, | ||
1635 | bool channel_type_valid, unsigned int wait, bool no_cck, | ||
1636 | bool dont_wait_for_ack), | ||
1637 | TP_ARGS(wiphy, wdev, chan, offchan, channel_type, channel_type_valid, | ||
1638 | wait, no_cck, dont_wait_for_ack), | ||
1639 | TP_STRUCT__entry( | ||
1640 | WIPHY_ENTRY | ||
1641 | WDEV_ENTRY | ||
1642 | CHAN_ENTRY | ||
1643 | __field(bool, offchan) | ||
1644 | __field(enum nl80211_channel_type, channel_type) | ||
1645 | __field(bool, channel_type_valid) | ||
1646 | __field(unsigned int, wait) | ||
1647 | __field(bool, no_cck) | ||
1648 | __field(bool, dont_wait_for_ack) | ||
1649 | ), | ||
1650 | TP_fast_assign( | ||
1651 | WIPHY_ASSIGN; | ||
1652 | WDEV_ASSIGN; | ||
1653 | CHAN_ASSIGN(chan); | ||
1654 | __entry->offchan = offchan; | ||
1655 | __entry->channel_type = channel_type; | ||
1656 | __entry->channel_type_valid = channel_type_valid; | ||
1657 | __entry->wait = wait; | ||
1658 | __entry->no_cck = no_cck; | ||
1659 | __entry->dont_wait_for_ack = dont_wait_for_ack; | ||
1660 | ), | ||
1661 | TP_printk(WIPHY_PR_FMT WDEV_PR_FMT CHAN_PR_FMT ", offchan: %s, " | ||
1662 | "channel type: %d, channel type valid: %s, wait: %u, " | ||
1663 | "no cck: %s, dont wait for ack: %s", | ||
1664 | WIPHY_PR_ARG, WDEV_PR_ARG, CHAN_PR_ARG, | ||
1665 | BOOL_TO_STR(__entry->offchan), __entry->channel_type, | ||
1666 | BOOL_TO_STR(__entry->channel_type_valid), __entry->wait, | ||
1667 | BOOL_TO_STR(__entry->no_cck), | ||
1668 | BOOL_TO_STR(__entry->dont_wait_for_ack)) | ||
1669 | ); | ||
1670 | |||
1671 | TRACE_EVENT(rdev_set_noack_map, | ||
1672 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, | ||
1673 | u16 noack_map), | ||
1674 | TP_ARGS(wiphy, netdev, noack_map), | ||
1675 | TP_STRUCT__entry( | ||
1676 | WIPHY_ENTRY | ||
1677 | NETDEV_ENTRY | ||
1678 | __field(u16, noack_map) | ||
1679 | ), | ||
1680 | TP_fast_assign( | ||
1681 | WIPHY_ASSIGN; | ||
1682 | NETDEV_ASSIGN; | ||
1683 | __entry->noack_map = noack_map; | ||
1684 | ), | ||
1685 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", noack_map: %u", | ||
1686 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->noack_map) | ||
1687 | ); | ||
1688 | |||
1689 | TRACE_EVENT(rdev_get_et_sset_count, | ||
1690 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, int sset), | ||
1691 | TP_ARGS(wiphy, netdev, sset), | ||
1692 | TP_STRUCT__entry( | ||
1693 | WIPHY_ENTRY | ||
1694 | NETDEV_ENTRY | ||
1695 | __field(int, sset) | ||
1696 | ), | ||
1697 | TP_fast_assign( | ||
1698 | WIPHY_ASSIGN; | ||
1699 | NETDEV_ASSIGN; | ||
1700 | __entry->sset = sset; | ||
1701 | ), | ||
1702 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", sset: %d", | ||
1703 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1704 | ); | ||
1705 | |||
1706 | TRACE_EVENT(rdev_get_et_strings, | ||
1707 | TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u32 sset), | ||
1708 | TP_ARGS(wiphy, netdev, sset), | ||
1709 | TP_STRUCT__entry( | ||
1710 | WIPHY_ENTRY | ||
1711 | NETDEV_ENTRY | ||
1712 | __field(u32, sset) | ||
1713 | ), | ||
1714 | TP_fast_assign( | ||
1715 | WIPHY_ASSIGN; | ||
1716 | NETDEV_ASSIGN; | ||
1717 | __entry->sset = sset; | ||
1718 | ), | ||
1719 | TP_printk(WIPHY_PR_FMT NETDEV_PR_FMT ", sset: %u", | ||
1720 | WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->sset) | ||
1721 | ); | ||
1722 | |||
1723 | DEFINE_EVENT(wiphy_wdev_evt, rdev_get_channel, | ||
1724 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1725 | TP_ARGS(wiphy, wdev) | ||
1726 | ); | ||
1727 | |||
1728 | TRACE_EVENT(rdev_return_channel, | ||
1729 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *chan, | ||
1730 | enum nl80211_channel_type type), | ||
1731 | TP_ARGS(wiphy, chan, type), | ||
1732 | TP_STRUCT__entry( | ||
1733 | WIPHY_ENTRY | ||
1734 | CHAN_ENTRY | ||
1735 | __field(enum nl80211_channel_type, type) | ||
1736 | ), | ||
1737 | TP_fast_assign( | ||
1738 | WIPHY_ASSIGN; | ||
1739 | CHAN_ASSIGN(chan); | ||
1740 | __entry->type = type; | ||
1741 | ), | ||
1742 | TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel type: %d", | ||
1743 | WIPHY_PR_ARG, CHAN_PR_ARG, __entry->type) | ||
1744 | ); | ||
1745 | |||
1746 | DEFINE_EVENT(wiphy_wdev_evt, rdev_start_p2p_device, | ||
1747 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1748 | TP_ARGS(wiphy, wdev) | ||
1749 | ); | ||
1750 | |||
1751 | DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_p2p_device, | ||
1752 | TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev), | ||
1753 | TP_ARGS(wiphy, wdev) | ||
1754 | ); | ||
1755 | |||
1756 | /************************************************************* | ||
1757 | * cfg80211 exported functions traces * | ||
1758 | *************************************************************/ | ||
1759 | |||
1760 | TRACE_EVENT(cfg80211_return_bool, | ||
1761 | TP_PROTO(bool ret), | ||
1762 | TP_ARGS(ret), | ||
1763 | TP_STRUCT__entry( | ||
1764 | __field(bool, ret) | ||
1765 | ), | ||
1766 | TP_fast_assign( | ||
1767 | __entry->ret = ret; | ||
1768 | ), | ||
1769 | TP_printk("returned %s", BOOL_TO_STR(__entry->ret)) | ||
1770 | ); | ||
1771 | |||
1772 | DECLARE_EVENT_CLASS(cfg80211_netdev_mac_evt, | ||
1773 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1774 | TP_ARGS(netdev, macaddr), | ||
1775 | TP_STRUCT__entry( | ||
1776 | NETDEV_ENTRY | ||
1777 | MAC_ENTRY(macaddr) | ||
1778 | ), | ||
1779 | TP_fast_assign( | ||
1780 | NETDEV_ASSIGN; | ||
1781 | MAC_ASSIGN(macaddr, macaddr); | ||
1782 | ), | ||
1783 | TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
1784 | NETDEV_PR_ARG, MAC_PR_ARG(macaddr)) | ||
1785 | ); | ||
1786 | |||
1787 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_notify_new_peer_candidate, | ||
1788 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1789 | TP_ARGS(netdev, macaddr) | ||
1790 | ); | ||
1791 | |||
1792 | DECLARE_EVENT_CLASS(netdev_evt_only, | ||
1793 | TP_PROTO(struct net_device *netdev), | ||
1794 | TP_ARGS(netdev), | ||
1795 | TP_STRUCT__entry( | ||
1796 | NETDEV_ENTRY | ||
1797 | ), | ||
1798 | TP_fast_assign( | ||
1799 | NETDEV_ASSIGN; | ||
1800 | ), | ||
1801 | TP_printk(NETDEV_PR_FMT , NETDEV_PR_ARG) | ||
1802 | ); | ||
1803 | |||
1804 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_rx_auth, | ||
1805 | TP_PROTO(struct net_device *netdev), | ||
1806 | TP_ARGS(netdev) | ||
1807 | ); | ||
1808 | |||
1809 | TRACE_EVENT(cfg80211_send_rx_assoc, | ||
1810 | TP_PROTO(struct net_device *netdev, struct cfg80211_bss *bss), | ||
1811 | TP_ARGS(netdev, bss), | ||
1812 | TP_STRUCT__entry( | ||
1813 | NETDEV_ENTRY | ||
1814 | MAC_ENTRY(bssid) | ||
1815 | CHAN_ENTRY | ||
1816 | ), | ||
1817 | TP_fast_assign( | ||
1818 | NETDEV_ASSIGN; | ||
1819 | MAC_ASSIGN(bssid, bss->bssid); | ||
1820 | CHAN_ASSIGN(bss->channel); | ||
1821 | ), | ||
1822 | TP_printk(NETDEV_PR_FMT MAC_PR_FMT CHAN_PR_FMT, | ||
1823 | NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG) | ||
1824 | ); | ||
1825 | |||
1826 | DEFINE_EVENT(netdev_evt_only, __cfg80211_send_deauth, | ||
1827 | TP_PROTO(struct net_device *netdev), | ||
1828 | TP_ARGS(netdev) | ||
1829 | ); | ||
1830 | |||
1831 | DEFINE_EVENT(netdev_evt_only, __cfg80211_send_disassoc, | ||
1832 | TP_PROTO(struct net_device *netdev), | ||
1833 | TP_ARGS(netdev) | ||
1834 | ); | ||
1835 | |||
1836 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_deauth, | ||
1837 | TP_PROTO(struct net_device *netdev), | ||
1838 | TP_ARGS(netdev) | ||
1839 | ); | ||
1840 | |||
1841 | DEFINE_EVENT(netdev_evt_only, cfg80211_send_unprot_disassoc, | ||
1842 | TP_PROTO(struct net_device *netdev), | ||
1843 | TP_ARGS(netdev) | ||
1844 | ); | ||
1845 | |||
1846 | DECLARE_EVENT_CLASS(netdev_mac_evt, | ||
1847 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1848 | TP_ARGS(netdev, mac), | ||
1849 | TP_STRUCT__entry( | ||
1850 | NETDEV_ENTRY | ||
1851 | MAC_ENTRY(mac) | ||
1852 | ), | ||
1853 | TP_fast_assign( | ||
1854 | NETDEV_ASSIGN; | ||
1855 | MAC_ASSIGN(mac, mac) | ||
1856 | ), | ||
1857 | TP_printk(NETDEV_PR_FMT ", mac: " MAC_PR_FMT, | ||
1858 | NETDEV_PR_ARG, MAC_PR_ARG(mac)) | ||
1859 | ); | ||
1860 | |||
1861 | DEFINE_EVENT(netdev_mac_evt, cfg80211_send_auth_timeout, | ||
1862 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1863 | TP_ARGS(netdev, mac) | ||
1864 | ); | ||
1865 | |||
1866 | DEFINE_EVENT(netdev_mac_evt, cfg80211_send_assoc_timeout, | ||
1867 | TP_PROTO(struct net_device *netdev, const u8 *mac), | ||
1868 | TP_ARGS(netdev, mac) | ||
1869 | ); | ||
1870 | |||
1871 | TRACE_EVENT(cfg80211_michael_mic_failure, | ||
1872 | TP_PROTO(struct net_device *netdev, const u8 *addr, | ||
1873 | enum nl80211_key_type key_type, int key_id, const u8 *tsc), | ||
1874 | TP_ARGS(netdev, addr, key_type, key_id, tsc), | ||
1875 | TP_STRUCT__entry( | ||
1876 | NETDEV_ENTRY | ||
1877 | MAC_ENTRY(addr) | ||
1878 | __field(enum nl80211_key_type, key_type) | ||
1879 | __field(int, key_id) | ||
1880 | __array(u8, tsc, 6) | ||
1881 | ), | ||
1882 | TP_fast_assign( | ||
1883 | NETDEV_ASSIGN; | ||
1884 | MAC_ASSIGN(addr, addr); | ||
1885 | __entry->key_type = key_type; | ||
1886 | __entry->key_id = key_id; | ||
1887 | memcpy(__entry->tsc, tsc, 6); | ||
1888 | ), | ||
1889 | TP_printk(NETDEV_PR_FMT MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm", | ||
1890 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type, | ||
1891 | __entry->key_id, __entry->tsc) | ||
1892 | ); | ||
1893 | |||
1894 | TRACE_EVENT(cfg80211_ready_on_channel, | ||
1895 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, | ||
1896 | struct ieee80211_channel *chan, | ||
1897 | enum nl80211_channel_type channel_type, unsigned int duration), | ||
1898 | TP_ARGS(wdev, cookie, chan, channel_type, duration), | ||
1899 | TP_STRUCT__entry( | ||
1900 | WDEV_ENTRY | ||
1901 | __field(u64, cookie) | ||
1902 | CHAN_ENTRY | ||
1903 | __field(enum nl80211_channel_type, channel_type) | ||
1904 | __field(unsigned int, duration) | ||
1905 | ), | ||
1906 | TP_fast_assign( | ||
1907 | WDEV_ASSIGN; | ||
1908 | __entry->cookie = cookie; | ||
1909 | CHAN_ASSIGN(chan); | ||
1910 | __entry->channel_type = channel_type; | ||
1911 | __entry->duration = duration; | ||
1912 | ), | ||
1913 | TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT ", channel type: %d, duration: %u", | ||
1914 | WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG, | ||
1915 | __entry->channel_type, __entry->duration) | ||
1916 | ); | ||
1917 | |||
1918 | TRACE_EVENT(cfg80211_ready_on_channel_expired, | ||
1919 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, | ||
1920 | struct ieee80211_channel *chan, | ||
1921 | enum nl80211_channel_type channel_type), | ||
1922 | TP_ARGS(wdev, cookie, chan, channel_type), | ||
1923 | TP_STRUCT__entry( | ||
1924 | WDEV_ENTRY | ||
1925 | __field(u64, cookie) | ||
1926 | CHAN_ENTRY | ||
1927 | __field(enum nl80211_channel_type, channel_type) | ||
1928 | ), | ||
1929 | TP_fast_assign( | ||
1930 | WDEV_ASSIGN; | ||
1931 | __entry->cookie = cookie; | ||
1932 | CHAN_ASSIGN(chan); | ||
1933 | __entry->channel_type = channel_type; | ||
1934 | ), | ||
1935 | TP_printk(WDEV_PR_FMT ", cookie: %llu, " CHAN_PR_FMT ", channel type: %d", | ||
1936 | WDEV_PR_ARG, __entry->cookie, CHAN_PR_ARG, | ||
1937 | __entry->channel_type) | ||
1938 | ); | ||
1939 | |||
1940 | TRACE_EVENT(cfg80211_new_sta, | ||
1941 | TP_PROTO(struct net_device *netdev, const u8 *mac_addr, | ||
1942 | struct station_info *sinfo), | ||
1943 | TP_ARGS(netdev, mac_addr, sinfo), | ||
1944 | TP_STRUCT__entry( | ||
1945 | NETDEV_ENTRY | ||
1946 | MAC_ENTRY(mac_addr) | ||
1947 | SINFO_ENTRY | ||
1948 | ), | ||
1949 | TP_fast_assign( | ||
1950 | NETDEV_ASSIGN; | ||
1951 | MAC_ASSIGN(mac_addr, mac_addr); | ||
1952 | SINFO_ASSIGN; | ||
1953 | ), | ||
1954 | TP_printk(NETDEV_PR_FMT MAC_PR_FMT, | ||
1955 | NETDEV_PR_ARG, MAC_PR_ARG(mac_addr)) | ||
1956 | ); | ||
1957 | |||
1958 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_del_sta, | ||
1959 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
1960 | TP_ARGS(netdev, macaddr) | ||
1961 | ); | ||
1962 | |||
1963 | TRACE_EVENT(cfg80211_rx_mgmt, | ||
1964 | TP_PROTO(struct wireless_dev *wdev, int freq, int sig_mbm), | ||
1965 | TP_ARGS(wdev, freq, sig_mbm), | ||
1966 | TP_STRUCT__entry( | ||
1967 | WDEV_ENTRY | ||
1968 | __field(int, freq) | ||
1969 | __field(int, sig_mbm) | ||
1970 | ), | ||
1971 | TP_fast_assign( | ||
1972 | WDEV_ASSIGN; | ||
1973 | __entry->freq = freq; | ||
1974 | __entry->sig_mbm = sig_mbm; | ||
1975 | ), | ||
1976 | TP_printk(WDEV_PR_FMT ", freq: %d, sig mbm: %d", | ||
1977 | WDEV_PR_ARG, __entry->freq, __entry->sig_mbm) | ||
1978 | ); | ||
1979 | |||
1980 | TRACE_EVENT(cfg80211_mgmt_tx_status, | ||
1981 | TP_PROTO(struct wireless_dev *wdev, u64 cookie, bool ack), | ||
1982 | TP_ARGS(wdev, cookie, ack), | ||
1983 | TP_STRUCT__entry( | ||
1984 | WDEV_ENTRY | ||
1985 | __field(u64, cookie) | ||
1986 | __field(bool, ack) | ||
1987 | ), | ||
1988 | TP_fast_assign( | ||
1989 | WDEV_ASSIGN; | ||
1990 | __entry->cookie = cookie; | ||
1991 | __entry->ack = ack; | ||
1992 | ), | ||
1993 | TP_printk(WDEV_PR_FMT", cookie: %llu, ack: %s", | ||
1994 | WDEV_PR_ARG, __entry->cookie, BOOL_TO_STR(__entry->ack)) | ||
1995 | ); | ||
1996 | |||
1997 | TRACE_EVENT(cfg80211_cqm_rssi_notify, | ||
1998 | TP_PROTO(struct net_device *netdev, | ||
1999 | enum nl80211_cqm_rssi_threshold_event rssi_event), | ||
2000 | TP_ARGS(netdev, rssi_event), | ||
2001 | TP_STRUCT__entry( | ||
2002 | NETDEV_ENTRY | ||
2003 | __field(enum nl80211_cqm_rssi_threshold_event, rssi_event) | ||
2004 | ), | ||
2005 | TP_fast_assign( | ||
2006 | NETDEV_ASSIGN; | ||
2007 | __entry->rssi_event = rssi_event; | ||
2008 | ), | ||
2009 | TP_printk(NETDEV_PR_FMT ", rssi event: %d", | ||
2010 | NETDEV_PR_ARG, __entry->rssi_event) | ||
2011 | ); | ||
2012 | |||
2013 | TRACE_EVENT(cfg80211_can_beacon_sec_chan, | ||
2014 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel, | ||
2015 | enum nl80211_channel_type channel_type), | ||
2016 | TP_ARGS(wiphy, channel, channel_type), | ||
2017 | TP_STRUCT__entry( | ||
2018 | WIPHY_ENTRY | ||
2019 | CHAN_ENTRY | ||
2020 | __field(enum nl80211_channel_type, channel_type) | ||
2021 | ), | ||
2022 | TP_fast_assign( | ||
2023 | WIPHY_ASSIGN; | ||
2024 | CHAN_ASSIGN(channel); | ||
2025 | __entry->channel_type = channel_type; | ||
2026 | ), | ||
2027 | TP_printk(WIPHY_PR_FMT CHAN_PR_FMT ", channel_type: %d", | ||
2028 | WIPHY_PR_ARG, CHAN_PR_ARG, __entry->channel_type) | ||
2029 | ); | ||
2030 | |||
2031 | TRACE_EVENT(cfg80211_ch_switch_notify, | ||
2032 | TP_PROTO(struct net_device *netdev, int freq, | ||
2033 | enum nl80211_channel_type type), | ||
2034 | TP_ARGS(netdev, freq, type), | ||
2035 | TP_STRUCT__entry( | ||
2036 | NETDEV_ENTRY | ||
2037 | __field(int, freq) | ||
2038 | __field(enum nl80211_channel_type, type) | ||
2039 | ), | ||
2040 | TP_fast_assign( | ||
2041 | NETDEV_ASSIGN; | ||
2042 | __entry->freq = freq; | ||
2043 | __entry->type = type; | ||
2044 | ), | ||
2045 | TP_printk(NETDEV_PR_FMT ", freq: %d, type: %d", NETDEV_PR_ARG, | ||
2046 | __entry->freq, __entry->type) | ||
2047 | ); | ||
2048 | |||
2049 | DECLARE_EVENT_CLASS(cfg80211_rx_evt, | ||
2050 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2051 | TP_ARGS(netdev, addr), | ||
2052 | TP_STRUCT__entry( | ||
2053 | NETDEV_ENTRY | ||
2054 | MAC_ENTRY(addr) | ||
2055 | ), | ||
2056 | TP_fast_assign( | ||
2057 | NETDEV_ASSIGN; | ||
2058 | MAC_ASSIGN(addr, addr); | ||
2059 | ), | ||
2060 | TP_printk(NETDEV_PR_FMT MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr)) | ||
2061 | ); | ||
2062 | |||
2063 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined, | ||
2064 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2065 | TP_ARGS(netdev, addr) | ||
2066 | ); | ||
2067 | |||
2068 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame, | ||
2069 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2070 | TP_ARGS(netdev, addr) | ||
2071 | ); | ||
2072 | |||
2073 | DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_unexpected_4addr_frame, | ||
2074 | TP_PROTO(struct net_device *netdev, const u8 *addr), | ||
2075 | TP_ARGS(netdev, addr) | ||
2076 | ); | ||
2077 | |||
2078 | TRACE_EVENT(cfg80211_probe_status, | ||
2079 | TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie, | ||
2080 | bool acked), | ||
2081 | TP_ARGS(netdev, addr, cookie, acked), | ||
2082 | TP_STRUCT__entry( | ||
2083 | NETDEV_ENTRY | ||
2084 | MAC_ENTRY(addr) | ||
2085 | __field(u64, cookie) | ||
2086 | __field(bool, acked) | ||
2087 | ), | ||
2088 | TP_fast_assign( | ||
2089 | NETDEV_ASSIGN; | ||
2090 | MAC_ASSIGN(addr, addr); | ||
2091 | __entry->cookie = cookie; | ||
2092 | __entry->acked = acked; | ||
2093 | ), | ||
2094 | TP_printk(NETDEV_PR_FMT MAC_PR_FMT ", cookie: %llu, acked: %s", | ||
2095 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->cookie, | ||
2096 | BOOL_TO_STR(__entry->acked)) | ||
2097 | ); | ||
2098 | |||
2099 | TRACE_EVENT(cfg80211_cqm_pktloss_notify, | ||
2100 | TP_PROTO(struct net_device *netdev, const u8 *peer, u32 num_packets), | ||
2101 | TP_ARGS(netdev, peer, num_packets), | ||
2102 | TP_STRUCT__entry( | ||
2103 | NETDEV_ENTRY | ||
2104 | MAC_ENTRY(peer) | ||
2105 | __field(u32, num_packets) | ||
2106 | ), | ||
2107 | TP_fast_assign( | ||
2108 | NETDEV_ASSIGN; | ||
2109 | MAC_ASSIGN(peer, peer); | ||
2110 | __entry->num_packets = num_packets; | ||
2111 | ), | ||
2112 | TP_printk(NETDEV_PR_FMT ", peer: " MAC_PR_FMT ", num of lost packets: %u", | ||
2113 | NETDEV_PR_ARG, MAC_PR_ARG(peer), __entry->num_packets) | ||
2114 | ); | ||
2115 | |||
2116 | DEFINE_EVENT(cfg80211_netdev_mac_evt, cfg80211_gtk_rekey_notify, | ||
2117 | TP_PROTO(struct net_device *netdev, const u8 *macaddr), | ||
2118 | TP_ARGS(netdev, macaddr) | ||
2119 | ); | ||
2120 | |||
2121 | TRACE_EVENT(cfg80211_pmksa_candidate_notify, | ||
2122 | TP_PROTO(struct net_device *netdev, int index, const u8 *bssid, | ||
2123 | bool preauth), | ||
2124 | TP_ARGS(netdev, index, bssid, preauth), | ||
2125 | TP_STRUCT__entry( | ||
2126 | NETDEV_ENTRY | ||
2127 | __field(int, index) | ||
2128 | MAC_ENTRY(bssid) | ||
2129 | __field(bool, preauth) | ||
2130 | ), | ||
2131 | TP_fast_assign( | ||
2132 | NETDEV_ASSIGN; | ||
2133 | __entry->index = index; | ||
2134 | MAC_ASSIGN(bssid, bssid); | ||
2135 | __entry->preauth = preauth; | ||
2136 | ), | ||
2137 | TP_printk(NETDEV_PR_FMT ", index:%d, bssid: " MAC_PR_FMT ", pre auth: %s", | ||
2138 | NETDEV_PR_ARG, __entry->index, MAC_PR_ARG(bssid), | ||
2139 | BOOL_TO_STR(__entry->preauth)) | ||
2140 | ); | ||
2141 | |||
2142 | TRACE_EVENT(cfg80211_report_obss_beacon, | ||
2143 | TP_PROTO(struct wiphy *wiphy, const u8 *frame, size_t len, | ||
2144 | int freq, int sig_dbm), | ||
2145 | TP_ARGS(wiphy, frame, len, freq, sig_dbm), | ||
2146 | TP_STRUCT__entry( | ||
2147 | WIPHY_ENTRY | ||
2148 | __field(int, freq) | ||
2149 | __field(int, sig_dbm) | ||
2150 | ), | ||
2151 | TP_fast_assign( | ||
2152 | WIPHY_ASSIGN; | ||
2153 | __entry->freq = freq; | ||
2154 | __entry->sig_dbm = sig_dbm; | ||
2155 | ), | ||
2156 | TP_printk(WIPHY_PR_FMT ", freq: %d, sig_dbm: %d", | ||
2157 | WIPHY_PR_ARG, __entry->freq, __entry->sig_dbm) | ||
2158 | ); | ||
2159 | |||
2160 | TRACE_EVENT(cfg80211_scan_done, | ||
2161 | TP_PROTO(struct cfg80211_scan_request *request, bool aborted), | ||
2162 | TP_ARGS(request, aborted), | ||
2163 | TP_STRUCT__entry( | ||
2164 | __field(u32, n_channels) | ||
2165 | __dynamic_array(u8, ie, request ? request->ie_len : 0) | ||
2166 | __array(u32, rates, IEEE80211_NUM_BANDS) | ||
2167 | __field(u32, wdev_id) | ||
2168 | MAC_ENTRY(wiphy_mac) | ||
2169 | __field(bool, no_cck) | ||
2170 | __field(bool, aborted) | ||
2171 | ), | ||
2172 | TP_fast_assign( | ||
2173 | if (request) { | ||
2174 | memcpy(__get_dynamic_array(ie), request->ie, | ||
2175 | request->ie_len); | ||
2176 | memcpy(__entry->rates, request->rates, | ||
2177 | IEEE80211_NUM_BANDS); | ||
2178 | __entry->wdev_id = request->wdev ? | ||
2179 | request->wdev->identifier : 0; | ||
2180 | if (request->wiphy) | ||
2181 | MAC_ASSIGN(wiphy_mac, | ||
2182 | request->wiphy->perm_addr); | ||
2183 | __entry->no_cck = request->no_cck; | ||
2184 | } | ||
2185 | __entry->aborted = aborted; | ||
2186 | ), | ||
2187 | TP_printk("aborted: %s", BOOL_TO_STR(__entry->aborted)) | ||
2188 | ); | ||
2189 | |||
2190 | DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_results, | ||
2191 | TP_PROTO(struct wiphy *wiphy), | ||
2192 | TP_ARGS(wiphy) | ||
2193 | ); | ||
2194 | |||
2195 | DEFINE_EVENT(wiphy_only_evt, cfg80211_sched_scan_stopped, | ||
2196 | TP_PROTO(struct wiphy *wiphy), | ||
2197 | TP_ARGS(wiphy) | ||
2198 | ); | ||
2199 | |||
2200 | TRACE_EVENT(cfg80211_get_bss, | ||
2201 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel, | ||
2202 | const u8 *bssid, const u8 *ssid, size_t ssid_len, | ||
2203 | u16 capa_mask, u16 capa_val), | ||
2204 | TP_ARGS(wiphy, channel, bssid, ssid, ssid_len, capa_mask, capa_val), | ||
2205 | TP_STRUCT__entry( | ||
2206 | WIPHY_ENTRY | ||
2207 | CHAN_ENTRY | ||
2208 | MAC_ENTRY(bssid) | ||
2209 | __dynamic_array(u8, ssid, ssid_len) | ||
2210 | __field(u16, capa_mask) | ||
2211 | __field(u16, capa_val) | ||
2212 | ), | ||
2213 | TP_fast_assign( | ||
2214 | WIPHY_ASSIGN; | ||
2215 | CHAN_ASSIGN(channel); | ||
2216 | MAC_ASSIGN(bssid, bssid); | ||
2217 | memcpy(__get_dynamic_array(ssid), ssid, ssid_len); | ||
2218 | __entry->capa_mask = capa_mask; | ||
2219 | __entry->capa_val = capa_val; | ||
2220 | ), | ||
2221 | TP_printk(WIPHY_PR_FMT CHAN_PR_FMT MAC_PR_FMT ", buf: %#.2x, " | ||
2222 | "capa_mask: %d, capa_val: %u", WIPHY_PR_ARG, CHAN_PR_ARG, | ||
2223 | MAC_PR_ARG(bssid), ((u8 *)__get_dynamic_array(ssid))[0], | ||
2224 | __entry->capa_mask, __entry->capa_val) | ||
2225 | ); | ||
2226 | |||
2227 | TRACE_EVENT(cfg80211_inform_bss_frame, | ||
2228 | TP_PROTO(struct wiphy *wiphy, struct ieee80211_channel *channel, | ||
2229 | struct ieee80211_mgmt *mgmt, size_t len, | ||
2230 | s32 signal), | ||
2231 | TP_ARGS(wiphy, channel, mgmt, len, signal), | ||
2232 | TP_STRUCT__entry( | ||
2233 | WIPHY_ENTRY | ||
2234 | CHAN_ENTRY | ||
2235 | __dynamic_array(u8, mgmt, len) | ||
2236 | __field(s32, signal) | ||
2237 | ), | ||
2238 | TP_fast_assign( | ||
2239 | WIPHY_ASSIGN; | ||
2240 | CHAN_ASSIGN(channel); | ||
2241 | if (mgmt) | ||
2242 | memcpy(__get_dynamic_array(mgmt), mgmt, len); | ||
2243 | __entry->signal = signal; | ||
2244 | ), | ||
2245 | TP_printk(WIPHY_PR_FMT CHAN_PR_FMT "signal: %d", | ||
2246 | WIPHY_PR_ARG, CHAN_PR_ARG, __entry->signal) | ||
2247 | ); | ||
2248 | |||
2249 | DECLARE_EVENT_CLASS(cfg80211_bss_evt, | ||
2250 | TP_PROTO(struct cfg80211_bss *pub), | ||
2251 | TP_ARGS(pub), | ||
2252 | TP_STRUCT__entry( | ||
2253 | MAC_ENTRY(bssid) | ||
2254 | CHAN_ENTRY | ||
2255 | ), | ||
2256 | TP_fast_assign( | ||
2257 | MAC_ASSIGN(bssid, pub->bssid); | ||
2258 | CHAN_ASSIGN(pub->channel); | ||
2259 | ), | ||
2260 | TP_printk(MAC_PR_FMT CHAN_PR_FMT, MAC_PR_ARG(bssid), CHAN_PR_ARG) | ||
2261 | ); | ||
2262 | |||
2263 | DEFINE_EVENT(cfg80211_bss_evt, cfg80211_return_bss, | ||
2264 | TP_PROTO(struct cfg80211_bss *pub), | ||
2265 | TP_ARGS(pub) | ||
2266 | ); | ||
2267 | |||
2268 | TRACE_EVENT(cfg80211_return_uint, | ||
2269 | TP_PROTO(unsigned int ret), | ||
2270 | TP_ARGS(ret), | ||
2271 | TP_STRUCT__entry( | ||
2272 | __field(unsigned int, ret) | ||
2273 | ), | ||
2274 | TP_fast_assign( | ||
2275 | __entry->ret = ret; | ||
2276 | ), | ||
2277 | TP_printk("ret: %d", __entry->ret) | ||
2278 | ); | ||
2279 | |||
2280 | TRACE_EVENT(cfg80211_return_u32, | ||
2281 | TP_PROTO(u32 ret), | ||
2282 | TP_ARGS(ret), | ||
2283 | TP_STRUCT__entry( | ||
2284 | __field(u32, ret) | ||
2285 | ), | ||
2286 | TP_fast_assign( | ||
2287 | __entry->ret = ret; | ||
2288 | ), | ||
2289 | TP_printk("ret: %u", __entry->ret) | ||
2290 | ); | ||
2291 | |||
2292 | #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ | ||
2293 | |||
2294 | #undef TRACE_INCLUDE_PATH | ||
2295 | #define TRACE_INCLUDE_PATH . | ||
2296 | #undef TRACE_INCLUDE_FILE | ||
2297 | #define TRACE_INCLUDE_FILE trace | ||
2298 | #include <trace/define_trace.h> | ||
diff --git a/net/wireless/util.c b/net/wireless/util.c index ef35f4ef2aa6..b99f01cda1f6 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -11,6 +11,8 @@ | |||
11 | #include <net/ip.h> | 11 | #include <net/ip.h> |
12 | #include <net/dsfield.h> | 12 | #include <net/dsfield.h> |
13 | #include "core.h" | 13 | #include "core.h" |
14 | #include "rdev-ops.h" | ||
15 | |||
14 | 16 | ||
15 | struct ieee80211_rate * | 17 | struct ieee80211_rate * |
16 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | 18 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, |
@@ -309,23 +311,21 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) | |||
309 | } | 311 | } |
310 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); | 312 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); |
311 | 313 | ||
312 | static int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) | 314 | unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) |
313 | { | 315 | { |
314 | int ae = meshhdr->flags & MESH_FLAGS_AE; | 316 | int ae = meshhdr->flags & MESH_FLAGS_AE; |
315 | /* 7.1.3.5a.2 */ | 317 | /* 802.11-2012, 8.2.4.7.3 */ |
316 | switch (ae) { | 318 | switch (ae) { |
319 | default: | ||
317 | case 0: | 320 | case 0: |
318 | return 6; | 321 | return 6; |
319 | case MESH_FLAGS_AE_A4: | 322 | case MESH_FLAGS_AE_A4: |
320 | return 12; | 323 | return 12; |
321 | case MESH_FLAGS_AE_A5_A6: | 324 | case MESH_FLAGS_AE_A5_A6: |
322 | return 18; | 325 | return 18; |
323 | case (MESH_FLAGS_AE_A4 | MESH_FLAGS_AE_A5_A6): | ||
324 | return 24; | ||
325 | default: | ||
326 | return 6; | ||
327 | } | 326 | } |
328 | } | 327 | } |
328 | EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen); | ||
329 | 329 | ||
330 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | 330 | int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, |
331 | enum nl80211_iftype iftype) | 331 | enum nl80211_iftype iftype) |
@@ -373,6 +373,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
373 | /* make sure meshdr->flags is on the linear part */ | 373 | /* make sure meshdr->flags is on the linear part */ |
374 | if (!pskb_may_pull(skb, hdrlen + 1)) | 374 | if (!pskb_may_pull(skb, hdrlen + 1)) |
375 | return -1; | 375 | return -1; |
376 | if (meshdr->flags & MESH_FLAGS_AE_A4) | ||
377 | return -1; | ||
376 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { | 378 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { |
377 | skb_copy_bits(skb, hdrlen + | 379 | skb_copy_bits(skb, hdrlen + |
378 | offsetof(struct ieee80211s_hdr, eaddr1), | 380 | offsetof(struct ieee80211s_hdr, eaddr1), |
@@ -397,6 +399,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, | |||
397 | /* make sure meshdr->flags is on the linear part */ | 399 | /* make sure meshdr->flags is on the linear part */ |
398 | if (!pskb_may_pull(skb, hdrlen + 1)) | 400 | if (!pskb_may_pull(skb, hdrlen + 1)) |
399 | return -1; | 401 | return -1; |
402 | if (meshdr->flags & MESH_FLAGS_AE_A5_A6) | ||
403 | return -1; | ||
400 | if (meshdr->flags & MESH_FLAGS_AE_A4) | 404 | if (meshdr->flags & MESH_FLAGS_AE_A4) |
401 | skb_copy_bits(skb, hdrlen + | 405 | skb_copy_bits(skb, hdrlen + |
402 | offsetof(struct ieee80211s_hdr, eaddr1), | 406 | offsetof(struct ieee80211s_hdr, eaddr1), |
@@ -703,19 +707,18 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev) | |||
703 | for (i = 0; i < 6; i++) { | 707 | for (i = 0; i < 6; i++) { |
704 | if (!wdev->connect_keys->params[i].cipher) | 708 | if (!wdev->connect_keys->params[i].cipher) |
705 | continue; | 709 | continue; |
706 | if (rdev->ops->add_key(wdev->wiphy, dev, i, false, NULL, | 710 | if (rdev_add_key(rdev, dev, i, false, NULL, |
707 | &wdev->connect_keys->params[i])) { | 711 | &wdev->connect_keys->params[i])) { |
708 | netdev_err(dev, "failed to set key %d\n", i); | 712 | netdev_err(dev, "failed to set key %d\n", i); |
709 | continue; | 713 | continue; |
710 | } | 714 | } |
711 | if (wdev->connect_keys->def == i) | 715 | if (wdev->connect_keys->def == i) |
712 | if (rdev->ops->set_default_key(wdev->wiphy, dev, | 716 | if (rdev_set_default_key(rdev, dev, i, true, true)) { |
713 | i, true, true)) { | ||
714 | netdev_err(dev, "failed to set defkey %d\n", i); | 717 | netdev_err(dev, "failed to set defkey %d\n", i); |
715 | continue; | 718 | continue; |
716 | } | 719 | } |
717 | if (wdev->connect_keys->defmgmt == i) | 720 | if (wdev->connect_keys->defmgmt == i) |
718 | if (rdev->ops->set_default_mgmt_key(wdev->wiphy, dev, i)) | 721 | if (rdev_set_default_mgmt_key(rdev, dev, i)) |
719 | netdev_err(dev, "failed to set mgtdef %d\n", i); | 722 | netdev_err(dev, "failed to set mgtdef %d\n", i); |
720 | } | 723 | } |
721 | 724 | ||
@@ -848,8 +851,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, | |||
848 | cfg80211_process_rdev_events(rdev); | 851 | cfg80211_process_rdev_events(rdev); |
849 | } | 852 | } |
850 | 853 | ||
851 | err = rdev->ops->change_virtual_intf(&rdev->wiphy, dev, | 854 | err = rdev_change_virtual_intf(rdev, dev, ntype, flags, params); |
852 | ntype, flags, params); | ||
853 | 855 | ||
854 | WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); | 856 | WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype); |
855 | 857 | ||
@@ -978,6 +980,105 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate) | |||
978 | } | 980 | } |
979 | EXPORT_SYMBOL(cfg80211_calculate_bitrate); | 981 | EXPORT_SYMBOL(cfg80211_calculate_bitrate); |
980 | 982 | ||
983 | unsigned int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, | ||
984 | u8 attr, u8 *buf, unsigned int bufsize) | ||
985 | { | ||
986 | u8 *out = buf; | ||
987 | u16 attr_remaining = 0; | ||
988 | bool desired_attr = false; | ||
989 | u16 desired_len = 0; | ||
990 | |||
991 | while (len > 0) { | ||
992 | unsigned int iedatalen; | ||
993 | unsigned int copy; | ||
994 | const u8 *iedata; | ||
995 | |||
996 | if (len < 2) | ||
997 | return -EILSEQ; | ||
998 | iedatalen = ies[1]; | ||
999 | if (iedatalen + 2 > len) | ||
1000 | return -EILSEQ; | ||
1001 | |||
1002 | if (ies[0] != WLAN_EID_VENDOR_SPECIFIC) | ||
1003 | goto cont; | ||
1004 | |||
1005 | if (iedatalen < 4) | ||
1006 | goto cont; | ||
1007 | |||
1008 | iedata = ies + 2; | ||
1009 | |||
1010 | /* check WFA OUI, P2P subtype */ | ||
1011 | if (iedata[0] != 0x50 || iedata[1] != 0x6f || | ||
1012 | iedata[2] != 0x9a || iedata[3] != 0x09) | ||
1013 | goto cont; | ||
1014 | |||
1015 | iedatalen -= 4; | ||
1016 | iedata += 4; | ||
1017 | |||
1018 | /* check attribute continuation into this IE */ | ||
1019 | copy = min_t(unsigned int, attr_remaining, iedatalen); | ||
1020 | if (copy && desired_attr) { | ||
1021 | desired_len += copy; | ||
1022 | if (out) { | ||
1023 | memcpy(out, iedata, min(bufsize, copy)); | ||
1024 | out += min(bufsize, copy); | ||
1025 | bufsize -= min(bufsize, copy); | ||
1026 | } | ||
1027 | |||
1028 | |||
1029 | if (copy == attr_remaining) | ||
1030 | return desired_len; | ||
1031 | } | ||
1032 | |||
1033 | attr_remaining -= copy; | ||
1034 | if (attr_remaining) | ||
1035 | goto cont; | ||
1036 | |||
1037 | iedatalen -= copy; | ||
1038 | iedata += copy; | ||
1039 | |||
1040 | while (iedatalen > 0) { | ||
1041 | u16 attr_len; | ||
1042 | |||
1043 | /* P2P attribute ID & size must fit */ | ||
1044 | if (iedatalen < 3) | ||
1045 | return -EILSEQ; | ||
1046 | desired_attr = iedata[0] == attr; | ||
1047 | attr_len = get_unaligned_le16(iedata + 1); | ||
1048 | iedatalen -= 3; | ||
1049 | iedata += 3; | ||
1050 | |||
1051 | copy = min_t(unsigned int, attr_len, iedatalen); | ||
1052 | |||
1053 | if (desired_attr) { | ||
1054 | desired_len += copy; | ||
1055 | if (out) { | ||
1056 | memcpy(out, iedata, min(bufsize, copy)); | ||
1057 | out += min(bufsize, copy); | ||
1058 | bufsize -= min(bufsize, copy); | ||
1059 | } | ||
1060 | |||
1061 | if (copy == attr_len) | ||
1062 | return desired_len; | ||
1063 | } | ||
1064 | |||
1065 | iedata += copy; | ||
1066 | iedatalen -= copy; | ||
1067 | attr_remaining = attr_len - copy; | ||
1068 | } | ||
1069 | |||
1070 | cont: | ||
1071 | len -= ies[1] + 2; | ||
1072 | ies += ies[1] + 2; | ||
1073 | } | ||
1074 | |||
1075 | if (attr_remaining && desired_attr) | ||
1076 | return -EILSEQ; | ||
1077 | |||
1078 | return -ENOENT; | ||
1079 | } | ||
1080 | EXPORT_SYMBOL(cfg80211_get_p2p_attr); | ||
1081 | |||
981 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, | 1082 | int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev, |
982 | u32 beacon_int) | 1083 | u32 beacon_int) |
983 | { | 1084 | { |
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 494379eb464f..742ab6ec4c9d 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <net/cfg80211-wext.h> | 19 | #include <net/cfg80211-wext.h> |
20 | #include "wext-compat.h" | 20 | #include "wext-compat.h" |
21 | #include "core.h" | 21 | #include "core.h" |
22 | #include "rdev-ops.h" | ||
22 | 23 | ||
23 | int cfg80211_wext_giwname(struct net_device *dev, | 24 | int cfg80211_wext_giwname(struct net_device *dev, |
24 | struct iw_request_info *info, | 25 | struct iw_request_info *info, |
@@ -301,8 +302,7 @@ int cfg80211_wext_siwrts(struct net_device *dev, | |||
301 | else | 302 | else |
302 | wdev->wiphy->rts_threshold = rts->value; | 303 | wdev->wiphy->rts_threshold = rts->value; |
303 | 304 | ||
304 | err = rdev->ops->set_wiphy_params(wdev->wiphy, | 305 | err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_RTS_THRESHOLD); |
305 | WIPHY_PARAM_RTS_THRESHOLD); | ||
306 | if (err) | 306 | if (err) |
307 | wdev->wiphy->rts_threshold = orts; | 307 | wdev->wiphy->rts_threshold = orts; |
308 | 308 | ||
@@ -342,8 +342,7 @@ int cfg80211_wext_siwfrag(struct net_device *dev, | |||
342 | wdev->wiphy->frag_threshold = frag->value & ~0x1; | 342 | wdev->wiphy->frag_threshold = frag->value & ~0x1; |
343 | } | 343 | } |
344 | 344 | ||
345 | err = rdev->ops->set_wiphy_params(wdev->wiphy, | 345 | err = rdev_set_wiphy_params(rdev, WIPHY_PARAM_FRAG_THRESHOLD); |
346 | WIPHY_PARAM_FRAG_THRESHOLD); | ||
347 | if (err) | 346 | if (err) |
348 | wdev->wiphy->frag_threshold = ofrag; | 347 | wdev->wiphy->frag_threshold = ofrag; |
349 | 348 | ||
@@ -396,7 +395,7 @@ static int cfg80211_wext_siwretry(struct net_device *dev, | |||
396 | if (!changed) | 395 | if (!changed) |
397 | return 0; | 396 | return 0; |
398 | 397 | ||
399 | err = rdev->ops->set_wiphy_params(wdev->wiphy, changed); | 398 | err = rdev_set_wiphy_params(rdev, changed); |
400 | if (err) { | 399 | if (err) { |
401 | wdev->wiphy->retry_short = oshort; | 400 | wdev->wiphy->retry_short = oshort; |
402 | wdev->wiphy->retry_long = olong; | 401 | wdev->wiphy->retry_long = olong; |
@@ -490,8 +489,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
490 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) | 489 | !(rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN)) |
491 | err = -ENOENT; | 490 | err = -ENOENT; |
492 | else | 491 | else |
493 | err = rdev->ops->del_key(&rdev->wiphy, dev, idx, | 492 | err = rdev_del_key(rdev, dev, idx, pairwise, |
494 | pairwise, addr); | 493 | addr); |
495 | } | 494 | } |
496 | wdev->wext.connect.privacy = false; | 495 | wdev->wext.connect.privacy = false; |
497 | /* | 496 | /* |
@@ -525,8 +524,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
525 | 524 | ||
526 | err = 0; | 525 | err = 0; |
527 | if (wdev->current_bss) | 526 | if (wdev->current_bss) |
528 | err = rdev->ops->add_key(&rdev->wiphy, dev, idx, | 527 | err = rdev_add_key(rdev, dev, idx, pairwise, addr, params); |
529 | pairwise, addr, params); | ||
530 | if (err) | 528 | if (err) |
531 | return err; | 529 | return err; |
532 | 530 | ||
@@ -552,8 +550,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
552 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); | 550 | __cfg80211_leave_ibss(rdev, wdev->netdev, true); |
553 | rejoin = true; | 551 | rejoin = true; |
554 | } | 552 | } |
555 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, | 553 | err = rdev_set_default_key(rdev, dev, idx, true, true); |
556 | idx, true, true); | ||
557 | } | 554 | } |
558 | if (!err) { | 555 | if (!err) { |
559 | wdev->wext.default_key = idx; | 556 | wdev->wext.default_key = idx; |
@@ -566,8 +563,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, | |||
566 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && | 563 | if (params->cipher == WLAN_CIPHER_SUITE_AES_CMAC && |
567 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { | 564 | (tx_key || (!addr && wdev->wext.default_mgmt_key == -1))) { |
568 | if (wdev->current_bss) | 565 | if (wdev->current_bss) |
569 | err = rdev->ops->set_default_mgmt_key(&rdev->wiphy, | 566 | err = rdev_set_default_mgmt_key(rdev, dev, idx); |
570 | dev, idx); | ||
571 | if (!err) | 567 | if (!err) |
572 | wdev->wext.default_mgmt_key = idx; | 568 | wdev->wext.default_mgmt_key = idx; |
573 | return err; | 569 | return err; |
@@ -631,8 +627,8 @@ static int cfg80211_wext_siwencode(struct net_device *dev, | |||
631 | err = 0; | 627 | err = 0; |
632 | wdev_lock(wdev); | 628 | wdev_lock(wdev); |
633 | if (wdev->current_bss) | 629 | if (wdev->current_bss) |
634 | err = rdev->ops->set_default_key(&rdev->wiphy, dev, | 630 | err = rdev_set_default_key(rdev, dev, idx, true, |
635 | idx, true, true); | 631 | true); |
636 | if (!err) | 632 | if (!err) |
637 | wdev->wext.default_key = idx; | 633 | wdev->wext.default_key = idx; |
638 | wdev_unlock(wdev); | 634 | wdev_unlock(wdev); |
@@ -839,7 +835,7 @@ static int cfg80211_wext_giwfreq(struct net_device *dev, | |||
839 | if (!rdev->ops->get_channel) | 835 | if (!rdev->ops->get_channel) |
840 | return -EINVAL; | 836 | return -EINVAL; |
841 | 837 | ||
842 | chan = rdev->ops->get_channel(wdev->wiphy, wdev, &channel_type); | 838 | chan = rdev_get_channel(rdev, wdev, &channel_type); |
843 | if (!chan) | 839 | if (!chan) |
844 | return -EINVAL; | 840 | return -EINVAL; |
845 | freq->m = chan->center_freq; | 841 | freq->m = chan->center_freq; |
@@ -899,7 +895,7 @@ static int cfg80211_wext_siwtxpower(struct net_device *dev, | |||
899 | return 0; | 895 | return 0; |
900 | } | 896 | } |
901 | 897 | ||
902 | return rdev->ops->set_tx_power(wdev->wiphy, type, DBM_TO_MBM(dbm)); | 898 | return rdev_set_tx_power(rdev, wdev, type, DBM_TO_MBM(dbm)); |
903 | } | 899 | } |
904 | 900 | ||
905 | static int cfg80211_wext_giwtxpower(struct net_device *dev, | 901 | static int cfg80211_wext_giwtxpower(struct net_device *dev, |
@@ -918,7 +914,7 @@ static int cfg80211_wext_giwtxpower(struct net_device *dev, | |||
918 | if (!rdev->ops->get_tx_power) | 914 | if (!rdev->ops->get_tx_power) |
919 | return -EOPNOTSUPP; | 915 | return -EOPNOTSUPP; |
920 | 916 | ||
921 | err = rdev->ops->get_tx_power(wdev->wiphy, &val); | 917 | err = rdev_get_tx_power(rdev, wdev, &val); |
922 | if (err) | 918 | if (err) |
923 | return err; | 919 | return err; |
924 | 920 | ||
@@ -1158,7 +1154,7 @@ static int cfg80211_wext_siwpower(struct net_device *dev, | |||
1158 | timeout = wrq->value / 1000; | 1154 | timeout = wrq->value / 1000; |
1159 | } | 1155 | } |
1160 | 1156 | ||
1161 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout); | 1157 | err = rdev_set_power_mgmt(rdev, dev, ps, timeout); |
1162 | if (err) | 1158 | if (err) |
1163 | return err; | 1159 | return err; |
1164 | 1160 | ||
@@ -1200,7 +1196,7 @@ static int cfg80211_wds_wext_siwap(struct net_device *dev, | |||
1200 | if (!rdev->ops->set_wds_peer) | 1196 | if (!rdev->ops->set_wds_peer) |
1201 | return -EOPNOTSUPP; | 1197 | return -EOPNOTSUPP; |
1202 | 1198 | ||
1203 | err = rdev->ops->set_wds_peer(wdev->wiphy, dev, (u8 *) &addr->sa_data); | 1199 | err = rdev_set_wds_peer(rdev, dev, (u8 *)&addr->sa_data); |
1204 | if (err) | 1200 | if (err) |
1205 | return err; | 1201 | return err; |
1206 | 1202 | ||
@@ -1272,7 +1268,7 @@ static int cfg80211_wext_siwrate(struct net_device *dev, | |||
1272 | if (!match) | 1268 | if (!match) |
1273 | return -EINVAL; | 1269 | return -EINVAL; |
1274 | 1270 | ||
1275 | return rdev->ops->set_bitrate_mask(wdev->wiphy, dev, NULL, &mask); | 1271 | return rdev_set_bitrate_mask(rdev, dev, NULL, &mask); |
1276 | } | 1272 | } |
1277 | 1273 | ||
1278 | static int cfg80211_wext_giwrate(struct net_device *dev, | 1274 | static int cfg80211_wext_giwrate(struct net_device *dev, |
@@ -1302,7 +1298,7 @@ static int cfg80211_wext_giwrate(struct net_device *dev, | |||
1302 | if (err) | 1298 | if (err) |
1303 | return err; | 1299 | return err; |
1304 | 1300 | ||
1305 | err = rdev->ops->get_station(&rdev->wiphy, dev, addr, &sinfo); | 1301 | err = rdev_get_station(rdev, dev, addr, &sinfo); |
1306 | if (err) | 1302 | if (err) |
1307 | return err; | 1303 | return err; |
1308 | 1304 | ||
@@ -1339,7 +1335,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev) | |||
1339 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); | 1335 | memcpy(bssid, wdev->current_bss->pub.bssid, ETH_ALEN); |
1340 | wdev_unlock(wdev); | 1336 | wdev_unlock(wdev); |
1341 | 1337 | ||
1342 | if (rdev->ops->get_station(&rdev->wiphy, dev, bssid, &sinfo)) | 1338 | if (rdev_get_station(rdev, dev, bssid, &sinfo)) |
1343 | return NULL; | 1339 | return NULL; |
1344 | 1340 | ||
1345 | memset(&wstats, 0, sizeof(wstats)); | 1341 | memset(&wstats, 0, sizeof(wstats)); |
@@ -1474,19 +1470,19 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev, | |||
1474 | if (!rdev->ops->set_pmksa) | 1470 | if (!rdev->ops->set_pmksa) |
1475 | return -EOPNOTSUPP; | 1471 | return -EOPNOTSUPP; |
1476 | 1472 | ||
1477 | return rdev->ops->set_pmksa(&rdev->wiphy, dev, &cfg_pmksa); | 1473 | return rdev_set_pmksa(rdev, dev, &cfg_pmksa); |
1478 | 1474 | ||
1479 | case IW_PMKSA_REMOVE: | 1475 | case IW_PMKSA_REMOVE: |
1480 | if (!rdev->ops->del_pmksa) | 1476 | if (!rdev->ops->del_pmksa) |
1481 | return -EOPNOTSUPP; | 1477 | return -EOPNOTSUPP; |
1482 | 1478 | ||
1483 | return rdev->ops->del_pmksa(&rdev->wiphy, dev, &cfg_pmksa); | 1479 | return rdev_del_pmksa(rdev, dev, &cfg_pmksa); |
1484 | 1480 | ||
1485 | case IW_PMKSA_FLUSH: | 1481 | case IW_PMKSA_FLUSH: |
1486 | if (!rdev->ops->flush_pmksa) | 1482 | if (!rdev->ops->flush_pmksa) |
1487 | return -EOPNOTSUPP; | 1483 | return -EOPNOTSUPP; |
1488 | 1484 | ||
1489 | return rdev->ops->flush_pmksa(&rdev->wiphy, dev); | 1485 | return rdev_flush_pmksa(rdev, dev); |
1490 | 1486 | ||
1491 | default: | 1487 | default: |
1492 | return -EOPNOTSUPP; | 1488 | return -EOPNOTSUPP; |