Skip to content
Permalink
Browse files

Bluetooth: controller: Move PKT_US to ULL internal header

Minor refactoring to move PKT_US into ULL internal header,
and rename ull_conn_allowed_check to ull_conn_llcp_req.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information...
cvinayak authored and carlescufi committed Jan 26, 2019
1 parent 705515c commit 7b68ec888cd23bfe92013e5f65a1d71b79c8c198
@@ -42,17 +42,6 @@
#include <soc.h>
#include "hal/debug.h"

/* Macro to return PDU time */
#if defined(CONFIG_BT_CTLR_PHY_CODED)
#define PKT_US(octets, phy) \
(((phy) & BIT(2)) ? \
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
#else /* !CONFIG_BT_CTLR_PHY_CODED */
#define PKT_US(octets, phy) \
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
#endif /* !CONFIG_BT_CTLR_PHY_CODED */

static int init_reset(void);
static void ticker_op_update_cb(u32_t status, void *param);
static inline void disable(u16_t handle);
@@ -184,22 +173,6 @@ struct ll_conn *ll_connected_get(u16_t handle)
return conn;
}

u8_t ull_conn_allowed_check(void *conn)
{
struct ll_conn * const conn_hdr = conn;
if (conn_hdr->llcp_req != conn_hdr->llcp_ack) {
return BT_HCI_ERR_CMD_DISALLOWED;
}

conn_hdr->llcp_req++;
if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1U) {
conn_hdr->llcp_req--;
return BT_HCI_ERR_CMD_DISALLOWED;
}

return 0;
}

void *ll_tx_mem_acquire(void)
{
return mem_acquire(&mem_conn_tx.free);
@@ -264,7 +237,7 @@ u8_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, u16_t interval_min,

if (!cmd) {

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -367,7 +340,7 @@ u8_t ll_feature_req_send(u16_t handle)
return BT_HCI_ERR_CMD_DISALLOWED;
}

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -388,7 +361,7 @@ u8_t ll_version_ind_send(u16_t handle)
return BT_HCI_ERR_CMD_DISALLOWED;
}

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -1281,6 +1254,22 @@ void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link,
ll_tx_ack_put(conn->lll.handle, tx);
}

u8_t ull_conn_llcp_req(void *conn)
{
struct ll_conn * const conn_hdr = conn;
if (conn_hdr->llcp_req != conn_hdr->llcp_ack) {
return BT_HCI_ERR_CMD_DISALLOWED;
}

conn_hdr->llcp_req++;
if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1) {
conn_hdr->llcp_req--;
return BT_HCI_ERR_CMD_DISALLOWED;
}

return 0;
}

static int init_reset(void)
{
/* Initialize conn pool. */
@@ -7,7 +7,17 @@
/* Macro to convert time in us to connection interval units */
#define RADIO_CONN_EVENTS(x, y) ((u16_t)(((x) + (y) - 1) / (y)))

u8_t ull_conn_allowed_check(void *conn);
/* Macro to return PDU time */
#if defined(CONFIG_BT_CTLR_PHY_CODED)
#define PKT_US(octets, phy) \
(((phy) & BIT(2)) ? \
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
#else /* !CONFIG_BT_CTLR_PHY_CODED */
#define PKT_US(octets, phy) \
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
#endif /* !CONFIG_BT_CTLR_PHY_CODED */

struct ll_conn *ll_conn_acquire(void);
void ll_conn_release(struct ll_conn *conn);
u16_t ll_conn_handle_get(struct ll_conn *conn);
@@ -30,3 +40,4 @@ void ull_conn_tx_lll_enqueue(struct ll_conn *conn, u8_t count);
void ull_conn_link_tx_release(void *link);
void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link,
struct node_tx *tx);
u8_t ull_conn_llcp_req(void *conn);
@@ -312,7 +312,7 @@ u8_t ll_chm_update(u8_t *chm)
continue;
}

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -341,7 +341,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk)
return BT_HCI_ERR_UNKNOWN_CONN_ID;
}

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -439,7 +439,7 @@ u8_t ll_start_enc_req_send(u16_t handle, u8_t error_code,

if (error_code) {
if (conn->refresh == 0U) {
ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}
@@ -463,7 +463,7 @@ u8_t ll_start_enc_req_send(u16_t handle, u8_t error_code,
memcpy(&conn->llcp.encryption.ltk[0], ltk,
sizeof(conn->llcp.encryption.ltk));

ret = ull_conn_allowed_check(conn);
ret = ull_conn_llcp_req(conn);
if (ret) {
return ret;
}

0 comments on commit 7b68ec8

Please sign in to comment.
You can’t perform that action at this time.