[PATCH] openbsc[master]: GSM timers: User reasonable defaults; don't save if equal de...

2017-07-19 Thread Harald Welte

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

GSM timers: User reasonable defaults; don't save if equal default

A number of the GSM timers (including T3109) had no reasonable
default values if not specified in the VTY / config file.  Together
with unconditional writing to the config file, this created
config files with a persistent setting for important timers as '0'.

Let's avoid this from happening by
* having reasonable defaults if nothing specified in the config file
* conditionally savingg timers only if they differ from default
* reject any timer values that state zero during start-up (see previous
  commit)

Change-Id: Iaac0bfca423852b61d8b9eb1438157ef00d0d8c8
Closes: OS#2380
---
M openbsc/include/openbsc/gsm_data.h
M openbsc/src/libbsc/bsc_vty.c
M openbsc/src/libbsc/net_init.c
3 files changed, 35 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/06/3306/1

diff --git a/openbsc/include/openbsc/gsm_data.h 
b/openbsc/include/openbsc/gsm_data.h
index a974051..37a341c 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -289,10 +289,18 @@
GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
 };
 
-#define GSM_T3101_DEFAULT 10
-#define GSM_T3105_DEFAULT 40
+#define GSM_T3101_DEFAULT 10   /* s */
+#define GSM_T3103_DEFAULT 5/* s */
+#define GSM_T3105_DEFAULT 100  /* ms */
+#define GSM_T3107_DEFAULT 5/* s */
+#define GSM_T3109_DEFAULT 19   /* s, must be 2s + radio_link_timeout*0.48 */
+#define GSM_T3111_DEFAULT 2/* s */
 #define GSM_T3113_DEFAULT 60
+#define GSM_T3115_DEFAULT 10
+#define GSM_T3117_DEFAULT 10
+#define GSM_T3119_DEFAULT 10
 #define GSM_T3122_DEFAULT 10
+#define GSM_T3141_DEFAULT 10
 
 struct gsm_tz {
int override; /* if 0, use system's time zone instead. */
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 92b4bbb..bcd78e3 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -787,6 +787,11 @@
return CMD_SUCCESS;
 }
 
