]> granicus.if.org Git - esp-idf/blob - components/bt/bluedroid/stack/l2cap/include/l2c_int.h
component/bt: Add Controller to Host Flow Control
[esp-idf] / components / bt / bluedroid / stack / l2cap / include / l2c_int.h
1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18
19 /******************************************************************************
20  *
21  *  This file contains L2CAP internal definitions
22  *
23  ******************************************************************************/
24 #ifndef L2C_INT_H
25 #define L2C_INT_H
26
27 #include <stdbool.h>
28
29 #include "stack/btm_api.h"
30 #include "stack/l2c_api.h"
31 #include "stack/l2cdefs.h"
32 #include "osi/list.h"
33 #include "osi/fixed_queue.h"
34
35 #define L2CAP_MIN_MTU   48      /* Minimum acceptable MTU is 48 bytes */
36
37 /* LE credit based L2CAP connection parameters */
38 #define L2CAP_LE_MIN_MTU            23
39 #define L2CAP_LE_MIN_MPS            23
40 #define L2CAP_LE_MAX_MPS            65533
41 #define L2CAP_LE_MIN_CREDIT         0
42 #define L2CAP_LE_MAX_CREDIT         65535
43 #define L2CAP_LE_DEFAULT_MTU        512
44 #define L2CAP_LE_DEFAULT_MPS        23
45 #define L2CAP_LE_DEFAULT_CREDIT     1
46
47
48 /* Timeouts. Since L2CAP works off a 1-second list, all are in seconds.
49 */
50 #define L2CAP_LINK_ROLE_SWITCH_TOUT  10           /* 10 seconds */
51 #define L2CAP_LINK_CONNECT_TOUT      60           /* 30 seconds */
52 #define L2CAP_LINK_CONNECT_TOUT_EXT  120          /* 120 seconds */
53 #define L2CAP_ECHO_RSP_TOUT          30           /* 30 seconds */
54 #define L2CAP_LINK_FLOW_CONTROL_TOUT 2            /* 2  seconds */
55 #define L2CAP_LINK_DISCONNECT_TOUT   30           /* 30 seconds */
56
57 #ifndef L2CAP_CHNL_CONNECT_TOUT      /* BTIF needs to override for internal project needs */
58 #define L2CAP_CHNL_CONNECT_TOUT      60           /* 60 seconds */
59 #endif
60
61 #define L2CAP_CHNL_CONNECT_TOUT_EXT  120          /* 120 seconds */
62 #define L2CAP_CHNL_CFG_TIMEOUT       30           /* 30 seconds */
63 #define L2CAP_CHNL_DISCONNECT_TOUT   10           /* 10 seconds */
64 #define L2CAP_DELAY_CHECK_SM4        2            /* 2 seconds */
65 #define L2CAP_WAIT_INFO_RSP_TOUT     3            /* 3 seconds */
66 #define L2CAP_WAIT_UNPARK_TOUT       2            /* 2 seconds */
67 #define L2CAP_LINK_INFO_RESP_TOUT    2            /* 2 seconds */
68 #define L2CAP_UPDATE_CONN_PARAM_TOUT 6            /* 6 seconds */
69 #define L2CAP_BLE_LINK_CONNECT_TOUT  30           /* 30 seconds */
70 #define L2CAP_BLE_CONN_PARAM_UPD_TOUT   30        /* 30 seconds */
71
72 /* quick timer uses millisecond unit */
73 #define L2CAP_DEFAULT_RETRANS_TOUT   2000         /* 2000 milliseconds */
74 #define L2CAP_DEFAULT_MONITOR_TOUT   12000        /* 12000 milliseconds */
75 #define L2CAP_FCR_ACK_TOUT           200          /* 200 milliseconds */
76
77 /* Define the possible L2CAP channel states. The names of
78 ** the states may seem a bit strange, but they are taken from
79 ** the Bluetooth specification.
80 */
81 typedef enum {
82     CST_CLOSED,                           /* Channel is in clodes state           */
83     CST_ORIG_W4_SEC_COMP,                 /* Originator waits security clearence  */
84     CST_TERM_W4_SEC_COMP,                 /* Acceptor waits security clearence    */
85     CST_W4_L2CAP_CONNECT_RSP,             /* Waiting for peer conenct response    */
86     CST_W4_L2CA_CONNECT_RSP,              /* Waiting for upper layer connect rsp  */
87     CST_CONFIG,                           /* Negotiating configuration            */
88     CST_OPEN,                             /* Data transfer state                  */
89     CST_W4_L2CAP_DISCONNECT_RSP,          /* Waiting for peer disconnect rsp      */
90     CST_W4_L2CA_DISCONNECT_RSP            /* Waiting for upper layer disc rsp     */
91 } tL2C_CHNL_STATE;
92
93 /* Define the possible L2CAP link states
94 */
95 typedef enum {
96     LST_DISCONNECTED,
97     LST_CONNECT_HOLDING,
98     LST_CONNECTING_WAIT_SWITCH,
99     LST_CONNECTING,
100     LST_CONNECTED,
101     LST_DISCONNECTING
102 } tL2C_LINK_STATE;
103
104
105
106 /* Define input events to the L2CAP link and channel state machines. The names
107 ** of the events may seem a bit strange, but they are taken from
108 ** the Bluetooth specification.
109 */
110 #define L2CEVT_LP_CONNECT_CFM          0          /* Lower layer connect confirm          */
111 #define L2CEVT_LP_CONNECT_CFM_NEG      1          /* Lower layer connect confirm (failed) */
112 #define L2CEVT_LP_CONNECT_IND          2          /* Lower layer connect indication       */
113 #define L2CEVT_LP_DISCONNECT_IND       3          /* Lower layer disconnect indication    */
114 #define L2CEVT_LP_QOS_CFM              4          /* Lower layer QOS confirmation         */
115 #define L2CEVT_LP_QOS_CFM_NEG          5          /* Lower layer QOS confirmation (failed)*/
116 #define L2CEVT_LP_QOS_VIOLATION_IND    6          /* Lower layer QOS violation indication */
117
118 #define L2CEVT_SEC_COMP                7          /* Security cleared successfully        */
119 #define L2CEVT_SEC_COMP_NEG            8          /* Security procedure failed            */
120
121 #define L2CEVT_L2CAP_CONNECT_REQ      10          /* Peer connection request              */
122 #define L2CEVT_L2CAP_CONNECT_RSP      11          /* Peer connection response             */
123 #define L2CEVT_L2CAP_CONNECT_RSP_PND  12          /* Peer connection response pending     */
124 #define L2CEVT_L2CAP_CONNECT_RSP_NEG  13          /* Peer connection response (failed)    */
125 #define L2CEVT_L2CAP_CONFIG_REQ       14          /* Peer configuration request           */
126 #define L2CEVT_L2CAP_CONFIG_RSP       15          /* Peer configuration response          */
127 #define L2CEVT_L2CAP_CONFIG_RSP_NEG   16          /* Peer configuration response (failed) */
128 #define L2CEVT_L2CAP_DISCONNECT_REQ   17          /* Peer disconnect request              */
129 #define L2CEVT_L2CAP_DISCONNECT_RSP   18          /* Peer disconnect response             */
130 #define L2CEVT_L2CAP_INFO_RSP         19          /* Peer information response            */
131 #define L2CEVT_L2CAP_DATA             20          /* Peer data                            */
132
133 #define L2CEVT_L2CA_CONNECT_REQ       21          /* Upper layer connect request          */
134 #define L2CEVT_L2CA_CONNECT_RSP       22          /* Upper layer connect response         */
135 #define L2CEVT_L2CA_CONNECT_RSP_NEG   23          /* Upper layer connect response (failed)*/
136 #define L2CEVT_L2CA_CONFIG_REQ        24          /* Upper layer config request           */
137 #define L2CEVT_L2CA_CONFIG_RSP        25          /* Upper layer config response          */
138 #define L2CEVT_L2CA_CONFIG_RSP_NEG    26          /* Upper layer config response (failed) */
139 #define L2CEVT_L2CA_DISCONNECT_REQ    27          /* Upper layer disconnect request       */
140 #define L2CEVT_L2CA_DISCONNECT_RSP    28          /* Upper layer disconnect response      */
141 #define L2CEVT_L2CA_DATA_READ         29          /* Upper layer data read                */
142 #define L2CEVT_L2CA_DATA_WRITE        30          /* Upper layer data write               */
143 #define L2CEVT_L2CA_FLUSH_REQ         31          /* Upper layer flush                    */
144
145 #define L2CEVT_TIMEOUT                32          /* Timeout                              */
146 #define L2CEVT_SEC_RE_SEND_CMD        33          /* btm_sec has enough info to proceed   */
147
148 #define L2CEVT_ACK_TIMEOUT            34          /* RR delay timeout                     */
149
150
151 /* Bitmask to skip over Broadcom feature reserved (ID) to avoid sending two
152    successive ID values, '0' id only or both */
153 #define L2CAP_ADJ_BRCM_ID           0x1
154 #define L2CAP_ADJ_ZERO_ID           0x2
155 #define L2CAP_ADJ_ID                0x3
156
157 /* Return values for l2cu_process_peer_cfg_req() */
158 #define L2CAP_PEER_CFG_UNACCEPTABLE     0
159 #define L2CAP_PEER_CFG_OK               1
160 #define L2CAP_PEER_CFG_DISCONNECT       2
161
162 /* eL2CAP option constants */
163 #define L2CAP_MIN_RETRANS_TOUT          2000    /* Min retransmission timeout if no flush timeout or PBF */
164 #define L2CAP_MIN_MONITOR_TOUT          12000   /* Min monitor timeout if no flush timeout or PBF */
165
166 #define L2CAP_MAX_FCR_CFG_TRIES         2       /* Config attempts before disconnecting */
167
168 typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
169
170 typedef struct {
171     UINT8       next_tx_seq;                /* Next sequence number to be Tx'ed         */
172     UINT8       last_rx_ack;                /* Last sequence number ack'ed by the peer  */
173     UINT8       next_seq_expected;          /* Next peer sequence number expected       */
174     UINT8       last_ack_sent;              /* Last peer sequence number ack'ed         */
175     UINT8       num_tries;                  /* Number of retries to send a packet       */
176     UINT8       max_held_acks;              /* Max acks we can hold before sending      */
177
178     BOOLEAN     remote_busy;                /* TRUE if peer has flowed us off           */
179     BOOLEAN     local_busy;                 /* TRUE if we have flowed off the peer      */
180
181     BOOLEAN     rej_sent;                   /* Reject was sent                          */
182     BOOLEAN     srej_sent;                  /* Selective Reject was sent                */
183     BOOLEAN     wait_ack;                   /* Transmitter is waiting ack (poll sent)   */
184     BOOLEAN     rej_after_srej;             /* Send a REJ when SREJ clears              */
185
186     BOOLEAN     send_f_rsp;                 /* We need to send an F-bit response        */
187
188     UINT16      rx_sdu_len;                 /* Length of the SDU being received         */
189     BT_HDR      *p_rx_sdu;                  /* Buffer holding the SDU being received    */
190     fixed_queue_t    *waiting_for_ack_q;          /* Buffers sent and waiting for peer to ack */
191     fixed_queue_t    *srej_rcv_hold_q;            /* Buffers rcvd but held pending SREJ rsp   */
192     fixed_queue_t    *retrans_q;                  /* Buffers being retransmitted              */
193
194     TIMER_LIST_ENT ack_timer;               /* Timer delaying RR                        */
195     TIMER_LIST_ENT mon_retrans_timer;       /* Timer Monitor or Retransmission          */
196
197 #if (L2CAP_ERTM_STATS == TRUE)
198     UINT32      connect_tick_count;         /* Time channel was established             */
199     UINT32      ertm_pkt_counts[2];         /* Packets sent and received                */
200     UINT32      ertm_byte_counts[2];        /* Bytes   sent and received                */
201     UINT32      s_frames_sent[4];           /* S-frames sent (RR, REJ, RNR, SREJ)       */
202     UINT32      s_frames_rcvd[4];           /* S-frames rcvd (RR, REJ, RNR, SREJ)       */
203     UINT32      xmit_window_closed;         /* # of times the xmit window was closed    */
204     UINT32      controller_idle;            /* # of times less than 2 packets in controller */
205     /* when the xmit window was closed          */
206     UINT32      pkts_retransmitted;         /* # of packets that were retransmitted     */
207     UINT32      retrans_touts;              /* # of retransmission timouts              */
208     UINT32      xmit_ack_touts;             /* # of xmit ack timouts                    */
209
210 #define L2CAP_ERTM_STATS_NUM_AVG 10
211 #define L2CAP_ERTM_STATS_AVG_NUM_SAMPLES 100
212     UINT32      ack_delay_avg_count;
213     UINT32      ack_delay_avg_index;
214     UINT32      throughput_start;
215     UINT32      throughput[L2CAP_ERTM_STATS_NUM_AVG];
216     UINT32      ack_delay_avg[L2CAP_ERTM_STATS_NUM_AVG];
217     UINT32      ack_delay_min[L2CAP_ERTM_STATS_NUM_AVG];
218     UINT32      ack_delay_max[L2CAP_ERTM_STATS_NUM_AVG];
219     UINT32      ack_q_count_avg[L2CAP_ERTM_STATS_NUM_AVG];
220     UINT32      ack_q_count_min[L2CAP_ERTM_STATS_NUM_AVG];
221     UINT32      ack_q_count_max[L2CAP_ERTM_STATS_NUM_AVG];
222 #endif
223 } tL2C_FCRB;
224
225
226 /* Define a registration control block. Every application (e.g. RFCOMM, SDP,
227 ** TCS etc) that registers with L2CAP is assigned one of these.
228 */
229 #if (L2CAP_UCD_INCLUDED == TRUE)
230 #define L2C_UCD_RCB_ID              0x00
231 #define L2C_UCD_STATE_UNUSED        0x00
232 #define L2C_UCD_STATE_W4_DATA       0x01
233 #define L2C_UCD_STATE_W4_RECEPTION  0x02
234 #define L2C_UCD_STATE_W4_MTU        0x04
235
236 typedef struct {
237     UINT8               state;
238     tL2CAP_UCD_CB_INFO  cb_info;
239 } tL2C_UCD_REG;
240 #endif
241
242 typedef struct {
243     BOOLEAN                 in_use;
244     UINT16                  psm;
245     UINT16                  real_psm;               /* This may be a dummy RCB for an o/b connection but */
246     /* this is the real PSM that we need to connect to   */
247 #if (L2CAP_UCD_INCLUDED == TRUE)
248     tL2C_UCD_REG            ucd;
249 #endif
250
251     tL2CAP_APPL_INFO        api;
252 } tL2C_RCB;
253
254 typedef void (tL2CAP_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
255                                 void *p_ref_data, tBTM_STATUS result);
256
257 typedef struct
258 {
259     UINT16                  psm;
260     tBT_TRANSPORT           transport;
261     BOOLEAN                 is_originator;
262     tL2CAP_SEC_CBACK        *p_callback;
263     void                    *p_ref_data;
264 }tL2CAP_SEC_DATA;
265
266 #ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
267 #define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
268 #endif
269 /* Define a channel control block (CCB). There may be many channel control blocks
270 ** between the same two Bluetooth devices (i.e. on the same link).
271 ** Each CCB has unique local and remote CIDs. All channel control blocks on
272 ** the same physical link and are chained together.
273 */
274 typedef struct t_l2c_ccb {
275     BOOLEAN             in_use;                 /* TRUE when in use, FALSE when not */
276     tL2C_CHNL_STATE     chnl_state;             /* Channel state                    */
277     tL2CAP_LE_CFG_INFO  local_conn_cfg;         /* Our config for ble conn oriented channel */
278     tL2CAP_LE_CFG_INFO  peer_conn_cfg;          /* Peer device config ble conn oriented channel */
279
280     struct t_l2c_ccb    *p_next_ccb;            /* Next CCB in the chain            */
281     struct t_l2c_ccb    *p_prev_ccb;            /* Previous CCB in the chain        */
282     struct t_l2c_linkcb *p_lcb;                 /* Link this CCB is assigned to     */
283
284     UINT16              local_cid;              /* Local CID                        */
285     UINT16              remote_cid;             /* Remote CID                       */
286
287     TIMER_LIST_ENT      timer_entry;            /* CCB Timer List Entry             */
288
289     tL2C_RCB            *p_rcb;                 /* Registration CB for this Channel */
290     bool                should_free_rcb;        /* True if RCB was allocated on the heap */
291
292 #define IB_CFG_DONE     0x01
293 #define OB_CFG_DONE     0x02
294 #define RECONFIG_FLAG   0x04                    /* True after initial configuration */
295 #define CFG_DONE_MASK   (IB_CFG_DONE | OB_CFG_DONE)
296
297     UINT8               config_done;            /* Configuration flag word         */
298     UINT8               local_id;               /* Transaction ID for local trans  */
299     UINT8               remote_id;              /* Transaction ID for local  */
300
301 #define CCB_FLAG_NO_RETRY       0x01            /* no more retry */
302 #define CCB_FLAG_SENT_PENDING   0x02            /* already sent pending response */
303     UINT8               flags;
304
305     tL2CAP_CFG_INFO     our_cfg;                /* Our saved configuration options    */
306     tL2CAP_CH_CFG_BITS  peer_cfg_bits;          /* Store what peer wants to configure */
307     tL2CAP_CFG_INFO     peer_cfg;               /* Peer's saved configuration options */
308
309     fixed_queue_t       *xmit_hold_q;            /* Transmit data hold queue         */
310     BOOLEAN             cong_sent;              /* Set when congested status sent   */
311     UINT16              buff_quota;             /* Buffer quota before sending congestion   */
312
313     tL2CAP_CHNL_PRIORITY ccb_priority;          /* Channel priority                 */
314     tL2CAP_CHNL_DATA_RATE tx_data_rate;         /* Channel Tx data rate             */
315     tL2CAP_CHNL_DATA_RATE rx_data_rate;         /* Channel Rx data rate             */
316
317     /* Fields used for eL2CAP */
318     tL2CAP_ERTM_INFO    ertm_info;
319     tL2C_FCRB           fcrb;
320     UINT16              tx_mps;                 /* TX MPS adjusted based on current controller */
321     UINT16              max_rx_mtu;
322     UINT8               fcr_cfg_tries;          /* Max number of negotiation attempts */
323     BOOLEAN             peer_cfg_already_rejected; /* If mode rejected once, set to TRUE */
324     BOOLEAN             out_cfg_fcr_present;    /* TRUE if cfg response shoulkd include fcr options */
325
326 #define L2CAP_CFG_FCS_OUR   0x01                /* Our desired config FCS option */
327 #define L2CAP_CFG_FCS_PEER  0x02                /* Peer's desired config FCS option */
328 #define L2CAP_BYPASS_FCS    (L2CAP_CFG_FCS_OUR | L2CAP_CFG_FCS_PEER)
329     UINT8               bypass_fcs;
330
331 #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
332     BOOLEAN             is_flushable;                   /* TRUE if channel is flushable     */
333 #endif
334
335 #if (L2CAP_NUM_FIXED_CHNLS > 0) || (L2CAP_UCD_INCLUDED == TRUE)
336     UINT16              fixed_chnl_idle_tout;   /* Idle timeout to use for the fixed channel       */
337 #endif
338     UINT16              tx_data_len;
339 } tL2C_CCB;
340
341 /***********************************************************************
342 ** Define a queue of linked CCBs.
343 */
344 typedef struct {
345     tL2C_CCB        *p_first_ccb;               /* The first channel in this queue */
346     tL2C_CCB        *p_last_ccb;                /* The last  channel in this queue */
347 } tL2C_CCB_Q;
348
349 #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
350
351 /* Round-Robin service for the same priority channels */
352 #define L2CAP_NUM_CHNL_PRIORITY     3           /* Total number of priority group (high, medium, low)*/
353 #define L2CAP_CHNL_PRIORITY_WEIGHT  5           /* weight per priority for burst transmission quota */
354 #define L2CAP_GET_PRIORITY_QUOTA(pri) ((L2CAP_NUM_CHNL_PRIORITY - (pri)) * L2CAP_CHNL_PRIORITY_WEIGHT)
355
356 /* CCBs within the same LCB are served in round robin with priority                       */
357 /* It will make sure that low priority channel (for example, HF signaling on RFCOMM)      */
358 /* can be sent to headset even if higher priority channel (for example, AV media channel) */
359 /* is congested.                                                                          */
360
361 typedef struct {
362     tL2C_CCB        *p_serve_ccb;               /* current serving ccb within priority group */
363     tL2C_CCB        *p_first_ccb;               /* first ccb of priority group */
364     UINT8           num_ccb;                    /* number of channels in priority group */
365     UINT8           quota;                      /* burst transmission quota */
366 } tL2C_RR_SERV;
367
368 #endif /* (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE) */
369
370 /* Define a link control block. There is one link control block between
371 ** this device and any other device (i.e. BD ADDR).
372 */
373 typedef struct t_l2c_linkcb {
374     BOOLEAN             in_use;                     /* TRUE when in use, FALSE when not */
375     tL2C_LINK_STATE     link_state;
376
377     TIMER_LIST_ENT      timer_entry;                /* Timer list entry for timeout evt */
378     UINT16              handle;                     /* The handle used with LM          */
379     UINT16              completed_packets;          /* The number of conpleted packets  */
380
381     tL2C_CCB_Q          ccb_queue;                  /* Queue of CCBs on this LCB        */
382
383     tL2C_CCB            *p_pending_ccb;             /* ccb of waiting channel during link disconnect */
384     TIMER_LIST_ENT      info_timer_entry;           /* Timer entry for info resp timeout evt */
385     TIMER_LIST_ENT      upda_con_timer;             /* Timer entry for update connection parametr */
386     BD_ADDR             remote_bd_addr;             /* The BD address of the remote     */
387
388     UINT8               link_role;                  /* Master or slave                  */
389     UINT8               id;
390     UINT8               cur_echo_id;                /* Current id value for echo request */
391     tL2CA_ECHO_RSP_CB   *p_echo_rsp_cb;             /* Echo response callback           */
392     UINT16              idle_timeout;               /* Idle timeout                     */
393     BOOLEAN             is_bonding;                 /* True - link active only for bonding */
394
395     UINT16              link_flush_tout;            /* Flush timeout used               */
396
397     UINT16              link_xmit_quota;            /* Num outstanding pkts allowed     */
398     UINT16              sent_not_acked;             /* Num packets sent but not acked   */
399
400     BOOLEAN             partial_segment_being_sent; /* Set TRUE when a partial segment  */
401     /* is being sent.                   */
402     BOOLEAN             w4_info_rsp;                /* TRUE when info request is active */
403     UINT8               info_rx_bits;               /* set 1 if received info type */
404     UINT32              peer_ext_fea;               /* Peer's extended features mask    */
405     list_t              *link_xmit_data_q;          /* Link transmit data buffer queue  */
406
407     UINT8               peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
408 #if (L2CAP_UCD_INCLUDED == TRUE)
409     UINT16              ucd_mtu;                    /* peer MTU on UCD */
410     fixed_queue_t       *ucd_out_sec_pending_q;      /* Security pending outgoing UCD packet  */
411     fixed_queue_t       *ucd_in_sec_pending_q;       /* Security pending incoming UCD packet  */
412 #endif
413
414     BT_HDR              *p_hcit_rcv_acl;            /* Current HCIT ACL buf being rcvd  */
415     UINT16              idle_timeout_sv;            /* Save current Idle timeout        */
416     UINT8               acl_priority;               /* L2C_PRIORITY_NORMAL or L2C_PRIORITY_HIGH */
417     tL2CA_NOCP_CB       *p_nocp_cb;                 /* Num Cmpl pkts callback           */
418
419 #if (L2CAP_NUM_FIXED_CHNLS > 0)
420     tL2C_CCB            *p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
421     UINT16              disc_reason;
422 #endif
423
424     tBT_TRANSPORT       transport;
425 #if (BLE_INCLUDED == TRUE)
426     tBLE_ADDR_TYPE      open_addr_type; /* be set by open API */
427     tBLE_ADDR_TYPE      ble_addr_type;
428     UINT16              tx_data_len;            /* tx data length used in data length extension */
429     fixed_queue_t       *le_sec_pending_q;      /* LE coc channels waiting for security check completion */
430     UINT8               sec_act;
431 #define L2C_BLE_CONN_UPDATE_DISABLE 0x1  /* disable update connection parameters */
432 #define L2C_BLE_NEW_CONN_PARAM      0x2  /* new connection parameter to be set */
433 #define L2C_BLE_UPDATE_PENDING      0x4  /* waiting for connection update finished */
434 #define L2C_BLE_NOT_DEFAULT_PARAM   0x8  /* not using default connection parameters */
435 #define L2C_BLE_UPDATE_PARAM_FULL   0x10 /* update connection parameters full, can not update */
436     UINT8               conn_update_mask;
437     /* cache connection parameters that wait to update */
438     UINT16              waiting_update_conn_min_interval;
439     UINT16              waiting_update_conn_max_interval;
440     UINT16              waiting_update_conn_latency;
441     UINT16              waiting_update_conn_timeout;
442     /* cache parameters that is being updated */
443     UINT16              updating_conn_min_interval;
444     UINT16              updating_conn_max_interval;
445     bool                updating_param_flag;
446     /* current connection parameters that current connection is using */
447     UINT16              current_used_conn_interval;
448     UINT16              current_used_conn_latency;
449     UINT16              current_used_conn_timeout;
450     /* connection parameters update order:
451        waiting_update_conn_xx -> updating_conn_xx -> current_used_conn_xx
452     */
453 #endif
454
455 #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
456     /* each priority group is limited burst transmission  */
457     /* round robin service for the same priority channels */
458     tL2C_RR_SERV        rr_serv[L2CAP_NUM_CHNL_PRIORITY];
459     UINT8               rr_pri;                             /* current serving priority group */
460 #endif
461
462 } tL2C_LCB;
463
464 /* Define the L2CAP control structure
465 */
466 typedef struct {
467     UINT8           l2cap_trace_level;
468     UINT16          controller_xmit_window;         /* Total ACL window for all links   */
469
470     UINT16          round_robin_quota;              /* Round-robin link quota           */
471     UINT16          round_robin_unacked;            /* Round-robin unacked              */
472     BOOLEAN         check_round_robin;              /* Do a round robin check           */
473
474     BOOLEAN         is_cong_cback_context;
475
476     tL2C_LCB        lcb_pool[MAX_L2CAP_LINKS];      /* Link Control Block pool          */
477     tL2C_CCB        ccb_pool[MAX_L2CAP_CHANNELS];   /* Channel Control Block pool       */
478     tL2C_RCB        rcb_pool[MAX_L2CAP_CLIENTS];    /* Registration info pool           */
479
480     tL2C_CCB        *p_free_ccb_first;              /* Pointer to first free CCB        */
481     tL2C_CCB        *p_free_ccb_last;               /* Pointer to last  free CCB        */
482
483     UINT8           desire_role;                    /* desire to be master/slave when accepting a connection */
484     BOOLEAN         disallow_switch;                /* FALSE, to allow switch at create conn */
485     UINT16          num_lm_acl_bufs;                /* # of ACL buffers on controller   */
486     UINT16          idle_timeout;                   /* Idle timeout                     */
487
488     list_t          *rcv_pending_q;                 /* Recv pending queue               */
489     TIMER_LIST_ENT  rcv_hold_tle;                   /* Timer list entry for rcv hold    */
490
491     tL2C_LCB        *p_cur_hcit_lcb;                /* Current HCI Transport buffer     */
492     UINT16          num_links_active;               /* Number of links active           */
493
494 #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
495     UINT16          non_flushable_pbf;              /* L2CAP_PKT_START_NON_FLUSHABLE if controller supports */
496     /* Otherwise, L2CAP_PKT_START */
497     BOOLEAN         is_flush_active;                /* TRUE if an HCI_Enhanced_Flush has been sent */
498 #endif
499
500 #if L2CAP_CONFORMANCE_TESTING == TRUE
501     UINT32          test_info_resp;                 /* Conformance testing needs a dynamic response */
502 #endif
503
504 #if (L2CAP_NUM_FIXED_CHNLS > 0)
505     tL2CAP_FIXED_CHNL_REG   fixed_reg[L2CAP_NUM_FIXED_CHNLS];   /* Reg info for fixed channels */
506 #endif
507
508 #if (BLE_INCLUDED == TRUE)
509     UINT16                   num_ble_links_active;               /* Number of LE links active           */
510     BOOLEAN                  is_ble_connecting;
511     BD_ADDR                  ble_connecting_bda;
512     UINT16                   controller_le_xmit_window;         /* Total ACL window for all links   */
513     tL2C_BLE_FIXED_CHNLS_MASK l2c_ble_fixed_chnls_mask;         // LE fixed channels mask
514     UINT16                   num_lm_ble_bufs;                   /* # of ACL buffers on controller   */
515     UINT16                   ble_round_robin_quota;              /* Round-robin link quota           */
516     UINT16                   ble_round_robin_unacked;            /* Round-robin unacked              */
517     BOOLEAN                  ble_check_round_robin;              /* Do a round robin check           */
518     tL2C_RCB                 ble_rcb_pool[BLE_MAX_L2CAP_CLIENTS]; /* Registration info pool          */
519 #endif
520
521     tL2CA_ECHO_DATA_CB      *p_echo_data_cb;                /* Echo data callback */
522
523 #if (defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) && (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE))
524     UINT16              high_pri_min_xmit_quota;    /* Minimum number of ACL credit for high priority link */
525 #endif /* (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == TRUE) */
526
527     UINT16          dyn_psm;
528 } tL2C_CB;
529
530
531
532 /* Define a structure that contains the information about a connection.
533 ** This structure is used to pass between functions, and not all the
534 ** fields will always be filled in.
535 */
536 typedef struct {
537     BD_ADDR         bd_addr;                        /* Remote BD address        */
538     UINT8           status;                         /* Connection status        */
539     UINT16          psm;                            /* PSM of the connection    */
540     UINT16          l2cap_result;                   /* L2CAP result             */
541     UINT16          l2cap_status;                   /* L2CAP status             */
542     UINT16          remote_cid;                     /* Remote CID               */
543 } tL2C_CONN_INFO;
544
545
546 typedef void (tL2C_FCR_MGMT_EVT_HDLR) (UINT8, tL2C_CCB *);
547
548 /* The offset in a buffer that L2CAP will use when building commands.
549 */
550 #define L2CAP_SEND_CMD_OFFSET       0
551
552
553 /* Number of ACL buffers to use for high priority channel
554 */
555 #if (!defined(L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE) || (L2CAP_HIGH_PRI_CHAN_QUOTA_IS_CONFIGURABLE == FALSE))
556 #define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A     (L2CAP_HIGH_PRI_MIN_XMIT_QUOTA)
557 #else
558 #define L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A     (l2cb.high_pri_min_xmit_quota)
559 #endif
560
561 #ifdef __cplusplus
562 extern "C" {
563 #endif
564
565
566 /* L2CAP global data
567 ************************************
568 */
569 #if (!defined L2C_DYNAMIC_MEMORY) || (L2C_DYNAMIC_MEMORY == FALSE)
570 extern tL2C_CB  l2cb;
571 #else
572 extern tL2C_CB *l2c_cb_ptr;
573 #define l2cb (*l2c_cb_ptr)
574 #endif
575
576
577 /* Functions provided by l2c_main.c
578 ************************************
579 */
580 void l2c_init(void);
581 void l2c_free(void);
582
583 extern void     l2c_process_timeout (TIMER_LIST_ENT *p_tle);
584 extern UINT8    l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flag);
585 extern void     l2c_rcv_acl_data (BT_HDR *p_msg);
586 extern void     l2c_process_held_packets (BOOLEAN timed_out);
587
588 /* Functions provided by l2c_utils.c
589 ************************************
590 */
591 extern tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPORT transport);
592 extern BOOLEAN  l2cu_start_post_bond_timer (UINT16 handle);
593 extern void     l2cu_release_lcb (tL2C_LCB *p_lcb);
594 extern tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport);
595 extern tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle);
596 extern void     l2cu_update_lcb_4_bonding (BD_ADDR p_bd_addr, BOOLEAN is_bonding);
597
598 extern UINT8    l2cu_get_conn_role (tL2C_LCB *p_this_lcb);
599 extern BOOLEAN  l2cu_set_acl_priority (BD_ADDR bd_addr, UINT8 priority, BOOLEAN reset_after_rs);
600
601 extern void     l2cu_enqueue_ccb (tL2C_CCB *p_ccb);
602 extern void     l2cu_dequeue_ccb (tL2C_CCB *p_ccb);
603 extern void     l2cu_change_pri_ccb (tL2C_CCB *p_ccb, tL2CAP_CHNL_PRIORITY priority);
604
605 extern tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid);
606 extern void     l2cu_release_ccb (tL2C_CCB *p_ccb);
607 extern tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid);
608 extern tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid);
609 extern void     l2cu_adj_id (tL2C_LCB *p_lcb, UINT8 adj_mask);
610 extern BOOLEAN  l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb);
611
612 extern void     l2cu_send_peer_cmd_reject (tL2C_LCB *p_lcb, UINT16 reason,
613         UINT8 rem_id, UINT16 p1, UINT16 p2);
614 extern void     l2cu_send_peer_connect_req (tL2C_CCB *p_ccb);
615 extern void     l2cu_send_peer_connect_rsp (tL2C_CCB *p_ccb, UINT16 result, UINT16 status);
616 extern void     l2cu_send_peer_config_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
617 extern void     l2cu_send_peer_config_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
618 extern void     l2cu_send_peer_config_rej (tL2C_CCB *p_ccb, UINT8 *p_data, UINT16 data_len, UINT16 rej_len);
619 extern void     l2cu_send_peer_disc_req (tL2C_CCB *p_ccb);
620 extern void     l2cu_send_peer_disc_rsp (tL2C_LCB *p_lcb, UINT8 remote_id, UINT16 local_cid, UINT16 remote_cid);
621 extern void     l2cu_send_peer_echo_req (tL2C_LCB *p_lcb, UINT8 *p_data, UINT16 data_len);
622 extern void     l2cu_send_peer_echo_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
623 extern void     l2cu_send_peer_info_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT16 info_type);
624 extern void     l2cu_reject_connection (tL2C_LCB *p_lcb, UINT16 remote_cid, UINT8 rem_id, UINT16 result);
625 extern void     l2cu_send_peer_info_req (tL2C_LCB *p_lcb, UINT16 info_type);
626 extern void     l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb);
627 extern void     l2cu_check_channel_congestion (tL2C_CCB *p_ccb);
628 extern void     l2cu_disconnect_chnl (tL2C_CCB *p_ccb);
629
630 #if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
631 extern void     l2cu_set_non_flushable_pbf(BOOLEAN);
632 #endif
633
634 #if (BLE_INCLUDED == TRUE)
635 extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
636 extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
637 #endif
638
639 extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
640 extern void    l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
641 extern void    l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
642
643 /* Functions provided by l2c_ucd.c
644 ************************************
645 */
646 #if (L2CAP_UCD_INCLUDED == TRUE)
647 void l2c_ucd_delete_sec_pending_q(tL2C_LCB  *p_lcb);
648 void l2c_ucd_enqueue_pending_out_sec_q(tL2C_CCB  *p_ccb, void *p_data);
649 BOOLEAN l2c_ucd_check_pending_info_req(tL2C_CCB  *p_ccb);
650 BOOLEAN l2c_ucd_check_pending_out_sec_q(tL2C_CCB  *p_ccb);
651 void l2c_ucd_send_pending_out_sec_q(tL2C_CCB  *p_ccb);
652 void l2c_ucd_discard_pending_out_sec_q(tL2C_CCB  *p_ccb);
653 BOOLEAN l2c_ucd_check_pending_in_sec_q(tL2C_CCB  *p_ccb);
654 void l2c_ucd_send_pending_in_sec_q(tL2C_CCB  *p_ccb);
655 void l2c_ucd_discard_pending_in_sec_q(tL2C_CCB  *p_ccb);
656 BOOLEAN l2c_ucd_check_rx_pkts(tL2C_LCB  *p_lcb, BT_HDR *p_msg);
657 BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data);
658 #endif
659
660 #if (BLE_INCLUDED == TRUE)
661 extern void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
662 extern void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id);
663 extern void l2cu_reject_ble_connection (tL2C_LCB *p_lcb, UINT8 rem_id, UINT16 result);
664 extern void l2cu_send_peer_ble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
665 extern void l2cu_send_peer_ble_credit_based_conn_req (tL2C_CCB *p_ccb);
666 extern void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
667 extern void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb);
668
669 #endif
670
671 #if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
672 extern UINT8 l2cu_find_completed_packets(UINT16 *handles, UINT16 *num_packets);
673 #endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
674
675 extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
676 extern void    l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
677 extern void    l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
678
679
680 /* Functions provided for Broadcom Aware
681 ****************************************
682 */
683 extern BOOLEAN  l2cu_check_feature_req (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
684 extern void     l2cu_check_feature_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 data_len);
685 extern void     l2cu_send_feature_req (tL2C_CCB *p_ccb);
686
687 extern tL2C_RCB *l2cu_allocate_rcb (UINT16 psm);
688 extern tL2C_RCB *l2cu_find_rcb_by_psm (UINT16 psm);
689 extern void     l2cu_release_rcb (tL2C_RCB *p_rcb);
690 extern tL2C_RCB *l2cu_allocate_ble_rcb (UINT16 psm);
691 extern tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm);
692
693
694 extern UINT8    l2cu_process_peer_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
695 extern void     l2cu_process_peer_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
696 extern void     l2cu_process_our_cfg_req (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
697 extern void     l2cu_process_our_cfg_rsp (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
698
699 extern void     l2cu_device_reset (void);
700 extern tL2C_LCB *l2cu_find_lcb_by_state (tL2C_LINK_STATE state);
701 extern BOOLEAN  l2cu_lcb_disconnecting (void);
702
703 extern BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport);
704 extern BOOLEAN l2cu_create_conn_after_switch (tL2C_LCB *p_lcb);
705 extern BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb);
706 extern void    l2cu_resubmit_pending_sec_req (BD_ADDR p_bda);
707 extern void    l2cu_initialize_amp_ccb (tL2C_LCB *p_lcb);
708 extern void    l2cu_adjust_out_mps (tL2C_CCB *p_ccb);
709
710 /* Functions provided by l2c_link.c
711 ************************************
712 */
713 extern BOOLEAN  l2c_link_hci_conn_req (BD_ADDR bd_addr);
714 extern BOOLEAN  l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda);
715 extern BOOLEAN  l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason);
716 extern BOOLEAN  l2c_link_hci_qos_violation (UINT16 handle);
717 extern void     l2c_link_timeout (tL2C_LCB *p_lcb);
718 extern void     l2c_info_timeout (tL2C_LCB *p_lcb);
719 extern void     l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf);
720 extern void     l2c_link_adjust_allocation (void);
721 extern void     l2c_link_process_num_completed_pkts (UINT8 *p);
722 extern void     l2c_link_process_num_completed_blocks (UINT8 controller_id, UINT8 *p, UINT16 evt_len);
723 extern void     l2c_link_processs_num_bufs (UINT16 num_lm_acl_bufs);
724 extern UINT8    l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles);
725 extern void     l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status);
726 extern void     l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT trasnport, void *p_ref_data, UINT8 status);
727 extern void     l2c_link_segments_xmitted (BT_HDR *p_msg);
728 extern void     l2c_pin_code_request (BD_ADDR bd_addr);
729 extern void     l2c_link_adjust_chnl_allocation (void);
730
731 #if (BLE_INCLUDED == TRUE)
732 extern void     l2c_link_processs_ble_num_bufs (UINT16 num_lm_acl_bufs);
733 #endif
734
735 #if L2CAP_WAKE_PARKED_LINK == TRUE
736 extern BOOLEAN  l2c_link_check_power_mode ( tL2C_LCB *p_lcb );
737 #define L2C_LINK_CHECK_POWER_MODE(x) l2c_link_check_power_mode ((x))
738 #else  // L2CAP_WAKE_PARKED_LINK
739 #define L2C_LINK_CHECK_POWER_MODE(x) (FALSE)
740 #endif  // L2CAP_WAKE_PARKED_LINK
741
742 #if L2CAP_CONFORMANCE_TESTING == TRUE
743 /* Used only for conformance testing */
744 extern void l2cu_set_info_rsp_mask (UINT32 mask);
745 #endif
746
747 /* Functions provided by l2c_csm.c
748 ************************************
749 */
750 extern void l2c_csm_execute (tL2C_CCB *p_ccb, UINT16 event, void *p_data);
751
752 extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf);
753
754
755 /* Functions provided by l2c_fcr.c
756 ************************************
757 */
758 extern void     l2c_fcr_cleanup (tL2C_CCB *p_ccb);
759 extern void     l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf);
760 extern void     l2c_fcr_proc_tout (tL2C_CCB *p_ccb);
761 extern void     l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb);
762 extern void     l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit);
763 extern BT_HDR   *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes);
764 extern BOOLEAN  l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb);
765 extern BT_HDR   *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length);
766 extern void     l2c_fcr_start_timer (tL2C_CCB *p_ccb);
767
768 /* Configuration negotiation */
769 extern UINT8    l2c_fcr_chk_chan_modes (tL2C_CCB *p_ccb);
770 extern BOOLEAN  l2c_fcr_adj_our_req_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
771 extern void     l2c_fcr_adj_our_rsp_options (tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_peer_cfg);
772 extern BOOLEAN  l2c_fcr_renegotiate_chan(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
773 extern UINT8    l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg);
774 extern void     l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb);
775 extern void     l2c_fcr_stop_timer (tL2C_CCB *p_ccb);
776 extern void     l2c_fcr_free_timer (tL2C_CCB *p_ccb);
777 /* Functions provided by l2c_ble.c
778 ************************************
779 */
780 #if (BLE_INCLUDED == TRUE)
781 extern BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb);
782 extern void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len);
783 extern void l2cble_conn_comp (UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
784                               UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout);
785 extern BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb);
786 extern void l2cble_notify_le_connection (BD_ADDR bda);
787 extern void l2c_ble_link_adjust_allocation (void);
788 extern void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_interval,
789                                                               UINT16 conn_latency, UINT16 conn_timeout);
790 extern void l2cble_get_conn_param_format_err_from_contoller(UINT8 status, UINT16 handle);
791
792 extern void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb);
793 extern void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result);
794 extern void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb);
795 extern void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value);
796 extern BOOLEAN l2ble_sec_access_req(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originator, tL2CAP_SEC_CBACK *p_callback, void *p_ref_data);
797
798
799 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
800 extern void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
801         UINT16 latency, UINT16 timeout);
802 #endif
803
804 extern void l2cble_update_data_length(tL2C_LCB *p_lcb);
805 extern void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid,
806         UINT16 tx_mtu);
807 extern void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status);
808 extern void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
809         UINT16 rx_data_len);
810 extern UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb);
811
812 #endif
813 extern void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb);
814
815 #ifdef __cplusplus
816 }
817 #endif
818
819 #endif