@@ -1976,9 +1976,25 @@ static inline u32_t isr_rx_conn_pkt_ack(struct pdu_data *pdu_data_tx,
19761976 break ;
19771977 }
19781978
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 ;
19821998
19831999 break ;
19842000
@@ -8273,6 +8289,7 @@ static inline int event_len_prep(struct connection *conn)
82738289 u16_t packet_rx_data_size ;
82748290 u16_t free_count_conn ;
82758291 u16_t free_count_rx ;
8292+ u16_t tx_octets ;
82768293
82778294 /* Ensure the rx pool is not in use.
82788295 * This is important to be able to re-size the pool
@@ -8292,25 +8309,48 @@ static inline int event_len_prep(struct connection *conn)
82928309 return - EAGAIN ;
82938310 }
82948311
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 */
83058313 conn -> max_rx_octets = conn -> llcp_length .rx_octets ;
83068314
8315+ /* backup tx_octets */
8316+ tx_octets = conn -> llcp_length .tx_octets ;
8317+
83078318#if defined(CONFIG_BT_CTLR_PHY )
8319+ /* Use the new rx time in the connection */
83088320 conn -> max_rx_time = conn -> llcp_length .rx_time ;
8321+
8322+ /* backup tx time */
8323+ u16_t tx_time = conn -> llcp_length .tx_time ;
83098324#endif /* CONFIG_BT_CTLR_PHY */
83108325
83118326 /* Reset event length update advanced flag */
83128327 conn -> evt_len_adv = 0U ;
83138328
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+
83148354 /** TODO This design is exception as memory initialization
83158355 * and allocation is done in radio context here, breaking the
83168356 * rule that the rx buffers are allocated in application
@@ -8407,13 +8447,13 @@ static inline int event_len_prep(struct connection *conn)
84078447
84088448 lr = & pdu_ctrl_rx -> llctrl .length_rsp ;
84098449 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 ;
84118451#if !defined(CONFIG_BT_CTLR_PHY )
84128452 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 );
84148454#else /* CONFIG_BT_CTLR_PHY */
84158455 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 ;
84178457#endif /* CONFIG_BT_CTLR_PHY */
84188458
84198459 /* 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,
1122611266#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
1122711267 conn -> llcp_length .req = 0U ;
1122811268 conn -> llcp_length .ack = 0U ;
11269+ conn -> llcp_length .cache .tx_octets = 0U ;
1122911270#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1123011271
1123111272#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,
1177011811#if defined(CONFIG_BT_CTLR_DATA_LENGTH )
1177111812 conn -> llcp_length .req = 0U ;
1177211813 conn -> llcp_length .ack = 0U ;
11814+ conn -> llcp_length .cache .tx_octets = 0U ;
1177311815#endif /* CONFIG_BT_CTLR_DATA_LENGTH */
1177411816
1177511817#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)
1222612268 }
1222712269
1222812270 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+ }
1223012287 }
1223112288
1223212289 /* TODO: parameter check tx_octets and tx_time */
0 commit comments