Lines Matching full:ctx

145 static void pu_prep_update_ind(struct ll_conn *conn, struct proc_ctx *ctx)  in pu_prep_update_ind()  argument
147 ctx->data.pu.tx = pu_select_phy(ctx->data.pu.tx); in pu_prep_update_ind()
148 ctx->data.pu.rx = pu_select_phy(ctx->data.pu.rx); in pu_prep_update_ind()
150 if (ctx->data.pu.tx != conn->lll.phy_tx) { in pu_prep_update_ind()
151 ctx->data.pu.c_to_p_phy = ctx->data.pu.tx; in pu_prep_update_ind()
153 ctx->data.pu.c_to_p_phy = 0U; in pu_prep_update_ind()
155 if (ctx->data.pu.rx != conn->lll.phy_rx) { in pu_prep_update_ind()
156 ctx->data.pu.p_to_c_phy = ctx->data.pu.rx; in pu_prep_update_ind()
158 ctx->data.pu.p_to_c_phy = 0U; in pu_prep_update_ind()
201 static uint8_t pu_check_update_ind(struct ll_conn *conn, struct proc_ctx *ctx) in pu_check_update_ind() argument
206 if (!phy_validation_check_phy_ind(ctx->data.pu.c_to_p_phy) || in pu_check_update_ind()
207 !phy_validation_check_phy_ind(ctx->data.pu.p_to_c_phy)) { in pu_check_update_ind()
209 ctx->data.pu.error = BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL; in pu_check_update_ind()
214 if (!((ctx->data.pu.c_to_p_phy | ctx->data.pu.p_to_c_phy) & 0x07)) { in pu_check_update_ind()
216 ctx->data.pu.error = BT_HCI_ERR_SUCCESS; in pu_check_update_ind()
220 if (is_instant_reached_or_passed(ctx->data.pu.instant, in pu_check_update_ind()
222 ctx->data.pu.error = BT_HCI_ERR_INSTANT_PASSED; in pu_check_update_ind()
230 static uint8_t pu_apply_phy_update(struct ll_conn *conn, struct proc_ctx *ctx) in pu_apply_phy_update() argument
243 const uint8_t p_to_c_phy = ctx->data.pu.p_to_c_phy & phy_bitmask; in pu_apply_phy_update()
244 const uint8_t c_to_p_phy = ctx->data.pu.c_to_p_phy & phy_bitmask; in pu_apply_phy_update()
285 static uint8_t pu_update_eff_times(struct ll_conn *conn, struct proc_ctx *ctx) in pu_update_eff_times() argument
294 if ((ctx->data.pu.p_to_c_phy && (lll->role == BT_HCI_ROLE_PERIPHERAL)) || in pu_update_eff_times()
295 (ctx->data.pu.c_to_p_phy && (lll->role == BT_HCI_ROLE_CENTRAL))) { in pu_update_eff_times()
299 if ((ctx->data.pu.p_to_c_phy && (lll->role == BT_HCI_ROLE_CENTRAL)) || in pu_update_eff_times()
300 (ctx->data.pu.c_to_p_phy && (lll->role == BT_HCI_ROLE_PERIPHERAL))) { in pu_update_eff_times()
321 static inline void pu_set_preferred_phys(struct ll_conn *conn, struct proc_ctx *ctx) in pu_set_preferred_phys() argument
323 conn->phy_pref_rx = ctx->data.pu.rx; in pu_set_preferred_phys()
324 conn->phy_pref_tx = ctx->data.pu.tx; in pu_set_preferred_phys()
331 conn->lll.phy_flags = ctx->data.pu.flags; in pu_set_preferred_phys()
334 static inline void pu_combine_phys(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t tx, in pu_combine_phys() argument
338 ctx->data.pu.rx &= rx; in pu_combine_phys()
339 ctx->data.pu.tx &= tx; in pu_combine_phys()
352 if (conn->lll.role == BT_HCI_ROLE_CENTRAL && (!ctx->data.pu.rx || !ctx->data.pu.tx)) { in pu_combine_phys()
353 ctx->data.pu.tx = 0; in pu_combine_phys()
354 ctx->data.pu.rx = 0; in pu_combine_phys()
359 static void pu_prepare_instant(struct ll_conn *conn, struct proc_ctx *ctx) in pu_prepare_instant() argument
364 if (ctx->data.pu.c_to_p_phy != 0 || ctx->data.pu.p_to_c_phy != 0) { in pu_prepare_instant()
365 ctx->data.pu.instant = ull_conn_event_counter(conn) + conn->lll.latency + in pu_prepare_instant()
368 ctx->data.pu.instant = 0; in pu_prepare_instant()
377 static void lp_pu_tx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_tx() argument
382 LL_ASSERT(ctx->node_ref.tx); in lp_pu_tx()
385 if (!((ctx->tx_opcode == PDU_DATA_LLCTRL_TYPE_PHY_REQ) && in lp_pu_tx()
389 ctx->state = LP_PU_STATE_WAIT_NTF_AVAIL; in lp_pu_tx()
392 ctx->data.pu.ntf_dle_node = llcp_ntf_alloc(); in lp_pu_tx()
393 LL_ASSERT(ctx->data.pu.ntf_dle_node); in lp_pu_tx()
397 tx = ctx->node_ref.tx; in lp_pu_tx()
398 ctx->node_ref.tx = NULL; in lp_pu_tx()
399 ctx->node_ref.tx_ack = tx; in lp_pu_tx()
403 switch (ctx->tx_opcode) { in lp_pu_tx()
405 pu_set_preferred_phys(conn, ctx); in lp_pu_tx()
406 llcp_pdu_encode_phy_req(ctx, pdu); in lp_pu_tx()
408 ctx->state = LP_PU_STATE_WAIT_TX_ACK_PHY_REQ; in lp_pu_tx()
412 pu_prep_update_ind(conn, ctx); in lp_pu_tx()
413 pu_prepare_instant(conn, ctx); in lp_pu_tx()
414 llcp_pdu_encode_phy_update_ind(ctx, pdu); in lp_pu_tx()
415 ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_UNUSED; in lp_pu_tx()
416 ctx->state = LP_PU_STATE_WAIT_TX_ACK_PHY_UPDATE_IND; in lp_pu_tx()
430 static void pu_ntf(struct ll_conn *conn, struct proc_ctx *ctx) in pu_ntf() argument
436 ntf = ctx->node_ref.rx; in pu_ntf()
437 ctx->node_ref.rx = NULL; in pu_ntf()
440 if (ctx->data.pu.ntf_pu) { in pu_ntf()
446 pdu->status = ctx->data.pu.error; in pu_ntf()
456 ctx->data.pu.ntf_pu = 0; in pu_ntf()
460 static void pu_dle_ntf(struct ll_conn *conn, struct proc_ctx *ctx) in pu_dle_ntf() argument
466 ntf = ctx->data.pu.ntf_dle_node; in pu_dle_ntf()
468 if (!ctx->data.pu.ntf_dle) { in pu_dle_ntf()
491 ctx->data.pu.ntf_dle = 0; in pu_dle_ntf()
492 ctx->data.pu.ntf_dle_node = NULL; in pu_dle_ntf()
496 static void lp_pu_complete_finalize(struct ll_conn *conn, struct proc_ctx *ctx) in lp_pu_complete_finalize() argument
500 ctx->state = LP_PU_STATE_IDLE; in lp_pu_complete_finalize()
503 static void lp_pu_tx_ntf(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_tx_ntf() argument
505 pu_ntf(conn, ctx); in lp_pu_tx_ntf()
507 pu_dle_ntf(conn, ctx); in lp_pu_tx_ntf()
509 lp_pu_complete_finalize(conn, ctx); in lp_pu_tx_ntf()
512 static void lp_pu_complete(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_complete() argument
521 ctx->state = LP_PU_STATE_WAIT_INSTANT_ON_AIR; in lp_pu_complete()
524 static void lp_pu_send_phy_req(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_send_phy_req() argument
527 !llcp_tx_alloc_peek(conn, ctx) || in lp_pu_send_phy_req()
529 ctx->state = LP_PU_STATE_WAIT_TX_PHY_REQ; in lp_pu_send_phy_req()
533 ctx->tx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_REQ; in lp_pu_send_phy_req()
536 ctx->node_ref.tx = llcp_tx_alloc(conn, ctx); in lp_pu_send_phy_req()
537 lp_pu_tx(conn, ctx, evt, param); in lp_pu_send_phy_req()
542 static void lp_pu_send_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_send_phy_update_ind() argument
545 if (llcp_lr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx)) { in lp_pu_send_phy_update_ind()
546 ctx->state = LP_PU_STATE_WAIT_TX_PHY_UPDATE_IND; in lp_pu_send_phy_update_ind()
548 ctx->tx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND; in lp_pu_send_phy_update_ind()
551 ctx->node_ref.tx = llcp_tx_alloc(conn, ctx); in lp_pu_send_phy_update_ind()
552 lp_pu_tx(conn, ctx, evt, param); in lp_pu_send_phy_update_ind()
557 static void lp_pu_st_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_st_idle() argument
561 lp_pu_send_phy_req(conn, ctx, evt, param); in lp_pu_st_idle()
569 static void lp_pu_st_wait_tx_phy_req(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_tx_phy_req() argument
574 lp_pu_send_phy_req(conn, ctx, evt, param); in lp_pu_st_wait_tx_phy_req()
583 static void lp_pu_st_wait_rx_phy_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_rx_phy_rsp() argument
590 uint8_t tx_pref = ctx->data.pu.tx; in lp_pu_st_wait_rx_phy_rsp()
591 uint8_t rx_pref = ctx->data.pu.rx; in lp_pu_st_wait_rx_phy_rsp()
593 llcp_pdu_decode_phy_rsp(ctx, (struct pdu_data *)param); in lp_pu_st_wait_rx_phy_rsp()
597 pu_combine_phys(conn, ctx, tx_pref, rx_pref); in lp_pu_st_wait_rx_phy_rsp()
600 llcp_rx_node_retain(ctx); in lp_pu_st_wait_rx_phy_rsp()
602 lp_pu_send_phy_update_ind(conn, ctx, evt, param); in lp_pu_st_wait_rx_phy_rsp()
612 llcp_rx_node_retain(ctx); in lp_pu_st_wait_rx_phy_rsp()
614 ctx->data.pu.error = BT_HCI_ERR_UNSUPP_REMOTE_FEATURE; in lp_pu_st_wait_rx_phy_rsp()
615 ctx->data.pu.ntf_pu = 1; in lp_pu_st_wait_rx_phy_rsp()
616 lp_pu_complete(conn, ctx, evt, param); in lp_pu_st_wait_rx_phy_rsp()
626 static void lp_pu_st_wait_tx_ack_phy_req(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_tx_ack_phy_req() argument
634 ctx->state = LP_PU_STATE_WAIT_RX_PHY_RSP; in lp_pu_st_wait_tx_ack_phy_req()
635 ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_RSP; in lp_pu_st_wait_tx_ack_phy_req()
642 conn, pu_select_phy_timing_restrict(conn, ctx->data.pu.tx)); in lp_pu_st_wait_tx_ack_phy_req()
643 ctx->state = LP_PU_STATE_WAIT_RX_PHY_UPDATE_IND; in lp_pu_st_wait_tx_ack_phy_req()
644 ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND; in lp_pu_st_wait_tx_ack_phy_req()
661 static void lp_pu_st_wait_tx_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_tx_phy_update_ind() argument
666 lp_pu_send_phy_update_ind(conn, ctx, evt, param); in lp_pu_st_wait_tx_phy_update_ind()
674 static void lp_pu_st_wait_tx_ack_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, in lp_pu_st_wait_tx_ack_phy_update_ind() argument
680 if (ctx->data.pu.p_to_c_phy || ctx->data.pu.c_to_p_phy) { in lp_pu_st_wait_tx_ack_phy_update_ind()
682 if (ctx->data.pu.c_to_p_phy) { in lp_pu_st_wait_tx_ack_phy_update_ind()
684 pu_set_timing_restrict(conn, ctx->data.pu.c_to_p_phy); in lp_pu_st_wait_tx_ack_phy_update_ind()
693 ctx->state = LP_PU_STATE_WAIT_INSTANT; in lp_pu_st_wait_tx_ack_phy_update_ind()
696 ctx->data.pu.error = BT_HCI_ERR_SUCCESS; in lp_pu_st_wait_tx_ack_phy_update_ind()
697 ctx->data.pu.ntf_pu = ctx->data.pu.host_initiated; in lp_pu_st_wait_tx_ack_phy_update_ind()
698 lp_pu_complete(conn, ctx, evt, param); in lp_pu_st_wait_tx_ack_phy_update_ind()
710 static void lp_pu_st_wait_rx_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_rx_phy_update_ind() argument
717 llcp_pdu_decode_phy_update_ind(ctx, (struct pdu_data *)param); in lp_pu_st_wait_rx_phy_update_ind()
718 const uint8_t end_procedure = pu_check_update_ind(conn, ctx); in lp_pu_st_wait_rx_phy_update_ind()
721 llcp_rx_node_retain(ctx); in lp_pu_st_wait_rx_phy_update_ind()
724 if (ctx->data.pu.p_to_c_phy) { in lp_pu_st_wait_rx_phy_update_ind()
726 pu_set_timing_restrict(conn, ctx->data.pu.p_to_c_phy); in lp_pu_st_wait_rx_phy_update_ind()
734 ctx->state = LP_PU_STATE_WAIT_INSTANT; in lp_pu_st_wait_rx_phy_update_ind()
737 if (ctx->data.pu.error != BT_HCI_ERR_SUCCESS) { in lp_pu_st_wait_rx_phy_update_ind()
739 conn->llcp_terminate.reason_final = ctx->data.pu.error; in lp_pu_st_wait_rx_phy_update_ind()
741 ctx->data.pu.ntf_pu = ctx->data.pu.host_initiated; in lp_pu_st_wait_rx_phy_update_ind()
742 lp_pu_complete(conn, ctx, evt, param); in lp_pu_st_wait_rx_phy_update_ind()
747 llcp_pdu_decode_reject_ext_ind(ctx, (struct pdu_data *)param); in lp_pu_st_wait_rx_phy_update_ind()
748 ctx->data.pu.error = ctx->reject_ext_ind.error_code; in lp_pu_st_wait_rx_phy_update_ind()
754 ctx->data.pu.error = BT_HCI_ERR_UNSUPP_REMOTE_FEATURE; in lp_pu_st_wait_rx_phy_update_ind()
757 llcp_rx_node_retain(ctx); in lp_pu_st_wait_rx_phy_update_ind()
759 ctx->data.pu.ntf_pu = 1; in lp_pu_st_wait_rx_phy_update_ind()
760 lp_pu_complete(conn, ctx, evt, param); in lp_pu_st_wait_rx_phy_update_ind()
770 static void lp_pu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_check_instant() argument
773 if (is_instant_reached_or_passed(ctx->data.pu.instant, ull_conn_event_counter(conn))) { in lp_pu_check_instant()
774 const uint8_t phy_changed = pu_apply_phy_update(conn, ctx); in lp_pu_check_instant()
777 ctx->data.pu.ntf_dle = pu_update_eff_times(conn, ctx); in lp_pu_check_instant()
781 ctx->data.pu.error = BT_HCI_ERR_SUCCESS; in lp_pu_check_instant()
782 ctx->data.pu.ntf_pu = (phy_changed || ctx->data.pu.host_initiated); in lp_pu_check_instant()
783 lp_pu_complete(conn, ctx, evt, param); in lp_pu_check_instant()
787 static void lp_pu_st_wait_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_instant() argument
792 lp_pu_check_instant(conn, ctx, evt, param); in lp_pu_st_wait_instant()
800 static void lp_pu_st_wait_instant_on_air(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_instant_on_air() argument
805 lp_pu_tx_ntf(conn, ctx, evt, param); in lp_pu_st_wait_instant_on_air()
814 static void lp_pu_st_wait_ntf_avail(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_pu_st_wait_ntf_avail() argument
819 lp_pu_tx(conn, ctx, evt, param); in lp_pu_st_wait_ntf_avail()
828 static void lp_pu_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_pu_execute_fsm() argument
830 switch (ctx->state) { in lp_pu_execute_fsm()
832 lp_pu_st_idle(conn, ctx, evt, param); in lp_pu_execute_fsm()
835 lp_pu_st_wait_tx_phy_req(conn, ctx, evt, param); in lp_pu_execute_fsm()
838 lp_pu_st_wait_tx_ack_phy_req(conn, ctx, evt, param); in lp_pu_execute_fsm()
842 lp_pu_st_wait_rx_phy_rsp(conn, ctx, evt, param); in lp_pu_execute_fsm()
845 lp_pu_st_wait_tx_phy_update_ind(conn, ctx, evt, param); in lp_pu_execute_fsm()
848 lp_pu_st_wait_tx_ack_phy_update_ind(conn, ctx, evt, param); in lp_pu_execute_fsm()
853 lp_pu_st_wait_rx_phy_update_ind(conn, ctx, evt, param); in lp_pu_execute_fsm()
857 lp_pu_st_wait_instant(conn, ctx, evt, param); in lp_pu_execute_fsm()
860 lp_pu_st_wait_instant_on_air(conn, ctx, evt, param); in lp_pu_execute_fsm()
864 lp_pu_st_wait_ntf_avail(conn, ctx, evt, param); in lp_pu_execute_fsm()
873 void llcp_lp_pu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pdu *rx) in llcp_lp_pu_rx() argument
880 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_PHY_RSP, pdu); in llcp_lp_pu_rx()
885 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_PHY_UPDATE_IND, pdu); in llcp_lp_pu_rx()
889 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_UNKNOWN, pdu); in llcp_lp_pu_rx()
892 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_REJECT, pdu); in llcp_lp_pu_rx()
899 ctx->state = LP_PU_STATE_IDLE; in llcp_lp_pu_rx()
904 void llcp_lp_pu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_lp_pu_run() argument
906 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_RUN, param); in llcp_lp_pu_run()
909 void llcp_lp_pu_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_lp_pu_tx_ack() argument
911 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_ACK, param); in llcp_lp_pu_tx_ack()
914 void llcp_lp_pu_tx_ntf(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_lp_pu_tx_ntf() argument
916 lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_NTF, NULL); in llcp_lp_pu_tx_ntf()
919 bool llcp_lp_pu_awaiting_instant(struct proc_ctx *ctx) in llcp_lp_pu_awaiting_instant() argument
921 return (ctx->state == LP_PU_STATE_WAIT_INSTANT); in llcp_lp_pu_awaiting_instant()
927 static void rp_pu_tx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_tx() argument
932 LL_ASSERT(ctx->node_ref.tx); in rp_pu_tx()
937 ctx->state = RP_PU_STATE_WAIT_NTF_AVAIL; in rp_pu_tx()
941 ctx->data.pu.ntf_dle_node = llcp_ntf_alloc(); in rp_pu_tx()
942 LL_ASSERT(ctx->data.pu.ntf_dle_node); in rp_pu_tx()
945 tx = ctx->node_ref.tx; in rp_pu_tx()
946 ctx->node_ref.tx = NULL; in rp_pu_tx()
948 ctx->node_ref.tx_ack = tx; in rp_pu_tx()
951 switch (ctx->tx_opcode) { in rp_pu_tx()
955 ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND; in rp_pu_tx()
956 ctx->state = RP_PU_STATE_WAIT_TX_ACK_PHY_RSP; in rp_pu_tx()
961 pu_prep_update_ind(conn, ctx); in rp_pu_tx()
962 pu_prepare_instant(conn, ctx); in rp_pu_tx()
963 llcp_pdu_encode_phy_update_ind(ctx, pdu); in rp_pu_tx()
964 ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_UNUSED; in rp_pu_tx()
965 ctx->state = RP_PU_STATE_WAIT_TX_ACK_PHY_UPDATE_IND; in rp_pu_tx()
979 static void rp_pu_complete_finalize(struct ll_conn *conn, struct proc_ctx *ctx) in rp_pu_complete_finalize() argument
983 ctx->state = RP_PU_STATE_IDLE; in rp_pu_complete_finalize()
986 static void rp_pu_complete(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_complete() argument
994 ctx->state = RP_PU_STATE_WAIT_INSTANT_ON_AIR; in rp_pu_complete()
997 static void rp_pu_tx_ntf(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_tx_ntf() argument
999 pu_ntf(conn, ctx); in rp_pu_tx_ntf()
1001 pu_dle_ntf(conn, ctx); in rp_pu_tx_ntf()
1003 rp_pu_complete_finalize(conn, ctx); in rp_pu_tx_ntf()
1007 static void rp_pu_send_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_send_phy_update_ind() argument
1010 if (llcp_rr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx) || in rp_pu_send_phy_update_ind()
1013 ctx->state = RP_PU_STATE_WAIT_TX_PHY_UPDATE_IND; in rp_pu_send_phy_update_ind()
1016 ctx->tx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND; in rp_pu_send_phy_update_ind()
1017 ctx->node_ref.tx = llcp_tx_alloc(conn, ctx); in rp_pu_send_phy_update_ind()
1018 rp_pu_tx(conn, ctx, evt, param); in rp_pu_send_phy_update_ind()
1025 static void rp_pu_send_phy_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_send_phy_rsp() argument
1027 if (llcp_rr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx) || in rp_pu_send_phy_rsp()
1029 ctx->state = RP_PU_STATE_WAIT_TX_PHY_RSP; in rp_pu_send_phy_rsp()
1032 ctx->tx_opcode = PDU_DATA_LLCTRL_TYPE_PHY_RSP; in rp_pu_send_phy_rsp()
1033 ctx->node_ref.tx = llcp_tx_alloc(conn, ctx); in rp_pu_send_phy_rsp()
1034 rp_pu_tx(conn, ctx, evt, param); in rp_pu_send_phy_rsp()
1039 static void rp_pu_st_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_st_idle() argument
1043 ctx->state = RP_PU_STATE_WAIT_RX_PHY_REQ; in rp_pu_st_idle()
1051 static void rp_pu_st_wait_rx_phy_req(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_rx_phy_req() argument
1054 llcp_pdu_decode_phy_req(ctx, (struct pdu_data *)param); in rp_pu_st_wait_rx_phy_req()
1056 pu_combine_phys(conn, ctx, conn->phy_pref_tx, conn->phy_pref_rx); in rp_pu_st_wait_rx_phy_req()
1065 llcp_rx_node_retain(ctx); in rp_pu_st_wait_rx_phy_req()
1066 rp_pu_send_phy_update_ind(conn, ctx, evt, param); in rp_pu_st_wait_rx_phy_req()
1071 rp_pu_send_phy_rsp(conn, ctx, evt, param); in rp_pu_st_wait_rx_phy_req()
1086 static void rp_pu_st_wait_tx_phy_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_tx_phy_rsp() argument
1091 rp_pu_send_phy_rsp(conn, ctx, evt, param); in rp_pu_st_wait_tx_phy_rsp()
1100 static void rp_pu_st_wait_tx_ack_phy(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_tx_ack_phy() argument
1107 } else if (ctx->state == RP_PU_STATE_WAIT_TX_ACK_PHY_RSP) { in rp_pu_st_wait_tx_ack_phy()
1111 conn, pu_select_phy_timing_restrict(conn, ctx->data.pu.tx)); in rp_pu_st_wait_tx_ack_phy()
1113 ctx->state = RP_PU_STATE_WAIT_RX_PHY_UPDATE_IND; in rp_pu_st_wait_tx_ack_phy()
1116 } else if (ctx->state == RP_PU_STATE_WAIT_TX_ACK_PHY_UPDATE_IND) { in rp_pu_st_wait_tx_ack_phy()
1118 if (ctx->data.pu.c_to_p_phy || ctx->data.pu.p_to_c_phy) { in rp_pu_st_wait_tx_ack_phy()
1120 if (ctx->data.pu.c_to_p_phy) { in rp_pu_st_wait_tx_ack_phy()
1125 pu_set_timing_restrict(conn, ctx->data.pu.c_to_p_phy); in rp_pu_st_wait_tx_ack_phy()
1127 ctx->state = RP_PU_STATE_WAIT_INSTANT; in rp_pu_st_wait_tx_ack_phy()
1129 rp_pu_complete(conn, ctx, evt, param); in rp_pu_st_wait_tx_ack_phy()
1144 static void rp_pu_st_wait_tx_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_tx_phy_update_ind() argument
1149 rp_pu_send_phy_update_ind(conn, ctx, evt, param); in rp_pu_st_wait_tx_phy_update_ind()
1159 static void rp_pu_st_wait_rx_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_rx_phy_update_ind() argument
1164 llcp_pdu_decode_phy_update_ind(ctx, (struct pdu_data *)param); in rp_pu_st_wait_rx_phy_update_ind()
1165 const uint8_t end_procedure = pu_check_update_ind(conn, ctx); in rp_pu_st_wait_rx_phy_update_ind()
1168 llcp_rx_node_retain(ctx); in rp_pu_st_wait_rx_phy_update_ind()
1175 ctx->state = RP_PU_STATE_WAIT_INSTANT; in rp_pu_st_wait_rx_phy_update_ind()
1177 if (ctx->data.pu.error == BT_HCI_ERR_INSTANT_PASSED) { in rp_pu_st_wait_rx_phy_update_ind()
1181 rp_pu_complete(conn, ctx, evt, param); in rp_pu_st_wait_rx_phy_update_ind()
1191 static void rp_pu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_check_instant() argument
1194 if (is_instant_reached_or_passed(ctx->data.pu.instant, ull_conn_event_counter(conn))) { in rp_pu_check_instant()
1195 ctx->data.pu.error = BT_HCI_ERR_SUCCESS; in rp_pu_check_instant()
1196 const uint8_t phy_changed = pu_apply_phy_update(conn, ctx); in rp_pu_check_instant()
1199 ctx->data.pu.ntf_dle = pu_update_eff_times(conn, ctx); in rp_pu_check_instant()
1203 ctx->data.pu.ntf_pu = phy_changed; in rp_pu_check_instant()
1204 rp_pu_complete(conn, ctx, evt, param); in rp_pu_check_instant()
1208 static void rp_pu_st_wait_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_instant() argument
1213 rp_pu_check_instant(conn, ctx, evt, param); in rp_pu_st_wait_instant()
1221 static void rp_pu_st_wait_instant_on_air(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_instant_on_air() argument
1226 rp_pu_tx_ntf(conn, ctx, evt, param); in rp_pu_st_wait_instant_on_air()
1235 static void rp_pu_st_wait_ntf_avail(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_pu_st_wait_ntf_avail() argument
1240 rp_pu_tx(conn, ctx, evt, param); in rp_pu_st_wait_ntf_avail()
1249 static void rp_pu_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_pu_execute_fsm() argument
1251 switch (ctx->state) { in rp_pu_execute_fsm()
1253 rp_pu_st_idle(conn, ctx, evt, param); in rp_pu_execute_fsm()
1256 rp_pu_st_wait_rx_phy_req(conn, ctx, evt, param); in rp_pu_execute_fsm()
1260 rp_pu_st_wait_tx_phy_rsp(conn, ctx, evt, param); in rp_pu_execute_fsm()
1263 rp_pu_st_wait_tx_ack_phy(conn, ctx, evt, param); in rp_pu_execute_fsm()
1266 rp_pu_st_wait_rx_phy_update_ind(conn, ctx, evt, param); in rp_pu_execute_fsm()
1271 rp_pu_st_wait_tx_phy_update_ind(conn, ctx, evt, param); in rp_pu_execute_fsm()
1274 rp_pu_st_wait_tx_ack_phy(conn, ctx, evt, param); in rp_pu_execute_fsm()
1278 rp_pu_st_wait_instant(conn, ctx, evt, param); in rp_pu_execute_fsm()
1281 rp_pu_st_wait_instant_on_air(conn, ctx, evt, param); in rp_pu_execute_fsm()
1285 rp_pu_st_wait_ntf_avail(conn, ctx, evt, param); in rp_pu_execute_fsm()
1294 void llcp_rp_pu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pdu *rx) in llcp_rp_pu_rx() argument
1300 rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_PHY_REQ, pdu); in llcp_rp_pu_rx()
1304 rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_PHY_UPDATE_IND, pdu); in llcp_rp_pu_rx()
1312 ctx->state = RP_PU_STATE_IDLE; in llcp_rp_pu_rx()
1317 void llcp_rp_pu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_rp_pu_run() argument
1319 rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_RUN, param); in llcp_rp_pu_run()
1322 void llcp_rp_pu_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_rp_pu_tx_ack() argument
1324 rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_ACK, param); in llcp_rp_pu_tx_ack()
1327 void llcp_rp_pu_tx_ntf(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_rp_pu_tx_ntf() argument
1329 rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_NTF, NULL); in llcp_rp_pu_tx_ntf()
1332 bool llcp_rp_pu_awaiting_instant(struct proc_ctx *ctx) in llcp_rp_pu_awaiting_instant() argument
1334 return (ctx->state == RP_PU_STATE_WAIT_INSTANT); in llcp_rp_pu_awaiting_instant()