pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/28047 )


Change subject: WIP: paging: start/stop credit_timer based on C0 running
......................................................................

WIP: paging: start/stop credit_timer based on C0 running

Change-Id: I1b5b1a98115b4e9d821eb3330fc5b970a0e78a44
---
M include/osmocom/bsc/paging.h
M src/osmo-bsc/osmo_bsc_main.c
M src/osmo-bsc/paging.c
3 files changed, 60 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/47/28047/1

diff --git a/include/osmocom/bsc/paging.h b/include/osmocom/bsc/paging.h
index 9b63225..154dd67 100644
--- a/include/osmocom/bsc/paging.h
+++ b/include/osmocom/bsc/paging.h
@@ -113,6 +113,8 @@
        uint16_t available_slots;
 };

+void paging_global_init(void);
+
 void paging_init(struct gsm_bts *bts);
 void paging_destructor(struct gsm_bts *bts);

diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c
index 12ddbd2..b986b0e 100644
--- a/src/osmo-bsc/osmo_bsc_main.c
+++ b/src/osmo-bsc/osmo_bsc_main.c
@@ -929,6 +929,7 @@
        assignment_fsm_init();
        handover_fsm_init();
        lb_init();
+       paging_global_init();

        /* Read the config */
        rc = bsc_network_configure(config_file);
diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c
index e7a0ee2..b69907e 100644
--- a/src/osmo-bsc/paging.c
+++ b/src/osmo-bsc/paging.c
@@ -220,10 +220,6 @@
                return;
        }
 
-       /* Skip paging if the bts is down. */
-       if (!bts->c0->rsl_link_primary)
-               goto sched_next_iter;
-
        osmo_clock_gettime(CLOCK_MONOTONIC, &now);
 
        /* do while loop: Try send at most first MAX_PAGE_REQ_PER_ITER paging
@@ -300,12 +296,10 @@
 {
        bts->paging.bts = bts;
        bts->paging.free_chans_need = -1;
-       unsigned int load_ind_timeout = bts_no_ccch_load_ind_timeout_sec(bts);
-       bts->paging.available_slots = paging_estimate_available_slots(bts, 
load_ind_timeout);
+       bts->paging.available_slots = 0;
        INIT_LLIST_HEAD(&bts->paging.pending_requests);
        osmo_timer_setup(&bts->paging.work_timer, paging_worker, &bts->paging);
        osmo_timer_setup(&bts->paging.credit_timer, paging_give_credit, 
&bts->paging);
-       osmo_timer_schedule(&bts->paging.credit_timer, load_ind_timeout, 0);
 }

 /* Called upon the bts struct being freed */
@@ -593,10 +587,12 @@
        LOG_BTS(bts, DPAG, LOGL_DEBUG, "Rx CCCH Load Indication from BTS 
(available_slots %u -> %u)\n",
                bts->paging.available_slots, free_slots);
        bts->paging.available_slots = free_slots;
-       paging_schedule_if_needed(&bts->paging);
-       /* Re-arm credit_timer */
-       osmo_timer_schedule(&bts->paging.credit_timer,
-                           bts_no_ccch_load_ind_timeout_sec(bts), 0);
+       /* Re-arm credit_timer if needed */
+       if (trx_is_usable(bts->c0)) {
+               paging_schedule_if_needed(&bts->paging);
+               osmo_timer_schedule(&bts->paging.credit_timer,
+                                   bts_no_ccch_load_ind_timeout_sec(bts), 0);
+       }
 }

 /*! Count the number of pending paging requests on given BTS */
@@ -680,3 +676,53 @@
        }
        return time_us;
 }
+
+/* Callback function to be called every time we receive a signal from NM */
+static int nm_sig_cb(unsigned int subsys, unsigned int signal,
+                    void *handler_data, void *signal_data)
+{
+       struct nm_running_chg_signal_data *nsd;
+       struct gsm_bts *bts;
+       struct gsm_bts_trx *trx;
+       unsigned int load_ind_timeout;
+
+       if (signal != S_NM_RUNNING_CHG)
+               return 0;
+       nsd = signal_data;
+       bts = nsd->bts;
+       switch (nsd->obj_class) {
+       case NM_OC_RADIO_CARRIER:
+               trx = (struct gsm_bts_trx *)nsd->obj;
+               break;
+       case NM_OC_BASEB_TRANSC:
+               trx = gsm_bts_bb_trx_get_trx((struct gsm_bts_bb_trx *)nsd->obj);
+               break;
+       default:
+               return 0;
+       }
+       if (trx != trx->bts->c0)
+               return 0;
+       if (nsd->running) {
+               if (trx_is_usable(trx)) {
+                       LOG_BTS(bts, DPAG, LOGL_INFO, "C0 becomes available for 
paging\n");
+                       /* Fill in initial credit */
+                       load_ind_timeout = 
bts_no_ccch_load_ind_timeout_sec(bts);
+                       bts->paging.available_slots = 
paging_estimate_available_slots(bts, load_ind_timeout);
+                       /* Start scheduling credit_timer */
+                       osmo_timer_schedule(&bts->paging.credit_timer,
+                                           
bts_no_ccch_load_ind_timeout_sec(bts), 0);
+                       /* work_timer will be started when new paging requests 
arrive. */
+               }
+       } else {
+               LOG_BTS(bts, DPAG, LOGL_INFO, "C0 becomes unavailable for 
paging\n");
+               osmo_timer_del(&bts->paging.work_timer);
+               osmo_timer_del(&bts->paging.credit_timer);
+       }
+       return 0;
+}
+
+/* To be called once at startup of the process: */
+void paging_global_init(void)
+{
+       osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
+}

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/28047
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I1b5b1a98115b4e9d821eb3330fc5b970a0e78a44
Gerrit-Change-Number: 28047
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to