From 6587336a5b0fd2e72f68e4f34e0c06d79f5538ce Mon Sep 17 00:00:00 2001 From: Piotr Pryga Date: Sat, 8 Jan 2022 11:01:24 +0100 Subject: [PATCH] Bluetooth: Controller: llcp: Make remote CTE REQ to compile with CTE RSP Part of the CTE request procdure that is related with handling of remote request should be compiled when CTE RSP is enabled. Withouth it CTE response will not work. Local CTE request does not need code reponsible for handling of remote reques. The commit changes conditional compilation guards. Signed-off-by: Piotr Pryga --- subsys/bluetooth/controller/ll_sw/ull_llcp.c | 2 +- subsys/bluetooth/controller/ll_sw/ull_llcp_common.c | 13 +++++++------ .../bluetooth/controller/ll_sw/ull_llcp_internal.h | 8 +++++++- subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c | 4 +++- subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c | 8 ++++---- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp.c b/subsys/bluetooth/controller/ll_sw/ull_llcp.c index 5d024dd70b8..fc3f57a87a1 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp.c @@ -391,7 +391,7 @@ struct proc_ctx *llcp_create_remote_procedure(enum llcp_proc proc) llcp_rp_comm_init_proc(ctx); break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PROC_CTE_REQ: llcp_rp_comm_init_proc(ctx); break; diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c index 4c0ad69c0b8..12dddd31ae4 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_common.c @@ -692,11 +692,11 @@ static void rp_comm_rx_decode(struct ll_conn *conn, struct proc_ctx *ctx, struct llcp_tx_pause_data(conn); break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PDU_DATA_LLCTRL_TYPE_CTE_REQ: llcp_pdu_decode_cte_req(conn, pdu); break; -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ default: /* Unknown opcode */ LL_ASSERT(0); @@ -737,13 +737,14 @@ static void rp_comm_tx(struct ll_conn *conn, struct proc_ctx *ctx) ctx->rx_opcode = PDU_DATA_LLCTRL_TYPE_LENGTH_RSP; break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PROC_CTE_REQ: { uint8_t err_code = 0; if (conn->llcp.cte_rsp.is_enabled == 0) { err_code = BT_HCI_ERR_UNSUPP_LL_PARAM_VAL; } + #if defined(CONFIG_BT_PHY_UPDATE) /* If the PHY update is not possible, then PHY1M is used. * CTE is supported for PHY1M. @@ -766,7 +767,7 @@ static void rp_comm_tx(struct ll_conn *conn, struct proc_ctx *ctx) } break; } -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ default: /* Unknown procedure */ LL_ASSERT(0); @@ -920,7 +921,7 @@ static void rp_comm_send_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t } break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PROC_CTE_REQ: if (ctx->pause || !llcp_tx_alloc_peek(conn, ctx)) { ctx->state = RP_COMMON_STATE_WAIT_TX; @@ -930,7 +931,7 @@ static void rp_comm_send_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t ctx->state = RP_COMMON_STATE_IDLE; } break; -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ default: /* Unknown procedure */ LL_ASSERT(0); diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h index f817a4ddb97..951dcef294e 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h @@ -583,9 +583,15 @@ void llcp_ntf_encode_length_change(struct ll_conn *conn, */ void llcp_pdu_encode_cte_req(struct proc_ctx *ctx, struct pdu_data *pdu); void llcp_ntf_encode_cte_req(struct ll_conn *conn, struct pdu_data *pdu); +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ + +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) +/* + * Constant Tone Response Procedure Helper + */ void llcp_pdu_decode_cte_req(struct ll_conn *conn, struct pdu_data *pdu); void llcp_pdu_encode_cte_rsp(struct ll_conn *conn, struct pdu_data *pdu); -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ #ifdef ZTEST_UNITTEST bool lr_is_disconnected(struct ll_conn *conn); diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c index 6864e8e538c..1d6be39cd8d 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c @@ -736,7 +736,9 @@ void llcp_ntf_encode_cte_req(struct ll_conn *conn, struct pdu_data *pdu) /* TODO add handling of IQ samples forwarding */ } +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) void llcp_pdu_decode_cte_req(struct ll_conn *conn, struct pdu_data *pdu) { conn->llcp.cte_req.min_cte_len = pdu->llctrl.cte_req.min_cte_len_req; @@ -757,4 +759,4 @@ void llcp_pdu_encode_cte_rsp(struct ll_conn *conn, struct pdu_data *pdu) pdu->cte_info.time = conn->llcp.cte_req.min_cte_len; pdu->cte_info.type = conn->llcp.cte_req.cte_type; } -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c index 083195c8e5b..8438dc11802 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_remote.c @@ -240,11 +240,11 @@ void llcp_rr_rx(struct ll_conn *conn, struct proc_ctx *ctx, struct node_rx_pdu * llcp_rp_comm_rx(conn, ctx, rx); break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PROC_CTE_REQ: llcp_rp_comm_rx(conn, ctx, rx); break; -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ default: /* Unknown procedure */ LL_ASSERT(0); @@ -325,11 +325,11 @@ static void rr_act_run(struct ll_conn *conn) llcp_rp_comm_run(conn, ctx, NULL); break; #endif /* CONFIG_BT_CTLR_DATA_LENGTH */ -#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ) +#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RSP) case PROC_CTE_REQ: llcp_rp_comm_run(conn, ctx, NULL); break; -#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */ +#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RSP */ default: /* Unknown procedure */ LL_ASSERT(0);