Skip to content

Commit bfa3fdb

Browse files
committed
Revert "[nrf fromtree] bluetooth: buf: Add a callback for freed buffer in rx pool"
This reverts commit fa2f75e. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent c1c2532 commit bfa3fdb

File tree

5 files changed

+13
-130
lines changed

5 files changed

+13
-130
lines changed

include/zephyr/bluetooth/buf.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,27 +146,6 @@ BUILD_ASSERT(CONFIG_BT_BUF_EVT_RX_COUNT > CONFIG_BT_BUF_ACL_TX_COUNT,
146146
*/
147147
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout);
148148

149-
/** A callback to notify about freed buffer in the incoming data pool.
150-
*
151-
* This callback is called when a buffer of a given type is freed and can be requested through the
152-
* @ref bt_buf_get_rx function. However, this callback is called from the context of the buffer
153-
* freeing operation and must not attempt to allocate a new buffer from the same pool.
154-
*
155-
* @warning When this callback is called, the scheduler is locked and the callee must not perform
156-
* any action that makes the current thread unready. This callback must only be used for very
157-
* short non-blocking operation (e.g. submitting a work item).
158-
*
159-
* @param type_mask A bit mask of buffer types that have been freed.
160-
*/
161-
typedef void (*bt_buf_rx_freed_cb_t)(enum bt_buf_type type_mask);
162-
163-
/** Set the callback to notify about freed buffer in the incoming data pool.
164-
*
165-
* @param cb Callback to notify about freed buffer in the incoming data pool. If NULL, the callback
166-
* is disabled.
167-
*/
168-
void bt_buf_rx_freed_cb_set(bt_buf_rx_freed_cb_t cb);
169-
170149
/** Allocate a buffer for outgoing data
171150
*
172151
* This will set the buffer type so bt_buf_set_type() does not need to

subsys/bluetooth/host/buf.c

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,6 @@
2222
*/
2323
#define SYNC_EVT_SIZE (BT_BUF_RESERVE + BT_HCI_EVT_HDR_SIZE + 255)
2424

25-
static bt_buf_rx_freed_cb_t buf_rx_freed_cb;
26-
27-
static void buf_rx_freed_notify(enum bt_buf_type mask)
28-
{
29-
k_sched_lock();
30-
31-
if (buf_rx_freed_cb) {
32-
buf_rx_freed_cb(mask);
33-
}
34-
35-
k_sched_unlock();
36-
}
37-
38-
#if defined(CONFIG_BT_ISO_RX)
39-
static void iso_rx_freed_cb(void)
40-
{
41-
buf_rx_freed_notify(BT_BUF_ISO_IN);
42-
}
43-
#endif
44-
4525
/* Pool for RX HCI buffers that are always freed by `bt_recv`
4626
* before it returns.
4727
*
@@ -57,37 +37,17 @@ NET_BUF_POOL_FIXED_DEFINE(discardable_pool, CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT,
5737
sizeof(struct bt_buf_data), NULL);
5838

5939
#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
60-
static void acl_in_pool_destroy(struct net_buf *buf)
61-
{
62-
bt_hci_host_num_completed_packets(buf);
63-
buf_rx_freed_notify(BT_BUF_ACL_IN);
64-
}
65-
66-
static void evt_pool_destroy(struct net_buf *buf)
67-
{
68-
net_buf_destroy(buf);
69-
buf_rx_freed_notify(BT_BUF_EVT);
70-
}
40+
NET_BUF_POOL_DEFINE(acl_in_pool, BT_BUF_ACL_RX_COUNT,
41+
BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE),
42+
sizeof(struct acl_data), bt_hci_host_num_completed_packets);
7143

72-
NET_BUF_POOL_DEFINE(acl_in_pool, BT_BUF_ACL_RX_COUNT, BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE),
73-
sizeof(struct acl_data), acl_in_pool_destroy);
74-
75-
NET_BUF_POOL_FIXED_DEFINE(evt_pool, CONFIG_BT_BUF_EVT_RX_COUNT, BT_BUF_EVT_RX_SIZE,
76-
sizeof(struct bt_buf_data), evt_pool_destroy);
44+
NET_BUF_POOL_FIXED_DEFINE(evt_pool, CONFIG_BT_BUF_EVT_RX_COUNT,
45+
BT_BUF_EVT_RX_SIZE, sizeof(struct bt_buf_data),
46+
NULL);
7747
#else
78-
static void hci_rx_pool_destroy(struct net_buf *buf)
79-
{
80-
net_buf_destroy(buf);
81-
82-
/* When ACL Flow Control is disabled, a single pool is used for events and acl data.
83-
* Therefore the callback will always notify about both types of buffers, BT_BUF_EVT and
84-
* BT_BUF_ACL_IN.
85-
*/
86-
buf_rx_freed_notify(BT_BUF_EVT | BT_BUF_ACL_IN);
87-
}
88-
89-
NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT, BT_BUF_RX_SIZE, sizeof(struct acl_data),
90-
hci_rx_pool_destroy);
48+
NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT,
49+
BT_BUF_RX_SIZE, sizeof(struct acl_data),
50+
NULL);
9151
#endif /* CONFIG_BT_HCI_ACL_FLOW_CONTROL */
9252

