drivers: bluetooth: hci: rpmsg: fix handling of hci events

Fixed handling of HCI events in the HCI driver over RPMsg. Now,
the driver makes use of discardable buffer pool when allocating
memory for certain HCI event types (e.g. Advertising Report Event).
Applications that are flooded with Advertising Reports will run
much better after this change (e.g. Mesh applications).

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
This commit is contained in:
Kamil Piszczek 2019-11-21 10:59:38 +01:00 committed by Johan Hedberg
commit 362f2299cd
2 changed files with 35 additions and 3 deletions

View file

@ -23,9 +23,35 @@
int bt_rpmsg_platform_init(void);
int bt_rpmsg_platform_send(struct net_buf *buf);
static bool is_hci_event_discardable(const u8_t *evt_data)
{
u8_t evt_type = evt_data[0];
switch (evt_type) {
#if defined(CONFIG_BT_BREDR)
case BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI:
case BT_HCI_EVT_EXTENDED_INQUIRY_RESULT:
return true;
#endif
case BT_HCI_EVT_LE_META_EVENT: {
u8_t subevt_type = evt_data[sizeof(struct bt_hci_evt_hdr)];
switch (subevt_type) {
case BT_HCI_EVT_LE_ADVERTISING_REPORT:
return true;
default:
return false;
}
}
default:
return false;
}
}
static struct net_buf *bt_rpmsg_evt_recv(u8_t *data, size_t remaining,
bool *prio)
{
bool discardable;
struct bt_hci_evt_hdr hdr;
struct net_buf *buf;
@ -34,6 +60,8 @@ static struct net_buf *bt_rpmsg_evt_recv(u8_t *data, size_t remaining,
return NULL;
}
discardable = is_hci_event_discardable(data);
memcpy((void *)&hdr, data, sizeof(hdr));
data += sizeof(hdr);
remaining -= sizeof(hdr);
@ -44,9 +72,13 @@ static struct net_buf *bt_rpmsg_evt_recv(u8_t *data, size_t remaining,
}
BT_DBG("len %u", hdr.len);
buf = bt_buf_get_evt(hdr.evt, false, K_NO_WAIT);
buf = bt_buf_get_evt(hdr.evt, discardable, K_NO_WAIT);
if (!buf) {
BT_ERR("No available event buffers!");
if (discardable) {
BT_DBG("Discardable buffer pool full, ignoring event");
} else {
BT_ERR("No available event buffers!");
}
return buf;
}

View file

@ -50,7 +50,7 @@ config BT_DISCARDABLE_BUF_COUNT
range 1 255
default 20 if BT_MESH
default 3
depends on BT_H4 || BT_CTLR
depends on BT_H4 || BT_RPMSG || BT_CTLR
help
Number of buffers in a separate buffer pool for events which
the HCI driver considers discardable. Examples of such events