Change in osmo-bsc[master]: codec_pref: also check amr codec rates in check_codec_pref()

2018-10-24 Thread dexter
dexter has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11442 )

Change subject: codec_pref: also check amr codec rates in check_codec_pref()
..

codec_pref: also check amr codec rates in check_codec_pref()

The function check_codec_pref() currently only does a basic check over
the general codec configuration of bts and msc. However, it does not yet
check if the amr codec rate settings for the BTSs contradict the
allowed/forbidden amr codec rates of the MSC. When the two settings do
contradict AMR would not work, even when everything else is correctly
configured. We need to check this on startup to spot configuration
problems quickly.

- Add function to calculate intersections of struct
  gsm48_multi_rate_conf variables.
- Calculate the intersection between the multi rate config of
  each BTS with the one of the MSC

Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Related: OS#3529
---
M include/osmocom/bsc/codec_pref.h
M src/osmo-bsc/codec_pref.c
2 files changed, 53 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/bsc/codec_pref.h b/include/osmocom/bsc/codec_pref.h
index d62d29f..51340c1 100644
--- a/include/osmocom/bsc/codec_pref.h
+++ b/include/osmocom/bsc/codec_pref.h
@@ -22,4 +22,8 @@
  const struct bsc_msc_data *msc,
  const struct gsm_bts *bts);
 
+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,
+  const struct gsm48_multi_rate_conf *b,
+  const struct gsm48_multi_rate_conf *a);
+
 int check_codec_pref(struct llist_head *mscs);
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c
index 9f30c7b..c99c383 100644
--- a/src/osmo-bsc/codec_pref.c
+++ b/src/osmo-bsc/codec_pref.c
@@ -393,6 +393,35 @@
}
 }

