[PATCH] osmo-bsc[master]: Move channel state assignment to macro

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/.

Max gerrit-no-reply at lists.osmocom.org
Tue Sep 5 11:33:33 UTC 2017


Review at  https://gerrit.osmocom.org/3828

Move channel state assignment to macro

Previously we've used function so debug print always pointed to the same
place which is not very useful. Replace it with macro so proper
file:line is printed. Also, make sure that we always change state only
through this macro.

Change-Id: I21789f8021290965b61a54a2b23177ccbbfe8321
---
M include/openbsc/abis_rsl.h
M src/libbsc/abis_rsl.c
M src/libbsc/bsc_api.c
M src/libbsc/chan_alloc.c
M src/libbsc/handover_logic.c
5 files changed, 20 insertions(+), 23 deletions(-)


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

diff --git a/include/openbsc/abis_rsl.h b/include/openbsc/abis_rsl.h
index f983fce..ecab0fe 100644
--- a/include/openbsc/abis_rsl.h
+++ b/include/openbsc/abis_rsl.h
@@ -34,6 +34,13 @@
 
 #define GSM48_LEN2PLEN(a)	(((a) << 2) | 1)
 
+#define LCHAN_SET_ST(lch_, st_)										\
+	do {												\
+		DEBUGP(DRSL, "%s state %s -> %s\n",							\
+		       gsm_lchan_name(lch_), gsm_lchans_name((lch_)->state), gsm_lchans_name(st_));	\
+		(lch_)->state = st_;									\
+	} while (0)
+
 int rsl_bcch_info(const struct gsm_bts_trx *trx, enum osmo_sysinfo_type si_type, const uint8_t *data, int len);
 int rsl_sacch_filling(struct gsm_bts_trx *trx, uint8_t type,
 		      const uint8_t *data, int len);
@@ -74,7 +81,6 @@
 int rsl_release_request(struct gsm_lchan *lchan, uint8_t link_id,
 			enum rsl_rel_mode release_mode);
 
-int rsl_lchan_set_state(struct gsm_lchan *lchan, int);
 int rsl_lchan_mark_broken(struct gsm_lchan *lchan, const char *broken);
 
 /* to be provided by external code */
diff --git a/src/libbsc/abis_rsl.c b/src/libbsc/abis_rsl.c
index 75229a5..fabb47a 100644
--- a/src/libbsc/abis_rsl.c
+++ b/src/libbsc/abis_rsl.c
@@ -79,7 +79,7 @@
 		osmo_timer_schedule(&lchan->error_timer,
 				   lchan->ts->trx->bts->network->T3111 + 2, 0);
 	} else {
-		rsl_lchan_set_state(lchan, LCHAN_S_NONE);
+		LCHAN_SET_ST(lchan, LCHAN_S_NONE);
 	}
 	lchan_free(lchan);
 }
@@ -509,7 +509,7 @@
 	 * the calling code passes the correct lchan. */
 	OSMO_ASSERT(lchan == lchan->ts->lchan);
 
-	rsl_lchan_set_state(lchan, LCHAN_S_ACT_REQ);
+	LCHAN_SET_ST(lchan, LCHAN_S_ACT_REQ);
 
 	msg = rsl_msgb_alloc();
 	dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
@@ -622,7 +622,7 @@
 		return rc;
 	}
 
-	rsl_lchan_set_state(lchan, LCHAN_S_ACT_REQ);
+	LCHAN_SET_ST(lchan, LCHAN_S_ACT_REQ);
 
 	ta = lchan->rqd_ta;
 
@@ -825,7 +825,7 @@
 
 	/* go back to the none state */
 	LOGP(DRSL, LOGL_INFO, "%s is back in operation.\n", gsm_lchan_name(lchan));
-	rsl_lchan_set_state(lchan, LCHAN_S_NONE);
+	LCHAN_SET_ST(lchan, LCHAN_S_NONE);
 
 	/* Put PDCH channel back into PDCH mode, if GPRS is enabled */
 	if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH
@@ -896,7 +896,7 @@
 		/*
 		 * TODO: start T3109 now.
 		 */
-		rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR);
+		LCHAN_SET_ST(lchan, LCHAN_S_REL_ERR);
 	}
 
 	/* Start another timer or assume the BTS sends a ACK/NACK? */
