Bluetooth: controller: Add peripheral/central conditional compilations
Add conditional compilation on peripheral and central specific control procedure implementation. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
abcee4dc2b
commit
d2415fcfd0
2 changed files with 57 additions and 7 deletions
|
@ -93,7 +93,9 @@ static inline void event_ch_map_prep(struct ll_conn *conn,
|
|||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
static bool is_enc_req_pause_tx(struct ll_conn *conn);
|
||||
static inline void event_enc_prep(struct ll_conn *conn);
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
static int enc_rsp_send(struct ll_conn *conn);
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
static int start_enc_rsp_send(struct ll_conn *conn,
|
||||
struct pdu_data *pdu_ctrl_tx);
|
||||
static inline bool ctrl_is_unexpected(struct ll_conn *conn, uint8_t opcode);
|
||||
|
@ -2619,7 +2621,7 @@ static inline void event_enc_prep(struct ll_conn *conn)
|
|||
struct node_tx *tx;
|
||||
|
||||
if (conn->llcp.encryption.state) {
|
||||
#if !defined(CONFIG_BT_CTLR_FAST_ENC)
|
||||
#if defined(CONFIG_BT_PERIPHERAL) && !defined(CONFIG_BT_CTLR_FAST_ENC)
|
||||
if (lll->role &&
|
||||
(conn->llcp.encryption.state == LLCP_ENC_STATE_INIT)) {
|
||||
struct node_rx_pdu *rx;
|
||||
|
@ -2662,7 +2664,7 @@ static inline void event_enc_prep(struct ll_conn *conn)
|
|||
/* Wait for LTK reply */
|
||||
conn->llcp.encryption.state = LLCP_ENC_STATE_LTK_WAIT;
|
||||
}
|
||||
#endif /* !CONFIG_BT_CTLR_FAST_ENC */
|
||||
#endif /* CONFIG_BT_PERIPHERAL && !CONFIG_BT_CTLR_FAST_ENC */
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -3809,6 +3811,7 @@ static inline void event_phy_upd_ind_prep(struct ll_conn *conn,
|
|||
}
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
static uint8_t conn_upd_recv(struct ll_conn *conn, memq_link_t *link,
|
||||
struct node_rx_pdu **rx, struct pdu_data *pdu)
|
||||
{
|
||||
|
@ -3904,6 +3907,7 @@ chan_map_upd_recv_exit:
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
static void terminate_ind_recv(struct ll_conn *conn, struct node_rx_pdu *rx,
|
||||
struct pdu_data *pdu)
|
||||
|
@ -3916,6 +3920,7 @@ static void terminate_ind_recv(struct ll_conn *conn, struct node_rx_pdu *rx,
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
static void enc_req_reused_send(struct ll_conn *conn, struct node_tx **tx)
|
||||
{
|
||||
struct pdu_data *pdu_ctrl_tx;
|
||||
|
@ -3949,7 +3954,9 @@ static void enc_req_reused_send(struct ll_conn *conn, struct node_tx **tx)
|
|||
/* dont release ctrl PDU memory */
|
||||
*tx = NULL;
|
||||
}
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
static int enc_rsp_send(struct ll_conn *conn)
|
||||
{
|
||||
struct pdu_data *pdu_ctrl_tx;
|
||||
|
@ -3991,6 +3998,7 @@ static int enc_rsp_send(struct ll_conn *conn)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
static int start_enc_rsp_send(struct ll_conn *conn,
|
||||
struct pdu_data *pdu_ctrl_tx)
|
||||
|
@ -5086,10 +5094,13 @@ static inline void ctrl_tx_pre_ack(struct ll_conn *conn,
|
|||
break;
|
||||
}
|
||||
__fallthrough;
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_REQ:
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_RSP:
|
||||
case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ:
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_RSP:
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
/* pause data packet tx */
|
||||
conn->llcp_enc.pause_tx = 1U;
|
||||
break;
|
||||
|
@ -5097,7 +5108,9 @@ static inline void ctrl_tx_pre_ack(struct ll_conn *conn,
|
|||
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_REQ:
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_RSP:
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
/* pause data packet tx */
|
||||
conn->llcp_phy.pause_tx = 1U;
|
||||
break;
|
||||
|
@ -5125,6 +5138,7 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
break;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_REQ:
|
||||
/* things from master stored for session key calculation */
|
||||
memcpy(&conn->llcp.encryption.skd[0],
|
||||
|
@ -5144,7 +5158,9 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
/* Reset enc req queued state */
|
||||
conn->llcp_enc.ack = conn->llcp_enc.req;
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_RSP:
|
||||
/* pause data packet tx */
|
||||
conn->llcp_enc.pause_tx = 1U;
|
||||
|
@ -5156,7 +5172,9 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
* alongwith this tx ack at this point in time.
|
||||
*/
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ:
|
||||
/* pause data packet tx */
|
||||
conn->llcp_enc.pause_tx = 1U;
|
||||
|
@ -5173,12 +5191,16 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
/* Reset enc req queued state */
|
||||
conn->llcp_enc.ack = conn->llcp_enc.req;
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_RSP:
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
if (!conn->lll.role) {
|
||||
/* reused tx-ed PDU and send enc req */
|
||||
enc_req_reused_send(conn, tx);
|
||||
} else {
|
||||
} else
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
{
|
||||
/* pause data packet tx */
|
||||
conn->llcp_enc.pause_tx = 1U;
|
||||
}
|
||||
|
@ -5264,6 +5286,7 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
conn->llcp_phy.state = LLCP_PHY_STATE_RSP_WAIT;
|
||||
__fallthrough;
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_RSP:
|
||||
if (conn->lll.role) {
|
||||
/* select the probable PHY with longest Tx time, which
|
||||
|
@ -5283,12 +5306,15 @@ static inline void ctrl_tx_ack(struct ll_conn *conn, struct node_tx **tx,
|
|||
/* resume data packet tx */
|
||||
conn->llcp_phy.pause_tx = 0U;
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND:
|
||||
conn->lll.phy_tx_time = conn->llcp.phy_upd_ind.tx;
|
||||
/* resume data packet tx */
|
||||
conn->llcp_phy.pause_tx = 0U;
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
|
||||
default:
|
||||
|
@ -5379,6 +5405,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
#endif /* CONFIG_BT_CTLR_LE_ENC */
|
||||
|
||||
switch (opcode) {
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_CONN_UPDATE_IND:
|
||||
{
|
||||
uint8_t err;
|
||||
|
@ -5417,6 +5444,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
case PDU_DATA_LLCTRL_TYPE_TERMINATE_IND:
|
||||
if (!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_TERMINATE_IND,
|
||||
|
@ -5428,6 +5456,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
break;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_REQ:
|
||||
if (!conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_ENC_REQ, pdu_rx->len)) {
|
||||
|
@ -5479,7 +5508,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
conn->procedure_expire = conn->procedure_reload;
|
||||
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_ENC_RSP:
|
||||
if (conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_ENC_RSP, pdu_rx->len)) {
|
||||
|
@ -5515,6 +5546,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
(*rx)->hdr.type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
case PDU_DATA_LLCTRL_TYPE_START_ENC_RSP:
|
||||
if (!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_START_ENC_RSP,
|
||||
|
@ -5567,6 +5599,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
break;
|
||||
#endif /* CONFIG_BT_CTLR_LE_ENC */
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_FEATURE_REQ:
|
||||
if (!conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_FEATURE_REQ,
|
||||
|
@ -5576,8 +5609,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
|
||||
nack = feature_rsp_send(conn, *rx, pdu_rx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_SLAVE_FEAT_REQ)
|
||||
#if defined(CONFIG_BT_CENTRAL) && defined(CONFIG_BT_CTLR_SLAVE_FEAT_REQ)
|
||||
case PDU_DATA_LLCTRL_TYPE_SLAVE_FEATURE_REQ:
|
||||
if (conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_SLAVE_FEATURE_REQ,
|
||||
|
@ -5587,8 +5621,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
|
||||
nack = feature_rsp_send(conn, *rx, pdu_rx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CTLR_SLAVE_FEAT_REQ */
|
||||
#endif /* CONFIG_BT_CENTRAL && CONFIG_BT_CTLR_SLAVE_FEAT_REQ */
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL) || defined(CONFIG_BT_CTLR_SLAVE_FEAT_REQ)
|
||||
case PDU_DATA_LLCTRL_TYPE_FEATURE_RSP:
|
||||
if ((!IS_ENABLED(CONFIG_BT_CTLR_SLAVE_FEAT_REQ) &&
|
||||
conn->lll.role) ||
|
||||
|
@ -5599,8 +5634,10 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
|
||||
feature_rsp_recv(conn, pdu_rx);
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL || CONFIG_BT_CTLR_SLAVE_FEAT_REQ */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_LE_ENC)
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ:
|
||||
if (!conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_REQ,
|
||||
|
@ -5610,6 +5647,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
|
||||
nack = pause_enc_rsp_send(conn, *rx, 1);
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
case PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_RSP:
|
||||
if (!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_PAUSE_ENC_RSP,
|
||||
|
@ -5893,6 +5931,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
}
|
||||
break;
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP:
|
||||
if (conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_CONN_PARAM_RSP,
|
||||
|
@ -5965,6 +6004,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
(*rx)->hdr.type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
|
||||
|
||||
case PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND:
|
||||
|
@ -6246,6 +6286,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
}
|
||||
break;
|
||||
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_RSP:
|
||||
if (conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_PHY_RSP, pdu_rx->len)) {
|
||||
|
@ -6279,7 +6320,9 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
(*rx)->hdr.type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
#if defined(CONFIG_BT_PERIPHERAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_PHY_UPD_IND:
|
||||
{
|
||||
uint8_t err;
|
||||
|
@ -6296,9 +6339,11 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_MIN_USED_CHAN)
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
case PDU_DATA_LLCTRL_TYPE_MIN_USED_CHAN_IND:
|
||||
if (conn->lll.role ||
|
||||
!pdu_len_cmp(PDU_DATA_LLCTRL_TYPE_MIN_USED_CHAN_IND,
|
||||
|
@ -6336,6 +6381,7 @@ static inline int ctrl_rx(memq_link_t *link, struct node_rx_pdu **rx,
|
|||
(*rx)->hdr.type = NODE_RX_TYPE_RELEASE;
|
||||
|
||||
break;
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
#endif /* CONFIG_BT_CTLR_MIN_USED_CHAN */
|
||||
|
||||
default:
|
||||
|
|
|
@ -72,8 +72,12 @@ struct ll_conn {
|
|||
#endif /* CONFIG_BT_CTLR_CONN_META */
|
||||
uint8_t latency_cancel:1;
|
||||
uint8_t sca:3;
|
||||
#if defined(CONFIG_BT_CTLR_CONN_RANDOM_FORCE)
|
||||
uint32_t force;
|
||||
#endif /* CONFIG_BT_CTLR_CONN_RANDOM_FORCE */
|
||||
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
|
||||
uint32_t ticks_to_offset;
|
||||
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
|
||||
} slave;
|
||||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue