Skip to content

Commit 772621d

Browse files
Add: experimental st40p api flag for queue stats (#1172)
Add experimental st40p api flag for our framebuffer queue statistics. This will allow the user to see clearly how many frames are in which queue state. Example output: TX_st40p(0,st40sink), stat free: 15 TX_st40p(0,st40sink), stat in_user: 0 TX_st40p(0,st40sink), stat ready: 12 TX_st40p(0,st40sink), stat in_transmitting: 1 We are assuming this may be inaccurate, as no locking is done on the queue, but it is useful for debugging purposes. We could possibly replace the current stats for consumer/producer. For now, we are keeping it as an optional feature.
1 parent a6db55d commit 772621d

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

include/experimental/st40_pipeline_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ enum st40p_tx_flag {
8888
/** Enable the st40p_tx_get_frame block behavior to wait until a frame becomes
8989
available or timeout(default: 1s, use st40p_tx_set_block_timeout to customize)*/
9090
ST40P_TX_FLAG_BLOCK_GET = (MTL_BIT32(15)),
91+
/**
92+
** Enable verbose reporting of framebuffer statuses in statistics output
93+
*/
94+
ST40P_TX_FLAG_ACCURATE_FRAMEBUFF_STATISTICS = (MTL_BIT32(25)),
9195
};
9296

9397
/**

lib/src/st2110/experimental/st40_pipeline_tx.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ static int tx_st40p_next_frame(void* priv, uint16_t* next_frame_idx,
9292
meta->timestamp = framebuff->frame_info.timestamp;
9393
}
9494

95+
if (ctx->ops.flags & (ST40P_TX_FLAG_ACCURATE_FRAMEBUFF_STATISTICS)) {
96+
ctx->stat_enable_verbose_framebuffers_status = true;
97+
}
98+
9599
/* point to next */
96100
ctx->framebuff_consumer_idx = tx_st40p_next_idx(ctx, framebuff->idx);
97101
mt_pthread_mutex_unlock(&ctx->lock);
@@ -283,17 +287,36 @@ static int tx_st40p_stat(void* priv) {
283287
struct st40p_tx_frame* framebuff = ctx->framebuffs;
284288
uint16_t producer_idx;
285289
uint16_t consumer_idx;
290+
uint16_t status_counts[ST40P_TX_FRAME_STATUS_MAX] = {0};
291+
enum st40p_tx_frame_status stat;
286292

287293
if (!ctx->ready) return -EBUSY; /* not ready */
288294

289295
producer_idx = ctx->framebuff_producer_idx;
290296
consumer_idx = ctx->framebuff_consumer_idx;
291-
notice("TX_st40p(%d,%s), p(%d:%s) c(%d:%s)\n", ctx->idx, ctx->ops_name, producer_idx,
292-
tx_st40p_stat_name(framebuff[producer_idx].stat), consumer_idx,
293-
tx_st40p_stat_name(framebuff[consumer_idx].stat));
297+
298+
if (ctx->stat_enable_verbose_framebuffers_status) {
299+
for (uint16_t j = 0; j < ctx->framebuff_cnt; j++) {
300+
stat = framebuff[j].stat;
301+
302+
if (stat < ST40P_TX_FRAME_STATUS_MAX) {
303+
status_counts[stat]++;
304+
}
305+
}
306+
307+
for (uint16_t i = 0; i < ST40P_TX_FRAME_STATUS_MAX; i++) {
308+
notice("TX_st40p(%d,%s), framebuffer queue %s: %u\n", ctx->idx, ctx->ops_name,
309+
tx_st40p_stat_name(i), status_counts[i]);
310+
}
311+
} else {
312+
notice("TX_st40p(%d,%s), p(%d:%s) c(%d:%s)\n", ctx->idx, ctx->ops_name, producer_idx,
313+
tx_st40p_stat_name(framebuff[producer_idx].stat), consumer_idx,
314+
tx_st40p_stat_name(framebuff[consumer_idx].stat));
315+
}
294316

295317
notice("TX_st40p(%d), frame get try %d succ %d, put %d\n", ctx->idx,
296318
ctx->stat_get_frame_try, ctx->stat_get_frame_succ, ctx->stat_put_frame);
319+
297320
ctx->stat_get_frame_try = 0;
298321
ctx->stat_get_frame_succ = 0;
299322
ctx->stat_put_frame = 0;

lib/src/st2110/experimental/st40_pipeline_tx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct st40p_tx_ctx {
4747
uint64_t block_timeout_ns;
4848

4949
/* get frame stat */
50+
bool stat_enable_verbose_framebuffers_status;
5051
int stat_get_frame_try;
5152
int stat_get_frame_succ;
5253
int stat_put_frame;

0 commit comments

Comments
 (0)