+/* small helper macro for conditional dumping of timer */
+#define VTY_OUT_TIMER(number)  \
+   if (gsmnet->T##number != GSM_T##number##_DEFAULT)   \
+   vty_out(vty, " timer t"#number" %u%s", gsmnet->T##number, 
VTY_NEWLINE)
+
 static int config_write_net(struct vty *vty)
 {
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
@@ -820,18 +825,18 @@
gsmnet->handover.pwr_hysteresis, VTY_NEWLINE);
vty_out(vty, " handover maximum distance %u%s",
gsmnet->handover.max_distance, VTY_NEWLINE);
-   vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE);
-   vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE);
-   vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE);
-   vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE);
-   vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE);
-   vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE);
-   vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE);
-   vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE);
-   vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE);
-   vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE);
-   vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE);
-   vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE);
+   VTY_OUT_TIMER(3101);
+   VTY_OUT_TIMER(3103);
+   VTY_OUT_TIMER(3105);
+   VTY_OUT_TIMER(3107);
+   VTY_OUT_TIMER(3109);
+   VTY_OUT_TIMER(3111);
+   VTY_OUT_TIMER(3113);
+   VTY_OUT_TIMER(3115);
+   VTY_OUT_TIMER(3117);
+   VTY_OUT_TIMER(3119);
+   VTY_OUT_TIMER(3122);
+   VTY_OUT_TIMER(3141);
vty_out(vty, " dyn_ts_allow_tch_f %d%s",
gsmnet->dyn_ts_allow_tch_f ? 1 : 0, VTY_NEWLINE);
vty_out(vty, " subscriber-keep-in-ram %d%s",
diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c
index 4dfc258..9d54319 100644
--- a/openbsc/src/libbsc/net_init.c
+++ b/openbsc/src/libbsc/net_init.c
@@ -44,10 +44,17 @@
net->num_bts = 0;
net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED;
net->T3101 = GSM_T3101_DEFAULT;
+   net->T3103 = GSM_T3103_DEFAULT;
net->T3105 = GSM_T3105_DEFAULT;
+   net->T3107 = GSM_T3107_DEFAULT;
+   net->T3109 = GSM_T3109_DEFAULT;
+   net->T3111 = GSM_T3111_DEFAULT;
net->T3113 = GSM_T3113_DEFAULT;
+   net->T3115 = GSM_T3115_DEFAULT;
+   net->T3117 = GSM_T3117_DEFAULT;
+   net->T3119 = GSM_T3119_DEFAULT;
net->T3122 = GSM_T3122_DEFAULT;
-   /* FIXME: initialize all other timers! */
+   net->T3141 = GSM_T3141_DEFAULT;
 
/* default set of handover parameters */
net->handover.win_rxlev_avg = 10;

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


[PATCH] openbsc[master]: bsc_vty: Don't allow timers of zero (0)

2017-07-19 Thread Harald Welte

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

bsc_vty: Don't allow timers of zero (0)

It typically doesn't make sense to configure any of the GSM RR timer
to 0 (Seconds).  In fact, accidentially configuring any of the timers
to zero might have severe side effects, such as "stuck channels"
described in https://osmocom.org/issues/2380

Change-Id: I517828f2f0c80ec01cb63648db2626f17a67fe57
---
M openbsc/src/libbsc/bsc_vty.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/05/3305/1

diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 6472e9d..92b4bbb 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -1539,14 +1539,14 @@
 #define DECLARE_TIMER(number, doc) \
 DEFUN(cfg_net_T##number,   \
   cfg_net_T##number##_cmd, \
-  "timer t" #number  " <0-65535>", \
+  "timer t" #number  " <1-65535>", \
   "Configure GSM Timers\n" \
   doc "Timer Value in seconds\n")  \
 {  \
struct gsm_network *gsmnet = gsmnet_from_vty(vty);  \
int value = atoi(argv[0]);  \
\
-   if (value < 0 || value > 65535) {   \
+   if (value < 1 || value > 65535) {   \
vty_out(vty, "Timer value %s out of range.%s",  \
argv[0], VTY_NEWLINE);  \
return CMD_WARNING; \

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I517828f2f0c80ec01cb63648db2626f17a67fe57
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


Build failure of network:osmocom:nightly/libosmocore in Debian_9.0/i586

2017-07-19 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/libosmocore/Debian_9.0/i586

Package network:osmocom:nightly/libosmocore failed to build in Debian_9.0/i586

Check out the package for editing:
  osc checkout network:osmocom:nightly libosmocore

Last lines of build log:
[  247s] -
[  247s] -[+] Testing: ??? (non-recursive, direct truncation, not punctured)
[  247s] -[.] Input length  : ret = 224  exp = 224 -> OK
[  247s] -[.] Output length : ret = 448  exp = 448 -> OK
[  247s] -[.] Pre computed vector checks:
[  247s] -[..] Encoding: OK
[  247s] -[..] Decoding: OK
[  247s] -[.] Random vector checks:
[  247s] -[..] Encoding / Decoding cycle : OK
[  247s] -[..] Encoding / Decoding cycle : OK
[  247s] -[..] Encoding / Decoding cycle : OK
[  247s] -
[  247s] ./testsuite.at:51: exit code was 132, expected 0
[  247s] 8. testsuite.at:48: 8. conv (testsuite.at:48): FAILED (testsuite.at:51)
[  247s] debian/rules:26: recipe for target 'override_dh_auto_test' failed
[  247s] make[1]: *** [override_dh_auto_test] Error 1
[  247s] make[1]: Leaving directory '/usr/src/packages/BUILD'
[  247s] debian/rules:15: recipe for target 'build' failed
[  247s] make: *** [build] Error 2
[  247s] dpkg-buildpackage: error: debian/rules build gave error exit status 2
[  247s] 
[  247s] build36 failed "build libosmocore_0.9.6.20170719.dsc" at Wed Jul 19 
19:53:56 UTC 2017.
[  247s] 
[  247s] ### VM INTERACTION START ###
[  249s] [  227.771645] reboot: Power down
[  252s] ### VM INTERACTION END ###
[  252s] 
[  252s] build36 failed "build libosmocore_0.9.6.20170719.dsc" at Wed Jul 19 
19:54:02 UTC 2017.
[  252s] 

-- 
Configure notifications at https://build.opensuse.org/user/notifications
openSUSE Build Service (https://build.opensuse.org/)


[PATCH] osmo-gsm-manuals[master]: update osmo-bts-virtual documentation, now that code is merged

2017-07-19 Thread Harald Welte

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

update osmo-bts-virtual documentation, now that code is merged

Change-Id: Icd8706d29ca0e96cb89b7736dbb62f9ce159382d
---
M OsmoBTS/chapters/bts-models.adoc
1 file changed, 41 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/04/3304/1

diff --git a/OsmoBTS/chapters/bts-models.adoc b/OsmoBTS/chapters/bts-models.adoc
index 40a86e2..5e51009 100644
--- a/OsmoBTS/chapters/bts-models.adoc
+++ b/OsmoBTS/chapters/bts-models.adoc
@@ -381,13 +381,32 @@
 Rather than communicating over a wireless RF interface, the GSM Um
 messages are encapsulated over GSMTAP/UDP/IP.
 
-At the time of writing, this functionality is not fully completed.  It
-is the idea to adopt the OsmocomBB MS-side GSM implementation to
-interface with this virtual Um interface, so that many instances of
-virtual MS can connect to some instances of OsmoBTS, testing MS, BTS,
-BSC and core network functionality.
+The Virtual Um interface (i.e. virtual radio layer) between OsmoBTS and
+OsmocomBB allows us to run a complete GSM network with 1-N BTSs and 1-M
+MSs without any actual radio hardware, which is of course excellent for
+all kinds of testing scenarios.
 
-=== `osmo-bts-trx` specific VTY commands
+The Virtual Um layer is based on sending L2 frames (blocks) encapsulated
+via GSMTAP UDP multicast packets. There are two separate multicast
+groups, one for uplink and one for downlink. The multicast nature
+simulates the shared medium and enables any simulated phone to receive
+the signal from multiple BTSs via the downlink multicast group.
+
+In OsmoBTS, this is implemented via the `osmo-bts-virtual` BTS model.
+
+Setting up OsmoBTS in its `osmo-bts-virtual` flavor isn't really much
+different from setting it up with real hardware. The amount of required
+configuration at the BTS configuration file is (as always) very minimal,
+as in the GSM network architecture provides almost all relevant
+configuration to the BTS from the BSC.
+
+An example configuratin file is provided as part of the osmo-bts source
+code: `doc/examples/virtual/osmobts-virtual.cfg`
+
+For more information see
+http://osmocom.org/projects/cellular-infrastructure/wiki/Virtual_Um
+
+=== `osmo-bts-virtual` specific VTY commands
 
 For a auto-generated complete syntax reference of the VTY commands,
 please see the associated _OsmoBTS VTY reference manual_
@@ -401,12 +420,22 @@
 Configure the network device used for sending/receiving the virtual Um
 interface messages (e.g. `eth0`).
 
-= `virtual-um udp-port <0-65535>`
+= `virtual-um ms-udp-port <0-65535>`
 
-Configure the UDP port used for sending/receiving the virtual Um
-interface messages (default: GSMTAP 2775).
+Configure the UDP port used for sending virtual Um
+downlink messages towards the MS (default: GSMTAP 4729).
 
-= `virtual-um multicast-group GROUP`
+= `virtual-um ms-multicast-group GROUP`
 
-Configure the IP multicast group used for sending/receiving the virtual
-Um interface messages.
+Configure the IP multicast group used for sending virtual
+Um downlink messages towards the MS (default: 239.193.23.1)
+
+= `virtual-um bts-udp-port <0-65535>`
+
+Configure the UDP port used for receiving virtual Um
+uplink messages from the MS (default: GSMTAP 4729).
+
+= `virtual-um bts-multicast-group GROUP`
+
+Configure the IP multicast group used for receiving virtual
+Um uplink messages from the MS (default: 239.193.23.2)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd8706d29ca0e96cb89b7736dbb62f9ce159382d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] libosmo-sccp[master]: sccp: make simple client configurable via VTY

2017-07-19 Thread dexter

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

sccp: make simple client configurable via VTY

The osmo_sccp_simple_client_on_ss7_id and osmo_sccp_simple_client
are not entirely configurable via VTY commands.

Add additional logic that checks for a still existing, valid
configuration. If no or an insufficient configuration is detected,
assume use the caller supplied parameters as standard configuration.

Change-Id: I293f3526ce6182dca74a169a23449dbc7af57c7c
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7.c
M src/sccp_user.c
3 files changed, 158 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/03/3303/1

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index 57a4e06..87ace4a 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -307,6 +307,8 @@
 osmo_ss7_as_find_by_rctx(struct osmo_ss7_instance *inst, uint32_t rctx);
 struct osmo_ss7_as *
 osmo_ss7_as_find_by_l_rk_id(struct osmo_ss7_instance *inst, uint32_t l_rk_id);
+struct osmo_ss7_as *osmo_ss7_as_find_by_proto(struct osmo_ss7_instance *inst,
+ enum osmo_ss7_asp_protocol proto);
 struct osmo_ss7_as *
 osmo_ss7_as_find_or_create(struct osmo_ss7_instance *inst, const char *name,
  enum osmo_ss7_asp_protocol proto);
@@ -383,6 +385,9 @@
 
 struct osmo_ss7_asp *
 osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name);
+struct osmo_ss7_asp
+*osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as,
+   enum osmo_ss7_asp_protocol proto);
 struct osmo_ss7_asp *
 osmo_ss7_asp_find_or_create(struct osmo_ss7_instance *inst, const char *name,
uint16_t remote_port, uint16_t local_port,
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index c13c588..2760e5e 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -833,6 +833,44 @@
return NULL;
 }
 
+/*! \brief Find Application Server by given protocol.
+ *  \param[in] inst SS7 Instance on which we operate
+ *  \param[in] proto Protocol identifier that must match
+ *  \returns pointer to Application Server on success; NULL otherwise */
+struct osmo_ss7_as *osmo_ss7_as_find_by_proto(struct osmo_ss7_instance *inst,
+ enum osmo_ss7_asp_protocol proto)
+{
+   struct osmo_ss7_as *as;
+   struct osmo_ss7_as *second_best_as = NULL;
+   unsigned int i;
+
+   OSMO_ASSERT(ss7_initialized);
+
+   /* Loop through the list with AS and try to find one
+* where the proto matches up */
+   llist_for_each_entry(as, &inst->as_list, list) {
+   if (as->cfg.proto == proto) {
+
+   /* Put down the first AS that matches the
+* proto, just in cas we will not find any
+* matching ASP */
+   if (!second_best_as)
+   second_best_as = as;
+
+   /* Check if the candicate we have here as
+* any suitable ASP */
+   for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+   if (as->cfg.asps[i]
+   && as->cfg.asps[i]->cfg.proto == proto)
+   return as;
+   }
+   }
+   }
+
+   /* Return with the second best find, if there is any */
+   return second_best_as;
+}
+
 /*! \brief Find or Create Application Server
  *  \param[in] inst SS7 Instance on which we operate
  *  \param[in] name Name of Application Server
@@ -1044,6 +1082,23 @@
return NULL;
 }
 
+/*! \brief Find an ASP that matches the given protocol.
+ *  \param[in] as Application Server in which to look for \ref asp
+ *  \returns SS7 ASP in case a matching one is found; NULL otherwise */
+struct osmo_ss7_asp
+*osmo_ss7_asp_find_by_proto(struct osmo_ss7_as *as,
+   enum osmo_ss7_asp_protocol proto)
+{
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+   if (as->cfg.asps[i] && as->cfg.asps[i]->cfg.proto == proto)
+   return as->cfg.asps[i];
+   }
+
+   return NULL;
+}
+
 struct osmo_ss7_asp *
 osmo_ss7_asp_find_or_create(struct osmo_ss7_instance *inst, const char *name,
uint16_t remote_port, uint16_t local_port,
diff --git a/src/sccp_user.c b/src/sccp_user.c
index b21a756..8fe9056 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -242,54 +242,115 @@
  int remote_port, const char *remote_ip)
 {
struct osmo_ss7_instance *ss7;
+   bool ss7_created = false;
struct osmo_ss7_as *as;
+   bool as_created = false;
struct osmo_ss7_route *rt;
+   bool rt_created = false;
struct osmo_ss7_asp *asp;
-   char *as_name, *asp_name;
+   bool asp_

osmo-gsm-manuals[master]: osmux-reference: Add sequence charts

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic2c63e4d9e67b877dc06a206ec7f07d0704329a5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-gsm-manuals[master]: osmux-reference-docinfo: Add latest changes to revhistory

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmux-reference-docinfo: Add latest changes to revhistory
..


osmux-reference-docinfo: Add latest changes to revhistory

Change-Id: I01e513a71a3f830d393c57c43678d7e4c8d2d151
---
M OsmoBSC/osmux-reference-docinfo.xml
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/OsmoBSC/osmux-reference-docinfo.xml 
b/OsmoBSC/osmux-reference-docinfo.xml
index 06b2d7e..7e31ec7 100644
--- a/OsmoBSC/osmux-reference-docinfo.xml
+++ b/OsmoBSC/osmux-reference-docinfo.xml
@@ -28,6 +28,14 @@
 Update frame bits according to implementation.
 
   
+  
+0.4
+19 July 2017
+Pau Espin Pedrol
+
+Add sequence charts, generate packet header structure with 
packetdiag, generate traffic saving plot with pychart.
+
+  
 
 
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I01e513a71a3f830d393c57c43678d7e4c8d2d151
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-gsm-manuals[master]: osmux-reference: Add sequence charts

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmux-reference: Add sequence charts
..


osmux-reference: Add sequence charts

Change-Id: Ic2c63e4d9e67b877dc06a206ec7f07d0704329a5
---
M OsmoBSC/osmux-reference.adoc
1 file changed, 189 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index b2767f3..0f66118 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -307,6 +307,195 @@
 * On receival of this kind of OSmux frame, it's usually enough for the reader 
to
   discard the header plus the calculated padding and keep operating.
 
+== Sequence Charts
+
+=== Trunking
+
+Following chart shows how trunking works for 3 concurrent calls from different
+MS on a given BTS. In this case only uplink data is shown, but downlink follows
+the same idea. Batching factor is set to 1 to easily illustrate trunking 
mechanism.
+
+It can be seen how 3 RTP packets from 3 different Ms (a, b, and c) arrive to 
the
+BSC from the BTS. The BSC generates 3 OSmux frames and stores and sends them
+together in one UDP packet to the BSC-NAT. The BSC-NAT decodes the three OSmux
+frames, identifies each of them through CID values and transform them back to
+RTP before sending them to the MGW.
+
+["mscgen"]
+
+msc {
+   hscale = 2;
+   bts [label="BTS"], bsc [label="BSC"], bscnat [label="BSC-NAT"], mgw 
[label="MGW"];
+
+   ...;
+   --- [label="3 Regular RTP-AMR calls using OSmux (has been 
ongoing for some time)"];
+
+   bts => bsc  [label="RTP-AMR[seq=y,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m,AMR(y)],Osmux[ft=2,cid=i+1,seq=n,AMR(x)],Osmux[ft=2,cid=i+2,seq=l,AMR(z)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o,ssrc=r] (originally 
seq=y,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p,ssrc=s] (originally 
seq=x,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q,ssrc=t] (originally 
seq=z,ssrc=MSc)"];
+bts => bsc [label="RTP-AMR[seq=y+1,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+1,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z+1,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m+1,AMR(y+1)],Osmux[ft=2,cid=i+1,seq=n+1,AMR(x+1)],Osmux[ft=2,cid=i+2,seq=l+1,AMR(z+1)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o+1,ssrc=r] (originally 
seq=y+1,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p+1,ssrc=s] (originally 
seq=x+1,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q+1,ssrc=t] (originally 
seq=z+1,ssrc=MSc)"];
+bts => bsc [label="RTP-AMR[seq=y+2,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+2,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z+2,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m+2,AMR(y+2)],Osmux[ft=2,cid=i+1,seq=n+2,AMR(x+2)],Osmux[ft=2,cid=i+2,seq=l+2,AMR(z+2)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o+2,ssrc=r] (originally 
seq=y+2,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p+2,ssrc=s] (originally 
seq=x+2,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q+2,ssrc=t] (originally 
seq=z+2,ssrc=MSc)"];
+}
+
+
+=== Batching
+
+Following chart shows how batching with a factor of 3 works. To easilly
+illustrate batching, only uplink and one concurrent call is considered.
+
+It can be seen how 3 RTP packets from MSa arrive to the BSC from the BTS. The
+BSC queues the 3 RTP packets and once the batchfactor is reached, an OSmux 
frame
+is generated and sent to the BSC-NAT. The BSC-NAT decodes the OSmux frames,
+transforms each AMR payload into an RTP packet and each RTP packet is scheduled
+for delivery according to expected proportional time delay (and timestamp field
+is set accordingly).
+
+["mscgen"]
+
+msc {
+   hscale = 2;
+   bts [label="BTS"], bsc [label="BSC"], bscnat [label="BSC-NAT"], mgw 
[label="MGW"];
+
+   ...;
+   --- [label="Regular RTP-AMR call using OSmux with batch 
factor 3 (has been ongoing for some time)"];
+
+   bts => bsc  [label="RTP-AMR[seq=x,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+1,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+2,ssrc=MSa]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m,AMR(x),AMR(x+1),AMR(x+2)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o,ssrc=r] (originally 
seq=x,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=o+1,ssrc=r] (originally 
seq=x+1,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=o+2,ssrc=r] (originally 
seq=x+2,ssrc=MSa)"];
+bts => bsc [label="RTP-AMR[seq=x+3,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[

osmo-gsm-manuals[master]: osmux-reference-docinfo: Add latest changes to revhistory

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I01e513a71a3f830d393c57c43678d7e4c8d2d151
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-gsm-manuals[master]: osmux-reference: Use packetdiag to draw packet header struct...

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmux-reference: Use packetdiag to draw packet header structures
..


osmux-reference: Use packetdiag to draw packet header structures

Change-Id: Id75152278f41d56b7bd2e652b9947e33d6523c64
---
M OsmoBSC/Makefile
M OsmoBSC/osmux-reference.adoc
2 files changed, 50 insertions(+), 16 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/OsmoBSC/Makefile b/OsmoBSC/Makefile
index 93c7b81..35f50da 100644
--- a/OsmoBSC/Makefile
+++ b/OsmoBSC/Makefile
@@ -33,6 +33,9 @@
-rm aoip-mgw-options*.png
-rm aoip-mgw-options*.svg
-rm aoip-mgw-options*.check
+   -rm osmux-reference__*.svg
+   -rm osmux-reference__*.png
+   -rm osmux-reference__*.check
 
 gen-bsc-vty-docbook: FORCE
$(call command,xsltproc -o generated/combined1.xml \
diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index 068bc19..b2767f3 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -144,14 +144,22 @@
 
 === LAPD Signalling (0)
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|X|FT |X X X X X|   PL-LENGTH   | LAPD header + payload |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  -
+   1-2:FT
+   3-7:
+   8-15:   PL-LENGTH
+   16-31:  LAPD header + payload
+}
+
 
 Field Type (FT): 2 bits::
-The Field Type allocated for AMR codec is "0".
+The Field Type allocated for LAPD Signalling is "0".
 
 This frame type is not yet supported inside OsmoCom and may be subject to
 change in future versions of the protocol.
@@ -162,11 +170,23 @@
 This OSmux packet header is used to transport one or more RTP-AMR packets for a
 specific RTP stream identified by the Circuit ID field.
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|M|FT | CTR |F|Q| Red. TS/SeqNR |  Circuit ID   |AMR FT |AMR CMR|
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  M
+   1-2:FT
+   3-5:CTR
+   6:  F
+   7:  Q
+   8-15:   Red. TS/SeqNR
+   16-23:  Circuit ID
+   24-27:  AMR FT
+   28-31:  AMR CMR
+}
+
 
 Marker (M): 1 bit::
 This is a 1:1 mapping from the RTP Marker (M) bit as specified in RFC3550
@@ -246,11 +266,22 @@
 When opening a connection, the peer is expected to send dummy packets until it
 starts sending real audio, at which point dummy packets are not needed anymore.
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|X|FT | CTR |X X|X X X X X X X X X| Circuit ID  |AMR FT |X X X X|
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  -
+   1-2:FT
+   3-5:CTR
+   6-7:--
+   8-15:   
+   16-23:  Circuit ID
+   24-27:  AMR FT
+   28-31:  
+}
+
 
 Field Type (FT): 2 bits::
 The Field Type allocated for AMR codec is "2".

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id75152278f41d56b7bd2e652b9947e33d6523c64
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-gsm-manuals[master]: osmux-reference: Add traffic saving plot

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: osmux-reference: Add traffic saving plot
..


osmux-reference: Add traffic saving plot

Change-Id: I8fa60c1f95436c39fd1ff9424a907876d367484e
---
M INSTALL.txt
M OsmoBSC/osmux-reference.adoc
M build/Makefile.asciidoc.inc
A build/python2-filter.conf
4 files changed, 80 insertions(+), 82 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/INSTALL.txt b/INSTALL.txt
index 6f19720..39653d3 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -6,7 +6,8 @@
   xsltproc \
   dblatex \
   mscgen \
-  graphviz
+  graphviz \
+  python-pychart
 
 Build PDFs, run:
   make
diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index 0f66118..4d03a4b 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -499,91 +499,67 @@
 
 == Evaluation: Expected traffic savings
 
-The following figure shows the traffic saving (in %) depending on the number
-of concurrent numbers of callings (asumming trunking but no batching at all):
+The following figure shows the growth in traffic saving (in %) depending on the
+number of concurrent numbers of callings for a given set of batching factor
+values:
+
+["python2"]
 
-  Traffic savings (%)
-  100 ++---+---+++---++---+---++
-  ++   +++   +   batch factor 1 **E*** +
-  ||
-   80 ++  ++
-  ||
-  ||
-  |   EE
-   60 ++ E***EE***++
-  |   **E  |
-  |    |
-   40 ++  *E**++
-  | ** |
-  |   **   |
-  | ** |
-   20 ++   E  ++
-  ||
-  ++   +++   ++   ++
-0 ++---+---+++---++---+---++
-  01   234   56   78
-Concurrent calls
+from pychart import *
+theme.get_options()
+theme.scale_factor = 5
+theme.use_color = 1
+theme.reinitialize()
+
+IP_HEADER=20
+UDP_HEADER=8
+RTP_HEADER=12
+OSMUX_HEADER=4
+AMR59_PAYLOAD=17
+
+def osmux_get_size(calls, payloads):
+return IP_HEADER + UDP_HEADER + (OSMUX_HEADER + AMR59_PAYLOAD * payloads) 
* calls
+
+def rtp_get_size(calls, payloads):
+return calls * payloads * (IP_HEADER + UDP_HEADER + RTP_HEADER + 
AMR59_PAYLOAD)
+
+def calc_traffic_saving(calls, payloads):
+return 100 - 100.0 * osmux_get_size(calls, payloads) / rtp_get_size(calls, 
payloads)
+
+#  The first value in each tuple is the X value, and subsequent values are Y 
values for different lines.
+def gen_table():
+data = []
+for calls in range(1, 9):
+col = (calls,)
+for factor in range(1, 9):
+col += (calc_traffic_saving(calls, factor),)
+data.append(col)
+return data
+
+def do_plot(data):
+xaxis = axis.X(format="/hL%d", tic_interval = 1, label="Concurrent calls")
+yaxis = axis.Y(format="%d%%", tic_interval = 10, label="Traffic Saving")
+ar = area.T(x_axis=xaxis, y_axis=yaxis, y_range=(None,None), 
x_grid_interval=1, x_grid_style=line_style.gray70_dash3)
+for y in range(1, len(data[0])):
+plot = line_plot.T(label="bfactor "+str(y), data=data, ycol=y, 
tick_mark=tick_mark.circle1)
+ar.add_plot(plot)
+ar.draw()
+
+data = gen_table()
+do_plot(data)
 
 
-The results shows a saving of 15.79% with only one concurrent call, that
-quickly improves with more concurrent calls (due to trunking).
+The results show a saving of 15.79% with only one concurrent call and with
+batching disabled (bfactor 1), that quickly improves with more concurrent calls
+(due to trunking).
 
-We also provide the expected results by batching 4 messages for a single call:
-
-  Traffic savings (%)
-  100 ++---+---+++---++---+---++
-  ++   +++   +   batch factor 4 **E*** +
-  |  

osmo-gsm-manuals[master]: osmux-reference: Add traffic saving plot

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8fa60c1f95436c39fd1ff9424a907876d367484e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-gsm-manuals[master]: osmux-reference: Use packetdiag to draw packet header struct...

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id75152278f41d56b7bd2e652b9947e33d6523c64
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-gsm-manuals[master]: osmux-reference: Add sequence charts

2017-07-19 Thread Pau Espin Pedrol

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

osmux-reference: Add sequence charts

Change-Id: Ic2c63e4d9e67b877dc06a206ec7f07d0704329a5
---
M OsmoBSC/osmux-reference.adoc
1 file changed, 189 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/00/3300/1

diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index b2767f3..0f66118 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -307,6 +307,195 @@
 * On receival of this kind of OSmux frame, it's usually enough for the reader 
to
   discard the header plus the calculated padding and keep operating.
 
+== Sequence Charts
+
+=== Trunking
+
+Following chart shows how trunking works for 3 concurrent calls from different
+MS on a given BTS. In this case only uplink data is shown, but downlink follows
+the same idea. Batching factor is set to 1 to easily illustrate trunking 
mechanism.
+
+It can be seen how 3 RTP packets from 3 different Ms (a, b, and c) arrive to 
the
+BSC from the BTS. The BSC generates 3 OSmux frames and stores and sends them
+together in one UDP packet to the BSC-NAT. The BSC-NAT decodes the three OSmux
+frames, identifies each of them through CID values and transform them back to
+RTP before sending them to the MGW.
+
+["mscgen"]
+
+msc {
+   hscale = 2;
+   bts [label="BTS"], bsc [label="BSC"], bscnat [label="BSC-NAT"], mgw 
[label="MGW"];
+
+   ...;
+   --- [label="3 Regular RTP-AMR calls using OSmux (has been 
ongoing for some time)"];
+
+   bts => bsc  [label="RTP-AMR[seq=y,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m,AMR(y)],Osmux[ft=2,cid=i+1,seq=n,AMR(x)],Osmux[ft=2,cid=i+2,seq=l,AMR(z)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o,ssrc=r] (originally 
seq=y,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p,ssrc=s] (originally 
seq=x,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q,ssrc=t] (originally 
seq=z,ssrc=MSc)"];
+bts => bsc [label="RTP-AMR[seq=y+1,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+1,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z+1,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m+1,AMR(y+1)],Osmux[ft=2,cid=i+1,seq=n+1,AMR(x+1)],Osmux[ft=2,cid=i+2,seq=l+1,AMR(z+1)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o+1,ssrc=r] (originally 
seq=y+1,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p+1,ssrc=s] (originally 
seq=x+1,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q+1,ssrc=t] (originally 
seq=z+1,ssrc=MSc)"];
+bts => bsc [label="RTP-AMR[seq=y+2,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+2,ssrc=MSb]"];
+   bts => bsc  [label="RTP-AMR[seq=z+2,ssrc=MSc]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m+2,AMR(y+2)],Osmux[ft=2,cid=i+1,seq=n+2,AMR(x+2)],Osmux[ft=2,cid=i+2,seq=l+2,AMR(z+2)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o+2,ssrc=r] (originally 
seq=y+2,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=p+2,ssrc=s] (originally 
seq=x+2,ssrc=MSb)"];
+   bscnat => mgw   [label="RTP-AMR[seq=q+2,ssrc=t] (originally 
seq=z+2,ssrc=MSc)"];
+}
+
+
+=== Batching
+
+Following chart shows how batching with a factor of 3 works. To easilly
+illustrate batching, only uplink and one concurrent call is considered.
+
+It can be seen how 3 RTP packets from MSa arrive to the BSC from the BTS. The
+BSC queues the 3 RTP packets and once the batchfactor is reached, an OSmux 
frame
+is generated and sent to the BSC-NAT. The BSC-NAT decodes the OSmux frames,
+transforms each AMR payload into an RTP packet and each RTP packet is scheduled
+for delivery according to expected proportional time delay (and timestamp field
+is set accordingly).
+
+["mscgen"]
+
+msc {
+   hscale = 2;
+   bts [label="BTS"], bsc [label="BSC"], bscnat [label="BSC-NAT"], mgw 
[label="MGW"];
+
+   ...;
+   --- [label="Regular RTP-AMR call using OSmux with batch 
factor 3 (has been ongoing for some time)"];
+
+   bts => bsc  [label="RTP-AMR[seq=x,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+1,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+2,ssrc=MSa]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq=m,AMR(x),AMR(x+1),AMR(x+2)]]"];
+bscnat => mgw  [label="RTP-AMR[seq=o,ssrc=r] (originally 
seq=x,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=o+1,ssrc=r] (originally 
seq=x+1,ssrc=MSa)"];
+   bscnat => mgw   [label="RTP-AMR[seq=o+2,ssrc=r] (originally 
seq=x+2,ssrc=MSa)"];
+bts => bsc [label="RTP-AMR[seq=x+3,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+4,ssrc=MSa]"];
+   bts => bsc  [label="RTP-AMR[seq=x+5,ssrc=MSa]"];
+bsc => bscnat   
[label="UDP[Osmux[ft=2,cid=i,seq

[PATCH] osmo-gsm-manuals[master]: osmux-reference: Add traffic saving plot

2017-07-19 Thread Pau Espin Pedrol

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

osmux-reference: Add traffic saving plot

Change-Id: I8fa60c1f95436c39fd1ff9424a907876d367484e
---
M INSTALL.txt
M OsmoBSC/osmux-reference.adoc
M build/Makefile.asciidoc.inc
A build/python2-filter.conf
4 files changed, 80 insertions(+), 82 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/01/3301/1

diff --git a/INSTALL.txt b/INSTALL.txt
index 6f19720..39653d3 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -6,7 +6,8 @@
   xsltproc \
   dblatex \
   mscgen \
-  graphviz
+  graphviz \
+  python-pychart
 
 Build PDFs, run:
   make
diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index 0f66118..4d03a4b 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -499,91 +499,67 @@
 
 == Evaluation: Expected traffic savings
 
-The following figure shows the traffic saving (in %) depending on the number
-of concurrent numbers of callings (asumming trunking but no batching at all):
+The following figure shows the growth in traffic saving (in %) depending on the
+number of concurrent numbers of callings for a given set of batching factor
+values:
+
+["python2"]
 
-  Traffic savings (%)
-  100 ++---+---+++---++---+---++
-  ++   +++   +   batch factor 1 **E*** +
-  ||
-   80 ++  ++
-  ||
-  ||
-  |   EE
-   60 ++ E***EE***++
-  |   **E  |
-  |    |
-   40 ++  *E**++
-  | ** |
-  |   **   |
-  | ** |
-   20 ++   E  ++
-  ||
-  ++   +++   ++   ++
-0 ++---+---+++---++---+---++
-  01   234   56   78
-Concurrent calls
+from pychart import *
+theme.get_options()
+theme.scale_factor = 5
+theme.use_color = 1
+theme.reinitialize()
+
+IP_HEADER=20
+UDP_HEADER=8
+RTP_HEADER=12
+OSMUX_HEADER=4
+AMR59_PAYLOAD=17
+
+def osmux_get_size(calls, payloads):
+return IP_HEADER + UDP_HEADER + (OSMUX_HEADER + AMR59_PAYLOAD * payloads) 
* calls
+
+def rtp_get_size(calls, payloads):
+return calls * payloads * (IP_HEADER + UDP_HEADER + RTP_HEADER + 
AMR59_PAYLOAD)
+
+def calc_traffic_saving(calls, payloads):
+return 100 - 100.0 * osmux_get_size(calls, payloads) / rtp_get_size(calls, 
payloads)
+
+#  The first value in each tuple is the X value, and subsequent values are Y 
values for different lines.
+def gen_table():
+data = []
+for calls in range(1, 9):
+col = (calls,)
+for factor in range(1, 9):
+col += (calc_traffic_saving(calls, factor),)
+data.append(col)
+return data
+
+def do_plot(data):
+xaxis = axis.X(format="/hL%d", tic_interval = 1, label="Concurrent calls")
+yaxis = axis.Y(format="%d%%", tic_interval = 10, label="Traffic Saving")
+ar = area.T(x_axis=xaxis, y_axis=yaxis, y_range=(None,None), 
x_grid_interval=1, x_grid_style=line_style.gray70_dash3)
+for y in range(1, len(data[0])):
+plot = line_plot.T(label="bfactor "+str(y), data=data, ycol=y, 
tick_mark=tick_mark.circle1)
+ar.add_plot(plot)
+ar.draw()
+
+data = gen_table()
+do_plot(data)
 
 
-The results shows a saving of 15.79% with only one concurrent call, that
-quickly improves with more concurrent calls (due to trunking).
+The results show a saving of 15.79% with only one concurrent call and with
+batching disabled (bfactor 1), that quickly improves with more concurrent calls
+(due to trunking).
 
-We also provide the expected results by batching 4 messages for a single call:
-
-  Traffic savings (%)
-  100 ++---+---+++---++---+---++
-  ++   +++   +   batch factor 4 **E*** +
-  ||
-   80 ++  ++
-  |  

[PATCH] osmo-gsm-manuals[master]: osmux-reference-docinfo: Add latest changes to revhistory

2017-07-19 Thread Pau Espin Pedrol

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

osmux-reference-docinfo: Add latest changes to revhistory

Change-Id: I01e513a71a3f830d393c57c43678d7e4c8d2d151
---
M OsmoBSC/osmux-reference-docinfo.xml
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/02/3302/1

diff --git a/OsmoBSC/osmux-reference-docinfo.xml 
b/OsmoBSC/osmux-reference-docinfo.xml
index 06b2d7e..7e31ec7 100644
--- a/OsmoBSC/osmux-reference-docinfo.xml
+++ b/OsmoBSC/osmux-reference-docinfo.xml
@@ -28,6 +28,14 @@
 Update frame bits according to implementation.
 
   
+  
+0.4
+19 July 2017
+Pau Espin Pedrol
+
+Add sequence charts, generate packet header structure with 
packetdiag, generate traffic saving plot with pychart.
+
+  
 
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01e513a71a3f830d393c57c43678d7e4c8d2d151
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[PATCH] osmo-gsm-manuals[master]: osmux-reference: Use packetdiag to draw packet header struct...

2017-07-19 Thread Pau Espin Pedrol

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

osmux-reference: Use packetdiag to draw packet header structures

Change-Id: Id75152278f41d56b7bd2e652b9947e33d6523c64
---
M OsmoBSC/Makefile
M OsmoBSC/osmux-reference.adoc
2 files changed, 50 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-manuals 
refs/changes/99/3299/1

diff --git a/OsmoBSC/Makefile b/OsmoBSC/Makefile
index 93c7b81..35f50da 100644
--- a/OsmoBSC/Makefile
+++ b/OsmoBSC/Makefile
@@ -33,6 +33,9 @@
-rm aoip-mgw-options*.png
-rm aoip-mgw-options*.svg
-rm aoip-mgw-options*.check
+   -rm osmux-reference__*.svg
+   -rm osmux-reference__*.png
+   -rm osmux-reference__*.check
 
 gen-bsc-vty-docbook: FORCE
$(call command,xsltproc -o generated/combined1.xml \
diff --git a/OsmoBSC/osmux-reference.adoc b/OsmoBSC/osmux-reference.adoc
index 068bc19..b2767f3 100644
--- a/OsmoBSC/osmux-reference.adoc
+++ b/OsmoBSC/osmux-reference.adoc
@@ -144,14 +144,22 @@
 
 === LAPD Signalling (0)
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|X|FT |X X X X X|   PL-LENGTH   | LAPD header + payload |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  -
+   1-2:FT
+   3-7:
+   8-15:   PL-LENGTH
+   16-31:  LAPD header + payload
+}
+
 
 Field Type (FT): 2 bits::
-The Field Type allocated for AMR codec is "0".
+The Field Type allocated for LAPD Signalling is "0".
 
 This frame type is not yet supported inside OsmoCom and may be subject to
 change in future versions of the protocol.
@@ -162,11 +170,23 @@
 This OSmux packet header is used to transport one or more RTP-AMR packets for a
 specific RTP stream identified by the Circuit ID field.
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|M|FT | CTR |F|Q| Red. TS/SeqNR |  Circuit ID   |AMR FT |AMR CMR|
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  M
+   1-2:FT
+   3-5:CTR
+   6:  F
+   7:  Q
+   8-15:   Red. TS/SeqNR
+   16-23:  Circuit ID
+   24-27:  AMR FT
+   28-31:  AMR CMR
+}
+
 
 Marker (M): 1 bit::
 This is a 1:1 mapping from the RTP Marker (M) bit as specified in RFC3550
@@ -246,11 +266,22 @@
 When opening a connection, the peer is expected to send dummy packets until it
 starts sending real audio, at which point dummy packets are not needed anymore.
 
- 0   1   2   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|X|FT | CTR |X X|X X X X X X X X X| Circuit ID  |AMR FT |X X X X|
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+[packetdiag]
+
+{
+   colwidth = 32
+   node_height = 40
+
+   0:  -
+   1-2:FT
+   3-5:CTR
+   6-7:--
+   8-15:   
+   16-23:  Circuit ID
+   24-27:  AMR FT
+   28-31:  
+}
+
 
 Field Type (FT): 2 bits::
 The Field Type allocated for AMR codec is "2".

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id75152278f41d56b7bd2e652b9947e33d6523c64
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 


[MERGED] osmo-bts[master]: virt: Don't print NOTICE log message if ARFCN doesn't match

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: virt: Don't print NOTICE log message if ARFCN doesn't match
..


virt: Don't print NOTICE log message if ARFCN doesn't match

In a larger simulated network with multiple BTSs it is normal that one
BTS will see GSMTAP frames for an ARFCN that is not an ARFCN used by the
local BTS.  This is just normal operation.

Change-Id: Ic68cace9648ccb17500c94b6ede8814674aa9c29
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 1 insertion(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index 9212121..3ef8c72 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -102,11 +102,8 @@
 
/* Generally ignore all msgs that are either not received with the 
right ARFCN... */
pinst = phy_instance_by_arfcn(plink, arfcn & GSMTAP_ARFCN_MASK);
-   if (!pinst) {
-   LOGP(DL1P, LOGL_NOTICE, "Ignoring incoming msg - msg ARFCN=%d 
not part of BTS\n",
-arfcn & GSMTAP_ARFCN_MASK);
+   if (!pinst)
goto nomessage;
-   }
 
/* switch case with removed ACCH flag */
switch ((gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH) & 0xff) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic68cace9648ccb17500c94b6ede8814674aa9c29
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bts[master]: VIRT-PHY: Report virtual RACH bursts with plausible burst type

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Report virtual RACH bursts with plausible burst type
..


VIRT-PHY: Report virtual RACH bursts with plausible burst type

Change-Id: I35b103c512993fc52d4e608f07115a4bb4b21022
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index 3ef8c72..4fe1ec8 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -119,7 +119,9 @@
l1sap.u.rach_ind.acc_delay = 0; /* probably not used in virt um 
*/
l1sap.u.rach_ind.is_11bit = 0;
l1sap.u.rach_ind.fn = fn;
-   l1sap.u.rach_ind.burst_type = GSM_L1_BURST_TYPE_NONE; /* FIXME: 
what comes here */
+   /* we don't rally know which RACH bursrt type the virtual MS is 
using, as this field is not
+* part of information present in the GSMTAP header.  So we 
simply report all of them as 0 */
+   l1sap.u.rach_ind.burst_type = GSM_L1_BURST_TYPE_ACCESS_0;
break;
case GSMTAP_CHANNEL_TCH_F:
case GSMTAP_CHANNEL_TCH_H:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I35b103c512993fc52d4e608f07115a4bb4b21022
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bts[master]: scheduler: Fix wrong log subsystem: L1C is L1 *control* not ...

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: scheduler: Fix wrong log subsystem: L1C is L1 *control* not 
user data
..


scheduler: Fix wrong log subsystem: L1C is L1 *control* not user data

RTS.ind, DATA.* and TCH.* primitives are L1P, not L1C.

Change-Id: I4a32b83225e931ced561fdf457fa962e8ad44bd2
---
M src/common/scheduler.c
1 file changed, 9 insertions(+), 9 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 121475a..08603d2 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -282,7 +282,7 @@
l1sap = msgb_l1sap_prim(msg);
if (l1sap->oph.operation != PRIM_OP_REQUEST) {
 wrong_type:
-   LOGP(DL1C, LOGL_ERROR, "Prim for ts=%u at fn=%u has "
+   LOGP(DL1P, LOGL_ERROR, "Prim for ts=%u at fn=%u has "
"wrong type.\n", tn, fn);
 free_msg:
/* unlink and free message */
@@ -305,7 +305,7 @@
goto wrong_type;
}
if (prim_fn > 100) {
-   LOGP(DL1C, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at "
+   LOGP(DL1P, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at "
 "fn=%u is out of range (100), or channel %s with "
 "type %s is already disabled. If this happens in "
 "conjunction with PCU, increase 'rts-advance' by 
5."
@@ -329,7 +329,7 @@
 found_msg:
if ((chan_nr ^ (trx_chan_desc[chan].chan_nr | tn))
 || ((link_id & 0xc0) ^ trx_chan_desc[chan].link_id)) {
-   LOGP(DL1C, LOGL_ERROR, "Prim for ts=%u at fn=%u has wrong "
+   LOGP(DL1P, LOGL_ERROR, "Prim for ts=%u at fn=%u has wrong "
"chan_nr=%02x link_id=%02x, expecting chan_nr=%02x "
"link_id=%02x.\n", tn, fn, chan_nr, link_id,
trx_chan_desc[chan].chan_nr | tn,
@@ -418,7 +418,7 @@
uint8_t tn = l1sap->u.data.chan_nr & 7;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 
-   LOGP(DL1C, LOGL_INFO, "PH-DATA.req: chan_nr=0x%02x link_id=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "PH-DATA.req: chan_nr=0x%02x link_id=0x%02x "
"fn=%u ts=%u trx=%u\n", l1sap->u.data.chan_nr,
l1sap->u.data.link_id, l1sap->u.data.fn, tn, l1t->trx->nr);
 
@@ -441,7 +441,7 @@
uint8_t tn = l1sap->u.tch.chan_nr & 7;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 
-   LOGP(DL1C, LOGL_INFO, "TCH.req: chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "TCH.req: chan_nr=0x%02x "
"fn=%u ts=%u trx=%u\n", l1sap->u.tch.chan_nr,
l1sap->u.tch.fn, tn, l1t->trx->nr);
 
@@ -477,12 +477,12 @@
link_id = trx_chan_desc[chan].link_id;
 
if (!chan_nr) {
-   LOGP(DL1C, LOGL_FATAL, "RTS func for %s with non-existing "
+   LOGP(DL1P, LOGL_FATAL, "RTS func for %s with non-existing "
"chan_nr %d\n", trx_chan_desc[chan].name, chan_nr);
return -ENODEV;
}
 
-   LOGP(DL1C, LOGL_INFO, "PH-RTS.ind: chan=%s chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "PH-RTS.ind: chan=%s chan_nr=0x%02x "
"link_id=0x%02x fn=%u ts=%u trx=%u\n", trx_chan_desc[chan].name,
chan_nr, link_id, fn, tn, l1t->trx->nr);
 
@@ -514,12 +514,12 @@
link_id = trx_chan_desc[chan].link_id;
 
if (!chan_nr) {
-   LOGP(DL1C, LOGL_FATAL, "RTS func for %s with non-existing "
+   LOGP(DL1P, LOGL_FATAL, "RTS func for %s with non-existing "
"chan_nr %d\n", trx_chan_desc[chan].name, chan_nr);
return -ENODEV;
}
 
-   LOGP(DL1C, LOGL_INFO, "TCH RTS.ind: chan=%s chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "TCH RTS.ind: chan=%s chan_nr=0x%02x "
"fn=%u ts=%u trx=%u\n", trx_chan_desc[chan].name,
chan_nr, fn, tn, l1t->trx->nr);
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a32b83225e931ced561fdf457fa962e8ad44bd2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bts[master]: VIRT-PHY: Report virtual RACH bursts with plausible burst type

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I35b103c512993fc52d4e608f07115a4bb4b21022
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bts[master]: scheduler: Fix wrong log subsystem: L1C is L1 *control* not ...

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I4a32b83225e931ced561fdf457fa962e8ad44bd2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bts[master]: virt: Don't print NOTICE log message if ARFCN doesn't match

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic68cace9648ccb17500c94b6ede8814674aa9c29
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: virt: Don't print NOTICE log message if ARFCN doesn't match

2017-07-19 Thread Harald Welte

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

virt: Don't print NOTICE log message if ARFCN doesn't match

In a larger simulated network with multiple BTSs it is normal that one
BTS will see GSMTAP frames for an ARFCN that is not an ARFCN used by the
local BTS.  This is just normal operation.

Change-Id: Ic68cace9648ccb17500c94b6ede8814674aa9c29
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 1 insertion(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/96/3296/1

diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index 9212121..3ef8c72 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -102,11 +102,8 @@
 
/* Generally ignore all msgs that are either not received with the 
right ARFCN... */
pinst = phy_instance_by_arfcn(plink, arfcn & GSMTAP_ARFCN_MASK);
-   if (!pinst) {
-   LOGP(DL1P, LOGL_NOTICE, "Ignoring incoming msg - msg ARFCN=%d 
not part of BTS\n",
-arfcn & GSMTAP_ARFCN_MASK);
+   if (!pinst)
goto nomessage;
-   }
 
/* switch case with removed ACCH flag */
switch ((gsmtap_chantype & ~GSMTAP_CHANNEL_ACCH) & 0xff) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic68cace9648ccb17500c94b6ede8814674aa9c29
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: VIRT-PHY: Report virtual RACH bursts with plausible burst type

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Report virtual RACH bursts with plausible burst type

Change-Id: I35b103c512993fc52d4e608f07115a4bb4b21022
---
M src/osmo-bts-virtual/l1_if.c
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/97/3297/1

diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index 3ef8c72..4fe1ec8 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -119,7 +119,9 @@
l1sap.u.rach_ind.acc_delay = 0; /* probably not used in virt um 
*/
l1sap.u.rach_ind.is_11bit = 0;
l1sap.u.rach_ind.fn = fn;
-   l1sap.u.rach_ind.burst_type = GSM_L1_BURST_TYPE_NONE; /* FIXME: 
what comes here */
+   /* we don't rally know which RACH bursrt type the virtual MS is 
using, as this field is not
+* part of information present in the GSMTAP header.  So we 
simply report all of them as 0 */
+   l1sap.u.rach_ind.burst_type = GSM_L1_BURST_TYPE_ACCESS_0;
break;
case GSMTAP_CHANNEL_TCH_F:
case GSMTAP_CHANNEL_TCH_H:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35b103c512993fc52d4e608f07115a4bb4b21022
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-bts[master]: scheduler: Fix wrong log subsystem: L1C is L1 *control* not ...

2017-07-19 Thread Harald Welte

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

scheduler: Fix wrong log subsystem: L1C is L1 *control* not user data

RTS.ind, DATA.* and TCH.* primitives are L1P, not L1C.

Change-Id: I4a32b83225e931ced561fdf457fa962e8ad44bd2
---
M src/common/scheduler.c
1 file changed, 9 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/98/3298/1

diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 121475a..08603d2 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -282,7 +282,7 @@
l1sap = msgb_l1sap_prim(msg);
if (l1sap->oph.operation != PRIM_OP_REQUEST) {
 wrong_type:
-   LOGP(DL1C, LOGL_ERROR, "Prim for ts=%u at fn=%u has "
+   LOGP(DL1P, LOGL_ERROR, "Prim for ts=%u at fn=%u has "
"wrong type.\n", tn, fn);
 free_msg:
/* unlink and free message */
@@ -305,7 +305,7 @@
goto wrong_type;
}
if (prim_fn > 100) {
-   LOGP(DL1C, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at "
+   LOGP(DL1P, LOGL_NOTICE, "Prim %u for trx=%u ts=%u at "
 "fn=%u is out of range (100), or channel %s with "
 "type %s is already disabled. If this happens in "
 "conjunction with PCU, increase 'rts-advance' by 
5."
@@ -329,7 +329,7 @@
 found_msg:
if ((chan_nr ^ (trx_chan_desc[chan].chan_nr | tn))
 || ((link_id & 0xc0) ^ trx_chan_desc[chan].link_id)) {
-   LOGP(DL1C, LOGL_ERROR, "Prim for ts=%u at fn=%u has wrong "
+   LOGP(DL1P, LOGL_ERROR, "Prim for ts=%u at fn=%u has wrong "
"chan_nr=%02x link_id=%02x, expecting chan_nr=%02x "
"link_id=%02x.\n", tn, fn, chan_nr, link_id,
trx_chan_desc[chan].chan_nr | tn,
@@ -418,7 +418,7 @@
uint8_t tn = l1sap->u.data.chan_nr & 7;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 
-   LOGP(DL1C, LOGL_INFO, "PH-DATA.req: chan_nr=0x%02x link_id=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "PH-DATA.req: chan_nr=0x%02x link_id=0x%02x "
"fn=%u ts=%u trx=%u\n", l1sap->u.data.chan_nr,
l1sap->u.data.link_id, l1sap->u.data.fn, tn, l1t->trx->nr);
 
@@ -441,7 +441,7 @@
uint8_t tn = l1sap->u.tch.chan_nr & 7;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
 
-   LOGP(DL1C, LOGL_INFO, "TCH.req: chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "TCH.req: chan_nr=0x%02x "
"fn=%u ts=%u trx=%u\n", l1sap->u.tch.chan_nr,
l1sap->u.tch.fn, tn, l1t->trx->nr);
 
@@ -477,12 +477,12 @@
link_id = trx_chan_desc[chan].link_id;
 
if (!chan_nr) {
-   LOGP(DL1C, LOGL_FATAL, "RTS func for %s with non-existing "
+   LOGP(DL1P, LOGL_FATAL, "RTS func for %s with non-existing "
"chan_nr %d\n", trx_chan_desc[chan].name, chan_nr);
return -ENODEV;
}
 
-   LOGP(DL1C, LOGL_INFO, "PH-RTS.ind: chan=%s chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "PH-RTS.ind: chan=%s chan_nr=0x%02x "
"link_id=0x%02x fn=%u ts=%u trx=%u\n", trx_chan_desc[chan].name,
chan_nr, link_id, fn, tn, l1t->trx->nr);
 
@@ -514,12 +514,12 @@
link_id = trx_chan_desc[chan].link_id;
 
if (!chan_nr) {
-   LOGP(DL1C, LOGL_FATAL, "RTS func for %s with non-existing "
+   LOGP(DL1P, LOGL_FATAL, "RTS func for %s with non-existing "
"chan_nr %d\n", trx_chan_desc[chan].name, chan_nr);
return -ENODEV;
}
 
-   LOGP(DL1C, LOGL_INFO, "TCH RTS.ind: chan=%s chan_nr=0x%02x "
+   LOGP(DL1P, LOGL_INFO, "TCH RTS.ind: chan=%s chan_nr=0x%02x "
"fn=%u ts=%u trx=%u\n", trx_chan_desc[chan].name,
chan_nr, fn, tn, l1t->trx->nr);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a32b83225e931ced561fdf457fa962e8ad44bd2
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


osmocom-bb[master]: VIRT-PHY: enable proper memory leak debugging

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: We don't do line-breaks inside log statements

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: We don't do line-breaks inside log statements
..


VIRT-PHY: We don't do line-breaks inside log statements

Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
---
M src/host/virt_phy/src/virtphy.c
1 file changed, 1 insertion(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 23811c2..e0bee72 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -184,9 +184,7 @@
l1ctl_accept_cb, l1ctl_close_cb, 
l1ctl_sock_path);
g_vphy.virt_um->priv = g_vphy.l1ctl_sock;
 
-   LOGP(DVIRPHY, LOGL_INFO,
-"Virtual physical layer ready...\n \
-   Waiting for l23 app on %s",
+   LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer ready, waiting for l23 
app(s) on %s\n",
 l1ctl_sock_path);
 
while (1) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[master]: VIRT-PHY: enable proper memory leak debugging

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: enable proper memory leak debugging
..


VIRT-PHY: enable proper memory leak debugging

We make sure that all allocations are tracked back to one talloc root
context, and install the usual SIGUSR1 handler to dump the talloc
report.  This enables us to do interactive debugging for memory leaks
while virtphy is running.

Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
---
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virtphy.c
2 files changed, 26 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/virt_l1_sched_simple.c 
b/src/host/virt_phy/src/virt_l1_sched_simple.c
index 7d1cdd4..ba8298f 100644
--- a/src/host/virt_phy/src/virt_l1_sched_simple.c
+++ b/src/host/virt_phy/src/virt_l1_sched_simple.c
@@ -127,7 +127,7 @@
}
if (!mi_fn) {
/* list did not contain mframe item with needed fn */
-   mi_fn = talloc_zero(NULL, struct virt_l1_sched_mframe_item);
+   mi_fn = talloc_zero(ms, struct virt_l1_sched_mframe_item);
mi_fn->fn = fn;
/* need to manually init the struct content no so happy */
mi_fn->tdma_item_list.prev = &mi_fn->tdma_item_list;
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index e0bee72..412b742 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -23,12 +23,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -168,8 +170,29 @@
l1_model_ms_destroy(ms);
 }
 
+static void *tall_vphy_ctx;
+
+static void signal_handler(int signum)
+{
+   LOGP(DMAIN, LOGL_NOTICE, "Signal %d received\n", signum);
+
+   switch (signum) {
+   case SIGUSR1:
+   talloc_report_full(tall_vphy_ctx, stderr);
+   break;
+   default:
+   break;
+   }
+}
+
 int main(int argc, char *argv[])
 {
+   tall_vphy_ctx = talloc_named_const(NULL, 1, "root");
+
+   msgb_talloc_ctx_init(tall_vphy_ctx, 0);
+   signal(SIGUSR1, &signal_handler);
+   osmo_init_ignore_signals();
+
/* init loginfo */
handle_options(argc, argv);
 
@@ -177,10 +200,10 @@
 
LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer starting up...\n");
 
-   g_vphy.virt_um = virt_um_init(NULL, ul_tx_grp, port, dl_rx_grp, port,
+   g_vphy.virt_um = virt_um_init(tall_vphy_ctx, ul_tx_grp, port, 
dl_rx_grp, port,
gsmtapl1_rx_from_virt_um_inst_cb);
 
-   g_vphy.l1ctl_sock = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb,
+   g_vphy.l1ctl_sock = l1ctl_sock_init(tall_vphy_ctx, 
l1ctl_sap_rx_from_l23_inst_cb,
l1ctl_accept_cb, l1ctl_close_cb, 
l1ctl_sock_path);
g_vphy.virt_um->priv = g_vphy.l1ctl_sock;
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmocom-bb[master]: VIRT-PHY: We don't do line-breaks inside log statements

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmo-sccp[master]: sccp: enable global addressbook search

2017-07-19 Thread Neels Hofmeyr

Patch Set 2:

(1 comment)

https://gerrit.osmocom.org/#/c/3265/2/src/osmo_ss7_vty.c
File src/osmo_ss7_vty.c:

Line 966:   llist_for_each_entry(entry, &sccp_address_book_global,
in the vty command to remove an address book entry, we call this function to 
remove a specific instance's address book entry. It feels a bit shaky that this 
function could techincally return a different instance's entry; that vty could 
OSMO_ASSERT(inst) to guard against that case -- but IMHO it's better to have a 
separate function to search globally: these are already two entirely distinct 
function bodies separated by an if().


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


libosmo-sccp[master]: cosmetic: fixup comment

2017-07-19 Thread Neels Hofmeyr

Patch Set 2: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/#/c/3264/2/src/osmo_ss7_vty.c
File src/osmo_ss7_vty.c:

Line 1198: /* Delete an addressbook entry */
the vty command string already says it all, could just drop the comment 
entirely.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8ecad584a1bc9b97693b199abd1ec2e5f6ce156d
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


libosmo-sccp[master]: sccp: improve sccp-addressbook API

2017-07-19 Thread Neels Hofmeyr

Patch Set 1: Code-Review-1

(4 comments)

This should rather be two or three separate patches with more meaningful 
summaries than "improve API".

I believe it would make sense to combine the osmo_sccp_addr_by_name part with 
the 'enable global addressbook search' patch.

https://gerrit.osmocom.org/#/c/3293/1/src/osmo_ss7_vty.c
File src/osmo_ss7_vty.c:

Line 982:  *  \param[in] addr pointer to output the resulting sccp-address;
\param[out]

I would also welcome the name to contain 'dest', maybe dest_addr to make it 
more obvious that it's an out-parameter


Line 983:  *  (set to NULL if not interested)
(indent this second line to line up with the description?)


Line 996:   memcpy(addr, &entry->addr, sizeof(*addr));
rather

  addr = entry->addr;


Line 1004: const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr)
Is this strictly an improvement of the API?


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I68209dd1b2c0aa94b1894637a22b5cc3a3ff1250
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


libosmo-sccp[master]: sccp: ensure addressbook entry names are unique

2017-07-19 Thread Neels Hofmeyr

Patch Set 1: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/#/c/3292/1/src/osmo_ss7_vty.c
File src/osmo_ss7_vty.c:

Line 1209:  }
(Hmm, I would have expected to see an API function that adds an address which 
the vty calls, and to forbid duplicates in that function. But ok, if so far the 
only way to manage address book entries is the vty command, I can accept it. A 
separate address management API would have made sense, but no need to add it 
now, "unfortunately")


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I63227cd87bc24f7d9ac995430b869f0393818335
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


libosmo-sccp[master]: sccp: enable global addressbook search

2017-07-19 Thread Neels Hofmeyr

Patch Set 2: Code-Review-1

(2 comments)

As I said in person, my humble opinion goes against keeping a second list. I 
see less bug surface if we simply iterate the ss7 instances' address lists. 
When each address is in exactly one list (only with its ss7 instance), we don't 
need to take care to keep the separate lists in sync in potentially numerous 
places. (I am tempted to accept the patch, but the more I think about it the 
less I like it)

https://gerrit.osmocom.org/#/c/3265/2/src/osmo_ss7_vty.c
File src/osmo_ss7_vty.c:

Line 987: *ss7)
(As discussed in person yesterday:)

There's a mutability problem with this function, even before this patch: it is 
possible to inadvertently change an address book entry. The returned address 
should be const, or we shoul d copy the found address to a destination struct 
provided by the caller.

Also, if I search globally, I want to know which ss7 instance the address was 
found in.

We discussed yesterday that a good function signature would be:

  struct osmo_ss7_instance *osmo_sccp_addr_by_name(const char *name, struct 
osmo_sccp_addr *dest)

It is then not possible to provide a specific instance to search in, but with 
the global address namespace we deemed that not necessary / to be added later 
if needed.

If no address was found, a NULL return value can indicate that.


Line 1000:  *  \param[in] ss7 instance (NULL to search global)
s/global/in all ss7 instances


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I5acc1e5abc3b3081149a9f476038e4e53d23b763
Gerrit-PatchSet: 2
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: Yes


osmocom-bb[master]: VIRT-PHY: Separate logging of L1 Control and L1 Data

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Idebc371a63508c593855486ff01b2ba6e8c2cfd1
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: Log MS context number whenever possible

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Log MS context number whenever possible
..


VIRT-PHY: Log MS context number whenever possible

Now that we can have multiple MS connected to one virtphy instance,
it is important to log some context whenever possible.  To do so, we
introduce a monotonically increasing MS number which gets assigned
whenever we allocate a l1_model_ms and printed when the LOGPMS() or
DEBUGPMS() macros are used.

Change-Id: Id7d9507126a03def5bd7690f1dbe987f9a749e65
---
M src/host/virt_phy/include/virtphy/logging.h
M src/host/virt_phy/include/virtphy/virt_l1_model.h
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
M src/host/virt_phy/src/logging.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
13 files changed, 71 insertions(+), 45 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/logging.h 
b/src/host/virt_phy/include/virtphy/logging.h
index 6ca2525..c98986c 100644
--- a/src/host/virt_phy/include/virtphy/logging.h
+++ b/src/host/virt_phy/include/virtphy/logging.h
@@ -2,8 +2,15 @@
 
 #include 
 
-#define DL1C 0
-#define DVIRPHY 1
+/* L1CTL related messages */
+enum virtphy_log_cat {
+   DL1C,
+   DVIRPHY,
+   DMAIN
+};
+
+#define LOGPMS(ss, lvl, ms, fmt, args ...) LOGP(ss, lvl, "MS %04u: " fmt, 
ms->nr, ## args)
+#define DEBUGPMS(ss, ms, fmt, args ...)DEBUGP(ss, "MS %04u: " 
fmt, ms->nr, ## args)
 
 extern const struct log_info ms_log_info;
 
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 0cb5381..fa79127 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -93,6 +93,7 @@
 };
 
 struct l1_model_ms {
+   uint32_t nr;
/* pointer to the L1CTL socket client associated with this specific MS 
*/
struct l1ctl_sock_client *lsc;
/* pointer to the (shared) GSMTAP/VirtUM socket to talk to BTS(s) */
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index dfcd5a8..ac1c2b5 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -70,18 +70,18 @@
outmsg->l1h = msgb_data(outmsg);
gh = msgb_l1(outmsg);
if (virt_um_write_msg(ms->vui, outmsg) == -1) {
-   LOGP(DVIRPHY, LOGL_ERROR, "Gsmtap msg could not send to 
virt um - "
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not 
send to virt um - "
 "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
 gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
 gh->sub_slot);
} else {
-   DEBUGP(DVIRPHY, "Sending gsmtap msg to virt um - "
+   DEBUGPMS(DVIRPHY, ms, "Sending gsmtap msg to virt um - "
   "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
   gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
   gh->sub_slot);
}
} else
-   LOGP(DVIRPHY, LOGL_ERROR, "Gsmtap msg could not be created!\n");
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not be 
created!\n");
 
/* free message */
msgb_free(msg);
@@ -118,7 +118,7 @@
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
if (ms->state.serving_cell.arfcn != arfcn) {
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
 arfcn, ms->state.serving_cell.arfcn);
return;
@@ -155,7 +155,7 @@
l1ctl_tx_data_ind(ms, msg, arfcn, link_id, chan_nr, fn, snr_db, 
signal_dbm, 0, 0);
break;
case GSMTAP_CHANNEL_RACH:
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignoring gsmtap msg from virt um - channel type is uplink 
only!\n");
break;
case GSMTAP_CHANNEL_SDCCH:
@@ -165,11 +165,11 @@
case GSMTAP_CHANNEL_PTCCH:
case GSMTAP_CHANNEL_CBCH51:
case GSMTAP_CHANNEL_CBCH52:
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignorin

[MERGED] osmocom-bb[master]: VIRT-PHY: Major rewrite to deal with muliple L1CTL clients

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Major rewrite to deal with muliple L1CTL clients
..


VIRT-PHY: Major rewrite to deal with muliple L1CTL clients

Change-Id: Ibfb2a93f8b45a95215c01368b1a52d92283474e6
---
M src/host/virt_phy/include/virtphy/gsmtapl1_if.h
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/include/virtphy/l1ctl_sock.h
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/include/virtphy/virt_l1_sched.h
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
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
16 files changed, 388 insertions(+), 428 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/gsmtapl1_if.h 
b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
index d8a4367..125ec11 100644
--- a/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
+++ b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
@@ -9,8 +9,4 @@
 void gsmtapl1_init(struct l1_model_ms *model);
 void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui,
   struct msgb *msg);
-void gsmtapl1_rx_from_virt_um(struct msgb *msg);
-void gsmtapl1_tx_to_virt_um_inst(uint32_t fn, struct virt_um_inst *vui, struct 
msgb *msg);
-void gsmtapl1_tx_to_virt_um(uint32_t fn, struct msgb *msg);
-void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
- uint8_t *link_id);
+void gsmtapl1_tx_to_virt_um_inst(struct l1_model_ms *ms, uint32_t fn, struct 
msgb *msg);
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index b84c3e9..5903a02 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -27,17 +27,11 @@
 
 
 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 prim_pm_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);
-void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_inst *lsi,
-   struct msgb *msg);
+void l1ctl_sap_tx_to_l23_inst(struct l1_model_ms *model, struct msgb *msg);
+void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_client *lsc, struct msgb 
*msg);
 void l1ctl_sap_rx_from_l23(struct msgb *msg);
-void l1ctl_sap_handler(struct msgb *msg);
+void l1ctl_sap_handler(struct l1_model_ms *ms, struct msgb *msg);
 
 /* utility methods */
 struct msgb *l1ctl_msgb_alloc(uint8_t msg_type);
@@ -45,39 +39,39 @@
  uint16_t arfcn);
 
 /* receive routines */
-void l1ctl_rx_fbsb_req(struct msgb *msg);
-void l1ctl_rx_dm_est_req(struct msgb *msg);
-void l1ctl_rx_dm_rel_req(struct msgb *msg);
-void l1ctl_rx_param_req(struct msgb *msg);
-void l1ctl_rx_dm_freq_req(struct msgb *msg);
-void l1ctl_rx_crypto_req(struct msgb *msg);
-void l1ctl_rx_rach_req(struct msgb *msg);
-void l1ctl_rx_data_req(struct msgb *msg);
-void l1ctl_rx_pm_req(struct msgb *msg);
-void l1ctl_rx_reset_req(struct msgb *msg);
-void l1ctl_rx_ccch_mode_req(struct msgb *msg);
-void l1ctl_rx_tch_mode_req(struct msgb *msg);
-void l1ctl_rx_neigh_pm_req(struct msgb *msg);
-void l1ctl_rx_traffic_req(struct msgb *msg);
-void l1ctl_rx_sim_req(struct msgb *msg);
+void l1ctl_rx_fbsb_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_est_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_rel_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_param_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_freq_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_crypto_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_rach_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_data_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_pm_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_reset_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_ccch_mode_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_tch_mode_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_neigh_pm_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_traffic_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_sim_req(struct l1_model_ms *, struct msgb *msg);
 
 /* transmit routines */
-v

[MERGED] osmocom-bb[master]: VIRT-PHY: Change default log levels

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Change default log levels
..


VIRT-PHY: Change default log levels

This will basically only print L1C message for all L1CTL happening
between MS and the BTS, while suppressing the GSMTAP/virtUM and L1P
related messages.

Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
---
M src/host/virt_phy/src/virtphy.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 481cdc1..b6f4f0c 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 
-#define DEFAULT_LOG_MASK "DL1C,1:DL1P,1:DVIRPHY,1:DMAIN,1"
+#define DEFAULT_LOG_MASK "DL1C,2:DL1P,2:DVIRPHY,2:DMAIN,1"
 
 /* this exists once in the program, and contains the state that we
  * only keep once:  L1CTL server socket, GSMTAP/VirtUM socket */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmocom-bb[master]: VIRT-PHY: Properly destroy l1_model_ms after disconnect

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: Properly destroy l1_model_ms after disconnect

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Properly destroy l1_model_ms after disconnect
..


VIRT-PHY: Properly destroy l1_model_ms after disconnect

If a MS disconnects, we need to clean up all related state

Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
---
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/include/virtphy/l1ctl_sock.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/l1ctl_sock.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virtphy.c
7 files changed, 33 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index 5903a02..94174da 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -27,7 +27,9 @@
 
 
 void l1ctl_sap_init(struct l1_model_ms *model);
+void l1ctl_sap_exit(struct l1_model_ms *model);
 void prim_pm_init(struct l1_model_ms *model);
+void prim_pm_exit(struct l1_model_ms *model);
 void l1ctl_sap_tx_to_l23_inst(struct l1_model_ms *model, struct msgb *msg);
 void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_client *lsc, struct msgb 
*msg);
 void l1ctl_sap_rx_from_l23(struct msgb *msg);
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sock.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
index 82ee5ca..2c98fa5 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sock.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
@@ -28,6 +28,8 @@
void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb *msg); /* 
Callback function called for incoming data from l2 app. */
/* Callback function called for new client after accept() */
int (*accept_cb)(struct l1ctl_sock_client *lsc);
+   /* Callback function called when client disappeared */
+   void (*close_cb)(struct l1ctl_sock_client *lsc);
 };
 
 /**
@@ -37,6 +39,7 @@
 void *ctx,
 void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb 
*msg),
 int (*accept_cb)(struct l1ctl_sock_client *lsc),
+void (*close_cb)(struct l1ctl_sock_client *lsc),
 char *path);
 
 /**
diff --git a/src/host/virt_phy/src/l1ctl_sap.c 
b/src/host/virt_phy/src/l1ctl_sap.c
index c7c8e3e..d4b33f1 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -58,6 +58,12 @@
prim_pm_init(model);
 }
 
+void l1ctl_sap_exit(struct l1_model_ms *model)
+{
+   virt_l1_sched_stop(model);
+   prim_pm_exit(model);
+}
+
 /**
  * @brief L1CTL handler called for received messages from L23.
  *
diff --git a/src/host/virt_phy/src/l1ctl_sock.c 
b/src/host/virt_phy/src/l1ctl_sock.c
index 00f25a6..bf28895 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -47,6 +47,9 @@
 
 static void l1ctl_client_destroy(struct l1ctl_sock_client *lsc)
 {
+   struct l1ctl_sock_inst *lsi = lsc->l1ctl_sock;
+   if (lsi->close_cb)
+   lsi->close_cb(lsc);
osmo_fd_close(&lsc->ofd);
llist_del(&lsc->list);
talloc_free(lsc);
@@ -149,6 +152,7 @@
 void *ctx,
 void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb 
*msg),
 int (*accept_cb)(struct l1ctl_sock_client *lsc),
+void (*close_cb)(struct l1ctl_sock_client *lsc),
 char *path)
 {
struct l1ctl_sock_inst *lsi;
@@ -172,6 +176,7 @@
 
lsi->recv_cb = recv_cb;
lsi->accept_cb = accept_cb;
+   lsi->close_cb = close_cb;
lsi->l1ctl_sock_path = path;
INIT_LLIST_HEAD(&lsi->clients);
 
diff --git a/src/host/virt_phy/src/virt_l1_model.c 
b/src/host/virt_phy/src/virt_l1_model.c
index 14676b0..6a9fa99 100644
--- a/src/host/virt_phy/src/virt_l1_model.c
+++ b/src/host/virt_phy/src/virt_l1_model.c
@@ -46,5 +46,6 @@
 void l1_model_ms_destroy(struct l1_model_ms *model)
 {
LOGPMS(DMAIN, LOGL_INFO, model, "destryed\n");
+   l1ctl_sap_exit(model);
talloc_free(model);
 }
diff --git a/src/host/virt_phy/src/virt_prim_pm.c 
b/src/host/virt_phy/src/virt_prim_pm.c
index 1cd3c03..4637013 100644
--- a/src/host/virt_phy/src/virt_prim_pm.c
+++ b/src/host/virt_phy/src/virt_prim_pm.c
@@ -138,3 +138,12 @@
l1s->pm.meas.arfcn_sig_lev_timers[i].data = 
&l1s->pm.meas.arfcn_sig_lev_dbm[i];
}
 }
+
+void prim_pm_exit(struct l1_model_ms *model)
+{
+   struct l1_state_ms *l1s = &model->state;
+   int i;
+
+   for (i = 0; i < 1024; ++i)
+   osmo_timer_del(&l1s->pm.meas.arfcn_sig_lev_timers[i]);
+}
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index b6f4f0c..23811c2 100644
--- a/src/host/virt_phy/src/virtphy

osmocom-bb[master]: VIRT-PHY: Clean up logging statements

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: If06a8b5f99349796d66a71201524361a6547945a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[master]: VIRT-PHY: Change default log levels

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: Clean up logging statements

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Clean up logging statements
..


VIRT-PHY: Clean up logging statements

The generated log lines have been *super* long, let's make them
significantly shorter.  Also, differentiate between DEBUG and INFO
level, so normal operation with LOGL_INFO will not spam the user while
still printing useful information.

Change-Id: If06a8b5f99349796d66a71201524361a6547945a
---
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
7 files changed, 66 insertions(+), 59 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index ac1c2b5..5454022 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,6 +39,14 @@
 #include 
 #include 
 #include 
+
+static char *pseudo_lchan_name(uint16_t arfcn, uint8_t ts, uint8_t ss, uint8_t 
sub_type)
+{
+   static char lname[64];
+   snprintf(lname, sizeof(lname), "(arfcn=%u,ts=%u,ss=%u,type=%s)",
+   arfcn, ts, ss, get_value_string(gsmtap_gsm_channel_names, 
sub_type));
+   return lname;
+}
 
 /**
  * Replace l11 header of given msgb by a gsmtap header and send it over the 
virt um.
@@ -70,18 +79,16 @@
outmsg->l1h = msgb_data(outmsg);
gh = msgb_l1(outmsg);
if (virt_um_write_msg(ms->vui, outmsg) == -1) {
-   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not 
send to virt um - "
-"(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
-gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
-gh->sub_slot);
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "%s Tx go GSMTAP 
failed: %s\n",
+   pseudo_lchan_name(gh->arfcn, gh->timeslot, 
gh->sub_slot, gh->sub_type),
+   strerror(errno));
} else {
-   DEBUGPMS(DVIRPHY, ms, "Sending gsmtap msg to virt um - "
-  "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
-  gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
-  gh->sub_slot);
+   DEBUGPMS(DVIRPHY, ms, "%s: Tx to GSMTAP: %s\n",
+   pseudo_lchan_name(gh->arfcn, gh->timeslot, 
gh->sub_slot, gh->sub_type),
+   osmo_hexdump(data, data_len));
}
} else
-   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not be 
created!\n");
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "GSMTAP msg could not be 
created!\n");
 
/* free message */
msgb_free(msg);
@@ -118,9 +125,6 @@
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
if (ms->state.serving_cell.arfcn != arfcn) {
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
-arfcn, ms->state.serving_cell.arfcn);
return;
}
 
@@ -155,8 +159,7 @@
l1ctl_tx_data_ind(ms, msg, arfcn, link_id, chan_nr, fn, snr_db, 
signal_dbm, 0, 0);
break;
case GSMTAP_CHANNEL_RACH:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type is uplink 
only!\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unexpected RACH in 
downlink ?!?\n");
break;
case GSMTAP_CHANNEL_SDCCH:
case GSMTAP_CHANNEL_CCCH:
@@ -165,12 +168,12 @@
case GSMTAP_CHANNEL_PTCCH:
case GSMTAP_CHANNEL_CBCH51:
case GSMTAP_CHANNEL_CBCH52:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type not 
supported!\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unsupported channel 
type %s\n",
+   get_value_string(gsmtap_gsm_channel_names, 
gsmtap_chantype));
break;
default:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type 
unknown.\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unknown channel type 
%s\n",
+   get_value_string(gsmtap_gsm_channel_names, 
gsmtap_chantype));
break;

osmocom-bb[master]: VIRT-PHY: Log MS context number whenever possible

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id7d9507126a03def5bd7690f1dbe987f9a749e65
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: Separate logging of L1 Control and L1 Data

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Separate logging of L1 Control and L1 Data
..


VIRT-PHY: Separate logging of L1 Control and L1 Data

L1 Data is quite verbose, while control is typically limited, so let's
make sure we log them as separate sub-systems

Change-Id: Idebc371a63508c593855486ff01b2ba6e8c2cfd1
---
M src/host/virt_phy/include/virtphy/logging.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/logging.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
6 files changed, 37 insertions(+), 7 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/logging.h 
b/src/host/virt_phy/include/virtphy/logging.h
index c98986c..b22db99 100644
--- a/src/host/virt_phy/include/virtphy/logging.h
+++ b/src/host/virt_phy/include/virtphy/logging.h
@@ -5,6 +5,7 @@
 /* L1CTL related messages */
 enum virtphy_log_cat {
DL1C,
+   DL1P,
DVIRPHY,
DMAIN
 };
diff --git a/src/host/virt_phy/src/l1ctl_sap.c 
b/src/host/virt_phy/src/l1ctl_sap.c
index 6bd63c9..d896042 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -70,7 +70,6 @@
if (!msg)
return;
 
-   DEBUGPMS(DL1C, ms, "Message incoming from layer 2: %s\n", 
osmo_hexdump(msg->data, msg->len));
l1ctl_sap_handler(ms, msg);
 }
 
@@ -146,6 +145,20 @@
return msg;
 }
 
+static bool is_l1ctl_control(uint8_t msg_type)
+{
+   switch (msg_type) {
+   case L1CTL_DATA_REQ:
+   case L1CTL_DATA_CONF:
+   case L1CTL_TRAFFIC_REQ:
+   case L1CTL_TRAFFIC_CONF:
+   case L1CTL_TRAFFIC_IND:
+   return false;
+   default:
+   return true;
+   }
+}
+
 /**
  * @brief General handler for incoming L1CTL messages from layer 2/3.
  *
@@ -154,6 +167,7 @@
 void l1ctl_sap_handler(struct l1_model_ms *ms, struct msgb *msg)
 {
struct l1ctl_hdr *l1h;
+   int log_subsys;
 
if (!msg)
return;
@@ -165,6 +179,13 @@
goto exit_msgbfree;
}
 
+   if (is_l1ctl_control(l1h->msg_type))
+   log_subsys = DL1C;
+   else
+   log_subsys = DL1P;
+
+   DEBUGPMS(log_subsys, ms, "Message incoming from layer 2: %s\n", 
osmo_hexdump(msg->data, msg->len));
+
switch (l1h->msg_type) {
case L1CTL_FBSB_REQ:
l1ctl_rx_fbsb_req(ms, msg);
diff --git a/src/host/virt_phy/src/logging.c b/src/host/virt_phy/src/logging.c
index 7fb2c23..feb5081 100644
--- a/src/host/virt_phy/src/logging.c
+++ b/src/host/virt_phy/src/logging.c
@@ -64,7 +64,15 @@
.description = "Layer 1 Control",
.color = "\033[1;31m",
.enabled = 1,
-   .loglevel = LOGL_DEBUG, },
+   .loglevel = LOGL_DEBUG,
+   },
+   [DL1P] = {
+   .name = "DL1P",
+   .description = "Layer 1 Data",
+   .color = "\033[1;31m",
+   .enabled = 1,
+   .loglevel = LOGL_DEBUG,
+   },
[DVIRPHY] = {
.name = "DVIRPHY",
.description = "Virtual Layer 1 Interface",
diff --git a/src/host/virt_phy/src/virt_prim_data.c 
b/src/host/virt_phy/src/virt_prim_data.c
index e03d097..cf34e7a 100644
--- a/src/host/virt_phy/src/virt_prim_data.c
+++ b/src/host/virt_phy/src/virt_prim_data.c
@@ -71,7 +71,7 @@
ul->chan_nr, ul->link_id);
 
rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, ×lot);
-   DEBUGPMS(DL1C, ms,
+   DEBUGPMS(DL1P, ms,
   "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);
@@ -107,7 +107,7 @@
 
memcpy(l1di->data, msgb_data(msg), msgb_length(msg));
 
-   DEBUGPMS(DL1C, ms, "Sending signaling-data to l23.\n");
+   DEBUGPMS(DL1P, ms, "Sending signaling-data to l23.\n");
l1ctl_sap_tx_to_l23_inst(ms, l1ctl_msg);
 }
 
diff --git a/src/host/virt_phy/src/virt_prim_traffic.c 
b/src/host/virt_phy/src/virt_prim_traffic.c
index 04f6749..46ba9f1 100644
--- a/src/host/virt_phy/src/virt_prim_traffic.c
+++ b/src/host/virt_phy/src/virt_prim_traffic.c
@@ -69,7 +69,7 @@
uint32_t fn_sched = sched_fn_ul(ms->state.current_time, ul->chan_nr, 
ul->link_id);
 
rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, ×lot);
-   DEBUGPMS(DL1C, ms, "Received and handled from l23 - 
L1CTL_TRAFFIC_REQ\n");
+   DEBUGPMS(DL1P, ms, "Received and handled from l23 - 
L1CTL_TRAFFIC_REQ\n");
 
msg->l2h = tr->data;
 
@@ -102,7 +102,7 @@
/* TODO: traffic decoding and decryption */
 
 

osmocom-bb[master]: VIRT-PHY: Major rewrite to deal with muliple L1CTL clients

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibfb2a93f8b45a95215c01368b1a52d92283474e6
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmocom-bb[master]: VIRT-PHY: We don't do line-breaks inside log statements

2017-07-19 Thread Harald Welte

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

VIRT-PHY: We don't do line-breaks inside log statements

Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
---
M src/host/virt_phy/src/virtphy.c
1 file changed, 1 insertion(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/94/3294/1

diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 23811c2..e0bee72 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -184,9 +184,7 @@
l1ctl_accept_cb, l1ctl_close_cb, 
l1ctl_sock_path);
g_vphy.virt_um->priv = g_vphy.l1ctl_sock;
 
-   LOGP(DVIRPHY, LOGL_INFO,
-"Virtual physical layer ready...\n \
-   Waiting for l23 app on %s",
+   LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer ready, waiting for l23 
app(s) on %s\n",
 l1ctl_sock_path);
 
while (1) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I27cba13ee782c53a9b2406319241fc7f4e3db0bd
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: enable proper memory leak debugging

2017-07-19 Thread Harald Welte

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

VIRT-PHY: enable proper memory leak debugging

We make sure that all allocations are tracked back to one talloc root
context, and install the usual SIGUSR1 handler to dump the talloc
report.  This enables us to do interactive debugging for memory leaks
while virtphy is running.

Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
---
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virtphy.c
2 files changed, 26 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/95/3295/1

diff --git a/src/host/virt_phy/src/virt_l1_sched_simple.c 
b/src/host/virt_phy/src/virt_l1_sched_simple.c
index 7d1cdd4..ba8298f 100644
--- a/src/host/virt_phy/src/virt_l1_sched_simple.c
+++ b/src/host/virt_phy/src/virt_l1_sched_simple.c
@@ -127,7 +127,7 @@
}
if (!mi_fn) {
/* list did not contain mframe item with needed fn */
-   mi_fn = talloc_zero(NULL, struct virt_l1_sched_mframe_item);
+   mi_fn = talloc_zero(ms, struct virt_l1_sched_mframe_item);
mi_fn->fn = fn;
/* need to manually init the struct content no so happy */
mi_fn->tdma_item_list.prev = &mi_fn->tdma_item_list;
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index e0bee72..412b742 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -23,12 +23,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -168,8 +170,29 @@
l1_model_ms_destroy(ms);
 }
 
+static void *tall_vphy_ctx;
+
+static void signal_handler(int signum)
+{
+   LOGP(DMAIN, LOGL_NOTICE, "Signal %d received\n", signum);
+
+   switch (signum) {
+   case SIGUSR1:
+   talloc_report_full(tall_vphy_ctx, stderr);
+   break;
+   default:
+   break;
+   }
+}
+
 int main(int argc, char *argv[])
 {
+   tall_vphy_ctx = talloc_named_const(NULL, 1, "root");
+
+   msgb_talloc_ctx_init(tall_vphy_ctx, 0);
+   signal(SIGUSR1, &signal_handler);
+   osmo_init_ignore_signals();
+
/* init loginfo */
handle_options(argc, argv);
 
@@ -177,10 +200,10 @@
 
LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer starting up...\n");
 
-   g_vphy.virt_um = virt_um_init(NULL, ul_tx_grp, port, dl_rx_grp, port,
+   g_vphy.virt_um = virt_um_init(tall_vphy_ctx, ul_tx_grp, port, 
dl_rx_grp, port,
gsmtapl1_rx_from_virt_um_inst_cb);
 
-   g_vphy.l1ctl_sock = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb,
+   g_vphy.l1ctl_sock = l1ctl_sock_init(tall_vphy_ctx, 
l1ctl_sap_rx_from_l23_inst_cb,
l1ctl_accept_cb, l1ctl_close_cb, 
l1ctl_sock_path);
g_vphy.virt_um->priv = g_vphy.l1ctl_sock;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73b3cf86eea5f56595c1b045cf0fde8035ff185a
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] libosmo-sccp[master]: vty: make addressbook available for _sg and _asp

2017-07-19 Thread Neels Hofmeyr
Neels Hofmeyr has submitted this change and it was merged.

Change subject: vty: make addressbook available for _sg and _asp
..


vty: make addressbook available for _sg and _asp

The installation of the vty commands for the sccp addressbook is
currently located in osmo_ss7_vty_init_sg(), which is normally
only used in signalling gateway applications. An ASP would lack
the addressbook functionality.

Make SCCP addressbook available for both SG and ASP

Change-Id: Ib49ab623055e9ada7f95e0163ba7e33c5f6f99cb
---
M src/osmo_ss7_vty.c
1 file changed, 37 insertions(+), 32 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index b06f554..9a4e963 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1587,6 +1587,41 @@
}
 }
 
+/* Commands for SCCP-Addressbook */
+static void vty_init_addr(void)
+{
+   install_node(&sccpaddr_node, NULL);
+   vty_install_default(L_CS7_SCCPADDR_NODE);
+   install_element(L_CS7_NODE, &cs7_show_sccpaddr_cmd);
+   install_element(L_CS7_NODE, &cs7_sccpaddr_cmd);
+   install_element(L_CS7_NODE, &cs7_sccpaddr_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_del_cmd);
+#if 0
+   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
+* so we leave the related VTY options out for now */
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ip_del_cmd);
+#endif
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ri_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_cmd);
+#if 0
+   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
+* so we leave the related VTY options out for now */
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv4_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv6_cmd);
+#endif
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_cmd);
+   install_node(&sccpaddr_gt_node, NULL);
+   vty_install_default(L_CS7_SCCPADDR_GT_NODE);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_gti_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_tt_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_npi_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_nai_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_digits_cmd);
+}
+
 static void vty_init_shared(void)
 {
install_element_ve(&show_cs7_user_cmd);
@@ -1628,6 +1663,8 @@
install_element(L_CS7_AS_NODE, &as_qos_class_cmd);
install_element(L_CS7_AS_NODE, &as_rout_key_cmd);
install_element(L_CS7_AS_NODE, &as_pc_override_cmd);
+
+   vty_init_addr();
 }
 
 void osmo_ss7_vty_init_asp(void)
@@ -1653,38 +1690,6 @@
install_element(L_CS7_NODE, &no_cs7_xua_cmd);
install_element(L_CS7_XUA_NODE, &xua_local_ip_cmd);
install_element(L_CS7_XUA_NODE, &xua_accept_dyn_asp_cmd);
-
-   /* Commands for SCCP-Addressbook */
-   install_node(&sccpaddr_node, NULL);
-   vty_install_default(L_CS7_SCCPADDR_NODE);
-   install_element(L_CS7_NODE, &cs7_show_sccpaddr_cmd);
-   install_element(L_CS7_NODE, &cs7_sccpaddr_cmd);
-   install_element(L_CS7_NODE, &cs7_sccpaddr_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_del_cmd);
-#if 0
-   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
-* so we leave the related VTY options out for now */
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ip_del_cmd);
-#endif
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ri_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_cmd);
-#if 0
-   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
-* so we leave the related VTY options out for now */
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv4_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv6_cmd);
-#endif
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_cmd);
-   install_node(&sccpaddr_gt_node, NULL);
-   vty_install_default(L_CS7_SCCPADDR_GT_NODE);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_gti_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_tt_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_npi_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &c