@@ -1220,17 +1220,8 @@
 {
 	LOGP(DRSL, LOGL_ERROR, "%s %s lchan broken: %s\n",
 	     gsm_lchan_name(lchan), gsm_lchant_name(lchan->type), reason);
-	rsl_lchan_set_state(lchan, LCHAN_S_BROKEN);
+	LCHAN_SET_ST(lchan, LCHAN_S_BROKEN);
 	lchan->broken_reason = reason;
-	return 0;
-}
-
-int rsl_lchan_set_state(struct gsm_lchan *lchan, int state)
-{
-	DEBUGP(DRSL, "%s state %s -> %s\n",
-	       gsm_lchan_name(lchan), gsm_lchans_name(lchan->state),
-	       gsm_lchans_name(state));
-	lchan->state = state;
 	return 0;
 }
 
@@ -1257,7 +1248,7 @@
 			talloc_free(lchan->rqd_ref);
 			lchan->rqd_ref = NULL;
 			lchan->rqd_ta = 0;
-			rsl_lchan_set_state(msg->lchan, LCHAN_S_ACTIVE);
+			LCHAN_SET_ST(msg->lchan, LCHAN_S_ACTIVE);
 			if (ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH) {
 				/*
 				 * lchan_act_tmr_cb() already called
@@ -1282,7 +1273,7 @@
 		LOGP(DRSL, LOGL_NOTICE, "%s CHAN ACT ACK, but state %s\n",
 			gsm_lchan_name(lchan),
 			gsm_lchans_name(lchan->state));
-	rsl_lchan_set_state(lchan, LCHAN_S_ACTIVE);
+	LCHAN_SET_ST(lchan, LCHAN_S_ACTIVE);
 
 	if (ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)
 		dyn_ts_switchover_complete(lchan);
@@ -2614,7 +2605,7 @@
 	 * rsl_rx_rf_chan_rel_ack(). PDCH is always on lchan[0].
 	 */
 	if (ts->dyn.pchan_is == GSM_PCHAN_PDCH) {
-		rsl_lchan_set_state(ts->lchan, LCHAN_S_REL_REQ);
+		LCHAN_SET_ST(ts->lchan, LCHAN_S_REL_REQ);
 		rc = rsl_rf_chan_release(ts->lchan, 0, SACCH_NONE);
 		if (rc) {
 			LOGP(DRSL, LOGL_ERROR,
diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index a0ba69a..2c64dde 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -246,7 +246,7 @@
 	conn->secondary_lchan = new_lchan;
 	new_lchan->conn = conn;
 
-	rsl_lchan_set_state(new_lchan, LCHAN_S_ACT_REQ);
+	LCHAN_SET_ST(new_lchan, LCHAN_S_ACT_REQ);
 	return 0;
 }
 
diff --git a/src/libbsc/chan_alloc.c b/src/libbsc/chan_alloc.c
index 4192d65..8d31dcf 100644
--- a/src/libbsc/chan_alloc.c
+++ b/src/libbsc/chan_alloc.c
@@ -448,7 +448,7 @@
 	osmo_timer_del(&lchan->error_timer);
 
 	lchan->type = GSM_LCHAN_NONE;
-	lchan->state = LCHAN_S_NONE;
+	LCHAN_SET_ST(lchan, LCHAN_S_NONE);
 
 	if (lchan->abis_ip.rtp_socket) {
 		rtp_socket_free(lchan->abis_ip.rtp_socket);
@@ -485,7 +485,7 @@
 int lchan_release(struct gsm_lchan *lchan, int sacch_deact, enum rsl_rel_mode mode)
 {
 	DEBUGP(DRLL, "%s starting release sequence\n", gsm_lchan_name(lchan));
-	rsl_lchan_set_state(lchan, LCHAN_S_REL_REQ);
+	LCHAN_SET_ST(lchan, LCHAN_S_REL_REQ);
 
 	lchan->conn = NULL;
 	_lchan_handle_release(lchan, sacch_deact, mode);
diff --git a/src/libbsc/handover_logic.c b/src/libbsc/handover_logic.c
index 8ced74f..5202cc9 100644
--- a/src/libbsc/handover_logic.c
+++ b/src/libbsc/handover_logic.c
@@ -152,7 +152,7 @@
 		return rc;
 	}
 
-	rsl_lchan_set_state(new_lchan, LCHAN_S_ACT_REQ);
+	LCHAN_SET_ST(new_lchan, LCHAN_S_ACT_REQ);
 	llist_add(&ho->list, &bsc_handovers);
 	/* we continue in the SS_LCHAN handler / ho_chan_activ_ack */
 

-- 
To view, visit https://gerrit.osmocom.org/3828
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21789f8021290965b61a54a2b23177ccbbfe8321
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list