Bluetooth: controller: Fix failing fast encryption setup feature

In commit c41d3edda when implementing the alternative
encryption setup implementation, the original fast
encryption setup implementation was broken. When host is
slow in responding to LTK request, the controller asserted
when fast encryption implementation is selected. This is
now fixed.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2017-05-23 22:22:54 +02:00 committed by Johan Hedberg
commit c3e674071d

View file

@ -5603,8 +5603,15 @@ static inline void event_enc_prep(struct connection *conn)
/* send enc start resp */
start_enc_rsp_send(conn, pdu_ctrl_tx);
}
/* slave send reject ind or start enc req at control priority */
#if defined(CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC)
else {
#else /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
else if (!conn->pause_tx || conn->refresh) {
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
/* ll ctrl packet */
pdu_ctrl_tx->ll_id = PDU_DATA_LLID_CTRL;
@ -5629,7 +5636,7 @@ static inline void event_enc_prep(struct connection *conn)
* controller.
*/
enc_rsp_send(conn);
#endif /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
/* calc the Session Key */
ecb_encrypt(&conn->llcp.encryption.ltk[0],
@ -5668,9 +5675,9 @@ static inline void event_enc_prep(struct connection *conn)
pdu_ctrl_tx->payload.llctrl.opcode =
PDU_DATA_LLCTRL_TYPE_START_ENC_REQ;
}
} else {
#if !defined(CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC)
} else {
/* enable transmit encryption */
_radio.conn_curr->enc_tx = 1;
@ -5679,13 +5686,7 @@ static inline void event_enc_prep(struct connection *conn)
/* resume data packet rx and tx */
_radio.conn_curr->pause_rx = 0;
_radio.conn_curr->pause_tx = 0;
#else /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
/* Fast Enc implementation shall have enqueued the
* start enc rsp in the radio ISR itself, we should
* not get here.
*/
LL_ASSERT(0);
#endif /* CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_FAST_ENC */
}