Lines Matching full:conn

52 static struct proc_ctx *rr_dequeue(struct ll_conn *conn);
114 void llcp_rr_check_done(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_rr_check_done() argument
119 ctx_header = llcp_rr_peek(conn); in llcp_rr_check_done()
128 rr_dequeue(conn); in llcp_rr_check_done()
137 static void rr_set_state(struct ll_conn *conn, enum rr_state state) in rr_set_state() argument
139 conn->llcp.remote.state = state; in rr_set_state()
142 void llcp_rr_set_incompat(struct ll_conn *conn, enum proc_incompat incompat) in llcp_rr_set_incompat() argument
144 conn->llcp.remote.incompat = incompat; in llcp_rr_set_incompat()
147 void llcp_rr_set_paused_cmd(struct ll_conn *conn, enum llcp_proc proc) in llcp_rr_set_paused_cmd() argument
150 conn->llcp.remote.paused_cmd = proc; in llcp_rr_set_paused_cmd()
154 enum llcp_proc llcp_rr_get_paused_cmd(struct ll_conn *conn) in llcp_rr_get_paused_cmd() argument
157 return conn->llcp.remote.paused_cmd; in llcp_rr_get_paused_cmd()
163 static enum proc_incompat rr_get_incompat(struct ll_conn *conn) in rr_get_incompat() argument
165 return conn->llcp.remote.incompat; in rr_get_incompat()
168 static void rr_set_collision(struct ll_conn *conn, bool collision) in rr_set_collision() argument
170 conn->llcp.remote.collision = collision; in rr_set_collision()
173 bool llcp_rr_get_collision(struct ll_conn *conn) in llcp_rr_get_collision() argument
175 return conn->llcp.remote.collision; in llcp_rr_get_collision()
178 static void rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx) in rr_enqueue() argument
180 sys_slist_append(&conn->llcp.remote.pend_proc_list, &ctx->node); in rr_enqueue()
183 static struct proc_ctx *rr_dequeue(struct ll_conn *conn) in rr_dequeue() argument
187 ctx = (struct proc_ctx *)sys_slist_get(&conn->llcp.remote.pend_proc_list); in rr_dequeue()
191 struct proc_ctx *llcp_rr_peek(struct ll_conn *conn) in llcp_rr_peek() argument
195 ctx = (struct proc_ctx *)sys_slist_peek_head(&conn->llcp.remote.pend_proc_list); in llcp_rr_peek()
199 bool llcp_rr_ispaused(struct ll_conn *conn) in llcp_rr_ispaused() argument
201 return (conn->llcp.remote.pause == 1U); in llcp_rr_ispaused()
204 void llcp_rr_pause(struct ll_conn *conn) in llcp_rr_pause() argument
206 conn->llcp.remote.pause = 1U; in llcp_rr_pause()
209 void llcp_rr_resume(struct ll_conn *conn) in llcp_rr_resume() argument
211 conn->llcp.remote.pause = 0U; in llcp_rr_resume()
214 void llcp_rr_prt_restart(struct ll_conn *conn) in llcp_rr_prt_restart() argument
216 conn->llcp.remote.prt_expire = conn->llcp.prt_reload; in llcp_rr_prt_restart()
219 void llcp_rr_prt_stop(struct ll_conn *conn) in llcp_rr_prt_stop() argument
221 conn->llcp.remote.prt_expire = 0U; in llcp_rr_prt_stop()
224 void llcp_rr_flush_procedures(struct ll_conn *conn) in llcp_rr_flush_procedures() argument
229 ctx = rr_dequeue(conn); in llcp_rr_flush_procedures()
231 llcp_nodes_release(conn, ctx); in llcp_rr_flush_procedures()
233 ctx = rr_dequeue(conn); in llcp_rr_flush_procedures()
237 void llcp_rr_rx(struct ll_conn *conn, struct proc_ctx *ctx, memq_link_t *link, in llcp_rr_rx() argument
253 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
257 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
261 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
265 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
270 llcp_rp_enc_rx(conn, ctx, rx); in llcp_rr_rx()
275 llcp_rp_pu_rx(conn, ctx, rx); in llcp_rr_rx()
280 llcp_rp_cu_rx(conn, ctx, rx); in llcp_rr_rx()
283 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
287 llcp_rp_chmu_rx(conn, ctx, rx); in llcp_rr_rx()
292 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
297 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
302 llcp_rp_cc_rx(conn, ctx, rx); in llcp_rr_rx()
307 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
312 llcp_rp_comm_rx(conn, ctx, rx); in llcp_rr_rx()
317 llcp_rp_past_rx(conn, ctx, rx); in llcp_rr_rx()
331 llcp_rr_check_done(conn, ctx); in llcp_rr_rx()
334 void llcp_rr_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, struct node_tx *tx) in llcp_rr_tx_ack() argument
339 llcp_rp_comm_tx_ack(conn, ctx, tx); in llcp_rr_tx_ack()
344 llcp_rp_pu_tx_ack(conn, ctx, tx); in llcp_rr_tx_ack()
349 llcp_rp_comm_tx_ack(conn, ctx, tx); in llcp_rr_tx_ack()
354 llcp_rp_comm_tx_ack(conn, ctx, tx); in llcp_rr_tx_ack()
365 llcp_rr_check_done(conn, ctx); in llcp_rr_tx_ack()
368 void llcp_rr_tx_ntf(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_rr_tx_ntf() argument
373 llcp_rp_pu_tx_ntf(conn, ctx); in llcp_rr_tx_ntf()
381 llcp_rr_check_done(conn, ctx); in llcp_rr_tx_ntf()
384 static void rr_act_run(struct ll_conn *conn) in rr_act_run() argument
388 ctx = llcp_rr_peek(conn); in rr_act_run()
393 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
397 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
401 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
405 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
410 llcp_rp_enc_run(conn, ctx, NULL); in rr_act_run()
415 llcp_rp_pu_run(conn, ctx, NULL); in rr_act_run()
420 llcp_rp_cu_run(conn, ctx, NULL); in rr_act_run()
423 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
427 llcp_rp_chmu_run(conn, ctx, NULL); in rr_act_run()
432 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
437 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
442 llcp_rp_cc_run(conn, ctx, NULL); in rr_act_run()
447 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
452 llcp_rp_comm_run(conn, ctx, NULL); in rr_act_run()
457 llcp_rp_past_run(conn, ctx, NULL); in rr_act_run()
466 llcp_rr_check_done(conn, ctx); in rr_act_run()
469 static void rr_tx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t opcode) in rr_tx() argument
477 tx = llcp_tx_alloc(conn, ctx); in rr_tx()
485 ctx_local = llcp_lr_peek(conn); in rr_tx()
494 if (conn->llcp.fex.valid && feature_ext_rej_ind(conn)) { in rr_tx()
495 llcp_pdu_encode_reject_ext_ind(pdu, conn->llcp.remote.reject_opcode, in rr_tx()
511 llcp_tx_enqueue(conn, tx); in rr_tx()
514 static void rr_act_reject(struct ll_conn *conn) in rr_act_reject() argument
516 struct proc_ctx *ctx = llcp_rr_peek(conn); in rr_act_reject()
520 if (llcp_rr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx)) { in rr_act_reject()
521 rr_set_state(conn, RR_STATE_REJECT); in rr_act_reject()
523 rr_tx(conn, ctx, PDU_DATA_LLCTRL_TYPE_REJECT_IND); in rr_act_reject()
526 rr_set_state(conn, RR_STATE_IDLE); in rr_act_reject()
530 static void rr_act_unsupported(struct ll_conn *conn) in rr_act_unsupported() argument
532 struct proc_ctx *ctx = llcp_rr_peek(conn); in rr_act_unsupported()
536 if (llcp_rr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx)) { in rr_act_unsupported()
537 rr_set_state(conn, RR_STATE_UNSUPPORTED); in rr_act_unsupported()
539 rr_tx(conn, ctx, PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP); in rr_act_unsupported()
542 rr_set_state(conn, RR_STATE_IDLE); in rr_act_unsupported()
546 static void rr_act_complete(struct ll_conn *conn) in rr_act_complete() argument
550 rr_set_collision(conn, 0U); in rr_act_complete()
552 ctx = llcp_rr_peek(conn); in rr_act_complete()
556 llcp_rr_prt_stop(conn); in rr_act_complete()
562 static void rr_act_connect(struct ll_conn *conn) in rr_act_connect() argument
567 static void rr_act_disconnect(struct ll_conn *conn) in rr_act_disconnect() argument
574 llcp_rr_flush_procedures(conn); in rr_act_disconnect()
577 static void rr_st_disconnect(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_disconnect() argument
581 rr_act_connect(conn); in rr_st_disconnect()
582 rr_set_state(conn, RR_STATE_IDLE); in rr_st_disconnect()
590 static void rr_st_idle(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_idle() argument
597 ctx = llcp_rr_peek(conn); in rr_st_idle()
599 const enum proc_incompat incompat = rr_get_incompat(conn); in rr_st_idle()
600 const bool periph = !!(conn->lll.role == BT_HCI_ROLE_PERIPHERAL); in rr_st_idle()
601 const bool central = !!(conn->lll.role == BT_HCI_ROLE_CENTRAL); in rr_st_idle()
608 rr_act_run(conn); in rr_st_idle()
609 rr_set_state(conn, RR_STATE_TERMINATE); in rr_st_idle()
618 rr_act_unsupported(conn); in rr_st_idle()
630 rr_set_collision(conn, with_instant); in rr_st_idle()
633 rr_act_run(conn); in rr_st_idle()
634 rr_set_state(conn, RR_STATE_ACTIVE); in rr_st_idle()
642 ctx_local = llcp_lr_peek(conn); in rr_st_idle()
654 rr_set_collision(conn, with_instant); in rr_st_idle()
657 rr_act_run(conn); in rr_st_idle()
658 rr_set_state(conn, RR_STATE_ACTIVE); in rr_st_idle()
670 conn->llcp.remote.reject_opcode = pdu->llctrl.opcode; in rr_st_idle()
671 rr_act_reject(conn); in rr_st_idle()
679 ctx_local = llcp_lr_peek(conn); in rr_st_idle()
684 conn->llcp_terminate.reason_final = in rr_st_idle()
687 conn->llcp_terminate.reason_final = in rr_st_idle()
694 rr_act_disconnect(conn); in rr_st_idle()
695 rr_set_state(conn, RR_STATE_DISCONNECT); in rr_st_idle()
703 static void rr_st_reject(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_reject() argument
705 rr_act_reject(conn); in rr_st_reject()
708 static void rr_st_unsupported(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_unsupported() argument
710 rr_act_unsupported(conn); in rr_st_unsupported()
713 static void rr_st_active(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_active() argument
717 if (llcp_rr_peek(conn)) { in rr_st_active()
718 rr_act_run(conn); in rr_st_active()
722 rr_act_complete(conn); in rr_st_active()
723 rr_set_state(conn, RR_STATE_IDLE); in rr_st_active()
726 rr_act_disconnect(conn); in rr_st_active()
727 rr_set_state(conn, RR_STATE_DISCONNECT); in rr_st_active()
735 static void rr_st_terminate(struct ll_conn *conn, uint8_t evt, void *param) in rr_st_terminate() argument
739 if (llcp_rr_peek(conn)) { in rr_st_terminate()
740 rr_act_run(conn); in rr_st_terminate()
744 rr_act_complete(conn); in rr_st_terminate()
745 rr_set_state(conn, RR_STATE_IDLE); in rr_st_terminate()
748 rr_act_disconnect(conn); in rr_st_terminate()
749 rr_set_state(conn, RR_STATE_DISCONNECT); in rr_st_terminate()
757 static void rr_execute_fsm(struct ll_conn *conn, uint8_t evt, void *param) in rr_execute_fsm() argument
759 switch (conn->llcp.remote.state) { in rr_execute_fsm()
761 rr_st_disconnect(conn, evt, param); in rr_execute_fsm()
764 rr_st_idle(conn, evt, param); in rr_execute_fsm()
767 rr_st_reject(conn, evt, param); in rr_execute_fsm()
770 rr_st_unsupported(conn, evt, param); in rr_execute_fsm()
773 rr_st_active(conn, evt, param); in rr_execute_fsm()
776 rr_st_terminate(conn, evt, param); in rr_execute_fsm()
784 void llcp_rr_init(struct ll_conn *conn) in llcp_rr_init() argument
786 rr_set_state(conn, RR_STATE_DISCONNECT); in llcp_rr_init()
787 conn->llcp.remote.prt_expire = 0U; in llcp_rr_init()
790 void llcp_rr_prepare(struct ll_conn *conn, struct node_rx_pdu *rx) in llcp_rr_prepare() argument
792 rr_execute_fsm(conn, RR_EVT_PREPARE, rx); in llcp_rr_prepare()
795 void llcp_rr_run(struct ll_conn *conn) in llcp_rr_run() argument
797 rr_execute_fsm(conn, RR_EVT_RUN, NULL); in llcp_rr_run()
800 void llcp_rr_complete(struct ll_conn *conn) in llcp_rr_complete() argument
802 rr_execute_fsm(conn, RR_EVT_COMPLETE, NULL); in llcp_rr_complete()
805 void llcp_rr_connect(struct ll_conn *conn) in llcp_rr_connect() argument
807 rr_execute_fsm(conn, RR_EVT_CONNECT, NULL); in llcp_rr_connect()
810 void llcp_rr_disconnect(struct ll_conn *conn) in llcp_rr_disconnect() argument
812 rr_execute_fsm(conn, RR_EVT_DISCONNECT, NULL); in llcp_rr_disconnect()
915 void llcp_rr_new(struct ll_conn *conn, memq_link_t *link, struct node_rx_pdu *rx, bool valid_pdu) in llcp_rr_new() argument
926 uint8_t role_mask = (1 << conn->lll.role); in llcp_rr_new()
935 llcp_rr_terminate(conn); in llcp_rr_new()
936 llcp_lr_terminate(conn); in llcp_rr_new()
945 rr_enqueue(conn, ctx); in llcp_rr_new()
948 llcp_rr_prepare(conn, rx); in llcp_rr_new()
950 llcp_rr_check_done(conn, ctx); in llcp_rr_new()
953 ctx = llcp_rr_peek(conn); in llcp_rr_new()
955 llcp_rr_rx(conn, ctx, link, rx); in llcp_rr_new()
959 void llcp_rr_terminate(struct ll_conn *conn) in llcp_rr_terminate() argument
961 llcp_rr_flush_procedures(conn); in llcp_rr_terminate()
962 llcp_rr_prt_stop(conn); in llcp_rr_terminate()
963 rr_set_collision(conn, 0U); in llcp_rr_terminate()
964 rr_set_state(conn, RR_STATE_IDLE); in llcp_rr_terminate()
969 bool llcp_rr_is_disconnected(struct ll_conn *conn) in llcp_rr_is_disconnected() argument
971 return conn->llcp.remote.state == RR_STATE_DISCONNECT; in llcp_rr_is_disconnected()
974 bool llcp_rr_is_idle(struct ll_conn *conn) in llcp_rr_is_idle() argument
976 return conn->llcp.remote.state == RR_STATE_IDLE; in llcp_rr_is_idle()
979 struct proc_ctx *llcp_rr_dequeue(struct ll_conn *conn) in llcp_rr_dequeue() argument
981 return rr_dequeue(conn); in llcp_rr_dequeue()
984 void llcp_rr_enqueue(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_rr_enqueue() argument
986 rr_enqueue(conn, ctx); in llcp_rr_enqueue()