Change in osmo-bsc[master]: bsc_vty: add features to shun specific lchans

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Jan 17 17:28:58 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/12624


Change subject: bsc_vty: add features to shun specific lchans
......................................................................

bsc_vty: add features to shun specific lchans

In some test and debug situations it is useful to have the ability to
lock certain lchans in a way that the BSC can not allocate them. One
application might be to simulate an exhaustion of all TCH/H channels in
order to force the BSC to take one of the available TCH/F.

Lets add a command to the vty which alloes us to mark certain lchans as
shunned and check that condition while doing the channel allocation

Change-Id: I397e68e26d6a1727890353fa34f4897b54795866
Related: OS#3503
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bsc_vty.c
M src/osmo-bsc/lchan_fsm.c
M src/osmo-bsc/lchan_select.c
4 files changed, 72 insertions(+), 19 deletions(-)



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

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 9f7ce8d..22d80df 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -613,6 +613,10 @@
 	struct gsm48_req_ref *rqd_ref;
 
 	struct gsm_subscriber_connection *conn;
+
+	/* Debug feature: When set to true via VTY, the channel allocator will
+	 * not use this lchan. */
+	bool shun;
 };
 
 /* One Timeslot in a TRX */
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index 791aebe..ed93dcb 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -1372,10 +1372,11 @@
 		lchan->ts->trx->bts->nr, lchan->ts->trx->nr, lchan->ts->nr,
 		lchan->nr, gsm_lchant_name(lchan->type), VTY_NEWLINE);
 	vty_out_dyn_ts_details(vty, lchan->ts);
-	vty_out(vty, "  Connection: %u, State: %s%s%s%s",
+	vty_out(vty, "  Connection: %u, State: %s%s%s%s%s",
 		lchan->conn ? 1: 0, lchan_state_name(lchan),
 		lchan->fi && lchan->fi->state == LCHAN_ST_BORKEN ? " Error reason: " : "",
 		lchan->fi && lchan->fi->state == LCHAN_ST_BORKEN ? lchan->last_error : "",
+		lchan->shun ? " (shunned)" : "",
 		VTY_NEWLINE);
 	vty_out(vty, "  BS Power: %u dBm, MS Power: %u dBm%s",
 		lchan->ts->trx->nominal_power - lchan->ts->trx->max_power_red
@@ -1430,22 +1431,24 @@
 		gsm_pchan_name(lchan->ts->pchan_on_init));
 	vty_out_dyn_ts_status(vty, lchan->ts);
 	vty_out(vty, ", Lchan %u, Type %s, State %s - "
-		"L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s",
+		"L1 MS Power: %u dBm RXL-FULL-dl: %4d dBm RXL-FULL-ul: %4d dBm%s%s",
 		lchan->nr,
 		gsm_lchant_name(lchan->type), lchan_state_name(lchan),
 		mr->ms_l1.pwr,
 		rxlev2dbm(mr->dl.full.rx_lev),
 		rxlev2dbm(mr->ul.full.rx_lev),
+		lchan->shun ? " (shunned)" : "",
 		VTY_NEWLINE);
 }
 
 
 static int dump_lchan_trx_ts(struct gsm_bts_trx_ts *ts, struct vty *vty,
-			     void (*dump_cb)(struct vty *, struct gsm_lchan *))
+			     void (*dump_cb)(struct vty *, struct gsm_lchan *),
+			     bool all)
 {
 	struct gsm_lchan *lchan;
 	ts_for_each_lchan(lchan, ts) {
-		if (lchan_state_is(lchan, LCHAN_ST_UNUSED))
+		if (lchan_state_is(lchan, LCHAN_ST_UNUSED) && all == false)
 			continue;
 		dump_cb(vty, lchan);
 	}
@@ -1454,33 +1457,36 @@
 }
 
 static int dump_lchan_trx(struct gsm_bts_trx *trx, struct vty *vty,
-			  void (*dump_cb)(struct vty *, struct gsm_lchan *))
+			  void (*dump_cb)(struct vty *, struct gsm_lchan *),
+			  bool all)
 {
 	int ts_nr;
 
 	for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
 		struct gsm_bts_trx_ts *ts = &trx->ts[ts_nr];
-		dump_lchan_trx_ts(ts, vty, dump_cb);
+		dump_lchan_trx_ts(ts, vty, dump_cb, all);
 	}
 
 	return CMD_SUCCESS;
 }
 
 static int dump_lchan_bts(struct gsm_bts *bts, struct vty *vty,
-			  void (*dump_cb)(struct vty *, struct gsm_lchan *))
+			  void (*dump_cb)(struct vty *, struct gsm_lchan *),
+			  bool all)
 {
 	int trx_nr;
 
 	for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
 		struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_nr);
-		dump_lchan_trx(trx, vty, dump_cb);
+		dump_lchan_trx(trx, vty, dump_cb, all);
 	}
 
 	return CMD_SUCCESS;
 }
 
 static int lchan_summary(struct vty *vty, int argc, const char **argv,
-			 void (*dump_cb)(struct vty *, struct gsm_lchan *))
+			 void (*dump_cb)(struct vty *, struct gsm_lchan *),
+			 bool all)
 {
 	struct gsm_network *net = gsmnet_from_vty(vty);
 	struct gsm_bts *bts = NULL;
@@ -1500,7 +1506,7 @@
 		bts = gsm_bts_num(net, bts_nr);
 
 		if (argc == 1)
-			return dump_lchan_bts(bts, vty, dump_cb);
+			return dump_lchan_bts(bts, vty, dump_cb, all);
 	}
 	if (argc >= 2) {
 		trx_nr = atoi(argv[1]);
@@ -1512,7 +1518,7 @@
 		trx = gsm_bts_trx_num(bts, trx_nr);
 
 		if (argc == 2)
-			return dump_lchan_trx(trx, vty, dump_cb);
+			return dump_lchan_trx(trx, vty, dump_cb, all);
 	}
 	if (argc >= 3) {
 		ts_nr = atoi(argv[2]);
@@ -1524,7 +1530,7 @@
 		ts = &trx->ts[ts_nr];
 
 		if (argc == 3)
-			return dump_lchan_trx_ts(ts, vty, dump_cb);
+			return dump_lchan_trx_ts(ts, vty, dump_cb, all);
 	}
 	if (argc >= 4) {
 		lchan_nr = atoi(argv[3]);
@@ -1541,7 +1547,7 @@
 
 	for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
 		bts = gsm_bts_num(net, bts_nr);
-		dump_lchan_bts(bts, vty, dump_cb);
+		dump_lchan_bts(bts, vty, dump_cb, all);
 	}
 
 	return CMD_SUCCESS;
@@ -1554,17 +1560,27 @@
 	SHOW_STR "Display information about a logical channel\n"
 	BTS_TRX_TS_LCHAN_STR)
 {
-	return lchan_summary(vty, argc, argv, lchan_dump_full_vty);
+	return lchan_summary(vty, argc, argv, lchan_dump_full_vty, true);
 }
 
 DEFUN(show_lchan_summary,
       show_lchan_summary_cmd,
       "show lchan summary [<0-255>] [<0-255>] [<0-7>] [<0-7>]",
 	SHOW_STR "Display information about a logical channel\n"
-        "Short summary\n"
+        "Short summary (in use lchans)\n"
 	BTS_TRX_TS_LCHAN_STR)
 {
-	return lchan_summary(vty, argc, argv, lchan_dump_short_vty);
+	return lchan_summary(vty, argc, argv, lchan_dump_short_vty, false);
+}
+
+DEFUN(show_lchan_all,
+      show_lchan_all_cmd,
+      "show lchan all [<0-255>] [<0-255>] [<0-7>] [<0-7>]",
+	SHOW_STR "Display information about a logical channel\n"
+        "Short summary (all lchans)\n"
+	BTS_TRX_TS_LCHAN_STR)
+{
+	return lchan_summary(vty, argc, argv, lchan_dump_short_vty, true);
 }
 
 static void dump_one_subscr_conn(struct vty *vty, const struct gsm_subscriber_connection *conn)
@@ -4774,6 +4790,34 @@
 	return CMD_SUCCESS;
 }
 
