Skip to content

Commit 7b68ec8

Browse files
cvinayakcarlescufi
authored andcommitted
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 <[email protected]>
1 parent 705515c commit 7b68ec8

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

subsys/bluetooth/controller/ll_sw/ull_conn.c

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@
4242
#include <soc.h>
4343
#include "hal/debug.h"
4444

45-
/* Macro to return PDU time */
46-
#if defined(CONFIG_BT_CTLR_PHY_CODED)
47-
#define PKT_US(octets, phy) \
48-
(((phy) & BIT(2)) ? \
49-
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
50-
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
51-
#else /* !CONFIG_BT_CTLR_PHY_CODED */
52-
#define PKT_US(octets, phy) \
53-
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
54-
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
55-
5645
static int init_reset(void);
5746
static void ticker_op_update_cb(u32_t status, void *param);
5847
static inline void disable(u16_t handle);
@@ -184,22 +173,6 @@ struct ll_conn *ll_connected_get(u16_t handle)
184173
return conn;
185174
}
186175

187-
u8_t ull_conn_allowed_check(void *conn)
188-
{
189-
struct ll_conn * const conn_hdr = conn;
190-
if (conn_hdr->llcp_req != conn_hdr->llcp_ack) {
191-
return BT_HCI_ERR_CMD_DISALLOWED;
192-
}
193-
194-
conn_hdr->llcp_req++;
195-
if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1U) {
196-
conn_hdr->llcp_req--;
197-
return BT_HCI_ERR_CMD_DISALLOWED;
198-
}
199-
200-
return 0;
201-
}
202-
203176
void *ll_tx_mem_acquire(void)
204177
{
205178
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,
264237

265238
if (!cmd) {
266239

267-
ret = ull_conn_allowed_check(conn);
240+
ret = ull_conn_llcp_req(conn);
268241
if (ret) {
269242
return ret;
270243
}
@@ -367,7 +340,7 @@ u8_t ll_feature_req_send(u16_t handle)
367340
return BT_HCI_ERR_CMD_DISALLOWED;
368341
}
369342

370-
ret = ull_conn_allowed_check(conn);
343+
ret = ull_conn_llcp_req(conn);
371344
if (ret) {
372345
return ret;
373346
}
@@ -388,7 +361,7 @@ u8_t ll_version_ind_send(u16_t handle)
388361
return BT_HCI_ERR_CMD_DISALLOWED;
389362
}
390363

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

1257+
u8_t ull_conn_llcp_req(void *conn)
1258+
{
1259+
struct ll_conn * const conn_hdr = conn;
1260+
if (conn_hdr->llcp_req != conn_hdr->llcp_ack) {
1261+
return BT_HCI_ERR_CMD_DISALLOWED;
1262+
}
1263+
1264+
conn_hdr->llcp_req++;
1265+
if (((conn_hdr->llcp_req - conn_hdr->llcp_ack) & 0x03) != 1) {
1266+
conn_hdr->llcp_req--;
1267+
return BT_HCI_ERR_CMD_DISALLOWED;
1268+
}
1269+
1270+
return 0;
1271+
}
1272+
12841273
static int init_reset(void)
12851274
{
12861275
/* Initialize conn pool. */

subsys/bluetooth/controller/ll_sw/ull_conn_internal.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
/* Macro to convert time in us to connection interval units */
88
#define RADIO_CONN_EVENTS(x, y) ((u16_t)(((x) + (y) - 1) / (y)))
99

10-
u8_t ull_conn_allowed_check(void *conn);
10+
/* Macro to return PDU time */
11+
#if defined(CONFIG_BT_CTLR_PHY_CODED)
12+
#define PKT_US(octets, phy) \
13+
(((phy) & BIT(2)) ? \
14+
(80 + 256 + 16 + 24 + ((((2 + (octets) + 4) * 8) + 24 + 3) * 8)) : \
15+
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1)))
16+
#else /* !CONFIG_BT_CTLR_PHY_CODED */
17+
#define PKT_US(octets, phy) \
18+
(((octets) + 14) * 8 / BIT(((phy) & 0x03) >> 1))
19+
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
20+
1121
struct ll_conn *ll_conn_acquire(void);
1222
void ll_conn_release(struct ll_conn *conn);
1323
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);
3040
void ull_conn_link_tx_release(void *link);
3141
void ull_conn_tx_ack(struct ll_conn *conn, memq_link_t *link,
3242
struct node_tx *tx);
43+
u8_t ull_conn_llcp_req(void *conn);

subsys/bluetooth/controller/ll_sw/ull_master.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ u8_t ll_chm_update(u8_t *chm)
312312
continue;
313313
}
314314

315-
ret = ull_conn_allowed_check(conn);
315+
ret = ull_conn_llcp_req(conn);
316316
if (ret) {
317317
return ret;
318318
}
@@ -341,7 +341,7 @@ u8_t ll_enc_req_send(u16_t handle, u8_t *rand, u8_t *ediv, u8_t *ltk)
341341
return BT_HCI_ERR_UNKNOWN_CONN_ID;
342342
}
343343

344-
ret = ull_conn_allowed_check(conn);
344+
ret = ull_conn_llcp_req(conn);
345345
if (ret) {
346346
return ret;
347347
}

subsys/bluetooth/controller/ll_sw/ull_slave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ u8_t ll_start_enc_req_send(u16_t handle, u8_t error_code,
439439

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

466-
ret = ull_conn_allowed_check(conn);
466+
ret = ull_conn_llcp_req(conn);
467467
if (ret) {
468468
return ret;
469469
}

0 commit comments

Comments
 (0)