Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-11-06 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..

Take into account BTS supported (M)CS values when retrieving the maximum

Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
---
M src/bts.cpp
M src/bts.h
M src/gprs_bssgp_pcu.cpp
M src/gprs_ms.cpp
M src/pcu_l1_if.cpp
M src/pcu_vty.c
6 files changed, 168 insertions(+), 55 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/bts.cpp b/src/bts.cpp
index 359f2d5..c2e3b9c 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -219,10 +219,10 @@
bts->cs_adj_enabled = 1;
bts->cs_adj_upper_limit = 33; /* Decrease CS if the error rate is above 
*/
bts->cs_adj_lower_limit = 10; /* Increase CS if the error rate is below 
*/
-   bts->max_cs_ul = MAX_GPRS_CS;
-   bts->max_cs_dl = MAX_GPRS_CS;
-   bts->max_mcs_ul = MAX_EDGE_MCS;
-   bts->max_mcs_dl = MAX_EDGE_MCS;
+   bts->vty.max_cs_ul = MAX_GPRS_CS;
+   bts->vty.max_cs_dl = MAX_GPRS_CS;
+   bts->vty.max_mcs_ul = MAX_EDGE_MCS;
+   bts->vty.max_mcs_dl = MAX_EDGE_MCS;
/* CS-1 to CS-4 */
bts->cs_lqual_ranges[0].low = -256;
bts->cs_lqual_ranges[0].high = 6;
@@ -320,6 +320,10 @@
 BTS::BTS()
: m_cur_fn(0)
, m_cur_blk_fn(-1)
+   , m_max_cs_dl(MAX_GPRS_CS)
+   , m_max_cs_ul(MAX_GPRS_CS)
+   , m_max_mcs_dl(MAX_EDGE_MCS)
+   , m_max_mcs_ul(MAX_EDGE_MCS)
, m_pollController(*this)
, m_sba(*this)
, m_ms_store(this)
@@ -1072,6 +1076,53 @@
bitvec_free(immediate_assignment);
 }

+/* return maximum DL CS supported by BTS and allowed by VTY */
+uint8_t BTS::max_cs_dl(void) const
+{
+   return m_max_cs_dl;
+}
+
+/* return maximum UL CS supported by BTS and allowed by VTY */
+uint8_t BTS::max_cs_ul(void) const
+{
+   return m_max_cs_ul;
+}
+
+/* return maximum DL MCS supported by BTS and allowed by VTY */
+uint8_t BTS::max_mcs_dl(void) const
+{
+   return m_max_mcs_dl;
+}
+
+/* return maximum UL MCS supported by BTS and allowed by VTY */
+uint8_t BTS::max_mcs_ul(void) const
+{
+   return m_max_mcs_ul;
+}
+
+/* Set maximum DL CS supported by BTS and allowed by VTY */
+void BTS::set_max_cs_dl(uint8_t cs_dl)
+{
+   m_max_cs_dl = cs_dl;
+}
+
+/* Set maximum UL CS supported by BTS and allowed by VTY */
+void BTS::set_max_cs_ul(uint8_t cs_ul)
+{
+   m_max_cs_ul = cs_ul;
+}
+
+/* Set maximum DL MCS supported by BTS and allowed by VTY */
+void BTS::set_max_mcs_dl(uint8_t mcs_dl)
+{
+   m_max_mcs_dl = mcs_dl;
+}
+
+/* Set maximum UL MCS supported by BTS and allowed by VTY */
+void BTS::set_max_mcs_ul(uint8_t mcs_ul)
+{
+   m_max_mcs_ul = mcs_ul;
+}

 GprsMs *BTS::ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class)
 {
@@ -1161,3 +1212,57 @@
if (slots & (1 << i))
pdch[i].unreserve(dir);
 }
