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
This commit is contained in:
Sebastian Stumpf 2017-02-26 14:43:01 +01:00 committed by Harald Welte
parent 2dfe603117
commit 360de6bead
8 changed files with 202 additions and 67 deletions

View File

@ -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);

View File

@ -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

View File

@ -145,6 +145,11 @@ void gsmtapl1_tx_to_virt_um(struct msgb *msg)
gsmtapl1_tx_to_virt_um_inst(l1_model_ms->vui, msg);
}
/**
* @see virt_prim_fbsb.c
*/
extern void prim_fbsb_sync(struct msgb *msg);
/**
* Receive a gsmtap message from the virt um.
*/

View File

@ -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);
}
/**
@ -374,40 +376,6 @@ void l1ctl_rx_param_req(struct msgb *msg)
par_req->ta, par_req->tx_power);
}
/**
* @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.
*
@ -583,36 +551,6 @@ void l1ctl_rx_neigh_pm_req(struct msgb *msg)
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);
}
/**
* @brief Handler for received L1CTL_SIM_REQ from L23.
*

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)