1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
77
78
79
80
81
82
94
95
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
124
125
126
127
128
129
130
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
177
178
187
188
189
190
191
192
193
194
195
196
197
198
199
200
207
208
209
210
211
216
217
218
219
220
221
222
227
233
234
235
236
240
241
242
243
253
254
255
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
296
297
298
299
300
301
302
303
304
308
309
310
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
378
379
380
383
384
385
386
387
388
389
390
395
396
413
414
422
423
427
428
429
430
431
432
443
444
445
446
447
448
449
450
451
452
454
455
457
458
459
460
461
462
463
464
465
468
469
470
471
472
473
474
484
485
486
492
493
494
500
501
502
503
504
505
508
509
510
511
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
543
544
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
573
574
575
576
577
578
579
580
581
582
583
584
594
595
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
627
628
629
630
631
632
633
634
649
657
658
661
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
693
694
695
696
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
745
746
747
757
758
759
760
763
764
765
766
767
768
769
770
771
775
776
782
783
788
789
790
791
792
793
794
795
796
797
798
801
802
803
804
807
808
809
813
814
815
816
817
818
819
820
821
822
823
824
825
826
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
941
942
943
944
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
994
1004
1005
1006
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1043
1044
1045
1046
1047
1057
1058
1059
1062
1066
1067
1070
1071
1072
1073
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1102
1103
1104
1105
1106
1107
1108
1109
1113
1114
1115
1116
1117
1118
1121
1122
1123
1131
1132
1135
1136
1137
1138
1139
1140
1141
1142
1143
1146
1147
1148
1154
1155
1156
1157
1158
1159
1162
1163
1164
1165
1168
1169
1171
1172
1173
1176
1177
1178
1179
1182
1183
1184
1185
1186
1187
1190
1191
1192
1193
1194
1195
1196
1197
1200
1201
1204
1205
1208
1209
1210
1211
1212
1213
1214
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1240
1241
1242
1243
1244
1252
1253
1254
1255
1256
1260
1265
1266
1267
1272
1277
1278
1279
1280
1281
1296
1297
1298
1299
1305
1313
1314
1315
1316
1319
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1379
1380
1381
1382
1385
1390
1391
1411
1412
1413
1418
1419
1420
1421
1422
1423
1424
1427
1428
1435
1436
1437
1438
1439
1440
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1461
1462
1466
1467
1468
1469
1470
1471
1472
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1515
/* ... */
/* ... */
#include <stdlib.h>
#include <string.h>
#include "device/controller.h"
#include "stack/bt_types.h"
#include "stack/hcimsgs.h"
#include "stack/l2cdefs.h"
#include "l2c_int.h"
#include "stack/l2c_api.h"
#include "stack/btu.h"
#include "stack/btm_api.h"
#include "btm_int.h"11 includes
static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t handle);
#endif
extern bool btm_ble_inter_get(void);
/* ... */
BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr)
{
tL2C_LCB *p_lcb;
tL2C_LCB *p_lcb_cur;
BOOLEAN no_links;
p_lcb = l2cu_find_lcb_by_bd_addr (bd_addr, BT_TRANSPORT_BR_EDR);
if (!p_lcb) {
p_lcb = l2cu_allocate_lcb (bd_addr, FALSE, BT_TRANSPORT_BR_EDR);
if (!p_lcb) {
btsnd_hcic_reject_conn (bd_addr, HCI_ERR_HOST_REJECT_RESOURCES);
L2CAP_TRACE_ERROR ("L2CAP failed to allocate LCB");
return FALSE;
}{...}
no_links = TRUE;
list_node_t *p_node = NULL;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb_cur = list_node(p_node);
if (p_lcb_cur == p_lcb) {
continue;
}{...}
if (p_lcb_cur->in_use) {
no_links = FALSE;
p_lcb->link_role = HCI_ROLE_MASTER;
break;
}{...}
}{...}
if (no_links) {
if (!btm_dev_support_switch (bd_addr)) {
p_lcb->link_role = HCI_ROLE_SLAVE;
}{...} else {
p_lcb->link_role = l2cu_get_conn_role(p_lcb);
}{...}
}{...}
btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role);
p_lcb->link_state = LST_CONNECTING;
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_CONNECT_TOUT);
return (TRUE);
}{...}
if ((p_lcb->link_state == LST_CONNECTING) || (p_lcb->link_state == LST_CONNECT_HOLDING)) {
if (!btm_dev_support_switch (bd_addr)) {
p_lcb->link_role = HCI_ROLE_SLAVE;
}{...} else {
p_lcb->link_role = l2cu_get_conn_role(p_lcb);
}{...}
btsnd_hcic_accept_conn (bd_addr, p_lcb->link_role);
p_lcb->link_state = LST_CONNECTING;
return (TRUE);
}{...} else if (p_lcb->link_state == LST_DISCONNECTING) {
btsnd_hcic_reject_conn (bd_addr, HCI_ERR_HOST_REJECT_DEVICE);
}{...} else {
L2CAP_TRACE_ERROR("L2CAP got conn_req while connected (state:%d). Reject it\n",
p_lcb->link_state);
btsnd_hcic_reject_conn (bd_addr, HCI_ERR_CONNECTION_EXISTS);
}{...}
return (FALSE);
}{ ... }
/* ... */
BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda)
{
tL2C_CONN_INFO ci;
tL2C_LCB *p_lcb;
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
#endif
tBTM_SEC_DEV_REC *p_dev_info = NULL;
btm_acl_update_busy_level (BTM_BLI_PAGE_DONE_EVT);
ci.status = status;
memcpy (ci.bd_addr, p_bda, BD_ADDR_LEN);
p_lcb = l2cu_find_lcb_by_bd_addr (ci.bd_addr, BT_TRANSPORT_BR_EDR);
if (!p_lcb) {
L2CAP_TRACE_WARNING ("L2CAP got conn_comp for unknown BD_ADDR\n");
return (FALSE);
}{...}
if (p_lcb->link_state != LST_CONNECTING) {
L2CAP_TRACE_ERROR ("L2CAP got conn_comp in bad state: %d status: 0x%d\n", p_lcb->link_state, status);
if (status != HCI_SUCCESS) {
l2c_link_hci_disc_comp (p_lcb->handle, status);
}{...}
return (FALSE);
}{...}
p_lcb->handle = handle;
if (ci.status == HCI_SUCCESS) {
p_lcb->link_state = LST_CONNECTED;
l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE);
if ((p_dev_info = btm_find_dev (p_bda)) != NULL) {
btm_acl_created (ci.bd_addr, p_dev_info->dev_class,
p_dev_info->sec_bd_name, handle,
p_lcb->link_role, BT_TRANSPORT_BR_EDR);
}{...} else {
btm_acl_created (ci.bd_addr, NULL, NULL, handle, p_lcb->link_role, BT_TRANSPORT_BR_EDR);
}{...}
BTM_SetLinkSuperTout (ci.bd_addr, btm_cb.btm_def_link_super_tout);
if (p_lcb->is_bonding) {
if (l2cu_start_post_bond_timer(handle)) {
return (TRUE);
}{...}
}{...}
l2c_process_held_packets(FALSE);
btu_stop_timer (&p_lcb->timer_entry);
#if (CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) {
l2c_csm_execute (p_ccb, L2CEVT_LP_CONNECT_CFM, &ci);
}{...}
#endif/* ... */
if (p_lcb->p_echo_rsp_cb) {
l2cu_send_peer_echo_req (p_lcb, NULL, 0);
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_ECHO_RSP_TOUT);
}{...} else if (!p_lcb->ccb_queue.p_first_ccb) {
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_STARTUP_TOUT);
}{...}
}{...}
else if ((ci.status == HCI_ERR_MAX_NUM_OF_CONNECTIONS) && l2cu_lcb_disconnecting()) {
p_lcb->link_state = LST_CONNECT_HOLDING;
p_lcb->handle = HCI_INVALID_HANDLE;
}{...} else {
p_lcb->link_state = LST_DISCONNECTING;
#if(CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) {
tL2C_CCB *pn = p_ccb->p_next_ccb;
l2c_csm_execute (p_ccb, L2CEVT_LP_CONNECT_CFM_NEG, &ci);
p_ccb = pn;
}{...}
#endif/* ... */
p_lcb->disc_reason = status;
if (p_lcb->ccb_queue.p_first_ccb == NULL) {
l2cu_release_lcb (p_lcb);
}{...} else {
if (ci.status == HCI_ERR_CONNECTION_EXISTS) {
p_lcb->link_state = LST_CONNECTING;
}{...} else {
l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR);
}{...}
}{...}
}{...}
return (TRUE);
}{ ... }
/* ... */
void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data, UINT8 status)
{
tL2C_CONN_INFO ci;
tL2C_LCB *p_lcb;
tL2C_CCB *p_ccb;
tL2C_CCB *p_next_ccb;
#if (CLASSIC_BT_INCLUDED == TRUE)
UINT8 event;
#endif
UNUSED(transport);
L2CAP_TRACE_DEBUG ("l2c_link_sec_comp: %d, %p", status, p_ref_data);
if (status == BTM_SUCCESS_NO_SECURITY) {
status = BTM_SUCCESS;
}{...}
ci.status = status;
memcpy (ci.bd_addr, p_bda, BD_ADDR_LEN);
p_lcb = l2cu_find_lcb_by_bd_addr (p_bda, BT_TRANSPORT_BR_EDR);
if (!p_lcb) {
L2CAP_TRACE_WARNING ("L2CAP got sec_comp for unknown BD_ADDR\n");
return;
}{...}
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) {
p_next_ccb = p_ccb->p_next_ccb;
if (p_ccb == p_ref_data) {
switch (status) {
case BTM_SUCCESS:
L2CAP_TRACE_DEBUG ("ccb timer ticks: %u", p_ccb->timer_entry.ticks);
#if (CLASSIC_BT_INCLUDED == TRUE)
event = L2CEVT_SEC_COMP;
#endif
break;
...
case BTM_DELAY_CHECK:
btu_start_timer (&p_ccb->timer_entry, BTU_TTYPE_L2CAP_CHNL, L2CAP_DELAY_CHECK_SM4);
return;
...
default:
#if (CLASSIC_BT_INCLUDED == TRUE)
event = L2CEVT_SEC_COMP_NEG;
#endif
break;...
}{...}
#if (CLASSIC_BT_INCLUDED == TRUE)
l2c_csm_execute (p_ccb, event, &ci);
#endif
break;
}{...}
}{...}
}{ ... }
/* ... */
BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
{
tL2C_LCB *p_lcb;
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
#endif
BOOLEAN status = TRUE;
BOOLEAN lcb_is_free = TRUE;
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
p_lcb = l2cu_find_lcb_by_handle (handle);
if (!p_lcb) {
#if (BLE_INCLUDED == TRUE)
if (reason != HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) {
BTM_Recovery_Pre_State();
}{...}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
if(btm_ble_inter_get() && reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) {
BTM_BleStartExtAdvRestart(handle);
}{...}
/* ... */#endif /* ... */
#endif
status = FALSE;
}{...} else {
if (btm_cb.acl_disc_reason != HCI_ERR_HOST_REJECT_SECURITY) {
btm_cb.acl_disc_reason = reason;
}{...}
p_lcb->disc_reason = btm_cb.acl_disc_reason;
p_lcb->link_state = LST_DISCONNECTING;
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE) {
btm_ble_update_link_topology_mask(p_lcb->link_role, FALSE);
}{...}
#endif/* ... */
#if (CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) {
tL2C_CCB *pn = p_ccb->p_next_ccb;
/* ... */
if (p_ccb != p_lcb->p_pending_ccb) {
l2c_csm_execute (p_ccb, L2CEVT_LP_DISCONNECT_IND, &reason);
}{...}
p_ccb = pn;
}{...}
#endif/* ... */
#if (BTM_SCO_INCLUDED == TRUE)
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
#endif
{
btm_sco_acl_removed (p_lcb->remote_bd_addr);
}{...}
/* ... */#endif
/* ... */
if (p_lcb->ccb_queue.p_first_ccb != NULL || p_lcb->p_pending_ccb) {
L2CAP_TRACE_DEBUG("l2c_link_hci_disc_comp: Restarting pending ACL request");
transport = p_lcb->transport;
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
l2cb.is_ble_connecting = FALSE;
btm_acl_removed (p_lcb->remote_bd_addr, p_lcb->transport);
BT_HDR *p_buf;
while (!list_is_empty(p_lcb->link_xmit_data_q)) {
p_buf = list_front(p_lcb->link_xmit_data_q);
list_remove(p_lcb->link_xmit_data_q, p_buf);
osi_free(p_buf);
}{...}
}{...} else
#endif
{
#if (L2CAP_NUM_FIXED_CHNLS > 0)
/* ... */
int xx;
for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++) {
if (p_lcb->p_fixed_ccbs[xx] && p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) {
#if BLE_INCLUDED == TRUE
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);/* ... */
#else
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR);/* ... */
#endif
l2cu_release_ccb (p_lcb->p_fixed_ccbs[xx]);
p_lcb->p_fixed_ccbs[xx] = NULL;
}{...}
}{...}
/* ... */#endif
}{...}
if (l2cu_create_conn(p_lcb, transport)) {
lcb_is_free = FALSE;
}{...}
}{...}
p_lcb->p_pending_ccb = NULL;
#if (BLE_INCLUDED == TRUE)
if(reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT && p_lcb->transport == BT_TRANSPORT_LE) {
#if (GATTC_CONNECT_RETRY_EN == TRUE)
if(p_lcb->link_role == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
L2CAP_TRACE_DEBUG("master retry connect, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
p_lcb->retry_create_con ++;
if (l2cu_create_conn(p_lcb, BT_TRANSPORT_LE)) {
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
lcb_is_free = FALSE;
}{...}
}{...}
/* ... */#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
p_lcb->retry_create_con ++;
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
BTM_BleStartExtAdvRestart(handle);
}{...}
/* ... */#endif
#if (BLE_42_FEATURE_SUPPORT == TRUE)
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
p_lcb->retry_create_con ++;
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
btm_ble_start_adv();
}{...}
/* ... */#endif
}{...}
/* ... */
#endif
if (lcb_is_free) {
l2cu_release_lcb (p_lcb);
}{...}
}{...}
if (lcb_is_free && ((p_lcb = l2cu_find_lcb_by_state(LST_CONNECT_HOLDING)) != NULL)) {
l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR);
}{...}
return status;
}{ ... }
/* ... */
BOOLEAN l2c_link_hci_qos_violation (UINT16 handle)
{
tL2C_LCB *p_lcb;
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
#endif
p_lcb = l2cu_find_lcb_by_handle (handle);
if (!p_lcb) {
return (FALSE);
}{...}
#if (CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) {
if (p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb) {
l2c_csm_execute (p_ccb, L2CEVT_LP_QOS_VIOLATION_IND, NULL);
}{...}
}{...}
#endif/* ... */
return (TRUE);
}{ ... }
/* ... */
void l2c_link_timeout (tL2C_LCB *p_lcb)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CCB *p_ccb;
#endif
#if (SMP_INCLUDED == TRUE)
UINT16 timeout;
tBTM_STATUS rc;/* ... */
#endif
L2CAP_TRACE_EVENT ("L2CAP - l2c_link_timeout() link state %d first CCB %p is_bonding:%d",
p_lcb->link_state, p_lcb->ccb_queue.p_first_ccb, p_lcb->is_bonding);
if ((p_lcb->link_state == LST_CONNECTING_WAIT_SWITCH) ||
(p_lcb->link_state == LST_CONNECTING) ||
(p_lcb->link_state == LST_CONNECT_HOLDING) ||
(p_lcb->link_state == LST_DISCONNECTING)) {
p_lcb->p_pending_ccb = NULL;
#if (CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) {
tL2C_CCB *pn = p_ccb->p_next_ccb;
l2c_csm_execute (p_ccb, L2CEVT_LP_DISCONNECT_IND, NULL);
p_ccb = pn;
}{...}
#endif/* ... */
#if (BLE_INCLUDED == TRUE)
if (p_lcb->link_state == LST_CONNECTING &&
l2cb.is_ble_connecting == TRUE) {
L2CA_CancelBleConnectReq(l2cb.ble_connecting_bda);
}{...}
#endif/* ... */
l2cu_release_lcb (p_lcb);
}{...}
if (p_lcb->link_state == LST_CONNECTED) {
if (p_lcb->p_echo_rsp_cb) {
tL2CA_ECHO_RSP_CB *p_cb = p_lcb->p_echo_rsp_cb;
p_lcb->p_echo_rsp_cb = NULL;
(*p_cb) (L2CAP_PING_RESULT_NO_RESP);
L2CAP_TRACE_WARNING ("L2CAP - ping timeout");
#if (CLASSIC_BT_INCLUDED == TRUE)
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; ) {
tL2C_CCB *pn = p_ccb->p_next_ccb;
l2c_csm_execute (p_ccb, L2CEVT_LP_DISCONNECT_IND, NULL);
p_ccb = pn;
}{...}
#endif/* ... */
}{...}
#if (SMP_INCLUDED == TRUE)
if (!p_lcb->ccb_queue.p_first_ccb) {
rc = btm_sec_disconnect (p_lcb->handle, HCI_ERR_PEER_USER);
if (rc == BTM_CMD_STORED) {
timeout = 0xFFFF;
}{...} else if (rc == BTM_CMD_STARTED) {
p_lcb->link_state = LST_DISCONNECTING;
timeout = L2CAP_LINK_DISCONNECT_TOUT;
}{...} else if (rc == BTM_SUCCESS) {
l2cu_process_fixed_disc_cback(p_lcb);
p_lcb->link_state = LST_DISCONNECTING;
timeout = 0xFFFF;
}{...} else if (rc == BTM_BUSY) {
timeout = 0xFFFF;
}{...} else if ((p_lcb->is_bonding)
&& (btsnd_hcic_disconnect (p_lcb->handle, HCI_ERR_PEER_USER))) {
l2cu_process_fixed_disc_cback(p_lcb);
p_lcb->link_state = LST_DISCONNECTING;
timeout = L2CAP_LINK_DISCONNECT_TOUT;
}{...} else {
timeout = BT_1SEC_TIMEOUT;
}{...}
if (timeout != 0xFFFF) {
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, timeout);
}{...}
}{...} else {
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
}{...}
#endif/* ... */
}{...}
}{ ... }
/* ... */
void l2c_info_timeout (tL2C_LCB *p_lcb)
{
tL2C_CCB *p_ccb;
#if (CLASSIC_BT_INCLUDED == TRUE)
tL2C_CONN_INFO ci;
#endif
if (p_lcb->w4_info_rsp) {
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) {
if ( (p_ccb->chnl_state == CST_ORIG_W4_SEC_COMP) || (p_ccb->chnl_state == CST_TERM_W4_SEC_COMP) ) {
btu_start_timer (&p_lcb->info_timer_entry, BTU_TTYPE_L2CAP_INFO, L2CAP_WAIT_INFO_RSP_TOUT);
return;
}{...}
}{...}
p_lcb->w4_info_rsp = FALSE;
#if (CLASSIC_BT_INCLUDED == TRUE)
if ((p_lcb->link_state != LST_DISCONNECTED) &&
(p_lcb->link_state != LST_DISCONNECTING)) {
if (p_lcb->ccb_queue.p_first_ccb) {
ci.status = HCI_SUCCESS;
memcpy (ci.bd_addr, p_lcb->remote_bd_addr, sizeof(BD_ADDR));
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) {
l2c_csm_execute (p_ccb, L2CEVT_L2CAP_INFO_RSP, &ci);
}{...}
}{...}
}{...}
#endif/* ... */
}{...}
}{ ... }
/* ... */
void l2c_link_adjust_allocation (void)
{
UINT16 qq, qq_remainder;
tL2C_LCB *p_lcb;
UINT16 hi_quota, low_quota;
UINT16 num_lowpri_links = 0;
UINT16 num_hipri_links = 0;
UINT16 controller_xmit_quota = l2cb.num_lm_acl_bufs;
UINT16 high_pri_link_quota = L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A;
list_node_t *p_node = NULL;
if (l2cb.num_links_active == 0) {
l2cb.controller_xmit_window = l2cb.num_lm_acl_bufs;
l2cb.round_robin_quota = l2cb.round_robin_unacked = 0;
return;
}{...}
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (p_lcb->in_use) {
if (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH) {
num_hipri_links++;
}{...} else {
num_lowpri_links++;
}{...}
}{...}
}{...}
low_quota = num_lowpri_links ? 1 : 0;
while ( (num_hipri_links * high_pri_link_quota + low_quota) > controller_xmit_quota ) {
high_pri_link_quota--;
}{...}
hi_quota = num_hipri_links * high_pri_link_quota;
low_quota = (hi_quota < controller_xmit_quota) ? controller_xmit_quota - hi_quota : 1;
if (num_lowpri_links > low_quota) {
l2cb.round_robin_quota = low_quota;
qq = qq_remainder = 1;
}{...}
else if (num_lowpri_links > 0) {
l2cb.round_robin_quota = 0;
l2cb.round_robin_unacked = 0;
qq = low_quota / num_lowpri_links;
qq_remainder = low_quota % num_lowpri_links;
}{...}
else {
l2cb.round_robin_quota = 0;
l2cb.round_robin_unacked = 0;
qq = qq_remainder = 1;
}{...}
L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation num_hipri: %u num_lowpri: %u low_quota: %u round_robin_quota: %u qq: %u\n",
num_hipri_links, num_lowpri_links, low_quota,
l2cb.round_robin_quota, qq);
p_node = NULL;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (p_lcb->in_use) {
if (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH) {
p_lcb->link_xmit_quota = high_pri_link_quota;
}{...} else {
if (( p_lcb->link_xmit_quota > 0 ) && ( qq == 0 )) {
l2cb.round_robin_unacked += p_lcb->sent_not_acked;
}{...}
p_lcb->link_xmit_quota = qq;
if (qq_remainder > 0) {
p_lcb->link_xmit_quota++;
qq_remainder--;
}{...}
}{...}
L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation Priority: %d XmitQuota: %d\n",
p_lcb->acl_priority, p_lcb->link_xmit_quota);
L2CAP_TRACE_EVENT (" SentNotAcked: %d RRUnacked: %d\n",
p_lcb->sent_not_acked, l2cb.round_robin_unacked);
if ( (p_lcb->link_state == LST_CONNECTED)
&& (!list_is_empty(p_lcb->link_xmit_data_q))
&& (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) {
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT);
}{...}
}{...}
}{...}
}{ ... }
/* ... */
bool l2c_chnl_allocation_in_ccb_list (void *p_ccb_node, void *context)
{
UNUSED(context);
tL2C_CCB *p_ccb = (tL2C_CCB *)p_ccb_node;
if (p_ccb->in_use) {
tL2CAP_CHNL_DATA_RATE data_rate = p_ccb->tx_data_rate + p_ccb->rx_data_rate;
p_ccb->buff_quota = L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA * data_rate;
L2CAP_TRACE_EVENT("CID:0x%04x FCR Mode:%u Priority:%u TxDataRate:%u RxDataRate:%u Quota:%u",
p_ccb->local_cid, p_ccb->peer_cfg.fcr.mode,
p_ccb->ccb_priority, p_ccb->tx_data_rate,
p_ccb->rx_data_rate, p_ccb->buff_quota);
l2cu_check_channel_congestion (p_ccb);
}{...}
return false;
}{ ... }
void l2c_link_adjust_chnl_allocation (void)
{
L2CAP_TRACE_DEBUG ("l2c_link_adjust_chnl_allocation");
list_foreach(l2cb.p_ccb_pool, l2c_chnl_allocation_in_ccb_list, NULL);
}{ ... }
/* ... */
void l2c_link_processs_num_bufs (UINT16 num_lm_acl_bufs)
{
l2cb.num_lm_acl_bufs = l2cb.controller_xmit_window = num_lm_acl_bufs;
}{ ... }
/* ... */
UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles)
{
UINT8 num_found = 0;
UNUSED(num_pkts);
UNUSED(handles);
return (num_found);
}{ ... }
/* ... */
void l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status)
{
tL2C_LCB *p_lcb;
if (bd_addr) {
p_lcb = l2cu_find_lcb_by_bd_addr (bd_addr, BT_TRANSPORT_BR_EDR);
if (p_lcb) {
p_lcb->link_role = new_role;
if (hci_status == HCI_SUCCESS) {
l2cu_set_acl_priority(bd_addr, p_lcb->acl_priority, TRUE);
}{...}
}{...}
}{...}
list_node_t *p_node = NULL;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if ((p_lcb->in_use) && (p_lcb->link_state == LST_CONNECTING_WAIT_SWITCH)) {
l2cu_create_conn_after_switch (p_lcb);
}{...}
}{...}
}{ ... }
/* ... */
void l2c_pin_code_request (BD_ADDR bd_addr)
{
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr (bd_addr, BT_TRANSPORT_BR_EDR);
if ( (p_lcb) && (!p_lcb->ccb_queue.p_first_ccb) ) {
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_CONNECT_TOUT_EXT);
}{...}
}{ ... }
#if L2CAP_WAKE_PARKED_LINK == TRUE
/* ... */
BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
{
tBTM_PM_MODE mode;
tL2C_CCB *p_ccb;
BOOLEAN need_to_active = FALSE;
/* ... */
if (list_is_empty(p_lcb->link_xmit_data_q)) {
for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) {
if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) {
need_to_active = TRUE;
break;
}{...}
}{...}
}{...} else {
need_to_active = TRUE;
}{...}
if ( need_to_active ) {
if (BTM_ReadPowerMode(p_lcb->remote_bd_addr, &mode) == BTM_SUCCESS) {
if ( mode == BTM_PM_STS_PENDING ) {
L2CAP_TRACE_DEBUG ("LCB(0x%x) is in PM pending state\n", p_lcb->handle);
return TRUE;
}{...}
}{...}
}{...}
return FALSE;
}{ ... }
#endif/* ... */
/* ... */
void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
{
BOOLEAN single_write = FALSE;
L2CAP_TRACE_DEBUG("%s",__func__);
if (p_buf) {
if (p_ccb != NULL) {
p_buf->event = p_ccb->local_cid;
single_write = TRUE;
}{...} else {
p_buf->event = 0;
}{...}
p_buf->layer_specific = 0;
list_append(p_lcb->link_xmit_data_q, p_buf);
if (p_lcb->link_xmit_quota == 0) {
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
l2cb.ble_check_round_robin = TRUE;
}{...} else
#endif
{
l2cb.check_round_robin = TRUE;
}{...}
}{...}
}{...}
/* ... */
if (l2cb.is_cong_cback_context) {
L2CAP_TRACE_ERROR("l2cab is_cong_cback_context");
return;
}{...}
/* ... */
if ( (p_lcb == NULL) || (p_lcb->link_xmit_quota == 0) ) {
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb_cur = NULL;
if (p_lcb == NULL) {
p_node = list_begin(l2cb.p_lcb_pool);
p_lcb = list_node(p_node);
}{...} else if (!single_write) {
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb_cur = list_node(p_node);
if (p_lcb_cur == p_lcb) {
p_node = list_next(p_node);
p_lcb = list_node(p_node);
break;
}{...}
}{...}
}{...}
for ( ; p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
#if (BLE_INCLUDED == TRUE)
L2CAP_TRACE_DEBUG("window = %d,robin_unacked = %d,robin_quota=%d",l2cb.controller_le_xmit_window,l2cb.ble_round_robin_unacked,l2cb.ble_round_robin_quota);
#endif
if (((l2cb.controller_xmit_window == 0 ||
(l2cb.round_robin_unacked >= l2cb.round_robin_quota))
#if (BLE_INCLUDED == TRUE)
&& (p_lcb->transport == BT_TRANSPORT_BR_EDR)
)
|| (p_lcb->transport == BT_TRANSPORT_LE &&
(l2cb.ble_round_robin_unacked >= l2cb.ble_round_robin_quota ||
l2cb.controller_le_xmit_window == 0 )))/* ... */
#else
))
#endif
break;
if (p_node == list_end(l2cb.p_lcb_pool)) {
p_node = list_begin(l2cb.p_lcb_pool);
p_lcb = list_node(p_node);
}{...}
L2CAP_TRACE_DEBUG("in_use=%d,segment_being_sent=%d,link_state=%d,link_xmit_quota=%d",p_lcb->in_use,p_lcb->partial_segment_being_sent,p_lcb->link_state,p_lcb->link_xmit_quota);
if ( (!p_lcb->in_use)
|| (p_lcb->partial_segment_being_sent)
|| (p_lcb->link_state != LST_CONNECTED)
|| (p_lcb->link_xmit_quota != 0)
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
continue;
}{...}
if (!list_is_empty(p_lcb->link_xmit_data_q)) {
p_buf = (BT_HDR *)list_front(p_lcb->link_xmit_data_q);
list_remove(p_lcb->link_xmit_data_q, p_buf);
l2c_link_send_to_lower (p_lcb, p_buf);
}{...} else if (single_write) {
break;
}{...}
else if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) != NULL) {
l2c_link_send_to_lower (p_lcb, p_buf);
}{...}
}{...}
if ( (l2cb.controller_xmit_window > 0)
&& (l2cb.round_robin_unacked < l2cb.round_robin_quota)
#if (BLE_INCLUDED == TRUE)
&& (p_lcb->transport == BT_TRANSPORT_BR_EDR)
#endif
) {
l2cb.check_round_robin = FALSE;
}{...}
#if (BLE_INCLUDED == TRUE)
if ( (l2cb.controller_le_xmit_window > 0)
&& (l2cb.ble_round_robin_unacked < l2cb.ble_round_robin_quota)
&& (p_lcb->transport == BT_TRANSPORT_LE)) {
l2cb.ble_check_round_robin = FALSE;
}{...}
#endif/* ... */
}{...} else {
L2CAP_TRACE_DEBUG("partial_segment_being_sent=%d,link_state=%d,power_mode=%d",p_lcb->partial_segment_being_sent,p_lcb->link_state,L2C_LINK_CHECK_POWER_MODE (p_lcb));
if ( (p_lcb->partial_segment_being_sent)
|| (p_lcb->link_state != LST_CONNECTED)
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
return;
}{...}
#if (BLE_INCLUDED == TRUE)
while ( ((l2cb.controller_xmit_window != 0 && (p_lcb->transport == BT_TRANSPORT_BR_EDR)) ||
(l2cb.controller_le_xmit_window != 0 && (p_lcb->transport == BT_TRANSPORT_LE)))
&& (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))/* ... */
#else
while ( (l2cb.controller_xmit_window != 0)
&& (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))/* ... */
#endif
{
if (list_is_empty(p_lcb->link_xmit_data_q)) {
break;
}{...}
p_buf = (BT_HDR *)list_front(p_lcb->link_xmit_data_q);
list_remove(p_lcb->link_xmit_data_q, p_buf);
if (!l2c_link_send_to_lower (p_lcb, p_buf)) {
break;
}{...}
}{...}
if (!single_write) {
#if (BLE_INCLUDED == TRUE)
while ( ((l2cb.controller_xmit_window != 0 && (p_lcb->transport == BT_TRANSPORT_BR_EDR)) ||
(l2cb.controller_le_xmit_window != 0 && (p_lcb->transport == BT_TRANSPORT_LE)))
&& (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))/* ... */
#else
while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))
#endif
{
if ( (p_lcb->partial_segment_being_sent)
|| (p_lcb->link_state != LST_CONNECTED)
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
break;
}{...}
if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) {
break;
}{...}
if (!l2c_link_send_to_lower (p_lcb, p_buf)) {
break;
}{...}
}{...}
}{...}
if ( (!list_is_empty(p_lcb->link_xmit_data_q)) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) ) {
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT);
}{...}
}{...}
}{ ... }
/* ... */
static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf)
{
UINT16 num_segs;
UINT16 xmit_window, acl_data_size;
const controller_t *controller = controller_get_interface();
L2CAP_TRACE_DEBUG("%s",__func__);
if ((p_buf->len <= controller->get_acl_packet_size_classic()
#if (BLE_INCLUDED == TRUE)
&& (p_lcb->transport == BT_TRANSPORT_BR_EDR)) ||
((p_lcb->transport == BT_TRANSPORT_LE) && (p_buf->len <= controller->get_acl_packet_size_ble()))/* ... */
#else
)
#endif
) {
if (p_lcb->link_xmit_quota == 0) {
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE) {
l2cb.ble_round_robin_unacked++;
}{...} else/* ... */
#endif
l2cb.round_robin_unacked++;
}{...}
p_lcb->sent_not_acked++;
p_buf->layer_specific = 0;
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE) {
l2cb.controller_le_xmit_window--;
bte_main_hci_send(p_buf, (UINT16)(BT_EVT_TO_LM_HCI_ACL | LOCAL_BLE_CONTROLLER_ID));
}{...} else
#endif
{
l2cb.controller_xmit_window--;
bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL);
}{...}
}{...} else {
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
acl_data_size = controller->get_acl_data_size_ble();
xmit_window = l2cb.controller_le_xmit_window;
}{...} else
#endif
{
acl_data_size = controller->get_acl_data_size_classic();
xmit_window = l2cb.controller_xmit_window;
}{...}
num_segs = (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) / acl_data_size;
if (p_lcb->link_xmit_quota == 0) {
num_segs = 1;
p_lcb->partial_segment_being_sent = TRUE;
}{...} else {
if (num_segs > xmit_window) {
num_segs = xmit_window;
p_lcb->partial_segment_being_sent = TRUE;
}{...}
if (num_segs > (p_lcb->link_xmit_quota - p_lcb->sent_not_acked)) {
num_segs = (p_lcb->link_xmit_quota - p_lcb->sent_not_acked);
p_lcb->partial_segment_being_sent = TRUE;
}{...}
}{...}
p_buf->layer_specific = num_segs;
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
l2cb.controller_le_xmit_window -= num_segs;
if (p_lcb->link_xmit_quota == 0) {
l2cb.ble_round_robin_unacked += num_segs;
}{...}
}{...} else
#endif
{
l2cb.controller_xmit_window -= num_segs;
if (p_lcb->link_xmit_quota == 0) {
l2cb.round_robin_unacked += num_segs;
}{...}
}{...}
p_lcb->sent_not_acked += num_segs;
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
bte_main_hci_send(p_buf, (UINT16)(BT_EVT_TO_LM_HCI_ACL | LOCAL_BLE_CONTROLLER_ID));
}{...} else
#endif
{
bte_main_hci_send(p_buf, BT_EVT_TO_LM_HCI_ACL);
}{...}
}{...}
#if (L2CAP_HCI_FLOW_CONTROL_DEBUG == TRUE)
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE) {
L2CAP_TRACE_DEBUG ("TotalWin=%d,Hndl=0x%x,Quota=%d,Unack=%d,RRQuota=%d,RRUnack=%d",
l2cb.controller_le_xmit_window,
p_lcb->handle,
p_lcb->link_xmit_quota, p_lcb->sent_not_acked,
l2cb.ble_round_robin_quota, l2cb.ble_round_robin_unacked);
}{...} else
#endif
{
L2CAP_TRACE_DEBUG ("TotalWin=%d,Hndl=0x%x,Quota=%d,Unack=%d,RRQuota=%d,RRUnack=%d",
l2cb.controller_xmit_window,
p_lcb->handle,
p_lcb->link_xmit_quota, p_lcb->sent_not_acked,
l2cb.round_robin_quota, l2cb.round_robin_unacked);
}{...}
#endif/* ... */
return TRUE;
}{ ... }
/* ... */
void l2c_link_process_num_completed_pkts (UINT8 *p)
{
UINT8 num_handles, xx;
UINT16 handle;
UINT16 num_sent;
tL2C_LCB *p_lcb;
STREAM_TO_UINT8 (num_handles, p);
for (xx = 0; xx < num_handles; xx++) {
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT16 (num_sent, p);
p_lcb = l2cu_find_lcb_by_handle (handle);
if ((p_lcb != NULL) && (p_lcb->p_nocp_cb)) {
L2CAP_TRACE_DEBUG ("L2CAP - calling NoCP callback");
(*p_lcb->p_nocp_cb)(p_lcb->remote_bd_addr);
}{...}
if (p_lcb) {
#if (BLE_INCLUDED == TRUE)
if (p_lcb && (p_lcb->transport == BT_TRANSPORT_LE)) {
l2cb.controller_le_xmit_window += num_sent;
}{...} else
#endif
{
l2cb.controller_xmit_window += num_sent;
}{...}
if (p_lcb->link_xmit_quota == 0) {
#if BLE_INCLUDED == TRUE
if (p_lcb->transport == BT_TRANSPORT_LE) {
if (l2cb.ble_round_robin_unacked > num_sent) {
l2cb.ble_round_robin_unacked -= num_sent;
}{...} else {
l2cb.ble_round_robin_unacked = 0;
}{...}
}{...} else
#endif
{
if (l2cb.round_robin_unacked > num_sent) {
l2cb.round_robin_unacked -= num_sent;
}{...} else {
l2cb.round_robin_unacked = 0;
}{...}
}{...}
}{...}
if (p_lcb->sent_not_acked > num_sent) {
p_lcb->sent_not_acked -= num_sent;
}{...} else {
p_lcb->sent_not_acked = 0;
}{...}
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
if ( (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)
&& (l2cb.check_round_robin)
&& (l2cb.round_robin_unacked < l2cb.round_robin_quota) ) {
l2c_link_check_send_pkts (NULL, NULL, NULL);
}{...}
#if BLE_INCLUDED == TRUE
if ((p_lcb->transport == BT_TRANSPORT_LE)
&& (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)
&& ((l2cb.ble_check_round_robin)
&& (l2cb.ble_round_robin_unacked < l2cb.ble_round_robin_quota))) {
l2c_link_check_send_pkts (NULL, NULL, NULL);
}{...}
#endif/* ... */
}{...}
#if (L2CAP_HCI_FLOW_CONTROL_DEBUG == TRUE)
if (p_lcb) {
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE) {
L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d\n",
l2cb.controller_le_xmit_window,
p_lcb->handle, p_lcb->sent_not_acked,
l2cb.ble_check_round_robin, l2cb.ble_round_robin_unacked);
}{...} else
#endif
{
L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d\n",
l2cb.controller_xmit_window,
p_lcb->handle, p_lcb->sent_not_acked,
l2cb.check_round_robin, l2cb.round_robin_unacked);
}{...}
}{...} else {
#if (BLE_INCLUDED == TRUE)
L2CAP_TRACE_DEBUG ("TotalWin=%d LE_Win: %d, Handle=0x%x, RRCheck=%d, RRUnack=%d\n",
l2cb.controller_xmit_window,
l2cb.controller_le_xmit_window,
handle,
l2cb.ble_check_round_robin, l2cb.ble_round_robin_unacked);/* ... */
#else
L2CAP_TRACE_DEBUG ("TotalWin=%d Handle=0x%x RRCheck=%d RRUnack=%d\n",
l2cb.controller_xmit_window,
handle,
l2cb.check_round_robin, l2cb.round_robin_unacked);/* ... */
#endif
}{...}
#endif/* ... */
}{...}
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
btu_check_bt_sleep ();/* ... */
#endif
}{ ... }
/* ... */
void l2c_link_segments_xmitted (BT_HDR *p_msg)
{
UINT8 *p = (UINT8 *)(p_msg + 1) + p_msg->offset;
UINT16 handle;
tL2C_LCB *p_lcb;
STREAM_TO_UINT16 (handle, p);
handle = HCID_GET_HANDLE (handle);
if ((p_lcb = l2cu_find_lcb_by_handle (handle)) == NULL) {
L2CAP_TRACE_WARNING ("L2CAP - rcvd segment complete, unknown handle: %d\n", handle);
osi_free (p_msg);
return;
}{...}
if (p_lcb->link_state == LST_CONNECTED) {
list_prepend(p_lcb->link_xmit_data_q, p_msg);
p_lcb->partial_segment_being_sent = FALSE;
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
}{...} else {
osi_free (p_msg);
}{...}
}{ ... }