Commit 34f8ed12 authored by Andries Kruithof's avatar Andries Kruithof Committed by Thomas Ebert Hansen

[TOPIC-BLE-LLCP] Bluetooth: controller: allow shell sample to compile

Minor updates to HCI interfacing to allow the shell sample to compile
Signed-off-by: default avatarAndries Kruithof <Andries.Kruithof@nordicsemi.no>
parent 4fced65b
......@@ -71,7 +71,8 @@ if(CONFIG_BT_LL_SW_SPLIT)
ll_sw/ull_llcp_pdu.c
ll_sw/ull_llcp_phy.c
ll_sw/ull_llcp_remote.c
ll_sw/ull_connection.c
ll_sw/ull_connections.c
ll_sw/ull_llcp_hci.c
)
endif()
if(CONFIG_BT_PERIPHERAL)
......
......@@ -6,41 +6,8 @@
/*
* copied from ull_conn_internal.h
* some macros will need to be moved to other, more logical places
*/
/*
* Macros to return correct Data Channel PDU time
* Note: formula is valid for 1M, 2M and Coded S8
* see BT spec Version 5.1 Vol 6. Part B, chapters 2.1 and 2.2
* for packet formats and thus lengths
*
* Payload overhead size is the Data Channel PDU Header + the MIC
*/
#define PAYLOAD_OVERHEAD_SIZE (2 + 4)
#define PHY_1M BIT(0)
#define PHY_2M BIT(1)
#define PHY_CODED BIT(2)
#if defined(CONFIG_BT_CTLR_PHY_CODED)
#define CODED_PHY_PREAMBLE_TIME_US (80)
#define CODED_PHY_ACCESS_ADDRESS_TIME_US (256)
#define CODED_PHY_CI_TIME_US (16)
#define CODED_PHY_TERM1_TIME_US (24)
#define CODED_PHY_CRC_SIZE (24)
#define CODED_PHY_TERM2_SIZE (3)
#define FEC_BLOCK1_TIME_US (CODED_PHY_ACCESS_ADDRESS_TIME_US + \
CODED_PHY_CI_TIME_US + \
CODED_PHY_TERM1_TIME_US)
#define FEC_BLOCK2_TIME_US(octets) ((((PAYLOAD_OVERHEAD_SIZE + \
(octets)) * 8) + \
CODED_PHY_CRC_SIZE + \
CODED_PHY_TERM2_SIZE) * 8)
#else /* !CONFIG_BT_CTLR_PHY_CODED */
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
#define ULL_HANDLE_NOT_CONNECTED 0xFFFF
struct ull_cp_conn *ll_conn_acquire(void);
......
......@@ -85,6 +85,32 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
struct pdu_data *pdu_rx, struct ull_cp_conn *conn);
/*
* EGON: following 2 functions need to be removed when implementing tx/rx path
*/
sys_slist_t ut_rx_q;
void ll_rx_enqueue(struct node_rx_pdu *rx)
{
sys_slist_append(&ut_rx_q, (sys_snode_t *) rx);
}
void ull_conn_lll_ack_enqueue(uint16_t handle, struct node_tx *tx)
{
struct lll_tx *lll_tx;
uint8_t idx;
idx = MFIFO_ENQUEUE_GET(conn_ack, (void **)&lll_tx);
LL_ASSERT(lll_tx);
lll_tx->handle = handle;
lll_tx->node = tx;
MFIFO_ENQUEUE(conn_ack, idx);
}
uint16_t ull_conn_init(void)
{
int err;
......@@ -218,6 +244,77 @@ void ull_conn_default_phy_rx_set(uint8_t phy_rx)
}
#endif /* CONFIG_BT_CTLR_PHY */
uint16_t ull_conn_lll_max_tx_octets_get(struct lll_conn *lll)
{
uint16_t max_tx_octets;
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
#if defined(CONFIG_BT_CTLR_PHY)
switch (lll->phy_tx_time) {
default:
case BIT(0):
/* 1M PHY, 1us = 1 bit, hence divide by 8.
* Deduct 10 bytes for preamble (1), access address (4),
* header (2), and CRC (3).
*/
max_tx_octets = (lll->max_tx_time >> 3) - 10;
break;
case BIT(1):
/* 2M PHY, 1us = 2 bits, hence divide by 4.
* Deduct 11 bytes for preamble (2), access address (4),
* header (2), and CRC (3).
*/
max_tx_octets = (lll->max_tx_time >> 2) - 11;
break;
#if defined(CONFIG_BT_CTLR_PHY_CODED)
case BIT(2):
if (lll->phy_flags & 0x01) {
/* S8 Coded PHY, 8us = 1 bit, hence divide by
* 64.
* Subtract time for preamble (80), AA (256),
* CI (16), TERM1 (24), CRC (192) and
* TERM2 (24), total 592 us.
* Subtract 2 bytes for header.
*/
max_tx_octets = ((lll->max_tx_time - 592) >>
6) - 2;
} else {
/* S2 Coded PHY, 2us = 1 bit, hence divide by
* 16.
* Subtract time for preamble (80), AA (256),
* CI (16), TERM1 (24), CRC (48) and
* TERM2 (6), total 430 us.
* Subtract 2 bytes for header.
*/
max_tx_octets = ((lll->max_tx_time - 430) >>
4) - 2;
}
break;
#endif /* CONFIG_BT_CTLR_PHY_CODED */
}
#if defined(CONFIG_BT_CTLR_LE_ENC)
if (lll->enc_tx) {
/* deduct the MIC */
max_tx_octets -= 4U;
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
if (max_tx_octets > lll->max_tx_octets) {
max_tx_octets = lll->max_tx_octets;
}
#else /* !CONFIG_BT_CTLR_PHY */
max_tx_octets = lll->max_tx_octets;
#endif /* !CONFIG_BT_CTLR_PHY */
#else /* !CONFIG_BT_CTLR_DATA_LENGTH */
max_tx_octets = PDU_DC_PAYLOAD_SIZE_MIN;
#endif /* !CONFIG_BT_CTLR_DATA_LENGTH */
return max_tx_octets;
}
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
uint16_t ull_conn_default_tx_octets_get(void)
{
......
......@@ -624,15 +624,10 @@ 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->master.terminate_ack = 0U;
conn->llcp_req = conn->llcp_ack = conn->llcp_type = 0U;
conn->llcp_rx = NULL;
conn->llcp_cu.req = conn->llcp_cu.ack = 0;
conn->llcp_feature.req = conn->llcp_feature.ack = 0;
conn->llcp_feature.features_conn = LL_FEAT;
conn->llcp_feature.features_peer = 0;
conn->llcp_version.req = conn->llcp_version.ack = 0;
conn->llcp_version.tx = conn->llcp_version.rx = 0U;
conn->llcp_terminate.reason_peer = 0U;
/* NOTE: use allocated link for generating dedicated
......@@ -642,19 +637,15 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
#if defined(CONFIG_BT_CTLR_LE_ENC)
conn_lll->enc_rx = conn_lll->enc_tx = 0U;
conn->llcp_enc.req = conn->llcp_enc.ack = 0U;
conn->llcp_enc.pause_tx = conn->llcp_enc.pause_rx = 0U;
conn->llcp_enc.refresh = 0U;
#endif /* CONFIG_BT_CTLR_LE_ENC */
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
conn->llcp_conn_param.req = 0U;
conn->llcp_conn_param.ack = 0U;
conn->llcp_conn_param.disabled = 0U;
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
conn->llcp_length.req = conn->llcp_length.ack = 0U;
conn->llcp_length.disabled = 0U;
conn->llcp_length.cache.tx_octets = 0U;
conn->default_tx_octets = ull_conn_default_tx_octets_get();
......@@ -665,7 +656,6 @@ uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
#if defined(CONFIG_BT_CTLR_PHY)
conn->llcp_phy.req = conn->llcp_phy.ack = 0U;
conn->llcp_phy.disabled = 0U;
conn->llcp_phy.pause_tx = 0U;
conn->phy_pref_tx = ull_conn_default_phy_tx_get();
......
......@@ -55,6 +55,7 @@ static void ticker_op_stop_scan_cb(uint32_t status, void *params);
static void ticker_op_cb(uint32_t status, void *params);
static inline void conn_release(struct ll_scan_set *scan);
#if defined(CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY)
#if defined(CONFIG_BT_CTLR_ADV_EXT)
uint8_t ll_create_connection(uint16_t scan_interval, uint16_t scan_window,
uint8_t filter_policy, uint8_t peer_addr_type,
......@@ -336,6 +337,7 @@ conn_is_valid:
return ull_scan_enable(scan);
#endif /* !CONFIG_BT_CTLR_ADV_EXT */
}
#endif /* CONFIG_BT_LL_SW_SPLIT_LEGACY */
#if defined(CONFIG_BT_CTLR_ADV_EXT)
uint8_t ll_connect_enable(uint8_t is_coded_included)
......@@ -373,6 +375,7 @@ uint8_t ll_connect_enable(uint8_t is_coded_included)
}
#endif /* CONFIG_BT_CTLR_ADV_EXT */
#if defined(CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY)
uint8_t ll_connect_disable(void **rx)
{
struct lll_conn *conn_lll;
......@@ -415,11 +418,13 @@ uint8_t ll_connect_disable(void **rx)
return status;
}
#endif /* CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY */
/* FIXME: Refactor out this interface so that its usable by extended
* advertising channel classification, and also master role connections can
* perform channel map update control procedure.
*/
#if defined(CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY)
uint8_t ll_chm_update(uint8_t const *const chm)
{
uint16_t handle;
......@@ -452,7 +457,9 @@ uint8_t ll_chm_update(uint8_t const *const chm)
return 0;
}
#endif /* CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY */
#if defined(CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY)
#if defined(CONFIG_BT_CTLR_LE_ENC)
uint8_t ll_enc_req_send(uint16_t handle, uint8_t const *const rand,
uint8_t const *const ediv, uint8_t const *const ltk)
......@@ -527,6 +534,7 @@ uint8_t ll_enc_req_send(uint16_t handle, uint8_t const *const rand,
return BT_HCI_ERR_CMD_DISALLOWED;
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
#endif /* CONFIG_BT_LL_SW_SPLIT_LLCP_LEGACY */
void ull_master_setup(memq_link_t *link, struct node_rx_hdr *rx,
struct node_rx_ftr *ftr, struct lll_conn *lll)
......
......@@ -415,6 +415,7 @@ void ull_slave_ticker_cb(uint32_t ticks_at_expire, uint32_t remainder,
DEBUG_RADIO_PREPARE_S(1);
}
#if defined(BT_LL_SW_SPLIT_LLCP_LEGACY)
#if defined(CONFIG_BT_CTLR_LE_ENC)
uint8_t ll_start_enc_req_send(uint16_t handle, uint8_t error_code,
uint8_t const *const ltk)
......@@ -461,6 +462,7 @@ uint8_t ll_start_enc_req_send(uint16_t handle, uint8_t error_code,
return 0;
}
#endif /* CONFIG_BT_CTLR_LE_ENC */
#endif /* BT_LL_SW_SPLIT_LLCP_LEGACY */
static void ticker_op_stop_adv_cb(uint32_t status, void *param)
{
......
......@@ -30,10 +30,3 @@
#include "ull_conn_types.h"
#include "ull_tx_queue.h"
#include "ull_llcp.h"
extern sys_slist_t ut_rx_q;
void ll_rx_enqueue(struct node_rx_pdu *rx)
{
sys_slist_append(&ut_rx_q, (sys_snode_t *) rx);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment