From 5ce4df2a675ee3c7410ddf3a20df575c4c998c30 Mon Sep 17 00:00:00 2001 From: Morten Priess Date: Mon, 30 Sep 2019 10:10:45 +0200 Subject: [PATCH] bluetooth: controller: Connection meta property support in LLL Added support for vendor specific meta data in LLL conn object. This enables vendors to add state data to connection, for supporting specialized BLE slave features. Signed-off-by: Morten Priess --- subsys/bluetooth/controller/Kconfig | 7 +++++++ subsys/bluetooth/controller/ll_sw/lll_conn.h | 7 +++++++ .../controller/ll_sw/nordic/lll/lll_conn_meta.h | 11 +++++++++++ subsys/bluetooth/controller/ll_sw/ull_adv.c | 3 +++ subsys/bluetooth/controller/ll_sw/ull_conn.c | 4 ++++ subsys/bluetooth/controller/ll_sw/ull_master.c | 3 +++ subsys/bluetooth/controller/ll_sw/ull_slave.c | 4 ++++ 7 files changed, 39 insertions(+) create mode 100644 subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_meta.h diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index 38085f83eae..13527c1121b 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -535,6 +535,13 @@ config BT_CTLR_LOW_LAT_ULL Low latency ULL implementation that uses tailchaining instead of while loop to demux rx messages from LLL. +config BT_CTLR_CONN_META + prompt "Enable connection meta data extension" + bool + help + Enables vendor specific per-connection meta data as part of the + LLL connection object. + endif # BT_LL_SW_SPLIT config BT_CTLR_RADIO_ENABLE_FAST diff --git a/subsys/bluetooth/controller/ll_sw/lll_conn.h b/subsys/bluetooth/controller/ll_sw/lll_conn.h index e11b68deb27..89bf05464d9 100644 --- a/subsys/bluetooth/controller/ll_sw/lll_conn.h +++ b/subsys/bluetooth/controller/ll_sw/lll_conn.h @@ -3,6 +3,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#if defined(CONFIG_BT_CTLR_CONN_META) +#include "lll_conn_meta.h" +#endif /* CONFIG_BT_CTLR_CONN_META */ #define LLL_CONN_RSSI_SAMPLE_COUNT 10 #define LLL_CONN_RSSI_THRESHOLD 4 @@ -136,6 +139,10 @@ struct lll_conn { u8_t rssi_reported; u8_t rssi_sample_count; #endif /* CONFIG_BT_CTLR_CONN_RSSI */ + +#if defined(CONFIG_BT_CTLR_CONN_META) + struct lll_conn_meta conn_meta; +#endif /* CONFIG_BT_CTLR_CONN_META */ }; int lll_conn_init(void); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_meta.h b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_meta.h new file mode 100644 index 00000000000..805d8ee6a70 --- /dev/null +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn_meta.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2019 Demant + * + * SPDX-License-Identifier: Apache-2.0 + */ +#if defined(CONFIG_BT_CTLR_CONN_META) +/* + * struct lll_conn_meta { }; + */ +#error Please define struct lll_conn_meta when enabling BT_CTLR_CONN_META +#endif /* CONFIG_BT_CTLR_CONN_META */ diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv.c b/subsys/bluetooth/controller/ll_sw/ull_adv.c index f0a6f80fe0c..e0976c99db7 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv.c @@ -610,6 +610,9 @@ u8_t ll_adv_enable(u8_t enable) conn_lll->slave.window_widening_event_us = 0; conn_lll->slave.window_size_prepare_us = 0; /* FIXME: END: Move to ULL? */ +#if defined(CONFIG_BT_CTLR_CONN_META) + memset(&conn_lll->conn_meta, 0, sizeof(conn_lll->conn_meta)); +#endif /* CONFIG_BT_CTLR_CONN_META */ conn->connect_expire = 6; conn->supervision_expire = 0; diff --git a/subsys/bluetooth/controller/ll_sw/ull_conn.c b/subsys/bluetooth/controller/ll_sw/ull_conn.c index 6991f3f4ddb..b0674ad330e 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_conn.c +++ b/subsys/bluetooth/controller/ll_sw/ull_conn.c @@ -2044,7 +2044,11 @@ static inline int event_conn_upd_prep(struct ll_conn *conn, u16_t lazy, ticks_at_expire, ticks_win_offset, HAL_TICKER_US_TO_TICKS(periodic_us), HAL_TICKER_REMAINDER(periodic_us), +#if defined(CONFIG_BT_CTLR_CONN_META) + TICKER_LAZY_MUST_EXPIRE, +#else TICKER_NULL_LAZY, +#endif /* CONFIG_BT_CTLR_CONN_META */ (ticks_slot_offset + conn->evt.ticks_slot), #if defined(CONFIG_BT_PERIPHERAL) && defined(CONFIG_BT_CENTRAL) lll->role ? ull_slave_ticker_cb : diff --git a/subsys/bluetooth/controller/ll_sw/ull_master.c b/subsys/bluetooth/controller/ll_sw/ull_master.c index 40887f474f8..019ac37e6de 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_master.c +++ b/subsys/bluetooth/controller/ll_sw/ull_master.c @@ -154,6 +154,9 @@ u8_t ll_create_connection(u16_t scan_interval, u16_t scan_window, conn_lll->data_chan_use = 0; conn_lll->role = 0; /* FIXME: END: Move to ULL? */ +#if defined(CONFIG_BT_CTLR_CONN_META) + memset(&conn_lll->conn_meta, 0, sizeof(conn_lll->conn_meta)); +#endif /* CONFIG_BT_CTLR_CONN_META */ conn->connect_expire = 6U; conn->supervision_expire = 0U; diff --git a/subsys/bluetooth/controller/ll_sw/ull_slave.c b/subsys/bluetooth/controller/ll_sw/ull_slave.c index 541056a182e..e2845f1bcb9 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_slave.c +++ b/subsys/bluetooth/controller/ll_sw/ull_slave.c @@ -271,7 +271,11 @@ void ull_slave_setup(memq_link_t *link, struct node_rx_hdr *rx, HAL_TICKER_US_TO_TICKS(conn_offset_us), HAL_TICKER_US_TO_TICKS(conn_interval_us), HAL_TICKER_REMAINDER(conn_interval_us), +#if defined(CONFIG_BT_CTLR_CONN_META) + TICKER_LAZY_MUST_EXPIRE, +#else TICKER_NULL_LAZY, +#endif /* CONFIG_BT_CTLR_CONN_META */ (conn->evt.ticks_slot + ticks_slot_overhead), ull_slave_ticker_cb, conn, ticker_op_cb,