bluetooth: controller: use global ull_conn_event_counter() in procedures
Replace the use of local event_counter() functions with one defined in ull_conn.c Signed-off-by: Erik Brockhoff <erbr@oticon.com>
This commit is contained in:
parent
0a9b4a41c7
commit
e42d453e3e
3 changed files with 10 additions and 56 deletions
|
@ -74,16 +74,6 @@ enum {
|
|||
/*
|
||||
* LLCP Local Procedure Channel Map Update FSM
|
||||
*/
|
||||
|
||||
/* TODO should go into some utils file */
|
||||
static uint16_t lp_event_counter(struct ll_conn *conn)
|
||||
{
|
||||
struct lll_conn *lll = &conn->lll;
|
||||
|
||||
/* Calculate current event counter */
|
||||
return lll->event_counter + lll->latency_prepare;
|
||||
}
|
||||
|
||||
static void lp_chmu_tx(struct ll_conn *conn, struct proc_ctx *ctx)
|
||||
{
|
||||
struct node_tx *tx;
|
||||
|
@ -119,7 +109,7 @@ static void lp_chmu_send_channel_map_update_ind(struct ll_conn *conn, struct pro
|
|||
} else {
|
||||
llcp_rr_set_incompat(conn, INCOMPAT_RESOLVABLE);
|
||||
|
||||
ctx->data.chmu.instant = lp_event_counter(conn) + CHMU_INSTANT_DELTA;
|
||||
ctx->data.chmu.instant = ull_conn_event_counter(conn) + CHMU_INSTANT_DELTA;
|
||||
|
||||
lp_chmu_tx(conn, ctx);
|
||||
|
||||
|
@ -155,7 +145,7 @@ static void lp_chmu_st_wait_tx_chan_map_ind(struct ll_conn *conn, struct proc_ct
|
|||
static void lp_chmu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
uint16_t event_counter = lp_event_counter(conn);
|
||||
uint16_t event_counter = ull_conn_event_counter(conn);
|
||||
|
||||
if (is_instant_reached_or_passed(ctx->data.chmu.instant, event_counter)) {
|
||||
llcp_rr_set_incompat(conn, INCOMPAT_NO_COLLISION);
|
||||
|
@ -210,16 +200,6 @@ void llcp_lp_chmu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
|||
/*
|
||||
* LLCP Remote Procedure Channel Map Update FSM
|
||||
*/
|
||||
|
||||
/* TODO should go into some utils file */
|
||||
static uint16_t rp_event_counter(struct ll_conn *conn)
|
||||
{
|
||||
struct lll_conn *lll = &conn->lll;
|
||||
|
||||
/* Calculate current event counter */
|
||||
return lll->event_counter + lll->latency_prepare;
|
||||
}
|
||||
|
||||
static void rp_chmu_complete(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param)
|
||||
{
|
||||
ull_conn_chan_map_set(conn, ctx->data.chmu.chm);
|
||||
|
@ -256,7 +236,7 @@ static void rp_chmu_st_wait_rx_channel_map_update_ind(struct ll_conn *conn, stru
|
|||
static void rp_chmu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
uint16_t event_counter = rp_event_counter(conn);
|
||||
uint16_t event_counter = ull_conn_event_counter(conn);
|
||||
|
||||
if (((event_counter - ctx->data.chmu.instant) & 0xFFFF) <= 0x7FFF) {
|
||||
rp_chmu_complete(conn, ctx, evt, param);
|
||||
|
|
|
@ -174,23 +174,6 @@ static void pu_reset_timing_restrict(struct ll_conn *conn)
|
|||
pu_set_timing_restrict(conn, conn->lll.phy_tx);
|
||||
}
|
||||
|
||||
static uint16_t pu_event_counter(struct ll_conn *conn)
|
||||
{
|
||||
struct lll_conn *lll;
|
||||
uint16_t event_counter;
|
||||
|
||||
/* TODO(thoh): Lazy hardcoded */
|
||||
uint16_t lazy = 0;
|
||||
|
||||
/**/
|
||||
lll = &conn->lll;
|
||||
|
||||
/* Calculate current event counter */
|
||||
event_counter = lll->event_counter + lll->latency_prepare + lazy;
|
||||
|
||||
return event_counter;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
static uint8_t pu_check_update_ind(struct ll_conn *conn, struct proc_ctx *ctx)
|
||||
{
|
||||
|
@ -203,7 +186,8 @@ static uint8_t pu_check_update_ind(struct ll_conn *conn, struct proc_ctx *ctx)
|
|||
ret = 1;
|
||||
} else {
|
||||
/* if instant already passed, quit procedure with error */
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant, pu_event_counter(conn))) {
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant,
|
||||
ull_conn_event_counter(conn))) {
|
||||
ctx->data.pu.error = BT_HCI_ERR_INSTANT_PASSED;
|
||||
ret = 1;
|
||||
}
|
||||
|
@ -457,7 +441,7 @@ static void lp_pu_send_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx
|
|||
if (ctx->pause || !llcp_tx_alloc_peek(conn, ctx)) {
|
||||
ctx->state = LP_PU_STATE_WAIT_TX_PHY_UPDATE_IND;
|
||||
} else {
|
||||
ctx->data.pu.instant = pu_event_counter(conn) + PHY_UPDATE_INSTANT_DELTA;
|
||||
ctx->data.pu.instant = ull_conn_event_counter(conn) + PHY_UPDATE_INSTANT_DELTA;
|
||||
lp_pu_tx(conn, ctx, PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND);
|
||||
ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_UNUSED;
|
||||
ctx->state = LP_PU_STATE_WAIT_TX_ACK_PHY_UPDATE_IND;
|
||||
|
@ -646,7 +630,7 @@ static void lp_pu_st_wait_rx_phy_update_ind(struct ll_conn *conn, struct proc_ct
|
|||
static void lp_pu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant, pu_event_counter(conn))) {
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant, ull_conn_event_counter(conn))) {
|
||||
const uint8_t phy_changed = pu_apply_phy_update(conn, ctx);
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
if (phy_changed) {
|
||||
|
@ -844,7 +828,7 @@ static void rp_pu_send_phy_update_ind(struct ll_conn *conn, struct proc_ctx *ctx
|
|||
ctx->state = RP_PU_STATE_WAIT_TX_PHY_UPDATE_IND;
|
||||
} else {
|
||||
llcp_rr_set_paused_cmd(conn, PROC_CTE_REQ);
|
||||
ctx->data.pu.instant = pu_event_counter(conn) + PHY_UPDATE_INSTANT_DELTA;
|
||||
ctx->data.pu.instant = ull_conn_event_counter(conn) + PHY_UPDATE_INSTANT_DELTA;
|
||||
rp_pu_tx(conn, ctx, PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND);
|
||||
ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_UNUSED;
|
||||
ctx->state = RP_PU_STATE_WAIT_TX_ACK_PHY_UPDATE_IND;
|
||||
|
@ -1011,7 +995,7 @@ static void rp_pu_st_wait_rx_phy_update_ind(struct ll_conn *conn, struct proc_ct
|
|||
static void rp_pu_check_instant(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant, pu_event_counter(conn))) {
|
||||
if (is_instant_reached_or_passed(ctx->data.pu.instant, ull_conn_event_counter(conn))) {
|
||||
ctx->data.pu.error = BT_HCI_ERR_SUCCESS;
|
||||
const uint8_t phy_changed = pu_apply_phy_update(conn, ctx);
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "helper_util.h"
|
||||
|
||||
static uint32_t event_active;
|
||||
static uint16_t lazy;
|
||||
sys_slist_t ut_rx_q;
|
||||
static sys_slist_t lt_tx_q;
|
||||
static uint32_t no_of_ctx_buffers_at_test_setup;
|
||||
|
@ -223,7 +222,6 @@ void test_setup(struct ll_conn *conn)
|
|||
ll_reset();
|
||||
conn->lll.event_counter = 0;
|
||||
event_active = 0;
|
||||
lazy = 0;
|
||||
|
||||
no_of_ctx_buffers_at_test_setup = ctx_buffers_free();
|
||||
}
|
||||
|
@ -260,9 +258,6 @@ void event_prepare(struct ll_conn *conn)
|
|||
lll->event_counter = event_counter + 1;
|
||||
|
||||
lll->latency_prepare = 0;
|
||||
|
||||
/* Rest lazy */
|
||||
lazy = 0;
|
||||
}
|
||||
|
||||
void event_tx_ack(struct ll_conn *conn, struct node_tx *tx)
|
||||
|
@ -289,15 +284,10 @@ void event_done(struct ll_conn *conn)
|
|||
|
||||
uint16_t event_counter(struct ll_conn *conn)
|
||||
{
|
||||
/* TODO(thoh): Mocked lll_conn */
|
||||
struct lll_conn *lll;
|
||||
uint16_t event_counter;
|
||||
|
||||
/**/
|
||||
lll = &conn->lll;
|
||||
|
||||
/* Calculate current event counter */
|
||||
event_counter = lll->event_counter + lll->latency_prepare + lazy;
|
||||
event_counter = ull_conn_event_counter(conn);
|
||||
|
||||
/* If event_counter is called inside an event_prepare()/event_done() pair
|
||||
* return the current event counter value (i.e. -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue