Bluetooth: controller: Replace use if LL_FEAT with ll_feat_get()

Replace the use of LL_FEAT define with ll_feat_get() so that
feature set value can be updated at runtime with host
feature bit values.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2021-02-18 12:38:45 +05:30 committed by Carles Cufí
commit ed59ceba62
7 changed files with 20 additions and 11 deletions

View file

@ -1195,7 +1195,7 @@ static void le_read_local_features(struct net_buf *buf, struct net_buf **evt)
rp->status = 0x00;
(void)memset(&rp->features[0], 0x00, sizeof(rp->features));
sys_put_le64(LL_FEAT, rp->features);
sys_put_le64(ll_feat_get(), rp->features);
}
static void le_set_random_address(struct net_buf *buf, struct net_buf **evt)

View file

@ -12,6 +12,8 @@
int ll_init(struct k_sem *sem_rx);
void ll_reset(void);
uint64_t ll_feat_get(void);
uint8_t *ll_addr_get(uint8_t addr_type, uint8_t *p_bdaddr);
uint8_t ll_addr_set(uint8_t addr_type, uint8_t const *const p_bdaddr);

View file

@ -6,6 +6,8 @@
#include <zephyr.h>
#include "ll_feat.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
#define LOG_MODULE_NAME bt_ctlr_ll_feat
#include "common/log.h"
@ -18,3 +20,8 @@ uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value)
return BT_HCI_ERR_CMD_DISALLOWED;
}
uint64_t ll_feat_get(void)
{
return LL_FEAT;
}

View file

@ -909,7 +909,7 @@ uint8_t ll_adv_enable(uint8_t enable)
conn->llcp_rx = NULL;
conn->llcp_cu.req = conn->llcp_cu.ack = 0;
conn->llcp_feature.req = conn->llcp_feature.ack = 0;
conn->llcp_feature.features_conn = LL_FEAT;
conn->llcp_feature.features_conn = ll_feat_get();
conn->llcp_feature.features_peer = 0;
conn->llcp_version.req = conn->llcp_version.ack = 0;
conn->llcp_version.tx = conn->llcp_version.rx = 0;

View file

@ -3122,9 +3122,6 @@ static inline void event_fex_prep(struct ll_conn *conn)
/* procedure request acked, move to waiting state */
conn->llcp_feature.ack--;
/* use initial feature bitmap */
conn->llcp_feature.features_conn = LL_FEAT;
/* place the feature exchange req packet as next in tx queue */
pdu->ll_id = PDU_DATA_LLID_CTRL;
pdu->len = offsetof(struct pdu_data_llctrl, feature_req) +
@ -4434,7 +4431,7 @@ static inline uint64_t feat_get(uint8_t *features)
{
uint64_t feat;
feat = ~LL_FEAT_BIT_MASK_VALID | sys_get_le64(features);
feat = sys_get_le64(features) | ~LL_FEAT_BIT_MASK_VALID;
feat &= LL_FEAT_BIT_MASK;
return feat;
@ -4444,7 +4441,8 @@ static inline uint64_t feat_get(uint8_t *features)
* Perform a logical and on octet0 and keep the remaining bits of the
* first input parameter
*/
static inline uint64_t feat_land_octet0(uint64_t feat_to_keep, uint64_t feat_octet0)
static inline uint64_t feat_land_octet0(uint64_t feat_to_keep,
uint64_t feat_octet0)
{
uint64_t feat_result;
@ -4481,7 +4479,7 @@ static int feature_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
* See BTCore V5.2, Vol. 6, Part B, chapter 5.1.4
*/
conn->llcp_feature.features_peer =
feat_land_octet0(feat_get(&req->features[0]), LL_FEAT);
feat_land_octet0(feat_get(&req->features[0]), ll_feat_get());
/* features exchanged */
conn->common.fex_valid = 1U;
@ -4498,7 +4496,8 @@ static int feature_rsp_send(struct ll_conn *conn, struct node_rx_pdu *rx,
* On feature response we send the local supported features.
* See BTCore V5.2 VOl 6 Part B, chapter 5.1.4
*/
feat = feat_land_octet0(LL_FEAT, conn->llcp_feature.features_conn);
feat = feat_land_octet0(ll_feat_get(),
conn->llcp_feature.features_conn);
sys_put_le64(feat, pdu_tx->llctrl.feature_rsp.features);
ctrl_tx_sec_enqueue(conn, tx);
@ -4525,7 +4524,7 @@ static void feature_rsp_recv(struct ll_conn *conn, struct pdu_data *pdu_rx)
* See BTCore V5.2, Vol. 6, Part B, chapter 5.1.4
*/
conn->llcp_feature.features_peer =
feat_land_octet0(feat_get(&rsp->features[0]), LL_FEAT);
feat_land_octet0(feat_get(&rsp->features[0]), ll_feat_get());
/* features exchanged */
conn->common.fex_valid = 1U;

View file

@ -172,6 +172,7 @@ struct ll_conn {
struct {
uint8_t req;
uint8_t ack;
/* TODO: 8, 16, 32 or 64 based on local supported features */
uint64_t features_conn;
uint64_t features_peer;
} llcp_feature;

View file

@ -257,7 +257,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
conn->llcp_rx = NULL;
conn->llcp_cu.req = conn->llcp_cu.ack = 0;
conn->llcp_feature.req = conn->llcp_feature.ack = 0;
conn->llcp_feature.features_conn = LL_FEAT;
conn->llcp_feature.features_conn = ll_feat_get();
conn->llcp_feature.features_peer = 0;
conn->llcp_version.req = conn->llcp_version.ack = 0;
conn->llcp_version.tx = conn->llcp_version.rx = 0U;