Skip to content

Commit 40cdd65

Browse files
ppryga-nordiccarlescufi
authored andcommitted
Bluetooth: Controller: llcp: add missing handling LL_UNKNOWN in CTE llcp
There was missing handling of LL_UNKNOWN_RSP in CTE request control procedure.In case there is a pending CTE request and peer responses with LL_UNKNOWN_RSP then Host should be notified with HCI_LE_CTE_- Request_Failed event. The pending CTE request procedure should be completed. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 7896226 commit 40cdd65

File tree

5 files changed

+61
-18
lines changed

5 files changed

+61
-18
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7908,7 +7908,11 @@ static void le_unknown_rsp(struct pdu_data *pdu_data, uint16_t handle,
79087908
le_remote_feat_complete(BT_HCI_ERR_UNSUPP_REMOTE_FEATURE,
79097909
NULL, handle, buf);
79107910
break;
7911-
7911+
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
7912+
case PDU_DATA_LLCTRL_TYPE_CTE_REQ:
7913+
le_df_cte_req_failed(BT_HCI_ERR_UNSUPP_REMOTE_FEATURE, handle, buf);
7914+
break;
7915+
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_REQ */
79127916
default:
79137917
BT_WARN("type: 0x%02x", pdu_data->llctrl.unknown_rsp.type);
79147918
break;

subsys/bluetooth/controller/ll_sw/ull_conn_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,17 @@ struct llcp_struct {
404404
struct {
405405
uint8_t sent;
406406
uint8_t valid;
407+
/*
408+
* Stores features supported by peer device. The content of the member may be
409+
* verified when feature exchange procedure has completed, valid member is set to 1.
410+
*/
407411
uint64_t features_peer;
412+
/*
413+
* Stores features common for two connected devices. Before feature exchange
414+
* procedure is completed, the member stores information about all features
415+
* supported by local device. After completion of the procedure, the feature set
416+
* may be limited to features that are common.
417+
*/
408418
uint64_t features_used;
409419
} fex;
410420

subsys/bluetooth/controller/ll_sw/ull_llcp.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,19 @@ uint8_t ull_cp_cte_req(struct ll_conn *conn, uint8_t min_cte_len, uint8_t cte_ty
971971
{
972972
struct proc_ctx *ctx;
973973

974+
/* If Controller gained, awareness:
975+
* - by Feature Exchange control procedure that peer device does not support CTE response,
976+
* - by reception LL_UNKNOWN_RSP with unknown type LL_CTE_REQ that peer device does not
977+
* recognize CTE request,
978+
* then response to Host that CTE request enable command is not possible due to unsupported
979+
* remote feature.
980+
*/
981+
if ((conn->llcp.fex.valid &&
982+
(!(conn->llcp.fex.features_peer & BIT64(BT_LE_FEAT_BIT_CONN_CTE_RESP)))) ||
983+
(!conn->llcp.fex.valid && !feature_cte_req(conn))) {
984+
return BT_HCI_ERR_UNSUPP_REMOTE_FEATURE;
985+
}
986+
974987
/* The request may be started by periodic CTE request procedure, so it skips earlier
975988
* verification of PHY. In case the PHY has changed to CODE the request should be stopped.
976989
*/

subsys/bluetooth/controller/ll_sw/ull_llcp_common.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ static void lp_comm_ntf_cte_req(struct ll_conn *conn, struct proc_ctx *ctx, stru
219219
llcp_ntf_encode_cte_req(pdu);
220220
}
221221
break;
222+
case PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP:
223+
llcp_ntf_encode_unknown_rsp(ctx, pdu);
224+
break;
222225
case PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND:
223226
llcp_ntf_encode_reject_ext_ind(ctx, pdu);
224227
break;
@@ -228,6 +231,17 @@ static void lp_comm_ntf_cte_req(struct ll_conn *conn, struct proc_ctx *ctx, stru
228231
}
229232
}
230233

234+
static void lp_comm_ntf_cte_req_tx(struct ll_conn *conn, struct proc_ctx *ctx)
235+
{
236+
if (llcp_ntf_alloc_is_available()) {
237+
lp_comm_ntf(conn, ctx);
238+
ull_cp_cte_req_set_disable(conn);
239+
ctx->state = LP_COMMON_STATE_IDLE;
240+
} else {
241+
ctx->state = LP_COMMON_STATE_WAIT_NTF;
242+
}
243+
}
244+
231245
static void lp_comm_complete_cte_req(struct ll_conn *conn, struct proc_ctx *ctx)
232246
{
233247
if (conn->llcp.cte_req.is_enabled) {
@@ -238,22 +252,19 @@ static void lp_comm_complete_cte_req(struct ll_conn *conn, struct proc_ctx *ctx)
238252
conn->llcp.cte_req.req_interval;
239253
}
240254
ctx->state = LP_COMMON_STATE_IDLE;
241-
} else if (llcp_ntf_alloc_is_available()) {
242-
lp_comm_ntf(conn, ctx);
243-
ull_cp_cte_req_set_disable(conn);
244-
ctx->state = LP_COMMON_STATE_IDLE;
245255
} else {
246-
ctx->state = LP_COMMON_STATE_WAIT_NTF;
256+
lp_comm_ntf_cte_req_tx(conn, ctx);
247257
}
248258
} else if (ctx->response_opcode == PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND &&
249-
ctx->reject_ext_ind.reject_opcode == PDU_DATA_LLCTRL_TYPE_CTE_REQ) {
250-
if (llcp_ntf_alloc_is_available()) {
251-
lp_comm_ntf(conn, ctx);
252-
ull_cp_cte_req_set_disable(conn);
253-
ctx->state = LP_COMMON_STATE_IDLE;
254-
} else {
255-
ctx->state = LP_COMMON_STATE_WAIT_NTF;
256-
}
259+
ctx->reject_ext_ind.reject_opcode == PDU_DATA_LLCTRL_TYPE_CTE_REQ) {
260+
lp_comm_ntf_cte_req_tx(conn, ctx);
261+
} else if (ctx->response_opcode == PDU_DATA_LLCTRL_TYPE_UNKNOWN_RSP &&
262+
ctx->unknown_response.type == PDU_DATA_LLCTRL_TYPE_CTE_REQ) {
263+
/* CTE response is unsupported in peer, so disable locally for this
264+
* connection
265+
*/
266+
feature_unmask_features(conn, LL_FEAT_BIT_CONNECTION_CTE_REQ);
267+
lp_comm_ntf_cte_req_tx(conn, ctx);
257268
} else if (ctx->response_opcode == PDU_DATA_LLCTRL_TYPE_UNUSED) {
258269
/* This path is related with handling disable the CTE REQ when PHY
259270
* has been changed to CODED PHY. BT 5.3 Core Vol 4 Part E 7.8.85

subsys/bluetooth/controller/ll_sw/ull_llcp_features.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ static inline bool feature_phy_coded(struct ll_conn *conn)
117117
#endif
118118
}
119119

120+
static inline bool feature_cte_req(struct ll_conn *conn)
121+
{
122+
#if defined(CONFIG_BT_CTLR_DF) && defined(CONFIG_BT_CTLR_DF_CONN_CTE_REQ)
123+
return conn->llcp.fex.features_used & LL_FEAT_BIT_CONNECTION_CTE_REQ;
124+
#else
125+
return 0;
126+
#endif
127+
}
128+
120129
/*
121130
* for asymmetric features we can check either if we support it
122131
* or if the peer supports it
@@ -148,10 +157,6 @@ static inline bool feature_peer_smi_tx(struct ll_conn *conn)
148157
* per_adv
149158
* pwr_class1
150159
* min_chann
151-
* CTE_req
152-
* CTE_rsp
153-
* CTE_tx
154-
* CTE_rx
155160
* ant_sw_CTE_tx
156161
* ant_sw_CTE_rx
157162
* tone_ext

0 commit comments

Comments
 (0)