[MERGED] openbsc[master]: rename helper functions in the acc ramp code to avoid confusion

2018-04-16 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: rename helper functions in the acc ramp code to avoid confusion
..


rename helper functions in the acc ramp code to avoid confusion

The word 'enabled' was used in two contexts: Whether ACC ramp is
enabled as a feature, and whether a particular access control class
is permantly allowed/disallowed via VTY configuration.

Rename some helper functions to avoid the use of the word 'enabled'
in the latter context.

This is a port of osmo-bsc commit 0ad90b39b9e638b5e3d926c9261d26e777ca478c

Change-Id: Ic1e5a1f969823cfbfb9fe9e959db87c1717c3a83
Related: OS#2591
---
M openbsc/src/libbsc/acc_ramp.c
1 file changed, 13 insertions(+), 13 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/src/libbsc/acc_ramp.c b/openbsc/src/libbsc/acc_ramp.c
index fd2c715..03ba80b 100644
--- a/openbsc/src/libbsc/acc_ramp.c
+++ b/openbsc/src/libbsc/acc_ramp.c
@@ -32,12 +32,12 @@
  * Check if an ACC has been permanently barred for a BTS,
  * e.g. with the 'rach access-control-class' VTY command.
  */
-static bool acc_is_enabled(struct gsm_bts *bts, unsigned int acc)
+static bool acc_is_permanently_barred(struct gsm_bts *bts, unsigned int acc)
 {
OSMO_ASSERT(acc >= 0 && acc <= 9);
if (acc == 8 || acc == 9)
-   return (bts->si_common.rach_control.t2 & (1 << (acc - 8))) == 0;
-   return (bts->si_common.rach_control.t3 & (1 << (acc))) == 0;
+   return (bts->si_common.rach_control.t2 & (1 << (acc - 8)));
+   return (bts->si_common.rach_control.t3 & (1 << (acc)));
 }
 
 static void allow_one_acc(struct acc_ramp *acc_ramp, unsigned int acc)
@@ -56,20 +56,20 @@
acc_ramp->barred_accs |= (1 << acc);
 }
 
-static void barr_all_enabled_accs(struct acc_ramp *acc_ramp)
+static void barr_all_accs(struct acc_ramp *acc_ramp)
 {
unsigned int acc;
for (acc = 0; acc < 10; acc++) {
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
barr_one_acc(acc_ramp, acc);
}
 }
 
-static void allow_all_enabled_accs(struct acc_ramp *acc_ramp)
+static void allow_all_accs(struct acc_ramp *acc_ramp)
 {
unsigned int acc;
for (acc = 0; acc < 10; acc++) {
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
allow_one_acc(acc_ramp, acc);
}
 }
@@ -102,7 +102,7 @@
 
/* Shortcut in case we only do one ramping step. */
if (acc_ramp->step_size == ACC_RAMP_STEP_SIZE_MAX) {
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
gsm_bts_set_system_infos(acc_ramp->bts);
return;
}
@@ -113,14 +113,14 @@
if (idx > 0) {
/* One of ACC0-ACC7 is still bared. */
unsigned int acc = idx - 1;
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
allow_one_acc(acc_ramp, acc);
} else {
idx = ffs(acc_ramp_get_barred_t2(acc_ramp));
if (idx == 1 || idx == 2) {
/* ACC8 or ACC9 is still barred. */
unsigned int acc = idx - 1 + 8;
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, 
acc))
allow_one_acc(acc_ramp, acc);
} else {
/* All ACCs are now allowed. */
@@ -196,7 +196,7 @@
acc_ramp->step_size = ACC_RAMP_STEP_SIZE_DEFAULT;
acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN;
acc_ramp->step_interval_is_fixed = false;
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
osmo_timer_setup(_ramp->step_timer, do_acc_ramping_step, acc_ramp);
osmo_signal_register_handler(SS_NM, acc_ramp_nm_sig_cb, acc_ramp);
 }
@@ -262,7 +262,7 @@
 
if (acc_ramp_is_enabled(acc_ramp)) {
/* Set all available ACCs to barred and start ramping up. */
-   barr_all_enabled_accs(acc_ramp);
+   barr_all_accs(acc_ramp);
do_acc_ramping_step(acc_ramp);
}
 }
@@ -276,6 +276,6 @@
if (osmo_timer_pending(_ramp->step_timer))
osmo_timer_del(_ramp->step_timer);
 
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
 }
 

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

openbsc[master]: rename helper functions in the acc ramp code to avoid confusion

2018-04-16 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic1e5a1f969823cfbfb9fe9e959db87c1717c3a83
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


openbsc[master]: rename helper functions in the acc ramp code to avoid confusion

2018-04-16 Thread Pau Espin Pedrol

Patch Set 1: Code-Review+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ic1e5a1f969823cfbfb9fe9e959db87c1717c3a83
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-HasComments: No