+/*! Calculate the intersection of the rate configuration of two multirate 
configuration
+ *  IE structures. The result c will be a copy of a, but the rate 
configuration bits
+ *  will be the intersection of the rate configuration bits in a and b.
+ *  \param[out] c user provided memory to store the result.
+ *  \param[in] a multi rate configuration a.
+ *  \param[in] b multi rate configuration b.
+ *  \returns 0 on success, -1 when the result contains an empty set of modes. 
*/
+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,
+  const struct gsm48_multi_rate_conf *b,
+  const struct gsm48_multi_rate_conf *a)
+{
+   struct gsm48_multi_rate_conf res;
+   uint8_t *_a = (uint8_t *) a;
+   uint8_t *_b = (uint8_t *) b;
+   uint8_t *_res = (uint8_t *) & res;
+
+   memcpy(, a, sizeof(res));
+
+   _res[1] = _a[1] & _b[1];
+
+   if (_res[1] == 0x00)
+   return -1;
+
+   if (c)
+   memcpy(c, , sizeof(*c));
+
+   return 0;
+}
+
 /*! Visit the codec settings for the MSC and for each BTS in order to make sure
  *  that the configuration does not contain any combinations that lead into a
  *  mutually exclusive codec configuration (empty intersection).
@@ -404,6 +433,8 @@
struct gsm_bts *bts;
struct gsm0808_speech_codec_list scl;
int rc = 0;
+   int rc_rate;
+   const struct gsm48_multi_rate_conf *bts_gsm48_ie;

llist_for_each_entry(msc, mscs, entry) {
llist_for_each_entry(bts, >network->bts_list, list) {
@@ -414,6 +445,24 @@
 bts->nr, msc->nr);
rc = -1;
}
+
+   bts_gsm48_ie = (struct gsm48_multi_rate_conf 
*)>mr_full.gsm48_ie;
+   rc_rate = calc_amr_rate_intersection(NULL, 
>amr_conf, bts_gsm48_ie);
+   if (rc_rate < 0) {
+   LOGP(DMSC, LOGL_FATAL,
+"network amr tch-f mode config of BTS %u 
does not intersect with amr-config of MSC %u\n",
+bts->nr, msc->nr);
+   rc = -1;
+   }
+
+   bts_gsm48_ie = (struct gsm48_multi_rate_conf 
*)>mr_half.gsm48_ie;
+   rc_rate = calc_amr_rate_intersection(NULL, 
>amr_conf, bts_gsm48_ie);
+   if (rc_rate < 0) {
+   LOGP(DMSC, LOGL_FATAL,
+"network amr tch-h mode config of BTS %u 
does not intersect with amr-config of MSC %u\n",
+bts->nr, msc->nr);
+   rc = -1;
+   }
}
}


--
To view, visit https://gerrit.osmocom.org/11442
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: 

Change in osmo-bsc[master]: codec_pref: also check amr codec rates in check_codec_pref()

2018-10-23 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/11442 )

Change subject: codec_pref: also check amr codec rates in check_codec_pref()
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/11442
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Gerrit-Change-Number: 11442
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Tue, 23 Oct 2018 18:24:00 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-bsc[master]: codec_pref: also check amr codec rates in check_codec_pref()

2018-10-23 Thread Harald Welte
Harald Welte has uploaded a new patch set (#2) to the change originally created 
by dexter. ( https://gerrit.osmocom.org/11442 )

Change subject: codec_pref: also check amr codec rates in check_codec_pref()
..

codec_pref: also check amr codec rates in check_codec_pref()

The function check_codec_pref() currently only does a basic check over
the general codec configuration of bts and msc. However, it does not yet
check if the amr codec rate settings for the BTSs contradict the
allowed/forbidden amr codec rates of the MSC. When the two settings do
contradict AMR would not work, even when everything else is correctly
configured. We need to check this on startup to spot configuration
problems quickly.

- Add function to calculate intersections of struct
  gsm48_multi_rate_conf variables.
- Calculate the intersection between the multi rate config of
  each BTS with the one of the MSC

Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Related: OS#3529
---
M include/osmocom/bsc/codec_pref.h
M src/osmo-bsc/codec_pref.c
2 files changed, 53 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/42/11442/2
--
To view, visit https://gerrit.osmocom.org/11442
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Gerrit-Change-Number: 11442
Gerrit-PatchSet: 2
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-bsc[master]: codec_pref: also check amr codec rates in check_codec_pref()

2018-10-23 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/11442 )

Change subject: codec_pref: also check amr codec rates in check_codec_pref()
..


Patch Set 1: Code-Review-1

(1 comment)

https://gerrit.osmocom.org/#/c/11442/1/src/osmo-bsc/codec_pref.c
File src/osmo-bsc/codec_pref.c:

https://gerrit.osmocom.org/#/c/11442/1/src/osmo-bsc/codec_pref.c@462
PS1, Line 462: tch-f
tch-h?



--
To view, visit https://gerrit.osmocom.org/11442
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Gerrit-Change-Number: 11442
Gerrit-PatchSet: 1
Gerrit-Owner: dexter 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Tue, 23 Oct 2018 16:54:07 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: Yes


Change in osmo-bsc[master]: codec_pref: also check amr codec rates in check_codec_pref()

2018-10-23 Thread dexter
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/11442


Change subject: codec_pref: also check amr codec rates in check_codec_pref()
..

codec_pref: also check amr codec rates in check_codec_pref()

The function check_codec_pref() currently only does a basic check over
the general codec configuration of bts and msc. However, it does not yet
check if the amr codec rate settings for the BTSs contradict the
allowed/forbidden amr codec rates of the MSC. When the two settings do
contradict AMR would not work, even when everything else is correctly
configured. We need to check this on startup to spot configuration
problems quickly.

- Add function to calculate intersections of struct
  gsm48_multi_rate_conf variables.
- Calculate the intersection between the multi rate config of
  each BTS with the one of the MSC

Change-Id: I3537d1c89e2520d35cc0e150ba8e6d3693e06710
Related: OS#3529
---
M include/osmocom/bsc/codec_pref.h
M src/osmo-bsc/codec_pref.c
2 files changed, 53 insertions(+), 0 deletions(-)



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

diff --git a/include/osmocom/bsc/codec_pref.h b/include/osmocom/bsc/codec_pref.h
index d62d29f..51340c1 100644
--- a/include/osmocom/bsc/codec_pref.h
+++ b/include/osmocom/bsc/codec_pref.h
@@ -22,4 +22,8 @@
  const struct bsc_msc_data *msc,
  const struct gsm_bts *bts);

+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,
+  const struct gsm48_multi_rate_conf *b,
+  const struct gsm48_multi_rate_conf *a);
+
 int check_codec_pref(struct llist_head *mscs);
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c
index 9f30c7b..b031220 100644
--- a/src/osmo-bsc/codec_pref.c
+++ b/src/osmo-bsc/codec_pref.c
@@ -393,6 +393,35 @@
}
 }

+/*! Calculate the intersection of the rate configuration of two multirate 
configuration
+ *  IE structures. The result c will be a copy of a, but the rate 
configuration bits
+ *  will be the intersection of the rate configuration bits in a and b.
+ *  \param[out] c user provided memory to store the result.
+ *  \param[in] a multi rate configuration a.
+ *  \param[in] b multi rate configuration b.
+ *  \returns 0 on success, -1 when the result contains an empty set of modes. 
*/
+int calc_amr_rate_intersection(struct gsm48_multi_rate_conf *c,
+  const struct gsm48_multi_rate_conf *b,
+  const struct gsm48_multi_rate_conf *a)
+{
+   struct gsm48_multi_rate_conf res;
+   uint8_t *_a = (uint8_t *) a;
+   uint8_t *_b = (uint8_t *) b;
+   uint8_t *_res = (uint8_t *) & res;
+
+   memcpy(, a, sizeof(res));
+
+   _res[1] = _a[1] & _b[1];
+
+   if (_res[1] == 0x00)
+   return -1;
+
+   if (c)
+   memcpy(c, , sizeof(*c));
+
+   return 0;
+}
+
 /*! Visit the codec settings for the MSC and for each BTS in order to make sure
  *  that the configuration does not contain any combinations that lead into a
  *  mutually exclusive codec configuration (empty intersection).
@@ -404,6 +433,8 @@
struct gsm_bts *bts;
struct gsm0808_speech_codec_list scl;
int rc = 0;
+   int rc_rate;
+   const struct gsm48_multi_rate_conf *bts_gsm48_ie;

llist_for_each_entry(msc, mscs, entry) {
llist_for_each_entry(bts, >network->bts_list, list) {
@@ -414,6 +445,24 @@
 bts->nr, msc->nr);
rc = -1;
}
+
+   bts_gsm48_ie = (struct gsm48_multi_rate_conf 
*)>mr_full.gsm48_ie;
+   rc_rate = calc_amr_rate_intersection(NULL, 
>amr_conf, bts_gsm48_ie);
+   if (rc_rate < 0) {
+   LOGP(DMSC, LOGL_FATAL,
+"network amr tch-f mode config of BTS %u 
does not intersect with amr-config of MSC %u\n",
+bts->nr, msc->nr);
+   rc = -1;
+   }
+
+   bts_gsm48_ie = (struct gsm48_multi_rate_conf 
*)>mr_half.gsm48_ie;
+   rc_rate = calc_amr_rate_intersection(NULL, 
>amr_conf, bts_gsm48_ie);
+   if (rc_rate < 0) {
+   LOGP(DMSC, LOGL_FATAL,
+"network amr tch-f mode config of BTS %u 
does not intersect with amr-config of MSC %u\n",
+bts->nr, msc->nr);
+   rc = -1;
+   }
}
}


-- 
To view, visit https://gerrit.osmocom.org/11442
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc