Hello Pau Espin Pedrol, Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/7732

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

trigger acc ramping based on trx rf-locked state

Make ACC ramping listen to network management signals and trigger
or abort ACC ramping based on the RF locked state of TRX 0.

This works as expected with a virtphy setup when RF lock state is
changed via VTY. However, this change still needs to be tested with
a nanobts. It's also not quite clear yet whether operational state
changes, as opposed to administrative ones, should be taken into
account as well.

Change-Id: I4124f1da3dadec003de45c1da8435506ee8f0a34
Depends: Ia25bff85d9e5c277da76bffa11d31972e9fdc323
---
M src/libbsc/acc_ramp.c
M src/libbsc/bsc_vty.c
2 files changed, 49 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/32/7732/3

diff --git a/src/libbsc/acc_ramp.c b/src/libbsc/acc_ramp.c
index aa4fd27..a1dbdac 100644
--- a/src/libbsc/acc_ramp.c
+++ b/src/libbsc/acc_ramp.c
@@ -26,6 +26,7 @@
 #include <osmocom/bsc/debug.h>
 #include <osmocom/bsc/acc_ramp.h>
 #include <osmocom/bsc/gsm_data.h>
+#include <osmocom/bsc/signal.h>
 
 /*
  * Check if an ACC has been permanently barred for a BTS,
@@ -134,6 +135,49 @@
                osmo_timer_schedule(&acc_ramp->step_timer, 
get_next_step_interval(acc_ramp), 0);
 }
 
+/* Implements osmo_signal_cbfn() -- trigger or abort ACC ramping upon changes 
RF lock state. */
+static int acc_ramp_nm_sig_cb(unsigned int subsys, unsigned int signal, void 
*handler_data, void *signal_data)
+{
+       struct nm_statechg_signal_data *nsd = signal_data;
+       struct acc_ramp *acc_ramp = handler_data;
+       struct gsm_bts_trx *trx = NULL;
+
+       if (signal != S_NM_STATECHG_ADM)
+               return 0;
+
+       if (nsd->obj_class != NM_OC_RADIO_CARRIER)
+               return 0;
+
+       trx = nsd->obj;
+
+       /* We only care about state changes of the first TRX. */
+       if (trx->nr != 0)
+               return 0;
+
+       /* RSL must already be up. We cannot send RACH system information to 
the BTS otherwise. */
+       if (trx->rsl_link == NULL)
+               return 0;
+
+       /* Trigger or abort ACC ramping based on the new 'RF lock' state of 
this TRX. */
+       switch (nsd->new_state->administrative) {
+       case NM_STATE_UNLOCKED:
+               acc_ramp_trigger(acc_ramp);
+               break;
+       case NM_STATE_LOCKED:
+       case NM_STATE_SHUTDOWN:
+               acc_ramp_abort(acc_ramp);
+               break;
+       case NM_STATE_NULL:
+               break;
+       default:
+               LOGP(DRSL, LOGL_NOTICE, "(bts=%d) ACC RAMP: unrecognized 
administrative state '0x%x' reported for TRX 0\n",
+                   acc_ramp->bts->nr, nsd->new_state->administrative);
+               break;
+       }
+
+       return 0;
+}
+
 /*!
  * Initialize an acc_ramp data structure.
  * Storage for this structure must be provided by the caller.
@@ -152,6 +196,7 @@
        acc_ramp->step_interval_is_fixed = false;
        allow_all_enabled_accs(acc_ramp);
        osmo_timer_setup(&acc_ramp->step_timer, do_acc_ramping_step, acc_ramp);
+       osmo_signal_register_handler(SS_NM, acc_ramp_nm_sig_cb, acc_ramp);
 }
 
 /*!
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index 521a36a..c8d1637 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -3278,7 +3278,10 @@
        if (!acc_ramp_is_enabled(&bts->acc_ramp))
                acc_ramp_set_enabled(&bts->acc_ramp, true);
 
-       /* ACC ramping takes effect when the BTS reconnects. */
+       /*
+        * ACC ramping takes effect either when the BTS reconnects RSL,
+        * or when RF administrative state changes to 'unlocked'.
+        */
        return CMD_SUCCESS;
 }
 

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4124f1da3dadec003de45c1da8435506ee8f0a34
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>

Reply via email to