summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Stumpf <sebastian.stumpf87@googlemail.com>2017-02-26 14:43:01 +0100
committerHarald Welte <laforge@gnumonks.org>2017-07-12 23:26:26 +0200
commit360de6bead3b1eaa897a55b8d8436c5613b7d100 (patch)
tree219dcbaa6d680907ef75583e43ce256cf9b459e7 /src
parent2dfe6031177b87eb602e248571e949ac65200f70 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/host/virt_phy/include/virtphy/l1ctl_sap.h2
-rw-r--r--src/host/virt_phy/src/Makefile.am2
-rw-r--r--src/host/virt_phy/src/gsmtapl1_if.c5
-rw-r--r--src/host/virt_phy/src/l1ctl_sap.c66
-rw-r--r--src/host/virt_phy/src/l1ctl_sock.c2
-rw-r--r--src/host/virt_phy/src/virt_prim_data.c98
-rw-r--r--src/host/virt_phy/src/virt_prim_traffic.c92
-rw-r--r--src/host/virt_phy/src/virtphy.c2
8 files changed, 202 insertions, 67 deletions
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index c11c5fe4..b82745c8 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 fd8d5d97..ae14ef6f 100644
--- a/src/host/virt_phy/src/Makefile.am
+++ b/src/host/virt_phy/src/Makefile.am
@@ -4,7 +4,7 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_srcdir)/../layer2
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 3762cdc2..6ab9edc7 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -146,6 +146,11 @@ void gsmtapl1_tx_to_virt_um(struct msgb *msg)
}
/**
+ * @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 6e42e5d9..1fb4a428 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -41,6 +41,8 @@ void l1ctl_sap_init(struct l1_model_ms *model)
l1_model_ms = model;
prim_rach_init(model);
prim_fbsb_init(model);
+ prim_data_init(model);
+ prim_traffic_init(model);
}
/**
@@ -375,40 +377,6 @@ void l1ctl_rx_param_req(struct msgb *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.
- */
-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 --
@@ -584,36 +552,6 @@ void l1ctl_rx_neigh_pm_req(struct msgb *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->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);
-}
-
-/**
* @brief Handler for received L1CTL_SIM_REQ from L23.
*
* -- sim request --
diff --git a/src/host/virt_phy/src/l1ctl_sock.c b/src/host/virt_phy/src/l1ctl_sock.c
index c28da607..ada251c3 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -82,7 +82,7 @@ static int l1ctl_sock_data_cb(struct osmo_fd *ofd, unsigned int what)
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 00000000..25036ccb
--- /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@mirider.augusta.de>
+ * (C) 2010 by Harald Welte <laforge@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 00000000..56609455
--- /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@mirider.augusta.de>
+ * (C) 2010 by Harald Welte <laforge@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 c9e7bdd3..70265a05 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -44,7 +44,7 @@ int main( int argc, char *argv[] )
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)