Bluetooth: controller: Implement LE Set Host Feature Command
Added implementation of HCI LE Set Host Feature command. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
ed59ceba62
commit
32d9b68944
7 changed files with 72 additions and 14 deletions
|
@ -20,6 +20,7 @@ zephyr_library_sources_ifdef(
|
|||
|
||||
if(CONFIG_BT_LL_SW_SPLIT)
|
||||
zephyr_library_sources(
|
||||
ll_sw/ll_feat.c
|
||||
ll_sw/ull.c
|
||||
ll_sw/lll_common.c
|
||||
)
|
||||
|
@ -85,12 +86,11 @@ if(CONFIG_BT_LL_SW_SPLIT)
|
|||
)
|
||||
endif()
|
||||
endif()
|
||||
if(CONFIG_BT_CTLR_SET_HOST_FEATURE)
|
||||
if(CONFIG_BT_CTLR_DF)
|
||||
zephyr_library_sources(
|
||||
ll_sw/ll_feat.c
|
||||
ll_sw/ull_df.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_CTLR_CONN_ISO)
|
||||
zephyr_library_sources(
|
||||
ll_sw/ull_conn_iso.c
|
||||
|
@ -110,11 +110,6 @@ if(CONFIG_BT_LL_SW_SPLIT)
|
|||
ll_sw/lll_chan.c
|
||||
)
|
||||
endif()
|
||||
if(CONFIG_BT_CTLR_DF)
|
||||
zephyr_library_sources(
|
||||
ll_sw/ull_df.c
|
||||
)
|
||||
endif()
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_CTLR_FILTER
|
||||
ll_sw/ull_filter.c
|
||||
|
|
|
@ -483,6 +483,7 @@ config BT_CTLR_ADV_ISO
|
|||
bool "LE Broadcast Isochronous Channel advertising" if !BT_LL_SW_SPLIT
|
||||
depends on BT_BROADCASTER && BT_CTLR_ADV_ISO_SUPPORT
|
||||
select BT_CTLR_ADV_PERIODIC
|
||||
select BT_CTLR_SET_HOST_FEATURE
|
||||
help
|
||||
Enable support for Bluetooth 5.2 LE Isochronous Advertising in the
|
||||
Controller.
|
||||
|
@ -494,6 +495,7 @@ config BT_CTLR_SYNC_ISO
|
|||
bool "LE Broadcast Isochronous Channel advertising sync" if !BT_LL_SW_SPLIT
|
||||
depends on BT_OBSERVER && BT_CTLR_SYNC_ISO_SUPPORT
|
||||
select BT_CTLR_SYNC_PERIODIC
|
||||
select BT_CTLR_SET_HOST_FEATURE
|
||||
help
|
||||
Enable support for Bluetooth 5.2 LE Isochronous Advertising sync in
|
||||
the Controller.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
int ll_init(struct k_sem *sem_rx);
|
||||
void ll_reset(void);
|
||||
|
||||
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value);
|
||||
uint64_t ll_feat_get(void);
|
||||
|
||||
uint8_t *ll_addr_get(uint8_t addr_type, uint8_t *p_bdaddr);
|
||||
|
@ -191,7 +192,6 @@ uint8_t ll_read_iso_link_quality(uint16_t handle,
|
|||
uint32_t *crc_error_packets,
|
||||
uint32_t *rx_unreceived_packets,
|
||||
uint32_t *duplicate_packets);
|
||||
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value);
|
||||
uint8_t ll_setup_iso_path(uint16_t handle, uint8_t path_dir, uint8_t path_id,
|
||||
uint8_t coding_format, uint16_t company_id,
|
||||
uint16_t vs_codec_id, uint32_t controller_delay,
|
||||
|
|
|
@ -177,6 +177,9 @@
|
|||
/* Mask to filter away octet 0 for feature exchange */
|
||||
#define LL_FEAT_FILTER_OCTET0 (LL_FEAT_BIT_MASK & ~0xFFULL)
|
||||
|
||||
/* Mask for host controlled features */
|
||||
#define LL_FEAT_HOST_BIT_MASK 0x100000000ULL
|
||||
|
||||
/* Feature bits of this controller */
|
||||
#define LL_FEAT (LL_FEAT_BIT_ENC | \
|
||||
LL_FEAT_BIT_CONN_PARAM_REQ | \
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2020 Demant
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
|
@ -6,6 +7,17 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
|
||||
#include "util/memq.h"
|
||||
|
||||
#include "hal/ccm.h"
|
||||
|
||||
#include "pdu.h"
|
||||
|
||||
#include "lll.h"
|
||||
#include "lll_conn.h"
|
||||
|
||||
#include "ull_conn_internal.h"
|
||||
|
||||
#include "ll_feat.h"
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
|
||||
|
@ -13,15 +25,55 @@
|
|||
#include "common/log.h"
|
||||
#include "hal/debug.h"
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE)
|
||||
static uint64_t host_features;
|
||||
|
||||
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value)
|
||||
{
|
||||
ARG_UNUSED(bit_number);
|
||||
ARG_UNUSED(bit_value);
|
||||
uint64_t feature;
|
||||
|
||||
/* Check if Bit_Number is not controlled by the Host */
|
||||
feature = BIT64(bit_number);
|
||||
if (!(feature & LL_FEAT_HOST_BIT_MASK)) {
|
||||
return BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
/* Check if the Controller has an established ACL */
|
||||
uint16_t conn_free_count = ll_conn_free_count_get();
|
||||
|
||||
/* Check if any connection contexts where allocated */
|
||||
if (conn_free_count != CONFIG_BT_MAX_CONN) {
|
||||
uint16_t handle;
|
||||
|
||||
/* Check if there are established connections */
|
||||
for (handle = 0U; handle < CONFIG_BT_MAX_CONN; handle++) {
|
||||
if (ll_connected_get(handle)) {
|
||||
return BT_HCI_ERR_CMD_DISALLOWED;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
|
||||
/* Set or Clear the Host feature bit */
|
||||
if (bit_value) {
|
||||
host_features |= feature;
|
||||
} else {
|
||||
host_features &= ~feature;
|
||||
}
|
||||
|
||||
return BT_HCI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
uint64_t ll_feat_get(void)
|
||||
{
|
||||
return LL_FEAT | (host_features & LL_FEAT_HOST_BIT_MASK);
|
||||
}
|
||||
|
||||
#else /* !CONFIG_BT_CTLR_SET_HOST_FEATURE */
|
||||
uint64_t ll_feat_get(void)
|
||||
{
|
||||
return LL_FEAT;
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BT_CTLR_SET_HOST_FEATURE */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2018-2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
@ -239,6 +239,11 @@ struct ll_conn *ll_connected_get(uint16_t handle)
|
|||
return conn;
|
||||
}
|
||||
|
||||
uint16_t ll_conn_free_count_get(void)
|
||||
{
|
||||
return mem_free_count_get(conn_free);
|
||||
}
|
||||
|
||||
void *ll_tx_mem_acquire(void)
|
||||
{
|
||||
return mem_acquire(&mem_conn_tx.free);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2019 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2017-2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@ void ll_conn_release(struct ll_conn *conn);
|
|||
uint16_t ll_conn_handle_get(struct ll_conn *conn);
|
||||
struct ll_conn *ll_conn_get(uint16_t handle);
|
||||
struct ll_conn *ll_connected_get(uint16_t handle);
|
||||
uint16_t ll_conn_free_count_get(void);
|
||||
void ll_tx_ack_put(uint16_t handle, struct node_tx *node_tx);
|
||||
int ull_conn_init(void);
|
||||
int ull_conn_reset(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue