Change in osmo-bsc[master]: assignment: special mixed desc/alloc conditions

Hoernchen gerrit-no-reply at lists.osmocom.org
Thu Jun 10 22:57:23 UTC 2021


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/24646 )


Change subject: assignment: special mixed desc/alloc conditions
......................................................................

assignment: special mixed desc/alloc conditions

There was a request to enable descending alloc in case a (averaged)
rxlev condition AND a #used ts threshold was met.

This is a hack that should not be merged.

Change-Id: I4ef37874807ebd26a14616fa49498e6ab124b07b
Related: SYS#5460
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/lchan_select.h
M src/osmo-bsc/abis_rsl.c
M src/osmo-bsc/assignment_fsm.c
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/handover_decision_2.c
M src/osmo-bsc/lchan_select.c
7 files changed, 147 insertions(+), 27 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/46/24646/1

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index 72f83eb..196fb05 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -288,6 +288,11 @@
 	/* maximum Tx power that the MS is permitted to use in this cell */
 	int ms_max_power;
 
+	/* conditions for desc alloc usage */
+	int assign_tsused_tresh;
+	int assign_rxlev_avgnum;
+	int assign_rxlev_tresh;
+
 	/* how do we talk OML with this TRX? */
 	struct gsm_e1_subslot oml_e1_link;
 	uint8_t oml_tei;
diff --git a/include/osmocom/bsc/lchan_select.h b/include/osmocom/bsc/lchan_select.h
index aa2f40e..3f0375f 100644
--- a/include/osmocom/bsc/lchan_select.h
+++ b/include/osmocom/bsc/lchan_select.h
@@ -5,4 +5,6 @@
 enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate);
 struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts,
 					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate);
-struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log);
+struct gsm_lchan *lchan_select_by_chan_mode2(struct gsm_bts *bts,
+					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate, struct gsm_lchan* old_lchan);
+struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log, struct gsm_lchan* old_lchan);
diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c
index ac8006d..25ef5a1 100644
--- a/src/osmo-bsc/abis_rsl.c
+++ b/src/osmo-bsc/abis_rsl.c
@@ -1731,12 +1731,12 @@
 
 	/* First check the situation on the BTS, if we have TCH/H or TCH/F resources available for another (EMERGENCY)
 	 * call. If yes, then no (further) action has to be carried out. */
