From 3f25909e108dc1504b93c82eeb226d898fc8f086 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sun, 1 Mar 2020 01:27:46 +0700 Subject: [PATCH] trxcon/scheduler: print completeness of the Rx burst buffers Change-Id: Ife9f5eabc23aa2eea08b190361e10a98e890d608 Related: OS#3554 --- src/host/trxcon/sched_lchan_common.c | 21 ++++++++++++++++++++- src/host/trxcon/sched_lchan_pdtch.c | 5 +++-- src/host/trxcon/sched_lchan_tchf.c | 5 +++-- src/host/trxcon/sched_lchan_tchh.c | 5 +++-- src/host/trxcon/sched_lchan_xcch.c | 5 +++-- src/host/trxcon/sched_trx.h | 1 + 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/host/trxcon/sched_lchan_common.c b/src/host/trxcon/sched_lchan_common.c index d8d9ee133..813f31574 100644 --- a/src/host/trxcon/sched_lchan_common.c +++ b/src/host/trxcon/sched_lchan_common.c @@ -2,7 +2,7 @@ * OsmocomBB <-> SDR connection bridge * TDMA scheduler: common routines for lchan handlers * - * (C) 2017-2019 by Vadim Yanitskiy + * (C) 2017-2020 by Vadim Yanitskiy * * All Rights Reserved * @@ -84,6 +84,25 @@ const uint8_t sched_nb_training_bits[8][26] = { }, }; +/* Get a string representation of the burst buffer's completeness. + * Examples: " ****.." (incomplete, 4/6 bursts) + * " ****" (complete, all 4 bursts) + * "**.***.." (incomplete, 5/8 bursts) */ +const char *burst_mask2str(const uint8_t *mask, int bits) +{ + /* TODO: CSD is interleaved over 22 bursts, so the mask needs to be extended */ + static char buf[8 + 1]; + char *ptr = buf; + + OSMO_ASSERT(bits <= 8 && bits > 0); + + while (--bits >= 0) + *(ptr++) = (*mask & (1 << bits)) ? '*' : '.'; + *ptr = '\0'; + + return buf; +} + int sched_gsmtap_send(enum trx_lchan_type lchan_type, uint32_t fn, uint8_t tn, uint16_t band_arfcn, int8_t signal_dbm, uint8_t snr, const uint8_t *data, size_t data_len) diff --git a/src/host/trxcon/sched_lchan_pdtch.c b/src/host/trxcon/sched_lchan_pdtch.c index 733e57418..83a6f53b8 100644 --- a/src/host/trxcon/sched_lchan_pdtch.c +++ b/src/host/trxcon/sched_lchan_pdtch.c @@ -88,8 +88,9 @@ int rx_pdtch_fn(struct trx_instance *trx, struct trx_ts *ts, /* Check for complete set of bursts */ if ((*mask & 0xf) != 0xf) { - LOGP(DSCHD, LOGL_ERROR, "Received incomplete data frame at " - "fn=%u (%u/%u) for %s\n", *first_fn, + LOGP(DSCHD, LOGL_ERROR, "Received incomplete (%s) data frame at " + "fn=%u (%u/%u) for %s\n", + burst_mask2str(mask, 4), *first_fn, (*first_fn) % ts->mf_layout->period, ts->mf_layout->period, lchan_desc->name); diff --git a/src/host/trxcon/sched_lchan_tchf.c b/src/host/trxcon/sched_lchan_tchf.c index f2ecdcc61..0109280b0 100644 --- a/src/host/trxcon/sched_lchan_tchf.c +++ b/src/host/trxcon/sched_lchan_tchf.c @@ -90,8 +90,9 @@ int rx_tchf_fn(struct trx_instance *trx, struct trx_ts *ts, /* Check for complete set of bursts */ if ((*mask & 0xf) != 0xf) { - LOGP(DSCHD, LOGL_ERROR, "Received incomplete traffic frame at " - "fn=%u (%u/%u) for %s\n", *first_fn, + LOGP(DSCHD, LOGL_ERROR, "Received incomplete (%s) traffic frame at " + "fn=%u (%u/%u) for %s\n", + burst_mask2str(mask, 8), *first_fn, (*first_fn) % ts->mf_layout->period, ts->mf_layout->period, lchan_desc->name); diff --git a/src/host/trxcon/sched_lchan_tchh.c b/src/host/trxcon/sched_lchan_tchh.c index 0201ee357..82886706e 100644 --- a/src/host/trxcon/sched_lchan_tchh.c +++ b/src/host/trxcon/sched_lchan_tchh.c @@ -299,8 +299,9 @@ int rx_tchh_fn(struct trx_instance *trx, struct trx_ts *ts, /* Check decoding result */ if (rc < 4) { - LOGP(DSCHD, LOGL_ERROR, "Received bad TCH frame ending at " - "fn=%u on %s (rc=%d)\n", fn, lchan_desc->name, rc); + LOGP(DSCHD, LOGL_ERROR, "Received bad TCH frame (%s) ending at " + "fn=%u on %s (rc=%d)\n", burst_mask2str(mask, 6), + fn, lchan_desc->name, rc); /* Send BFI */ goto bfi; diff --git a/src/host/trxcon/sched_lchan_xcch.c b/src/host/trxcon/sched_lchan_xcch.c index d34164652..34fe5ce8e 100644 --- a/src/host/trxcon/sched_lchan_xcch.c +++ b/src/host/trxcon/sched_lchan_xcch.c @@ -87,8 +87,9 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts, /* Check for complete set of bursts */ if ((*mask & 0xf) != 0xf) { - LOGP(DSCHD, LOGL_ERROR, "Received incomplete data frame at " - "fn=%u (%u/%u) for %s\n", *first_fn, + LOGP(DSCHD, LOGL_ERROR, "Received incomplete (%s) data frame at " + "fn=%u (%u/%u) for %s\n", + burst_mask2str(mask, 4), *first_fn, (*first_fn) % ts->mf_layout->period, ts->mf_layout->period, lchan_desc->name); diff --git a/src/host/trxcon/sched_trx.h b/src/host/trxcon/sched_trx.h index 8718ed699..13fc678dc 100644 --- a/src/host/trxcon/sched_trx.h +++ b/src/host/trxcon/sched_trx.h @@ -355,6 +355,7 @@ int sched_trx_handle_tx_burst(struct trx_instance *trx, /* Shared declarations for lchan handlers */ extern const uint8_t sched_nb_training_bits[8][26]; +const char *burst_mask2str(const uint8_t *mask, int bits); size_t sched_bad_frame_ind(uint8_t *l2, struct trx_lchan_state *lchan); int sched_send_dt_ind(struct trx_instance *trx, struct trx_ts *ts, struct trx_lchan_state *lchan, uint8_t *l2, size_t l2_len,