Lines Matching refs:br_chan

148 	struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan);  in l2cap_br_chan_alloc_cid()  local
155 if (br_chan->rx.cid > 0) { in l2cap_br_chan_alloc_cid()
156 return br_chan; in l2cap_br_chan_alloc_cid()
165 br_chan->rx.cid = cid; in l2cap_br_chan_alloc_cid()
166 return br_chan; in l2cap_br_chan_alloc_cid()
181 struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); in l2cap_br_chan_destroy() local
183 LOG_DBG("chan %p cid 0x%04x", br_chan, br_chan->rx.cid); in l2cap_br_chan_destroy()
192 struct k_work_q *rtx_work_queue = br_chan->rtx_work.queue; in l2cap_br_chan_destroy()
195 k_work_cancel_delayable_sync(&br_chan->rtx_work, &br_chan->rtx_sync); in l2cap_br_chan_destroy()
197 k_work_cancel_delayable(&br_chan->rtx_work); in l2cap_br_chan_destroy()
267 static void raise_data_ready(struct bt_l2cap_br_chan *br_chan) in raise_data_ready() argument
269 if (!atomic_set(&br_chan->_pdu_ready_lock, 1)) { in raise_data_ready()
270 sys_slist_append(&br_chan->chan.conn->l2cap_data_ready, in raise_data_ready()
271 &br_chan->_pdu_ready); in raise_data_ready()
277 bt_conn_data_ready(br_chan->chan.conn); in raise_data_ready()
280 static void lower_data_ready(struct bt_l2cap_br_chan *br_chan) in lower_data_ready() argument
282 struct bt_conn *conn = br_chan->chan.conn; in lower_data_ready()
285 __ASSERT_NO_MSG(s == &br_chan->_pdu_ready); in lower_data_ready()
287 __maybe_unused atomic_t old = atomic_set(&br_chan->_pdu_ready_lock, 0); in lower_data_ready()
292 static void cancel_data_ready(struct bt_l2cap_br_chan *br_chan) in cancel_data_ready() argument
294 struct bt_conn *conn = br_chan->chan.conn; in cancel_data_ready()
297 &br_chan->_pdu_ready); in cancel_data_ready()
299 atomic_set(&br_chan->_pdu_ready_lock, 0); in cancel_data_ready()
307 struct bt_l2cap_br_chan *br_chan = CONTAINER_OF(ch, struct bt_l2cap_br_chan, chan); in bt_l2cap_br_send_cb() local
309 LOG_DBG("chan %p buf %p len %zu", br_chan, buf, buf->len); in bt_l2cap_br_send_cb()
326 k_fifo_put(&br_chan->_pdu_tx_queue, buf); in bt_l2cap_br_send_cb()
327 raise_data_ready(br_chan); in bt_l2cap_br_send_cb()
367 static bool chan_has_data(struct bt_l2cap_br_chan *br_chan) in chan_has_data() argument
369 return !k_fifo_is_empty(&br_chan->_pdu_tx_queue); in chan_has_data()
383 struct bt_l2cap_br_chan *br_chan = CONTAINER_OF(pdu_ready, in l2cap_br_data_pull() local
390 struct net_buf *pdu = k_fifo_peek_head(&br_chan->_pdu_tx_queue); in l2cap_br_data_pull()
407 __maybe_unused struct net_buf *b = k_fifo_get(&br_chan->_pdu_tx_queue, K_NO_WAIT); in l2cap_br_data_pull()
411 LOG_DBG("chan %p done", br_chan); in l2cap_br_data_pull()
412 lower_data_ready(br_chan); in l2cap_br_data_pull()
415 if (chan_has_data(br_chan)) { in l2cap_br_data_pull()
416 LOG_DBG("chan %p ready", br_chan); in l2cap_br_data_pull()
417 raise_data_ready(br_chan); in l2cap_br_data_pull()
648 struct bt_l2cap_br_chan *br_chan; in bt_l2cap_br_connected() local
658 br_chan = BR_CHAN(chan); in bt_l2cap_br_connected()
660 br_chan->rx.cid = fchan->cid; in bt_l2cap_br_connected()
661 br_chan->tx.cid = fchan->cid; in bt_l2cap_br_connected()
674 connect_fixed_channel(br_chan); in bt_l2cap_br_connected()
676 sig_ch = CONTAINER_OF(br_chan, struct bt_l2cap_br, chan); in bt_l2cap_br_connected()
774 struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); in l2cap_br_conn_security() local
777 if (br_chan->required_sec_level == BT_SECURITY_L0) { in l2cap_br_conn_security()
785 if (br_chan->required_sec_level == BT_SECURITY_L1 && in l2cap_br_conn_security()
790 switch (br_chan->required_sec_level) { in l2cap_br_conn_security()
803 br_chan->required_sec_level = BT_SECURITY_L2; in l2cap_br_conn_security()
808 check = bt_conn_set_security(chan->conn, br_chan->required_sec_level); in l2cap_br_conn_security()
817 chan->conn->sec_level >= br_chan->required_sec_level) { in l2cap_br_conn_security()
893 struct bt_l2cap_br_chan *br_chan; in bt_l2cap_br_chan_set_state_debug() local
895 br_chan = BR_CHAN(chan); in bt_l2cap_br_chan_set_state_debug()
897 LOG_DBG("chan %p psm 0x%04x %s -> %s", chan, br_chan->psm, in bt_l2cap_br_chan_set_state_debug()
898 bt_l2cap_chan_state_str(br_chan->state), bt_l2cap_chan_state_str(state)); in bt_l2cap_br_chan_set_state_debug()
906 if (br_chan->state != BT_L2CAP_DISCONNECTED) { in bt_l2cap_br_chan_set_state_debug()
911 if (br_chan->state != BT_L2CAP_CONNECTING) { in bt_l2cap_br_chan_set_state_debug()
916 if (br_chan->state != BT_L2CAP_CONFIG && in bt_l2cap_br_chan_set_state_debug()
917 br_chan->state != BT_L2CAP_CONNECTING) { in bt_l2cap_br_chan_set_state_debug()
922 if (br_chan->state != BT_L2CAP_CONFIG && in bt_l2cap_br_chan_set_state_debug()
923 br_chan->state != BT_L2CAP_CONNECTED) { in bt_l2cap_br_chan_set_state_debug()
932 br_chan->state = state; in bt_l2cap_br_chan_set_state_debug()
946 struct bt_l2cap_br_chan *br_chan = CONTAINER_OF(chan, struct bt_l2cap_br_chan, chan); in bt_l2cap_br_chan_del() local
954 cancel_data_ready(br_chan); in bt_l2cap_br_chan_del()
957 while (chan_has_data(br_chan)) { in bt_l2cap_br_chan_del()
958 struct net_buf *buf = k_fifo_get(&br_chan->_pdu_tx_queue, K_NO_WAIT); in bt_l2cap_br_chan_del()
992 struct bt_l2cap_br_chan *br_chan; in l2cap_br_conn_req() local
1047 br_chan = BR_CHAN(chan); in l2cap_br_conn_req()
1048 br_chan->required_sec_level = server->sec_level; in l2cap_br_conn_req()
1052 br_chan->ident = ident; in l2cap_br_conn_req()
1081 br_chan->ident = ident; in l2cap_br_conn_req()
1102 struct bt_l2cap_br_chan *br_chan; in l2cap_br_conf_rsp() local
1122 br_chan = BR_CHAN(chan); in l2cap_br_conf_rsp()
1125 k_work_cancel_delayable(&br_chan->rtx_work); in l2cap_br_conf_rsp()
1133 atomic_set_bit(br_chan->flags, L2CAP_FLAG_CONN_LCONF_DONE); in l2cap_br_conf_rsp()
1135 if (br_chan->state == BT_L2CAP_CONFIG && in l2cap_br_conf_rsp()
1136 atomic_test_bit(br_chan->flags, in l2cap_br_conf_rsp()
1138 LOG_DBG("scid 0x%04x rx MTU %u dcid 0x%04x tx MTU %u", br_chan->rx.cid, in l2cap_br_conf_rsp()
1139 br_chan->rx.mtu, br_chan->tx.cid, br_chan->tx.mtu); in l2cap_br_conf_rsp()
1593 struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); in l2cap_br_disconnected() local
1595 LOG_DBG("ch %p cid 0x%04x", br_chan, br_chan->rx.cid); in l2cap_br_disconnected()
1597 if (atomic_test_and_clear_bit(br_chan->flags, in l2cap_br_disconnected()
1603 (void)k_work_cancel_delayable(&br_chan->rtx_work); in l2cap_br_disconnected()
1613 struct bt_l2cap_br_chan *br_chan; in bt_l2cap_br_chan_disconnect() local
1619 br_chan = BR_CHAN(chan); in bt_l2cap_br_chan_disconnect()
1621 if (br_chan->state == BT_L2CAP_DISCONNECTING) { in bt_l2cap_br_chan_disconnect()
1625 LOG_DBG("chan %p scid 0x%04x dcid 0x%04x", chan, br_chan->rx.cid, br_chan->tx.cid); in bt_l2cap_br_chan_disconnect()
1635 req->dcid = sys_cpu_to_le16(br_chan->tx.cid); in bt_l2cap_br_chan_disconnect()
1636 req->scid = sys_cpu_to_le16(br_chan->rx.cid); in bt_l2cap_br_chan_disconnect()
1638 l2cap_br_chan_send_req(br_chan, buf, L2CAP_BR_DISCONN_TIMEOUT); in bt_l2cap_br_chan_disconnect()
1677 struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); in bt_l2cap_br_chan_connect() local
1683 if (br_chan->psm) { in bt_l2cap_br_chan_connect()
1692 if (br_chan->required_sec_level > BT_SECURITY_L4) { in bt_l2cap_br_chan_connect()
1694 } else if (br_chan->required_sec_level == BT_SECURITY_L0 && in bt_l2cap_br_chan_connect()
1696 br_chan->required_sec_level = BT_SECURITY_L1; in bt_l2cap_br_chan_connect()
1699 switch (br_chan->state) { in bt_l2cap_br_chan_connect()
1717 br_chan->psm = psm; in bt_l2cap_br_chan_connect()
1759 struct bt_l2cap_br_chan *br_chan; in l2cap_br_conn_rsp() local
1779 br_chan = BR_CHAN(chan); in l2cap_br_conn_rsp()
1782 k_work_cancel_delayable(&br_chan->rtx_work); in l2cap_br_conn_rsp()
1784 if (br_chan->state != BT_L2CAP_CONNECTING) { in l2cap_br_conn_rsp()
1786 bt_l2cap_chan_state_str(br_chan->state)); in l2cap_br_conn_rsp()
1792 br_chan->ident = 0U; in l2cap_br_conn_rsp()
1799 k_work_reschedule(&br_chan->rtx_work, L2CAP_BR_CONN_TIMEOUT); in l2cap_br_conn_rsp()
1810 struct bt_l2cap_br_chan *br_chan; in bt_l2cap_br_chan_send_cb() local
1816 br_chan = BR_CHAN(chan); in bt_l2cap_br_chan_send_cb()
1828 if (buf->len > br_chan->tx.mtu) { in bt_l2cap_br_chan_send_cb()
1832 return bt_l2cap_br_send_cb(br_chan->chan.conn, br_chan->tx.cid, buf, cb, user_data); in bt_l2cap_br_chan_send_cb()
1996 struct bt_l2cap_br_chan *br_chan = BR_CHAN(chan); in check_fixed_channel() local
1998 if (br_chan->rx.cid < L2CAP_BR_CID_DYN_START) { in check_fixed_channel()
1999 connect_fixed_channel(br_chan); in check_fixed_channel()