libosmo-sccp[master]: vty: make addressbook available for _sg and _asp

2017-07-19 Thread Neels Hofmeyr

Patch Set 6: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib49ab623055e9ada7f95e0163ba7e33c5f6f99cb
Gerrit-PatchSet: 6
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[PATCH] libosmo-sccp[master]: vty: make addressbook available for _sg and _asp

2017-07-19 Thread Neels Hofmeyr
Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/3103

to look at the new patch set (#6).

vty: make addressbook available for _sg and _asp

The installation of the vty commands for the sccp addressbook is
currently located in osmo_ss7_vty_init_sg(), which is normally
only used in signalling gateway applications. An ASP would lack
the addressbook functionality.

Make SCCP addressbook available for both SG and ASP

Change-Id: Ib49ab623055e9ada7f95e0163ba7e33c5f6f99cb
---
M src/osmo_ss7_vty.c
1 file changed, 37 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/03/3103/6

diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index b06f554..9a4e963 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1587,6 +1587,41 @@
}
 }
 
+/* Commands for SCCP-Addressbook */
+static void vty_init_addr(void)
+{
+   install_node(&sccpaddr_node, NULL);
+   vty_install_default(L_CS7_SCCPADDR_NODE);
+   install_element(L_CS7_NODE, &cs7_show_sccpaddr_cmd);
+   install_element(L_CS7_NODE, &cs7_sccpaddr_cmd);
+   install_element(L_CS7_NODE, &cs7_sccpaddr_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_del_cmd);
+#if 0
+   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
+* so we leave the related VTY options out for now */
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ip_del_cmd);
+#endif
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_del_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ri_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_cmd);
+#if 0
+   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
+* so we leave the related VTY options out for now */
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv4_cmd);
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv6_cmd);
+#endif
+   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_cmd);
+   install_node(&sccpaddr_gt_node, NULL);
+   vty_install_default(L_CS7_SCCPADDR_GT_NODE);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_gti_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_tt_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_npi_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_nai_cmd);
+   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_digits_cmd);
+}
+
 static void vty_init_shared(void)
 {
install_element_ve(&show_cs7_user_cmd);
@@ -1628,6 +1663,8 @@
install_element(L_CS7_AS_NODE, &as_qos_class_cmd);
install_element(L_CS7_AS_NODE, &as_rout_key_cmd);
install_element(L_CS7_AS_NODE, &as_pc_override_cmd);
+
+   vty_init_addr();
 }
 
 void osmo_ss7_vty_init_asp(void)
