@@ -2821,7 +2821,8 @@ isr_rx_conn_pkt_ctrl(struct radio_pdu_node_rx *node_rx,
2821
2821
rsp = & pdu_data_rx -> llctrl .feature_rsp ;
2822
2822
2823
2823
/* AND the feature set to get Feature USED */
2824
- _radio .conn_curr -> llcp_features &= feat_get (& rsp -> features [0 ]);
2824
+ _radio .conn_curr -> llcp_feature .features &=
2825
+ feat_get (& rsp -> features [0 ]);
2825
2826
2826
2827
/* features exchanged */
2827
2828
_radio .conn_curr -> common .fex_valid = 1U ;
@@ -2830,6 +2831,8 @@ isr_rx_conn_pkt_ctrl(struct radio_pdu_node_rx *node_rx,
2830
2831
* rx_enqueue = 1U ;
2831
2832
2832
2833
/* Procedure complete */
2834
+ _radio .conn_curr -> llcp_feature .ack =
2835
+ _radio .conn_curr -> llcp_feature .req ;
2833
2836
_radio .conn_curr -> procedure_expire = 0U ;
2834
2837
}
2835
2838
break ;
@@ -7579,7 +7582,7 @@ static inline void event_enc_reject_prep(struct connection *conn,
7579
7582
pdu -> ll_id = PDU_DATA_LLID_CTRL ;
7580
7583
7581
7584
if (conn -> common .fex_valid &&
7582
- (conn -> llcp_features & BIT (BT_LE_FEAT_BIT_EXT_REJ_IND ))) {
7585
+ (conn -> llcp_feature . features & BIT (BT_LE_FEAT_BIT_EXT_REJ_IND ))) {
7583
7586
struct pdu_data_llctrl_reject_ext_ind * p ;
7584
7587
7585
7588
pdu -> llctrl .opcode = PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND ;
@@ -7744,12 +7747,17 @@ static inline void event_fex_prep(struct connection *conn)
7744
7747
{
7745
7748
struct radio_pdu_node_tx * node_tx ;
7746
7749
7750
+ /* If waiting for response, do nothing */
7751
+ if (!((conn -> llcp_feature .ack - conn -> llcp_feature .req ) & 0x01 )) {
7752
+ return ;
7753
+ }
7754
+
7747
7755
if (conn -> common .fex_valid ) {
7748
7756
struct radio_pdu_node_rx * node_rx ;
7749
7757
struct pdu_data * pdu_ctrl_rx ;
7750
7758
7751
7759
/* procedure request acked */
7752
- conn -> llcp_ack = conn -> llcp_req ;
7760
+ conn -> llcp_feature . ack = conn -> llcp_feature . req ;
7753
7761
7754
7762
/* Prepare the rx packet structure */
7755
7763
node_rx = packet_rx_reserve_get (2 );
@@ -7768,11 +7776,11 @@ static inline void event_fex_prep(struct connection *conn)
7768
7776
(void )memset (& pdu_ctrl_rx -> llctrl .feature_rsp .features [0 ], 0x00 ,
7769
7777
sizeof (pdu_ctrl_rx -> llctrl .feature_rsp .features ));
7770
7778
pdu_ctrl_rx -> llctrl .feature_req .features [0 ] =
7771
- conn -> llcp_features & 0xFF ;
7779
+ conn -> llcp_feature . features & 0xFF ;
7772
7780
pdu_ctrl_rx -> llctrl .feature_req .features [1 ] =
7773
- (conn -> llcp_features >> 8 ) & 0xFF ;
7781
+ (conn -> llcp_feature . features >> 8 ) & 0xFF ;
7774
7782
pdu_ctrl_rx -> llctrl .feature_req .features [2 ] =
7775
- (conn -> llcp_features >> 16 ) & 0xFF ;
7783
+ (conn -> llcp_feature . features >> 16 ) & 0xFF ;
7776
7784
7777
7785
/* enqueue feature rsp structure into rx queue */
7778
7786
packet_rx_enqueue ();
@@ -7784,11 +7792,11 @@ static inline void event_fex_prep(struct connection *conn)
7784
7792
if (node_tx ) {
7785
7793
struct pdu_data * pdu_ctrl_tx = (void * )node_tx -> pdu_data ;
7786
7794
7787
- /* procedure request acked */
7788
- conn -> llcp_ack = conn -> llcp_req ;
7795
+ /* procedure request acked, move to waiting state */
7796
+ conn -> llcp_feature . ack -- ;
7789
7797
7790
7798
/* use initial feature bitmap */
7791
- conn -> llcp_features = LL_FEAT ;
7799
+ conn -> llcp_feature . features = LL_FEAT ;
7792
7800
7793
7801
/* place the feature exchange req packet as next in tx queue */
7794
7802
pdu_ctrl_tx -> ll_id = PDU_DATA_LLID_CTRL ;
@@ -7803,11 +7811,11 @@ static inline void event_fex_prep(struct connection *conn)
7803
7811
0x00 ,
7804
7812
sizeof (pdu_ctrl_tx -> llctrl .feature_req .features ));
7805
7813
pdu_ctrl_tx -> llctrl .feature_req .features [0 ] =
7806
- conn -> llcp_features & 0xFF ;
7814
+ conn -> llcp_feature . features & 0xFF ;
7807
7815
pdu_ctrl_tx -> llctrl .feature_req .features [1 ] =
7808
- (conn -> llcp_features >> 8 ) & 0xFF ;
7816
+ (conn -> llcp_feature . features >> 8 ) & 0xFF ;
7809
7817
pdu_ctrl_tx -> llctrl .feature_req .features [2 ] =
7810
- (conn -> llcp_features >> 16 ) & 0xFF ;
7818
+ (conn -> llcp_feature . features >> 16 ) & 0xFF ;
7811
7819
7812
7820
ctrl_tx_enqueue (conn , node_tx );
7813
7821
@@ -7821,6 +7829,10 @@ static inline void event_fex_prep(struct connection *conn)
7821
7829
7822
7830
static inline void event_vex_prep (struct connection * conn )
7823
7831
{
7832
+ /* If waiting for response, do nothing */
7833
+ if (!((conn -> llcp_version .ack - conn -> llcp_version .req ) & 0x01 )) {
7834
+ return ;
7835
+ }
7824
7836
7825
7837
if (conn -> llcp_version .tx == 0 ) {
7826
7838
struct radio_pdu_node_tx * node_tx ;
@@ -7830,8 +7842,8 @@ static inline void event_vex_prep(struct connection *conn)
7830
7842
struct pdu_data * pdu_ctrl_tx = (void * )
7831
7843
node_tx -> pdu_data ;
7832
7844
7833
- /* procedure request acked */
7834
- conn -> llcp_ack = conn -> llcp_req ;
7845
+ /* procedure request acked, move to waiting state */
7846
+ conn -> llcp_version . ack -- ;
7835
7847
7836
7848
/* set version ind tx-ed flag */
7837
7849
conn -> llcp_version .tx = 1U ;
@@ -7862,7 +7874,7 @@ static inline void event_vex_prep(struct connection *conn)
7862
7874
struct pdu_data * pdu_ctrl_rx ;
7863
7875
7864
7876
/* procedure request acked */
7865
- conn -> llcp_ack = conn -> llcp_req ;
7877
+ conn -> llcp_version . ack = conn -> llcp_version . req ;
7866
7878
7867
7879
/* Prepare the rx packet structure */
7868
7880
node_rx = packet_rx_reserve_get (2 );
@@ -8769,12 +8781,26 @@ static void event_connection_prepare(u32_t ticks_at_expire,
8769
8781
/* calc current event counter value */
8770
8782
event_counter = conn -> event_counter + conn -> latency_prepare ;
8771
8783
8772
- #if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ ) || defined(CONFIG_BT_CTLR_PHY )
8773
8784
/* Check if no other procedure with instant is requested and not in
8774
8785
* Encryption setup.
8775
8786
*/
8776
8787
if ((conn -> llcp_ack == conn -> llcp_req ) && !conn -> pause_rx ) {
8777
- if (0 ) {
8788
+ if (conn -> llcp_feature .ack != conn -> llcp_feature .req ) {
8789
+ /* Stop previous event, to avoid Radio DMA corrupting
8790
+ * the rx queue.
8791
+ */
8792
+ event_stop (0 , 0 , 0 , (void * )STATE_ABORT );
8793
+
8794
+ event_fex_prep (conn );
8795
+
8796
+ } else if (conn -> llcp_version .ack != conn -> llcp_version .req ) {
8797
+ /* Stop previous event, to avoid Radio DMA corrupting
8798
+ * the rx queue.
8799
+ */
8800
+ event_stop (0 , 0 , 0 , (void * )STATE_ABORT );
8801
+
8802
+ event_vex_prep (conn );
8803
+
8778
8804
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ )
8779
8805
/* check if CPR procedure is requested */
8780
8806
} else if (conn -> llcp_conn_param .ack !=
@@ -8789,20 +8815,8 @@ static void event_connection_prepare(u32_t ticks_at_expire,
8789
8815
ticks_at_expire );
8790
8816
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
8791
8817
8792
- #if defined(CONFIG_BT_CTLR_PHY )
8793
- /* check if PHY Req procedure is requested */
8794
- } else if (conn -> llcp_phy .ack != conn -> llcp_phy .req ) {
8795
- /* Stop previous event, to avoid Radio DMA corrupting
8796
- * the rx queue.
8797
- */
8798
- event_stop (0 , 0 , 0 , (void * )STATE_ABORT );
8799
-
8800
- /* handle PHY Upd state machine */
8801
- event_phy_req_prep (conn );
8802
- #endif /* CONFIG_BT_CTLR_PHY */
8803
-
8804
8818
#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
8805
- /* check if procedure is requested */
8819
+ /* check if DLE procedure is requested */
8806
8820
} else if (conn -> llcp_length .ack != conn -> llcp_length .req ) {
8807
8821
/* Stop previous event, to avoid Radio DMA corrupting
8808
8822
* the rx queue
@@ -8811,18 +8825,28 @@ static void event_connection_prepare(u32_t ticks_at_expire,
8811
8825
8812
8826
/* handle DLU state machine */
8813
8827
if (event_len_prep (conn )) {
8814
- /* NOTE: rx pool could not be resized,
8815
- * lets skip this event and try in the next
8816
- * event.
8828
+ /* NOTE: rx pool could not be resized, lets
8829
+ * skip this event and try in the next event.
8817
8830
*/
8818
8831
_radio .ticker_id_prepare = 0U ;
8819
8832
8820
8833
goto event_connection_prepare_skip ;
8821
8834
}
8822
8835
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
8836
+
8837
+ #if defined(CONFIG_BT_CTLR_PHY )
8838
+ /* check if PHY Req procedure is requested */
8839
+ } else if (conn -> llcp_phy .ack != conn -> llcp_phy .req ) {
8840
+ /* Stop previous event, to avoid Radio DMA corrupting
8841
+ * the rx queue.
8842
+ */
8843
+ event_stop (0 , 0 , 0 , (void * )STATE_ABORT );
8844
+
8845
+ /* handle PHY Upd state machine */
8846
+ event_phy_req_prep (conn );
8847
+ #endif /* CONFIG_BT_CTLR_PHY */
8823
8848
}
8824
8849
}
8825
- #endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ || CONFIG_BT_CTLR_PHY */
8826
8850
8827
8851
/* check if procedure is requested */
8828
8852
if (conn -> llcp_ack != conn -> llcp_req ) {
@@ -8848,14 +8872,6 @@ static void event_connection_prepare(u32_t ticks_at_expire,
8848
8872
break ;
8849
8873
#endif /* CONFIG_BT_CTLR_LE_ENC */
8850
8874
8851
- case LLCP_FEATURE_EXCHANGE :
8852
- event_fex_prep (conn );
8853
- break ;
8854
-
8855
- case LLCP_VERSION_EXCHANGE :
8856
- event_vex_prep (conn );
8857
- break ;
8858
-
8859
8875
#if defined(CONFIG_BT_CTLR_LE_PING )
8860
8876
case LLCP_PING :
8861
8877
event_ping_prep (conn );
@@ -8917,7 +8933,6 @@ static void event_connection_prepare(u32_t ticks_at_expire,
8917
8933
}
8918
8934
}
8919
8935
8920
-
8921
8936
/* Setup XTAL startup and radio active events */
8922
8937
event_common_prepare (ticks_at_expire , remainder ,
8923
8938
& conn -> hdr .ticks_xtal_to_start ,
@@ -9718,6 +9733,8 @@ static bool is_enc_req_pause_tx(struct connection *conn)
9718
9733
if ((pdu_data_tx -> ll_id == PDU_DATA_LLID_CTRL ) &&
9719
9734
(pdu_data_tx -> llctrl .opcode == PDU_DATA_LLCTRL_TYPE_ENC_REQ )) {
9720
9735
if ((conn -> llcp_req != conn -> llcp_ack ) ||
9736
+ (conn -> llcp_feature .ack != conn -> llcp_feature .req ) ||
9737
+ (conn -> llcp_version .ack != conn -> llcp_version .req ) ||
9721
9738
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ )
9722
9739
(conn -> llcp_conn_param .ack != conn -> llcp_conn_param .req ) ||
9723
9740
#endif /* CONFIG_BT_CTLR_CONN_PARAM_REQ */
@@ -10186,7 +10203,7 @@ static u32_t conn_update_req(struct connection *conn)
10186
10203
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ )
10187
10204
} else if (!conn -> llcp_conn_param .disabled &&
10188
10205
(!conn -> common .fex_valid ||
10189
- (conn -> llcp_features &
10206
+ (conn -> llcp_feature . features &
10190
10207
BIT (BT_LE_FEAT_BIT_CONN_PARAM_REQ )))) {
10191
10208
/** Perform slave intiated conn param req */
10192
10209
conn -> llcp_conn_param .status = 0U ;
@@ -10511,7 +10528,7 @@ static u8_t feature_rsp_send(struct connection *conn,
10511
10528
10512
10529
/* AND the feature set to get Feature USED */
10513
10530
req = & pdu_data_rx -> llctrl .feature_req ;
10514
- conn -> llcp_features &= feat_get (& req -> features [0 ]);
10531
+ conn -> llcp_feature . features &= feat_get (& req -> features [0 ]);
10515
10532
10516
10533
/* features exchanged */
10517
10534
conn -> common .fex_valid = 1U ;
@@ -10525,11 +10542,11 @@ static u8_t feature_rsp_send(struct connection *conn,
10525
10542
(void )memset (& pdu_ctrl_tx -> llctrl .feature_rsp .features [0 ], 0x00 ,
10526
10543
sizeof (pdu_ctrl_tx -> llctrl .feature_rsp .features ));
10527
10544
pdu_ctrl_tx -> llctrl .feature_req .features [0 ] =
10528
- conn -> llcp_features & 0xFF ;
10545
+ conn -> llcp_feature . features & 0xFF ;
10529
10546
pdu_ctrl_tx -> llctrl .feature_req .features [1 ] =
10530
- (conn -> llcp_features >> 8 ) & 0xFF ;
10547
+ (conn -> llcp_feature . features >> 8 ) & 0xFF ;
10531
10548
pdu_ctrl_tx -> llctrl .feature_req .features [2 ] =
10532
- (conn -> llcp_features >> 16 ) & 0xFF ;
10549
+ (conn -> llcp_feature . features >> 16 ) & 0xFF ;
10533
10550
10534
10551
ctrl_tx_sec_enqueue (conn , node_tx );
10535
10552
@@ -10568,7 +10585,10 @@ static u8_t version_ind_send(struct connection *conn,
10568
10585
empty_tx_enqueue (conn );
10569
10586
10570
10587
} else if (!conn -> llcp_version .rx ) {
10588
+ LL_ASSERT (conn -> llcp_version .ack != conn -> llcp_version .req );
10589
+
10571
10590
/* Procedure complete */
10591
+ conn -> llcp_version .ack = conn -> llcp_version .req ;
10572
10592
conn -> procedure_expire = 0U ;
10573
10593
10574
10594
/* enqueue the version ind */
@@ -11128,7 +11148,7 @@ u32_t radio_adv_enable(u16_t interval, u8_t chan_map, u8_t filter_policy,
11128
11148
}
11129
11149
11130
11150
conn -> handle = 0xFFFF ;
11131
- conn -> llcp_features = LL_FEAT ;
11151
+ conn -> llcp_feature . features = LL_FEAT ;
11132
11152
conn -> data_chan_sel = 0U ;
11133
11153
conn -> data_chan_use = 0U ;
11134
11154
conn -> event_counter = 0U ;
@@ -11177,6 +11197,10 @@ u32_t radio_adv_enable(u16_t interval, u8_t chan_map, u8_t filter_policy,
11177
11197
11178
11198
conn -> llcp_req = 0U ;
11179
11199
conn -> llcp_ack = 0U ;
11200
+ conn -> llcp_feature .req = 0U ;
11201
+ conn -> llcp_feature .ack = 0U ;
11202
+ conn -> llcp_version .req = 0U ;
11203
+ conn -> llcp_version .ack = 0U ;
11180
11204
conn -> llcp_version .tx = 0U ;
11181
11205
conn -> llcp_version .rx = 0U ;
11182
11206
conn -> llcp_terminate .req = 0U ;
@@ -11648,7 +11672,7 @@ u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, u16_t interval,
11648
11672
328 + RADIO_TIFS + 328 );
11649
11673
11650
11674
conn -> handle = 0xFFFF ;
11651
- conn -> llcp_features = LL_FEAT ;
11675
+ conn -> llcp_feature . features = LL_FEAT ;
11652
11676
access_addr = access_addr_get ();
11653
11677
memcpy (& conn -> access_addr [0 ], & access_addr , sizeof (conn -> access_addr ));
11654
11678
bt_rand (& conn -> crc_init [0 ], 3 );
@@ -11717,6 +11741,10 @@ u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, u16_t interval,
11717
11741
11718
11742
conn -> llcp_req = 0U ;
11719
11743
conn -> llcp_ack = 0U ;
11744
+ conn -> llcp_feature .req = 0U ;
11745
+ conn -> llcp_feature .ack = 0U ;
11746
+ conn -> llcp_version .req = 0U ;
11747
+ conn -> llcp_version .ack = 0U ;
11720
11748
conn -> llcp_version .tx = 0U ;
11721
11749
conn -> llcp_version .rx = 0U ;
11722
11750
conn -> llcp_terminate .req = 0U ;
@@ -11820,7 +11848,7 @@ u8_t ll_conn_update(u16_t handle, u8_t cmd, u8_t status, u16_t interval_min,
11820
11848
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ )
11821
11849
if (!conn -> llcp_conn_param .disabled &&
11822
11850
(!conn -> common .fex_valid ||
11823
- (conn -> llcp_features &
11851
+ (conn -> llcp_feature . features &
11824
11852
BIT (BT_LE_FEAT_BIT_CONN_PARAM_REQ )))) {
11825
11853
cmd ++ ;
11826
11854
} else if (conn -> role ) {
@@ -12074,12 +12102,11 @@ u8_t ll_feature_req_send(u16_t handle)
12074
12102
return BT_HCI_ERR_UNKNOWN_CONN_ID ;
12075
12103
}
12076
12104
12077
- if (conn -> llcp_req != conn -> llcp_ack ) {
12105
+ if (conn -> llcp_feature . req != conn -> llcp_feature . ack ) {
12078
12106
return BT_HCI_ERR_CMD_DISALLOWED ;
12079
12107
}
12080
12108
12081
- conn -> llcp_type = LLCP_FEATURE_EXCHANGE ;
12082
- conn -> llcp_req ++ ;
12109
+ conn -> llcp_feature .req ++ ;
12083
12110
12084
12111
return 0 ;
12085
12112
}
@@ -12093,12 +12120,11 @@ u8_t ll_version_ind_send(u16_t handle)
12093
12120
return BT_HCI_ERR_UNKNOWN_CONN_ID ;
12094
12121
}
12095
12122
12096
- if (conn -> llcp_req != conn -> llcp_ack ) {
12123
+ if (conn -> llcp_version . req != conn -> llcp_version . ack ) {
12097
12124
return BT_HCI_ERR_CMD_DISALLOWED ;
12098
12125
}
12099
12126
12100
- conn -> llcp_type = LLCP_VERSION_EXCHANGE ;
12101
- conn -> llcp_req ++ ;
12127
+ conn -> llcp_version .req ++ ;
12102
12128
12103
12129
return 0 ;
12104
12130
}
@@ -12199,8 +12225,7 @@ u32_t ll_length_req_send(u16_t handle, u16_t tx_octets, u16_t tx_time)
12199
12225
return BT_HCI_ERR_UNKNOWN_CONN_ID ;
12200
12226
}
12201
12227
12202
- if ((conn -> llcp_req != conn -> llcp_ack ) ||
12203
- (conn -> llcp_length .req != conn -> llcp_length .ack )) {
12228
+ if (conn -> llcp_length .req != conn -> llcp_length .ack ) {
12204
12229
return BT_HCI_ERR_CMD_DISALLOWED ;
12205
12230
}
12206
12231
@@ -12280,8 +12305,7 @@ u8_t ll_phy_req_send(u16_t handle, u8_t tx, u8_t flags, u8_t rx)
12280
12305
return BT_HCI_ERR_UNKNOWN_CONN_ID ;
12281
12306
}
12282
12307
12283
- if ((conn -> llcp_req != conn -> llcp_ack ) ||
12284
- (conn -> llcp_phy .req != conn -> llcp_phy .ack )) {
12308
+ if (conn -> llcp_phy .req != conn -> llcp_phy .ack ) {
12285
12309
return BT_HCI_ERR_CMD_DISALLOWED ;
12286
12310
}
12287
12311
0 commit comments