[PATCH] osmocom-bb[master]: VIRT-PHY: Data and traffic req from l23 now use scheduler.

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 12 21:20:47 UTC 2017


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

VIRT-PHY: Data and traffic req from l23 now use scheduler.

Msgs are not put on virt um directly in the handler like before, but are
scheduled. FN they are scheduled with not yet properly calculated.

Also, code was extracted from lactl_sap.c into own files.

Change-Id: Ibe57abebadf294f1407d82cef3fd0b51e7c1b23e
---
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/src/Makefile.am
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/l1ctl_sock.c
A src/host/virt_phy/src/virt_prim_data.c
A src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
8 files changed, 202 insertions(+), 67 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/06/3206/1

diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index c11c5fe..b82745c 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -20,6 +20,8 @@
 
 void l1ctl_sap_init(struct l1_model_ms *model);
 void prim_rach_init(struct l1_model_ms *model);
+void prim_data_init(struct l1_model_ms *model);
+void prim_traffic_init(struct l1_model_ms *model);
 void prim_fbsb_init(struct l1_model_ms *model);
 void l1ctl_sap_tx_to_l23_inst(struct l1ctl_sock_inst *lsi, struct msgb *msg);
 void l1ctl_sap_tx_to_l23(struct msgb *msg);
diff --git a/src/host/virt_phy/src/Makefile.am b/src/host/virt_phy/src/Makefile.am
index fd8d5d9..ae14ef6 100644
--- a/src/host/virt_phy/src/Makefile.am
+++ b/src/host/virt_phy/src/Makefile.am
@@ -4,7 +4,7 @@
 CFLAGS = "-g -O0"
 
 sbin_PROGRAMS = virtphy
-virtphy_SOURCES = virtphy.c l1ctl_sock.c gsmtapl1_if.c l1ctl_sap.c virt_prim_fbsb.c virt_prim_rach.c virt_l1_sched_simple.c logging.c virt_l1_model.c shared/virtual_um.c shared/osmo_mcast_sock.c
+virtphy_SOURCES = virtphy.c l1ctl_sock.c gsmtapl1_if.c l1ctl_sap.c virt_prim_fbsb.c virt_prim_rach.c virt_prim_data.c virt_prim_traffic.c virt_l1_sched_simple.c logging.c virt_l1_model.c shared/virtual_um.c shared/osmo_mcast_sock.c
 virtphy_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) 
 virtphy_LDFLAGS = -pthread
 
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c b/src/host/virt_phy/src/gsmtapl1_if.c
index 3762cdc..6ab9edc 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -146,6 +146,11 @@
 }
 
 /**
+ * @see virt_prim_fbsb.c
+ */
+extern void prim_fbsb_sync(struct msgb *msg);
+
+/**
  * Receive a gsmtap message from the virt um.
  */
 void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui,
diff --git a/src/host/virt_phy/src/l1ctl_sap.c b/src/host/virt_phy/src/l1ctl_sap.c
index 6e42e5d..1fb4a42 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -41,6 +41,8 @@
 	l1_model_ms = model;
 	prim_rach_init(model);
 	prim_fbsb_init(model);
+	prim_data_init(model);
+	prim_traffic_init(model);
 }
 
 /**
@@ -375,40 +377,6 @@
 }
 
 /**
- * @brief Handler for received L1CTL_DATA_REQ from L23.
- *
- * -- data request --
- *
- * @param [in] msg the received message.
- *
- * Transmit message on a signalling channel. FACCH/SDCCH or SACCH depending on the headers set link id (TS 8.58 - 9.3.2).
- *
- * TODO: Check if a msg on FACCH is coming in here and needs special handling.
- */
-void l1ctl_rx_data_req(struct msgb *msg)
-{
-	struct l1ctl_hdr *l1h = (struct l1ctl_hdr *)msg->data;
-	struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
-	struct l1ctl_data_ind *data_ind = (struct l1ctl_data_ind *)ul->payload;
-	// TODO: calc the scheduled fn
-	uint32_t fn_sched = l1_model_ms->state->downlink_time.fn;
-
-	DEBUGP(DL1C,
-	                "Received and handled from l23 - L1CTL_DATA_REQ (link_id=0x%02x, ul=%p, ul->payload=%p, data_ind=%p, data_ind->data=%p l3h=%p)\n",
-	                ul->link_id, ul, ul->payload, data_ind, data_ind->data,
-	                msg->l3h);
-
-	msg->l2h = data_ind->data;
-
-	// TODO: append to scheduler queue instead of sending here directly
-	gsmtapl1_tx_to_virt_um(msg);
-
-	// send confirm to layer23
-	msg = l1ctl_create_l2_msg(L1CTL_DATA_CONF, fn_sched, 0, 0);
-	l1ctl_sap_tx_to_l23(msg);
-}
-
-/**
  * @brief Handler for received L1CTL_PM_REQ from L23.
  *
  * -- power measurement request --
@@ -581,36 +549,6 @@
 	DEBUGP(DL1C,
 	                "Received and ignored from l23 - L1CTL_NEIGH_PM_REQ new list with %u entries\n",
 	                pm_req->n);
-}
-
-/**
- * @brief Handler for received L1CTL_TRAFFIC_REQ from L23.
- *
- * -- traffic request --
- *
- * @param [in] msg the received message.
- *
- * Enqueue the message (traffic frame) to the L1 state machine's transmit queue. In virtual layer1 just submit it to the virt um.
- *
- */
-void l1ctl_rx_traffic_req(struct msgb *msg)
-{
-	struct l1ctl_hdr *l1h = (struct l1ctl_hdr *)msg->data;
-	struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
-	struct l1ctl_traffic_req *tr = (struct l1ctl_traffic_req *)ul->payload;
-	// TODO: calc the scheduled fn
-	uint32_t fn_sched = l1_model_ms->state->downlink_time.fn;
-
-	DEBUGP(DL1C, "Received and handled from l23 - L1CTL_TRAFFIC_REQ\n");
-
-	msg->l2h = tr->data;
-
-	// TODO: append to scheduler queue instead of sending here directly
-	gsmtapl1_tx_to_virt_um(msg);
-
-	// send confirm to layer23
-	msg = l1ctl_create_l2_msg(L1CTL_TRAFFIC_CONF, fn_sched, 0, 0);
-	l1ctl_sap_tx_to_l23(msg);
 }
 
 /**
diff --git a/src/host/virt_phy/src/l1ctl_sock.c b/src/host/virt_phy/src/l1ctl_sock.c
index c28da60..ada251c 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -82,7 +82,7 @@
 
 		if (rc == len) {
 			msgb_put(msg, rc);
-			l1h = msgb_data(msg);
+			l1h = (void *) msgb_data(msg);
 			msg->l1h = l1h;
 			lsi->recv_cb(lsi, msg);
 			return 0;
diff --git a/src/host/virt_phy/src/virt_prim_data.c b/src/host/virt_phy/src/virt_prim_data.c
new file mode 100644
index 0000000..25036cc
--- /dev/null
+++ b/src/host/virt_phy/src/virt_prim_data.c
@@ -0,0 +1,98 @@
+/* Layer 1 normal data burst tx handling */
+
+/* (C) 2010 by Dieter Spaar <spaar at mirider.augusta.de>
+ * (C) 2010 by Harald Welte <laforge at gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_08_58.h>
+#include <osmocom/core/msgb.h>
+#include <virtphy/l1ctl_sap.h>
+#include <virtphy/virt_l1_sched.h>
+#include <virtphy/logging.h>
+#include <virtphy/gsmtapl1_if.h>
+
+#include <l1ctl_proto.h>
+
+static struct l1_model_ms *l1_model_ms = NULL;
+static void virt_l1_sched_handler_cb(struct msgb * msg);
+
+/**
+ * @brief Handler callback function for DATA request.
+ *
+ * @param [in] msg the msg to sent over virtual um.
+ */
+static void virt_l1_sched_handler_cb(struct msgb * msg)
+{
+	gsmtapl1_tx_to_virt_um(msg);
+	// send confirm to layer23
+	// FIXME: as we might send multiple burst, the base fn may be another one than the current
+	msg = l1ctl_create_l2_msg(L1CTL_DATA_CONF, l1_model_ms->state->current_time.fn, 0, 0);
+	l1ctl_sap_tx_to_l23(msg);
+}
+
+/**
+ * @brief Handler for received L1CTL_DATA_REQ from L23.
+ *
+ * -- data request --
+ *
+ * @param [in] msg the received message.
+ *
+ * Transmit message on a signalling channel. FACCH/SDCCH or SACCH depending on the headers set link id (TS 8.58 - 9.3.2).
+ *
+ * TODO: Check if a msg on FACCH is coming in here and needs special handling.
+ * TODO: Check if msg contains data of a burst or data of 4 bursts!
+ */
+void l1ctl_rx_data_req(struct msgb *msg)
+{
+	struct l1ctl_hdr *l1h = (struct l1ctl_hdr *)msg->data;
+	struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
+	struct l1ctl_data_ind *data_ind = (struct l1ctl_data_ind *)ul->payload;
+	// TODO: calc the scheduled fn
+	uint32_t fn_sched = l1_model_ms->state->current_time.fn;
+	uint8_t rsl_chantype, subslot, timeslot;
+	rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, &timeslot);
+
+
+	DEBUGP(DL1C,
+	                "Received and handled from l23 - L1CTL_DATA_REQ (link_id=0x%02x, ul=%p, ul->payload=%p, data_ind=%p, data_ind->data=%p l3h=%p)\n",
+	                ul->link_id, ul, ul->payload, data_ind, data_ind->data,
+	                msg->l3h);
+
+	msg->l2h = data_ind->data;
+
+	virt_l1_sched_schedule(msg, fn_sched, timeslot, &virt_l1_sched_handler_cb);
+
+}
+
+/**
+ * @brief Initialize virtual prim data.
+ *
+ * @param [in] model the l1 model instance
+ */
+void prim_data_init(struct l1_model_ms *model)
+{
+	l1_model_ms = model;
+}
diff --git a/src/host/virt_phy/src/virt_prim_traffic.c b/src/host/virt_phy/src/virt_prim_traffic.c
new file mode 100644
index 0000000..5660945
--- /dev/null
+++ b/src/host/virt_phy/src/virt_prim_traffic.c
@@ -0,0 +1,92 @@
+/* Layer 1 normal data burst tx handling */
+
+/* (C) 2010 by Dieter Spaar <spaar at mirider.augusta.de>
+ * (C) 2010 by Harald Welte <laforge at gnumonks.org>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_08_58.h>
+#include <osmocom/core/msgb.h>
+#include <virtphy/l1ctl_sap.h>
+#include <virtphy/virt_l1_sched.h>
+#include <virtphy/logging.h>
+#include <virtphy/gsmtapl1_if.h>
+
+#include <l1ctl_proto.h>
+
+static struct l1_model_ms *l1_model_ms = NULL;
+static void virt_l1_sched_handler_cb(struct msgb * msg);
+
+/**
+ * @brief Handler callback function for TRAFFIC request.
+ *
+ * @param [in] msg the msg to sent over virtual um.
+ */
+static void virt_l1_sched_handler_cb(struct msgb * msg)
+{
+	gsmtapl1_tx_to_virt_um(msg);
+	// send confirm to layer23
+	msg = l1ctl_create_l2_msg(L1CTL_TRAFFIC_CONF,
+	                          l1_model_ms->state->current_time.fn, 0, 0);
+	l1ctl_sap_tx_to_l23(msg);
+}
+
+/**
+ * @brief Handler for received L1CTL_TRAFFIC_REQ from L23.
+ *
+ * -- traffic request --
+ *
+ * @param [in] msg the received message.
+ *
+ * Enqueue the message (traffic frame) to the L1 state machine's transmit queue. In virtual layer1 just submit it to the virt um.
+ *
+ */
+void l1ctl_rx_traffic_req(struct msgb *msg)
+{
+	struct l1ctl_hdr *l1h = (struct l1ctl_hdr *)msg->data;
+	struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
+	struct l1ctl_traffic_req *tr = (struct l1ctl_traffic_req *)ul->payload;
+	// TODO: calc the scheduled fn
+	uint32_t fn_sched = l1_model_ms->state->current_time.fn;
+	uint8_t rsl_chantype, subslot, timeslot;
+	rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, &timeslot);
+
+	DEBUGP(DL1C, "Received and handled from l23 - L1CTL_TRAFFIC_REQ\n");
+
+	msg->l2h = tr->data;
+
+	virt_l1_sched_schedule(msg, fn_sched, timeslot,
+	                       &virt_l1_sched_handler_cb);
+}
+
+/**
+ * @brief Initialize virtual prim traffic.
+ *
+ * @param [in] model the l1 model instance
+ */
+void prim_traffic_init(struct l1_model_ms *model)
+{
+	l1_model_ms = model;
+}
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index c9e7bdd..70265a0 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -44,7 +44,7 @@
 	virt_l1_sched_init(model);
 
 	LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer ready...\n \
-			Waiting for l23 app on", l1ctl_sock_path);
+			Waiting for l23 app on %s", l1ctl_sock_path);
 
 	while (1) {
 		// handle osmocom fd READ events (l1ctl-unix-socket, virtual-um-mcast-socket)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe57abebadf294f1407d82cef3fd0b51e7c1b23e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: BastusIII <sebastian.stumpf87 at googlemail.com>



More information about the gerrit-log mailing list