Bluetooth: controller: DO TODO, compile out members of struct re. CPR

Compile out misc. members not used when Connection Parameter Request
is not supported.
Implement missing tests re. unsupported features in CU/CPR procedure

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
This commit is contained in:
Erik Brockhoff 2022-04-06 11:03:21 +02:00 committed by Carles Cufí
commit 06078ee54e
3 changed files with 107 additions and 55 deletions

View file

@ -190,7 +190,6 @@ struct proc_ctx {
} pu; } pu;
#endif /* CONFIG_BT_CTLR_PHY */ #endif /* CONFIG_BT_CTLR_PHY */
/* TODO(tosk): leave out some params below if !CONFIG_BT_CTLR_CONN_PARAM_REQ */
/* Connection Update & Connection Parameter Request */ /* Connection Update & Connection Parameter Request */
struct { struct {
uint8_t error; uint8_t error;
@ -202,6 +201,7 @@ struct proc_ctx {
uint16_t interval_max; uint16_t interval_max;
uint16_t latency; uint16_t latency;
uint16_t timeout; uint16_t timeout;
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
uint8_t preferred_periodicity; uint8_t preferred_periodicity;
uint16_t reference_conn_event_count; uint16_t reference_conn_event_count;
uint16_t offset0; uint16_t offset0;
@ -210,6 +210,7 @@ struct proc_ctx {
uint16_t offset3; uint16_t offset3;
uint16_t offset4; uint16_t offset4;
uint16_t offset5; uint16_t offset5;
#endif /* defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) */
} cu; } cu;
/* Use by ACL Termination Procedure */ /* Use by ACL Termination Procedure */

View file

@ -504,6 +504,7 @@ void llcp_pdu_decode_phy_rsp(struct proc_ctx *ctx, struct pdu_data *pdu)
#endif /* CONFIG_BT_CENTRAL */ #endif /* CONFIG_BT_CENTRAL */
#endif /* CONFIG_BT_CTLR_PHY */ #endif /* CONFIG_BT_CTLR_PHY */
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
/* /*
* Connection Update Procedure Helper * Connection Update Procedure Helper
*/ */
@ -592,6 +593,7 @@ void llcp_pdu_decode_conn_param_rsp(struct proc_ctx *ctx, struct pdu_data *pdu)
ctx->data.cu.offset4 = sys_le16_to_cpu(p->offset4); ctx->data.cu.offset4 = sys_le16_to_cpu(p->offset4);
ctx->data.cu.offset5 = sys_le16_to_cpu(p->offset5); ctx->data.cu.offset5 = sys_le16_to_cpu(p->offset5);
} }
#endif /* defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) */
void llcp_pdu_encode_conn_update_ind(struct proc_ctx *ctx, struct pdu_data *pdu) void llcp_pdu_encode_conn_update_ind(struct proc_ctx *ctx, struct pdu_data *pdu)
{ {

View file

@ -51,7 +51,6 @@ struct pdu_data_llctrl_conn_update_ind conn_update_ind = { .win_size = 1U,
.timeout = TIMEOUT, .timeout = TIMEOUT,
.instant = 6U }; .instant = 6U };
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
/* Default conn_param_req PDU */ /* Default conn_param_req PDU */
struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_MIN, struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_MIN,
.interval_max = INTVL_MAX, .interval_max = INTVL_MAX,
@ -66,6 +65,7 @@ struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_M
.offset4 = 0xffffU, .offset4 = 0xffffU,
.offset5 = 0xffffU }; .offset5 = 0xffffU };
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
/* Default conn_param_rsp PDU */ /* Default conn_param_rsp PDU */
struct pdu_data_llctrl_conn_param_rsp conn_param_rsp = { .interval_min = INTVL_MIN, struct pdu_data_llctrl_conn_param_rsp conn_param_rsp = { .interval_min = INTVL_MIN,
.interval_max = INTVL_MAX, .interval_max = INTVL_MAX,
@ -1276,28 +1276,6 @@ void test_conn_update_central_rem_reject(void)
"Free CTX buffers %d", ctx_buffers_free()); "Free CTX buffers %d", ctx_buffers_free());
} }
/* Peripheral-initiated Connection Parameters Request procedure.
* Peripheral requests change in LE connection parameters, centrals Controller do not
* support Connection Parameters Request procedure.
*
* +-----+ +-------+ +-----+
* | UT | | LL_C | | LT |
* +-----+ +-------+ +-----+
* | | |
* | | LL_CONNECTION_PARAM_REQ |
* | |<--------------------------|
* | | |
* | | LL_UNKNOWN_RSP |
* | |-------------------------->|
* | | |
*/
void test_conn_update_central_rem_unsupp_feat(void)
{
/* TODO(thoh): Implement when Remote Request machine has feature
* checking
*/
}
/* /*
* (A) * (A)
* Peripheral-initiated Connection Parameters Request procedure. * Peripheral-initiated Connection Parameters Request procedure.
@ -2525,29 +2503,6 @@ void test_conn_update_periph_rem_reject(void)
"Free CTX buffers %d", ctx_buffers_free()); "Free CTX buffers %d", ctx_buffers_free());
} }
/*
* Central-initiated Connection Parameters Request procedure.
* Central requests change in LE connection parameters, peripherals Controller do not
* support Connection Parameters Request procedure.
*
* +-----+ +-------+ +-----+
* | UT | | LL_P | | LT |
* +-----+ +-------+ +-----+
* | | |
* | | LL_CONNECTION_PARAM_REQ |
* | |<--------------------------|
* | | |
* | | LL_UNKNOWN_RSP |
* | |-------------------------->|
* | | |
*/
void test_conn_update_periph_rem_unsupp_feat(void)
{
/* TODO(thoh): Implement when Remote Request machine has feature
* checking
*/
}
/* /*
* (A) * (A)
* Central-initiated Connection Parameters Request procedure. * Central-initiated Connection Parameters Request procedure.
@ -2890,7 +2845,7 @@ void test_conn_update_central_loc_accept_no_param_req(void)
/* /*
* Parameter Request Procedure not supported. * Parameter Request Procedure not supported.
* Peripheral-initiated Connection Update procedure. * Peripheral-initiated Connection Update/Connection Parameter Request procedure
* Central receives Connection Update parameters. * Central receives Connection Update parameters.
* *
* +-----+ +-------+ +-----+ * +-----+ +-------+ +-----+
@ -2904,8 +2859,15 @@ void test_conn_update_central_loc_accept_no_param_req(void)
* | |-------------------------->| * | |-------------------------->|
* | | | * | | |
* | | | * | | |
* | | LL_CONNECTION_PARAM_REQ |
* | |<--------------------------|
* | | |
* | | LL_UNKNOWN_RSP |
* | |-------------------------->|
* | | |
* | | |
*/ */
void test_conn_update_central_rem_accept_no_param_req(void) void test_conn_update_central_rem_unknown_no_param_req(void)
{ {
struct node_tx *tx; struct node_tx *tx;
@ -2943,6 +2905,93 @@ void test_conn_update_central_rem_accept_no_param_req(void)
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
"Free CTX buffers %d", ctx_buffers_free()); "Free CTX buffers %d", ctx_buffers_free());
/* Check UNKNOWN_RSP on Connection Parameter Request */
unknown_rsp.type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ;
/* Prepare */
event_prepare(&conn);
/* Rx */
lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
/* Done */
event_done(&conn);
/* Prepare */
event_prepare(&conn);
/* Tx Queue should have one LL Control PDU */
lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
lt_rx_q_is_empty(&conn);
/* Done */
event_done(&conn);
/* There should NOT be a host notification */
ut_rx_q_is_empty();
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
"Free CTX buffers %d", ctx_buffers_free());
}
/*
* Parameter Request Procedure not supported.
* Peripheral-initiated Connection Update/Connection Parameter Request procedure
* Central receives Connection Update parameters.
*
* +-----+ +-------+ +-----+
* | UT | | LL_M | | LT |
* +-----+ +-------+ +-----+
* | | |
* | | |
* | | LL_CONNECTION_PARAM_REQ |
* | |<--------------------------|
* | | |
* | | LL_UNKNOWN_RSP |
* | |-------------------------->|
* | | |
* | | |
*/
void test_conn_update_periph_rem_unknown_no_param_req(void)
{
struct node_tx *tx;
struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
.type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ
};
/* Role */
test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
/* Connect */
ull_cp_state_set(&conn, ULL_CP_CONNECTED);
/* Prepare */
event_prepare(&conn);
/* Rx */
lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
/* Done */
event_done(&conn);
/* Prepare */
event_prepare(&conn);
/* Tx Queue should have one LL Control PDU */
lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
lt_rx_q_is_empty(&conn);
/* Done */
event_done(&conn);
/* There should NOT be a host notification */
ut_rx_q_is_empty();
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
"Free CTX buffers %d", ctx_buffers_free());
} }
/* /*
@ -3110,8 +3159,6 @@ void test_main(void)
setup, unit_test_noop), setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_central_rem_reject, ztest_unit_test_setup_teardown(test_conn_update_central_rem_reject,
setup, unit_test_noop), setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_central_rem_unsupp_feat,
setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_central_rem_collision, ztest_unit_test_setup_teardown(test_conn_update_central_rem_collision,
setup, unit_test_noop)); setup, unit_test_noop));
@ -3137,8 +3184,6 @@ void test_main(void)
setup, unit_test_noop), setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_reject, ztest_unit_test_setup_teardown(test_conn_update_periph_rem_reject,
setup, unit_test_noop), setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_unsupp_feat,
setup, unit_test_noop),
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_collision, ztest_unit_test_setup_teardown(test_conn_update_periph_rem_collision,
setup, unit_test_noop)); setup, unit_test_noop));
@ -3154,7 +3199,7 @@ void test_main(void)
setup, unit_test_noop)); setup, unit_test_noop));
ztest_test_suite(central_rem_no_param_req, ztest_unit_test_setup_teardown( ztest_test_suite(central_rem_no_param_req, ztest_unit_test_setup_teardown(
test_conn_update_central_rem_accept_no_param_req, test_conn_update_central_rem_unknown_no_param_req,
setup, unit_test_noop)); setup, unit_test_noop));
ztest_test_suite( ztest_test_suite(
@ -3162,8 +3207,12 @@ void test_main(void)
ztest_unit_test_setup_teardown(test_conn_update_periph_loc_disallowed_no_param_req, ztest_unit_test_setup_teardown(test_conn_update_periph_loc_disallowed_no_param_req,
setup, unit_test_noop)); setup, unit_test_noop));
ztest_test_suite(periph_rem_no_param_req, ztest_unit_test_setup_teardown( ztest_test_suite(periph_rem_no_param_req,
ztest_unit_test_setup_teardown(
test_conn_update_periph_rem_accept_no_param_req, test_conn_update_periph_rem_accept_no_param_req,
setup, unit_test_noop),
ztest_unit_test_setup_teardown(
test_conn_update_periph_rem_unknown_no_param_req,
setup, unit_test_noop)); setup, unit_test_noop));
ztest_run_test_suite(central_loc_no_param_req); ztest_run_test_suite(central_loc_no_param_req);