diff --git a/include/zephyr/bluetooth/testing.h b/include/zephyr/bluetooth/testing.h new file mode 100644 index 00000000000..3ac48c7b36e --- /dev/null +++ b/include/zephyr/bluetooth/testing.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @brief Internal testing interfaces for Bluetooth + * @file + * @internal + * + * The interfaces in this file are internal and not stable. + */ + +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ +#define ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ + +#include + +/** @brief Hook for `acl_in_pool.destroy` + * + * Weak-function interface. The user can simply define this + * function, and it will automatically become the event + * listener. + * + * @kconfig_dep{CONFIG_BT_TESTING} + */ +void bt_testing_trace_event_acl_pool_destroy(struct net_buf *buf); + +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ */ diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 2db727fb6eb..7bb93f5295e 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #if DT_HAS_CHOSEN(zephyr_bt_hci) #include #else @@ -263,6 +265,12 @@ void bt_send_one_host_num_completed_packets(uint16_t handle) BT_ASSERT_MSG(err == 0, "Unable to send Host NCP (err %d)", err); } +#if defined(CONFIG_BT_TESTING) +__weak void bt_testing_trace_event_acl_pool_destroy(struct net_buf *buf) +{ +} +#endif + #if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL) void bt_hci_host_num_completed_packets(struct net_buf *buf) { @@ -270,6 +278,10 @@ void bt_hci_host_num_completed_packets(struct net_buf *buf) struct bt_conn *conn; uint8_t index = acl(buf)->index; + if (IS_ENABLED(CONFIG_BT_TESTING)) { + bt_testing_trace_event_acl_pool_destroy(buf); + } + net_buf_destroy(buf); if (acl(buf)->host_ncp_sent) {