+/* Debug command to temporarily disable certain timeslots in order to force
+ * the channel allocator to pick one specific or from a group of specific
+ * timeslots. */
+DEFUN(ts_shun, ts_shun_cmd,
+	"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> (shun|allow)",
+	BTS_NR_TRX_TS_SS_STR2
+	"Avoid channel allocation on timeslot (for debugging)\n"
+	"Allow channel allocation on timeslot (take back shunning, for debugging)\n")
+{
+	struct gsm_bts_trx_ts *ts;
+	struct gsm_lchan *lchan;
+	int ss_nr = atoi(argv[3]);
+	ts = vty_get_ts(vty, argv[0], argv[1], argv[2]);
+	if (!ts)
+		return CMD_WARNING;
+	lchan = &ts->lchan[ss_nr];
+	if (!lchan)
+		return CMD_WARNING;
+
+	if (!strcmp(argv[4], "shun"))
+		lchan->shun = true;
+	else
+		lchan->shun = false;
+
+	return CMD_SUCCESS;
+}
+
+
 DEFUN(lchan_mdcx, lchan_mdcx_cmd,
 	"bts <0-255> trx <0-255> timeslot <0-7> sub-slot <0-7> mdcx A.B.C.D <0-65535>",
 	BTS_NR_TRX_TS_SS_STR2
@@ -5085,6 +5129,7 @@
 	install_element_ve(&show_ts_cmd);
 	install_element_ve(&show_lchan_cmd);
 	install_element_ve(&show_lchan_summary_cmd);
+	install_element_ve(&show_lchan_all_cmd);
 
 	install_element_ve(&show_subscr_conn_cmd);
 
@@ -5249,6 +5294,8 @@
 	install_element(ENABLE_NODE, &pdch_act_cmd);
 	install_element(ENABLE_NODE, &lchan_act_cmd);
 	install_element(ENABLE_NODE, &lchan_mdcx_cmd);
+	install_element(ENABLE_NODE, &ts_shun_cmd);
+
 	install_element(ENABLE_NODE, &handover_subscr_conn_cmd);
 	install_element(ENABLE_NODE, &assignment_subscr_conn_cmd);
 	install_element(ENABLE_NODE, &smscb_cmd_cmd);
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index f344cf9..c3b0017 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -400,6 +400,7 @@
 		.meas_rep_last_seen_nr = 255,
 
 		.last_error = lchan->last_error,
+		.shun = lchan->shun,
 	};
 }
 
diff --git a/src/osmo-bsc/lchan_select.c b/src/osmo-bsc/lchan_select.c
index eac0adf..4edf748 100644
--- a/src/osmo-bsc/lchan_select.c
+++ b/src/osmo-bsc/lchan_select.c
@@ -80,16 +80,17 @@
 
 		/* TS is (going to be) in desired pchan mode. Go ahead and check for an available lchan. */
 		ts_as_pchan_for_each_lchan(lchan, ts, as_pchan) {
-			if (lchan->fi->state == LCHAN_ST_UNUSED) {
+			if (lchan->fi->state == LCHAN_ST_UNUSED && lchan->shun == false) {
 				LOGPLCHANALLOC("%s ss=%d is available%s\n",
 					       gsm_ts_and_pchan_name(ts), lchan->nr,
 					       ts->pchan_is != as_pchan ? " after dyn PCHAN change" : "");
 				return lchan;
 			}
-			LOGPLCHANALLOC("%s ss=%d in type=%s,state=%s not suitable\n",
+
+			LOGPLCHANALLOC("%s ss=%d in type=%s,state=%s %s\n",
 				       gsm_ts_and_pchan_name(ts), lchan->nr,
 				       gsm_lchant_name(lchan->type),
-				       osmo_fsm_inst_state_name(lchan->fi));
+				       osmo_fsm_inst_state_name(lchan->fi), lchan->shun ? "shunned" : "not suitable");
 		}
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/12624
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I397e68e26d6a1727890353fa34f4897b54795866
Gerrit-Change-Number: 12624
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190117/1e15faf3/attachment.htm>


More information about the gerrit-log mailing list