@@ -1653,38 +1690,6 @@
install_element(L_CS7_NODE, &no_cs7_xua_cmd);
install_element(L_CS7_XUA_NODE, &xua_local_ip_cmd);
install_element(L_CS7_XUA_NODE, &xua_accept_dyn_asp_cmd);
-
-   /* Commands for SCCP-Addressbook */
-   install_node(&sccpaddr_node, NULL);
-   vty_install_default(L_CS7_SCCPADDR_NODE);
-   install_element(L_CS7_NODE, &cs7_show_sccpaddr_cmd);
-   install_element(L_CS7_NODE, &cs7_sccpaddr_cmd);
-   install_element(L_CS7_NODE, &cs7_sccpaddr_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_del_cmd);
-#if 0
-   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
-* so we leave the related VTY options out for now */
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ip_del_cmd);
-#endif
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_del_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ri_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_pc_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ssn_cmd);
-#if 0
-   /* FIXME: IP-Address based SCCP-Routing is currently not supported,
-* so we leave the related VTY options out for now */
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv4_cmd);
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_ipv6_cmd);
-#endif
-   install_element(L_CS7_SCCPADDR_NODE, &cs7_sccpaddr_gt_cmd);
-   install_node(&sccpaddr_gt_node, NULL);
-   vty_install_default(L_CS7_SCCPADDR_GT_NODE);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_gti_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_tt_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_npi_cmd);
-   install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_nai_cmd);
-   install_e

