Bluetooth: Controller: Kconfig radio ISR profiling

Add Kconfig configuration and conditional compilation of
radio ISR profiling.

Change-id: Ia80d6bc54810156be99b2e6a25327c30d0714697
Signed-off-by: Vinayak Chettimada <vinayak.kariappa.chettimada@nordicsemi.no>
This commit is contained in:
Vinayak Chettimada 2016-12-27 19:23:32 +01:00 committed by Johan Hedberg
commit a591205045
6 changed files with 38 additions and 10 deletions

View file

@ -38,6 +38,8 @@ config BLUETOOTH_CONTROLLER_RX_STACK_SIZE
which all radio messages are encoded into HCI events or data
before passing it to Bluetooth receiving thread.
comment "BLE Controller debug configuration"
config BLUETOOTH_CONTROLLER_ASSERT_HANDLER
bool "Bluetooth Controller Assertion Handler"
depends on BLUETOOTH_HCI_RAW
@ -48,5 +50,12 @@ config BLUETOOTH_CONTROLLER_ASSERT_HANDLER
and will be invoked whenever the controller code encounters
an unrecoverable error.
config BLUETOOTH_CONTROLLER_PROFILE_ISR
bool "Profile radio ISR"
help
Turn on measurement of radio ISR latency, CPU usage and generation of
controller event with these profiling data. The controller event
contains current, minimum and maximum ISR entry latencies; and
current, minimum and maximum ISR CPU use in micro-seconds.
endif # BLUETOOTH_CONTROLLER

View file

@ -1103,6 +1103,7 @@ static void encode_control(struct radio_pdu_node_rx *node_rx,
/** @todo */
return;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
case NODE_RX_TYPE_PROFILE:
/** @todo */
BT_INFO("l: %d, %d, %d; t: %d, %d, %d.",
@ -1113,6 +1114,7 @@ static void encode_control(struct radio_pdu_node_rx *node_rx,
pdu_data->payload.profile.min,
pdu_data->payload.profile.max);
return;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
default:
LL_ASSERT(0);

View file

@ -60,7 +60,6 @@
#define XTAL_ADVANCED 1
#define SCHED_ADVANCED 1
#define PROFILE_ISR 0
#define FAST_ENC_PROCEDURE 0
#define SILENT_CONNECTION 0
@ -1950,7 +1949,8 @@ static inline void isr_rx_conn(uint8_t crc_ok, uint8_t trx_done,
struct pdu_data *pdu_data_rx;
struct pdu_data *pdu_data_tx;
uint8_t crc_close = 0;
#if PROFILE_ISR
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
static uint8_t s_lmax;
static uint8_t s_lmin = (uint8_t) -1;
static uint8_t s_lprv;
@ -1960,7 +1960,7 @@ static inline void isr_rx_conn(uint8_t crc_ok, uint8_t trx_done,
uint32_t sample;
uint8_t latency, elapsed, prv;
uint8_t chg = 0;
#endif
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
/* Collect RSSI for connection */
if (_radio.packet_counter == 0) {
@ -2075,7 +2075,7 @@ static inline void isr_rx_conn(uint8_t crc_ok, uint8_t trx_done,
isr_rx_conn_exit:
#if PROFILE_ISR
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
/* get the ISR latency sample */
sample = radio_tmr_sample_get();
@ -2145,7 +2145,7 @@ isr_rx_conn_exit:
packet_rx_enqueue();
}
}
#endif
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
return;
}
@ -2629,12 +2629,14 @@ static void isr(void)
/* Read radio status and events */
trx_done = radio_is_done();
if (trx_done) {
#if PROFILE_ISR
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
/* sample the packet timer here, use it to calculate ISR latency
* and generate the profiling event at the end of the ISR.
*/
radio_tmr_sample();
#endif
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
crc_ok = radio_crc_is_valid();
devmatch_ok = radio_filter_has_match();
irkmatch_ok = radio_ar_has_match();
@ -7604,13 +7606,17 @@ void radio_rx_dequeue(void)
switch (radio_pdu_node_rx->hdr.type) {
case NODE_RX_TYPE_DC_PDU:
case NODE_RX_TYPE_PROFILE:
case NODE_RX_TYPE_REPORT:
case NODE_RX_TYPE_CONNECTION:
case NODE_RX_TYPE_CONN_UPDATE:
case NODE_RX_TYPE_ENC_REFRESH:
case NODE_RX_TYPE_APTO:
case NODE_RX_TYPE_RSSI:
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
case NODE_RX_TYPE_PROFILE:
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
/* release data link credit quota */
LL_ASSERT(_radio.link_rx_data_quota <
(_radio.packet_rx_count - 1));
@ -7642,13 +7648,17 @@ void radio_rx_mem_release(struct radio_pdu_node_rx **radio_pdu_node_rx)
switch (_radio_pdu_node_rx_free->hdr.type) {
case NODE_RX_TYPE_DC_PDU:
case NODE_RX_TYPE_PROFILE:
case NODE_RX_TYPE_REPORT:
case NODE_RX_TYPE_CONNECTION:
case NODE_RX_TYPE_CONN_UPDATE:
case NODE_RX_TYPE_ENC_REFRESH:
case NODE_RX_TYPE_APTO:
case NODE_RX_TYPE_RSSI:
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
case NODE_RX_TYPE_PROFILE:
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
mem_release(_radio_pdu_node_rx_free,
&_radio.pkt_rx_data_free);
break;

View file

@ -180,7 +180,6 @@ struct radio_pdu_node_tx {
enum radio_pdu_node_rx_type {
NODE_RX_TYPE_NONE,
NODE_RX_TYPE_DC_PDU,
NODE_RX_TYPE_PROFILE,
NODE_RX_TYPE_REPORT,
NODE_RX_TYPE_CONNECTION,
NODE_RX_TYPE_TERMINATE,
@ -188,6 +187,9 @@ enum radio_pdu_node_rx_type {
NODE_RX_TYPE_ENC_REFRESH,
NODE_RX_TYPE_APTO,
NODE_RX_TYPE_RSSI,
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
NODE_RX_TYPE_PROFILE,
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
};
struct radio_pdu_node_rx_hdr {

View file

@ -232,6 +232,7 @@ struct pdu_data_llctrl {
} __packed ctrldata;
} __packed;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
struct profile {
uint8_t lcur;
uint8_t lmin;
@ -240,6 +241,7 @@ struct profile {
uint8_t min;
uint8_t max;
} __packed;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
struct pdu_data {
uint8_t ll_id:2;
@ -256,7 +258,9 @@ struct pdu_data {
uint8_t lldata[1];
struct pdu_data_llctrl llctrl;
uint8_t rssi;
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR)
struct profile profile;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR */
} __packed payload;
} __packed;

View file

@ -1,5 +1,6 @@
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_CONTROLLER=y
CONFIG_BLUETOOTH_CONTROLLER_PROFILE_ISR=y
CONFIG_BLUETOOTH_PERIPHERAL=y
CONFIG_BLUETOOTH_CENTRAL=y
CONFIG_BLUETOOTH_SMP=y