From 9b553c3eb22fd36e088a093673e584385f85bada Mon Sep 17 00:00:00 2001 From: Erik Brockhoff Date: Thu, 25 Aug 2022 16:58:16 +0200 Subject: [PATCH] Bluetooth: controller: fixup to peripheral CIS CREATE procedure Missing decode of conn_event_count on CIS_IND Peripheral Suggest update to conn_event_count in case of a delayed CIS_IND, allowing CIS peripheral more time to setup Signed-off-by: Erik Brockhoff --- subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c | 4 ++++ subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h | 1 + subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c index f057e47e51c..2824e830196 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_cc.c @@ -154,6 +154,9 @@ static void llcp_rp_cc_tx_rsp(struct ll_conn *conn, struct proc_ctx *ctx) pdu = (struct pdu_data *)tx->pdu; + ctx->data.cis_create.conn_event_count = MAX(ctx->data.cis_create.conn_event_count, + cc_event_counter(conn) + 2); + llcp_pdu_encode_cis_rsp(ctx, pdu); ctx->tx_opcode = pdu->llctrl.opcode; @@ -368,6 +371,7 @@ static void rp_cc_state_wait_rx_cis_ind(struct ll_conn *conn, struct proc_ctx *c switch (evt) { case RP_CC_EVT_CIS_IND: + llcp_pdu_decode_cis_ind(ctx, pdu); if (!ull_peripheral_iso_setup(&pdu->llctrl.cis_ind, ctx->data.cis_create.cig_id, ctx->data.cis_create.cis_handle)) { diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h index ca12a7a2328..2a888d4617c 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h @@ -716,6 +716,7 @@ void llcp_rp_cc_reject(struct ll_conn *conn, struct proc_ctx *ctx); void llcp_pdu_decode_cis_req(struct proc_ctx *ctx, struct pdu_data *pdu); void llcp_pdu_encode_cis_rsp(struct proc_ctx *ctx, struct pdu_data *pdu); +void llcp_pdu_decode_cis_ind(struct proc_ctx *ctx, struct pdu_data *pdu); void llcp_pdu_encode_cis_terminate_ind(struct proc_ctx *ctx, struct pdu_data *pdu); void llcp_pdu_decode_cis_terminate_ind(struct proc_ctx *ctx, struct pdu_data *pdu); void llcp_pdu_encode_cis_req(struct proc_ctx *ctx, struct pdu_data *pdu); diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c index d56f4ee716e..a162beb9c45 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c @@ -828,6 +828,15 @@ void llcp_pdu_decode_cis_req(struct proc_ctx *ctx, struct pdu_data *pdu) */ } +void llcp_pdu_decode_cis_ind(struct proc_ctx *ctx, struct pdu_data *pdu) +{ + ctx->data.cis_create.conn_event_count = + sys_le16_to_cpu(pdu->llctrl.cis_ind.conn_event_count); + /* The remainder of the cis ind is decoded by ull_peripheral_iso_setup, so + * no need to do it here too + */ +} + void llcp_pdu_encode_cis_rsp(struct proc_ctx *ctx, struct pdu_data *pdu) { struct pdu_data_llctrl_cis_rsp *p;