Bluetooth: Controller: Deprioritize adv report buffer allocation

Advertising reports are the only HCI events which we can drop if we
are low on buffers. Allocate them therefore with K_NO_WAIT rather than
K_FOREVER.

Change-Id: I0b7c92647f9be54b8746da837037725f8161a452
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-12-31 11:24:44 +02:00
commit 2f191012c2
3 changed files with 21 additions and 3 deletions

View file

@ -1367,3 +1367,13 @@ void hci_num_cmplt_encode(struct net_buf *buf, uint16_t handle, uint8_t num)
hc->handle = sys_cpu_to_le16(handle);
hc->count = sys_cpu_to_le16(num);
}
bool hci_evt_is_discardable(struct radio_pdu_node_rx *node_rx)
{
switch (node_rx->hdr.type) {
case NODE_RX_TYPE_REPORT:
return true;
default:
return false;
}
}

View file

@ -236,9 +236,16 @@ static void recv_thread(void *p1, void *p2, void *p3)
if (node_rx->hdr.type != NODE_RX_TYPE_DC_PDU ||
pdu_data->ll_id == PDU_DATA_LLID_CTRL) {
/* generate a (non-priority) HCI event */
if (hci_evt_is_discardable(node_rx)) {
buf = bt_buf_get_rx(K_NO_WAIT);
} else {
buf = bt_buf_get_rx(K_FOREVER);
}
if (buf) {
bt_buf_set_type(buf, BT_BUF_EVT);
hci_evt_encode(node_rx, buf);
}
} else {
/* generate ACL data */
buf = bt_buf_get_rx(K_FOREVER);

View file

@ -24,4 +24,5 @@ void hci_evt_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf);
void hci_acl_encode(struct radio_pdu_node_rx *node_rx, struct net_buf *buf);
void hci_num_cmplt_encode(struct net_buf *buf, uint16_t handle, uint8_t num);
void hci_le_rand(void *buf, uint8_t len);
bool hci_evt_is_discardable(struct radio_pdu_node_rx *node_rx);
#endif /* _HCI_CONTROLLER_H_ */