You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2024/01/12 11:26:03 UTC

(mynewt-nimble) branch master updated (24a3d58c -> e5acfe06)

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

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


    from 24a3d58c nimble/host: Fix possible overflow in ble_gatts_peer_cl_sup_feat_update
     new 4809e773 nimble/ll: Fix PHY update instant calculation
     new e5acfe06 nimble/ll: Fix channel map update instant calculation

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/controller/src/ble_ll_ctrl.c | 51 +++++++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 10 deletions(-)


(mynewt-nimble) 02/02: nimble/ll: Fix channel map update instant calculation

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e5acfe06c32b1b5806f890997c3ca7d7f32aad52
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Fri Dec 22 14:10:53 2023 +0100

    nimble/ll: Fix channel map update instant calculation
    
    The instant for channel map update was calculated at the time PDU was
    enqueued in connsm. This caused new map to be always applied at instant
    regardless if PDU was even dequeued for tx, e.g. in case there
    encryption procedure pending. This could result in connection being
    dropped.
    
    Currently we calculate instant when PDU is dequeued to make sure this is
    the next PDU to be sent and thus instant is valid.
---
 nimble/controller/src/ble_ll_ctrl.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c
index 6c739a3c..6eb883c8 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -1883,12 +1883,15 @@ ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
     memcpy(pyld, g_ble_ll_data.chan_map, BLE_LL_CHAN_MAP_LEN);
     memcpy(connsm->req_chanmap, pyld, BLE_LL_CHAN_MAP_LEN);
 
+    /* Instant is placed in ble_ll_ctrl_chanmap_req_instant()*/
+}
+
+static void
+ble_ll_ctrl_chanmap_req_instant(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
+{
     /* Place instant into request */
     connsm->chanmap_instant = connsm->event_cntr + connsm->periph_latency + 6 + 1;
     put_le16(pyld + BLE_LL_CHAN_MAP_LEN, connsm->chanmap_instant);
-
-    /* Set scheduled flag */
-    connsm->flags.chanmap_update_sched = 1;
 }
 
 /**
@@ -3106,6 +3109,10 @@ ble_ll_ctrl_tx_start(struct ble_ll_conn_sm *connsm, struct os_mbuf *txpdu)
         ble_ll_ctrl_conn_update_make_ind_pdu(connsm, ctrdata);
         connsm->flags.conn_update_sched = 1;
         break;
+    case BLE_LL_CTRL_CHANNEL_MAP_REQ:
+        ble_ll_ctrl_chanmap_req_instant(connsm, ctrdata);
+        connsm->flags.chanmap_update_sched = 1;
+        break;
 #if MYNEWT_VAL(BLE_LL_PHY)
     case BLE_LL_CTRL_PHY_UPDATE_IND:
         if (ble_ll_ctrl_phy_update_ind_instant(connsm, ctrdata)) {


(mynewt-nimble) 01/02: nimble/ll: Fix PHY update instant calculation

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4809e7735a1717c5348331977918587be2e23bf6
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Thu Dec 21 12:36:23 2023 +0100

    nimble/ll: Fix PHY update instant calculation
    
    The instant for PHY update was calculated at the time PDU was enqueued
    in connsm. This caused new PHY to be always applied at instant regardless
    if PDU was even dequeued for tx, e.g. in case there encryption procedure
    pending. This could result in connection being dropped.
    
    Currently we calculate instant when PDU is dequeued to make sure this is
    the next PDU to be sent and thus instant is valid.
---
 nimble/controller/src/ble_ll_ctrl.c | 38 ++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/nimble/controller/src/ble_ll_ctrl.c b/nimble/controller/src/ble_ll_ctrl.c
index d0989d65..6c739a3c 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -765,7 +765,6 @@ ble_ll_ctrl_phy_update_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
     uint8_t s_to_m;
     uint8_t tx_phys;
     uint8_t rx_phys;
-    uint16_t instant;
     uint8_t is_periph_sym = 0;
 
     /* Get preferences from PDU */
@@ -839,13 +838,7 @@ ble_ll_ctrl_phy_update_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
             connsm->flags.phy_update_host_initiated = 0;
             ble_ll_ctrl_proc_stop(connsm, BLE_LL_CTRL_PROC_PHY_UPDATE);
         }
-        instant = 0;
     } else {
-        /* Determine instant we will use. 6 more is minimum */
-        instant = connsm->event_cntr + connsm->periph_latency + 6 + 1;
-        connsm->phy_instant = instant;
-        connsm->flags.phy_update_sched = 1;
-
         /* Set new phys to use when instant occurs */
         connsm->phy_data.new_tx_phy = m_to_s;
         connsm->phy_data.new_rx_phy = s_to_m;
@@ -862,7 +855,31 @@ ble_ll_ctrl_phy_update_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 
     ctrdata[0] = m_to_s;
     ctrdata[1] = s_to_m;
+}
+
+static bool
+ble_ll_ctrl_phy_update_ind_instant(struct ble_ll_conn_sm *connsm, uint8_t *ctrdata)
+{
+    uint16_t instant;
+    uint8_t m_to_s;
+    uint8_t s_to_m;
+    bool schedule = false;
+
+    m_to_s = ctrdata[0];
+    s_to_m = ctrdata[1];
+
+    if ((m_to_s == 0) && (s_to_m == 0)) {
+        instant = 0;
+    } else {
+        /* Determine instant we will use. 6 more is minimum */
+        instant = connsm->event_cntr + connsm->periph_latency + 6 + 1;
+        connsm->phy_instant = instant;
+        schedule = true;
+    }
+
     put_le16(ctrdata + 2, instant);
+
+    return schedule;
 }
 #endif
 
@@ -3089,6 +3106,13 @@ ble_ll_ctrl_tx_start(struct ble_ll_conn_sm *connsm, struct os_mbuf *txpdu)
         ble_ll_ctrl_conn_update_make_ind_pdu(connsm, ctrdata);
         connsm->flags.conn_update_sched = 1;
         break;
+#if MYNEWT_VAL(BLE_LL_PHY)
+    case BLE_LL_CTRL_PHY_UPDATE_IND:
+        if (ble_ll_ctrl_phy_update_ind_instant(connsm, ctrdata)) {
+            connsm->flags.phy_update_sched = 1;
+        }
+        break;
+#endif
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
     case BLE_LL_CTRL_SUBRATE_IND:
         connsm->flags.subrate_trans = 1;