pdch: Introduce APIs to print PDCH name

This will allow printing PDCH with same formatting outside of LOGPDCH.

Change-Id: If18cb4a48237751e0dddede6793191b36dfe386d
This commit is contained in:
Pau Espin 2022-12-15 16:25:27 +01:00
parent ff7c581011
commit 23ae0e3d23
2 changed files with 17 additions and 3 deletions

View File

@ -1336,3 +1336,17 @@ bool pdch_is_full(const struct gprs_rlcmac_pdch *pdch)
pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) == NO_FREE_TFI ||
find_free_usf(pdch->assigned_usf()) < 0;
}
const char *pdch_name(const struct gprs_rlcmac_pdch *pdch)
{
static char _pdch_name_buf[128];
return pdch_name_buf(pdch, _pdch_name_buf, sizeof(_pdch_name_buf));
}
char *pdch_name_buf(const struct gprs_rlcmac_pdch *pdch, char *buf, size_t buf_size)
{
struct osmo_strbuf sb = { .buf = buf, .len = buf_size };
OSMO_STRBUF_PRINTF(sb, "PDCH(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ")",
pdch->trx->bts->nr, pdch->trx->trx_no, pdch->ts_no);
return buf;
}

View File

@ -191,11 +191,11 @@ void pdch_free_all_tbf(struct gprs_rlcmac_pdch *pdch);
void pdch_disable(struct gprs_rlcmac_pdch *pdch);
bool pdch_is_enabled(const struct gprs_rlcmac_pdch *pdch);
bool pdch_is_full(const struct gprs_rlcmac_pdch *pdch);
const char *pdch_name(const struct gprs_rlcmac_pdch *pdch);
char *pdch_name_buf(const struct gprs_rlcmac_pdch *pdch, char *buf, size_t buf_size);
#ifdef __cplusplus
}
#endif
#define LOGPDCH(pdch, category, level, fmt, args...) \
LOGP(category, level, "PDCH(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ") " fmt, \
(pdch)->trx->bts->nr, (pdch)->trx->trx_no, (pdch)->ts_no, \
## args)
LOGP(category, level, "%s " fmt, pdch_name(pdch), ## args)