Commit 651afd7c authored by Vinayak Kariappa Chettimada's avatar Vinayak Kariappa Chettimada Committed by Anas Nashif
Browse files

Bluetooth: controller: Add control procedure lock



Add control procedure lock flag to detection procedure
transaction violations.

Signed-off-by: default avatarVinayak Kariappa Chettimada <vich@nordicsemi.no>
parent ef7cbbfb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -877,6 +877,7 @@ uint8_t ll_adv_enable(uint8_t enable)
		conn->procedure_expire = 0;

		conn->common.fex_valid = 0;
		conn->common.txn_lock = 0;
		conn->slave.latency_cancel = 0;

		conn->llcp_req = conn->llcp_ack = conn->llcp_type = 0;
+36 −0
Original line number Diff line number Diff line
@@ -1979,6 +1979,42 @@ static inline void ctrl_tx_check_and_resume(struct ll_conn *conn)
}
#endif /* CONFIG_BT_CTLR_LE_ENC */

/* Check transaction violation and get free ctrl tx PDU */
static struct node_tx *ctrl_tx_rsp_mem_acquire(struct ll_conn *conn,
					       struct node_rx_pdu *rx,
					       int *err)
{
	struct node_tx *tx;

	/* Ignore duplicate requests without previous being acknowledged. */
	if (conn->common.txn_lock) {
		/* Mark for buffer for release */
		rx->hdr.type = NODE_RX_TYPE_RELEASE;

		/* Drop request */
		*err = 0U;

		return NULL;
	}

	/* Acquire ctrl tx mem */
	tx = mem_acquire(&mem_conn_tx_ctrl.free);
	if (!tx) {
		*err = -ENOBUFS;

		return NULL;
	}

	/* Lock further responses to duplicate requests before previous
	 * response is acknowledged.
	 */
	conn->common.txn_lock = 1U;

	/* NOTE: err value not required when returning valid ctrl tx PDU */

	return tx;
}

static inline void ctrl_tx_last_enqueue(struct ll_conn *conn,
					struct node_tx *tx)
{
+3 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ struct ll_conn {
	union {
		struct {
			uint8_t fex_valid:1;
			uint8_t txn_lock:1;
#if defined(CONFIG_BT_CTLR_CONN_META)
			uint8_t is_must_expire:1;
#endif /* CONFIG_BT_CTLR_CONN_META */
@@ -67,6 +68,7 @@ struct ll_conn {
#if defined(CONFIG_BT_PERIPHERAL)
		struct {
			uint8_t  fex_valid:1;
			uint8_t  txn_lock:1;
#if defined(CONFIG_BT_CTLR_CONN_META)
			uint8_t  is_must_expire:1;
#endif /* CONFIG_BT_CTLR_CONN_META */
@@ -87,6 +89,7 @@ struct ll_conn {
#if defined(CONFIG_BT_CENTRAL)
		struct {
			uint8_t fex_valid:1;
			uint8_t txn_lock:1;
#if defined(CONFIG_BT_CTLR_CONN_META)
			uint8_t is_must_expire:1;
#endif /* CONFIG_BT_CTLR_CONN_META */
+1 −0
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
#endif /* CONFIG_BT_CTLR_LE_PING */

	conn->common.fex_valid = 0U;
	conn->common.txn_lock = 0U;
	conn->master.terminate_ack = 0U;

	conn->llcp_req = conn->llcp_ack = conn->llcp_type = 0U;