[MERGED] osmocom-bb[master]: VIRT-PHY: Use IPv4 multicast groups for private / local scope

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Use IPv4 multicast groups for private / local scope
..


VIRT-PHY: Use IPv4 multicast groups for private / local scope

The addresses in the original code make little sense:
* 224.0.0.1 is "All systems on this subnet" and not routed
  outside the local ethernet segment
* 225.0.0.1 is in a RESERVED range that shouldn't be used

Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
---
M src/host/virt_phy/include/virtphy/virtual_um.h
1 file changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index 6e7c384..ac098dd 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -4,10 +4,15 @@
 #include 
 #include "osmo_mcast_sock.h"
 
+/* We use multicast group addresses from the 239.192.0.0/14 rage, as
+ * those are designated by RFC2365 as "IPv4 Organization Local Scope,
+ * "... the space from which an organization should allocate sub-
+ *  ranges when defining scopes for private use." */
+
 #define VIRT_UM_MSGB_SIZE  256
-#define DEFAULT_MS_MCAST_GROUP "224.0.0.1"
+#define DEFAULT_MS_MCAST_GROUP "239.193.23.1"
 #define DEFAULT_MS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
-#define DEFAULT_BTS_MCAST_GROUP "225.0.0.1"
+#define DEFAULT_BTS_MCAST_GROUP"239.193.23.2"
 #define DEFAULT_BTS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 
 struct virt_um_inst {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[master]: VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP, ALL} flags

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP,ALL} flags
..


VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP,ALL} flags

libosmocore has recently gained support for flags like
OSMO_SOCK_F_NO_MCAST_LOOP and OSMO_SOCK_F_NO_MCAST_ALL that can be
passed to the socket initializer functions, further reducing complexity
of the code in osmo_mcast_sock.c here.

The related change-IDs are I5ab5de45c0b64ceb3636ea98245a23defa24ffd4 and
I24a5b1ebc3f84d2d5d4734e54df50efaea26490b in libosmocore.git.

Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 8 insertions(+), 36 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c 
b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index df3abc3..0521c0d 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -28,21 +28,16 @@
uint16_t tx_mcast_port, bool loopback)
 {
int rc;
+   unsigned int flags = OSMO_SOCK_F_CONNECT;
+
+   if (!loopback)
+   flags |= OSMO_SOCK_F_NO_MCAST_LOOP;
 
/* setup mcast server socket */
rc = osmo_sock_init_ofd(ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-   tx_mcast_group, tx_mcast_port, 
OSMO_SOCK_F_CONNECT);
+   tx_mcast_group, tx_mcast_port, flags);
if (rc < 0) {
perror("Failed to create Multicast Server Socket");
-   return rc;
-   }
-
-   /* determines whether sent mcast packets should be looped back to the 
local sockets.
-* loopback must be enabled if the mcast client is on the same machine 
*/
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, 
sizeof(loopback));
-   if (rc < 0) {
-   perror("Failed to configure multicast loopback.\n");
-   fd_close(ofd);
return rc;
}
 
@@ -56,8 +51,7 @@
int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int 
what),
void *osmo_fd_data)
 {
-   struct ip_mreq mreq;
-   int rc, loopback = 1, all = 0;
+   int rc;
 
ofd->cb = fd_rx_cb;
ofd->when = BSC_FD_READ;
@@ -65,38 +59,16 @@
 
/* Create mcast client socket */
rc = osmo_sock_init_ofd(ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-   NULL, mcast_port, OSMO_SOCK_F_BIND);
+   NULL, mcast_port, 
OSMO_SOCK_F_BIND|OSMO_SOCK_F_NO_MCAST_ALL);
if (rc < 0) {
perror("Could not create mcast client socket");
return rc;
}
 
