Skip to content

Commit

Permalink
[nrf fromtree] Bluetooth: Controller: Fix to use non-discardable buffer
Browse files Browse the repository at this point in the history
Fix to use non-discardable Rx buffer for handling Extended
and Periodic Advertising Report.

Regression introduced in
commit 18171bc ("Bluetooth: Host: Non-discardable event
buffer size is 255 for ext adv"). The default discardable Rx
buffer size was reduced causing increased fragmentation and
deadlock trying to get more free discardable Rx buffers to
generate HCI Extended and Periodic Advertising reports.

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
(cherry picked from commit 230f4f1)
(cherry picked from commit 901604f)
  • Loading branch information
cvinayak authored and mbolivar-nordic committed Feb 10, 2022
1 parent 7d45497 commit 54af281
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions subsys/bluetooth/controller/hci/hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ static uint32_t conn_count;
static uint32_t cis_pending_count;
#endif

#if !defined(CONFIG_BT_HCI_RAW) && defined(CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT)
#define ADV_REPORT_EVT_MAX_LEN CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE
#else
#define ADV_REPORT_EVT_MAX_LEN CONFIG_BT_BUF_EVT_RX_SIZE
#endif

/* In HCI event PHY indices start at 1 compare to 0 indexed in aux_ptr field in
* the Common Extended Payload Format in the PDUs.
*/
Expand Down Expand Up @@ -6186,7 +6180,7 @@ static void le_ext_adv_report(struct pdu_data *pdu_data,

/* HCI fragment */
evt_buf = buf;
data_len_max = ADV_REPORT_EVT_MAX_LEN -
data_len_max = CONFIG_BT_BUF_EVT_RX_SIZE -
sizeof(struct bt_hci_evt_le_meta_event) -
sizeof(struct bt_hci_evt_le_ext_advertising_report) -
sizeof(struct bt_hci_evt_le_ext_advertising_info);
Expand Down Expand Up @@ -6535,7 +6529,7 @@ static void le_per_adv_sync_report(struct pdu_data *pdu_data,
accept = ftr->sync_rx_enabled;
}

data_len_max = ADV_REPORT_EVT_MAX_LEN -
data_len_max = CONFIG_BT_BUF_EVT_RX_SIZE -
sizeof(struct bt_hci_evt_le_meta_event) -
sizeof(struct bt_hci_evt_le_per_advertising_report);
data_len_total = node_rx->hdr.rx_ftr.aux_data_len;
Expand Down Expand Up @@ -7668,13 +7662,6 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
defined(CONFIG_BT_CTLR_PROFILE_ISR)
#if defined(CONFIG_BT_OBSERVER)
case NODE_RX_TYPE_REPORT:

#if defined(CONFIG_BT_CTLR_ADV_EXT)
__fallthrough;
case NODE_RX_TYPE_EXT_1M_REPORT:
case NODE_RX_TYPE_EXT_2M_REPORT:
case NODE_RX_TYPE_EXT_CODED_REPORT:
#endif /* CONFIG_BT_CTLR_ADV_EXT */
#endif /* CONFIG_BT_OBSERVER */

#if defined(CONFIG_BT_CTLR_SCAN_REQ_NOTIFY)
Expand Down Expand Up @@ -7703,18 +7690,20 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
#if defined(CONFIG_BT_CTLR_ADV_EXT)
#if defined(CONFIG_BT_BROADCASTER)
case NODE_RX_TYPE_EXT_ADV_TERMINATE:

#if defined(CONFIG_BT_CTLR_ADV_ISO)
case NODE_RX_TYPE_BIG_COMPLETE:
case NODE_RX_TYPE_BIG_TERMINATE:
#endif /* CONFIG_BT_CTLR_ADV_ISO */
#endif /* CONFIG_BT_BROADCASTER */

#if defined(CONFIG_BT_OBSERVER)
__fallthrough;
case NODE_RX_TYPE_EXT_1M_REPORT:
case NODE_RX_TYPE_EXT_2M_REPORT:
case NODE_RX_TYPE_EXT_CODED_REPORT:
case NODE_RX_TYPE_EXT_SCAN_TERMINATE:

#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC)
__fallthrough;
case NODE_RX_TYPE_SYNC:
case NODE_RX_TYPE_SYNC_REPORT:
case NODE_RX_TYPE_SYNC_LOST:
Expand All @@ -7724,7 +7713,6 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */

#if defined(CONFIG_BT_CTLR_SYNC_ISO)
__fallthrough;
case NODE_RX_TYPE_SYNC_ISO:
case NODE_RX_TYPE_SYNC_ISO_LOST:
#endif /* CONFIG_BT_CTLR_SYNC_ISO */
Expand All @@ -7744,9 +7732,11 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
#if defined(CONFIG_BT_CTLR_CONN_ISO)
case NODE_RX_TYPE_CIS_ESTABLISHED:
#endif /* CONFIG_BT_CTLR_CONN_ISO */

#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
case NODE_RX_TYPE_CONN_IQ_SAMPLE_REPORT:
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RX */

return HCI_CLASS_EVT_REQUIRED;

case NODE_RX_TYPE_TERMINATE:
Expand All @@ -7759,17 +7749,22 @@ uint8_t hci_get_class(struct node_rx_pdu *node_rx)
#if defined(CONFIG_BT_CTLR_CONN_RSSI_EVENT)
case NODE_RX_TYPE_RSSI:
#endif /* CONFIG_BT_CTLR_CONN_RSSI_EVENT */

#if defined(CONFIG_BT_CTLR_LE_PING)
case NODE_RX_TYPE_APTO:
#endif /* CONFIG_BT_CTLR_LE_PING */

#if defined(CONFIG_BT_CTLR_CHAN_SEL_2)
case NODE_RX_TYPE_CHAN_SEL_ALGO:
#endif /* CONFIG_BT_CTLR_CHAN_SEL_2 */

#if defined(CONFIG_BT_CTLR_PHY)
case NODE_RX_TYPE_PHY_UPDATE:
#endif /* CONFIG_BT_CTLR_PHY */

return HCI_CLASS_EVT_CONNECTION;
#endif /* CONFIG_BT_CONN */

#if defined(CONFIG_BT_CTLR_SYNC_ISO) || defined(CONFIG_BT_CTLR_CONN_ISO)
case NODE_RX_TYPE_ISO_PDU:
return HCI_CLASS_ISO_DATA;
Expand Down

0 comments on commit 54af281

Please sign in to comment.