Lines Matching full:ctx

81 static uint8_t rp_check_phy(struct ll_conn *conn, struct proc_ctx *ctx,  in rp_check_phy()  argument
102 static void rp_past_complete(struct ll_conn *conn, struct proc_ctx *ctx) in rp_past_complete() argument
105 ctx->state = RP_PAST_STATE_IDLE; in rp_past_complete()
108 static void rp_past_st_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in rp_past_st_idle() argument
112 ctx->state = RP_PAST_STATE_WAIT_RX; in rp_past_st_idle()
125 struct proc_ctx *ctx; in rp_past_resolve_cb() local
131 ctx = llcp_rr_peek(conn); in rp_past_resolve_cb()
132 if (!ctx) { in rp_past_resolve_cb()
139 if (ctx->state != RP_PAST_STATE_WAIT_RESOLVE_COMPLETE) { in rp_past_resolve_cb()
152 memcpy(&ctx->data.periodic_sync.adv_addr, &id_addr->val, sizeof(bt_addr_t)); in rp_past_resolve_cb()
154 ctx->data.periodic_sync.addr_type = id_addr_type; in rp_past_resolve_cb()
155 ctx->data.periodic_sync.addr_resolved = 1U; in rp_past_resolve_cb()
160 ctx->state = RP_PAST_STATE_WAIT_NEXT_EVT; in rp_past_resolve_cb()
163 static bool rp_past_addr_resolve(struct ll_conn *conn, struct proc_ctx *ctx) in rp_past_addr_resolve() argument
172 (void)memcpy(&adv_addr.val, ctx->data.periodic_sync.adv_addr, sizeof(bt_addr_t)); in rp_past_addr_resolve()
185 static void rp_past_st_wait_resolve_if(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_past_st_wait_resolve_if() argument
190 if (rp_past_addr_resolve(conn, ctx)) { in rp_past_st_wait_resolve_if()
191 ctx->state = RP_PAST_STATE_WAIT_RESOLVE_COMPLETE; in rp_past_st_wait_resolve_if()
201 static void rp_past_st_wait_rx(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_past_st_wait_rx() argument
208 llcp_pdu_decode_periodic_sync_ind(ctx, pdu); in rp_past_st_wait_rx()
211 if (rp_check_phy(conn, ctx, pdu) != BT_HCI_ERR_SUCCESS) { in rp_past_st_wait_rx()
213 rp_past_complete(conn, ctx); in rp_past_st_wait_rx()
217 ctx->data.periodic_sync.addr_resolved = 0U; in rp_past_st_wait_rx()
219 if (ctx->data.periodic_sync.addr_type == BT_ADDR_LE_RANDOM) { in rp_past_st_wait_rx()
223 if (rp_past_addr_resolve(conn, ctx)) { in rp_past_st_wait_rx()
224 ctx->state = RP_PAST_STATE_WAIT_RESOLVE_COMPLETE; in rp_past_st_wait_rx()
227 ctx->state = RP_PAST_STATE_WAIT_RESOLVE_INTERFACE_AVAIL; in rp_past_st_wait_rx()
241 ctx->data.periodic_sync.sync_conn_event_count == in rp_past_st_wait_rx()
243 ctx->state = RP_PAST_STATE_WAIT_NEXT_EVT; in rp_past_st_wait_rx()
250 ctx->data.periodic_sync.id, in rp_past_st_wait_rx()
251 &ctx->data.periodic_sync.sync_info, in rp_past_st_wait_rx()
252 ctx->data.periodic_sync.conn_event_count, in rp_past_st_wait_rx()
253 ctx->data.periodic_sync.last_pa_event_counter, in rp_past_st_wait_rx()
254 ctx->data.periodic_sync.sid, in rp_past_st_wait_rx()
255 ctx->data.periodic_sync.addr_type, in rp_past_st_wait_rx()
256 ctx->data.periodic_sync.sca, in rp_past_st_wait_rx()
257 ctx->data.periodic_sync.phy, in rp_past_st_wait_rx()
258 ctx->data.periodic_sync.adv_addr, in rp_past_st_wait_rx()
259 ctx->data.periodic_sync.sync_conn_event_count, in rp_past_st_wait_rx()
260 ctx->data.periodic_sync.addr_resolved); in rp_past_st_wait_rx()
261 rp_past_complete(conn, ctx); in rp_past_st_wait_rx()
269 static void rp_past_st_wait_next_evt(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_past_st_wait_next_evt() argument
280 ctx->data.periodic_sync.sync_conn_event_count == ull_conn_event_counter(conn)) { in rp_past_st_wait_next_evt()
287 ctx->data.periodic_sync.id, in rp_past_st_wait_next_evt()
288 &ctx->data.periodic_sync.sync_info, in rp_past_st_wait_next_evt()
289 ctx->data.periodic_sync.conn_event_count, in rp_past_st_wait_next_evt()
290 ctx->data.periodic_sync.last_pa_event_counter, in rp_past_st_wait_next_evt()
291 ctx->data.periodic_sync.sid, in rp_past_st_wait_next_evt()
292 ctx->data.periodic_sync.addr_type, in rp_past_st_wait_next_evt()
293 ctx->data.periodic_sync.sca, in rp_past_st_wait_next_evt()
294 ctx->data.periodic_sync.phy, in rp_past_st_wait_next_evt()
295 ctx->data.periodic_sync.adv_addr, in rp_past_st_wait_next_evt()
296 ctx->data.periodic_sync.sync_conn_event_count, in rp_past_st_wait_next_evt()
297 ctx->data.periodic_sync.addr_resolved); in rp_past_st_wait_next_evt()
298 rp_past_complete(conn, ctx); in rp_past_st_wait_next_evt()
306 static void rp_past_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in rp_past_execute_fsm() argument
309 switch (ctx->state) { in rp_past_execute_fsm()
311 rp_past_st_idle(conn, ctx, evt, param); in rp_past_execute_fsm()
314 rp_past_st_wait_rx(conn, ctx, evt, param); in rp_past_execute_fsm()
317 rp_past_st_wait_next_evt(conn, ctx, evt, param); in rp_past_execute_fsm()
321 rp_past_st_wait_resolve_if(conn, ctx, evt, param); in rp_past_execute_fsm()
334 void llcp_rp_past_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pdu *rx) in llcp_rp_past_rx() argument
336 rp_past_execute_fsm(conn, ctx, RP_PAST_EVT_RX, rx->pdu); in llcp_rp_past_rx()
339 void llcp_rp_past_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_rp_past_run() argument
341 rp_past_execute_fsm(conn, ctx, RP_PAST_EVT_RUN, param); in llcp_rp_past_run()
374 static void lp_past_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
377 static void lp_past_complete(struct ll_conn *conn, struct proc_ctx *ctx) in lp_past_complete() argument
380 ctx->state = LP_PAST_STATE_IDLE; in lp_past_complete()
383 static void lp_past_tx(struct ll_conn *conn, struct proc_ctx *ctx) in lp_past_tx() argument
393 offset_us = ctx->data.periodic_sync.offset_us - in lp_past_tx()
394 ctx->data.periodic_sync.conn_start_to_actual_us; in lp_past_tx()
396 llcp_pdu_fill_sync_info_offset(&ctx->data.periodic_sync.sync_info, in lp_past_tx()
402 tx = llcp_tx_alloc(conn, ctx); in lp_past_tx()
408 llcp_pdu_encode_periodic_sync_ind(ctx, pdu); in lp_past_tx()
414 ctx->state = LP_PAST_STATE_WAIT_TX_ACK; in lp_past_tx()
415 ctx->node_ref.tx_ack = tx; in lp_past_tx()
418 void llcp_lp_past_offset_calc_reply(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_lp_past_offset_calc_reply() argument
420 lp_past_execute_fsm(conn, ctx, LP_PAST_EVT_OFFSET_CALC_REPLY, NULL); in llcp_lp_past_offset_calc_reply()
423 static void lp_past_offset_calc_req(struct ll_conn *conn, struct proc_ctx *ctx, in lp_past_offset_calc_req() argument
426 if (llcp_lr_ispaused(conn) || !llcp_tx_alloc_peek(conn, ctx)) { in lp_past_offset_calc_req()
427 ctx->state = LP_PAST_STATE_WAIT_TX_REQ; in lp_past_offset_calc_req()
430 ctx->state = LP_PAST_STATE_WAIT_OFFSET_CALC; in lp_past_offset_calc_req()
435 static void lp_past_st_wait_tx_req(struct ll_conn *conn, struct proc_ctx *ctx, in lp_past_st_wait_tx_req() argument
440 lp_past_offset_calc_req(conn, ctx, evt, param); in lp_past_st_wait_tx_req()
448 static void lp_past_st_wait_offset_calc(struct ll_conn *conn, struct proc_ctx *ctx, in lp_past_st_wait_offset_calc() argument
455 ctx->state = LP_PAST_STATE_WAIT_EVT_DONE; in lp_past_st_wait_offset_calc()
456 } else if (ctx->data.periodic_sync.conn_evt_trx) { in lp_past_st_wait_offset_calc()
458 lp_past_tx(conn, ctx); in lp_past_st_wait_offset_calc()
461 ctx->state = LP_PAST_STATE_WAIT_TX_REQ; in lp_past_st_wait_offset_calc()
470 void llcp_lp_past_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, struct node_tx *tx) in llcp_lp_past_tx_ack() argument
472 lp_past_execute_fsm(conn, ctx, LP_PAST_EVT_ACK, tx->pdu); in llcp_lp_past_tx_ack()
475 void llcp_lp_past_conn_evt_done(struct ll_conn *conn, struct proc_ctx *ctx) in llcp_lp_past_conn_evt_done() argument
477 if (ctx->data.periodic_sync.conn_evt_trx != 0) { in llcp_lp_past_conn_evt_done()
478 lp_past_execute_fsm(conn, ctx, LP_PAST_EVT_RX_RECEIVED, NULL); in llcp_lp_past_conn_evt_done()
480 lp_past_execute_fsm(conn, ctx, LP_PAST_EVT_NO_RX_RECEIVED, NULL); in llcp_lp_past_conn_evt_done()
484 static void lp_past_state_wait_evt_done(struct ll_conn *conn, struct proc_ctx *ctx, in lp_past_state_wait_evt_done() argument
500 lp_past_tx(conn, ctx); in lp_past_state_wait_evt_done()
504 ctx->state = LP_PAST_STATE_WAIT_TX_REQ; in lp_past_state_wait_evt_done()
509 static void lp_past_st_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param) in lp_past_st_idle() argument
517 lp_past_offset_calc_req(conn, ctx, evt, param); in lp_past_st_idle()
522 lp_past_complete(conn, ctx); in lp_past_st_idle()
531 static void lp_past_st_wait_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_past_st_wait_tx_ack() argument
537 lp_past_complete(conn, ctx); in lp_past_st_wait_tx_ack()
545 static void lp_past_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, in lp_past_execute_fsm() argument
548 switch (ctx->state) { in lp_past_execute_fsm()
550 lp_past_st_idle(conn, ctx, evt, param); in lp_past_execute_fsm()
553 lp_past_st_wait_tx_req(conn, ctx, evt, param); in lp_past_execute_fsm()
556 lp_past_st_wait_offset_calc(conn, ctx, evt, param); in lp_past_execute_fsm()
559 lp_past_st_wait_tx_ack(conn, ctx, evt, param); in lp_past_execute_fsm()
562 lp_past_state_wait_evt_done(conn, ctx, evt, param); in lp_past_execute_fsm()
571 void llcp_lp_past_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param) in llcp_lp_past_run() argument
573 lp_past_execute_fsm(conn, ctx, LP_PAST_EVT_RUN, param); in llcp_lp_past_run()