-   /* Enable loopback of msgs to the host. */
-   /* Loopback must be enabled for the client, so multiple
-* processes are able to receive a mcast package. */
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP,
-   &loopback, sizeof(loopback));
-   if (rc < 0) {
-   perror("Failed to enable IP_MULTICAST_LOOP");
-   fd_close(ofd);
-   return rc;
-   }
-
/* Configure and join the multicast group */
-   memset(&mreq, 0, sizeof(mreq));
-   mreq.imr_multiaddr.s_addr = inet_addr(mcast_group);
-   mreq.imr_interface.s_addr = htonl(INADDR_ANY);
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, 
sizeof(mreq));
+   rc = osmo_sock_mcast_subscribe(ofd->fd, mcast_group);
if (rc < 0) {
perror("Failed to join to mcast goup");
-   fd_close(ofd);
-   return rc;
-   }
-
-   /* this option will set the delivery option so that only packets
-* from sockets we are subscribed to via IP_ADD_MEMBERSHIP are received 
*/
-   if (setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_ALL, &all, 
sizeof(all)) < 0) {
-   perror("Failed to modify delivery policy to explicitly 
joined.\n");
fd_close(ofd);
return rc;
}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[master]: VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore
..


VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore

Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
---
M src/host/virt_phy/include/virtphy/virtual_um.h
M src/host/virt_phy/src/virtphy.c
2 files changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index 79d74a5..52f2df6 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -17,9 +17,7 @@
 
 #define VIRT_UM_MSGB_SIZE  256
 #define DEFAULT_MS_MCAST_GROUP "239.193.23.1"
-#define DEFAULT_MS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 #define DEFAULT_BTS_MCAST_GROUP"239.193.23.2"
-#define DEFAULT_BTS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 
 struct virt_um_inst {
void *priv;
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 43346ed..28dd685 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,12 +35,11 @@
 #include 
 #include 
 
-#define DEFAULT_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 #define DEFAULT_LOG_MASK "DL1C,1:DVIRPHY,1"
 
 static char *dl_rx_grp = DEFAULT_MS_MCAST_GROUP;
 static char *ul_tx_grp = DEFAULT_BTS_MCAST_GROUP;
-static int port = DEFAULT_MCAST_PORT;
+static int port = GSMTAP_UDP_PORT;
 static char *log_mask = DEFAULT_LOG_MASK;
 static char *l1ctl_sock_path = L1CTL_SOCK_PATH;
 static char *arfcn_sig_lev_red_mask = NULL;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmocom-bb[master]: VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY Use libosmocore unix domain socket helper

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY Use libosmocore unix domain socket helper
..


VIRT-PHY Use libosmocore unix domain socket helper

Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
---
M src/host/virt_phy/src/l1ctl_sock.c
1 file changed, 11 insertions(+), 28 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/l1ctl_sock.c 
b/src/host/virt_phy/src/l1ctl_sock.c
index 2e16bfa..370d3f3 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -32,13 +32,13 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -102,11 +102,9 @@
 {
 
struct l1ctl_sock_inst *lsi = ofd->data;
-   struct sockaddr_un local_addr;
-   socklen_t addr_len = sizeof(struct sockaddr_in);
int fd;
 
-   fd = accept(ofd->fd, (struct sockaddr *)&local_addr, &addr_len);
+   fd = accept(ofd->fd, NULL, NULL);
if (fd < 0) {
fprintf(stderr, "Failed to accept connection to l2.\n");
return -1;
@@ -130,39 +128,24 @@
 char *path)
 {
struct l1ctl_sock_inst *lsi;
-   struct sockaddr_un local_addr;
-   int fd, rc;
+   int rc;
 
if (!path)
path = L1CTL_SOCK_PATH;
 
-   if ((fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
-   fprintf(stderr, "Failed to create Unix Domain Socket.\n");
-   return NULL;
-   }
-
-   local_addr.sun_family = AF_LOCAL;
-   strcpy(local_addr.sun_path, path);
-   unlink(local_addr.sun_path);
-
-   if ((rc = bind(fd, (struct sockaddr *)&local_addr, sizeof(local_addr))) 
!= 0) {
-   fprintf(stderr, "Failed to bind the unix domain socket. '%s'\n",
-   local_addr.sun_path);
-   return NULL;
-   }
-
-   if (listen(fd, 0) != 0) {
-   fprintf(stderr, "Failed to listen.\n");
-   return NULL;
-   }
-
lsi = talloc_zero(ctx, struct l1ctl_sock_inst);
lsi->priv = NULL;
-   lsi->recv_cb = recv_cb;
lsi->ofd.data = lsi;
-   lsi->ofd.fd = fd;
lsi->ofd.when = BSC_FD_READ;
lsi->ofd.cb = l1ctl_sock_accept_cb;
+
+   rc = osmo_sock_unix_init_ofd(&lsi->ofd, SOCK_STREAM, 0, path, 
OSMO_SOCK_F_BIND);
+   if (rc < 0) {
+   talloc_free(lsi);
+   return NULL;
+   }
+
+   lsi->recv_cb = recv_cb;
/* no connection -> invalid filedescriptor and not 0 (==std_in) */
lsi->connection.fd = -1;
lsi->l1ctl_sock_path = path;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[master]: VIRT-PHY: reorganize data structures

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: reorganize data structures
..


VIRT-PHY: reorganize data structures

* l1_model_ms can become a static member of l1_model_ms
* crypto_info_ms can become a static member of l1_state_ms

Change-Id: I94ca4dad1c6c668ce6307d5e5d728b1c1502af12
---
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
11 files changed, 82 insertions(+), 77 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 991cb1a..61776ec 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -18,13 +18,6 @@
 };
 
 
-struct l1_model_ms {
-   struct l1ctl_sock_inst *lsi;
-   struct virt_um_inst *vui;
-   struct l1_state_ms *state;
-   struct crypto_info_ms *crypto_inf;
-};
-
 /* structure representing L1 sync information about a cell */
 struct l1_cell_info {
/* on which ARFCN (+band) is the cell? */
@@ -53,12 +46,13 @@
struct gsm_time downlink_time;  /* current GSM time received on 
downlink */
struct gsm_time current_time; /* GSM time used internally for 
scheduling */
 
-   uint8_t state; // the ms state like in ms_state
+   enum ms_state state;
 
/* the cell on which we are camping right now */
struct l1_cell_info serving_cell;
/* neighbor cell sync info */
struct l1_cell_info neigh_cell[L1S_NUM_NEIGH_CELL];
+   struct crypto_info_ms crypto_inf;
 
/* TCH info */
uint8_t tch_mode; // see enum gsm48_chan_mode in gsm_04_08.h
@@ -94,6 +88,13 @@
} pm;
 };
 
+struct l1_model_ms {
+   struct l1ctl_sock_inst *lsi;
+   struct virt_um_inst *vui;
+   struct l1_state_ms state;
+};
+
+
 struct l1_model_ms *l1_model_ms_init(void *ctx);
 
 void l1_model_ms_destroy(struct l1_model_ms *model);
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index 2624046..18580b4 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -55,7 +55,7 @@
struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
struct gsmtap_hdr *gh;
struct msgb *outmsg;/* msg to send with gsmtap header prepended */
-   uint16_t arfcn = l1_model_ms->state->serving_cell.arfcn;/* 
arfcn of the cell we currently camp on */
+   uint16_t arfcn = l1_model_ms->state.serving_cell.arfcn; /* arfcn of the 
cell we currently camp on */
uint8_t signal_dbm = 63;/* signal strength */
uint8_t snr = 63;   /* signal noise ratio, 63 is best */
uint8_t *data = msgb_l2(msg);   /* data to transmit (whole message 
without l1 header) */
@@ -145,19 +145,19 @@
goto freemsg;
}
/* we do not forward messages to l23 if we are in network search state 
*/
-   if (l1_model_ms->state->state == MS_STATE_IDLE_SEARCHING)
+   if (l1_model_ms->state.state == MS_STATE_IDLE_SEARCHING)
goto freemsg;
 
/* forward downlink msg to fbsb sync routine if we are in sync state */
-   if (l1_model_ms->state->state == MS_STATE_IDLE_SYNCING) {
+   if (l1_model_ms->state.state == MS_STATE_IDLE_SYNCING) {
prim_fbsb_sync(msg);
return;
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
-   if (l1_model_ms->state->serving_cell.arfcn != arfcn) {
+   if (l1_model_ms->state.serving_cell.arfcn != arfcn) {
LOGP(DVIRPHY, LOGL_NOTICE,
 "Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
-arfcn, l1_model_ms->state->serving_cell.arfcn);
+arfcn, l1_model_ms->state.serving_cell.arfcn);
goto freemsg;
}
 
@@ -166,8 +166,8 @@
/* see TS 08.58 -> 9.3.1 for channel number encoding */
chan_nr = rsl_enc_chan_nr(rsl_chantype, subslot, timeslot);
 
-   gsm_fn2gsmtime(&l1_model_ms->state->downlink_time, fn);
-   virt_l1_sched_sync_time(l1_model_ms->state->downlink_time, 0);
+   gsm_fn2gsmtime(&l1_model_ms->state.downlink_time, fn);
+   virt_l1_sched_sync_time(l1_model_ms->state.downlink_time, 0);
virt_l1_sched_execute(fn);
 
DEBUGP(DVIRPHY, "Receiving gsmtap msg from virt um - "
@@ -191,8 +19

osmocom-bb[master]: VIRT-PHY Use libosmocore unix domain socket helper

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmocom-bb[master]: VIRT-PHY: some more comments/documentation

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: some more comments/documentation
..


VIRT-PHY: some more comments/documentation

Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
---
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/include/virtphy/virtual_um.h
2 files changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 296931a..991cb1a 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -1,5 +1,7 @@
 #pragma once
 
+/* Per-MS specific state, closely attached to the L1CTL user progran */
+
 #include 
 #include 
 #include 
diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index ac098dd..79d74a5 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -1,5 +1,11 @@
 #pragma once
 
+/* the "Virtual Um instance" encapsulates the multicast UDP sockets as
+ * well as the encoding and decoding of GSMTAP messages towards the
+ * virtual radio interface. It receives DL messages via GSMTAP from any
+ * number of BTSs transmitting to GSMTAP, and transmits UL messages via
+ * GSMTAP to those BTSs in another multicast group */
+
 #include 
 #include 
 #include "osmo_mcast_sock.h"

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmocom-bb[master]: VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: VIRT-PHY: Use osmo_fd_close() introduced in libosmocore
..


VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

libosmocore has recently received a new function osmo_fd_close() which
can be used to replace the private fd_close() function in this code.

This requires Change-Id Icd0933eed6a24edde7cdcb378e138897ecc5332c in
libosmocore.

Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 4 insertions(+), 15 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c 
b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index 0521c0d..b52e005 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -10,17 +10,6 @@
 #include 
 #include 
 
-/* convenience wrapper */
-static void fd_close(struct osmo_fd *ofd)
-{
-   /* multicast memberships of socket are implicitly dropped when
-* socket is closed */
-   osmo_fd_unregister(ofd);
-   close(ofd->fd);
-   ofd->fd = -1;
-   ofd->when = 0;
-}
-
 /* server socket is what we use for transmission. It is not subscribed
  * to a multicast group or locally bound, but it is just a normal UDP
  * socket that's connected to the remote mcast group + port */
@@ -69,7 +58,7 @@
rc = osmo_sock_mcast_subscribe(ofd->fd, mcast_group);
if (rc < 0) {
perror("Failed to join to mcast goup");
-   fd_close(ofd);
+   osmo_fd_close(ofd);
return rc;
}
 
@@ -96,7 +85,7 @@
}
rc = mcast_server_sock_setup(&bidir_sock->tx_ofd, tx_mcast_group, 
tx_mcast_port, loopback);
if (rc < 0) {
-   fd_close(&bidir_sock->rx_ofd);
+   osmo_fd_close(&bidir_sock->rx_ofd);
talloc_free(bidir_sock);
return NULL;
}
@@ -117,7 +106,7 @@
 
 void mcast_bidir_sock_close(struct mcast_bidir_sock *bidir_sock)
 {
-   fd_close(&bidir_sock->tx_ofd);
-   fd_close(&bidir_sock->rx_ofd);
+   osmo_fd_close(&bidir_sock->tx_ofd);
+   osmo_fd_close(&bidir_sock->rx_ofd);
talloc_free(bidir_sock);
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmocom-bb[master]: VIRT-PHY: reorganize data structures

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I94ca4dad1c6c668ce6307d5e5d728b1c1502af12
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[master]: VIRT-PHY: Use IPv4 multicast groups for private / local scope

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[master]: VIRT-PHY: some more comments/documentation

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[master]: VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmocom-bb[master]: VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP, ALL} flags

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmo-sccp[master]: sccp: ensure addressbook entry names are unique

2017-07-19 Thread dexter

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

sccp: ensure addressbook entry names are unique

It is possible to add two (or more) different
sccp-addresses under the same name, when the
addresses are defined in different cs7 instances.

Add a check to make sure an address name is not
used multiple times

Change-Id: I63227cd87bc24f7d9ac995430b869f0393818335
---
M src/osmo_ss7_vty.c
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/92/3292/1

diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index a076724..76882eb 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -1199,6 +1199,15 @@
return CMD_WARNING;
}
 
+   /* Ensure that we do not use address names that
+* are already used in other ss7 instances. */
+   if (addr_entry_by_name(name, NULL) != NULL) {
+   vty_out(vty,
+   "address-name already used in other ss7 instance!%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
entry = addr_entry_by_name(name, inst);
 
/* Create a new addressbook entry if we can not find an

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63227cd87bc24f7d9ac995430b869f0393818335
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] libosmo-sccp[master]: sccp: improve sccp-addressbook API

2017-07-19 Thread dexter

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

sccp: improve sccp-addressbook API

When searching the addressbook, return the SS7 instance
and write sccp-address to given destination pointer.
(name -> addr+ss7inst)

Remove the no longer needed ss7 instance pointer when
using the backward search. (addr -> name)

Change-Id: I68209dd1b2c0aa94b1894637a22b5cc3a3ff1250
---
M include/osmocom/sigtran/sccp_sap.h
M src/osmo_ss7_vty.c
2 files changed, 20 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/93/3293/1

diff --git a/include/osmocom/sigtran/sccp_sap.h 
b/include/osmocom/sigtran/sccp_sap.h
index 2258b0d..c00320c 100644
--- a/include/osmocom/sigtran/sccp_sap.h
+++ b/include/osmocom/sigtran/sccp_sap.h
@@ -248,8 +248,7 @@
 
 int osmo_sccp_user_sap_down(struct osmo_sccp_user *scu, struct osmo_prim_hdr 
*oph);
 
-struct osmo_sccp_addr *
-osmo_sccp_addr_by_name(const char *name, const struct osmo_ss7_instance *ss7);
+struct osmo_ss7_instance *
+osmo_sccp_addr_by_name(struct osmo_sccp_addr *addr, const char *name);
 
-char * osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
- const struct osmo_ss7_instance *ss7);
+const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr);
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 76882eb..e3f7f46 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -979,41 +979,35 @@
 }
 
 /*! \brief Lookup an SCCP address from the addressbook by its name.
- *  \param[in] lookup-name of the address to lookup
- *  \param[in] ss7 instance (NULL to search global)
- *  \returns SCCP address; NULL on error */
-struct osmo_sccp_addr *osmo_sccp_addr_by_name(const char *name,
- const struct osmo_ss7_instance
- *ss7)
+ *  \param[in] addr pointer to output the resulting sccp-address;
+ *  (set to NULL if not interested)
+ *  \param[in] name of the address to lookup
+ *  \returns SS7 instance; NULL on error */
+struct osmo_ss7_instance *osmo_sccp_addr_by_name(struct osmo_sccp_addr *addr,
+const char *name)
 {
struct osmo_sccp_addr_entry *entry;
 
-   entry = addr_entry_by_name(name, ss7);
-   if (entry)
-   return &entry->addr;
+   entry = addr_entry_by_name(name, NULL);
+   if (!entry)
+   return NULL;
 
-   return NULL;
+   if (addr)
+   memcpy(addr, &entry->addr, sizeof(*addr));
+
+   return entry->inst;
 }
 
 /*! \brief Reverse lookup the lookup-name of a specified SCCP address.
  *  \param[in] name of the address to lookup
- *  \param[in] ss7 instance (NULL to search global)
  *  \returns char pointer to the lookup-name; NULL on error */
-char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr,
-const struct osmo_ss7_instance *ss7)
+const char *osmo_sccp_name_by_addr(const struct osmo_sccp_addr *addr)
 {
struct osmo_sccp_addr_entry *entry;
 
-   if (ss7 == NULL) {
-   llist_for_each_entry(entry, &sccp_address_book_global, 
list_global) {
-   if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
-   return entry->name;
-   }
-   } else {
-   llist_for_each_entry(entry, &ss7->cfg.sccp_address_book, list) {
-   if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
-   return entry->name;
-   }
+   llist_for_each_entry(entry, &sccp_address_book_global, list_global) {
+   if (memcmp(&entry->addr, addr, sizeof(*addr)) == 0)
+   return entry->name;
}
 
return NULL;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68209dd1b2c0aa94b1894637a22b5cc3a3ff1250
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: dexter 


[PATCH] osmocom-bb[master]: VIRT-PHY: Change default log levels

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Change default log levels

This will basically only print L1C message for all L1CTL happening
between MS and the BTS, while suppressing the GSMTAP/virtUM and L1P
related messages.

Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
---
M src/host/virt_phy/src/virtphy.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/90/3290/1

diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 481cdc1..b6f4f0c 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -37,7 +37,7 @@
 #include 
 #include 
 
-#define DEFAULT_LOG_MASK "DL1C,1:DL1P,1:DVIRPHY,1:DMAIN,1"
+#define DEFAULT_LOG_MASK "DL1C,2:DL1P,2:DVIRPHY,2:DMAIN,1"
 
 /* this exists once in the program, and contains the state that we
  * only keep once:  L1CTL server socket, GSMTAP/VirtUM socket */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9513db3cee12644ed9b9858e13b740ffd27aba24
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Use osmo_fd_close() introduced in libosmocore

libosmocore has recently received a new function osmo_fd_close() which
can be used to replace the private fd_close() function in this code.

This requires Change-Id Icd0933eed6a24edde7cdcb378e138897ecc5332c in
libosmocore.

Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 4 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/80/3280/1

diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c 
b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index 0521c0d..b52e005 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -10,17 +10,6 @@
 #include 
 #include 
 
-/* convenience wrapper */
-static void fd_close(struct osmo_fd *ofd)
-{
-   /* multicast memberships of socket are implicitly dropped when
-* socket is closed */
-   osmo_fd_unregister(ofd);
-   close(ofd->fd);
-   ofd->fd = -1;
-   ofd->when = 0;
-}
-
 /* server socket is what we use for transmission. It is not subscribed
  * to a multicast group or locally bound, but it is just a normal UDP
  * socket that's connected to the remote mcast group + port */
@@ -69,7 +58,7 @@
rc = osmo_sock_mcast_subscribe(ofd->fd, mcast_group);
if (rc < 0) {
perror("Failed to join to mcast goup");
-   fd_close(ofd);
+   osmo_fd_close(ofd);
return rc;
}
 
@@ -96,7 +85,7 @@
}
rc = mcast_server_sock_setup(&bidir_sock->tx_ofd, tx_mcast_group, 
tx_mcast_port, loopback);
if (rc < 0) {
-   fd_close(&bidir_sock->rx_ofd);
+   osmo_fd_close(&bidir_sock->rx_ofd);
talloc_free(bidir_sock);
return NULL;
}
@@ -117,7 +106,7 @@
 
 void mcast_bidir_sock_close(struct mcast_bidir_sock *bidir_sock)
 {
-   fd_close(&bidir_sock->tx_ofd);
-   fd_close(&bidir_sock->rx_ofd);
+   osmo_fd_close(&bidir_sock->tx_ofd);
+   osmo_fd_close(&bidir_sock->rx_ofd);
talloc_free(bidir_sock);
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8a518dfb09465c2765681407e5581aee2d62d6d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP, ALL} flags

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Use new OSMO_SOCK_F_NO_MCAST_{LOOP,ALL} flags

libosmocore has recently gained support for flags like
OSMO_SOCK_F_NO_MCAST_LOOP and OSMO_SOCK_F_NO_MCAST_ALL that can be
passed to the socket initializer functions, further reducing complexity
of the code in osmo_mcast_sock.c here.

The related change-IDs are I5ab5de45c0b64ceb3636ea98245a23defa24ffd4 and
I24a5b1ebc3f84d2d5d4734e54df50efaea26490b in libosmocore.git.

Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
---
M src/host/virt_phy/src/shared/osmo_mcast_sock.c
1 file changed, 8 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/79/3279/1

diff --git a/src/host/virt_phy/src/shared/osmo_mcast_sock.c 
b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
index df3abc3..0521c0d 100644
--- a/src/host/virt_phy/src/shared/osmo_mcast_sock.c
+++ b/src/host/virt_phy/src/shared/osmo_mcast_sock.c
@@ -28,21 +28,16 @@
uint16_t tx_mcast_port, bool loopback)
 {
int rc;
+   unsigned int flags = OSMO_SOCK_F_CONNECT;
+
+   if (!loopback)
+   flags |= OSMO_SOCK_F_NO_MCAST_LOOP;
 
/* setup mcast server socket */
rc = osmo_sock_init_ofd(ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-   tx_mcast_group, tx_mcast_port, 
OSMO_SOCK_F_CONNECT);
+   tx_mcast_group, tx_mcast_port, flags);
if (rc < 0) {
perror("Failed to create Multicast Server Socket");
-   return rc;
-   }
-
-   /* determines whether sent mcast packets should be looped back to the 
local sockets.
-* loopback must be enabled if the mcast client is on the same machine 
*/
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, 
sizeof(loopback));
-   if (rc < 0) {
-   perror("Failed to configure multicast loopback.\n");
-   fd_close(ofd);
return rc;
}
 
@@ -56,8 +51,7 @@
int (*fd_rx_cb)(struct osmo_fd *ofd, unsigned int 
what),
void *osmo_fd_data)
 {
-   struct ip_mreq mreq;
-   int rc, loopback = 1, all = 0;
+   int rc;
 
ofd->cb = fd_rx_cb;
ofd->when = BSC_FD_READ;
@@ -65,38 +59,16 @@
 
/* Create mcast client socket */
rc = osmo_sock_init_ofd(ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
-   NULL, mcast_port, OSMO_SOCK_F_BIND);
+   NULL, mcast_port, 
OSMO_SOCK_F_BIND|OSMO_SOCK_F_NO_MCAST_ALL);
if (rc < 0) {
perror("Could not create mcast client socket");
return rc;
}
 
-   /* Enable loopback of msgs to the host. */
-   /* Loopback must be enabled for the client, so multiple
-* processes are able to receive a mcast package. */
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_LOOP,
-   &loopback, sizeof(loopback));
-   if (rc < 0) {
-   perror("Failed to enable IP_MULTICAST_LOOP");
-   fd_close(ofd);
-   return rc;
-   }
-
/* Configure and join the multicast group */
-   memset(&mreq, 0, sizeof(mreq));
-   mreq.imr_multiaddr.s_addr = inet_addr(mcast_group);
-   mreq.imr_interface.s_addr = htonl(INADDR_ANY);
-   rc = setsockopt(ofd->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, 
sizeof(mreq));
+   rc = osmo_sock_mcast_subscribe(ofd->fd, mcast_group);
if (rc < 0) {
perror("Failed to join to mcast goup");
-   fd_close(ofd);
-   return rc;
-   }
-
-   /* this option will set the delivery option so that only packets
-* from sockets we are subscribed to via IP_ADD_MEMBERSHIP are received 
*/
-   if (setsockopt(ofd->fd, IPPROTO_IP, IP_MULTICAST_ALL, &all, 
sizeof(all)) < 0) {
-   perror("Failed to modify delivery policy to explicitly 
joined.\n");
fd_close(ofd);
return rc;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I961aa07a381fef2cf9a2fb5357937864364ca04b
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: some more comments/documentation

2017-07-19 Thread Harald Welte

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

VIRT-PHY: some more comments/documentation

Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
---
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/include/virtphy/virtual_um.h
2 files changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/82/3282/1

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 296931a..991cb1a 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -1,5 +1,7 @@
 #pragma once
 
+/* Per-MS specific state, closely attached to the L1CTL user progran */
+
 #include 
 #include 
 #include 
diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index ac098dd..79d74a5 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -1,5 +1,11 @@
 #pragma once
 
+/* the "Virtual Um instance" encapsulates the multicast UDP sockets as
+ * well as the encoding and decoding of GSMTAP messages towards the
+ * virtual radio interface. It receives DL messages via GSMTAP from any
+ * number of BTSs transmitting to GSMTAP, and transmits UL messages via
+ * GSMTAP to those BTSs in another multicast group */
+
 #include 
 #include 
 #include "osmo_mcast_sock.h"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24fc98624178e9441d6cfcd61bc14e17c1391e9e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY Use libosmocore unix domain socket helper

2017-07-19 Thread Harald Welte

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

VIRT-PHY Use libosmocore unix domain socket helper

Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
---
M src/host/virt_phy/src/l1ctl_sock.c
1 file changed, 11 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/84/3284/1

diff --git a/src/host/virt_phy/src/l1ctl_sock.c 
b/src/host/virt_phy/src/l1ctl_sock.c
index 2e16bfa..370d3f3 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -32,13 +32,13 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -102,11 +102,9 @@
 {
 
struct l1ctl_sock_inst *lsi = ofd->data;
-   struct sockaddr_un local_addr;
-   socklen_t addr_len = sizeof(struct sockaddr_in);
int fd;
 
-   fd = accept(ofd->fd, (struct sockaddr *)&local_addr, &addr_len);
+   fd = accept(ofd->fd, NULL, NULL);
if (fd < 0) {
fprintf(stderr, "Failed to accept connection to l2.\n");
return -1;
@@ -130,39 +128,24 @@
 char *path)
 {
struct l1ctl_sock_inst *lsi;
-   struct sockaddr_un local_addr;
-   int fd, rc;
+   int rc;
 
if (!path)
path = L1CTL_SOCK_PATH;
 
-   if ((fd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
-   fprintf(stderr, "Failed to create Unix Domain Socket.\n");
-   return NULL;
-   }
-
-   local_addr.sun_family = AF_LOCAL;
-   strcpy(local_addr.sun_path, path);
-   unlink(local_addr.sun_path);
-
-   if ((rc = bind(fd, (struct sockaddr *)&local_addr, sizeof(local_addr))) 
!= 0) {
-   fprintf(stderr, "Failed to bind the unix domain socket. '%s'\n",
-   local_addr.sun_path);
-   return NULL;
-   }
-
-   if (listen(fd, 0) != 0) {
-   fprintf(stderr, "Failed to listen.\n");
-   return NULL;
-   }
-
lsi = talloc_zero(ctx, struct l1ctl_sock_inst);
lsi->priv = NULL;
-   lsi->recv_cb = recv_cb;
lsi->ofd.data = lsi;
-   lsi->ofd.fd = fd;
lsi->ofd.when = BSC_FD_READ;
lsi->ofd.cb = l1ctl_sock_accept_cb;
+
+   rc = osmo_sock_unix_init_ofd(&lsi->ofd, SOCK_STREAM, 0, path, 
OSMO_SOCK_F_BIND);
+   if (rc < 0) {
+   talloc_free(lsi);
+   return NULL;
+   }
+
+   lsi->recv_cb = recv_cb;
/* no connection -> invalid filedescriptor and not 0 (==std_in) */
lsi->connection.fd = -1;
lsi->l1ctl_sock_path = path;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0fa003bd7c7468d39a0c39fbea89000d576a4f3
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: Major rewrite to deal with muliple L1CTL clients

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Major rewrite to deal with muliple L1CTL clients

Change-Id: Ibfb2a93f8b45a95215c01368b1a52d92283474e6
---
M src/host/virt_phy/include/virtphy/gsmtapl1_if.h
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/include/virtphy/l1ctl_sock.h
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/include/virtphy/virt_l1_sched.h
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
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
16 files changed, 388 insertions(+), 428 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/86/3286/1

diff --git a/src/host/virt_phy/include/virtphy/gsmtapl1_if.h 
b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
index d8a4367..125ec11 100644
--- a/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
+++ b/src/host/virt_phy/include/virtphy/gsmtapl1_if.h
@@ -9,8 +9,4 @@
 void gsmtapl1_init(struct l1_model_ms *model);
 void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui,
   struct msgb *msg);
-void gsmtapl1_rx_from_virt_um(struct msgb *msg);
-void gsmtapl1_tx_to_virt_um_inst(uint32_t fn, struct virt_um_inst *vui, struct 
msgb *msg);
-void gsmtapl1_tx_to_virt_um(uint32_t fn, struct msgb *msg);
-void chantype_gsmtap2rsl(uint8_t gsmtap_chantype, uint8_t *rsl_chantype,
- uint8_t *link_id);
+void gsmtapl1_tx_to_virt_um_inst(struct l1_model_ms *ms, uint32_t fn, struct 
msgb *msg);
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index b84c3e9..5903a02 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -27,17 +27,11 @@
 
 
 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 prim_pm_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);
-void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_inst *lsi,
-   struct msgb *msg);
+void l1ctl_sap_tx_to_l23_inst(struct l1_model_ms *model, struct msgb *msg);
+void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_client *lsc, struct msgb 
*msg);
 void l1ctl_sap_rx_from_l23(struct msgb *msg);
-void l1ctl_sap_handler(struct msgb *msg);
+void l1ctl_sap_handler(struct l1_model_ms *ms, struct msgb *msg);
 
 /* utility methods */
 struct msgb *l1ctl_msgb_alloc(uint8_t msg_type);
@@ -45,39 +39,39 @@
  uint16_t arfcn);
 
 /* receive routines */
-void l1ctl_rx_fbsb_req(struct msgb *msg);
-void l1ctl_rx_dm_est_req(struct msgb *msg);
-void l1ctl_rx_dm_rel_req(struct msgb *msg);
-void l1ctl_rx_param_req(struct msgb *msg);
-void l1ctl_rx_dm_freq_req(struct msgb *msg);
-void l1ctl_rx_crypto_req(struct msgb *msg);
-void l1ctl_rx_rach_req(struct msgb *msg);
-void l1ctl_rx_data_req(struct msgb *msg);
-void l1ctl_rx_pm_req(struct msgb *msg);
-void l1ctl_rx_reset_req(struct msgb *msg);
-void l1ctl_rx_ccch_mode_req(struct msgb *msg);
-void l1ctl_rx_tch_mode_req(struct msgb *msg);
-void l1ctl_rx_neigh_pm_req(struct msgb *msg);
-void l1ctl_rx_traffic_req(struct msgb *msg);
-void l1ctl_rx_sim_req(struct msgb *msg);
+void l1ctl_rx_fbsb_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_est_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_rel_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_param_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_dm_freq_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_crypto_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_rach_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_data_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_pm_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_reset_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_ccch_mode_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_tch_mode_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_neigh_pm_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_traffic_req(struct l1_model_ms *, struct msgb *msg);
+void l1ctl_rx_sim_req(struct l1_model_ms *, struct msgb *msg);
 
 /* transmit routines */
-void l1ctl_tx_reset(uint8_t msg_type, uint8_t reset_type);
-void l1ctl_tx_rach_conf(uint32_t fn, uint16_t arfcn);
-void l1ctl_tx_data_conf(uint32_t fn, uint16_t snr, uint

[PATCH] osmocom-bb[master]: VIRT-PHY: Use IPv4 multicast groups for private / local scope

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Use IPv4 multicast groups for private / local scope

The addresses in the original code make little sense:
* 224.0.0.1 is "All systems on this subnet" and not routed
  outside the local ethernet segment
* 225.0.0.1 is in a RESERVED range that shouldn't be used

Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
---
M src/host/virt_phy/include/virtphy/virtual_um.h
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/81/3281/1

diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index 6e7c384..ac098dd 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -4,10 +4,15 @@
 #include 
 #include "osmo_mcast_sock.h"
 
+/* We use multicast group addresses from the 239.192.0.0/14 rage, as
+ * those are designated by RFC2365 as "IPv4 Organization Local Scope,
+ * "... the space from which an organization should allocate sub-
+ *  ranges when defining scopes for private use." */
+
 #define VIRT_UM_MSGB_SIZE  256
-#define DEFAULT_MS_MCAST_GROUP "224.0.0.1"
+#define DEFAULT_MS_MCAST_GROUP "239.193.23.1"
 #define DEFAULT_MS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
-#define DEFAULT_BTS_MCAST_GROUP "225.0.0.1"
+#define DEFAULT_BTS_MCAST_GROUP"239.193.23.2"
 #define DEFAULT_BTS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 
 struct virt_um_inst {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e3acd745e65a6cfa70b681a440da6a59a1ed0b5
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmocom-bb[master]: VIRT-PHY: Properly destroy l1_model_ms after disconnect

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Properly destroy l1_model_ms after disconnect

If a MS disconnects, we need to clean up all related state

Change-Id: Ib7adef61150b5a4338483019e4dd75d7279d1f5d
---
M src/host/virt_phy/include/virtphy/l1ctl_sap.h
M src/host/virt_phy/include/virtphy/l1ctl_sock.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/l1ctl_sock.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virtphy.c
7 files changed, 33 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/91/3291/1

diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sap.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
index 5903a02..94174da 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sap.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sap.h
@@ -27,7 +27,9 @@
 
 
 void l1ctl_sap_init(struct l1_model_ms *model);
+void l1ctl_sap_exit(struct l1_model_ms *model);
 void prim_pm_init(struct l1_model_ms *model);
+void prim_pm_exit(struct l1_model_ms *model);
 void l1ctl_sap_tx_to_l23_inst(struct l1_model_ms *model, struct msgb *msg);
 void l1ctl_sap_rx_from_l23_inst_cb(struct l1ctl_sock_client *lsc, struct msgb 
*msg);
 void l1ctl_sap_rx_from_l23(struct msgb *msg);
diff --git a/src/host/virt_phy/include/virtphy/l1ctl_sock.h 
b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
index 82ee5ca..2c98fa5 100644
--- a/src/host/virt_phy/include/virtphy/l1ctl_sock.h
+++ b/src/host/virt_phy/include/virtphy/l1ctl_sock.h
@@ -28,6 +28,8 @@
void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb *msg); /* 
Callback function called for incoming data from l2 app. */
/* Callback function called for new client after accept() */
int (*accept_cb)(struct l1ctl_sock_client *lsc);
+   /* Callback function called when client disappeared */
+   void (*close_cb)(struct l1ctl_sock_client *lsc);
 };
 
 /**
@@ -37,6 +39,7 @@
 void *ctx,
 void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb 
*msg),
 int (*accept_cb)(struct l1ctl_sock_client *lsc),
+void (*close_cb)(struct l1ctl_sock_client *lsc),
 char *path);
 
 /**
diff --git a/src/host/virt_phy/src/l1ctl_sap.c 
b/src/host/virt_phy/src/l1ctl_sap.c
index c7c8e3e..d4b33f1 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -58,6 +58,12 @@
prim_pm_init(model);
 }
 
+void l1ctl_sap_exit(struct l1_model_ms *model)
+{
+   virt_l1_sched_stop(model);
+   prim_pm_exit(model);
+}
+
 /**
  * @brief L1CTL handler called for received messages from L23.
  *
diff --git a/src/host/virt_phy/src/l1ctl_sock.c 
b/src/host/virt_phy/src/l1ctl_sock.c
index 00f25a6..bf28895 100644
--- a/src/host/virt_phy/src/l1ctl_sock.c
+++ b/src/host/virt_phy/src/l1ctl_sock.c
@@ -47,6 +47,9 @@
 
 static void l1ctl_client_destroy(struct l1ctl_sock_client *lsc)
 {
+   struct l1ctl_sock_inst *lsi = lsc->l1ctl_sock;
+   if (lsi->close_cb)
+   lsi->close_cb(lsc);
osmo_fd_close(&lsc->ofd);
llist_del(&lsc->list);
talloc_free(lsc);
@@ -149,6 +152,7 @@
 void *ctx,
 void (*recv_cb)(struct l1ctl_sock_client *lsc, struct msgb 
*msg),
 int (*accept_cb)(struct l1ctl_sock_client *lsc),
+void (*close_cb)(struct l1ctl_sock_client *lsc),
 char *path)
 {
struct l1ctl_sock_inst *lsi;
@@ -172,6 +176,7 @@
 
lsi->recv_cb = recv_cb;
lsi->accept_cb = accept_cb;
+   lsi->close_cb = close_cb;
lsi->l1ctl_sock_path = path;
INIT_LLIST_HEAD(&lsi->clients);
 
diff --git a/src/host/virt_phy/src/virt_l1_model.c 
b/src/host/virt_phy/src/virt_l1_model.c
index 14676b0..6a9fa99 100644
--- a/src/host/virt_phy/src/virt_l1_model.c
+++ b/src/host/virt_phy/src/virt_l1_model.c
@@ -46,5 +46,6 @@
 void l1_model_ms_destroy(struct l1_model_ms *model)
 {
LOGPMS(DMAIN, LOGL_INFO, model, "destryed\n");
+   l1ctl_sap_exit(model);
talloc_free(model);
 }
diff --git a/src/host/virt_phy/src/virt_prim_pm.c 
b/src/host/virt_phy/src/virt_prim_pm.c
index 1cd3c03..4637013 100644
--- a/src/host/virt_phy/src/virt_prim_pm.c
+++ b/src/host/virt_phy/src/virt_prim_pm.c
@@ -138,3 +138,12 @@
l1s->pm.meas.arfcn_sig_lev_timers[i].data = 
&l1s->pm.meas.arfcn_sig_lev_dbm[i];
}
 }
+
+void prim_pm_exit(struct l1_model_ms *model)
+{
+   struct l1_state_ms *l1s = &model->state;
+   int i;
+
+   for (i = 0; i < 1024; ++i)
+   osmo_timer_del(&l1s->pm.meas.arfcn_sig_lev_timers[i]);
+}
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index b6f4f0c..23811c2 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -162,6 +162,12 @@
return 0;
 }
 
+static void l1ctl_close_cb(struct l1ctl_sock_client *lsc)
+{
+   struct l1_m

[PATCH] osmocom-bb[master]: VIRT-PHY: Separate logging of L1 Control and L1 Data

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Separate logging of L1 Control and L1 Data

L1 Data is quite verbose, while control is typically limited, so let's
make sure we log them as separate sub-systems

Change-Id: Idebc371a63508c593855486ff01b2ba6e8c2cfd1
---
M src/host/virt_phy/include/virtphy/logging.h
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/logging.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
6 files changed, 37 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/88/3288/1

diff --git a/src/host/virt_phy/include/virtphy/logging.h 
b/src/host/virt_phy/include/virtphy/logging.h
index c98986c..b22db99 100644
--- a/src/host/virt_phy/include/virtphy/logging.h
+++ b/src/host/virt_phy/include/virtphy/logging.h
@@ -5,6 +5,7 @@
 /* L1CTL related messages */
 enum virtphy_log_cat {
DL1C,
+   DL1P,
DVIRPHY,
DMAIN
 };
diff --git a/src/host/virt_phy/src/l1ctl_sap.c 
b/src/host/virt_phy/src/l1ctl_sap.c
index 6bd63c9..d896042 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -70,7 +70,6 @@
if (!msg)
return;
 
-   DEBUGPMS(DL1C, ms, "Message incoming from layer 2: %s\n", 
osmo_hexdump(msg->data, msg->len));
l1ctl_sap_handler(ms, msg);
 }
 
