Skip to content

Commit f8ac289

Browse files
alwa-nordiccvinayak
authored andcommitted
Bluetooth: Rename num_complete_pool -> sync_evt_pool
Refactor only. The surrounding ifdefs are intentionally not changed in this patch. They will be in the near future. Rename the pool and generalize the documentation to allow using this pool for other events that fit the same criteria. This pool can be used for any buffer that is processed synchronously, without negatively affecting 'num complete' messages. E.g. 'cmd complete/status' can be put in this pool already. We will be working towards making the host process all event buffers synchronously. This is because events have no dedicated flow control, and discarding events in the driver without informing the host creates problems. Discarding should instead happen in the host higher layers when unavoidable. Signed-off-by: Aleksander Wasaznik <[email protected]> (cherry picked from commit 2a7adae) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 13c4e70 commit f8ac289

File tree

1 file changed

+12
-8
lines changed
  • subsys/bluetooth/host

1 file changed

+12
-8
lines changed

subsys/bluetooth/host/buf.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@
2828
#define NUM_COMLETE_EVENT_SIZE BT_BUF_EVT_SIZE( \
2929
sizeof(struct bt_hci_cp_host_num_completed_packets) + \
3030
MAX_EVENT_COUNT * sizeof(struct bt_hci_handle_count))
31-
/* Dedicated pool for HCI_Number_of_Completed_Packets. This event is always
32-
* consumed synchronously by bt_recv_prio() so a single buffer is enough.
33-
* Having a dedicated pool for it ensures that exhaustion of the RX pool
34-
* cannot block the delivery of this priority event.
31+
32+
/* Pool for RX HCI buffers that are always freed by `bt_recv`
33+
* before it returns.
34+
*
35+
* A singleton buffer shall be sufficient for correct operation.
36+
* The buffer count may be increased as an optimization to allow
37+
* the HCI transport to fill buffers in parallel with `bt_recv`
38+
* consuming them.
3539
*/
36-
NET_BUF_POOL_FIXED_DEFINE(num_complete_pool, 1, NUM_COMLETE_EVENT_SIZE,
37-
sizeof(struct bt_buf_data), NULL);
40+
#define SYNC_EVT_SIZE NUM_COMLETE_EVENT_SIZE
41+
NET_BUF_POOL_FIXED_DEFINE(sync_evt_pool, 1, SYNC_EVT_SIZE, sizeof(struct bt_buf_data), NULL);
3842
#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */
3943

4044
NET_BUF_POOL_FIXED_DEFINE(discardable_pool, CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT,
@@ -92,7 +96,7 @@ struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable,
9296
switch (evt) {
9397
#if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO)
9498
case BT_HCI_EVT_NUM_COMPLETED_PACKETS:
95-
buf = net_buf_alloc(&num_complete_pool, timeout);
99+
buf = net_buf_alloc(&sync_evt_pool, timeout);
96100
break;
97101
#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */
98102
default:
@@ -139,7 +143,7 @@ struct net_buf_pool *bt_buf_get_discardable_pool(void)
139143
#if defined(CONFIG_BT_CONN) || defined(CONFIG_BT_ISO)
140144
struct net_buf_pool *bt_buf_get_num_complete_pool(void)
141145
{
142-
return &num_complete_pool;
146+
return &sync_evt_pool;
143147
}
144148
#endif /* CONFIG_BT_CONN || CONFIG_BT_ISO */
145149
#endif /* ZTEST_UNITTEST */

0 commit comments

Comments
 (0)