Bluetooth: controller: refactor of procedure init for mem optim
Refactoring alloc/init of procedures in LLCP to optimize memory. Signed-off-by: Erik Brockhoff <erbr@oticon.com>
This commit is contained in:
parent
c4fefc0767
commit
7724b3e356
8 changed files with 100 additions and 287 deletions
|
@ -331,8 +331,9 @@ static struct proc_ctx *create_procedure(enum llcp_proc proc, struct llcp_mem_po
|
|||
ctx->rx_greedy = 0U;
|
||||
ctx->node_ref.rx = NULL;
|
||||
ctx->node_ref.tx_ack = NULL;
|
||||
ctx->state = LLCP_STATE_IDLE;
|
||||
|
||||
/* Clear procedure data */
|
||||
/* Clear procedure context data */
|
||||
memset((void *)&ctx->data, 0, sizeof(ctx->data));
|
||||
|
||||
/* Initialize opcodes fields to known values */
|
||||
|
@ -345,172 +346,12 @@ static struct proc_ctx *create_procedure(enum llcp_proc proc, struct llcp_mem_po
|
|||
|
||||
struct proc_ctx *llcp_create_local_procedure(enum llcp_proc proc)
|
||||
{
|
||||
struct proc_ctx *ctx;
|
||||
|
||||
ctx = create_procedure(proc, &mem_local_ctx);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (ctx->proc) {
|
||||
#if defined(CONFIG_BT_CTLR_LE_PING)
|
||||
case PROC_LE_PING:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_LE_PING */
|
||||
case PROC_FEATURE_EXCHANGE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_MIN_USED_CHAN)
|
||||
case PROC_MIN_USED_CHANS:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_MIN_USED_CHAN */
|
||||
case PROC_VERSION_EXCHANGE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC) && defined(CONFIG_BT_CENTRAL)
|
||||
case PROC_ENCRYPTION_START:
|
||||
case PROC_ENCRYPTION_PAUSE:
|
||||
llcp_lp_enc_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_LE_ENC && CONFIG_BT_CENTRAL */
|
||||
#ifdef CONFIG_BT_CTLR_PHY
|
||||
case PROC_PHY_UPDATE:
|
||||
llcp_lp_pu_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
case PROC_CONN_UPDATE:
|
||||
case PROC_CONN_PARAM_REQ:
|
||||
llcp_lp_cu_init_proc(ctx);
|
||||
break;
|
||||
case PROC_TERMINATE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PROC_CHAN_MAP_UPDATE:
|
||||
llcp_lp_chmu_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
case PROC_DATA_LENGTH_UPDATE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
|
||||
case PROC_CTE_REQ:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */
|
||||
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
|
||||
case PROC_CIS_TERMINATE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* defined(CONFIG_BT_CTLR_CENTRAL_ISO) || defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) */
|
||||
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO)
|
||||
case PROC_CIS_CREATE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* defined(CONFIG_BT_CTLR_CENTRAL_ISO) */
|
||||
#if defined(CONFIG_BT_CTLR_SCA_UPDATE)
|
||||
case PROC_SCA_UPDATE:
|
||||
llcp_lp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_SCA_UPDATE */
|
||||
default:
|
||||
/* Unknown procedure */
|
||||
LL_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
return create_procedure(proc, &mem_local_ctx);
|
||||
}
|
||||
|
||||
struct proc_ctx *llcp_create_remote_procedure(enum llcp_proc proc)
|
||||
{
|
||||
struct proc_ctx *ctx;
|
||||
|
||||
ctx = create_procedure(proc, &mem_remote_ctx);
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (ctx->proc) {
|
||||
case PROC_UNKNOWN:
|
||||
/* Nothing to do */
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_LE_PING)
|
||||
case PROC_LE_PING:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_LE_PING */
|
||||
case PROC_FEATURE_EXCHANGE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_MIN_USED_CHAN)
|
||||
case PROC_MIN_USED_CHANS:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_MIN_USED_CHAN */
|
||||
case PROC_VERSION_EXCHANGE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC) && defined(CONFIG_BT_PERIPHERAL)
|
||||
case PROC_ENCRYPTION_START:
|
||||
case PROC_ENCRYPTION_PAUSE:
|
||||
llcp_rp_enc_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_LE_ENC && CONFIG_BT_PERIPHERAL */
|
||||
#ifdef CONFIG_BT_CTLR_PHY
|
||||
case PROC_PHY_UPDATE:
|
||||
llcp_rp_pu_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
case PROC_CONN_UPDATE:
|
||||
case PROC_CONN_PARAM_REQ:
|
||||
llcp_rp_cu_init_proc(ctx);
|
||||
break;
|
||||
case PROC_TERMINATE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PROC_CHAN_MAP_UPDATE:
|
||||
llcp_rp_chmu_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
case PROC_DATA_LENGTH_UPDATE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
|
||||
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP)
|
||||
case PROC_CTE_REQ:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */
|
||||
#if defined(CONFIG_BT_PERIPHERAL) && defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
|
||||
case PROC_CIS_CREATE:
|
||||
llcp_rp_cc_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL && CONFIG_BT_CTLR_PERIPHERAL_ISO */
|
||||
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
|
||||
case PROC_CIS_TERMINATE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* defined(CONFIG_BT_CTLR_CENTRAL_ISO) || defined(CONFIG_BT_CTLR_PERIPHERAL_ISO) */
|
||||
#if defined(CONFIG_BT_CTLR_SCA_UPDATE)
|
||||
case PROC_SCA_UPDATE:
|
||||
llcp_rp_comm_init_proc(ctx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_SCA_UPDATE */
|
||||
|
||||
default:
|
||||
/* Unknown procedure */
|
||||
LL_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
return create_procedure(proc, &mem_remote_ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -85,7 +85,7 @@ static void cc_ntf_established(struct ll_conn *conn, struct proc_ctx *ctx)
|
|||
/* LLCP Remote Procedure FSM states */
|
||||
enum {
|
||||
/* Establish Procedure */
|
||||
RP_CC_STATE_IDLE,
|
||||
RP_CC_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_CC_STATE_WAIT_RX_CIS_REQ,
|
||||
RP_CC_STATE_WAIT_REPLY,
|
||||
RP_CC_STATE_WAIT_TX_CIS_RSP,
|
||||
|
@ -590,17 +590,6 @@ void llcp_rp_cc_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pd
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_rp_cc_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
switch (ctx->proc) {
|
||||
case PROC_CIS_CREATE:
|
||||
ctx->state = RP_CC_STATE_IDLE;
|
||||
break;
|
||||
default:
|
||||
LL_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool llcp_rp_cc_awaiting_reply(struct proc_ctx *ctx)
|
||||
{
|
||||
return (ctx->state == RP_CC_STATE_WAIT_REPLY);
|
||||
|
@ -642,7 +631,7 @@ static void lp_cc_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_
|
|||
|
||||
/* LLCP Local Procedure FSM states */
|
||||
enum {
|
||||
LP_CC_STATE_IDLE,
|
||||
LP_CC_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_CC_STATE_WAIT_NTF_AVAIL,
|
||||
LP_CC_STATE_WAIT_OFFSET_CALC,
|
||||
LP_CC_STATE_WAIT_OFFSET_CALC_TX_REQ,
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
/* LLCP Local Procedure Channel Map Update FSM states */
|
||||
enum {
|
||||
LP_CHMU_STATE_IDLE,
|
||||
LP_CHMU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_CHMU_STATE_WAIT_TX_CHAN_MAP_IND,
|
||||
LP_CHMU_STATE_WAIT_INSTANT,
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ enum {
|
|||
|
||||
/* LLCP Remote Procedure Channel Map Update FSM states */
|
||||
enum {
|
||||
RP_CHMU_STATE_IDLE,
|
||||
RP_CHMU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_CHMU_STATE_WAIT_RX_CHAN_MAP_IND,
|
||||
RP_CHMU_STATE_WAIT_INSTANT,
|
||||
};
|
||||
|
@ -198,11 +198,6 @@ void llcp_lp_chmu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_lp_chmu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = LP_CHMU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_lp_chmu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
lp_chmu_execute_fsm(conn, ctx, LP_CHMU_EVT_RUN, param);
|
||||
|
@ -319,11 +314,6 @@ void llcp_rp_chmu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_rp_chmu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = RP_CHMU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_rp_chmu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
rp_chmu_execute_fsm(conn, ctx, RP_CHMU_EVT_RUN, param);
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
/* LLCP Local Procedure FSM states */
|
||||
enum {
|
||||
LP_COMMON_STATE_IDLE,
|
||||
LP_COMMON_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_COMMON_STATE_WAIT_TX,
|
||||
LP_COMMON_STATE_WAIT_TX_ACK,
|
||||
LP_COMMON_STATE_WAIT_RX,
|
||||
|
@ -84,7 +84,7 @@ enum {
|
|||
|
||||
/* LLCP Remote Procedure Common FSM states */
|
||||
enum {
|
||||
RP_COMMON_STATE_IDLE,
|
||||
RP_COMMON_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_COMMON_STATE_WAIT_RX,
|
||||
RP_COMMON_STATE_POSTPONE_TERMINATE,
|
||||
RP_COMMON_STATE_WAIT_TX,
|
||||
|
@ -921,11 +921,6 @@ void llcp_lp_comm_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_
|
|||
lp_comm_execute_fsm(conn, ctx, LP_COMMON_EVT_RESPONSE, rx->pdu);
|
||||
}
|
||||
|
||||
void llcp_lp_comm_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = LP_COMMON_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_lp_comm_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
lp_comm_execute_fsm(conn, ctx, LP_COMMON_EVT_RUN, param);
|
||||
|
@ -1421,11 +1416,6 @@ void llcp_rp_comm_tx_ack(struct ll_conn *conn, struct proc_ctx *ctx, struct node
|
|||
rp_comm_execute_fsm(conn, ctx, RP_COMMON_EVT_ACK, tx->pdu);
|
||||
}
|
||||
|
||||
void llcp_rp_comm_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = RP_COMMON_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_rp_comm_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
rp_comm_execute_fsm(conn, ctx, RP_COMMON_EVT_RUN, param);
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
/* LLCP Local Procedure Connection Update FSM states */
|
||||
enum {
|
||||
LP_CU_STATE_IDLE,
|
||||
LP_CU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_CU_STATE_WAIT_TX_CONN_PARAM_REQ,
|
||||
LP_CU_STATE_WAIT_RX_CONN_PARAM_RSP,
|
||||
LP_CU_STATE_WAIT_TX_CONN_UPDATE_IND,
|
||||
|
@ -109,7 +109,7 @@ enum {
|
|||
|
||||
/* LLCP Remote Procedure Connection Update FSM states */
|
||||
enum {
|
||||
RP_CU_STATE_IDLE,
|
||||
RP_CU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_CU_STATE_WAIT_RX_CONN_PARAM_REQ,
|
||||
RP_CU_STATE_WAIT_CONN_PARAM_REQ_AVAILABLE,
|
||||
RP_CU_STATE_WAIT_NTF_CONN_PARAM_REQ,
|
||||
|
@ -728,11 +728,6 @@ void llcp_lp_cu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pd
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_lp_cu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = LP_CU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_lp_cu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
lp_cu_execute_fsm(conn, ctx, LP_CU_EVT_RUN, param);
|
||||
|
@ -1311,11 +1306,6 @@ void llcp_rp_cu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pd
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_rp_cu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = RP_CU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_rp_cu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
rp_cu_execute_fsm(conn, ctx, RP_CU_EVT_RUN, param);
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
#if defined(CONFIG_BT_CENTRAL)
|
||||
/* LLCP Local Procedure Encryption FSM states */
|
||||
enum {
|
||||
/* Start Procedure */
|
||||
LP_ENC_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_ENC_STATE_UNENCRYPTED,
|
||||
/* Start Procedure */
|
||||
LP_ENC_STATE_WAIT_TX_ENC_REQ,
|
||||
LP_ENC_STATE_WAIT_RX_ENC_RSP,
|
||||
LP_ENC_STATE_WAIT_RX_START_ENC_REQ,
|
||||
|
@ -94,8 +95,9 @@ enum {
|
|||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
/* LLCP Remote Procedure Encryption FSM states */
|
||||
enum {
|
||||
/* Start Procedure */
|
||||
RP_ENC_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_ENC_STATE_UNENCRYPTED,
|
||||
/* Start Procedure */
|
||||
RP_ENC_STATE_WAIT_RX_ENC_REQ,
|
||||
RP_ENC_STATE_WAIT_TX_ENC_RSP,
|
||||
RP_ENC_STATE_WAIT_LTK_REPLY,
|
||||
|
@ -252,7 +254,7 @@ static void lp_enc_complete(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t
|
|||
{
|
||||
lp_enc_ntf(conn, ctx);
|
||||
llcp_lr_complete(conn);
|
||||
ctx->state = LP_ENC_STATE_UNENCRYPTED;
|
||||
ctx->state = LP_ENC_STATE_IDLE;
|
||||
}
|
||||
|
||||
static void lp_enc_store_m(struct ll_conn *conn, struct proc_ctx *ctx, struct pdu_data *pdu)
|
||||
|
@ -340,21 +342,6 @@ static void lp_enc_send_start_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx
|
|||
}
|
||||
}
|
||||
|
||||
static void lp_enc_st_unencrypted(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case LP_ENC_EVT_RUN:
|
||||
/* Pause Tx data */
|
||||
llcp_tx_pause_data(conn, LLCP_TX_QUEUE_PAUSE_DATA_ENCRYPTION);
|
||||
lp_enc_send_enc_req(conn, ctx, evt, param);
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void lp_enc_st_wait_tx_enc_req(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
|
@ -510,6 +497,21 @@ static void lp_enc_st_wait_rx_start_enc_rsp(struct ll_conn *conn, struct proc_ct
|
|||
}
|
||||
}
|
||||
|
||||
static void lp_enc_st_unencrypted(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case LP_ENC_EVT_RUN:
|
||||
/* Pause Tx data */
|
||||
llcp_tx_pause_data(conn, LLCP_TX_QUEUE_PAUSE_DATA_ENCRYPTION);
|
||||
lp_enc_send_enc_req(conn, ctx, evt, param);
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void lp_enc_state_encrypted(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
|
@ -525,6 +527,23 @@ static void lp_enc_state_encrypted(struct ll_conn *conn, struct proc_ctx *ctx, u
|
|||
}
|
||||
}
|
||||
|
||||
static void lp_enc_st_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case LP_ENC_EVT_RUN:
|
||||
if (ctx->proc == PROC_ENCRYPTION_PAUSE) {
|
||||
lp_enc_state_encrypted(conn, ctx, evt, param);
|
||||
} else {
|
||||
lp_enc_st_unencrypted(conn, ctx, evt, param);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void lp_enc_state_wait_tx_pause_enc_req(struct ll_conn *conn, struct proc_ctx *ctx,
|
||||
uint8_t evt, void *param)
|
||||
{
|
||||
|
@ -572,6 +591,9 @@ static void lp_enc_state_wait_tx_pause_enc_rsp(struct ll_conn *conn, struct proc
|
|||
static void lp_enc_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param)
|
||||
{
|
||||
switch (ctx->state) {
|
||||
case LP_ENC_STATE_IDLE:
|
||||
lp_enc_st_idle(conn, ctx, evt, param);
|
||||
break;
|
||||
/* Start Procedure */
|
||||
case LP_ENC_STATE_UNENCRYPTED:
|
||||
lp_enc_st_unencrypted(conn, ctx, evt, param);
|
||||
|
@ -653,20 +675,6 @@ void llcp_lp_enc_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_p
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_lp_enc_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
switch (ctx->proc) {
|
||||
case PROC_ENCRYPTION_START:
|
||||
ctx->state = LP_ENC_STATE_UNENCRYPTED;
|
||||
break;
|
||||
case PROC_ENCRYPTION_PAUSE:
|
||||
ctx->state = LP_ENC_STATE_ENCRYPTED;
|
||||
break;
|
||||
default:
|
||||
LL_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
void llcp_lp_enc_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
lp_enc_execute_fsm(conn, ctx, LP_ENC_EVT_RUN, param);
|
||||
|
@ -878,7 +886,7 @@ static void rp_enc_send_start_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx
|
|||
} else {
|
||||
llcp_rp_enc_tx(conn, ctx, PDU_DATA_LLCTRL_TYPE_START_ENC_RSP);
|
||||
llcp_rr_complete(conn);
|
||||
ctx->state = RP_ENC_STATE_UNENCRYPTED;
|
||||
ctx->state = RP_ENC_STATE_IDLE;
|
||||
|
||||
/* Resume Tx data */
|
||||
llcp_tx_resume_data(conn, LLCP_TX_QUEUE_PAUSE_DATA_ENCRYPTION);
|
||||
|
@ -909,19 +917,6 @@ static void rp_enc_send_pause_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx
|
|||
}
|
||||
}
|
||||
|
||||
static void rp_enc_state_unencrypted(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case RP_ENC_EVT_RUN:
|
||||
ctx->state = RP_ENC_STATE_WAIT_RX_ENC_REQ;
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void rp_enc_store_m(struct ll_conn *conn, struct proc_ctx *ctx, struct pdu_data *pdu)
|
||||
{
|
||||
/* Store Rand */
|
||||
|
@ -1076,6 +1071,35 @@ static void rp_enc_state_encrypted(struct ll_conn *conn, struct proc_ctx *ctx, u
|
|||
}
|
||||
}
|
||||
|
||||
static void rp_enc_state_unencrypted(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case RP_ENC_EVT_RUN:
|
||||
ctx->state = RP_ENC_STATE_WAIT_RX_ENC_REQ;
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void rp_enc_state_idle(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,
|
||||
void *param)
|
||||
{
|
||||
switch (evt) {
|
||||
case RP_ENC_EVT_RUN:
|
||||
if (ctx->proc == PROC_ENCRYPTION_PAUSE) {
|
||||
rp_enc_state_encrypted(conn, ctx, evt, param);
|
||||
} else {
|
||||
rp_enc_state_unencrypted(conn, ctx, evt, param);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* Ignore other evts */
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void rp_enc_state_wait_rx_pause_enc_req(struct ll_conn *conn, struct proc_ctx *ctx,
|
||||
uint8_t evt, void *param)
|
||||
{
|
||||
|
@ -1151,6 +1175,9 @@ static void rp_enc_state_wait_rx_pause_enc_rsp(struct ll_conn *conn, struct proc
|
|||
static void rp_enc_execute_fsm(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt, void *param)
|
||||
{
|
||||
switch (ctx->state) {
|
||||
case RP_ENC_STATE_IDLE:
|
||||
rp_enc_state_idle(conn, ctx, evt, param);
|
||||
break;
|
||||
/* Start Procedure */
|
||||
case RP_ENC_STATE_UNENCRYPTED:
|
||||
rp_enc_state_unencrypted(conn, ctx, evt, param);
|
||||
|
@ -1237,20 +1264,6 @@ void llcp_rp_enc_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_p
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_rp_enc_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
switch (ctx->proc) {
|
||||
case PROC_ENCRYPTION_START:
|
||||
ctx->state = RP_ENC_STATE_UNENCRYPTED;
|
||||
break;
|
||||
case PROC_ENCRYPTION_PAUSE:
|
||||
ctx->state = RP_ENC_STATE_ENCRYPTED;
|
||||
break;
|
||||
default:
|
||||
LL_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
void llcp_rp_enc_ltk_req_reply(struct ll_conn *conn, struct proc_ctx *ctx)
|
||||
{
|
||||
rp_enc_execute_fsm(conn, ctx, RP_ENC_EVT_LTK_REQ_REPLY, NULL);
|
||||
|
|
|
@ -33,6 +33,14 @@ enum llcp_proc {
|
|||
PROC_NONE = 0x0,
|
||||
};
|
||||
|
||||
/* Generic IDLE state to be used across all procedures
|
||||
* This allows a cheap procedure alloc/init handling
|
||||
*/
|
||||
enum llcp_proc_state_idle {
|
||||
LLCP_STATE_IDLE
|
||||
};
|
||||
|
||||
|
||||
enum llcp_tx_q_pause_data_mask {
|
||||
LLCP_TX_QUEUE_PAUSE_DATA_ENCRYPTION = 0x01,
|
||||
LLCP_TX_QUEUE_PAUSE_DATA_PHY_UPDATE = 0x02,
|
||||
|
@ -128,6 +136,11 @@ struct proc_ctx {
|
|||
/* llcp_mem_pool owner of this context */
|
||||
struct llcp_mem_pool *owner;
|
||||
|
||||
#if defined(LLCP_TX_CTRL_BUF_QUEUE_ENABLE)
|
||||
/* Wait list next pointer */
|
||||
sys_snode_t wait_node;
|
||||
#endif /* LLCP_TX_CTRL_BUF_QUEUE_ENABLE */
|
||||
|
||||
/* PROC_ */
|
||||
enum llcp_proc proc;
|
||||
|
||||
|
@ -149,9 +162,6 @@ struct proc_ctx {
|
|||
int collision;
|
||||
|
||||
#if defined(LLCP_TX_CTRL_BUF_QUEUE_ENABLE)
|
||||
/* Wait list next pointer */
|
||||
sys_snode_t wait_node;
|
||||
|
||||
/* Procedure wait reason */
|
||||
enum llcp_wait_reason wait_reason;
|
||||
#endif /* LLCP_TX_CTRL_BUF_QUEUE_ENABLE */
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
/* LLCP Local Procedure PHY Update FSM states */
|
||||
enum {
|
||||
LP_PU_STATE_IDLE,
|
||||
LP_PU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
LP_PU_STATE_WAIT_TX_PHY_REQ,
|
||||
LP_PU_STATE_WAIT_TX_ACK_PHY_REQ,
|
||||
LP_PU_STATE_WAIT_RX_PHY_RSP,
|
||||
|
@ -89,7 +89,7 @@ enum {
|
|||
|
||||
/* LLCP Remote Procedure PHY Update FSM states */
|
||||
enum {
|
||||
RP_PU_STATE_IDLE,
|
||||
RP_PU_STATE_IDLE = LLCP_STATE_IDLE,
|
||||
RP_PU_STATE_WAIT_RX_PHY_REQ,
|
||||
RP_PU_STATE_WAIT_TX_PHY_RSP,
|
||||
RP_PU_STATE_WAIT_TX_ACK_PHY_RSP,
|
||||
|
@ -905,11 +905,6 @@ void llcp_lp_pu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pd
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_lp_pu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = LP_PU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_lp_pu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
lp_pu_execute_fsm(conn, ctx, LP_PU_EVT_RUN, param);
|
||||
|
@ -1323,11 +1318,6 @@ void llcp_rp_pu_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pd
|
|||
}
|
||||
}
|
||||
|
||||
void llcp_rp_pu_init_proc(struct proc_ctx *ctx)
|
||||
{
|
||||
ctx->state = RP_PU_STATE_IDLE;
|
||||
}
|
||||
|
||||
void llcp_rp_pu_run(struct ll_conn *conn, struct proc_ctx *ctx, void *param)
|
||||
{
|
||||
rp_pu_execute_fsm(conn, ctx, RP_PU_EVT_RUN, param);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue