Change in osmocom-bb[master]: virtphy: Delay response between L1SAP_PM_REQ and L1SAP_PM_CONF

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

laforge gerrit-no-reply at lists.osmocom.org
Tue Mar 10 20:58:52 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/17448 )

Change subject: virtphy: Delay response between L1SAP_PM_REQ and L1SAP_PM_CONF
......................................................................

virtphy: Delay response between L1SAP_PM_REQ and L1SAP_PM_CONF

Change-Id: I443b5512c4966c232107aeb73e1fd8b83335d63d
---
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/src/virt_prim_pm.c
2 files changed, 29 insertions(+), 10 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/host/virt_phy/include/virtphy/virt_l1_model.h b/src/host/virt_phy/include/virtphy/virt_l1_model.h
index 99ad39f..ffed708 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -100,6 +100,12 @@
 			uint8_t arfcn_sig_lev_red_dbm[1024];
 			struct osmo_timer_list arfcn_sig_lev_timers[1024];
 		} meas;
+		struct {
+			uint16_t band_arfcn_from;
+			uint16_t band_arfcn_to;
+			/* timer between receiving PM_REQ and responding with PM_CONF */
+			struct osmo_timer_list timer;
+		} req;
 	} pm;
 };
 
diff --git a/src/host/virt_phy/src/virt_prim_pm.c b/src/host/virt_phy/src/virt_prim_pm.c
index 6d11f49..561f6ce 100644
--- a/src/host/virt_phy/src/virt_prim_pm.c
+++ b/src/host/virt_phy/src/virt_prim_pm.c
@@ -84,25 +84,36 @@
 	struct l1_state_ms *l1s = &ms->state;
 	struct l1ctl_hdr *l1h = (struct l1ctl_hdr *) msg->data;
 	struct l1ctl_pm_req *pm_req = (struct l1ctl_pm_req *) l1h->data;
+
+	/* just parse the data from the request here */
+	l1s->pm.req.band_arfcn_from = ntohs(pm_req->range.band_arfcn_from);
+	l1s->pm.req.band_arfcn_to = ntohs(pm_req->range.band_arfcn_to);
+
+	LOGPMS(DL1C, LOGL_INFO, ms, "Rx L1CTL_PM_REQ TYPE=%u, FROM=%d, TO=%d\n",
+		pm_req->type, l1s->pm.req.band_arfcn_from, l1s->pm.req.band_arfcn_to);
+
+	/* generating the response will happen delayed in a timer, as otherwise
+	 * we will respond too fast, and 'mobile' will run havoc in a busy loop issuing
+	 * endless PM_REQ until a cell eventually isfound */
+	osmo_timer_schedule(&l1s->pm.req.timer, 0, 300000);
+}
+
+static void pm_conf_timer_cb(void *data)
+{
+	struct l1_model_ms *ms = data;
+	struct l1_state_ms *l1s = &ms->state;
 	struct msgb *resp_msg = l1ctl_msgb_alloc(L1CTL_PM_CONF);
 	uint16_t arfcn_next;
 
-	/* convert to host order */
-	pm_req->range.band_arfcn_from = ntohs(pm_req->range.band_arfcn_from);
-	pm_req->range.band_arfcn_to = ntohs(pm_req->range.band_arfcn_to);
-
-	LOGPMS(DL1C, LOGL_INFO, ms, "Rx L1CTL_PM_REQ TYPE=%u, FROM=%d, TO=%d\n",
-		pm_req->type, pm_req->range.band_arfcn_from, pm_req->range.band_arfcn_to);
-
-	for (arfcn_next = pm_req->range.band_arfcn_from;
-	     arfcn_next <= pm_req->range.band_arfcn_to; ++arfcn_next) {
+	for (arfcn_next = l1s->pm.req.band_arfcn_from;
+	     arfcn_next <= l1s->pm.req.band_arfcn_to; ++arfcn_next) {
 		struct l1ctl_pm_conf *pm_conf = (struct l1ctl_pm_conf *) msgb_put(resp_msg, sizeof(*pm_conf));
 		pm_conf->band_arfcn = htons(arfcn_next);
 		/* set min and max to the value calculated for that
 		 * arfcn (IGNORE UPLINKK AND  PCS AND OTHER FLAGS) */
 		pm_conf->pm[0] = dbm2rxlev(l1s->pm.meas.arfcn_sig_lev_dbm[arfcn_next & ARFCN_NO_FLAGS_MASK]);
 		pm_conf->pm[1] = dbm2rxlev(l1s->pm.meas.arfcn_sig_lev_dbm[arfcn_next & ARFCN_NO_FLAGS_MASK]);
-		if (arfcn_next == pm_req->range.band_arfcn_to) {
+		if (arfcn_next == l1s->pm.req.band_arfcn_to) {
 			struct l1ctl_hdr *resp_l1h = msgb_l1(resp_msg);
 			resp_l1h->flags |= L1CTL_F_DONE;
 		}
@@ -137,6 +148,7 @@
 		l1s->pm.meas.arfcn_sig_lev_timers[i].cb = prim_pm_timer_cb;
 		l1s->pm.meas.arfcn_sig_lev_timers[i].data = &l1s->pm.meas.arfcn_sig_lev_dbm[i];
 	}
+	osmo_timer_setup(&l1s->pm.req.timer, pm_conf_timer_cb, model);
 }
 
 void prim_pm_exit(struct l1_model_ms *model)
@@ -146,4 +158,5 @@
 
 	for (i = 0; i < 1024; ++i)
 		osmo_timer_del(&l1s->pm.meas.arfcn_sig_lev_timers[i]);
+	osmo_timer_del(&l1s->pm.req.timer);
 }

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I443b5512c4966c232107aeb73e1fd8b83335d63d
Gerrit-Change-Number: 17448
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200310/7ec516bf/attachment.htm>


More information about the gerrit-log mailing list