-	if (lchan_avail_by_type(rqd->bts, GSM_LCHAN_TCH_F, true)) {
+	if (lchan_avail_by_type(rqd->bts, GSM_LCHAN_TCH_F, true, 0)) {
 		LOG_BTS(rqd->bts, DRSL, LOGL_NOTICE,
 			"CHAN RQD/EMERGENCY-PRIORITY: at least one TCH/F is (now) available!\n");
 		return false;
 	}
-	if (lchan_avail_by_type(rqd->bts, GSM_LCHAN_TCH_H, true)) {
+	if (lchan_avail_by_type(rqd->bts, GSM_LCHAN_TCH_H, true, 0)) {
 		LOG_BTS(rqd->bts, DRSL, LOGL_NOTICE,
 			"CHAN RQD/EMERGENCY-PRIORITY: at least one TCH/H is (now) available!\n");
 		return false;
diff --git a/src/osmo-bsc/assignment_fsm.c b/src/osmo-bsc/assignment_fsm.c
index f5aee82..d6ea525 100644
--- a/src/osmo-bsc/assignment_fsm.c
+++ b/src/osmo-bsc/assignment_fsm.c
@@ -585,8 +585,8 @@
 	} else {
 		/* Try to allocate a new lchan in order of preference */
 		for (i = 0; i < req->n_ch_mode_rate; i++) {
-			conn->assignment.new_lchan = lchan_select_by_chan_mode(bts,
-			    req->ch_mode_rate_list[i].chan_mode, req->ch_mode_rate_list[i].chan_rate);
+			conn->assignment.new_lchan = lchan_select_by_chan_mode2(bts,
+			    req->ch_mode_rate_list[i].chan_mode, req->ch_mode_rate_list[i].chan_rate, conn->lchan);
 			if (!conn->assignment.new_lchan)
 				continue;
 			LOG_ASSIGNMENT(conn, LOGL_DEBUG, "selected new lchan %s for mode[%d] = %s channel_rate=%d\n",
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 430863b..4a5101a 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1293,6 +1293,12 @@
 	config_write_power_ctrl(vty, 2, &bts->bs_power_ctrl);
 	config_write_power_ctrl(vty, 2, &bts->ms_power_ctrl);
 
+	if (bts->assign_rxlev_avgnum > 0) {
+		vty_out(vty, "  assign_rxlev_avgnum %u%s", bts->assign_rxlev_avgnum, VTY_NEWLINE);
+		vty_out(vty, "  assign_rxlev_tresh %d%s", bts->assign_rxlev_tresh, VTY_NEWLINE);
+		vty_out(vty, "  assign_tsused_tresh %u%s", bts->assign_tsused_tresh, VTY_NEWLINE);
+	}
+
 	config_write_bts_model(vty, bts);
 }
 
@@ -5051,6 +5057,67 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN_USRATTR(cfg_bts_assign_tsused_tresh,
+	      cfg_bts_assign_tsused_tresh_cmd,
+	      X(BSC_VTY_ATTR_NEW_LCHAN),
+	      "assign_tsused_tresh <0-65535>",
+	      "Set #ts used cutoff value for enabling descending chan alloc\n" "#ts\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int tresh = atoi(argv[0]);
+
+	if (tresh < 0 || tresh > 0xffff) {
+		vty_out(vty, "%% assign_tsused_tresh %d is not in the valid range (0-65535)%s",
+			tresh, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	bts->assign_tsused_tresh = tresh;
+
+	return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_bts_assign_rxlev_avgnum,
+	      cfg_bts_assign_rxlev_avgnum_cmd,
+	      X(BSC_VTY_ATTR_NEW_LCHAN),
+	      "assign_rxlev_avgnum <0-10>",
+	      "Set numver of measurements to average for enabling descending chan alloc\n" "#meas\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int avg = atoi(argv[0]);
+
+	if (avg < 0 || avg > 10) {
+		vty_out(vty, "%% assign_rxlev_avgnum %d is not in the valid range (0-10)%s",
+			avg, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	bts->assign_rxlev_avgnum = avg;
+
+	return CMD_SUCCESS;
+}
+
+DEFUN_USRATTR(cfg_bts_assign_rxlev_tresh,
+	      cfg_bts_assign_rxlev_tresh_cmd,
+	      X(BSC_VTY_ATTR_NEW_LCHAN),
+	      "assign_rxlev_tresh <-150-150>",
+	      "Set rxlev cutoff value (dBm) for enabling descending chan alloc\n" "num ts\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int tresh = atoi(argv[0]);
+
+	if (tresh < -150 || tresh > 150) {
+		vty_out(vty, "%% assign_rxlev_tresh %d is not in the valid range (-150-150)%s",
+			tresh, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	bts->assign_rxlev_tresh = tresh;
+
+	return CMD_SUCCESS;
+}
+
+
 DEFUN_USRATTR(cfg_power_ctrl_mode,
 	      cfg_power_ctrl_mode_cmd,
 	      X(BSC_VTY_ATTR_NEW_LCHAN),
@@ -8107,6 +8174,10 @@
 
 	install_element(BTS_NODE, &cfg_bts_power_ctrl_cmd);
 	install_element(BTS_NODE, &cfg_bts_no_power_ctrl_cmd);
+	install_element(BTS_NODE, &cfg_bts_assign_tsused_tresh_cmd);
+	install_element(BTS_NODE, &cfg_bts_assign_rxlev_avgnum_cmd);
+	install_element(BTS_NODE, &cfg_bts_assign_rxlev_tresh_cmd);
+
 	install_node(&power_ctrl_node, dummy_config_write);
 	install_element(POWER_CTRL_NODE, &cfg_power_ctrl_mode_cmd);
 	install_element(POWER_CTRL_NODE, &cfg_power_ctrl_bs_power_cmd);
diff --git a/src/osmo-bsc/handover_decision_2.c b/src/osmo-bsc/handover_decision_2.c
index a866293..e0458b0 100644
--- a/src/osmo-bsc/handover_decision_2.c
+++ b/src/osmo-bsc/handover_decision_2.c
@@ -1009,7 +1009,7 @@
 	c->target.min_free_tchh = ho_get_hodec2_tchh_min_slots(c->target.bts->ho);
 
 	/* Would the next TCH/F lchan occupy a dynamic timeslot that currently counts for free TCH/H timeslots? */
-	next_lchan = lchan_avail_by_type(c->target.bts, GSM_LCHAN_TCH_F, false);
+	next_lchan = lchan_avail_by_type(c->target.bts, GSM_LCHAN_TCH_F, false, 0);
 	if (next_lchan && next_lchan->ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH)
 		c->target.next_tchf_reduces_tchh = 2;
 	else
@@ -1017,7 +1017,7 @@
 
 	/* Would the next TCH/H lchan occupy a dynamic timeslot that currently counts for free TCH/F timeslots?
 	 * Note that a dyn TS already in TCH/H mode (half occupied) would not reduce free TCH/F. */
-	next_lchan = lchan_avail_by_type(c->target.bts, GSM_LCHAN_TCH_H, false);
+	next_lchan = lchan_avail_by_type(c->target.bts, GSM_LCHAN_TCH_H, false, 0);
 	if (next_lchan && next_lchan->ts->pchan_on_init == GSM_PCHAN_TCH_F_TCH_H_PDCH
 	    && next_lchan->ts->pchan_is != GSM_PCHAN_TCH_H)
 		c->target.next_tchh_reduces_tchf = 1;
diff --git a/src/osmo-bsc/lchan_select.c b/src/osmo-bsc/lchan_select.c
index 53c4358..22fb3bd 100644
--- a/src/osmo-bsc/lchan_select.c
+++ b/src/osmo-bsc/lchan_select.c
@@ -32,7 +32,7 @@
 
 static struct gsm_lchan *
 _lc_find_trx(struct gsm_bts_trx *trx, enum gsm_phys_chan_config pchan,
-	     enum gsm_phys_chan_config as_pchan, bool allow_pchan_switch, bool log)
+	     enum gsm_phys_chan_config as_pchan, bool allow_pchan_switch, bool log, bool use_desc_alloc)
 {
 	struct gsm_lchan *lchan;
 	struct gsm_bts_trx_ts *ts;
@@ -52,7 +52,7 @@
 		return NULL;
 	}
 
-	if (trx->bts->chan_alloc_reverse) {
+	if (trx->bts->chan_alloc_reverse || use_desc_alloc) {
 		/* check TS 7..0 */
 		start = 7;
 		stop = -1;
@@ -106,7 +106,7 @@
 
 static struct gsm_lchan *
 _lc_dyn_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan,
-		 enum gsm_phys_chan_config dyn_as_pchan, bool log)
+		 enum gsm_phys_chan_config dyn_as_pchan, bool log, bool use_desc_alloc)
 {
 	struct gsm_bts_trx *trx;
 	struct gsm_lchan *lc;
@@ -120,15 +120,15 @@
 	 * true, because they never switch anyway. */
 	try_pchan_switch = (pchan != dyn_as_pchan);
 	for (allow_pchan_switch = 0; allow_pchan_switch <= (try_pchan_switch ? 1 : 0); allow_pchan_switch++) {
-		if (bts->chan_alloc_reverse) {
+		if (bts->chan_alloc_reverse || use_desc_alloc) {
 			llist_for_each_entry_reverse(trx, &bts->trx_list, list) {
-				lc = _lc_find_trx(trx, pchan, dyn_as_pchan, (bool)allow_pchan_switch, log);
+				lc = _lc_find_trx(trx, pchan, dyn_as_pchan, (bool)allow_pchan_switch, log, use_desc_alloc);
 				if (lc)
 					return lc;
 			}
 		} else {
 			llist_for_each_entry(trx, &bts->trx_list, list) {
-				lc = _lc_find_trx(trx, pchan, dyn_as_pchan, (bool)allow_pchan_switch, log);
+				lc = _lc_find_trx(trx, pchan, dyn_as_pchan, (bool)allow_pchan_switch, log, use_desc_alloc);
 				if (lc)
 					return lc;
 			}
@@ -139,9 +139,9 @@
 }
 
 static struct gsm_lchan *
-_lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, bool log)
+_lc_find_bts(struct gsm_bts *bts, enum gsm_phys_chan_config pchan, bool log, bool use_desc_alloc)
 {
-	return _lc_dyn_find_bts(bts, pchan, pchan, log);
+	return _lc_dyn_find_bts(bts, pchan, pchan, log, use_desc_alloc);
 }
 
 enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate)
@@ -187,17 +187,34 @@
 	return lchan_select_by_type(bts, type);
 }
 
-struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log)
+static bool special_alloc_handling(struct gsm_bts *bts, struct gsm_lchan* lc)
+{
+	int ts_used;
+	int avglev;
+
+	if (!bts->assign_rxlev_avgnum || !lc)
+		return false;
+
+	ts_used = bts_count_free_ts(bts, GSM_PCHAN_TCH_F) + bts_count_free_ts(bts, GSM_PCHAN_TCH_H);
+	avglev = get_meas_rep_avg(lc, MEAS_REP_DL_RXLEV_FULL, bts->assign_rxlev_avgnum);
+
+	if (rxlev2dbm(avglev) > bts->assign_rxlev_tresh && ts_used > bts->assign_tsused_tresh)
+		return true;
+	return false;
+}
+
+struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log, struct gsm_lchan* old_lchan)
 {
 	struct gsm_lchan *lchan = NULL;
 	enum gsm_phys_chan_config first, first_cbch, second, second_cbch;
+	bool use_desc_alloc = special_alloc_handling(bts, old_lchan);
 
 	if (log)
 		LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_avail_by_type(%s)\n", gsm_lchant_name(type));
 
 	switch (type) {
 	case GSM_LCHAN_SDCCH:
-		if (bts->chan_alloc_reverse) {
+		if (bts->chan_alloc_reverse || use_desc_alloc) {
 			first = GSM_PCHAN_SDCCH8_SACCH8C;
 			first_cbch = GSM_PCHAN_SDCCH8_SACCH8C_CBCH;
 			second = GSM_PCHAN_CCCH_SDCCH4;
@@ -209,20 +226,20 @@
 			second_cbch = GSM_PCHAN_SDCCH8_SACCH8C_CBCH;
 		}
 
-		lchan = _lc_find_bts(bts, first, log);
+		lchan = _lc_find_bts(bts, first, log, use_desc_alloc);
 		if (lchan == NULL)
-			lchan = _lc_find_bts(bts, first_cbch, log);
+			lchan = _lc_find_bts(bts, first_cbch, log, use_desc_alloc);
 		if (lchan == NULL)
-			lchan = _lc_find_bts(bts, second, log);
+			lchan = _lc_find_bts(bts, second, log, use_desc_alloc);
 		if (lchan == NULL)
-			lchan = _lc_find_bts(bts, second_cbch, log);
+			lchan = _lc_find_bts(bts, second_cbch, log, use_desc_alloc);
 		break;
 	case GSM_LCHAN_TCH_F:
-		lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F, log);
+		lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_F, log, use_desc_alloc);
 		/* If we don't have TCH/F available, try dynamic TCH/F_PDCH */
 		if (!lchan) {
 			lchan = _lc_dyn_find_bts(bts, GSM_PCHAN_TCH_F_PDCH,
-						 GSM_PCHAN_TCH_F, log);
+						 GSM_PCHAN_TCH_F, log, use_desc_alloc);
 			/* TCH/F_PDCH used as TCH/F -- here, type is already
 			 * set to GSM_LCHAN_TCH_F, but for clarity's sake... */
 			if (lchan)
@@ -233,19 +250,19 @@
 		if (!lchan && bts->network->dyn_ts_allow_tch_f) {
 			lchan = _lc_dyn_find_bts(bts,
 						 GSM_PCHAN_TCH_F_TCH_H_PDCH,
-						 GSM_PCHAN_TCH_F, log);
+						 GSM_PCHAN_TCH_F, log, use_desc_alloc);
 			if (lchan)
 				type = GSM_LCHAN_TCH_F;
 		}
 		break;
 	case GSM_LCHAN_TCH_H:
-		lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H, log);
+		lchan = _lc_find_bts(bts, GSM_PCHAN_TCH_H, log, use_desc_alloc);
 		/* No dedicated TCH/x available -- try fully dynamic
 		 * TCH/F_TCH/H_PDCH */
 		if (!lchan) {
 			lchan = _lc_dyn_find_bts(bts,
 						 GSM_PCHAN_TCH_F_TCH_H_PDCH,
-						 GSM_PCHAN_TCH_H, log);
+						 GSM_PCHAN_TCH_H, log, use_desc_alloc);
 			if (lchan)
 				type = GSM_LCHAN_TCH_H;
 		}
@@ -264,7 +281,7 @@
 {
 	struct gsm_lchan *lchan = NULL;
 
-	lchan = lchan_avail_by_type(bts, type, true);
+	lchan = lchan_avail_by_type(bts, type, true, 0);
 
 	LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_select_by_type(%s)\n", gsm_lchant_name(type));
 
@@ -277,3 +294,28 @@
 
 	return lchan;
 }
+
+
+
+struct gsm_lchan *lchan_select_by_chan_mode2(struct gsm_bts *bts,
+					    enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate, struct gsm_lchan* old_lchan)
+{
+	enum gsm_chan_t type = chan_mode_to_chan_type(chan_mode, chan_rate);
+	struct gsm_lchan *lchan = NULL;
+
+	if (type == GSM_LCHAN_NONE)
+		return NULL;
+
+	lchan = lchan_avail_by_type(bts, type, true, old_lchan);
+
+	LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_select_by_type2(%s)\n", gsm_lchant_name(type));
+
+	if (lchan) {
+		lchan->type = type;
+		LOG_LCHAN(lchan, LOGL_INFO, "Selected\n");
+	} else
+		LOG_BTS(bts, DRLL, LOGL_NOTICE, "Failed to select %s channel\n",
+			gsm_lchant_name(type));
+
+	return lchan;
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/24646
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I4ef37874807ebd26a14616fa49498e6ab124b07b
Gerrit-Change-Number: 24646
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210610/c22c1e9b/attachment.htm>


More information about the gerrit-log mailing list