fixeria submitted this change.

View Change

Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved laforge: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve
bts_chan_load(): also calculate per-TRX channel load

This is required for the upcoming dynamic channel allocation mode.

Change-Id: I220145238c23135f7e68ca2d474764312ffb66c5
Related: SYS#5460
---
M include/osmocom/bsc/bts_trx.h
M src/osmo-bsc/bts_trx_vty.c
M src/osmo-bsc/chan_alloc.c
3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/osmocom/bsc/bts_trx.h b/include/osmocom/bsc/bts_trx.h
index eab5fec..8d2493f 100644
--- a/include/osmocom/bsc/bts_trx.h
+++ b/include/osmocom/bsc/bts_trx.h
@@ -81,6 +81,7 @@
struct gsm_bts_trx_ts ts[TRX_NR_TS];

struct chan_counts chan_counts;
+ struct load_counter lchan_load;
};

static inline struct gsm_bts_trx *gsm_bts_bb_trx_get_trx(struct gsm_bts_bb_trx *bb_transc) {
diff --git a/src/osmo-bsc/bts_trx_vty.c b/src/osmo-bsc/bts_trx_vty.c
index 9cf128e..bd13a05 100644
--- a/src/osmo-bsc/bts_trx_vty.c
+++ b/src/osmo-bsc/bts_trx_vty.c
@@ -747,6 +747,11 @@
vty_out(vty, " E1 Signalling Link:%s", VTY_NEWLINE);
e1isl_dump_vty(vty, trx->rsl_link_primary);
}
+
+ const struct load_counter *ll = &trx->lchan_load;
+ vty_out(vty, " Channel load: %u%%%s",
+ ll->total ? ll->used * 100 / ll->total : 0,
+ VTY_NEWLINE);
}

void config_write_e1_link(struct vty *vty, struct gsm_e1_subslot *e1_link,
diff --git a/src/osmo-bsc/chan_alloc.c b/src/osmo-bsc/chan_alloc.c
index fea4efd..4fbf8be 100644
--- a/src/osmo-bsc/chan_alloc.c
+++ b/src/osmo-bsc/chan_alloc.c
@@ -44,8 +44,12 @@
struct gsm_bts_trx *trx;

llist_for_each_entry(trx, &bts->trx_list, list) {
+ struct load_counter *ll = &trx->lchan_load;
int i;

+ /* init per-TRX load counters */
+ memset(ll, 0, sizeof(*ll));
+
/* skip administratively deactivated transceivers */
if (!trx_is_usable(trx))
continue;
@@ -66,6 +70,7 @@
ts->pchan_on_init == GSM_PCHAN_TCH_F_PDCH) &&
(ts->pchan_is == GSM_PCHAN_NONE ||
ts->pchan_is == GSM_PCHAN_PDCH)) {
+ ll->total++;
pl->total++;
/* Below loop would not count this timeslot, since in PDCH mode it has no usable
* timeslots. But let's make it clear that the timeslot must not be counted again: */
@@ -77,11 +82,13 @@
if (lchan->type == GSM_LCHAN_CBCH)
continue;

+ ll->total++;
pl->total++;

/* lchans under a BORKEN TS should be counted
* as used just as BORKEN lchans under a normal TS */
if (ts->fi->state == TS_ST_BORKEN) {
+ ll->used++;
pl->used++;
continue;
}
@@ -90,6 +97,7 @@
case LCHAN_ST_UNUSED:
break;
default:
+ ll->used++;
pl->used++;
break;
}

To view, visit change 28325. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I220145238c23135f7e68ca2d474764312ffb66c5
Gerrit-Change-Number: 28325
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged