Bluetooth: controller: Create HCI stubs for CIG/CIS and ISO

Put infrastructure for the following HCI commands/events in place:
* LE Read ISO Link Quality command
* LE Read ISO TX Sync command
* LE Set Host Feature Command

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
This commit is contained in:
Asger Munk Nielsen 2020-11-23 15:28:22 +01:00 committed by Carles Cufí
commit fbee6cc933
6 changed files with 165 additions and 0 deletions

View file

@ -84,6 +84,12 @@ if(CONFIG_BT_LL_SW_SPLIT)
)
endif()
endif()
if(CONFIG_BT_CTLR_SET_HOST_FEATURE)
zephyr_library_sources(
ll_sw/ll_feat.c
)
endif()
if(CONFIG_BT_CTLR_ADV_ISO OR
CONFIG_BT_CTLR_SYNC_ISO OR
CONFIG_BT_CTLR_PERIPHERAL_ISO OR

View file

@ -500,6 +500,11 @@ config BT_CTLR_ADV_DATA_LEN_MAX
endif # BT_CTLR_ADV_EXT
config BT_CTLR_SET_HOST_FEATURE
bool "LE Set Host Feature Command [EXPERIMENTAL]"
help
Enables optional LE Set Host Feature Command
config BT_CTLR_CENTRAL_ISO
bool "LE Connected Isochronous Stream Central" if !BT_LL_SW_SPLIT
depends on BT_CTLR_CENTRAL_ISO_SUPPORT && BT_CENTRAL
@ -509,6 +514,7 @@ config BT_CTLR_CENTRAL_ISO
config BT_CTLR_CENTRAL_ISO
bool "LE Connected Isochronous Stream Central [EXPERIMENTAL]" if BT_LL_SW_SPLIT
select BT_CTLR_SET_HOST_FEATURE
config BT_CTLR_PERIPHERAL_ISO
bool "LE Connected Isochronous Stream Peripheral" if !BT_LL_SW_SPLIT
@ -519,6 +525,7 @@ config BT_CTLR_PERIPHERAL_ISO
config BT_CTLR_PERIPHERAL_ISO
bool "LE Connected Isochronous Stream Peripheral [EXPERIMENTAL]" if BT_LL_SW_SPLIT
select BT_CTLR_SET_HOST_FEATURE
config BT_CTLR_DTM
bool

View file

@ -1777,6 +1777,68 @@ static void le_remove_cig(struct net_buf *buf, struct net_buf **evt)
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || \
defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
static void le_read_iso_tx_sync(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_cp_le_read_iso_tx_sync *cmd = (void *)buf->data;
struct bt_hci_rp_le_read_iso_tx_sync *rp;
uint8_t status;
uint16_t handle, handle_le16;
uint16_t seq;
uint32_t timestamp;
uint32_t offset;
handle_le16 = cmd->handle;
handle = sys_le16_to_cpu(handle_le16);
status = ll_read_iso_tx_sync(handle, &seq, &timestamp, &offset);
rp = hci_cmd_complete(evt, sizeof(*rp));
rp->status = status;
rp->handle = handle_le16;
rp->seq = sys_cpu_to_le16(seq);
rp->timestamp = sys_cpu_to_le32(timestamp);
sys_put_le24(offset, rp->offset);
}
static void le_read_iso_link_quality(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_cp_le_read_iso_link_quality *cmd = (void *)buf->data;
struct bt_hci_rp_le_read_iso_link_quality *rp;
uint8_t status;
uint16_t handle, handle_le16;
uint32_t tx_unacked_packets;
uint32_t tx_flushed_packets;
uint32_t tx_last_subevent_packets;
uint32_t retransmitted_packets;
uint32_t crc_error_packets;
uint32_t rx_unreceived_packets;
uint32_t duplicate_packets;
handle_le16 = cmd->handle;
handle = sys_le16_to_cpu(handle_le16);
status = ll_read_iso_link_quality(handle, &tx_unacked_packets,
&tx_flushed_packets,
&tx_last_subevent_packets,
&retransmitted_packets,
&crc_error_packets,
&rx_unreceived_packets,
&duplicate_packets);
rp = hci_cmd_complete(evt, sizeof(*rp));
rp->status = status;
rp->handle = handle_le16;
rp->tx_unacked_packets = sys_cpu_to_le32(tx_unacked_packets);
rp->tx_flushed_packets = sys_cpu_to_le32(tx_flushed_packets);
rp->tx_last_subevent_packets =
sys_cpu_to_le32(tx_last_subevent_packets);
rp->retransmitted_packets = sys_cpu_to_le32(retransmitted_packets);
rp->crc_error_packets = sys_cpu_to_le32(crc_error_packets);
rp->rx_unreceived_packets = sys_cpu_to_le32(rx_unreceived_packets);
rp->duplicate_packets = sys_cpu_to_le32(duplicate_packets);
}
static void le_setup_iso_path(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_cp_le_setup_iso_path *cmd = (void *)buf->data;
@ -1899,6 +1961,20 @@ static void le_iso_read_test_counters(struct net_buf *buf, struct net_buf **evt)
}
#endif /* CONFIG_BT_CTLR_CENTRAL_ISO || CONFIG_BT_CTLR_PERIPHERAL_ISO */
#if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE)
static void le_set_host_feature(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_cp_le_set_host_feature *cmd = (void *)buf->data;
struct bt_hci_rp_le_set_host_feature *rp;
uint8_t status;
status = ll_set_host_feature(cmd->bit_number, cmd->bit_value);
rp = hci_cmd_complete(evt, sizeof(*rp));
rp->status = status;
}
#endif /* CONFIG_BT_CTLR_SET_HOST_FEATURE */
#if defined(CONFIG_BT_PERIPHERAL)
#if defined(CONFIG_BT_CTLR_LE_ENC)
static void le_ltk_req_reply(struct net_buf *buf, struct net_buf **evt)
@ -3160,6 +3236,9 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO) || \
defined(CONFIG_BT_CTLR_PERIPHERAL_ISO)
case BT_OCF(BT_HCI_OP_LE_READ_ISO_TX_SYNC):
le_read_iso_tx_sync(cmd, evt);
break;
case BT_OCF(BT_HCI_OP_LE_SETUP_ISO_PATH):
le_setup_iso_path(cmd, evt);
@ -3184,8 +3263,18 @@ static int controller_cmd_handle(uint16_t ocf, struct net_buf *cmd,
case BT_OCF(BT_HCI_OP_LE_ISO_READ_TEST_COUNTERS):
le_iso_read_test_counters(cmd, evt);
break;
case BT_OCF(BT_HCI_OP_LE_READ_ISO_LINK_QUALITY):
le_read_iso_link_quality(cmd, evt);
break;
#endif /* CONFIG_BT_CTLR_CENTRAL_ISO || CONFIG_BT_CTLR_PERIPHERAL_ISO */
#if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE)
case BT_OCF(BT_HCI_OP_LE_SET_HOST_FEATURE):
le_set_host_feature(cmd, evt);
break;
#endif /* CONFIG_BT_CTLR_SET_HOST_FEATURE */
case BT_OCF(BT_HCI_OP_LE_READ_CHAN_MAP):
le_read_chan_map(cmd, evt);
break;

View file

@ -157,6 +157,17 @@ uint8_t ll_configure_data_path(uint8_t data_path_dir,
uint8_t data_path_id,
uint8_t vs_config_len,
uint8_t *vs_config);
uint8_t ll_read_iso_tx_sync(uint16_t handle, uint16_t *seq,
uint32_t *timestamp, uint32_t *offset);
uint8_t ll_read_iso_link_quality(uint16_t handle,
uint32_t *tx_unacked_packets,
uint32_t *tx_flushed_packets,
uint32_t *tx_last_subevent_packets,
uint32_t *retransmitted_packets,
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,

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2020 Demant
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_DRIVER)
#define LOG_MODULE_NAME bt_ctlr_ll_feat
#include "common/log.h"
#include "hal/debug.h"
uint8_t ll_set_host_feature(uint8_t bit_number, uint8_t bit_value)
{
ARG_UNUSED(bit_number);
ARG_UNUSED(bit_value);
return BT_HCI_ERR_CMD_DISALLOWED;
}

View file

@ -25,6 +25,17 @@ __weak uint8_t ll_configure_data_path(uint8_t data_path_dir,
return BT_HCI_ERR_CMD_DISALLOWED;
}
uint8_t ll_read_iso_tx_sync(uint16_t handle, uint16_t *seq,
uint32_t *timestamp, uint32_t *offset)
{
ARG_UNUSED(handle);
ARG_UNUSED(seq);
ARG_UNUSED(timestamp);
ARG_UNUSED(offset);
return BT_HCI_ERR_CMD_DISALLOWED;
}
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,
@ -89,3 +100,24 @@ uint8_t ll_iso_read_test_counters(uint16_t handle, uint32_t *received_cnt,
return BT_HCI_ERR_CMD_DISALLOWED;
}
uint8_t ll_read_iso_link_quality(uint16_t handle,
uint32_t *tx_unacked_packets,
uint32_t *tx_flushed_packets,
uint32_t *tx_last_subevent_packets,
uint32_t *retransmitted_packets,
uint32_t *crc_error_packets,
uint32_t *rx_unreceived_packets,
uint32_t *duplicate_packets)
{
ARG_UNUSED(handle);
ARG_UNUSED(tx_unacked_packets);
ARG_UNUSED(tx_flushed_packets);
ARG_UNUSED(tx_last_subevent_packets);
ARG_UNUSED(retransmitted_packets);
ARG_UNUSED(crc_error_packets);
ARG_UNUSED(rx_unreceived_packets);
ARG_UNUSED(duplicate_packets);
return BT_HCI_ERR_CMD_DISALLOWED;
}