@@ -1976,9 +1976,25 @@ static inline u32_t isr_rx_conn_pkt_ack(struct pdu_data *pdu_data_tx,
1976
1976
break ;
1977
1977
}
1978
1978
1979
- /* Procedure complete */
1980
- conn -> llcp_length .ack = conn -> llcp_length .req ;
1981
- conn -> procedure_expire = 0U ;
1979
+ /* check cache */
1980
+ if (!conn -> llcp_length .cache .tx_octets ) {
1981
+ /* Procedure complete */
1982
+ conn -> llcp_length .ack =
1983
+ conn -> llcp_length .req ;
1984
+ conn -> procedure_expire = 0U ;
1985
+
1986
+ break ;
1987
+ }
1988
+
1989
+ /* Initiate cached procedure */
1990
+ conn -> llcp_length .tx_octets =
1991
+ conn -> llcp_length .cache .tx_octets ;
1992
+ conn -> llcp_length .cache .tx_octets = 0 ;
1993
+ #if defined(CONFIG_BT_CTLR_PHY )
1994
+ conn -> llcp_length .tx_time =
1995
+ conn -> llcp_length .cache .tx_time ;
1996
+ #endif /* CONFIG_BT_CTLR_PHY */
1997
+ conn -> llcp_length .state = LLCP_LENGTH_STATE_REQ ;
1982
1998
1983
1999
break ;
1984
2000
@@ -8273,6 +8289,7 @@ static inline int event_len_prep(struct connection *conn)
8273
8289
u16_t packet_rx_data_size ;
8274
8290
u16_t free_count_conn ;
8275
8291
u16_t free_count_rx ;
8292
+ u16_t tx_octets ;
8276
8293
8277
8294
/* Ensure the rx pool is not in use.
8278
8295
* This is important to be able to re-size the pool
@@ -8292,25 +8309,48 @@ static inline int event_len_prep(struct connection *conn)
8292
8309
return - EAGAIN ;
8293
8310
}
8294
8311
8295
- if (conn -> llcp_length .state == LLCP_LENGTH_STATE_RESIZE ) {
8296
- /* Procedure complete */
8297
- conn -> llcp_length .ack = conn -> llcp_length .req ;
8298
- conn -> procedure_expire = 0U ;
8299
- } else {
8300
- conn -> llcp_length .state =
8301
- LLCP_LENGTH_STATE_RESIZE_RSP_ACK_WAIT ;
8302
- }
8303
-
8304
- /* Use the new rx octets/time in the connection */
8312
+ /* Use the new rx octets in the connection */
8305
8313
conn -> max_rx_octets = conn -> llcp_length .rx_octets ;
8306
8314
8315
+ /* backup tx_octets */
8316
+ tx_octets = conn -> llcp_length .tx_octets ;
8317
+
8307
8318
#if defined(CONFIG_BT_CTLR_PHY )
8319
+ /* Use the new rx time in the connection */
8308
8320
conn -> max_rx_time = conn -> llcp_length .rx_time ;
8321
+
8322
+ /* backup tx time */
8323
+ u16_t tx_time = conn -> llcp_length .tx_time ;
8309
8324
#endif /* CONFIG_BT_CTLR_PHY */
8310
8325
8311
8326
/* Reset event length update advanced flag */
8312
8327
conn -> evt_len_adv = 0U ;
8313
8328
8329
+ /* switch states, to wait for ack, to request cached values or
8330
+ * complete the procedure
8331
+ */
8332
+ if (conn -> llcp_length .state == LLCP_LENGTH_STATE_RESIZE ) {
8333
+ /* check cache */
8334
+ if (!conn -> llcp_length .cache .tx_octets ) {
8335
+ /* Procedure complete */
8336
+ conn -> llcp_length .ack = conn -> llcp_length .req ;
8337
+ conn -> procedure_expire = 0U ;
8338
+ } else {
8339
+ /* Initiate cached procedure */
8340
+ conn -> llcp_length .tx_octets =
8341
+ conn -> llcp_length .cache .tx_octets ;
8342
+ conn -> llcp_length .cache .tx_octets = 0 ;
8343
+ #if defined(CONFIG_BT_CTLR_PHY )
8344
+ conn -> llcp_length .tx_time =
8345
+ conn -> llcp_length .cache .tx_time ;
8346
+ #endif /* CONFIG_BT_CTLR_PHY */
8347
+ conn -> llcp_length .state = LLCP_LENGTH_STATE_REQ ;
8348
+ }
8349
+ } else {
8350
+ conn -> llcp_length .state =
8351
+ LLCP_LENGTH_STATE_RESIZE_RSP_ACK_WAIT ;
8352
+ }
8353
+
8314
8354
/** TODO This design is exception as memory initialization
8315
8355
* and allocation is done in radio context here, breaking the
8316
8356
* rule that the rx buffers are allocated in application
@@ -8407,13 +8447,13 @@ static inline int event_len_prep(struct connection *conn)
8407
8447
8408
8448
lr = & pdu_ctrl_rx -> llctrl .length_rsp ;
8409
8449
lr -> max_rx_octets = conn -> max_rx_octets ;
8410
- lr -> max_tx_octets = conn -> llcp_length . tx_octets ;
8450
+ lr -> max_tx_octets = tx_octets ;
8411
8451
#if !defined(CONFIG_BT_CTLR_PHY )
8412
8452
lr -> max_rx_time = RADIO_PKT_TIME (conn -> max_rx_octets , 0 );
8413
- lr -> max_tx_time = RADIO_PKT_TIME (lr -> max_tx_octets , 0 );
8453
+ lr -> max_tx_time = RADIO_PKT_TIME (tx_octets , 0 );
8414
8454
#else /* CONFIG_BT_CTLR_PHY */
8415
8455
lr -> max_rx_time = conn -> max_rx_time ;
8416
- lr -> max_tx_time = conn -> llcp_length . tx_time ;
8456
+ lr -> max_tx_time = tx_time ;
8417
8457
#endif /* CONFIG_BT_CTLR_PHY */
8418
8458
8419
8459
/* enqueue version ind structure into rx queue */
@@ -11226,6 +11266,7 @@ u32_t radio_adv_enable(u16_t interval, u8_t chan_map, u8_t filter_policy,
11226
11266
#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
11227
11267
conn -> llcp_length .req = 0U ;
11228
11268
conn -> llcp_length .ack = 0U ;
11269
+ conn -> llcp_length .cache .tx_octets = 0U ;
11229
11270
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
11230
11271
11231
11272
#if defined(CONFIG_BT_CTLR_PHY )
@@ -11770,6 +11811,7 @@ u32_t radio_connect_enable(u8_t adv_addr_type, u8_t *adv_addr, u16_t interval,
11770
11811
#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
11771
11812
conn -> llcp_length .req = 0U ;
11772
11813
conn -> llcp_length .ack = 0U ;
11814
+ conn -> llcp_length .cache .tx_octets = 0U ;
11773
11815
#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
11774
11816
11775
11817
#if defined(CONFIG_BT_CTLR_PHY )
@@ -12226,7 +12268,22 @@ u32_t ll_length_req_send(u16_t handle, u16_t tx_octets, u16_t tx_time)
12226
12268
}
12227
12269
12228
12270
if (conn -> llcp_length .req != conn -> llcp_length .ack ) {
12229
- return BT_HCI_ERR_CMD_DISALLOWED ;
12271
+ switch (conn -> llcp_length .state ) {
12272
+ case LLCP_LENGTH_STATE_RSP_ACK_WAIT :
12273
+ case LLCP_LENGTH_STATE_RESIZE_RSP :
12274
+ case LLCP_LENGTH_STATE_RESIZE_RSP_ACK_WAIT :
12275
+ /* cached until peer procedure completes */
12276
+ if (!conn -> llcp_length .cache .tx_octets ) {
12277
+ conn -> llcp_length .cache .tx_octets = tx_octets ;
12278
+ #if defined(CONFIG_BT_CTLR_PHY )
12279
+ conn -> llcp_length .cache .tx_time = tx_time ;
12280
+ #endif /* CONFIG_BT_CTLR_PHY */
12281
+ return 0 ;
12282
+ }
12283
+ /* pass through */
12284
+ default :
12285
+ return BT_HCI_ERR_CMD_DISALLOWED ;
12286
+ }
12230
12287
}
12231
12288
12232
12289
/* TODO: parameter check tx_octets and tx_time */
0 commit comments