[MERGED] osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-03-06 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: vty: Implement VTY cfg parsing for current parameters
..


vty: Implement VTY cfg parsing for current parameters

At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
---
M CommonLibs/trx_vty.c
M CommonLibs/trx_vty.h
M Transceiver52M/osmo-trx.cpp
3 files changed, 469 insertions(+), 2 deletions(-)

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



diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index b16cd24..843d19f 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -36,6 +36,22 @@
 
 static struct trx_ctx* g_trx_ctx;
 
+static const struct value_string clock_ref_names[] = {
+   { REF_INTERNAL, "internal" },
+   { REF_EXTERNAL, "external" },
+   { REF_GPS,  "gspdo" },
+   { 0,NULL }
+};
+
+static const struct value_string filler_names[] = {
+   { FILLER_DUMMY, "Dummy bursts" },
+   { FILLER_ZERO,  "Disabled" },
+   { FILLER_NORM_RAND, "Normal bursts with random payload" },
+   { FILLER_EDGE_RAND, "EDGE bursts with random payload" },
+   { FILLER_ACCESS_RAND,   "Access bursts with random payload" },
+   { 0,NULL }
+};
+
 struct trx_ctx *trx_from_vty(struct vty *v)
 {
 /* It can't hurt to force callers to continue to pass the vty instance
@@ -50,11 +66,18 @@
 
 enum trx_vty_node {
TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   CHAN_NODE,
 };
 
 static struct cmd_node trx_node = {
TRX_NODE,
"%s(config-trx)# ",
+   1,
+};
+
+static struct cmd_node chan_node = {
+   CHAN_NODE,
+   "%s(config-trx-chan)# ",
1,
 };
 
@@ -84,15 +107,364 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_remote_ip, cfg_remote_ip_cmd,
+   "remote-ip A.B.C.D",
+   "Set the IP address for the remote BTS\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.remote_addr, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_base_port, cfg_base_port_cmd,
+   "base-port <1-65535>",
+   "Set the TRX Base Port\n"
+   "TRX Base Port\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.base_port = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_dev_args, cfg_dev_args_cmd,
+   "dev-args DESC",
+   "Set the device-specific arguments to pass to the device\n"
+   "Device-specific arguments\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.dev_args, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_tx_sps, cfg_tx_sps_cmd,
+   "tx-sps (1|4)",
+   "Set the Tx Samples-per-Symbol\n"
+   "Tx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.tx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rx_sps, cfg_rx_sps_cmd,
+   "rx-sps (1|4)",
+   "Set the Rx Samples-per-Symbol\n"
+   "Rx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.rx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rtsc, cfg_test_rtsc_cmd,
+   "test rtsc <0-7>",
+   "Set the Random Normal Burst test mode with TSC\n"
+   "TSC\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rach_delay_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rtsc_set = true;
+   trx->cfg.rtsc = atoi(argv[0]);
+   if (!trx->cfg.egprs) /* Don't override egprs which sets different 
filler */
+   trx->cfg.filler = FILLER_NORM_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rach_delay, cfg_test_rach_delay_cmd,
+   "test rach-delay <0-68>",
+   "Set the Random Access Burst test mode with delay\n"
+   "RACH delay\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rtsc_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   if (trx->cfg.egprs) {
+   vty_out(vty, "rach-delay and egprs options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rach_delay_set = true;
+   trx->cfg.rach_delay = atoi(argv[0]);
+   trx->cfg.filler = FILLER_ACCESS_RAND;
+
+   re

osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-03-05 Thread Harald Welte

Patch Set 6: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 6
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-03-05 Thread Pau Espin Pedrol
Hello Vadim Yanitskiy, Jenkins Builder,

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

https://gerrit.osmocom.org/6650

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

vty: Implement VTY cfg parsing for current parameters

At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
---
M CommonLibs/trx_vty.c
M CommonLibs/trx_vty.h
M Transceiver52M/osmo-trx.cpp
3 files changed, 469 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/50/6650/6

diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index b16cd24..843d19f 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -36,6 +36,22 @@
 
 static struct trx_ctx* g_trx_ctx;
 
+static const struct value_string clock_ref_names[] = {
+   { REF_INTERNAL, "internal" },
+   { REF_EXTERNAL, "external" },
+   { REF_GPS,  "gspdo" },
+   { 0,NULL }
+};
+
+static const struct value_string filler_names[] = {
+   { FILLER_DUMMY, "Dummy bursts" },
+   { FILLER_ZERO,  "Disabled" },
+   { FILLER_NORM_RAND, "Normal bursts with random payload" },
+   { FILLER_EDGE_RAND, "EDGE bursts with random payload" },
+   { FILLER_ACCESS_RAND,   "Access bursts with random payload" },
+   { 0,NULL }
+};
+
 struct trx_ctx *trx_from_vty(struct vty *v)
 {
 /* It can't hurt to force callers to continue to pass the vty instance
@@ -50,11 +66,18 @@
 
 enum trx_vty_node {
TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   CHAN_NODE,
 };
 
 static struct cmd_node trx_node = {
TRX_NODE,
"%s(config-trx)# ",
+   1,
+};
+
+static struct cmd_node chan_node = {
+   CHAN_NODE,
+   "%s(config-trx-chan)# ",
1,
 };
 
@@ -84,15 +107,364 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_remote_ip, cfg_remote_ip_cmd,
+   "remote-ip A.B.C.D",
+   "Set the IP address for the remote BTS\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.remote_addr, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_base_port, cfg_base_port_cmd,
+   "base-port <1-65535>",
+   "Set the TRX Base Port\n"
+   "TRX Base Port\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.base_port = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_dev_args, cfg_dev_args_cmd,
+   "dev-args DESC",
+   "Set the device-specific arguments to pass to the device\n"
+   "Device-specific arguments\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.dev_args, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_tx_sps, cfg_tx_sps_cmd,
+   "tx-sps (1|4)",
+   "Set the Tx Samples-per-Symbol\n"
+   "Tx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.tx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rx_sps, cfg_rx_sps_cmd,
+   "rx-sps (1|4)",
+   "Set the Rx Samples-per-Symbol\n"
+   "Rx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.rx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rtsc, cfg_test_rtsc_cmd,
+   "test rtsc <0-7>",
+   "Set the Random Normal Burst test mode with TSC\n"
+   "TSC\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rach_delay_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rtsc_set = true;
+   trx->cfg.rtsc = atoi(argv[0]);
+   if (!trx->cfg.egprs) /* Don't override egprs which sets different 
filler */
+   trx->cfg.filler = FILLER_NORM_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rach_delay, cfg_test_rach_delay_cmd,
+   "test rach-delay <0-68>",
+   "Set the Random Access Burst test mode with delay\n"
+   "RACH delay\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rtsc_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   if (trx->cfg.egprs) {
+   vty_out(vty, "rach-delay and egprs options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rach_delay_set = true;
+   trx->cfg.rach_delay = atoi(argv[0]);
+   trx->cfg.filler = FILLER_ACCESS_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_clock_ref, c

osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-03-05 Thread Vadim Yanitskiy

Patch Set 5: Code-Review-1

Please add the configuration example(s) before this change.
At the moment, the "osmo-trx-limesdr.cfg" looks unrelated.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-23 Thread Harald Welte

Patch Set 5:

(1 comment)

https://gerrit.osmocom.org/#/c/6650/5/CommonLibs/trx_vty.c
File CommonLibs/trx_vty.c:

Line 123:   "base-port <0-65535>",
port number '0' is not legal.


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: Yes


osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-23 Thread Harald Welte

Patch Set 5:

> > I don't think any of our vty has "on|off" so far. We have a
 > > enable/disable or 0/1 ,(or cmd / no cmd). Let's not introduce
 > even
 > > more inconsistencies, please.
 > 
 > We have on/off for osmux for instance. 

*sigh*.  Not sure how that slipped through the cracks at the time.  I really 
dislike
those inconsistencies.  They are a public sign of how sloppy we are :/

> But I can change it to other stuff if looks better to you, I have no 
> preference.

I think any method is better than the on|off

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-23 Thread Pau Espin Pedrol

Patch Set 5:

> I don't think any of our vty has "on|off" so far. We have a
 > enable/disable or 0/1 ,(or cmd / no cmd). Let's not introduce even
 > more inconsistencies, please.

We have on/off for osmux for instance. But I can change it to other stuff if 
looks better to you, I have no preference.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-23 Thread Harald Welte

Patch Set 5:

I don't think any of our vty has "on|off" so far. We have a enable/disable or 
0/1 ,(or cmd / no cmd). Let's not introduce even more inconsistencies, please.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
Gerrit-PatchSet: 5
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-22 Thread Pau Espin Pedrol
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/6650

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

vty: Implement VTY cfg parsing for current parameters

At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
---
M CommonLibs/trx_vty.c
M CommonLibs/trx_vty.h
M Transceiver52M/osmo-trx.cpp
A doc/examples/osmo-trx-limesdr.cfg
4 files changed, 488 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/50/6650/2

diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index b16cd24..2182df5 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -36,6 +36,22 @@
 
 static struct trx_ctx* g_trx_ctx;
 
+static const struct value_string clock_ref_names[] = {
+   { REF_INTERNAL, "internal" },
+   { REF_EXTERNAL, "external" },
+   { REF_GPS,  "gspdo" },
+   { 0,NULL }
+};
+
+static const struct value_string filler_names[] = {
+   { FILLER_DUMMY, "Dummy bursts" },
+   { FILLER_ZERO,  "Disabled" },
+   { FILLER_NORM_RAND, "Normal bursts with random payload" },
+   { FILLER_EDGE_RAND, "EDGE bursts with random payload" },
+   { FILLER_ACCESS_RAND,   "Access bursts with random payload" },
+   { 0,NULL }
+};
+
 struct trx_ctx *trx_from_vty(struct vty *v)
 {
 /* It can't hurt to force callers to continue to pass the vty instance
@@ -50,11 +66,18 @@
 
 enum trx_vty_node {
TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   CHAN_NODE,
 };
 
 static struct cmd_node trx_node = {
TRX_NODE,
"%s(config-trx)# ",
+   1,
+};
+
+static struct cmd_node chan_node = {
+   CHAN_NODE,
+   "%s(config-trx-chan)# ",
1,
 };
 
@@ -84,15 +107,363 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_remote_ip, cfg_remote_ip_cmd,
+   "remote-ip A.B.C.D",
+   "Set the IP address for the remote BTS\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.remote_addr, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_base_port, cfg_base_port_cmd,
+   "base-port <0-65535>",
+   "Set the TRX Base Port\n"
+   "TRX Base Port\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.base_port = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_dev_args, cfg_dev_args_cmd,
+   "dev-args DESC",
+   "Set the device-specific arguments to pass to the device\n"
+   "Device-specific arguments\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.dev_args, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_tx_sps, cfg_tx_sps_cmd,
+   "tx-sps (1|4)",
+   "Set the Tx Samples-per-Symbol\n"
+   "Tx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.tx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rx_sps, cfg_rx_sps_cmd,
+   "rx-sps (1|4)",
+   "Set the Rx Samples-per-Symbol\n"
+   "Rx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.rx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rtsc, cfg_test_rtsc_cmd,
+   "test rtsc <0-7>",
+   "Set the Random Normal Burst test mode with TSC\n"
+   "TSC\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rach_delay_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rtsc_set = true;
+   trx->cfg.rtsc = atoi(argv[0]);
+   if (!trx->cfg.egprs) /* Don't override egprs which sets different 
filler */
+   trx->cfg.filler = FILLER_NORM_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_test_rach_delay, cfg_test_rach_delay_cmd,
+   "test rach-delay <0-68>",
+   "Set the Random Access Burst test mode with delay\n"
+   "RACH delay\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rtsc_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   if (trx->cfg.egprs) {
+   vty_out(vty, "rach-delay and egprs options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rach_delay_set = true;
+   trx->cfg.rach_delay = atoi(argv[0]);
+   trx->cfg.filler = FILLER_ACCESS_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEF

osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-22 Thread Pau Espin Pedrol

Patch Set 1:

> I think the test related config items should be more visibly test
 > related?

Sorry I don't get what you mean here, can you elaborate a bit more?

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

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


osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-22 Thread Harald Welte

Patch Set 1:

I think the test related config items should be more visibly test related?

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

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


[PATCH] osmo-trx[master]: vty: Implement VTY cfg parsing for current parameters

2018-02-21 Thread Pau Espin Pedrol

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

vty: Implement VTY cfg parsing for current parameters

At this stage, osmo-trx still uses the cmdline parameters top run the
device, but it is already able to parse all the same parameters from a
cfg file through the VTY and filling a trx_ctx structure which will be
later used to drive the device. Device config can be printed in the VTY
with "show trx".

Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
---
M CommonLibs/trx_vty.c
M CommonLibs/trx_vty.h
M Transceiver52M/osmo-trx.cpp
A doc/examples/osmo-trx-limesdr.cfg
4 files changed, 488 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/50/6650/1

diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c
index b16cd24..73603b3 100644
--- a/CommonLibs/trx_vty.c
+++ b/CommonLibs/trx_vty.c
@@ -36,6 +36,22 @@
 
 static struct trx_ctx* g_trx_ctx;
 
+static const struct value_string clock_ref_names[] = {
+   { REF_INTERNAL, "internal" },
+   { REF_EXTERNAL, "external" },
+   { REF_GPS,  "gspdo" },
+   { 0,NULL }
+};
+
+static const struct value_string filler_names[] = {
+   { FILLER_DUMMY, "Dummy bursts" },
+   { FILLER_ZERO,  "Disabled" },
+   { FILLER_NORM_RAND, "Normal bursts with random payload" },
+   { FILLER_EDGE_RAND, "EDGE bursts with random payload" },
+   { FILLER_ACCESS_RAND,   "Access bursts with random payload" },
+   { 0,NULL }
+};
+
 struct trx_ctx *trx_from_vty(struct vty *v)
 {
 /* It can't hurt to force callers to continue to pass the vty instance
@@ -50,11 +66,18 @@
 
 enum trx_vty_node {
TRX_NODE = _LAST_OSMOVTY_NODE + 1,
+   CHAN_NODE,
 };
 
 static struct cmd_node trx_node = {
TRX_NODE,
"%s(config-trx)# ",
+   1,
+};
+
+static struct cmd_node chan_node = {
+   CHAN_NODE,
+   "%s(config-trx-chan)# ",
1,
 };
 
@@ -84,15 +107,363 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_remote_ip, cfg_remote_ip_cmd,
+   "remote-ip A.B.C.D",
+   "Set the IP address for the remote BTS\n"
+   "IPv4 Address\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.remote_addr, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_base_port, cfg_base_port_cmd,
+   "base-port <0-65535>",
+   "Set the TRX Base Port\n"
+   "TRX Base Port\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.base_port = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_dev_args, cfg_dev_args_cmd,
+   "dev-args DESC",
+   "Set the device-specific arguments to pass to the device\n"
+   "Device-specific arguments\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   osmo_talloc_replace_string(trx, &trx->cfg.dev_args, argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_tx_sps, cfg_tx_sps_cmd,
+   "tx-sps (1|4)",
+   "Set the Tx Samples-per-Symbol\n"
+   "Tx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.tx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rx_sps, cfg_rx_sps_cmd,
+   "rx-sps (1|4)",
+   "Set the Rx Samples-per-Symbol\n"
+   "Rx Samples-per-Symbol\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   trx->cfg.rx_sps = atoi(argv[0]);
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rtsc, cfg_rtsc_cmd,
+   "rtsc <0-7>",
+   "Set the Random Normal Burst test mode with TSC\n"
+   "TSC\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rach_delay_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rtsc_set = true;
+   trx->cfg.rtsc = atoi(argv[0]);
+   if (!trx->cfg.egprs) /* Don't override egprs which sets different 
filler */
+   trx->cfg.filler = FILLER_NORM_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_rach_delay, cfg_rach_delay_cmd,
+   "rach-delay <0-68>",
+   "Set the Random Access Burst test mode with delay\n"
+   "RACH delay\n")
+{
+   struct trx_ctx *trx = trx_from_vty(vty);
+
+   if (trx->cfg.rtsc_set) {
+   vty_out(vty, "rach-delay and rtsc options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   if (trx->cfg.egprs) {
+   vty_out(vty, "rach-delay and egprs options are 
mutual-exclusive%s",
+   VTY_NEWLINE);
+   return CMD_WARNING;
+   }
+
+   trx->cfg.rach_delay_set = true;
+   trx->cfg.rach_delay = atoi(argv[0]);
+   trx->cfg.filler = FILLER_ACCESS_RAND;
+
+   return CMD_SUCCESS;
+}
+
+DEFUN(cfg_clock_ref, cfg_clock_ref_cmd,
+   "clock-ref (internal|external|gpsdo)",
+   "Set the Reference Clock\n"
+   "Enab