pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/22449 )

Change subject: NACC: allow setting keep time for entries in neigh and si cache
......................................................................

NACC: allow setting keep time for entries in neigh and si cache

Related: SYS#4909
Change-Id: Ifa336aa27dd88ff5b78dbc5a2799740f542bb369
---
M src/gprs_pcu.c
M src/gprs_pcu.h
M src/neigh_cache.c
M src/neigh_cache.h
M src/pcu_vty.c
5 files changed, 45 insertions(+), 15 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve



diff --git a/src/gprs_pcu.c b/src/gprs_pcu.c
index 9a21cdb..31ed8b7 100644
--- a/src/gprs_pcu.c
+++ b/src/gprs_pcu.c
@@ -33,6 +33,8 @@
        { .T=1,     .default_val=30,  .unit=OSMO_TDEF_S,  .desc="BSSGP 
(un)blocking procedures timer (s)",  .val=0 },
        { .T=2,     .default_val=30,  .unit=OSMO_TDEF_S,  .desc="BSSGP reset 
procedure timer (s)",          .val=0 },
        { .T=3190,  .default_val=5,   .unit=OSMO_TDEF_S,  .desc="Return to 
packet idle mode after Packet DL Assignment on CCCH (s)", .val=0},
+       { .T=PCU_TDEF_NEIGH_CACHE_ALIVE,   .default_val=5,  .unit=OSMO_TDEF_S,  
 .desc="[ARFCN+BSIC]->[RAC+CI] resolution cache entry storage timeout (s)", 
.val=0 },
+       { .T=PCU_TDEF_SI_CACHE_ALIVE,      .default_val=5,  .unit=OSMO_TDEF_S,  
 .desc="[RAC+CI]->[SI] resolution cache entry storage timeout (s)", .val=0 },
        { .T=-2000, .default_val=2,   .unit=OSMO_TDEF_MS, .desc="Tbf reject for 
PRR timer (ms)",            .val=0 },
        { .T=-2001, .default_val=2,   .unit=OSMO_TDEF_S,  .desc="PACCH 
assignment timer (s)",               .val=0 },
        { .T=-2002, .default_val=200, .unit=OSMO_TDEF_MS, .desc="Waiting after 
IMM.ASS confirm timer (ms)", .val=0 },
@@ -114,8 +116,8 @@

        INIT_LLIST_HEAD(&pcu->bts_list);

-       pcu->neigh_cache = neigh_cache_alloc(pcu);
-       pcu->si_cache = si_cache_alloc(pcu);
+       pcu->neigh_cache = neigh_cache_alloc(pcu, osmo_tdef_get(pcu->T_defs, 
PCU_TDEF_NEIGH_CACHE_ALIVE, OSMO_TDEF_S, -1));
+       pcu->si_cache = si_cache_alloc(pcu, osmo_tdef_get(pcu->T_defs, 
PCU_TDEF_SI_CACHE_ALIVE, OSMO_TDEF_S, -1));

        return pcu;
 }
diff --git a/src/gprs_pcu.h b/src/gprs_pcu.h
index 8e18f89..4f22f68 100644
--- a/src/gprs_pcu.h
+++ b/src/gprs_pcu.h
@@ -37,6 +37,9 @@
 #define MAX_EDGE_MCS 9
 #define MAX_GPRS_CS 4

+#define PCU_TDEF_NEIGH_CACHE_ALIVE (-10)
+#define PCU_TDEF_SI_CACHE_ALIVE    (-11)
+
 /* see bts->gsmtap_categ_mask */
 enum pcu_gsmtap_category {
        PCU_GSMTAP_C_DL_UNKNOWN         = 0,    /* unknown or undecodable 
downlink blocks */
diff --git a/src/neigh_cache.c b/src/neigh_cache.c
index a4bdfbe..ae619d3 100644
--- a/src/neigh_cache.c
+++ b/src/neigh_cache.c
@@ -27,10 +27,6 @@
 #include <neigh_cache.h>
 #include <gprs_debug.h>

-#define KEEP_TIME_DEFAULT_SEC 5
-
-/*TODO: add a timer to the_pcu T_defs, pass value to struct neigh_cache 
instead of KEEP_TIME_DEFAULT_SEC */
-
 static inline bool neigh_cache_entry_key_eq(const struct neigh_cache_entry_key 
*a,
                                            const struct neigh_cache_entry_key 
*b)
 {
@@ -89,16 +85,23 @@
        osmo_timer_schedule(&cache->cleanup_timer, result.tv_sec, 
result.tv_nsec*1000);
 }

-struct neigh_cache *neigh_cache_alloc(void *ctx)
+struct neigh_cache *neigh_cache_alloc(void *ctx, unsigned int keep_time_sec)
 {
        struct neigh_cache *cache = talloc_zero(ctx, struct neigh_cache);
        OSMO_ASSERT(cache);
        INIT_LLIST_HEAD(&cache->list);
        osmo_timer_setup(&cache->cleanup_timer, neigh_cache_cleanup_cb, cache);
-       cache->keep_time_intval = (struct timespec){ .tv_sec = 
KEEP_TIME_DEFAULT_SEC, .tv_nsec = 0};
+       cache->keep_time_intval = (struct timespec){ .tv_sec = keep_time_sec, 
.tv_nsec = 0};
        return cache;

 }
+
+void neigh_cache_set_keep_time_interval(struct neigh_cache *cache, unsigned 
int keep_time_sec)
+{
+       cache->keep_time_intval = (struct timespec){ .tv_sec = keep_time_sec, 
.tv_nsec = 0};
+       neigh_cache_schedule_cleanup(cache);
+}
+
 struct neigh_cache_entry *neigh_cache_add(struct neigh_cache *cache,
                                          const struct neigh_cache_entry_key 
*key,
                                          const struct osmo_cell_global_id_ps 
*value)
@@ -168,8 +171,6 @@
 // SI CACHE
 ///////////////////

-/*TODO: add a timer to the_pcu T_defs, pass value to struct neigh_cache 
instead of KEEP_TIME_DEFAULT_SEC */
-
 static void si_cache_schedule_cleanup(struct si_cache *cache);
 static void si_cache_cleanup_cb(void *data)
 {
@@ -218,15 +219,22 @@
        osmo_timer_schedule(&cache->cleanup_timer, result.tv_sec, 
result.tv_nsec*1000);
 }

-struct si_cache *si_cache_alloc(void *ctx)
+struct si_cache *si_cache_alloc(void *ctx, unsigned int keep_time_sec)
 {
        struct si_cache *cache = talloc_zero(ctx, struct si_cache);
        OSMO_ASSERT(cache);
        INIT_LLIST_HEAD(&cache->list);
        osmo_timer_setup(&cache->cleanup_timer, si_cache_cleanup_cb, cache);
-       cache->keep_time_intval = (struct timespec){ .tv_sec = 
KEEP_TIME_DEFAULT_SEC, .tv_nsec = 0};
+       cache->keep_time_intval = (struct timespec){ .tv_sec = keep_time_sec, 
.tv_nsec = 0};
        return cache;
 }
+
+void si_cache_set_keep_time_interval(struct si_cache *cache, unsigned int 
keep_time_sec)
+{
+       cache->keep_time_intval = (struct timespec){ .tv_sec = keep_time_sec, 
.tv_nsec = 0};
+       si_cache_schedule_cleanup(cache);
+}
+
 struct si_cache_entry *si_cache_add(struct si_cache *cache,
                                    const struct osmo_cell_global_id_ps *key,
                                    const struct si_cache_value *value)
diff --git a/src/neigh_cache.h b/src/neigh_cache.h
index 3fd56b7..4fed0fa 100644
--- a/src/neigh_cache.h
+++ b/src/neigh_cache.h
@@ -55,7 +55,8 @@
        struct osmo_cell_global_id_ps value;
 };

-struct neigh_cache *neigh_cache_alloc(void *ctx);
+struct neigh_cache *neigh_cache_alloc(void *ctx, unsigned int keep_time_sec);
+void neigh_cache_set_keep_time_interval(struct neigh_cache *cache, unsigned 
int keep_time_sec);
 struct neigh_cache_entry *neigh_cache_add(struct neigh_cache *cache,
                                          const struct neigh_cache_entry_key 
*key,
                                          const struct osmo_cell_global_id_ps 
*value);
@@ -90,7 +91,8 @@
        struct si_cache_value value;
 };

-struct si_cache *si_cache_alloc(void *ctx);
+struct si_cache *si_cache_alloc(void *ctx, unsigned int keep_time_sec);
+void si_cache_set_keep_time_interval(struct si_cache *cache, unsigned int 
keep_time_sec);
 struct si_cache_entry *si_cache_add(struct si_cache *cache,
                                    const struct osmo_cell_global_id_ps *key,
                                    const struct si_cache_value *value);
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index 8f97f30..b0d1ac6 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -1064,10 +1064,25 @@
           OSMO_TDEF_VTY_DOC_SET,
           CMD_ATTR_IMMEDIATE)
 {
+       int rc;
+       struct osmo_tdef *t;
        /* If any arguments are missing, redirect to 'show' */
        if (argc < 2)
                return show_timer(self, vty, argc, argv);
-       return osmo_tdef_vty_set_cmd(vty, the_pcu->T_defs, argv);
+       if ((rc = osmo_tdef_vty_set_cmd(vty, the_pcu->T_defs, argv)) != 
CMD_SUCCESS)
+               return rc;
+       t = osmo_tdef_vty_parse_T_arg(vty, the_pcu->T_defs, argv[0]);
+       switch (t->T) {
+       case PCU_TDEF_NEIGH_CACHE_ALIVE:
+               neigh_cache_set_keep_time_interval(the_pcu->neigh_cache, 
t->val);
+               break;
+       case PCU_TDEF_SI_CACHE_ALIVE:
+               si_cache_set_keep_time_interval(the_pcu->si_cache, t->val);
+               break;
+       default:
+               break;
+       }
+       return CMD_SUCCESS;
 }

 DEFUN(show_tbf,

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ifa336aa27dd88ff5b78dbc5a2799740f542bb369
Gerrit-Change-Number: 22449
Gerrit-PatchSet: 4
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to