diff --git a/subsys/bluetooth/controller/Kconfig.ll_sw_split b/subsys/bluetooth/controller/Kconfig.ll_sw_split index db42b656251..57a473b164b 100644 --- a/subsys/bluetooth/controller/Kconfig.ll_sw_split +++ b/subsys/bluetooth/controller/Kconfig.ll_sw_split @@ -533,15 +533,25 @@ config BT_CTLR_LLCP_COMMON_TX_CTRL_BUF_NUM Configure between 0 and (4 - BT_CTLR_LLCP_PER_CONN_TX_CTRL_BUF_NUM) * BT_CTLR_LLCP_CONN config BT_CTLR_LLCP_PROC_CTX_BUF_NUM - int "Number of control procedure contexts to be available across all connections" + int "Number of local control procedure contexts to be available across all connections" default 2 if BT_CTLR_LLCP_CONN = 1 default BT_CTLR_LLCP_CONN if BT_CTLR_LLCP_CONN > 1 range 2 255 help Set the number control procedure contexts that is to be available. This defines the size of the pool of control procedure contexts available - for handlign control procedures. This pool is shared across all - connections (local vs remote initiate), with allocation through a queue + for handling local initiated control procedures. + This pool is shared across all connections, with allocation through a queue. + +config BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM + int "Number of remote control procedure contexts to be available across all connections" + default BT_CTLR_LLCP_CONN + range 1 255 + help + Set the number control procedure contexts that is to be available. + This defines the size of the pool of control procedure contexts available + for handling remote initiated control procedures. + This pool is shared across all connections, with allocation through a queue. endif #!BT_LL_SW_LLCP_LEGACY diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp.c b/subsys/bluetooth/controller/ll_sw/ull_llcp.c index a6928b603da..3f4926091a5 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp.c +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp.c @@ -59,8 +59,13 @@ static uint8_t buffer_mem_tx[TX_CTRL_BUF_SIZE * LLCP_TX_CTRL_BUF_COUNT]; static struct llcp_mem_pool mem_tx = { .pool = buffer_mem_tx }; /* TODO: Determine 'correct' number of ctx */ -static uint8_t buffer_mem_ctx[PROC_CTX_BUF_SIZE * CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM]; -static struct llcp_mem_pool mem_ctx = { .pool = buffer_mem_ctx }; +static uint8_t buffer_mem_local_ctx[PROC_CTX_BUF_SIZE * CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM]; +static struct llcp_mem_pool mem_local_ctx = { .pool = buffer_mem_local_ctx }; + +/* TODO(thoh-ot): Determine 'correct' number of ctx */ +static uint8_t buffer_mem_remote_ctx[PROC_CTX_BUF_SIZE * + CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM]; +static struct llcp_mem_pool mem_remote_ctx = { .pool = buffer_mem_remote_ctx }; /* * LLCP Resource Management @@ -282,7 +287,7 @@ struct proc_ctx *llcp_create_local_procedure(enum llcp_proc proc) { struct proc_ctx *ctx; - ctx = create_procedure(proc, &mem_ctx); + ctx = create_procedure(proc, &mem_local_ctx); if (!ctx) { return NULL; } @@ -350,7 +355,7 @@ struct proc_ctx *llcp_create_remote_procedure(enum llcp_proc proc) { struct proc_ctx *ctx; - ctx = create_procedure(proc, &mem_ctx); + ctx = create_procedure(proc, &mem_remote_ctx); if (!ctx) { return NULL; } @@ -423,8 +428,11 @@ struct proc_ctx *llcp_create_remote_procedure(enum llcp_proc proc) void ull_cp_init(void) { - mem_init(mem_ctx.pool, PROC_CTX_BUF_SIZE, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, - &mem_ctx.free); + mem_init(mem_local_ctx.pool, PROC_CTX_BUF_SIZE, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + &mem_local_ctx.free); + mem_init(mem_remote_ctx.pool, PROC_CTX_BUF_SIZE, + CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM, + &mem_remote_ctx.free); mem_init(mem_tx.pool, TX_CTRL_BUF_SIZE, LLCP_TX_CTRL_BUF_COUNT, &mem_tx.free); #if defined(LLCP_TX_CTRL_BUF_QUEUE_ENABLE) @@ -1025,13 +1033,19 @@ void ull_cp_rx(struct ll_conn *conn, struct node_rx_pdu *rx) #ifdef ZTEST_UNITTEST -int ctx_buffers_free(void) +static uint16_t local_ctx_buffers_free(void) { - int nr_of_free_ctx; + return mem_free_count_get(mem_local_ctx.free); +} - nr_of_free_ctx = mem_free_count_get(mem_ctx.free); +static uint16_t remote_ctx_buffers_free(void) +{ + return mem_free_count_get(mem_remote_ctx.free); +} - return nr_of_free_ctx; +uint16_t ctx_buffers_free(void) +{ + return local_ctx_buffers_free() + remote_ctx_buffers_free(); } void test_int_mem_proc_ctx(void) @@ -1043,28 +1057,29 @@ void test_int_mem_proc_ctx(void) ull_cp_init(); nr_of_free_ctx = ctx_buffers_free(); - zassert_equal(nr_of_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_of_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM + + CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM, NULL); for (int i = 0U; i < CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM; i++) { - ctx1 = proc_ctx_acquire(&mem_ctx); + ctx1 = proc_ctx_acquire(&mem_local_ctx); /* The previous acquire should be valid */ zassert_not_null(ctx1, NULL); } - nr_of_free_ctx = ctx_buffers_free(); + nr_of_free_ctx = local_ctx_buffers_free(); zassert_equal(nr_of_free_ctx, 0, NULL); - ctx2 = proc_ctx_acquire(&mem_ctx); + ctx2 = proc_ctx_acquire(&mem_local_ctx); /* The last acquire should fail */ zassert_is_null(ctx2, NULL); llcp_proc_ctx_release(ctx1); - nr_of_free_ctx = ctx_buffers_free(); + nr_of_free_ctx = local_ctx_buffers_free(); zassert_equal(nr_of_free_ctx, 1, NULL); - ctx1 = proc_ctx_acquire(&mem_ctx); + ctx1 = proc_ctx_acquire(&mem_local_ctx); /* Releasing returns the context to the avilable pool */ zassert_not_null(ctx1, NULL); @@ -1141,7 +1156,7 @@ void test_int_create_proc(void) ull_cp_init(); - ctx = create_procedure(PROC_VERSION_EXCHANGE, &mem_ctx); + ctx = create_procedure(PROC_VERSION_EXCHANGE, &mem_local_ctx); zassert_not_null(ctx, NULL); zassert_equal(ctx->proc, PROC_VERSION_EXCHANGE, NULL); @@ -1150,7 +1165,7 @@ void test_int_create_proc(void) for (int i = 0U; i < CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM; i++) { zassert_not_null(ctx, NULL); - ctx = create_procedure(PROC_VERSION_EXCHANGE, &mem_ctx); + ctx = create_procedure(PROC_VERSION_EXCHANGE, &mem_local_ctx); } zassert_is_null(ctx, NULL); diff --git a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h index e7cafdc39e2..1a727da8be7 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h +++ b/subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h @@ -626,5 +626,5 @@ bool lr_is_disconnected(struct ll_conn *conn); bool lr_is_idle(struct ll_conn *conn); bool rr_is_disconnected(struct ll_conn *conn); bool rr_is_idle(struct ll_conn *conn); -int ctx_buffers_free(void); +uint16_t ctx_buffers_free(void); #endif diff --git a/tests/bluetooth/controller/common/include/helper_util.h b/tests/bluetooth/controller/common/include/helper_util.h index 59ba05265da..40ee1e9d184 100644 --- a/tests/bluetooth/controller/common/include/helper_util.h +++ b/tests/bluetooth/controller/common/include/helper_util.h @@ -6,9 +6,10 @@ */ void test_print_conn(struct ll_conn *conn); - +uint16_t test_ctx_buffers_cnt(void); void test_set_role(struct ll_conn *conn, uint8_t role); void test_setup(struct ll_conn *conn); + void event_prepare(struct ll_conn *conn); void event_tx_ack(struct ll_conn *conn, struct node_tx *tx); void event_done(struct ll_conn *conn); diff --git a/tests/bluetooth/controller/common/src/helper_util.c b/tests/bluetooth/controller/common/src/helper_util.c index c0411690555..edefbf88249 100644 --- a/tests/bluetooth/controller/common/src/helper_util.c +++ b/tests/bluetooth/controller/common/src/helper_util.c @@ -42,6 +42,7 @@ 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; #define PDU_DC_LL_HEADER_SIZE (offsetof(struct pdu_data, lldata)) #define NODE_RX_HEADER_SIZE (offsetof(struct node_rx_pdu, pdu)) @@ -192,6 +193,11 @@ void test_print_conn(struct ll_conn *conn) printf("--------------------->\n"); } +uint16_t test_ctx_buffers_cnt(void) +{ + return no_of_ctx_buffers_at_test_setup; +} + void test_setup(struct ll_conn *conn) { ull_conn_init(); @@ -218,6 +224,8 @@ void test_setup(struct ll_conn *conn) conn->lll.event_counter = 0; event_active = 0; lazy = 0; + + no_of_ctx_buffers_at_test_setup = ctx_buffers_free(); } diff --git a/tests/bluetooth/controller/ctrl_api/src/main.c b/tests/bluetooth/controller/ctrl_api/src/main.c index 346b7a114cc..460dacbd519 100644 --- a/tests/bluetooth/controller/ctrl_api/src/main.c +++ b/tests/bluetooth/controller/ctrl_api/src/main.c @@ -107,13 +107,13 @@ void test_int_disconnect_loc(void) ull_cp_state_set(&conn, ULL_CP_CONNECTED); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); err = ull_cp_version_exchange(&conn); zassert_equal(err, BT_HCI_ERR_SUCCESS, NULL); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt() - 1, NULL); event_prepare(&conn); lt_rx(LL_VERSION_IND, &conn, &tx, &local_version_ind); @@ -126,7 +126,7 @@ void test_int_disconnect_loc(void) ull_cp_state_set(&conn, ULL_CP_DISCONNECTED); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); ut_rx_q_is_empty(); @@ -137,7 +137,7 @@ void test_int_disconnect_loc(void) event_done(&conn); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); /* * all buffers should still be empty @@ -165,7 +165,7 @@ void test_int_disconnect_rem(void) ull_cp_state_set(&conn, ULL_CP_CONNECTED); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); /* Prepare */ event_prepare(&conn); @@ -173,7 +173,7 @@ void test_int_disconnect_rem(void) lt_tx(LL_VERSION_IND, &conn, &remote_version_ind); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); /* Disconnect before we reply */ @@ -189,7 +189,7 @@ void test_int_disconnect_rem(void) event_done(&conn); nr_free_ctx = ctx_buffers_free(); - zassert_equal(nr_free_ctx, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, NULL); + zassert_equal(nr_free_ctx, test_ctx_buffers_cnt(), NULL); /* There should not be a host notifications */ ut_rx_q_is_empty(); diff --git a/tests/bluetooth/controller/ctrl_chmu/src/main.c b/tests/bluetooth/controller/ctrl_chmu/src/main.c index 47fe03528bb..fee2c62fc4e 100644 --- a/tests/bluetooth/controller/ctrl_chmu/src/main.c +++ b/tests/bluetooth/controller/ctrl_chmu/src/main.c @@ -125,7 +125,7 @@ void test_channel_map_update_central_loc(void) zassert_mem_equal(conn.lll.data_chan_map, chm, sizeof(conn.lll.data_chan_map), "Channel map invalid"); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -193,7 +193,7 @@ void test_channel_map_update_periph_rem(void) zassert_mem_equal(conn.lll.data_chan_map, chm, sizeof(conn.lll.data_chan_map), "Channel map invalid"); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -211,7 +211,7 @@ void test_channel_map_update_periph_loc(void) err = ull_cp_chan_map_update(&conn, chm); zassert_equal(err, BT_HCI_ERR_CMD_DISALLOWED, NULL); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_conn_update/src/main.c b/tests/bluetooth/controller/ctrl_conn_update/src/main.c index 61a3628a8f7..5945cf9efd3 100644 --- a/tests/bluetooth/controller/ctrl_conn_update/src/main.c +++ b/tests/bluetooth/controller/ctrl_conn_update/src/main.c @@ -274,7 +274,7 @@ void test_conn_update_central_loc_accept(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -344,7 +344,7 @@ void test_conn_update_central_loc_reject(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -467,7 +467,7 @@ void test_conn_update_central_loc_remote_legacy(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -590,7 +590,7 @@ void test_conn_update_central_loc_unsupp_wo_feat_exch(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -689,7 +689,7 @@ void test_conn_update_central_loc_unsupp_w_feat_exch(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -854,7 +854,7 @@ void test_conn_update_central_loc_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -974,7 +974,7 @@ void test_conn_update_central_rem_accept(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1051,7 +1051,7 @@ void test_conn_update_central_rem_reject(void) /* Done */ event_done(&conn); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1314,7 +1314,7 @@ void test_conn_update_central_rem_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1416,7 +1416,7 @@ void test_conn_update_periph_loc_accept(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1495,7 +1495,7 @@ void test_conn_update_periph_loc_reject(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1574,7 +1574,7 @@ void test_conn_update_periph_loc_unsupp_feat_wo_feat_exch(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1622,7 +1622,7 @@ void test_conn_update_periph_loc_unsupp_feat_w_feat_exch(void) /* There should be no host notification */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1800,7 +1800,7 @@ void test_conn_update_periph_loc_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1930,7 +1930,7 @@ void test_conn_update_periph_rem_accept(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -2010,7 +2010,7 @@ void test_conn_update_periph_rem_reject(void) /* Done */ event_done(&conn); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -2261,7 +2261,7 @@ void test_conn_update_periph_rem_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */ @@ -2373,7 +2373,7 @@ void test_conn_update_central_loc_accept_no_param_req(void) } } while (parameters_changed-- > 0U); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -2430,7 +2430,7 @@ void test_conn_update_central_rem_accept_no_param_req(void) /* There should NOT be a host notification */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -2521,7 +2521,7 @@ void test_conn_update_periph_rem_accept_no_param_req(void) } } while (parameters_changed-- > 0U); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -2566,7 +2566,7 @@ void test_conn_update_periph_loc_disallowed_no_param_req(void) /* There should be no host notification */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_cte_req/src/main.c b/tests/bluetooth/controller/ctrl_cte_req/src/main.c index 653bd8c71ff..b8c6be691ca 100644 --- a/tests/bluetooth/controller/ctrl_cte_req/src/main.c +++ b/tests/bluetooth/controller/ctrl_cte_req/src/main.c @@ -110,7 +110,7 @@ void test_cte_req_central_local(void) /* Release tx node */ ull_cp_release_tx(&conn, tx); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -180,7 +180,7 @@ void test_cte_req_peripheral_local(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -249,7 +249,7 @@ void test_cte_req_central_remote(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -318,7 +318,7 @@ void test_cte_req_peripheral_remote(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -394,7 +394,7 @@ void test_cte_req_rejected_inv_ll_param_central_local(void) /* Release tx node */ ull_cp_release_tx(&conn, tx); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -468,7 +468,7 @@ void test_cte_req_rejected_inv_ll_param_peripheral_local(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -540,7 +540,7 @@ void test_cte_req_reject_inv_ll_param_central_remote(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -612,7 +612,7 @@ void test_cte_req_reject_inv_ll_param_peripheral_remote(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1023,10 +1023,10 @@ static void test_local_cte_req_wait_for_phy_update_complete_and_disable(uint8_t if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1); + test_ctx_buffers_cnt() - 1); } else { run_phy_update_peripheral(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1); + test_ctx_buffers_cnt() - 1); } /* In this test CTE request is local procedure. Local procedures are handled after remote @@ -1045,7 +1045,7 @@ static void test_local_cte_req_wait_for_phy_update_complete_and_disable(uint8_t /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1088,16 +1088,16 @@ static void test_local_cte_req_wait_for_phy_update_complete(uint8_t role) if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(true, &local_cte_req, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1); + test_ctx_buffers_cnt() - 1); } else { run_phy_update_peripheral(true, &local_cte_req, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1); + test_ctx_buffers_cnt() - 1); } /* PHY update was completed. Handle CTE request */ run_local_cte_req(&local_cte_req); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1139,15 +1139,15 @@ static void test_local_phy_update_wait_for_cte_req_complete(uint8_t role) /* Handle CTE request */ run_local_cte_req(&local_cte_req); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt() - 1, "Free CTX buffers %d", ctx_buffers_free()); if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } else { run_phy_update_peripheral(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } } @@ -1229,15 +1229,15 @@ static void test_phy_update_wait_for_remote_cte_req_complete(uint8_t role) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt() - 1, "Free CTX buffers %d", ctx_buffers_free()); if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } else { run_phy_update_peripheral(true, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } } @@ -1284,10 +1284,10 @@ static void test_cte_req_wait_for_remote_phy_update_complete_and_disable(uint8_t if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(false, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } else { run_phy_update_peripheral(false, NULL, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } /* There is no special handling of CTE REQ completion. It is done when instant happens just @@ -1338,10 +1338,10 @@ static void test_cte_req_wait_for_remote_phy_update_complete(uint8_t role) if (role == BT_HCI_ROLE_CENTRAL) { run_phy_update_central(false, &local_cte_req, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } else { run_phy_update_peripheral(false, &local_cte_req, &phy_req, pu_event_counter(&conn), - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM); + test_ctx_buffers_cnt()); } /* There is no special handling of CTE REQ completion here. It is done when instant happens diff --git a/tests/bluetooth/controller/ctrl_encrypt/src/main.c b/tests/bluetooth/controller/ctrl_encrypt/src/main.c index cfb02e7dd37..31e311f1afc 100644 --- a/tests/bluetooth/controller/ctrl_encrypt/src/main.c +++ b/tests/bluetooth/controller/ctrl_encrypt/src/main.c @@ -286,7 +286,7 @@ void test_encryption_start_central_loc(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -520,7 +520,7 @@ void test_encryption_start_central_loc_limited_memory(void) /* Release dummy procedure */ llcp_proc_ctx_release(ctx); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -636,7 +636,7 @@ void test_encryption_start_central_loc_no_ltk(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -747,7 +747,7 @@ void test_encryption_start_central_loc_no_ltk_2(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -964,7 +964,7 @@ void test_encryption_start_periph_rem(void) /* CCM Tx Direction should be S->M */ CHECK_TX_CCM_STATE(conn, sk_be, iv, 0U, CCM_DIR_S_TO_M); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1268,7 +1268,7 @@ void test_encryption_start_periph_rem_limited_memory(void) /* Release dummy procedure */ llcp_proc_ctx_release(ctx); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1415,7 +1415,7 @@ void test_encryption_start_periph_rem_no_ltk(void) ut_rx_q_is_empty(); /* Note that for this test the context is not released */ - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt() - 1, "Free CTX buffers %d", ctx_buffers_free()); } @@ -1566,7 +1566,7 @@ void test_encryption_pause_central_loc(void) /* Rx Decryption should be enabled */ zassert_equal(conn.lll.enc_rx, 1U, NULL); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1742,7 +1742,7 @@ void test_encryption_pause_periph_rem(void) /* Tx Encryption should be enabled */ zassert_equal(conn.lll.enc_tx, 1U, NULL); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_feature_exchange/src/main.c b/tests/bluetooth/controller/ctrl_feature_exchange/src/main.c index ea4da569691..ea61e6e1145 100644 --- a/tests/bluetooth/controller/ctrl_feature_exchange/src/main.c +++ b/tests/bluetooth/controller/ctrl_feature_exchange/src/main.c @@ -128,7 +128,7 @@ void test_feat_exchange_central_loc(void) } zassert_equal(conn.lll.event_counter, feat_to_test, "Wrong event-count %d\n", conn.lll.event_counter); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -146,7 +146,9 @@ void test_feat_exchange_central_loc_2(void) } zassert_not_equal(err, BT_HCI_ERR_SUCCESS, NULL); - zassert_equal(ctx_buffers_free(), 0, "Free CTX buffers %d", ctx_buffers_free()); + zassert_equal(ctx_buffers_free(), + test_ctx_buffers_cnt() - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + "Free CTX buffers %d", ctx_buffers_free()); } /* @@ -209,7 +211,7 @@ void test_feat_exchange_central_rem(void) } zassert_equal(conn.lll.event_counter, CENTRAL_NR_OF_EVENTS * (feat_to_test), "Wrong event-count %d\n", conn.lll.event_counter); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -297,7 +299,7 @@ void test_feat_exchange_central_rem_2(void) zassert_equal(conn.lll.event_counter, CENTRAL_NR_OF_EVENTS * (feat_to_test), "Wrong event-count %d\n", conn.lll.event_counter); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -355,7 +357,7 @@ void test_peripheral_feat_exchange_periph_loc(void) ut_rx_q_is_empty(); zassert_equal(conn.lll.event_counter, 2, "Wrong event-count %d\n", conn.lll.event_counter); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -417,7 +419,7 @@ void test_feat_exchange_periph_loc_unknown_rsp(void) ut_rx_q_is_empty(); zassert_equal(conn.lll.event_counter, 3, "Wrong event-count %d\n", conn.lll.event_counter); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_feature_exchange/src/main_hci.c b/tests/bluetooth/controller/ctrl_feature_exchange/src/main_hci.c index 4e3df2c4aa9..bf6cfd64de8 100644 --- a/tests/bluetooth/controller/ctrl_feature_exchange/src/main_hci.c +++ b/tests/bluetooth/controller/ctrl_feature_exchange/src/main_hci.c @@ -133,7 +133,7 @@ void test_hci_feat_exchange_central_loc(void) ll_conn_release(conn_from_pool); } - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -155,13 +155,15 @@ void test_hci_feat_exchange_wrong_handle(void) ctx = llcp_create_local_procedure(PROC_FEATURE_EXCHANGE); ctx_counter++; } while (ctx != NULL); + zassert_equal(ctx_counter, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM + 1, "Error in setup of test\n"); err = ll_feature_req_send(conn_handle); zassert_equal(err, BT_HCI_ERR_CMD_DISALLOWED, "Wrong reply for wrong handle\n"); - zassert_equal(ctx_buffers_free(), 0, "Free CTX buffers %d", ctx_buffers_free()); + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt() - (ctx_counter - 1), + "Free CTX buffers %d", ctx_buffers_free()); } void test_hci_main(void) diff --git a/tests/bluetooth/controller/ctrl_hci/src/main.c b/tests/bluetooth/controller/ctrl_hci/src/main.c index 123b29d1f13..7006797112b 100644 --- a/tests/bluetooth/controller/ctrl_hci/src/main.c +++ b/tests/bluetooth/controller/ctrl_hci/src/main.c @@ -136,7 +136,7 @@ void test_hci_feature_exchange_wrong_handle(void) ctx = llcp_create_local_procedure(PROC_FEATURE_EXCHANGE); ctx_counter++; } while (ctx != NULL); - zassert_equal(ctx_counter, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM + 1, + zassert_equal(ctx_counter, test_ctx_buffers_cnt() + 1, "Error in setup of test\n"); err = ll_feature_req_send(conn_handle); @@ -203,7 +203,7 @@ void test_hci_version_ind_wrong_handle(void) ctx = llcp_create_local_procedure(PROC_VERSION_EXCHANGE); ctx_counter++; } while (ctx != NULL); - zassert_equal(ctx_counter, CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM + 1, + zassert_equal(ctx_counter, test_ctx_buffers_cnt() + 1, "Error in setup of test\n"); err = ll_version_ind_send(conn_handle); diff --git a/tests/bluetooth/controller/ctrl_le_ping/src/main.c b/tests/bluetooth/controller/ctrl_le_ping/src/main.c index 8e2a9a3821a..7f153815edf 100644 --- a/tests/bluetooth/controller/ctrl_le_ping/src/main.c +++ b/tests/bluetooth/controller/ctrl_le_ping/src/main.c @@ -97,7 +97,7 @@ void test_ping_central_loc(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -155,7 +155,7 @@ void test_ping_periph_loc(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -209,7 +209,7 @@ void test_ping_central_rem(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -263,7 +263,7 @@ void test_ping_periph_rem(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_min_used_chans/src/main.c b/tests/bluetooth/controller/ctrl_min_used_chans/src/main.c index 5d5440593b1..df5907d4229 100644 --- a/tests/bluetooth/controller/ctrl_min_used_chans/src/main.c +++ b/tests/bluetooth/controller/ctrl_min_used_chans/src/main.c @@ -100,7 +100,7 @@ void test_min_used_chans_periph_loc(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -118,7 +118,7 @@ void test_min_used_chans_central_loc(void) err = ull_cp_min_used_chans(&conn, 1, 2); zassert_equal(err, BT_HCI_ERR_CMD_DISALLOWED, NULL); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -162,7 +162,7 @@ void test_min_used_chans_central_rem(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM - 1, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt() - 1, "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_phy_update/src/main.c b/tests/bluetooth/controller/ctrl_phy_update/src/main.c index 4e03bbe2b62..d17a095c395 100644 --- a/tests/bluetooth/controller/ctrl_phy_update/src/main.c +++ b/tests/bluetooth/controller/ctrl_phy_update/src/main.c @@ -215,7 +215,7 @@ void test_phy_update_central_loc(void) CHECK_CURRENT_PHY_STATE(conn, PHY_2M, PREFER_S8_CODING, PHY_2M); CHECK_PREF_PHY_STATE(conn, PHY_2M, PHY_2M); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -266,7 +266,7 @@ void test_phy_update_central_loc_unsupp_feat(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -365,7 +365,7 @@ void test_phy_update_central_rem(void) CHECK_CURRENT_PHY_STATE(conn, PHY_1M, PREFER_S8_CODING, PHY_2M); CHECK_PREF_PHY_STATE(conn, PHY_1M | PHY_2M | PHY_CODED, PHY_1M | PHY_2M | PHY_CODED); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -459,7 +459,7 @@ void test_phy_update_periph_loc(void) CHECK_CURRENT_PHY_STATE(conn, PHY_2M, PREFER_S8_CODING, PHY_2M); CHECK_PREF_PHY_STATE(conn, PHY_2M, PHY_2M); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -563,7 +563,7 @@ void test_phy_update_periph_rem(void) CHECK_CURRENT_PHY_STATE(conn, PHY_2M, PREFER_S8_CODING, PHY_1M); CHECK_PREF_PHY_STATE(conn, PHY_1M | PHY_2M | PHY_CODED, PHY_1M | PHY_2M | PHY_CODED); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -734,7 +734,7 @@ void test_phy_update_central_loc_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -907,7 +907,7 @@ void test_phy_update_central_rem_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -1036,7 +1036,7 @@ void test_phy_update_periph_loc_collision(void) /* Release Ntf */ ull_cp_release_ntf(ntf); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_terminate/src/main.c b/tests/bluetooth/controller/ctrl_terminate/src/main.c index 18519b54825..6c11a5fb4a2 100644 --- a/tests/bluetooth/controller/ctrl_terminate/src/main.c +++ b/tests/bluetooth/controller/ctrl_terminate/src/main.c @@ -69,7 +69,7 @@ static void test_terminate_rem(uint8_t role) /* There should be no host notification */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -121,7 +121,7 @@ void test_terminate_loc(uint8_t role) /* There should be no host notification */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_unsupported/src/main.c b/tests/bluetooth/controller/ctrl_unsupported/src/main.c index 0febe352253..9cef0db297d 100644 --- a/tests/bluetooth/controller/ctrl_unsupported/src/main.c +++ b/tests/bluetooth/controller/ctrl_unsupported/src/main.c @@ -98,7 +98,7 @@ static void lt_tx_pdu_and_rx_unknown_rsp(enum helper_pdu_opcode opcode) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -148,7 +148,7 @@ static void lt_tx_undef_opcode_and_rx_unknown_rsp(uint8_t opcode) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/ctrl_version/src/main.c b/tests/bluetooth/controller/ctrl_version/src/main.c index 838adfa5e24..e256b3d1d72 100644 --- a/tests/bluetooth/controller/ctrl_version/src/main.c +++ b/tests/bluetooth/controller/ctrl_version/src/main.c @@ -107,7 +107,7 @@ void test_version_exchange_central_loc(void) ut_rx_pdu(LL_VERSION_IND, &ntf, &remote_version_ind); ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -128,7 +128,9 @@ void test_version_exchange_central_loc_2(void) zassert_not_equal(err, BT_HCI_ERR_SUCCESS, NULL); - zassert_equal(ctx_buffers_free(), 0, "Free CTX buffers %d", ctx_buffers_free()); + zassert_equal(ctx_buffers_free(), + test_ctx_buffers_cnt() - CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + "Free CTX buffers %d", ctx_buffers_free()); } /* +-----+ +-------+ +-----+ @@ -186,7 +188,7 @@ void test_version_exchange_central_rem(void) /* There should not be a host notifications */ ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -254,7 +256,7 @@ void test_version_exchange_central_rem_2(void) ut_rx_pdu(LL_VERSION_IND, &ntf, &remote_version_ind); ut_rx_q_is_empty(); - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } @@ -349,7 +351,7 @@ void test_version_exchange_central_loc_twice(void) /* Second attempt to run the version exchange completes immediately in idle state. * The context is released just after that. */ - zassert_equal(ctx_buffers_free(), CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM, + zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d", ctx_buffers_free()); } diff --git a/tests/bluetooth/controller/mock_ctrl/include/kconfig.h b/tests/bluetooth/controller/mock_ctrl/include/kconfig.h index f5222e7e29a..f3892e3c3d4 100644 --- a/tests/bluetooth/controller/mock_ctrl/include/kconfig.h +++ b/tests/bluetooth/controller/mock_ctrl/include/kconfig.h @@ -89,6 +89,10 @@ #define CONFIG_BT_CTLR_LLCP_PROC_CTX_BUF_NUM CONFIG_BT_CTLR_LLCP_CONN #endif +#ifndef CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM +#define CONFIG_BT_CTLR_LLCP_REMOTE_PROC_CTX_BUF_NUM CONFIG_BT_CTLR_LLCP_CONN +#endif + #ifndef CONFIG_BT_CTLR_LLCP_COMMON_TX_CTRL_BUF_NUM #define CONFIG_BT_CTLR_LLCP_COMMON_TX_CTRL_BUF_NUM 2 #endif