@@ -146,6 +145,20 @@
return msg;
 }
 
+static bool is_l1ctl_control(uint8_t msg_type)
+{
+   switch (msg_type) {
+   case L1CTL_DATA_REQ:
+   case L1CTL_DATA_CONF:
+   case L1CTL_TRAFFIC_REQ:
+   case L1CTL_TRAFFIC_CONF:
+   case L1CTL_TRAFFIC_IND:
+   return false;
+   default:
+   return true;
+   }
+}
+
 /**
  * @brief General handler for incoming L1CTL messages from layer 2/3.
  *
@@ -154,6 +167,7 @@
 void l1ctl_sap_handler(struct l1_model_ms *ms, struct msgb *msg)
 {
struct l1ctl_hdr *l1h;
+   int log_subsys;
 
if (!msg)
return;
@@ -165,6 +179,13 @@
goto exit_msgbfree;
}
 
+   if (is_l1ctl_control(l1h->msg_type))
+   log_subsys = DL1C;
+   else
+   log_subsys = DL1P;
+
+   DEBUGPMS(log_subsys, ms, "Message incoming from layer 2: %s\n", 
osmo_hexdump(msg->data, msg->len));
+
switch (l1h->msg_type) {
case L1CTL_FBSB_REQ:
l1ctl_rx_fbsb_req(ms, msg);
diff --git a/src/host/virt_phy/src/logging.c b/src/host/virt_phy/src/logging.c
index 7fb2c23..feb5081 100644
--- a/src/host/virt_phy/src/logging.c
+++ b/src/host/virt_phy/src/logging.c
@@ -64,7 +64,15 @@
.description = "Layer 1 Control",
.color = "\033[1;31m",
.enabled = 1,
-   .loglevel = LOGL_DEBUG, },
+   .loglevel = LOGL_DEBUG,
+   },
+   [DL1P] = {
+   .name = "DL1P",
+   .description = "Layer 1 Data",
+   .color = "\033[1;31m",
+   .enabled = 1,
+   .loglevel = LOGL_DEBUG,
+   },
[DVIRPHY] = {
.name = "DVIRPHY",
.description = "Virtual Layer 1 Interface",
diff --git a/src/host/virt_phy/src/virt_prim_data.c 
b/src/host/virt_phy/src/virt_prim_data.c
index e03d097..cf34e7a 100644
--- a/src/host/virt_phy/src/virt_prim_data.c
+++ b/src/host/virt_phy/src/virt_prim_data.c
@@ -71,7 +71,7 @@
ul->chan_nr, ul->link_id);
 
rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, ×lot);
-   DEBUGPMS(DL1C, ms,
+   DEBUGPMS(DL1P, ms,
   "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);
@@ -107,7 +107,7 @@
 
memcpy(l1di->data, msgb_data(msg), msgb_length(msg));
 
-   DEBUGPMS(DL1C, ms, "Sending signaling-data to l23.\n");
+   DEBUGPMS(DL1P, ms, "Sending signaling-data to l23.\n");
l1ctl_sap_tx_to_l23_inst(ms, l1ctl_msg);
 }
 
diff --git a/src/host/virt_phy/src/virt_prim_traffic.c 
b/src/host/virt_phy/src/virt_prim_traffic.c
index 04f6749..46ba9f1 100644
--- a/src/host/virt_phy/src/virt_prim_traffic.c
+++ b/src/host/virt_phy/src/virt_prim_traffic.c
@@ -69,7 +69,7 @@
uint32_t fn_sched = sched_fn_ul(ms->state.current_time, ul->chan_nr, 
ul->link_id);
 
rsl_dec_chan_nr(ul->chan_nr, &rsl_chantype, &subslot, ×lot);
-   DEBUGPMS(DL1C, ms, "Received and handled from l23 - 
L1CTL_TRAFFIC_REQ\n");
+   DEBUGPMS(DL1P, ms, "Received and handled from l23 - 
L1CTL_TRAFFIC_REQ\n");
 
msg->l2h = tr->data;
 
@@ -102,7 +102,7 @@
/* TODO: traffic decoding and decryption */
 
memcpy(l1ti->data, msgb_data(msg), msgb_length(msg));
-   DEBUGPMS(DL1C, ms, "Sending to l23 - L1CTL_TRAFFIC_IND\n");
+   DEBUGPMS(DL1P, ms, "Sending to

[PATCH] osmocom-bb[master]: VIRT-PHY: Log MS context number whenever possible

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Log MS context number whenever possible

Now that we can have multiple MS connected to one virtphy instance,
it is important to log some context whenever possible.  To do so, we
introduce a monotonically increasing MS number which gets assigned
whenever we allocate a l1_model_ms and printed when the LOGPMS() or
DEBUGPMS() macros are used.

Change-Id: Id7d9507126a03def5bd7690f1dbe987f9a749e65
---
M src/host/virt_phy/include/virtphy/logging.h
M src/host/virt_phy/include/virtphy/virt_l1_model.h
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
M src/host/virt_phy/src/logging.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
13 files changed, 71 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/87/3287/1

diff --git a/src/host/virt_phy/include/virtphy/logging.h 
b/src/host/virt_phy/include/virtphy/logging.h
index 6ca2525..c98986c 100644
--- a/src/host/virt_phy/include/virtphy/logging.h
+++ b/src/host/virt_phy/include/virtphy/logging.h
@@ -2,8 +2,15 @@
 
 #include 
 
-#define DL1C 0
-#define DVIRPHY 1
+/* L1CTL related messages */
+enum virtphy_log_cat {
+   DL1C,
+   DVIRPHY,
+   DMAIN
+};
+
+#define LOGPMS(ss, lvl, ms, fmt, args ...) LOGP(ss, lvl, "MS %04u: " fmt, 
ms->nr, ## args)
+#define DEBUGPMS(ss, ms, fmt, args ...)DEBUGP(ss, "MS %04u: " 
fmt, ms->nr, ## args)
 
 extern const struct log_info ms_log_info;
 
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 0cb5381..fa79127 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -93,6 +93,7 @@
 };
 
 struct l1_model_ms {
+   uint32_t nr;
/* pointer to the L1CTL socket client associated with this specific MS 
*/
struct l1ctl_sock_client *lsc;
/* pointer to the (shared) GSMTAP/VirtUM socket to talk to BTS(s) */
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index dfcd5a8..ac1c2b5 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -70,18 +70,18 @@
outmsg->l1h = msgb_data(outmsg);
gh = msgb_l1(outmsg);
if (virt_um_write_msg(ms->vui, outmsg) == -1) {
-   LOGP(DVIRPHY, LOGL_ERROR, "Gsmtap msg could not send to 
virt um - "
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not 
send to virt um - "
 "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
 gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
 gh->sub_slot);
} else {
-   DEBUGP(DVIRPHY, "Sending gsmtap msg to virt um - "
+   DEBUGPMS(DVIRPHY, ms, "Sending gsmtap msg to virt um - "
   "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
   gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
   gh->sub_slot);
}
} else
-   LOGP(DVIRPHY, LOGL_ERROR, "Gsmtap msg could not be created!\n");
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not be 
created!\n");
 
/* free message */
msgb_free(msg);
@@ -118,7 +118,7 @@
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
if (ms->state.serving_cell.arfcn != arfcn) {
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
 arfcn, ms->state.serving_cell.arfcn);
return;
@@ -155,7 +155,7 @@
l1ctl_tx_data_ind(ms, msg, arfcn, link_id, chan_nr, fn, snr_db, 
signal_dbm, 0, 0);
break;
case GSMTAP_CHANNEL_RACH:
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignoring gsmtap msg from virt um - channel type is uplink 
only!\n");
break;
case GSMTAP_CHANNEL_SDCCH:
@@ -165,11 +165,11 @@
case GSMTAP_CHANNEL_PTCCH:
case GSMTAP_CHANNEL_CBCH51:
case GSMTAP_CHANNEL_CBCH52:
-   LOGP(DVIRPHY, LOGL_NOTICE,
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
 "Ignoring gsmtap msg from virt um - channel type not 
supported!\n");
break;
default:
-   LOGP(DVIRPHY, LOGL_NOTICE,
+  

[PATCH] osmocom-bb[master]: VIRT-PHY: Clean up logging statements

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Clean up logging statements

The generated log lines have been *super* long, let's make them
significantly shorter.  Also, differentiate between DEBUG and INFO
level, so normal operation with LOGL_INFO will not spam the user while
still printing useful information.

Change-Id: If06a8b5f99349796d66a71201524361a6547945a
---
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
7 files changed, 66 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/89/3289/1

diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index ac1c2b5..5454022 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -38,6 +39,14 @@
 #include 
 #include 
 #include 
+
+static char *pseudo_lchan_name(uint16_t arfcn, uint8_t ts, uint8_t ss, uint8_t 
sub_type)
+{
+   static char lname[64];
+   snprintf(lname, sizeof(lname), "(arfcn=%u,ts=%u,ss=%u,type=%s)",
+   arfcn, ts, ss, get_value_string(gsmtap_gsm_channel_names, 
sub_type));
+   return lname;
+}
 
 /**
  * Replace l11 header of given msgb by a gsmtap header and send it over the 
virt um.
@@ -70,18 +79,16 @@
outmsg->l1h = msgb_data(outmsg);
gh = msgb_l1(outmsg);
if (virt_um_write_msg(ms->vui, outmsg) == -1) {
-   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not 
send to virt um - "
-"(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
-gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
-gh->sub_slot);
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "%s Tx go GSMTAP 
failed: %s\n",
+   pseudo_lchan_name(gh->arfcn, gh->timeslot, 
gh->sub_slot, gh->sub_type),
+   strerror(errno));
} else {
-   DEBUGPMS(DVIRPHY, ms, "Sending gsmtap msg to virt um - "
-  "(arfcn=%u, type=%u, subtype=%u, timeslot=%u, 
subslot=%u)\n",
-  gh->arfcn, gh->type, gh->sub_type, gh->timeslot,
-  gh->sub_slot);
+   DEBUGPMS(DVIRPHY, ms, "%s: Tx to GSMTAP: %s\n",
+   pseudo_lchan_name(gh->arfcn, gh->timeslot, 
gh->sub_slot, gh->sub_type),
+   osmo_hexdump(data, data_len));
}
} else
-   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "Gsmtap msg could not be 
created!\n");
+   LOGPMS(DVIRPHY, LOGL_ERROR, ms, "GSMTAP msg could not be 
created!\n");
 
/* free message */
msgb_free(msg);
@@ -118,9 +125,6 @@
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
if (ms->state.serving_cell.arfcn != arfcn) {
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
-arfcn, ms->state.serving_cell.arfcn);
return;
}
 
@@ -155,8 +159,7 @@
l1ctl_tx_data_ind(ms, msg, arfcn, link_id, chan_nr, fn, snr_db, 
signal_dbm, 0, 0);
break;
case GSMTAP_CHANNEL_RACH:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type is uplink 
only!\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unexpected RACH in 
downlink ?!?\n");
break;
case GSMTAP_CHANNEL_SDCCH:
case GSMTAP_CHANNEL_CCCH:
@@ -165,12 +168,12 @@
case GSMTAP_CHANNEL_PTCCH:
case GSMTAP_CHANNEL_CBCH51:
case GSMTAP_CHANNEL_CBCH52:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type not 
supported!\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unsupported channel 
type %s\n",
+   get_value_string(gsmtap_gsm_channel_names, 
gsmtap_chantype));
break;
default:
-   LOGPMS(DVIRPHY, LOGL_NOTICE, ms,
-"Ignoring gsmtap msg from virt um - channel type 
unknown.\n");
+   LOGPMS(DVIRPHY, LOGL_NOTICE, ms, "Ignoring unknown channel type 
%s\n",
+   get_value_string(gsmtap_gsm_channel_names, 
gsmtap_chantype));
break;
}
 }
@@ -203,23 +206,24 @@
uint8_t rsl_chantype;   /* rsl chan type (8.58, 9.3.1) */
uint8_t link_id;/* rsl link id tell

[PATCH] osmocom-bb[master]: VIRT-PHY: reorganize data structures

2017-07-19 Thread Harald Welte

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

VIRT-PHY: reorganize data structures

* l1_model_ms can become a static member of l1_model_ms
* crypto_info_ms can become a static member of l1_state_ms

Change-Id: I94ca4dad1c6c668ce6307d5e5d728b1c1502af12
---
M src/host/virt_phy/include/virtphy/virt_l1_model.h
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/virt_l1_model.c
M src/host/virt_phy/src/virt_l1_sched_simple.c
M src/host/virt_phy/src/virt_prim_data.c
M src/host/virt_phy/src/virt_prim_fbsb.c
M src/host/virt_phy/src/virt_prim_pm.c
M src/host/virt_phy/src/virt_prim_rach.c
M src/host/virt_phy/src/virt_prim_traffic.c
M src/host/virt_phy/src/virtphy.c
11 files changed, 82 insertions(+), 77 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/83/3283/1

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 991cb1a..61776ec 100644
--- a/src/host/virt_phy/include/virtphy/virt_l1_model.h
+++ b/src/host/virt_phy/include/virtphy/virt_l1_model.h
@@ -18,13 +18,6 @@
 };
 
 
-struct l1_model_ms {
-   struct l1ctl_sock_inst *lsi;
-   struct virt_um_inst *vui;
-   struct l1_state_ms *state;
-   struct crypto_info_ms *crypto_inf;
-};
-
 /* structure representing L1 sync information about a cell */
 struct l1_cell_info {
/* on which ARFCN (+band) is the cell? */
@@ -53,12 +46,13 @@
struct gsm_time downlink_time;  /* current GSM time received on 
downlink */
struct gsm_time current_time; /* GSM time used internally for 
scheduling */
 
-   uint8_t state; // the ms state like in ms_state
+   enum ms_state state;
 
/* the cell on which we are camping right now */
struct l1_cell_info serving_cell;
/* neighbor cell sync info */
struct l1_cell_info neigh_cell[L1S_NUM_NEIGH_CELL];
+   struct crypto_info_ms crypto_inf;
 
/* TCH info */
uint8_t tch_mode; // see enum gsm48_chan_mode in gsm_04_08.h
@@ -94,6 +88,13 @@
} pm;
 };
 
