Bluetooth: controller: split: fix LL/CON/MAS/BV-74-C tx timing
Fix EBQ tests for the Max Tx Time and Max Rx Time parameter. Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no> Bluetooth: controller: split: fixed for endianness Added conversion to correct endianness Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
This commit is contained in:
parent
e0f51b29ef
commit
0ac4433a12
|
@ -33,8 +33,10 @@
|
|||
+ ACCESS_ADDR_SIZE + CRC_SIZE)
|
||||
#define BYTES2US(bytes, phy) (((bytes)<<3)/BIT((phy&0x3)>>1))
|
||||
|
||||
/* Data channel minimum payload */
|
||||
/* Data channel minimum payload size and time */
|
||||
#define PDU_DC_PAYLOAD_SIZE_MIN 27
|
||||
#define PDU_DC_PAYLOAD_TIME_MIN 328
|
||||
|
||||
/* Link Layer header size of Data PDU. Assumes pdu_data is packed */
|
||||
#define PDU_DC_LL_HEADER_SIZE (offsetof(struct pdu_data, lldata))
|
||||
|
||||
|
|
|
@ -3147,6 +3147,76 @@ static inline void event_ping_prep(struct ll_conn *conn)
|
|||
#endif /* CONFIG_BT_CTLR_LE_PING */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
|
||||
static inline void dle_max_time_get(const struct ll_conn *conn,
|
||||
u16_t *max_rx_time, u16_t *max_tx_time)
|
||||
{
|
||||
u32_t feature_coded_phy = 0;
|
||||
u32_t feature_phy_2m = 0;
|
||||
u16_t rx_time = 0;
|
||||
u16_t tx_time = 0;
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
feature_coded_phy = (conn->llcp_feature.features &
|
||||
BIT(BT_LE_FEAT_BIT_PHY_CODED));
|
||||
#else
|
||||
feature_coded_phy = 0;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY_2M)
|
||||
feature_phy_2m = (conn->llcp_feature.features &
|
||||
BIT(BT_LE_FEAT_BIT_PHY_2M));
|
||||
#else
|
||||
feature_phy_2m = 0;
|
||||
#endif
|
||||
#else
|
||||
feature_coded_phy = 0;
|
||||
feature_phy_2m = 0;
|
||||
#endif
|
||||
|
||||
if (!conn->common.fex_valid ||
|
||||
(!feature_coded_phy && !feature_phy_2m)) {
|
||||
rx_time = PKT_US(LL_LENGTH_OCTETS_RX_MAX, 0);
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
tx_time = MAX(MIN(PKT_US(LL_LENGTH_OCTETS_RX_MAX, 0),
|
||||
conn->default_tx_time),
|
||||
PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0));
|
||||
#else /* !CONFIG_BT_CTLR_PHY */
|
||||
tx_time = PKT_US(conn->default_tx_octets, 0);
|
||||
#endif /* !CONFIG_BT_CTLR_PHY */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
} else if (feature_coded_phy) {
|
||||
rx_time = MAX(PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(2)),
|
||||
PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, BIT(2)));
|
||||
tx_time = MIN(PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(2)),
|
||||
conn->default_tx_time);
|
||||
tx_time = MAX(PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0), tx_time);
|
||||
#endif /* CONFIG_BT_CTLR_PHY_CODED */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY_2M)
|
||||
} else if (feature_phy_2m) {
|
||||
rx_time = MAX(PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(1)),
|
||||
PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, BIT(1)));
|
||||
tx_time = MAX(PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0),
|
||||
MIN(PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(1)),
|
||||
conn->default_tx_time));
|
||||
#endif /* CONFIG_BT_CTLR_PHY_2M */
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
}
|
||||
|
||||
/*
|
||||
* see Vol. 6 Part B chapter 4.5.10
|
||||
* minimum value for time is 328 us
|
||||
*/
|
||||
rx_time = MAX(PDU_DC_PAYLOAD_TIME_MIN, rx_time);
|
||||
tx_time = MAX(PDU_DC_PAYLOAD_TIME_MIN, tx_time);
|
||||
|
||||
*max_rx_time = rx_time;
|
||||
*max_tx_time = tx_time;
|
||||
}
|
||||
|
||||
static inline void event_len_prep(struct ll_conn *conn)
|
||||
{
|
||||
switch (conn->llcp_length.state) {
|
||||
|
@ -3155,39 +3225,17 @@ static inline void event_len_prep(struct ll_conn *conn)
|
|||
struct pdu_data_llctrl_length_req *lr;
|
||||
struct pdu_data *pdu_ctrl_tx;
|
||||
struct node_tx *tx;
|
||||
/*
|
||||
* initialize to 0 to eliminate compiler warnings
|
||||
*/
|
||||
u16_t rx_time = 0;
|
||||
u16_t tx_time = 0;
|
||||
/*
|
||||
* Using bool instead of u8_t increases code size
|
||||
* in this case.
|
||||
*/
|
||||
u8_t feature_coded_phy;
|
||||
u8_t feature_phy_2m;
|
||||
|
||||
tx = mem_acquire(&mem_conn_tx_ctrl.free);
|
||||
if (!tx) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
feature_coded_phy = (conn->llcp_feature.features &
|
||||
BIT(BT_LE_FEAT_BIT_PHY_CODED));
|
||||
#else
|
||||
feature_coded_phy = 0;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY_2M)
|
||||
feature_phy_2m = (conn->llcp_feature.features &
|
||||
BIT(BT_LE_FEAT_BIT_PHY_2M));
|
||||
#else
|
||||
feature_phy_2m = 0;
|
||||
#endif
|
||||
#else
|
||||
feature_coded_phy = 0;
|
||||
feature_phy_2m = 0;
|
||||
#endif
|
||||
|
||||
/* wait for resp before completing the procedure */
|
||||
conn->llcp_length.state = LLCP_LENGTH_STATE_REQ_ACK_WAIT;
|
||||
|
||||
|
@ -3196,7 +3244,7 @@ static inline void event_len_prep(struct ll_conn *conn)
|
|||
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
conn->default_tx_time = conn->llcp_length.tx_time;
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
#endif
|
||||
|
||||
/* place the length req packet as next in tx queue */
|
||||
pdu_ctrl_tx = (void *) tx->pdu;
|
||||
|
@ -3210,38 +3258,10 @@ static inline void event_len_prep(struct ll_conn *conn)
|
|||
lr->max_rx_octets = sys_cpu_to_le16(LL_LENGTH_OCTETS_RX_MAX);
|
||||
lr->max_tx_octets = sys_cpu_to_le16(conn->default_tx_octets);
|
||||
|
||||
if (!conn->common.fex_valid ||
|
||||
(!feature_coded_phy && !feature_phy_2m)) {
|
||||
rx_time = PKT_US(LL_LENGTH_OCTETS_RX_MAX, 0);
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
tx_time = MIN(PKT_US(LL_LENGTH_OCTETS_RX_MAX, 0),
|
||||
conn->default_tx_time);
|
||||
#else /* !CONFIG_BT_CTLR_PHY */
|
||||
tx_time = PKT_US(conn->default_tx_octets, 0);
|
||||
#endif /* !CONFIG_BT_CTLR_PHY */
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
} else if (feature_coded_phy) {
|
||||
rx_time = PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(2));
|
||||
tx_time = conn->default_tx_time;
|
||||
#endif /* CONFIG_BT_CTLR_PHY_CODED */
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PHY_2M)
|
||||
} else if (feature_phy_2m) {
|
||||
rx_time = PKT_US(LL_LENGTH_OCTETS_RX_MAX, BIT(1));
|
||||
if (conn->default_tx_time > rx_time) {
|
||||
tx_time = rx_time;
|
||||
} else {
|
||||
tx_time = conn->default_tx_time;
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_PHY_2M */
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
}
|
||||
|
||||
dle_max_time_get(conn, &rx_time, &tx_time);
|
||||
lr->max_rx_time = sys_cpu_to_le16(rx_time);
|
||||
lr->max_tx_time = sys_cpu_to_le16(tx_time);
|
||||
|
||||
|
||||
ctrl_tx_enqueue(conn, tx);
|
||||
|
||||
/* 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,
|
|||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
u16_t max_rx_time;
|
||||
u16_t max_tx_time;
|
||||
u16_t lr_rx_time, lr_tx_time;
|
||||
|
||||
dle_max_time_get(conn, &max_rx_time, &max_tx_time);
|
||||
|
||||
/* use the minimal of our default_tx_time and
|
||||
* peer max_rx_time
|
||||
*/
|
||||
max_rx_time = sys_le16_to_cpu(lr->max_rx_time);
|
||||
if (max_rx_time >= PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
|
||||
eff_tx_time = MIN(max_rx_time,
|
||||
conn->default_tx_time);
|
||||
|
||||
lr_rx_time = sys_le16_to_cpu(lr->max_rx_time);
|
||||
lr_tx_time = sys_le16_to_cpu(lr->max_tx_time);
|
||||
|
||||
if (lr_rx_time >= PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
|
||||
eff_tx_time = MIN(lr_rx_time, max_tx_time);
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
eff_tx_time = MAX(eff_tx_time,
|
||||
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,
|
|||
/* use the minimal of our max supported and
|
||||
* peer max_tx_time
|
||||
*/
|
||||
max_tx_time = sys_le16_to_cpu(lr->max_tx_time);
|
||||
if (max_tx_time >= PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
|
||||
if (lr_tx_time >= PKT_US(PDU_DC_PAYLOAD_SIZE_MIN, 0)) {
|
||||
eff_rx_time = MIN(lr_tx_time, max_rx_time);
|
||||
#if defined(CONFIG_BT_CTLR_PHY_CODED)
|
||||
eff_rx_time = MIN(max_tx_time,
|
||||
PKT_US(LL_LENGTH_OCTETS_RX_MAX,
|
||||
BIT(2)));
|
||||
eff_rx_time = MAX(eff_rx_time,
|
||||
PKT_US(PDU_DC_PAYLOAD_SIZE_MIN,
|
||||
conn->lll.phy_rx));
|
||||
#else /* !CONFIG_BT_CTLR_PHY_CODED */
|
||||
eff_rx_time = MIN(max_tx_time,
|
||||
PKT_US(LL_LENGTH_OCTETS_RX_MAX, 0));
|
||||
#endif /* !CONFIG_BT_CTLR_PHY_CODED */
|
||||
}
|
||||
#endif /* CONFIG_BT_CTLR_PHY */
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
|
||||
#define PKT_US(octets, phy) (((phy) & BIT(2)) ? \
|
||||
(CODED_PHY_PREAMBLE_TIME_US + \
|
||||
FEC_BLOCK1_TIME_US + \
|
||||
FEC_BLOCK1_TIME_US + \
|
||||
FEC_BLOCK2_TIME_US(octets)) : \
|
||||
(((PREAMBLE_SIZE(1) + \
|
||||
(((PREAMBLE_SIZE(1) + \
|
||||
ACCESS_ADDR_SIZE + \
|
||||
PAYLOAD_OVERHEAD_SIZE + \
|
||||
(octets) + \
|
||||
|
|
Loading…
Reference in a new issue