Commit 91a78866 authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Anas Nashif
Browse files

Bluetooth: Controller: Fix advertising after connections from same peer



Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.

Relates to commit 010c5c2f ("Bluetooth: controller:
Ignore connections from same peer").

Signed-off-by: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent 0afddb23
Loading
Loading
Loading
Loading
+38 −31
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@
#include "common/log.h"
#include "hal/debug.h"

static void invalid_release(struct lll_conn *lll, memq_link_t *link,
			    struct node_rx_hdr *rx);
static void ticker_op_stop_adv_cb(uint32_t status, void *param);
static void ticker_op_cb(uint32_t status, void *param);
static void ticker_update_latency_cancel_op_cb(uint32_t ticker_status,
@@ -112,10 +114,8 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
	/* Do not connect twice to the same peer */
	if (ull_conn_peer_connected(own_addr_type, own_addr,
				    peer_addr_type, peer_id_addr)) {
		rx->type = NODE_RX_TYPE_RELEASE;
		invalid_release(lll, link, rx);

		ll_rx_put(link, rx);
		ll_rx_sched();
		return;
	}

@@ -136,34 +136,7 @@ void ull_slave_setup(struct node_rx_hdr *rx, struct node_rx_ftr *ftr,
	lll->interval = sys_le16_to_cpu(pdu_adv->connect_ind.interval);
	if ((lll->data_chan_count < 2) || (lll->data_chan_hop < 5) ||
	    (lll->data_chan_hop > 16) || !lll->interval) {
		lll->slave.initiated = 0U;

		/* Mark for buffer for release */
		rx->type = NODE_RX_TYPE_RELEASE;

		/* Release CSA#2 related node rx too */
		if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
			struct node_rx_pdu *rx_csa;

			/* pick the rx node instance stored within the
			 * connection rx node.
			 */
			rx_csa = (void *)ftr->extra;

			/* Enqueue the connection event to be release */
			ll_rx_put(link, rx);

			/* Use the rx node for CSA event */
			rx = (void *)rx_csa;
			link = rx->link;

			/* Mark for buffer for release */
			rx->type = NODE_RX_TYPE_RELEASE;
		}

		/* Enqueue connection or CSA event to be release */
		ll_rx_put(link, rx);
		ll_rx_sched();
		invalid_release(lll, link, rx);

		return;
	}
@@ -578,6 +551,40 @@ uint8_t ll_start_enc_req_send(uint16_t handle, uint8_t error_code,
}
#endif /* CONFIG_BT_CTLR_LE_ENC */

static void invalid_release(struct lll_conn *lll, memq_link_t *link,
			    struct node_rx_hdr *rx)
{
	/* Let the advertiser continue with connectable advertising */
	lll->slave.initiated = 0U;

	/* Mark for buffer for release */
	rx->type = NODE_RX_TYPE_RELEASE;

	/* Release CSA#2 related node rx too */
	if (IS_ENABLED(CONFIG_BT_CTLR_CHAN_SEL_2)) {
		struct node_rx_pdu *rx_csa;

		/* pick the rx node instance stored within the
		 * connection rx node.
		 */
		rx_csa = rx->rx_ftr.extra;

		/* Enqueue the connection event to be release */
		ll_rx_put(link, rx);

		/* Use the rx node for CSA event */
		rx = (void *)rx_csa;
		link = rx->link;

		/* Mark for buffer for release */
		rx->type = NODE_RX_TYPE_RELEASE;
	}

	/* Enqueue connection or CSA event to be release */
	ll_rx_put(link, rx);
	ll_rx_sched();
}

static void ticker_op_stop_adv_cb(uint32_t status, void *param)
{
	LL_ASSERT(status != TICKER_STATUS_FAILURE ||