Skip to content

Commit ef1f8c3

Browse files
wopu-otnashif
authored andcommitted
Bluetooth: controller: Add support for ISO feature bits
Add support for ISO feature bits. This includes extending fields that hold features to 64 bits to be able to handle the host-controlled "Isochronous Channels" feature. Signed-off-by: Wolfgang Puffitsch <[email protected]>
1 parent 45bdff1 commit ef1f8c3

File tree

4 files changed

+60
-26
lines changed

4 files changed

+60
-26
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ static void le_read_local_features(struct net_buf *buf, struct net_buf **evt)
11371137
rp->status = 0x00;
11381138

11391139
(void)memset(&rp->features[0], 0x00, sizeof(rp->features));
1140-
sys_put_le24(LL_FEAT, rp->features);
1140+
sys_put_le64(LL_FEAT, rp->features);
11411141
}
11421142

11431143
static void le_set_random_address(struct net_buf *buf, struct net_buf **evt)

subsys/bluetooth/controller/include/ll_feat.h

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,40 @@
125125
#define LL_FEAT_BIT_ANT_SWITCH_TX_AOD 0
126126
#endif /* !CONFIG_BT_CTLR_DF && !CONFIG_BT_CTLR_DF_ANT_SWITCH_TX */
127127

128-
#define LL_FEAT_BIT_MASK 0x1FFFF
129-
#define LL_FEAT_BIT_MASK_VALID 0x1CF2F
130-
#define LL_FEAT_FILTER_OCTET0 0x1FF00
128+
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO)
129+
#define LL_FEAT_BIT_CIS_CENTRAL BIT64(BT_LE_FEAT_BIT_CIS_MASTER)
130+
#else /* !CONFIG_BT_CTLR_CENTRAL_ISO */
131+
#define LL_FEAT_BIT_CIS_CENTRAL 0
132+
#endif /* !CONFIG_BT_CTLR_CENTRAL_ISO */
133+
134+
#if defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
135+
#define LL_FEAT_BIT_CIS_PERIPHERAL BIT64(BT_LE_FEAT_BIT_CIS_SLAVE)
136+
#else /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */
137+
#define LL_FEAT_BIT_CIS_PERIPHERAL 0
138+
#endif /* !CONFIG_BT_CTLR_PERIPHERAL_ISO */
139+
140+
#if defined(CONFIG_BT_CTLR_ADV_ISO)
141+
#define LL_FEAT_BIT_ISO_BROADCASTER BIT64(BT_LE_FEAT_BIT_ISO_BROADCASTER)
142+
#else /* !CONFIG_BT_CTLR_ADV_ISO */
143+
#define LL_FEAT_BIT_ISO_BROADCASTER 0
144+
#endif /* !CONFIG_BT_CTLR_ADV_ISO */
145+
146+
#if defined(CONFIG_BT_CTLR_SYNC_ISO)
147+
#define LL_FEAT_BIT_SYNC_RECEIVER BIT64(BT_LE_FEAT_BIT_SYNC_RECEIVER)
148+
#else /* !CONFIG_BT_CTLR_SYNC_ISO */
149+
#define LL_FEAT_BIT_SYNC_RECEIVER 0
150+
#endif /* !CONFIG_BT_CTLR_SYNC_ISO */
151+
152+
/* All defined feature bits */
153+
#define LL_FEAT_BIT_MASK 0xFFFFFFFFFULL
154+
155+
/* Feature bits that are valid from controller to controller */
156+
#define LL_FEAT_BIT_MASK_VALID 0xFF787CF2FULL
157+
158+
/* Mask to filter away octet 0 for feature exchange */
159+
#define LL_FEAT_FILTER_OCTET0 (LL_FEAT_BIT_MASK & ~0xFFULL)
160+
161+
/* Feature bits of this controller */
131162
#define LL_FEAT (LL_FEAT_BIT_ENC | \
132163
LL_FEAT_BIT_CONN_PARAM_REQ | \
133164
LL_FEAT_BIT_EXT_REJ_IND | \
@@ -145,4 +176,8 @@
145176
LL_FEAT_BIT_CONNECTIONLESS_CTE_TX | \
146177
LL_FEAT_BIT_ANT_SWITCH_TX_AOD | \
147178
LL_FEAT_BIT_CHAN_SEL_2 | \
148-
LL_FEAT_BIT_MIN_USED_CHAN)
179+
LL_FEAT_BIT_MIN_USED_CHAN | \
180+
LL_FEAT_BIT_CIS_CENTRAL | \
181+
LL_FEAT_BIT_CIS_PERIPHERAL | \
182+
LL_FEAT_BIT_ISO_BROADCASTER | \
183+
LL_FEAT_BIT_SYNC_RECEIVER)

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ uint8_t ll_conn_update(uint16_t handle, uint8_t cmd, uint8_t status, uint16_t in
333333
if (!conn->llcp_conn_param.disabled &&
334334
(!conn->common.fex_valid ||
335335
(conn->llcp_feature.features_conn &
336-
BIT(BT_LE_FEAT_BIT_CONN_PARAM_REQ)))) {
336+
BIT64(BT_LE_FEAT_BIT_CONN_PARAM_REQ)))) {
337337
cmd++;
338338
} else if (conn->lll.role) {
339339
return BT_HCI_ERR_UNSUPP_REMOTE_FEATURE;
@@ -523,7 +523,7 @@ uint32_t ll_length_req_send(uint16_t handle, uint16_t tx_octets, uint16_t tx_tim
523523

524524
if (conn->llcp_length.disabled ||
525525
(conn->common.fex_valid &&
526-
!(conn->llcp_feature.features_conn & BIT(BT_LE_FEAT_BIT_DLE)))) {
526+
!(conn->llcp_feature.features_conn & BIT64(BT_LE_FEAT_BIT_DLE)))) {
527527
return BT_HCI_ERR_UNSUPP_REMOTE_FEATURE;
528528
}
529529

@@ -634,9 +634,9 @@ uint8_t ll_phy_req_send(uint16_t handle, uint8_t tx, uint8_t flags, uint8_t rx)
634634

635635
if (conn->llcp_phy.disabled ||
636636
(conn->common.fex_valid &&
637-
!(conn->llcp_feature.features_conn & BIT(BT_LE_FEAT_BIT_PHY_2M)) &&
637+
!(conn->llcp_feature.features_conn & BIT64(BT_LE_FEAT_BIT_PHY_2M)) &&
638638
!(conn->llcp_feature.features_conn &
639-
BIT(BT_LE_FEAT_BIT_PHY_CODED)))) {
639+
BIT64(BT_LE_FEAT_BIT_PHY_CODED)))) {
640640
return BT_HCI_ERR_UNSUPP_REMOTE_FEATURE;
641641
}
642642