+
+void bts_set_max_cs(struct gprs_rlcmac_bts *bts, uint8_t cs_dl, uint8_t cs_ul)
+{
+   int i;
+
+   bts->vty.max_cs_dl = cs_dl;
+   cs_dl = 0;
+   for (i = bts->vty.max_cs_dl - 1; i >= 0; i--) {
+   if (bts->cs_mask & (1 << i)) {
+   cs_dl = i + 1;
+   break;
+   }
+   }
+
+   bts->vty.max_cs_ul = cs_ul;
+   cs_ul = 0;
+   for (i = bts->vty.max_cs_ul - 1; i >= 0; i--) {
+   if (bts->cs_mask & (1 << i)) {
+   cs_ul = i + 1;
+   break;
+   }
+   }
+
+   LOGP(DRLCMAC, LOGL_DEBUG, "New max CS: DL=%u UL=%u\n", cs_dl, cs_ul);
+   bts->bts->set_max_cs_dl(cs_dl);
+   bts->bts->set_max_cs_ul(cs_ul);
+}
+
+void bts_set_max_mcs(struct gprs_rlcmac_bts *bts, uint8_t mcs_dl, uint8_t 
mcs_ul)
+{
+   int i;
+
+   bts->vty.max_mcs_dl = mcs_dl;
+   mcs_dl = 0;
+   for (i = bts->vty.max_mcs_dl - 1; i >= 0; i--) {
+   if (bts->mcs_mask & (1 << i)) {
+   mcs_dl = i + 1;
+   break;
+   }
+   }
+
+   bts->vty.max_mcs_ul = mcs_ul;
+   mcs_ul = 0;
+   for (i = bts->vty.max_mcs_ul - 1; i >= 0; i--) {
+   if (bts->mcs_mask & (1 << i)) {
+   mcs_ul = i + 1;
+   break;
+   }
+   }
+
+   LOGP(DRLCMAC, LOGL_DEBUG, "New max MCS: DL=%u UL=%u\n", mcs_dl, mcs_ul);
+   bts->bts->set_max_mcs_dl(mcs_dl);
+   bts->bts->set_max_mcs_ul(mcs_ul);
+}
diff --git a/src/bts.h b/src/bts.h
index 7335483..8d7f6ca 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -114,8 +114,10 @@
uint16_t mcs_mask;  /* Allowed MCS mask from BTS */
uint8_t initial_cs_dl, initial_cs_ul;
uint8_t initial_mcs_dl, initial_mcs_ul;
-   uint8_t max_cs_dl, max_cs_ul;
-   uint8_t max_mcs_dl, max_mcs_ul;
+   st

Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-11-06 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..


Patch Set 3: Code-Review+2


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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
Gerrit-Change-Number: 20992
Gerrit-PatchSet: 3
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Fri, 06 Nov 2020 10:31:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-11-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..


Patch Set 2: Code-Review+1


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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
Gerrit-Change-Number: 20992
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Mon, 02 Nov 2020 17:25:36 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-11-02 Thread pespin
Hello Jenkins Builder, fixeria,

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

https://gerrit.osmocom.org/c/osmo-pcu/+/20992

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

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..

Take into account BTS supported (M)CS values when retrieving the maximum

Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
---
M src/bts.cpp
M src/bts.h
M src/gprs_bssgp_pcu.cpp
M src/gprs_ms.cpp
M src/pcu_l1_if.cpp
M src/pcu_vty.c
6 files changed, 168 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/92/20992/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/20992
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
Gerrit-Change-Number: 20992
Gerrit-PatchSet: 2
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-CC: laforge 
Gerrit-MessageType: newpatchset


Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-11-02 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..


Patch Set 1:

it looks to me like we're recomputing this over and over again, rather than 
storing the pre-computed value on every change (VTY or PCUIF are they onkly two 
sources of change here, right?).


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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
Gerrit-Change-Number: 20992
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-CC: laforge 
Gerrit-Comment-Date: Mon, 02 Nov 2020 09:16:52 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-10-31 Thread fixeria
fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )

Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..


Patch Set 1: Code-Review+1


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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
Gerrit-Change-Number: 20992
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria 
Gerrit-Comment-Date: Sat, 31 Oct 2020 12:48:28 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-pcu[master]: Take into account BTS supported (M)CS values when retrieving the maximum

2020-10-30 Thread pespin
pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/20992 )


Change subject: Take into account BTS supported (M)CS values when retrieving 
the maximum
..

Take into account BTS supported (M)CS values when retrieving the maximum

Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
---
M src/bts.cpp
M src/bts.h
M src/gprs_bssgp_pcu.cpp
M src/gprs_ms.cpp
4 files changed, 78 insertions(+), 25 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/92/20992/1

diff --git a/src/bts.cpp b/src/bts.cpp
index be957fa..79bb9e6 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1005,6 +1005,61 @@
bitvec_free(immediate_assignment);
 }