+struct l1_model_ms {
+   struct l1ctl_sock_inst *lsi;
+   struct virt_um_inst *vui;
+   struct l1_state_ms state;
+};
+
+
 struct l1_model_ms *l1_model_ms_init(void *ctx);
 
 void l1_model_ms_destroy(struct l1_model_ms *model);
diff --git a/src/host/virt_phy/src/gsmtapl1_if.c 
b/src/host/virt_phy/src/gsmtapl1_if.c
index 2624046..18580b4 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -55,7 +55,7 @@
struct l1ctl_info_ul *ul = (struct l1ctl_info_ul *)l1h->data;
struct gsmtap_hdr *gh;
struct msgb *outmsg;/* msg to send with gsmtap header prepended */
-   uint16_t arfcn = l1_model_ms->state->serving_cell.arfcn;/* 
arfcn of the cell we currently camp on */
+   uint16_t arfcn = l1_model_ms->state.serving_cell.arfcn; /* arfcn of the 
cell we currently camp on */
uint8_t signal_dbm = 63;/* signal strength */
uint8_t snr = 63;   /* signal noise ratio, 63 is best */
uint8_t *data = msgb_l2(msg);   /* data to transmit (whole message 
without l1 header) */
@@ -145,19 +145,19 @@
goto freemsg;
}
/* we do not forward messages to l23 if we are in network search state 
*/
-   if (l1_model_ms->state->state == MS_STATE_IDLE_SEARCHING)
+   if (l1_model_ms->state.state == MS_STATE_IDLE_SEARCHING)
goto freemsg;
 
/* forward downlink msg to fbsb sync routine if we are in sync state */
-   if (l1_model_ms->state->state == MS_STATE_IDLE_SYNCING) {
+   if (l1_model_ms->state.state == MS_STATE_IDLE_SYNCING) {
prim_fbsb_sync(msg);
return;
}
/* generally ignore all messages coming from another arfcn than the 
camped one */
-   if (l1_model_ms->state->serving_cell.arfcn != arfcn) {
+   if (l1_model_ms->state.serving_cell.arfcn != arfcn) {
LOGP(DVIRPHY, LOGL_NOTICE,
 "Ignoring gsmtap msg from virt um - msg arfcn=%d not equal 
synced arfcn=%d!\n",
-arfcn, l1_model_ms->state->serving_cell.arfcn);
+arfcn, l1_model_ms->state.serving_cell.arfcn);
goto freemsg;
}
 
@@ -166,8 +166,8 @@
/* see TS 08.58 -> 9.3.1 for channel number encoding */
chan_nr = rsl_enc_chan_nr(rsl_chantype, subslot, timeslot);
 
-   gsm_fn2gsmtime(&l1_model_ms->state->downlink_time, fn);
-   virt_l1_sched_sync_time(l1_model_ms->state->downlink_time, 0);
+   gsm_fn2gsmtime(&l1_model_ms->state.downlink_time, fn);
+   virt_l1_sched_sync_time(l1_model_ms->state.downlink_time, 0);
virt_l1_sched_execute(fn);
 
DEBUGP(DVIRPHY, "Receiving gsmtap msg from virt um - "
@@ -191,8 +191,8 @@
case GSMTAP_CHANNEL_SDCCH8:
/* only forward messages on dedicated channels to l2, if
 * the timeslot

[PATCH] osmocom-bb[master]: VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore

2017-07-19 Thread Harald Welte

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

VIRT-PHY: Don't redefine GSMTAP port number, use libosmocore

Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
---
M src/host/virt_phy/include/virtphy/virtual_um.h
M src/host/virt_phy/src/virtphy.c
2 files changed, 2 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/85/3285/1

diff --git a/src/host/virt_phy/include/virtphy/virtual_um.h 
b/src/host/virt_phy/include/virtphy/virtual_um.h
index 79d74a5..52f2df6 100644
--- a/src/host/virt_phy/include/virtphy/virtual_um.h
+++ b/src/host/virt_phy/include/virtphy/virtual_um.h
@@ -17,9 +17,7 @@
 
 #define VIRT_UM_MSGB_SIZE  256
 #define DEFAULT_MS_MCAST_GROUP "239.193.23.1"
-#define DEFAULT_MS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 #define DEFAULT_BTS_MCAST_GROUP"239.193.23.2"
-#define DEFAULT_BTS_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 
 struct virt_um_inst {
void *priv;
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 43346ed..28dd685 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,12 +35,11 @@
 #include 
 #include 
 
-#define DEFAULT_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
 #define DEFAULT_LOG_MASK "DL1C,1:DVIRPHY,1"
 
 static char *dl_rx_grp = DEFAULT_MS_MCAST_GROUP;
 static char *ul_tx_grp = DEFAULT_BTS_MCAST_GROUP;
-static int port = DEFAULT_MCAST_PORT;
+static int port = GSMTAP_UDP_PORT;
 static char *log_mask = DEFAULT_LOG_MASK;
 static char *l1ctl_sock_path = L1CTL_SOCK_PATH;
 static char *arfcn_sig_lev_red_mask = NULL;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I11d04d76292c52ec5ab70893e8c6a2e55586b2ec
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] osmo-gsm-manuals[master]: all manuals: Move date and release from center head to right...

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: all manuals: Move date and release from center head to right 
foot
..


all manuals: Move date and release from center head to right foot

Otherwise long doc titles (top left) run on top of release and date
making it impossible to read any of them correctly.

Change-Id: I685a981a5cfd82214d1d654aa1553a844c2af157
---
M build/custom-dblatex.sty
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/build/custom-dblatex.sty b/build/custom-dblatex.sty
index 41e7c70..606b9ab 100644
--- a/build/custom-dblatex.sty
+++ b/build/custom-dblatex.sty
@@ -77,7 +77,8 @@
 % left footer
 \def\DBKpublisher{}
 
-\def\releasebox{\DBKreleaseinfo, \DBKdate}
+\def\releasebox{}
+\rfoot[]{\DBKreleaseinfo, \DBKdate}
 
 \def\maketitle{
\DBKcover

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I685a981a5cfd82214d1d654aa1553a844c2af157
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 


[MERGED] libosmocore[master]: add DLMGCP logging category for libosmo-mgcp

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: add DLMGCP logging category for libosmo-mgcp
..


add DLMGCP logging category for libosmo-mgcp

In the course of splitting up the openbsc.git repository, we will create
libosmo-mgcp and need a library logging category for that purpose.

Change-Id: I09c587e2d59472cbde852d467d457254746d9e67
---
M include/osmocom/core/logging.h
M src/logging.c
2 files changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index e058a57..86a6977 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -104,7 +104,8 @@
 #define DLSCCP -14 /*!< Osmocom SCCP */
 #define DLSUA  -15 /*!< Osmocom SUA */
 #define DLM3UA -16 /*!< Osmocom M3UA */
-#define OSMO_NUM_DLIB  16  /*!< Number of logging sub-systems in libraries 
*/
+#define DLMGCP -17 /*!< Osmocom MGCP */
+#define OSMO_NUM_DLIB  17  /*!< Number of logging sub-systems in libraries 
*/
 
 /*! Configuration of single log category / sub-system */
 struct log_category {
diff --git a/src/logging.c b/src/logging.c
index 2fb06ba..2e913e5 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -161,6 +161,11 @@
.description = "libosmo-sigtran MTP3 User Adaptation",
.enabled = 1, .loglevel = LOGL_NOTICE,
},
+   [INT2IDX(DLMGCP)] = {
+   .name = "DLMGCP",
+   .description = "libosmo-mgcp Media Gateway Control Protocol",
+   .enabled = 1, .loglevel = LOGL_NOTICE,
+   },
 };
 
 /*! descriptive string for each log level */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I09c587e2d59472cbde852d467d457254746d9e67
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-gsm-manuals[master]: all manuals: Move date and release from center head to right...

2017-07-19 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: I685a981a5cfd82214d1d654aa1553a844c2af157
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-manuals
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


openbsc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

2017-07-19 Thread Harald Welte

Patch Set 2: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[MERGED] openbsc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: bsc_vty: Add VTY command to test CTRL TRAP feature
..


bsc_vty: Add VTY command to test CTRL TRAP feature

Using this new command (introduced in OsmoBSC + OsmoNITB), you can
simulate the generation of TRAP events for testin purposes.

start the control interface monitor as an example client program:
./openbsc/contrib/bsc_control.py -m -d localhost -p 4249

then start OsmoBSC or OsmoNITB, telnet to the VTY and enter 'enable'
mode and issue the following (example) command:
ctrl-interface generate-trap my.foo.var 2342

As a result, on the bsc_control.py you will see:
Got message: TRAP 0 my.foo.var 2342

Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
---
M openbsc/src/libbsc/bsc_vty.c
1 file changed, 16 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 91a90c1..6472e9d 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -4122,6 +4123,20 @@
rsl_ipacc_mdcx(lchan, ntohl(ia.s_addr), port, 0);
return CMD_SUCCESS;
 }
+
+DEFUN(ctrl_trap, ctrl_trap_cmd,
+   "ctrl-interface generate-trap TRAP VALUE",
+   "Commands related to the CTRL Interface\n"
+   "Generate a TRAP for test purpose\n"
+   "Identity/Name of the TRAP variable\n"
+   "Value of the TRAP variable\n")
+{
+   struct gsm_network *net = gsmnet_from_vty(vty);
+
+   ctrl_cmd_send_trap(net->ctrl, argv[0], (char *) argv[1]);
+   return CMD_SUCCESS;
+}
+
 extern int bsc_vty_init_extra(void);
 
 int bsc_vty_init(struct gsm_network *network)
@@ -4325,6 +4340,7 @@
install_element(ENABLE_NODE, &lchan_act_cmd);
install_element(ENABLE_NODE, &lchan_mdcx_cmd);
install_element(ENABLE_NODE, &smscb_cmd_cmd);
+   install_element(ENABLE_NODE, &ctrl_trap_cmd);
 
abis_nm_vty_init();
abis_om2k_vty_init();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 


[MERGED] osmo-bts[master]: lc15: port lc15bts-mgr changes

2017-07-19 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: lc15: port lc15bts-mgr changes
..


lc15: port lc15bts-mgr changes

That's mostly changes related to lc15bts-mgr from
https://gitlab.com/nrw_noa/osmo-bts branch nrw/litecell15 based on
eb5b7f80510b603579f7af6d7d5ead296c2fa260 commit.

I wanted to incorporate vty and hardcoded paths changes so we can use it
from this point without major backward-incompatible changes as a base
for future ports.

Change-Id: Iabbaedc84594150a4e5445c16dd1f6f89858
Related: SYS#3679
---
M doc/examples/litecell15/lc15bts-mgr.cfg
M include/osmo-bts/phy_link.h
M src/common/Makefile.am
M src/osmo-bts-litecell15/Makefile.am
M src/osmo-bts-litecell15/hw_misc.c
A src/osmo-bts-litecell15/misc/lc15bts_bts.c
A src/osmo-bts-litecell15/misc/lc15bts_bts.h
M src/osmo-bts-litecell15/misc/lc15bts_clock.c
A src/osmo-bts-litecell15/misc/lc15bts_led.c
A src/osmo-bts-litecell15/misc/lc15bts_led.h
M src/osmo-bts-litecell15/misc/lc15bts_mgr.c
M src/osmo-bts-litecell15/misc/lc15bts_mgr.h
M src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
M src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c
M src/osmo-bts-litecell15/misc/lc15bts_misc.c
M src/osmo-bts-litecell15/misc/lc15bts_misc.h
M src/osmo-bts-litecell15/misc/lc15bts_par.c
M src/osmo-bts-litecell15/misc/lc15bts_par.h
M src/osmo-bts-litecell15/misc/lc15bts_power.c
M src/osmo-bts-litecell15/misc/lc15bts_power.h
M src/osmo-bts-litecell15/misc/lc15bts_temp.c
M src/osmo-bts-litecell15/misc/lc15bts_temp.h
22 files changed, 2,014 insertions(+), 411 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/doc/examples/litecell15/lc15bts-mgr.cfg 
b/doc/examples/litecell15/lc15bts-mgr.cfg
index 750dc36..c7d0a79 100644
--- a/doc/examples/litecell15/lc15bts-mgr.cfg
+++ b/doc/examples/litecell15/lc15bts-mgr.cfg
@@ -25,39 +25,19 @@
  no login
 !
 lc15bts-mgr
- limits supply
-   threshold warning 60
-   threshold critical 78
- limits soc
-   threshold warning 60
-   threshold critical 78
- limits fpga
-   threshold warning 60
-   threshold critical 78
- limits logrf
-   threshold warning 60
-   threshold critical 78
- limits tx0
-   threshold warning 60
-   threshold critical 78
- limits tx1
-   threshold warning 60
-   threshold critical 78
- limits pa0
-   threshold warning 60
-   threshold critical 78
- limits pa1
-   threshold warning 60
-   threshold critical 78
- actions normal
-  pa0-on
-  pa1-on
-  bts-service-on
- actions warn
-  no pa0-off
-  no pa1-off
-  no bts-service-off
- actions critical
-  pa0-off
-  pa1-off
-  no bts-service-off
+ limits supply_volt
+   threshold warning min 17500
+   threshold critical min 19000
+ limits tx0_vswr
+   threshold warning max 3
+ limits tx1_vswr
+   threshold warning max 3
+ limits supply_pwr
+   threshold warning max 110
+   threshold critical max 120
+ limits pa0_pwr
+   threshold warning max 50
+   threshold critical max 60
+ limits pa1_pwr
+   threshold warning max 50
+   threshold critical max 60
diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index d8d3c6b..3d4bf91 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -124,6 +124,12 @@
int minTxPower;
int maxTxPower;
struct lc15l1_hdl *hdl;
+   uint8_t max_cell_size;  /* 0:166 qbits*/
+   uint8_t diversity_mode; /* 0: SISO A, 1: SISO 
B, 2: MRC */
+   uint8_t pedestal_mode;  /* 0: unused TS is OFF, 
1: unused TS is in minimum Tx power */
+   uint8_t dsp_alive_period;   /* DSP alive timer 
period  */
+   uint8_t tx_pwr_adj_mode;/* 0: no auto adjust 
power, 1: auto adjust power using RMS detector */
+   uint8_t tx_pwr_red_8psk;/* 8-PSK maximum Tx 
power reduction level in dB */
} lc15;
} u;
 };
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index dd368d0..d104c48 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -2,6 +2,10 @@
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS)
 LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOCODEC_LIBS)
 
+if ENABLE_LC15BTS
+AM_CFLAGS += -DENABLE_LC15BTS
+endif
+
 noinst_LIBRARIES = libbts.a libl1sched.a
 libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
   rsl.c vty.c paging.c measurement.c amr.c lchan.c \
diff --git a/src/osmo-bts-litecell15/Makefile.am 
b/src/osmo-bts-litecell15/Makefile.am
index 3026e96..90e6c46 100644
--- a/src/osmo-bts-litecell15/Makefile.am
+++ b/src/osmo-bts-litecell15/Makefile.am
@@ -4,9 +4,11 @@
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOABIS_CFLAG

osmo-bts[master]: lc15: port lc15bts-mgr changes

2017-07-19 Thread Harald Welte

Patch Set 4: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Iabbaedc84594150a4e5445c16dd1f6f89858
Gerrit-PatchSet: 4
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Minh-Quang Nguyen 
Gerrit-Reviewer: jfdionne 
Gerrit-HasComments: No


openbsc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

2017-07-19 Thread Harald Welte

Patch Set 1:

No, we cannot.  Generating a trap requires us to know the ctrl_handle, which is 
returned to whoever creates a control interface instance.  The only way to 
solve this would be to keep a library-internal list of all control interface 
instances that have been allocated, and then iterate over the list to dispatch 
the command to all control interface instances.

Alternatively, we could restrict the number of control interface instances of 
any application to '1' and keep a static pointer to that inside the library to 
generate the trap.

Etiher way, it would be quite a change to the semantics of how the API works 
right now, so I went for the straight-forward approach.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


openbsc[master]: bsc_vty: Add VTY command to test CTRL TRAP feature

2017-07-19 Thread Max

Patch Set 1:

Can we make it part of libosmoctrl so it's automatically available to all 
projects using it?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib1d2ec38290dc94797c1b365d9b733e5215ab7d1
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


[PATCH] osmo-bts[master]: lc15: port lc15bts-mgr changes

2017-07-19 Thread Max
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/3277

to look at the new patch set (#4).

lc15: port lc15bts-mgr changes

That's mostly changes related to lc15bts-mgr from
https://gitlab.com/nrw_noa/osmo-bts branch nrw/litecell15 based on
eb5b7f80510b603579f7af6d7d5ead296c2fa260 commit.

I wanted to incorporate vty and hardcoded paths changes so we can use it
from this point without major backward-incompatible changes as a base
for future ports.

Change-Id: Iabbaedc84594150a4e5445c16dd1f6f89858
Related: SYS#3679
---
M doc/examples/litecell15/lc15bts-mgr.cfg
M include/osmo-bts/phy_link.h
M src/common/Makefile.am
M src/osmo-bts-litecell15/Makefile.am
M src/osmo-bts-litecell15/hw_misc.c
A src/osmo-bts-litecell15/misc/lc15bts_bts.c
A src/osmo-bts-litecell15/misc/lc15bts_bts.h
M src/osmo-bts-litecell15/misc/lc15bts_clock.c
A src/osmo-bts-litecell15/misc/lc15bts_led.c
A src/osmo-bts-litecell15/misc/lc15bts_led.h
M src/osmo-bts-litecell15/misc/lc15bts_mgr.c
M src/osmo-bts-litecell15/misc/lc15bts_mgr.h
M src/osmo-bts-litecell15/misc/lc15bts_mgr_temp.c
M src/osmo-bts-litecell15/misc/lc15bts_mgr_vty.c
M src/osmo-bts-litecell15/misc/lc15bts_misc.c
M src/osmo-bts-litecell15/misc/lc15bts_misc.h
M src/osmo-bts-litecell15/misc/lc15bts_par.c
M src/osmo-bts-litecell15/misc/lc15bts_par.h
M src/osmo-bts-litecell15/misc/lc15bts_power.c
M src/osmo-bts-litecell15/misc/lc15bts_power.h
M src/osmo-bts-litecell15/misc/lc15bts_temp.c
M src/osmo-bts-litecell15/misc/lc15bts_temp.h
22 files changed, 2,014 insertions(+), 411 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/77/3277/4

diff --git a/doc/examples/litecell15/lc15bts-mgr.cfg 
b/doc/examples/litecell15/lc15bts-mgr.cfg
index 750dc36..c7d0a79 100644
--- a/doc/examples/litecell15/lc15bts-mgr.cfg
+++ b/doc/examples/litecell15/lc15bts-mgr.cfg
@@ -25,39 +25,19 @@
  no login
 !
 lc15bts-mgr
- limits supply
-   threshold warning 60
-   threshold critical 78
- limits soc
-   threshold warning 60
-   threshold critical 78
- limits fpga
-   threshold warning 60
-   threshold critical 78
- limits logrf
-   threshold warning 60
-   threshold critical 78
- limits tx0
-   threshold warning 60
-   threshold critical 78
- limits tx1
-   threshold warning 60
-   threshold critical 78
- limits pa0
-   threshold warning 60
-   threshold critical 78
- limits pa1
-   threshold warning 60
-   threshold critical 78
- actions normal
-  pa0-on
-  pa1-on
-  bts-service-on
- actions warn
-  no pa0-off
-  no pa1-off
-  no bts-service-off
- actions critical
-  pa0-off
-  pa1-off
-  no bts-service-off
+ limits supply_volt
+   threshold warning min 17500
+   threshold critical min 19000
+ limits tx0_vswr
+   threshold warning max 3
+ limits tx1_vswr
+   threshold warning max 3
+ limits supply_pwr
+   threshold warning max 110
+   threshold critical max 120
+ limits pa0_pwr
+   threshold warning max 50
+   threshold critical max 60
+ limits pa1_pwr
+   threshold warning max 50
+   threshold critical max 60
diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h
index d8d3c6b..3d4bf91 100644
--- a/include/osmo-bts/phy_link.h
+++ b/include/osmo-bts/phy_link.h
@@ -124,6 +124,12 @@
int minTxPower;
int maxTxPower;
struct lc15l1_hdl *hdl;
+   uint8_t max_cell_size;  /* 0:166 qbits*/
+   uint8_t diversity_mode; /* 0: SISO A, 1: SISO 
B, 2: MRC */
+   uint8_t pedestal_mode;  /* 0: unused TS is OFF, 
1: unused TS is in minimum Tx power */
+   uint8_t dsp_alive_period;   /* DSP alive timer 
period  */
+   uint8_t tx_pwr_adj_mode;/* 0: no auto adjust 
power, 1: auto adjust power using RMS detector */
+   uint8_t tx_pwr_red_8psk;/* 8-PSK maximum Tx 
power reduction level in dB */
} lc15;
} u;
 };
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index dd368d0..d104c48 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -2,6 +2,10 @@
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOCODEC_CFLAGS)
 LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOCODEC_LIBS)
 
+if ENABLE_LC15BTS
+AM_CFLAGS += -DENABLE_LC15BTS
+endif
+
 noinst_LIBRARIES = libbts.a libl1sched.a
 libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
   rsl.c vty.c paging.c measurement.c amr.c lchan.c \
diff --git a/src/osmo-bts-litecell15/Makefile.am 
b/src/osmo-bts-litecell15/Makefile.am
index 3026e96..90e6c46 100644
--- a/src/osmo-bts-litecell15/Makefile.am
+++ b/src/osmo-bts-litecell15/Makefile.am
@@ -4,9 +4,11 @@
 AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOCODEC_CFLAGS) 
$(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) 
$(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_C