@@ -2709,7 +2709,7 @@ static inline void event_enc_reject_prep(struct ll_conn *conn,
27092709

27102710
if (conn->common.fex_valid &&
27112711
(conn->llcp_feature.features_conn &
2712-
BIT(BT_LE_FEAT_BIT_EXT_REJ_IND))) {
2712+
BIT64(BT_LE_FEAT_BIT_EXT_REJ_IND))) {
27132713
struct pdu_data_llctrl_reject_ext_ind *p;
27142714

27152715
pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND;
@@ -2937,7 +2937,7 @@ static inline void event_fex_prep(struct ll_conn *conn)
29372937
pdu->llctrl.opcode = PDU_DATA_LLCTRL_TYPE_FEATURE_RSP;
29382938
(void)memset(&pdu->llctrl.feature_rsp.features[0], 0x00,
29392939
sizeof(pdu->llctrl.feature_rsp.features));
2940-
sys_put_le24(conn->llcp_feature.features_peer,
2940+
sys_put_le64(conn->llcp_feature.features_peer,
29412941
pdu->llctrl.feature_req.features);
29422942

29432943
/* enqueue feature rsp structure into rx queue */
@@ -2967,7 +2967,7 @@ static inline void event_fex_prep(struct ll_conn *conn)
29672967
(void)memset(&pdu->llctrl.feature_req.features[0],
29682968
0x00,
29692969
sizeof(pdu->llctrl.feature_req.features));
2970-
sys_put_le24(conn->llcp_feature.features_conn,
2970+
sys_put_le64(conn->llcp_feature.features_conn,
29712971
pdu->llctrl.feature_req.features);
29722972

29732973
ctrl_tx_enqueue(conn, tx);
@@ -3395,22 +3395,22 @@ static inline void event_ping_prep(struct ll_conn *conn)
33953395
static inline void dle_max_time_get(const struct ll_conn *conn,
33963396
uint16_t *max_rx_time, uint16_t *max_tx_time)
33973397
{
3398-
uint32_t feature_coded_phy = 0;
3399-
uint32_t feature_phy_2m = 0;
3398+
uint64_t feature_coded_phy = 0;
3399+
uint64_t feature_phy_2m = 0;
34003400
uint16_t rx_time = 0;
34013401
uint16_t tx_time = 0;
34023402

34033403
#if defined(CONFIG_BT_CTLR_PHY)
34043404
#if defined(CONFIG_BT_CTLR_PHY_CODED)
34053405
feature_coded_phy = (conn->llcp_feature.features_conn &
3406-
BIT(BT_LE_FEAT_BIT_PHY_CODED));
3406+
BIT64(BT_LE_FEAT_BIT_PHY_CODED));
34073407
#else
34083408
feature_coded_phy = 0;
34093409
#endif
34103410

34113411
#if defined(CONFIG_BT_CTLR_PHY_2M)
34123412
feature_phy_2m = (conn->llcp_feature.features_conn &
3413-
BIT(BT_LE_FEAT_BIT_PHY_2M));
3413+
BIT64(BT_LE_FEAT_BIT_PHY_2M));
34143414
#else
34153415
feature_phy_2m = 0;
34163416
#endif
@@ -4252,12 +4252,11 @@ static int unknown_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
42524252
return 0;
42534253
}
42544254

4255-
static inline uint32_t feat_get(uint8_t *features)
4255+
static inline uint64_t feat_get(uint8_t *features)
42564256
{
4257-
uint32_t feat;
4257+
uint64_t feat;
42584258

4259-
feat = ~LL_FEAT_BIT_MASK_VALID | features[0] |
4260-
(features[1] << 8) | (features[2] << 16);
4259+
feat = ~LL_FEAT_BIT_MASK_VALID | sys_get_le64(features);
42614260
feat &= LL_FEAT_BIT_MASK;
42624261

42634262
return feat;
@@ -4267,9 +4266,9 @@ static inline uint32_t feat_get(uint8_t *features)
42674266
* Perform a logical and on octet0 and keep the remaining bits of the
42684267
* first input parameter
42694268
*/
4270-
static inline uint32_t feat_land_octet0(uint32_t feat_to_keep, uint32_t feat_octet0)
4269+
static inline uint64_t feat_land_octet0(uint64_t feat_to_keep, uint64_t feat_octet0)
42714270
{
4272-
uint32_t feat_result;
4271+
uint64_t feat_result;
42734272

42744273
feat_result = feat_to_keep & feat_octet0;
42754274
feat_result &= 0xFF;
@@ -4284,7 +4283,7 @@ static int feature_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
42844283
struct pdu_data_llctrl_feature_req *req;
42854284
struct node_tx *tx;
42864285
struct pdu_data *pdu_tx;
4287-
uint32_t feat;
4286+
uint64_t feat;
42884287

42894288
/* acquire tx mem */
42904289
tx = mem_acquire(&mem_conn_tx_ctrl.free);
@@ -4319,7 +4318,7 @@ static int feature_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
43194318
* See BTCore V5.2 VOl 6 Part B, chapter 5.1.4
43204319
*/
43214320
feat = feat_land_octet0(LL_FEAT, conn->llcp_feature.features_conn);
4322-
sys_put_le24(feat, pdu_tx->llctrl.feature_rsp.features);
4321+
sys_put_le64(feat, pdu_tx->llctrl.feature_rsp.features);
43234322

43244323
ctrl_tx_sec_enqueue(conn, tx);
43254324

subsys/bluetooth/controller/ll_sw/ull_conn_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ struct ll_conn {
162162
struct {
163163
uint8_t req;
164164
uint8_t ack;
165-
uint32_t features_conn;
166-
uint32_t features_peer;
165+
uint64_t features_conn;
166+
uint64_t features_peer;
167167
} llcp_feature;
168168

169169
struct {

0 commit comments

Comments
 (0)