diff --git a/nimble/host/src/ble_hs_hci.c b/nimble/host/src/ble_hs_hci.c index ea2e067ee..f9167ff0b 100644 --- a/nimble/host/src/ble_hs_hci.c +++ b/nimble/host/src/ble_hs_hci.c @@ -440,6 +440,24 @@ ble_hs_hci_frag_alloc(uint16_t frag_size, void *arg) return NULL; } +/** + * Retrieves the total capacity of the ACL fragment pool (always 1). + */ +int +ble_hs_hci_frag_num_mbufs(void) +{ + return ble_hs_hci_frag_mempool.mp_num_blocks; +} + +/** + * Retrieves the the count of free buffers in the ACL fragment pool. + */ +int +ble_hs_hci_frag_num_mbufs_free(void) +{ + return ble_hs_hci_frag_mempool.mp_num_free; +} + static struct os_mbuf * ble_hs_hci_acl_hdr_prepend(struct os_mbuf *om, uint16_t handle, uint8_t pb_flag) diff --git a/nimble/host/src/ble_hs_hci_priv.h b/nimble/host/src/ble_hs_hci_priv.h index a152dde1e..dc4d676d3 100644 --- a/nimble/host/src/ble_hs_hci_priv.h +++ b/nimble/host/src/ble_hs_hci_priv.h @@ -262,6 +262,9 @@ int ble_hs_hci_cmd_build_le_set_phy(uint16_t conn_handle, uint8_t tx_phys_mask, uint8_t rx_phys_mask, uint16_t phy_opts, uint8_t *dst, int dst_len); +int ble_hs_hci_frag_num_mbufs(void); +int ble_hs_hci_frag_num_mbufs_free(void); + #if MYNEWT_VAL(BLE_EXT_ADV) #endif diff --git a/nimble/host/test/src/ble_hs_test_util.c b/nimble/host/test/src/ble_hs_test_util.c index a63d02f68..af30b8fa6 100644 --- a/nimble/host/test/src/ble_hs_test_util.c +++ b/nimble/host/test/src/ble_hs_test_util.c @@ -1738,6 +1738,18 @@ ble_hs_test_util_mbuf_chain_len(const struct os_mbuf *om) return count; } +static int +ble_hs_test_util_num_mbufs(void) +{ + return os_msys_count() + ble_hs_hci_frag_num_mbufs(); +} + +static int +ble_hs_test_util_num_mbufs_free(void) +{ + return os_msys_num_free() + ble_hs_hci_frag_num_mbufs_free(); +} + struct os_mbuf * ble_hs_test_util_mbuf_alloc_all_but(int count) { @@ -1787,7 +1799,7 @@ ble_hs_test_util_mbuf_count(const struct ble_hs_test_util_mbuf_params *params) ble_hs_process_rx_data_queue(); - count = os_msys_num_free(); + count = ble_hs_test_util_num_mbufs_free(); if (params->prev_tx) { count += ble_hs_test_util_mbuf_chain_len(ble_hs_test_util_prev_tx_cur); @@ -1838,7 +1850,7 @@ ble_hs_test_util_assert_mbufs_freed( } count = ble_hs_test_util_mbuf_count(params); - TEST_ASSERT(count == os_msys_count()); + TEST_ASSERT(count == ble_hs_test_util_num_mbufs()); } static int