Skip to content

Commit

Permalink
Bluetooth: Add dedicated pool for HCI_Num_Completed_Packets HCI event
Browse files Browse the repository at this point in the history
This event is a priority one, so it's not safe to have it use the RX
buffer pool which may be depleted due to non-priority events (e.g.
advertising events). Since the event is consumed synchronously it's
safe to have a single-buffer pool for it. Also introduce a new
bt_buf_get_evt() API for HCI drivers to simplify the driver-side code,
this effectively also deprecates bt_buf_get_cmd_complete() which now
has no in-tree HCI driver users anymore.

Fixes #16864

Signed-off-by: Johan Hedberg <[email protected]>
  • Loading branch information
Johan Hedberg authored and nashif committed Jul 2, 2019
1 parent 7e37ef4 commit d7d9988
Show file tree
Hide file tree
Showing 12 changed files with 853 additions and 35 deletions.
11 changes: 3 additions & 8 deletions drivers/bluetooth/hci/h4.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,11 @@ static struct net_buf *get_rx(int timeout)
{
BT_DBG("type 0x%02x, evt 0x%02x", rx.type, rx.evt.evt);

if (rx.type == H4_EVT && (rx.evt.evt == BT_HCI_EVT_CMD_COMPLETE ||
rx.evt.evt == BT_HCI_EVT_CMD_STATUS)) {
return bt_buf_get_cmd_complete(timeout);
if (rx.type == H4_EVT) {
return bt_buf_get_evt(rx.evt.evt, timeout);
}

if (rx.type == H4_ACL) {
return bt_buf_get_rx(BT_BUF_ACL_IN, timeout);
} else {
return bt_buf_get_rx(BT_BUF_EVT, timeout);
}
return bt_buf_get_rx(BT_BUF_ACL_IN, timeout);
}

static void rx_thread(void *p1, void *p2, void *p3)
Expand Down
11 changes: 1 addition & 10 deletions drivers/bluetooth/hci/h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,7 @@ static inline struct net_buf *get_evt_buf(u8_t evt)
{
struct net_buf *buf;

switch (evt) {
case BT_HCI_EVT_CMD_COMPLETE:
case BT_HCI_EVT_CMD_STATUS:
buf = bt_buf_get_cmd_complete(K_NO_WAIT);
break;
default:
buf = bt_buf_get_rx(BT_BUF_EVT, K_NO_WAIT);
break;
}

buf = bt_buf_get_evt(evt, K_NO_WAIT);
if (buf) {
net_buf_add_u8(h5.rx_buf, evt);
}
Expand Down
Loading

0 comments on commit d7d9988

Please sign in to comment.