Lines Matching refs:le_chan
118 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_chan_alloc_cid() local
125 if (le_chan->rx.cid > 0) { in l2cap_chan_alloc_cid()
126 return le_chan; in l2cap_chan_alloc_cid()
131 le_chan->rx.cid = cid; in l2cap_chan_alloc_cid()
132 return le_chan; in l2cap_chan_alloc_cid()
200 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_set_state_debug() local
202 LOG_DBG("chan %p psm 0x%04x %s -> %s", chan, le_chan->psm, in bt_l2cap_chan_set_state_debug()
203 bt_l2cap_chan_state_str(le_chan->state), bt_l2cap_chan_state_str(state)); in bt_l2cap_chan_set_state_debug()
211 if (le_chan->state != BT_L2CAP_DISCONNECTED) { in bt_l2cap_chan_set_state_debug()
216 if (le_chan->state != BT_L2CAP_CONNECTING) { in bt_l2cap_chan_set_state_debug()
221 if (le_chan->state != BT_L2CAP_CONFIG && in bt_l2cap_chan_set_state_debug()
222 le_chan->state != BT_L2CAP_CONNECTING) { in bt_l2cap_chan_set_state_debug()
227 if (le_chan->state != BT_L2CAP_CONFIG && in bt_l2cap_chan_set_state_debug()
228 le_chan->state != BT_L2CAP_CONNECTED) { in bt_l2cap_chan_set_state_debug()
237 le_chan->state = state; in bt_l2cap_chan_set_state_debug()
253 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_del() local
261 cancel_data_ready(le_chan); in bt_l2cap_chan_del()
266 while (chan_has_data(le_chan)) { in bt_l2cap_chan_del()
267 struct net_buf *buf = k_fifo_get(&le_chan->tx_queue, K_NO_WAIT); in bt_l2cap_chan_del()
337 static void init_le_chan_private(struct bt_l2cap_le_chan *le_chan) in init_le_chan_private() argument
343 le_chan->_sdu = NULL; in init_le_chan_private()
344 le_chan->_sdu_len = 0; in init_le_chan_private()
346 le_chan->_sdu_len_done = 0; in init_le_chan_private()
349 memset(&le_chan->_pdu_ready, 0, sizeof(le_chan->_pdu_ready)); in init_le_chan_private()
350 le_chan->_pdu_ready_lock = 0; in init_le_chan_private()
351 le_chan->_pdu_remaining = 0; in init_le_chan_private()
357 struct bt_l2cap_le_chan *le_chan; in l2cap_chan_add() local
360 le_chan = l2cap_chan_alloc_cid(conn, chan); in l2cap_chan_add()
362 le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_chan_add()
365 if (!le_chan) { in l2cap_chan_add()
371 init_le_chan_private(le_chan); in l2cap_chan_add()
382 k_work_init_delayable(&le_chan->rtx_work, l2cap_rtx_timeout); in l2cap_chan_add()
384 if (L2CAP_LE_CID_IS_DYN(le_chan->rx.cid)) { in l2cap_chan_add()
385 k_work_init(&le_chan->rx_work, l2cap_rx_process); in l2cap_chan_add()
386 k_fifo_init(&le_chan->rx_queue); in l2cap_chan_add()
405 struct bt_l2cap_le_chan *le_chan; in bt_l2cap_connected() local
411 le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_connected()
416 le_chan->rx.cid = fchan->cid; in bt_l2cap_connected()
417 le_chan->tx.cid = fchan->cid; in bt_l2cap_connected()
423 k_fifo_init(&le_chan->tx_queue); in bt_l2cap_connected()
682 static void raise_data_ready(struct bt_l2cap_le_chan *le_chan) in raise_data_ready() argument
684 if (!atomic_set(&le_chan->_pdu_ready_lock, 1)) { in raise_data_ready()
685 sys_slist_append(&le_chan->chan.conn->l2cap_data_ready, in raise_data_ready()
686 &le_chan->_pdu_ready); in raise_data_ready()
687 LOG_DBG("data ready raised %p", le_chan); in raise_data_ready()
689 LOG_DBG("data ready already %p", le_chan); in raise_data_ready()
692 bt_conn_data_ready(le_chan->chan.conn); in raise_data_ready()
695 static void lower_data_ready(struct bt_l2cap_le_chan *le_chan) in lower_data_ready() argument
697 struct bt_conn *conn = le_chan->chan.conn; in lower_data_ready()
700 LOG_DBG("%p", le_chan); in lower_data_ready()
702 __ASSERT_NO_MSG(s == &le_chan->_pdu_ready); in lower_data_ready()
704 __maybe_unused atomic_t old = atomic_set(&le_chan->_pdu_ready_lock, 0); in lower_data_ready()
709 static void cancel_data_ready(struct bt_l2cap_le_chan *le_chan) in cancel_data_ready() argument
711 struct bt_conn *conn = le_chan->chan.conn; in cancel_data_ready()
713 LOG_DBG("%p", le_chan); in cancel_data_ready()
716 &le_chan->_pdu_ready); in cancel_data_ready()
717 atomic_set(&le_chan->_pdu_ready_lock, 0); in cancel_data_ready()
720 int bt_l2cap_send_pdu(struct bt_l2cap_le_chan *le_chan, struct net_buf *pdu, in bt_l2cap_send_pdu() argument
723 if (!le_chan->chan.conn || le_chan->chan.conn->state != BT_CONN_CONNECTED) { in bt_l2cap_send_pdu()
748 k_fifo_put(&le_chan->tx_queue, pdu); in bt_l2cap_send_pdu()
750 raise_data_ready(le_chan); /* tis just a flag */ in bt_l2cap_send_pdu()
1292 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_chan_destroy() local
1295 LOG_DBG("chan %p cid 0x%04x", le_chan, le_chan->rx.cid); in l2cap_chan_destroy()
1304 struct k_work_q *rtx_work_queue = le_chan->rtx_work.queue; in l2cap_chan_destroy()
1307 k_work_cancel_delayable_sync(&le_chan->rtx_work, &le_chan->rtx_sync); in l2cap_chan_destroy()
1309 k_work_cancel_delayable(&le_chan->rtx_work); in l2cap_chan_destroy()
1313 while ((buf = k_fifo_get(&le_chan->rx_queue, K_NO_WAIT))) { in l2cap_chan_destroy()
1318 if (le_chan->_sdu) { in l2cap_chan_destroy()
1319 net_buf_unref(le_chan->_sdu); in l2cap_chan_destroy()
1320 le_chan->_sdu = NULL; in l2cap_chan_destroy()
1321 le_chan->_sdu_len = 0U; in l2cap_chan_destroy()
1350 struct bt_l2cap_le_chan *le_chan; in l2cap_chan_accept() local
1384 le_chan = BT_L2CAP_LE_CHAN(*chan); in l2cap_chan_accept()
1386 le_chan->required_sec_level = server->sec_level; in l2cap_chan_accept()
1393 l2cap_chan_tx_init(le_chan); in l2cap_chan_accept()
1394 le_chan->tx.cid = scid; in l2cap_chan_accept()
1395 le_chan->tx.mps = mps; in l2cap_chan_accept()
1396 le_chan->tx.mtu = mtu; in l2cap_chan_accept()
1397 l2cap_chan_tx_give_credits(le_chan, credits); in l2cap_chan_accept()
1400 l2cap_chan_rx_init(le_chan); in l2cap_chan_accept()
1403 le_chan->psm = server->psm; in l2cap_chan_accept()
1443 struct bt_l2cap_le_chan *le_chan; in le_conn_req() local
1496 le_chan = BT_L2CAP_LE_CHAN(chan); in le_conn_req()
1499 rsp->dcid = sys_cpu_to_le16(le_chan->rx.cid); in le_conn_req()
1500 rsp->mps = sys_cpu_to_le16(le_chan->rx.mps); in le_conn_req()
1501 rsp->mtu = sys_cpu_to_le16(le_chan->rx.mtu); in le_conn_req()
1502 rsp->credits = sys_cpu_to_le16(le_chan->rx.credits); in le_conn_req()
2126 struct bt_l2cap_le_chan *le_chan; in le_credits() local
2145 le_chan = BT_L2CAP_LE_CHAN(chan); in le_credits()
2147 if (atomic_get(&le_chan->tx.credits) + credits > UINT16_MAX) { in le_credits()
2153 l2cap_chan_tx_give_credits(le_chan, credits); in le_credits()
2155 LOG_DBG("chan %p total credits %lu", le_chan, atomic_get(&le_chan->tx.credits)); in le_credits()
2258 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_chan_shutdown() local
2266 if (le_chan->_sdu) { in l2cap_chan_shutdown()
2267 net_buf_unref(le_chan->_sdu); in l2cap_chan_shutdown()
2268 le_chan->_sdu = NULL; in l2cap_chan_shutdown()
2269 le_chan->_sdu_len = 0U; in l2cap_chan_shutdown()
2273 while ((buf = k_fifo_get(&le_chan->tx_queue, K_NO_WAIT))) { in l2cap_chan_shutdown()
2278 while ((buf = k_fifo_get(&le_chan->rx_queue, K_NO_WAIT))) { in l2cap_chan_shutdown()
2360 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_give_credits() local
2382 if (atomic_add_safe_u16(&le_chan->rx.credits, additional_credits)) { in bt_l2cap_chan_give_credits()
2390 err = l2cap_chan_send_credits_pdu(chan->conn, le_chan->rx.cid, additional_credits); in bt_l2cap_chan_give_credits()
2403 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_recv_complete() local
2421 if (bt_l2cap_chan_get_state(&le_chan->chan) == BT_L2CAP_CONNECTED) { in bt_l2cap_chan_recv_complete()
2422 l2cap_chan_send_credits(le_chan, 1); in bt_l2cap_chan_recv_complete()
2700 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_chan_recv() local
2702 if (L2CAP_LE_CID_IS_DYN(le_chan->rx.cid)) { in l2cap_chan_recv()
2704 l2cap_chan_recv_queue(le_chan, buf); in l2cap_chan_recv()
2784 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in l2cap_disconnected() local
2786 LOG_DBG("ch %p cid 0x%04x", le_chan, le_chan->rx.cid); in l2cap_disconnected()
2793 (void)k_work_cancel_delayable(&le_chan->rtx_work); in l2cap_disconnected()
3134 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_connect() local
3151 if (le_chan->required_sec_level > BT_SECURITY_L4) { in bt_l2cap_chan_connect()
3153 } else if (le_chan->required_sec_level == BT_SECURITY_L0) { in bt_l2cap_chan_connect()
3154 le_chan->required_sec_level = BT_SECURITY_L1; in bt_l2cap_chan_connect()
3157 return l2cap_le_connect(conn, le_chan, psm); in bt_l2cap_chan_connect()
3165 struct bt_l2cap_le_chan *le_chan; in bt_l2cap_chan_disconnect() local
3176 le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_disconnect()
3178 LOG_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, le_chan->rx.cid, le_chan->tx.cid); in bt_l2cap_chan_disconnect()
3180 le_chan->ident = get_ident(); in bt_l2cap_chan_disconnect()
3183 le_chan->ident, sizeof(*req)); in bt_l2cap_chan_disconnect()
3189 req->dcid = sys_cpu_to_le16(le_chan->tx.cid); in bt_l2cap_chan_disconnect()
3190 req->scid = sys_cpu_to_le16(le_chan->rx.cid); in bt_l2cap_chan_disconnect()
3212 static int bt_l2cap_dyn_chan_send(struct bt_l2cap_le_chan *le_chan, struct net_buf *buf) in bt_l2cap_dyn_chan_send() argument
3216 LOG_DBG("chan %p buf %p", le_chan, buf); in bt_l2cap_dyn_chan_send()
3221 if (sdu_len > le_chan->tx.mtu) { in bt_l2cap_dyn_chan_send()
3223 sdu_len, le_chan->tx.mtu); in bt_l2cap_dyn_chan_send()
3272 k_fifo_put(&le_chan->tx_queue, buf); in bt_l2cap_dyn_chan_send()
3275 raise_data_ready(le_chan); in bt_l2cap_dyn_chan_send()
3310 struct bt_l2cap_le_chan *le_chan = BT_L2CAP_LE_CHAN(chan); in bt_l2cap_chan_send() local
3312 __ASSERT_NO_MSG(le_chan); in bt_l2cap_chan_send()
3313 __ASSERT_NO_MSG(L2CAP_LE_CID_IS_DYN(le_chan->tx.cid)); in bt_l2cap_chan_send()
3315 return bt_l2cap_dyn_chan_send(le_chan, buf); in bt_l2cap_chan_send()