You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/02/22 19:53:04 UTC

[mynewt-nimble] 05/05: nimble/ll: Add fixed css option

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 8e7cbbba3a2a90f08176274bb3f4d35eeb148090
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Feb 4 20:43:01 2022 +0100

    nimble/ll: Add fixed css option
    
    In fixed mode css always uses slot duration and slots per period
    configured with syscfg, configuration hci vs command is not included.
    This allows for some compile-time optimizations.
---
 .../controller/include/controller/ble_ll_sched.h   | 23 ++++++++++++++++++++++
 nimble/controller/src/ble_ll_hci_vs.c              |  4 ++++
 nimble/controller/src/ble_ll_sched.c               |  8 ++++++++
 nimble/controller/syscfg.yml                       |  6 ++++++
 4 files changed, 41 insertions(+)

diff --git a/nimble/controller/include/controller/ble_ll_sched.h b/nimble/controller/include/controller/ble_ll_sched.h
index a79262a..a65b5d4 100644
--- a/nimble/controller/include/controller/ble_ll_sched.h
+++ b/nimble/controller/include/controller/ble_ll_sched.h
@@ -176,12 +176,35 @@ int ble_ll_sched_dtm(struct ble_ll_sched_item *sch);
 #endif
 
 #if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED)
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
 void ble_ll_sched_css_set_params(uint32_t slot_us, uint32_t period_slots);
+#endif
 void ble_ll_sched_css_set_conn_anchor(struct ble_ll_conn_sm *connsm);
+#if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
+static inline uint32_t
+ble_ll_sched_css_get_slot_us(void)
+{
+    return MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_SLOT_US);
+}
+
+static inline uint32_t
+ble_ll_sched_css_get_period_slots(void)
+{
+    return MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_PERIOD_SLOTS);
+}
+
+static inline uint32_t
+ble_ll_sched_css_get_conn_interval_us(void)
+{
+    return ble_ll_sched_css_get_period_slots() *
+           ble_ll_sched_css_get_slot_us() / 1250;
+}
+#else
 uint32_t ble_ll_sched_css_get_slot_us(void);
 uint32_t ble_ll_sched_css_get_period_slots(void);
 uint32_t ble_ll_sched_css_get_conn_interval_us(void);
 #endif
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/nimble/controller/src/ble_ll_hci_vs.c b/nimble/controller/src/ble_ll_hci_vs.c
index 5049b39..2b39092 100644
--- a/nimble/controller/src/ble_ll_hci_vs.c
+++ b/nimble/controller/src/ble_ll_hci_vs.c
@@ -136,6 +136,7 @@ ble_ll_hci_vs_set_tx_power(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
 
 
 #if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
 static int
 ble_ll_hci_vs_css_configure(const uint8_t *cmdbuf, uint8_t cmdlen,
                             uint8_t *rspbuf, uint8_t *rsplen)
@@ -167,6 +168,7 @@ ble_ll_hci_vs_css_configure(const uint8_t *cmdbuf, uint8_t cmdlen,
 
     return BLE_ERR_SUCCESS;
 }
+#endif
 
 static int
 ble_ll_hci_vs_css_set_next_slot(const uint8_t *cmdbuf, uint8_t cmdlen,
@@ -251,8 +253,10 @@ ble_ll_hci_vs_css(uint16_t ocf, const uint8_t *cmdbuf, uint8_t cmdlen,
     *rsplen = 0;
 
     switch (cmd->opcode) {
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
     case BLE_HCI_VS_CSS_OP_CONFIGURE:
         return ble_ll_hci_vs_css_configure(cmdbuf, cmdlen, rspbuf, rsplen);
+#endif
     case BLE_HCI_VS_CSS_OP_SET_NEXT_SLOT:
         return ble_ll_hci_vs_css_set_next_slot(cmdbuf, cmdlen, rspbuf, rsplen);
     case BLE_HCI_VS_CSS_OP_SET_CONN_SLOT:
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index eb9ed8b..40139a8 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -47,8 +47,10 @@ int32_t g_ble_ll_sched_max_early;
 
 #if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED)
 struct ble_ll_sched_css {
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
     uint32_t slot_us;
     uint32_t period_slots;
+#endif
     uint32_t period_anchor_ticks;
     uint8_t period_anchor_rem_us;
     uint8_t period_anchor_idx;
@@ -56,8 +58,10 @@ struct ble_ll_sched_css {
 };
 
 static struct ble_ll_sched_css g_ble_ll_sched_css = {
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
     .slot_us = MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_SLOT_US),
     .period_slots = MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_PERIOD_SLOTS),
+#endif
 };
 #endif
 
@@ -1182,12 +1186,14 @@ ble_ll_sched_init(void)
 }
 
 #if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED)
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
 void
 ble_ll_sched_css_set_params(uint32_t slot_us, uint32_t period_slots)
 {
     g_ble_ll_sched_css.slot_us = slot_us;
     g_ble_ll_sched_css.period_slots = period_slots;
 }
+#endif
 
 void
 ble_ll_sched_css_set_conn_anchor(struct ble_ll_conn_sm *connsm)
@@ -1215,6 +1221,7 @@ ble_ll_sched_css_set_conn_anchor(struct ble_ll_conn_sm *connsm)
     }
 }
 
+#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
 inline uint32_t
 ble_ll_sched_css_get_slot_us(void)
 {
@@ -1234,5 +1241,6 @@ ble_ll_sched_css_get_conn_interval_us(void)
            ble_ll_sched_css_get_slot_us() /
            BLE_LL_CONN_ITVL_USECS;
 }
+#endif
 
 #endif
diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index 8f08dd7..ec1ef93 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -157,6 +157,12 @@ syscfg.defs:
             connections each at period-duration interval, each connection will
             be allocated at least one slot in each connection event.
         value: 0
+    BLE_LL_CONN_STRICT_SCHED_FIXED:
+        description: >
+            Enable fixed mode for connection strict scheduling, i.e. slot duration
+            and slots per period values are fixed to syscfg values and cannot
+            be changed in runtime. This allows for some compile-time optimizations.
+        value: 0
     BLE_LL_CONN_STRICT_SCHED_SLOT_US:
         description: >
             Slot duration in microseconds. Shall be multiply of 1250us.