[PATCH] openbsc[master]: rename helper functions in the acc ramp code to avoid confusion

2018-04-16 Thread Stefan Sperling

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

rename helper functions in the acc ramp code to avoid confusion

The word 'enabled' was used in two contexts: Whether ACC ramp is
enabled as a feature, and whether a particular access control class
is permantly allowed/disallowed via VTY configuration.

Rename some helper functions to avoid the use of the word 'enabled'
in the latter context.

This is a port of osmo-bsc commit 0ad90b39b9e638b5e3d926c9261d26e777ca478c

Change-Id: Ic1e5a1f969823cfbfb9fe9e959db87c1717c3a83
Related: OS#2591
---
M openbsc/src/libbsc/acc_ramp.c
1 file changed, 13 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/22/7822/1

diff --git a/openbsc/src/libbsc/acc_ramp.c b/openbsc/src/libbsc/acc_ramp.c
index fd2c715..03ba80b 100644
--- a/openbsc/src/libbsc/acc_ramp.c
+++ b/openbsc/src/libbsc/acc_ramp.c
@@ -32,12 +32,12 @@
  * Check if an ACC has been permanently barred for a BTS,
  * e.g. with the 'rach access-control-class' VTY command.
  */
-static bool acc_is_enabled(struct gsm_bts *bts, unsigned int acc)
+static bool acc_is_permanently_barred(struct gsm_bts *bts, unsigned int acc)
 {
OSMO_ASSERT(acc >= 0 && acc <= 9);
if (acc == 8 || acc == 9)
-   return (bts->si_common.rach_control.t2 & (1 << (acc - 8))) == 0;
-   return (bts->si_common.rach_control.t3 & (1 << (acc))) == 0;
+   return (bts->si_common.rach_control.t2 & (1 << (acc - 8)));
+   return (bts->si_common.rach_control.t3 & (1 << (acc)));
 }
 
 static void allow_one_acc(struct acc_ramp *acc_ramp, unsigned int acc)
@@ -56,20 +56,20 @@
acc_ramp->barred_accs |= (1 << acc);
 }
 
-static void barr_all_enabled_accs(struct acc_ramp *acc_ramp)
+static void barr_all_accs(struct acc_ramp *acc_ramp)
 {
unsigned int acc;
for (acc = 0; acc < 10; acc++) {
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
barr_one_acc(acc_ramp, acc);
}
 }
 
-static void allow_all_enabled_accs(struct acc_ramp *acc_ramp)
+static void allow_all_accs(struct acc_ramp *acc_ramp)
 {
unsigned int acc;
for (acc = 0; acc < 10; acc++) {
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
allow_one_acc(acc_ramp, acc);
}
 }
@@ -102,7 +102,7 @@
 
/* Shortcut in case we only do one ramping step. */
if (acc_ramp->step_size == ACC_RAMP_STEP_SIZE_MAX) {
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
gsm_bts_set_system_infos(acc_ramp->bts);
return;
}
@@ -113,14 +113,14 @@
if (idx > 0) {
/* One of ACC0-ACC7 is still bared. */
unsigned int acc = idx - 1;
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, acc))
allow_one_acc(acc_ramp, acc);
} else {
idx = ffs(acc_ramp_get_barred_t2(acc_ramp));
if (idx == 1 || idx == 2) {
/* ACC8 or ACC9 is still barred. */
unsigned int acc = idx - 1 + 8;
-   if (acc_is_enabled(acc_ramp->bts, acc))
+   if (!acc_is_permanently_barred(acc_ramp->bts, 
acc))
allow_one_acc(acc_ramp, acc);
} else {
/* All ACCs are now allowed. */
@@ -196,7 +196,7 @@
acc_ramp->step_size = ACC_RAMP_STEP_SIZE_DEFAULT;
acc_ramp->step_interval_sec = ACC_RAMP_STEP_INTERVAL_MIN;
acc_ramp->step_interval_is_fixed = false;
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
osmo_timer_setup(_ramp->step_timer, do_acc_ramping_step, acc_ramp);
osmo_signal_register_handler(SS_NM, acc_ramp_nm_sig_cb, acc_ramp);
 }
@@ -262,7 +262,7 @@
 
if (acc_ramp_is_enabled(acc_ramp)) {
/* Set all available ACCs to barred and start ramping up. */
-   barr_all_enabled_accs(acc_ramp);
+   barr_all_accs(acc_ramp);
do_acc_ramping_step(acc_ramp);
}
 }
@@ -276,6 +276,6 @@
if (osmo_timer_pending(_ramp->step_timer))
osmo_timer_del(_ramp->step_timer);
 
-   allow_all_enabled_accs(acc_ramp);
+   allow_all_accs(acc_ramp);
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1e5a1f969823cfbfb9fe9e959db87c1717c3a83
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling