@@ -8405,6 +8405,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
8405
8405
} else if (((event_counter - conn -> llcp .phy_upd_ind .instant ) & 0xFFFF )
8406
8406
<= 0x7FFF ) {
8407
8407
struct radio_pdu_node_rx * node_rx ;
8408
+ u16_t eff_tx_time , eff_rx_time ;
8408
8409
u8_t old_tx , old_rx ;
8409
8410
8410
8411
/* procedure request acked */
@@ -8413,11 +8414,52 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
8413
8414
/* apply new phy */
8414
8415
old_tx = conn -> phy_tx ;
8415
8416
old_rx = conn -> phy_rx ;
8417
+ eff_tx_time = conn -> max_tx_time ;
8418
+ eff_rx_time = conn -> max_rx_time ;
8416
8419
if (conn -> llcp .phy_upd_ind .tx ) {
8420
+ u16_t tx_time ;
8421
+
8417
8422
conn -> phy_tx = conn -> llcp .phy_upd_ind .tx ;
8423
+
8424
+ tx_time = RADIO_PKT_TIME (conn -> max_tx_octets ,
8425
+ conn -> phy_tx );
8426
+ if (tx_time >=
8427
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
8428
+ eff_tx_time = MIN (tx_time ,
8429
+ conn -> default_tx_time );
8430
+ #if defined(CONFIG_BT_CTLR_PHY_CODED )
8431
+ eff_tx_time = MAX (eff_tx_time ,
8432
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN ,
8433
+ conn -> phy_tx ));
8434
+ #endif /* CONFIG_BT_CTLR_PHY_CODED */
8435
+ } else {
8436
+ eff_tx_time =
8437
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN ,
8438
+ 0 );
8439
+ }
8418
8440
}
8419
8441
if (conn -> llcp .phy_upd_ind .rx ) {
8442
+ u16_t rx_time ;
8443
+
8420
8444
conn -> phy_rx = conn -> llcp .phy_upd_ind .rx ;
8445
+
8446
+ rx_time = RADIO_PKT_TIME (conn -> max_rx_octets ,
8447
+ conn -> phy_rx );
8448
+ if (rx_time >=
8449
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN , 0 )) {
8450
+ eff_rx_time = MIN (rx_time ,
8451
+ RADIO_PKT_TIME (LL_LENGTH_OCTETS_RX_MAX ,
8452
+ BIT (2 )));
8453
+ #if defined(CONFIG_BT_CTLR_PHY_CODED )
8454
+ eff_rx_time = MAX (eff_rx_time ,
8455
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN ,
8456
+ conn -> phy_rx ));
8457
+ #endif /* CONFIG_BT_CTLR_PHY_CODED */
8458
+ } else {
8459
+ eff_rx_time =
8460
+ RADIO_PKT_TIME (PDU_DC_PAYLOAD_SIZE_MIN ,
8461
+ 0 );
8462
+ }
8421
8463
}
8422
8464
conn -> phy_flags = conn -> phy_pref_flags ;
8423
8465
@@ -8427,6 +8469,7 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
8427
8469
return ;
8428
8470
}
8429
8471
8472
+ /* Prepare the rx packet structure */
8430
8473
node_rx = packet_rx_reserve_get (2 );
8431
8474
LL_ASSERT (node_rx );
8432
8475
@@ -8438,7 +8481,43 @@ static inline void event_phy_upd_ind_prep(struct connection *conn,
8438
8481
upd -> tx = conn -> phy_tx ;
8439
8482
upd -> rx = conn -> phy_rx ;
8440
8483
8484
+ /* enqueue phy update structure into rx queue */
8441
8485
packet_rx_enqueue ();
8486
+
8487
+ /* Update max tx and/or max rx if changed */
8488
+ if ((eff_tx_time == conn -> max_tx_time ) &&
8489
+ (eff_rx_time == conn -> max_rx_time )) {
8490
+ return ;
8491
+ }
8492
+ conn -> max_tx_time = eff_tx_time ;
8493
+ conn -> max_rx_time = eff_rx_time ;
8494
+
8495
+ #if defined(CONFIG_BT_CTLR_DATA_LENGTH )
8496
+ /* Prepare the rx packet structure */
8497
+ node_rx = packet_rx_reserve_get (2 );
8498
+ LL_ASSERT (node_rx );
8499
+ node_rx -> hdr .handle = conn -> handle ;
8500
+ node_rx -> hdr .type = NODE_RX_TYPE_DC_PDU ;
8501
+
8502
+ /* prepare length rsp structure */
8503
+ struct pdu_data * pdu_ctrl_rx = (void * )node_rx -> pdu_data ;
8504
+
8505
+ pdu_ctrl_rx -> ll_id = PDU_DATA_LLID_CTRL ;
8506
+ pdu_ctrl_rx -> len =
8507
+ offsetof(struct pdu_data_llctrl , length_rsp ) +
8508
+ sizeof (struct pdu_data_llctrl_length_rsp );
8509
+ pdu_ctrl_rx -> llctrl .opcode = PDU_DATA_LLCTRL_TYPE_LENGTH_RSP ;
8510
+
8511
+ struct pdu_data_llctrl_length_req * lr =
8512
+ (void * )& pdu_ctrl_rx -> llctrl .length_rsp ;
8513
+ lr -> max_rx_octets = conn -> max_rx_octets ;
8514
+ lr -> max_tx_octets = conn -> max_tx_octets ;
8515
+ lr -> max_rx_time = conn -> max_rx_time ;
8516
+ lr -> max_tx_time = conn -> max_tx_time ;
8517
+
8518
+ /* enqueue length rsp structure into rx queue */
8519
+ packet_rx_enqueue ();
8520
+ #endif /* CONFIG_BT_CTLR_DATA_LENGTH */
8442
8521
}
8443
8522
}
8444
8523
#endif /* CONFIG_BT_CTLR_PHY */
0 commit comments