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/03/28 17:07:43 UTC

[mynewt-nimble] branch master updated: nimble/ll: Fix internal flow control for conn

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


The following commit(s) were added to refs/heads/master by this push:
     new 3a4ca9e  nimble/ll: Fix internal flow control for conn
3a4ca9e is described below

commit 3a4ca9eb7edd25ff3d082bbeb77617d2f08dc856
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Mar 28 14:04:59 2022 +0200

    nimble/ll: Fix internal flow control for conn
    
    We need free credit if:
    in isr: credit is allocated but ll->hs flow control blocked allocation
    in task: credit was allocated for mbuf being freed (e.g. we allocate
             credits only for non-empty PDUs so we should not free a credit
             if this is an empty PDU)
---
 nimble/controller/src/ble_ll_conn.c | 16 ++++++++++++----
 nimble/include/nimble/ble.h         |  1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 3be8f66..9bbcfd4 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -3270,7 +3270,9 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct ble_mbuf_hdr *hdr)
     /* Free buffer */
 conn_rx_data_pdu_end:
 #if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
-    ble_transport_int_flow_ctl_put();
+    if (hdr->rxinfo.flags & BLE_MBUF_HDR_F_CONN_CREDIT_INT) {
+        ble_transport_int_flow_ctl_put();
+    }
 #endif
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_CTRL_TO_HOST_FLOW_CONTROL)
@@ -3337,9 +3339,12 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
     /* Do not alloc PDU if there are no free buffers in transport. We'll nak
      * this PDU in LL.
      */
-    if (alloc_rxpdu && BLE_LL_LLID_IS_DATA(hdr_byte) && (rx_pyld_len > 0) &&
-        !ble_transport_int_flow_ctl_get()) {
-        alloc_rxpdu = false;
+    if (alloc_rxpdu && BLE_LL_LLID_IS_DATA(hdr_byte) && (rx_pyld_len > 0)) {
+        if (ble_transport_int_flow_ctl_get()) {
+            rxhdr->rxinfo.flags |= BLE_MBUF_HDR_F_CONN_CREDIT_INT;
+        } else {
+            alloc_rxpdu = false;
+        }
     }
 #endif
 
@@ -3355,6 +3360,9 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
         if (ble_ll_conn_cth_flow_alloc_credit(connsm)) {
             rxhdr->rxinfo.flags |= BLE_MBUF_HDR_F_CONN_CREDIT;
         } else {
+#if MYNEWT_VAL(BLE_TRANSPORT_INT_FLOW_CTL)
+            ble_transport_int_flow_ctl_put();
+#endif
             alloc_rxpdu = false;
         }
     }
diff --git a/nimble/include/nimble/ble.h b/nimble/include/nimble/ble.h
index d349afe..bbf2275 100644
--- a/nimble/include/nimble/ble.h
+++ b/nimble/include/nimble/ble.h
@@ -93,6 +93,7 @@ struct ble_mbuf_hdr_rxinfo
 #define BLE_MBUF_HDR_F_CONNECT_RSP_RXD  (0x0008)
 #define BLE_MBUF_HDR_F_CONN_CREDIT      (0x8000)
 #define BLE_MBUF_HDR_F_IGNORED          (0x8000)
+#define BLE_MBUF_HDR_F_CONN_CREDIT_INT  (0x4000)
 #define BLE_MBUF_HDR_F_SCAN_REQ_TXD     (0x4000)
 #define BLE_MBUF_HDR_F_INITA_RESOLVED   (0x2000)
 #define BLE_MBUF_HDR_F_TARGETA_RESOLVED (0x2000)