Commit b9172861 authored by Aleksander Wasaznik's avatar Aleksander Wasaznik Committed by David Leach
Browse files

Bluetooth: host: remove `CONFIG_BT_RECV_BLOCKING`



This config selects a variant of the HCI driver interface that spills
out host internals unto the drivers and even the Zephyr controller. It
will now be removed in favor of driver interfaces that hide the
internals of the host.

The new default is `CONFIG_BT_RECV_WORKQ_BT`.

Any references to the removed kconfig are refactored out.

Any out-of-tree driver using the removed interface can be easily adapted
by copying the following implementations into the driver as private
functions:

 - `hci_driver.h:BT_HCI_EVT_FLAG_RECV_PRIO`
 - `hci_driver.h:BT_HCI_EVT_FLAG_RECV`
 - `hci_driver.h:bt_hci_evt_get_flags`
 - `hci_raw.c:bt_recv_prio`

In combination these symbols function as a interface adapter. These
symbols will be removed in this PR in subsequent commits.

Signed-off-by: default avatarAleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
parent 03d234d5
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -278,7 +278,6 @@ static size_t h4_discard(const struct device *uart, size_t len)
static inline void read_payload(void)
{
	struct net_buf *buf;
	uint8_t evt_flags;
	int read;

	if (!rx.buf) {
@@ -331,27 +330,16 @@ static inline void read_payload(void)
	rx.buf = NULL;

	if (rx.type == H4_EVT) {
		evt_flags = bt_hci_evt_get_flags(rx.evt.evt);
		bt_buf_set_type(buf, BT_BUF_EVT);
	} else {
		evt_flags = BT_HCI_EVT_FLAG_RECV;
		bt_buf_set_type(buf, BT_BUF_ACL_IN);
	}

	reset_rx();

	if (IS_ENABLED(CONFIG_BT_RECV_BLOCKING) &&
	    (evt_flags & BT_HCI_EVT_FLAG_RECV_PRIO)) {
		LOG_DBG("Calling bt_recv_prio(%p)", buf);
		bt_recv_prio(buf);
	}

	if ((evt_flags & BT_HCI_EVT_FLAG_RECV) ||
	    !IS_ENABLED(CONFIG_BT_RECV_BLOCKING)) {
	LOG_DBG("Putting buf %p to rx fifo", buf);
	net_buf_put(&rx.fifo, buf);
}
}

static inline void read_header(void)
{
+1 −8
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
{
	struct net_buf *buf;
	uint8_t packet_type = data[0];
	uint8_t flags;
	uint8_t event_code;

	LOG_HEXDUMP_DBG(data, len, "host packet data:");
@@ -67,7 +66,6 @@ uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
	switch (packet_type) {
	case h4_event:
		event_code = data[0];
		flags = bt_hci_evt_get_flags(event_code);
		buf = bt_buf_get_evt(event_code, false, K_FOREVER);
		break;
	case h4_acl:
@@ -79,12 +77,7 @@ uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
	}

	net_buf_add_mem(buf, data, len);
	if (IS_ENABLED(CONFIG_BT_RECV_BLOCKING) &&
	    (packet_type == h4_event) && (flags & BT_HCI_EVT_FLAG_RECV_PRIO)) {
		bt_recv_prio(buf);
	} else {
	bt_recv(buf);
	}

	sl_btctrl_hci_transmit_complete(0);

+0 −15
Original line number Diff line number Diff line
@@ -49,10 +49,6 @@ enum {
 * Helper for the HCI driver to get HCI event flags that describes rules that.
 * must be followed.
 *
 * When @kconfig{CONFIG_BT_RECV_BLOCKING} is enabled the flags
 * BT_HCI_EVT_FLAG_RECV and BT_HCI_EVT_FLAG_RECV_PRIO indicates if the event
 * should be given to bt_recv or bt_recv_prio.
 *
 * @param evt HCI event code.
 *
 * @return HCI event flags for the specified event.
@@ -85,10 +81,6 @@ static inline uint8_t bt_hci_evt_get_flags(uint8_t evt)
 * host with data from the controller. The buffer needs to have its type
 * set with the help of bt_buf_set_type() before calling this API.
 *
 * When @kconfig{CONFIG_BT_RECV_BLOCKING} is defined then this API should not be used
 * for so-called high priority HCI events, which should instead be delivered to
 * the host stack through bt_recv_prio().
 *
 * @note This function must only be called from a cooperative thread.
 *
 * @param buf Network buffer containing data from the controller.
@@ -176,10 +168,6 @@ struct bt_hci_driver {
	 * return until the transport is ready for operation, meaning it
	 * is safe to start calling the send() handler.
	 *
	 * If the driver uses its own RX thread, i.e.
	 * @kconfig{CONFIG_BT_RECV_BLOCKING} is set, then this
	 * function is expected to start that thread.
	 *
	 * @return 0 on success or negative error number on failure.
	 */
	int (*open)(void);
@@ -190,9 +178,6 @@ struct bt_hci_driver {
	 * Closes the HCI transport. This function must not return until the
	 * transport is closed.
	 *
	 * If the driver uses its own RX thread, i.e.
	 * @kconfig{CONFIG_BT_RECV_BLOCKING} is set, then this
	 * function is expected to abort that thread.
	 * @return 0 on success or negative error number on failure.
	 */
	int (*close)(void);
+0 −2
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ config BT_BUF_ACL_RX_SIZE
config BT_BUF_ACL_RX_COUNT
	int "Number of incoming ACL data buffers"
	default NET_BUF_RX_COUNT if NET_L2_BT
	default 3 if BT_RECV_BLOCKING
	default 6
	range 1 64
	help
@@ -126,7 +125,6 @@ config BT_BUF_EVT_RX_SIZE

config BT_BUF_EVT_RX_COUNT
	int "Number of HCI Event buffers"
	default 3 if BT_RECV_BLOCKING
	default 20 if (BT_MESH && !(BT_BUF_EVT_DISCARDABLE_COUNT > 0))
	default 10
	range 2 255
+3 −5
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ struct k_thread prio_recv_thread_data;
static K_KERNEL_STACK_DEFINE(prio_recv_thread_stack,
			     CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE);
struct k_thread recv_thread_data;
static K_KERNEL_STACK_DEFINE(recv_thread_stack, CONFIG_BT_RX_STACK_SIZE);
static K_KERNEL_STACK_DEFINE(recv_thread_stack, CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE);

#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
static struct k_poll_signal hbuf_signal;
@@ -81,11 +81,10 @@ static sys_slist_t hbuf_pend;
static int32_t hbuf_count;
#endif

#if !defined(CONFIG_BT_RECV_BLOCKING)
/* Copied here from `hci_raw.c`, which would be used in
 * conjunction with this driver when serializing HCI over wire.
 * This serves as a converter from the more complicated
 * `CONFIG_BT_RECV_BLOCKING` API to the normal single-receiver
 * This serves as a converter from the historical (removed from
 * tree) 'recv blocking' API to the normal single-receiver
 * `bt_recv` API.
 */
int bt_recv_prio(struct net_buf *buf)
@@ -103,7 +102,6 @@ int bt_recv_prio(struct net_buf *buf)

	return bt_recv(buf);
}
#endif /* CONFIG_BT_RECV_BLOCKING */

#if defined(CONFIG_BT_CTLR_ISO)

Loading