9353
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
@@ -119,19 +79,6 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
11979
return buf;
12080
}
12181

122-
void bt_buf_rx_freed_cb_set(bt_buf_rx_freed_cb_t cb)
123-
{
124-
k_sched_lock();
125-
126-
buf_rx_freed_cb = cb;
127-
128-
#if defined(CONFIG_BT_ISO_RX)
129-
bt_iso_buf_rx_freed_cb_set(cb != NULL ? iso_rx_freed_cb : NULL);
130-
#endif
131-
132-
k_sched_unlock();
133-
}
134-
13582
struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable,
13683
k_timeout_t timeout)
13784
{

subsys/bluetooth/host/hci_raw.c

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,8 @@ static uint8_t raw_mode = BT_HCI_RAW_MODE_H4;
4343
static uint8_t raw_mode;
4444
#endif
4545

46-
static bt_buf_rx_freed_cb_t buf_rx_freed_cb;
47-
48-
static void hci_rx_buf_destroy(struct net_buf *buf)
49-
{
50-
net_buf_destroy(buf);
51-
52-
if (buf_rx_freed_cb) {
53-
/* bt_buf_get_rx is used for all types of RX buffers */
54-
buf_rx_freed_cb(BT_BUF_EVT | BT_BUF_ACL_IN | BT_BUF_ISO_IN);
55-
}
56-
}
57-
58-
NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT, BT_BUF_RX_SIZE, sizeof(struct bt_buf_data),
59-
hci_rx_buf_destroy);
46+
NET_BUF_POOL_FIXED_DEFINE(hci_rx_pool, BT_BUF_RX_COUNT,
47+
BT_BUF_RX_SIZE, sizeof(struct bt_buf_data), NULL);
6048
NET_BUF_POOL_FIXED_DEFINE(hci_cmd_pool, BT_BUF_CMD_TX_COUNT,
6149
BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE),
6250
sizeof(struct bt_buf_data), NULL);
@@ -118,11 +106,6 @@ struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
118106
return buf;
119107
}
120108

121-
void bt_buf_rx_freed_cb_set(bt_buf_rx_freed_cb_t cb)
122-
{
123-
buf_rx_freed_cb = cb;
124-
}
125-
126109
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
127110
const void *data, size_t size)
128111
{

subsys/bluetooth/host/iso.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,9 @@ LOG_MODULE_REGISTER(bt_iso);
3535
#define iso_chan(_iso) ((_iso)->iso.chan);
3636

3737
#if defined(CONFIG_BT_ISO_RX)
38-
static bt_iso_buf_rx_freed_cb_t buf_rx_freed_cb;
39-
40-
static void iso_rx_buf_destroy(struct net_buf *buf)
41-
{
42-
net_buf_destroy(buf);
43-
44-
if (buf_rx_freed_cb) {
45-
buf_rx_freed_cb();
46-
}
47-
}
48-
4938
NET_BUF_POOL_FIXED_DEFINE(iso_rx_pool, CONFIG_BT_ISO_RX_BUF_COUNT,
50-
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_RX_MTU), sizeof(struct iso_data),
51-
iso_rx_buf_destroy);
39+
BT_ISO_SDU_BUF_SIZE(CONFIG_BT_ISO_RX_MTU),
40+
sizeof(struct iso_data), NULL);
5241

5342
static struct bt_iso_recv_info iso_info_data[CONFIG_BT_ISO_RX_BUF_COUNT];
5443
#define iso_info(buf) (&iso_info_data[net_buf_id(buf)])
@@ -594,11 +583,6 @@ struct net_buf *bt_iso_get_rx(k_timeout_t timeout)
594583
return buf;
595584
}
596585

597-
void bt_iso_buf_rx_freed_cb_set(bt_iso_buf_rx_freed_cb_t cb)
598-
{
599-
buf_rx_freed_cb = cb;
600-
}
601-
602586
void bt_iso_recv(struct bt_conn *iso, struct net_buf *buf, uint8_t flags)
603587
{
604588
struct bt_hci_iso_data_hdr *hdr;

subsys/bluetooth/host/iso_internal.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ void hci_iso(struct net_buf *buf);
7878
/* Allocates RX buffer */
7979
struct net_buf *bt_iso_get_rx(k_timeout_t timeout);
8080

81-
/** A callback used to notify about freed buffer in the iso rx pool. */
82-
typedef void (*bt_iso_buf_rx_freed_cb_t)(void);
83-
84-
/** Set a callback to notify about freed buffer in the iso rx pool.
85-
*
86-
* @param cb Callback to notify about freed buffer in the iso rx pool. If NULL, the callback is
87-
* disabled.
88-
*/
89-
void bt_iso_buf_rx_freed_cb_set(bt_iso_buf_rx_freed_cb_t cb);
90-
9181
/* Process CIS Established event */
9282
void hci_le_cis_established(struct net_buf *buf);
9383

0 commit comments

Comments
 (0)