@@ -3147,6 +3147,76 @@ static inline void event_ping_prep(struct ll_conn *conn)
3147
3147
#endif /* CONFIG_BT_CTLR_LE_PING */
3148
3148
3149
3149
#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
3150
+ static inline void dle_max_time_get (const struct ll_conn * conn ,
3151
+ u16_t * max_rx_time , u16_t * max_tx_time )
3152
+ {
3153
+ u32_t feature_coded_phy = 0 ;
3154
+ u32_t feature_phy_2m = 0 ;
3155
+ u16_t rx_time = 0 ;
3156
+ u16_t tx_time = 0 ;
3157
+
3158
+ #if defined(CONFIG_BT_CTLR_PHY )
3159
+ #if defined(CONFIG_BT_CTLR_PHY_CODED )
3160
+ feature_coded_phy = (conn -> llcp_feature .features &
3161
+ BIT (BT_LE_FEAT_BIT_PHY_CODED ));
3162
+ #else
3163
+ feature_coded_phy = 0 ;
3164
+ #endif
3165
+
3166
+ #if defined(CONFIG_BT_CTLR_PHY_2M )
3167
+ feature_phy_2m = (conn -> llcp_feature .features &
3168
+ BIT (BT_LE_FEAT_BIT_PHY_2M ));
3169
+ #else
3170
+ feature_phy_2m = 0 ;
3171
+ #endif
3172
+ #else
3173
+ feature_coded_phy = 0 ;
3174
+ feature_phy_2m = 0 ;
3175
+ #endif
3176
+
3177
+ if (!conn -> common .fex_valid ||
3178
+ (!feature_coded_phy && !feature_phy_2m )) {
3179
+ rx_time = PKT_US (LL_LENGTH_OCTETS_RX_MAX , 0 );
3180
+ #if defined(CONFIG_BT_CTLR_PHY )
3181
+ tx_time = MAX (MIN (PKT_US (LL_LENGTH_OCTETS_RX_MAX , 0 ),
3182
+ conn -> default_tx_time ),
3183
+ PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , 0 ));
3184
+ #else /* !CONFIG_BT_CTLR_PHY */
3185
+ tx_time = PKT_US (conn -> default_tx_octets , 0 );
3186
+ #endif /* !CONFIG_BT_CTLR_PHY */
3187
+
3188
+ #if defined(CONFIG_BT_CTLR_PHY )
3189
+ #if defined(CONFIG_BT_CTLR_PHY_CODED )
3190
+ } else if (feature_coded_phy ) {
3191
+ rx_time = MAX (PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (2 )),
3192
+ PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , BIT (2 )));
3193
+ tx_time = MIN (PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (2 )),
3194
+ conn -> default_tx_time );
3195
+ tx_time = MAX (PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , 0 ), tx_time );
3196
+ #endif /* CONFIG_BT_CTLR_PHY_CODED */
3197
+
3198
+ #if defined(CONFIG_BT_CTLR_PHY_2M )
3199
+ } else if (feature_phy_2m ) {
3200
+ rx_time = MAX (PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (1 )),
3201
+ PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , BIT (1 )));
3202
+ tx_time = MAX (PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , 0 ),
3203
+ MIN (PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (1 )),
3204
+ conn -> default_tx_time ));
3205
+ #endif /* CONFIG_BT_CTLR_PHY_2M */
3206
+ #endif /* CONFIG_BT_CTLR_PHY */
3207
+ }
3208
+
3209
+ /*
3210
+ * see Vol. 6 Part B chapter 4.5.10
3211
+ * minimum value for time is 328 us
3212
+ */
3213
+ rx_time = MAX (PDU_DC_PAYLOAD_TIME_MIN , rx_time );
3214
+ tx_time = MAX (PDU_DC_PAYLOAD_TIME_MIN , tx_time );
3215
+
3216
+ * max_rx_time = rx_time ;
3217
+ * max_tx_time = tx_time ;
3218
+ }
3219
+
3150
3220
static inline void event_len_prep (struct ll_conn * conn )
3151
3221
{
3152
3222
switch (conn -> llcp_length .state ) {
@@ -3155,39 +3225,17 @@ static inline void event_len_prep(struct ll_conn *conn)
3155
3225
struct pdu_data_llctrl_length_req * lr ;
3156
3226
struct pdu_data * pdu_ctrl_tx ;
3157
3227
struct node_tx * tx ;
3158
- u16_t rx_time = 0 ;
3159
- u16_t tx_time = 0 ;
3160
3228
/*
3161
- * Using bool instead of u8_t increases code size
3162
- * in this case.
3229
+ * initialize to 0 to eliminate compiler warnings
3163
3230
*/
3164
- u8_t feature_coded_phy ;
3165
- u8_t feature_phy_2m ;
3231
+ u16_t rx_time = 0 ;
3232
+ u16_t tx_time = 0 ;
3166
3233
3167
3234
tx = mem_acquire (& mem_conn_tx_ctrl .free );
3168
3235
if (!tx ) {
3169
3236
return ;
3170
3237
}
3171
3238
3172
- #if defined(CONFIG_BT_CTLR_PHY )
3173
- #if defined(CONFIG_BT_CTLR_PHY_CODED )
3174
- feature_coded_phy = (conn -> llcp_feature .features &
3175
- BIT (BT_LE_FEAT_BIT_PHY_CODED ));
3176
- #else
3177
- feature_coded_phy = 0 ;
3178
- #endif
3179
-
3180
- #if defined(CONFIG_BT_CTLR_PHY_2M )
3181
- feature_phy_2m = (conn -> llcp_feature .features &
3182
- BIT (BT_LE_FEAT_BIT_PHY_2M ));
3183
- #else
3184
- feature_phy_2m = 0 ;
3185
- #endif
3186
- #else
3187
- feature_coded_phy = 0 ;
3188
- feature_phy_2m = 0 ;
3189
- #endif
3190
-
3191
3239
/* wait for resp before completing the procedure */
3192
3240
conn -> llcp_length .state = LLCP_LENGTH_STATE_REQ_ACK_WAIT ;
3193
3241
@@ -3196,7 +3244,7 @@ static inline void event_len_prep(struct ll_conn *conn)
3196
3244
3197
3245
#if defined(CONFIG_BT_CTLR_PHY )
3198
3246
conn -> default_tx_time = conn -> llcp_length .tx_time ;
3199
- #endif /* CONFIG_BT_CTLR_PHY */
3247
+ #endif
3200
3248
3201
3249
/* place the length req packet as next in tx queue */
3202
3250
pdu_ctrl_tx = (void * ) tx -> pdu ;
@@ -3210,38 +3258,10 @@ static inline void event_len_prep(struct ll_conn *conn)
3210
3258
lr -> max_rx_octets = sys_cpu_to_le16 (LL_LENGTH_OCTETS_RX_MAX );
3211
3259
lr -> max_tx_octets = sys_cpu_to_le16 (conn -> default_tx_octets );
3212
3260
3213
- if (!conn -> common .fex_valid ||
3214
- (!feature_coded_phy && !feature_phy_2m )) {
3215
- rx_time = PKT_US (LL_LENGTH_OCTETS_RX_MAX , 0 );
3216
- #if defined(CONFIG_BT_CTLR_PHY )
3217
- tx_time = MIN (PKT_US (LL_LENGTH_OCTETS_RX_MAX , 0 ),
3218
- conn -> default_tx_time );
3219
- #else /* !CONFIG_BT_CTLR_PHY */
3220
- tx_time = PKT_US (conn -> default_tx_octets , 0 );
3221
- #endif /* !CONFIG_BT_CTLR_PHY */
3222
- #if defined(CONFIG_BT_CTLR_PHY )
3223
- #if defined(CONFIG_BT_CTLR_PHY_CODED )
3224
- } else if (feature_coded_phy ) {
3225
- rx_time = PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (2 ));
3226
- tx_time = conn -> default_tx_time ;
3227
- #endif /* CONFIG_BT_CTLR_PHY_CODED */
3228
-
3229
- #if defined(CONFIG_BT_CTLR_PHY_2M )
3230
- } else if (feature_phy_2m ) {
3231
- rx_time = PKT_US (LL_LENGTH_OCTETS_RX_MAX , BIT (1 ));
3232
- if (conn -> default_tx_time > rx_time ) {
3233
- tx_time = rx_time ;
3234
- } else {
3235
- tx_time = conn -> default_tx_time ;
3236
- }
3237
- #endif /* CONFIG_BT_CTLR_PHY_2M */
3238
- #endif /* CONFIG_BT_CTLR_PHY */
3239
- }
3240
-
3261
+ dle_max_time_get (conn , & rx_time , & tx_time );
3241
3262
lr -> max_rx_time = sys_cpu_to_le16 (rx_time );
3242
3263
lr -> max_tx_time = sys_cpu_to_le16 (tx_time );
3243
3264
3244
-
3245
3265
ctrl_tx_enqueue (conn , tx );
3246
3266
3247
3267
/* Start Procedure Timeout (TODO: this shall not replace
@@ -4512,14 +4532,19 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
4512
4532
#if defined(CONFIG_BT_CTLR_PHY )
4513
4533
u16_t max_rx_time ;
4514
4534
u16_t max_tx_time ;
4535
+ u16_t lr_rx_time , lr_tx_time ;
4536
+
4537
+ dle_max_time_get (conn , & max_rx_time , & max_tx_time );
4515
4538
4516
4539
/* use the minimal of our default_tx_time and
4517
4540
* peer max_rx_time
4518
4541
*/
4519
- max_rx_time = sys_le16_to_cpu (lr -> max_rx_time );
4520
- if (max_rx_time >= PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
4521
- eff_tx_time = MIN (max_rx_time ,
4522
- conn -> default_tx_time );
4542
+
4543
+ lr_rx_time = sys_le16_to_cpu (lr -> max_rx_time );
4544
+ lr_tx_time = sys_le16_to_cpu (lr -> max_tx_time );
4545
+
4546
+ if (lr_rx_time >= PKT_US (PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
4547
+ eff_tx_time = MIN (lr_rx_time , max_tx_time );
4523
4548
#if defined(CONFIG_BT_CTLR_PHY_CODED )
4524
4549
eff_tx_time = MAX (eff_tx_time ,
4525
4550
PKT_US (PDU_DC_PAYLOAD_SIZE_MIN ,
@@ -4530,18 +4555,12 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
4530
4555
/* use the minimal of our max supported and
4531
4556
* peer max_tx_time
4532
4557
*/
4533
- max_tx_time = sys_le16_to_cpu ( lr -> max_tx_time );
4534
- if ( max_tx_time >= PKT_US ( PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
4558
+ if ( lr_tx_time >= PKT_US ( PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
4559
+ eff_rx_time = MIN ( lr_tx_time , max_rx_time );
4535
4560
#if defined(CONFIG_BT_CTLR_PHY_CODED )
4536
- eff_rx_time = MIN (max_tx_time ,
4537
- PKT_US (LL_LENGTH_OCTETS_RX_MAX ,
4538
- BIT (2 )));
4539
4561
eff_rx_time = MAX (eff_rx_time ,
4540
4562
PKT_US (PDU_DC_PAYLOAD_SIZE_MIN ,
4541
4563
conn -> lll .phy_rx ));
4542
- #else /* !CONFIG_BT_CTLR_PHY_CODED */
4543
- eff_rx_time = MIN (max_tx_time ,
4544
- PKT_US (LL_LENGTH_OCTETS_RX_MAX , 0 ));
4545
4564
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
4546
4565
}
4547
4566
#endif /* CONFIG_BT_CTLR_PHY */
0 commit comments