Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimble/ll: Coding Selection support #1938

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions nimble/controller/include/controller/ble_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
#define BLE_LL_FEAT_CONN_SUBRATING (0x0002000000000)
#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x0004000000000)
#define BLE_LL_FEAT_CHANNEL_CLASS (0x0008000000000)
#define BLE_LL_FEAT_ADV_CODING_SEL (0x0010000000000)
#define BLE_LL_FEAT_ADV_CODING_SEL_HOST (0x0020000000000)
#define BLE_LL_FEAT_CS (0x0400000000000)
#define BLE_LL_FEAT_CS_HOST_SUPPORT (0x0800000000000)
#define BLE_LL_FEAT_CS_PCT_QUALITY_IND (0x1000000000000)
Expand All @@ -297,13 +299,6 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
#define BLE_LL_CONN_INITIAL_FEATURES (0x00000022)
#define BLE_LL_CONN_CLEAR_FEATURE(connsm, feature) (connsm->conn_features &= ~(feature))

/* All the features which can be controlled by the Host */
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
#define BLE_LL_HOST_CONTROLLED_FEATURES (BLE_LL_FEAT_CONN_SUBRATING_HOST)
#else
#define BLE_LL_HOST_CONTROLLED_FEATURES (0)
#endif

/* LL timing */
#define BLE_LL_IFS (150) /* usecs */
#define BLE_LL_MAFS (300) /* usecs */
Expand Down
13 changes: 12 additions & 1 deletion nimble/controller/src/ble_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ int8_t g_ble_ll_tx_power;
static int8_t g_ble_ll_tx_power_phy_current;
int8_t g_ble_ll_tx_power_compensation;
int8_t g_ble_ll_rx_power_compensation;
static const uint64_t g_ble_ll_host_controlled_features =
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
BLE_LL_FEAT_CONN_SUBRATING_HOST |
#elif MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
BLE_LL_FEAT_ADV_CODING_SEL_HOST |
#endif
0;

/* Supported states */
#if MYNEWT_VAL(BLE_LL_ROLE_BROADCASTER)
Expand Down Expand Up @@ -1486,7 +1493,7 @@ ble_ll_set_host_feat(const uint8_t *cmdbuf, uint8_t len)
}

mask = (uint64_t)1 << (cmd->bit_num);
if (!(mask & BLE_LL_HOST_CONTROLLED_FEATURES)) {
if (!(mask & g_ble_ll_host_controlled_features)) {
return BLE_ERR_UNSUPPORTED;
}

Expand Down Expand Up @@ -1939,6 +1946,10 @@ ble_ll_init(void)
features |= BLE_LL_FEAT_PERIODIC_ADV_ADI;
#endif

#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
features |= BLE_LL_FEAT_ADV_CODING_SEL;
#endif

lldata->ll_supp_features = features;

/* Initialize random number generation */
Expand Down
35 changes: 33 additions & 2 deletions nimble/controller/src/ble_ll_scan_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ struct ble_ll_scan_aux_data {
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
int8_t rpa_index;
#endif
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
uint8_t pri_phy_mode;
#endif
};

#define AUX_MEMPOOL_SIZE (OS_MEMPOOL_SIZE( \
Expand Down Expand Up @@ -216,7 +219,8 @@ ble_ll_scan_aux_need_truncation(struct ble_ll_scan_aux_data *aux)
}

static struct ble_hci_ev *
ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_ll_scan_addr_data *addrd,
ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_mbuf_hdr_rxinfo *rxinfo,
struct ble_ll_scan_addr_data *addrd,
struct ble_ll_scan_aux_data *aux)
{
struct ble_hci_ev_le_subev_ext_adv_rpt *hci_subev;
Expand Down Expand Up @@ -257,6 +261,16 @@ ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_ll_scan_addr_data *addrd,
report->tx_power = 0x7f;
report->rssi = 0x7f;
report->periodic_itvl = 0;

#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
if (aux->pri_phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
report->pri_phy = 0x04;
}
if (rxinfo->phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
report->sec_phy = 0x04;
}
#endif

if (addrd->targeta) {
report->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
report->dir_addr_type = addrd->targeta_type;
Expand Down Expand Up @@ -326,6 +340,12 @@ ble_ll_hci_ev_update_ext_adv_report_from_aux(struct ble_hci_ev *hci_ev,
}
report->sec_phy = rxhdr->rxinfo.phy;

#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
if (rxhdr->rxinfo.phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
report->sec_phy = 0x04;
}
#endif

/* Strip PDU header and ext header, leave only AD */
os_mbuf_adj(rxpdu, 3 + eh_len);

Expand Down Expand Up @@ -421,6 +441,13 @@ ble_ll_hci_ev_update_ext_adv_report_from_ext(struct ble_hci_ev *hci_ev,
report->periodic_itvl = 0;
report->data_len = 0;

//TODO(m): change set ext adv params v2 to this mynewt val
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
if (rxinfo->phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
report->pri_phy = 0x04;
}
#endif

/* Now parse extended header... */

if (eh_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
Expand Down Expand Up @@ -609,7 +636,7 @@ ble_ll_hci_ev_send_ext_adv_report_for_aux(struct os_mbuf *rxpdu,
hci_ev = aux->hci_ev;
aux->hci_ev = NULL;
} else {
hci_ev = ble_ll_hci_ev_alloc_ext_adv_report_for_aux(addrd, aux);
hci_ev = ble_ll_hci_ev_alloc_ext_adv_report_for_aux(&rxhdr->rxinfo, addrd, aux);
if (!hci_ev) {
aux->hci_state = BLE_LL_SCAN_AUX_H_DONE;
return -1;
Expand Down Expand Up @@ -1074,6 +1101,10 @@ ble_ll_scan_aux_rx_isr_end_on_ext(struct ble_ll_scan_sm *scansm,
aux->pri_phy = rxinfo->phy;
aux->aux_ptr = aux_ptr;

#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_CODING_SELECTION)
aux->pri_phy_mode = rxinfo->phy_mode;
#endif

if (addrd.adva) {
memcpy(aux->adva, addrd.adva, 6);
aux->adva_type = addrd.adva_type;
Expand Down
7 changes: 7 additions & 0 deletions nimble/controller/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ syscfg.defs:
restrictions:
- '(BLE_VERSION >= 53) if 1'

BLE_LL_CFG_FEAT_LL_CODING_SELECTION:
description: >
Enables support LE Coding Selection.
value: 1 #TODO(M)
restrictions:
- '(BLE_VERSION >= 54) if 1'

BLE_LL_PERIODIC_ADV_SYNC_BIGINFO_REPORTS:
description: >
This option is used to enable/disable support for
Expand Down
Loading