+/* return maximum DL CS supported by BTS and allowed by VTY */
+uint8_t BTS::max_cs_dl(void) const
+{
+   int i;
+   if (!m_bts.max_cs_dl)
+   return 0;
+   for (i = m_bts.max_cs_dl - 1; i >= 0; i--) {
+   if (m_bts.cs_supported[i]) {
+   return i + 1;
+   }
+   }
+   return 0;
+}
+
+/* return maximum UL CS supported by BTS and allowed by VTY */
+uint8_t BTS::max_cs_ul(void) const
+{
+   int i;
+   if (!m_bts.max_cs_ul)
+   return 0;
+   for (i = m_bts.max_cs_ul - 1; i >= 0; i--) {
+   if (m_bts.cs_supported[i]) {
+   return i + 1;
+   }
+   }
+   return 0;
+}
+
+/* return maximum DL MCS supported by BTS and allowed by VTY */
+uint8_t BTS::max_mcs_dl(void) const
+{
+   int i;
+   if (!m_bts.max_mcs_dl)
+   return 0;
+   for (i = m_bts.max_mcs_dl - 1; i >= 0; i--) {
+   if (m_bts.mcs_supported[i]) {
+   return i + 1;
+   }
+   }
+   return 0;
+}
+
+/* return maximum UL MCS supported by BTS and allowed by VTY */
+uint8_t BTS::max_mcs_ul(void) const
+{
+   int i;
+   if (!m_bts.max_mcs_ul)
+   return 0;
+   for (i = m_bts.max_mcs_ul - 1; i >= 0; i--) {
+   if (m_bts.mcs_supported[i]) {
+   return i + 1;
+   }
+   }
+   return 0;
+}

 GprsMs *BTS::ms_alloc(uint8_t ms_class, uint8_t egprs_ms_class)
 {
diff --git a/src/bts.h b/src/bts.h
index 9bf80e1..edb5d6e 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -329,6 +329,11 @@

void snd_dl_ass(gprs_rlcmac_tbf *tbf, bool poll, uint16_t pgroup);

+   uint8_t max_cs_dl(void) const;
+   uint8_t max_cs_ul(void) const;
+   uint8_t max_mcs_dl(void) const;
+   uint8_t max_mcs_ul(void) const;
+
GprsMsStorage &ms_store();
GprsMs *ms_by_tlli(uint32_t tlli, uint32_t old_tlli = 0);
GprsMs *ms_by_imsi(const char *imsi);
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index d36d96d..a788ac0 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -750,8 +750,8 @@
}
}
}
-   } else if (bts->max_mcs_dl) {
-   num = bts->max_mcs_dl;
+   } else if (bts->bts->max_mcs_dl()) {
+   num = bts->bts->max_mcs_dl();
} else {
num = 9;
}
@@ -770,8 +770,8 @@
}
}
}
-   } else if (bts->max_cs_dl) {
-   num = bts->max_cs_dl;
+   } else if (bts->bts->max_cs_dl()) {
+   num = bts->bts->max_cs_dl();
} else {
num = 4;
}
diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp
index efd1845..b295686 100644
--- a/src/gprs_ms.cpp
+++ b/src/gprs_ms.cpp
@@ -541,9 +541,8 @@

m_egprs_ms_class = ms_class_;

-   struct gprs_rlcmac_bts *bts = m_bts->bts_data();
-   if (mcs_is_edge_gmsk(mcs_get_egprs_by_num(bts->max_mcs_ul)) &&
-   mcs_is_edge_gmsk(mcs_get_egprs_by_num(bts->max_mcs_dl)) &&
+   if (mcs_is_edge_gmsk(mcs_get_egprs_by_num(m_bts->max_mcs_ul())) &&
+   mcs_is_edge_gmsk(mcs_get_egprs_by_num(m_bts->max_mcs_dl())) &&
mode() != EGPRS)
{
set_mode(EGPRS_GMSK);
@@ -609,26 +608,23 @@

 enum CodingScheme GprsMs::max_cs_ul() const
 {
-   struct gprs_rlcmac_bts *bts_data;
-
OSMO_ASSERT(m_bts != NULL);
-   bts_data = m_bts->bts_data();

if (mcs_is_gprs(m_current_cs_ul)) {
-   if (!bts_data->max_cs_ul) {
+   if (!m_bts->max_cs_ul()) {
return CS4;
}

-   return mcs_get_gprs_by_num(bts_data->max_cs_ul);
+   return mcs_get_gprs_by_num(m_bts->max_cs_ul());
}

if (!mcs_is_edge(m_current_cs_ul))
return UNKNOWN;

-   if (bts_data->max_mcs_ul)
-   return mcs_get_egprs_by_num(bts_data->max_mcs_ul);
-   else if (bts_data->max_cs_ul)
-