Change in libosmocore[master]: Set DTX in Cell Options
diff mbox

Message ID gerrit.1462893474235.I5a8924f57669c951b2e51b663d95f1d360062a54@gerrit.osmocom.org
State New
Headers show

Commit Message

gerrit-no-reply@lists.osmocom.org May 10, 2016, 3:17 p.m. UTC
From Max <msuraev@sysmocom.de>:

Max has uploaded a new change for review.

  https://gerrit.osmocom.org/39

Change subject: Set DTX in Cell Options
......................................................................

Set DTX in Cell Options

* rename field of struct gsm48_cell_options to better match the spec
* add comments with spec references
* add function for setting DTX in cell options struct
* add necessary enum type

Change-Id: I5a8924f57669c951b2e51b663d95f1d360062a54
---
M include/osmocom/gsm/protocol/gsm_04_08.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 61 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/39/1

Comments

gerrit-no-reply@lists.osmocom.org May 10, 2016, 7:03 p.m. UTC | #1
From Harald Welte <laforge@gnumonks.org>:

Harald Welte has posted comments on this change.

Change subject: Set DTX in Cell Options
......................................................................


Patch Set 1: Code-Review-1

(1 comment)

aside from the naming (see comment) it looks fine to me

https://gerrit.osmocom.org/#/c/39/1/include/osmocom/gsm/protocol/gsm_04_08.h
File include/osmocom/gsm/protocol/gsm_04_08.h:

Line 474: 	GSM48_MAY_USE,
Naming.  GSM48_MAY_USE is very generic, as 04.08 covers all of GSM L3.  So unless we intend to use the same enum for other topics, too (which we don't, as it is called gsm48_dtx_mode), it should be called GSM48_{MAY,SHALL,SHALL_NOT}_USE_DTX or GSM48_DTX_{MAY,SHALL,SHALL_NOT}_BE_USED
gerrit-no-reply@lists.osmocom.org May 11, 2016, 8:23 a.m. UTC | #2
From Max <msuraev@sysmocom.de>:

Hello Harald Welte, Jenkins Builder,

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

    https://gerrit.osmocom.org/39

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

Change subject: Set DTX in Cell Options
......................................................................

Set DTX in Cell Options

* rename field of struct gsm48_cell_options to better match the spec
* add comments with spec references
* add function for setting DTX in cell options struct
* add necessary enum type

Change-Id: I5a8924f57669c951b2e51b663d95f1d360062a54
---
M include/osmocom/gsm/protocol/gsm_04_08.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 61 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/39/2
gerrit-no-reply@lists.osmocom.org May 11, 2016, 8:45 a.m. UTC | #3
From Max <msuraev@sysmocom.de>:

Max has posted comments on this change.

Change subject: Set DTX in Cell Options
......................................................................


Patch Set 2:

Build failure in unrelated test bssgp-fc - weird. How can I download testsuite.log from jenkins?
gerrit-no-reply@lists.osmocom.org May 11, 2016, 10:12 a.m. UTC | #4
From Harald Welte <laforge@gnumonks.org>:

Harald Welte has posted comments on this change.

Change subject: Set DTX in Cell Options
......................................................................


Patch Set 2: Code-Review+2
Neels Hofmeyr May 12, 2016, 10:31 a.m. UTC | #5
On Tue, May 10, 2016 at 07:03:34PM +0000, gerrit-no-reply@lists.osmocom.org wrote:
> https://gerrit.osmocom.org/#/c/39/1/include/osmocom/gsm/protocol/gsm_04_08.h

> GSM48_{MAY,SHALL,SHALL_NOT}_USE_DTX or GSM48_DTX_{MAY,SHALL,SHALL_NOT}_BE_USED

I like the latter, with _DTX_ up first.

~Neels
Max May 12, 2016, 10:38 a.m. UTC | #6
Already applied in 2nd version of patch. Thanks!

On 05/12/2016 12:31 PM, Neels Hofmeyr wrote:
> On Tue, May 10, 2016 at 07:03:34PM +0000, gerrit-no-reply@lists.osmocom.org wrote:
>> https://gerrit.osmocom.org/#/c/39/1/include/osmocom/gsm/protocol/gsm_04_08.h
>> GSM48_{MAY,SHALL,SHALL_NOT}_USE_DTX or GSM48_DTX_{MAY,SHALL,SHALL_NOT}_BE_USED
> I like the latter, with _DTX_ up first.
>
> ~Neels
>

Patch
diff mbox

diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h
index 3282bc1..5ee387b 100644
--- a/include/osmocom/gsm/protocol/gsm_04_08.h
+++ b/include/osmocom/gsm/protocol/gsm_04_08.h
@@ -1,6 +1,7 @@ 
 #pragma once
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #include <osmocom/core/utils.h>
 
@@ -469,11 +470,20 @@ 
 	uint8_t t3212;
 } __attribute__ ((packed));
 
+enum gsm48_dtx_mode {
+	GSM48_MAY_USE,
+	GSM48_SHALL_USE,
+	GSM48_SHALL_NOT
+};
+
+/* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1),
+   3GPP TS 44.018 */
 struct gsm48_cell_options {
 	uint8_t radio_link_timeout:4,
 		 dtx:2,
 		 pwrc:1,
-		 spare:1;
+	/* either DN-IND or top bit of DTX IND */
+		 d:1;
 } __attribute__ ((packed));
 
 /* Section 9.2.9 CM service request */
@@ -827,6 +837,9 @@ 
 	}
 }
 
+void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
+		   enum gsm48_dtx_mode half, bool is_bcch);
+
 #define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99
 
 /* Section 10.4 */
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index ab62605..2a30b3c 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -25,7 +25,7 @@ 
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
-
+#include <stdbool.h>
 #include <arpa/inet.h>
 
 #include <osmocom/core/utils.h>
@@ -358,6 +358,50 @@ 
 	return 0;
 }
 
+/*! \brief Set DTX mode in Cell Options IE (3GPP TS 44.018)
+ *  \param[in] op Cell Options structure in which DTX parameters will be set
+ *  \param[in] full Mode for full-rate channels
+ *  \param[in] half Mode for half-rate channels
+ *  \param[in] is_bcch Indicates if we should use 10.5.2.3.1 instead of
+ *             10.5.2.3a.2
+ *
+ * There is no space for separate DTX settings for Full and Half rate channels
+ * in BCCH - in this case full setting is used for both and half parameter is
+ * ignored.
+ */
+void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
+		   enum gsm48_dtx_mode half, bool is_bcch)
+{
+	if (is_bcch) {
+		switch (full) {
+		case GSM48_MAY_USE:
+			op->dtx = 0;
+			return;
+		case GSM48_SHALL_USE:
+			op->dtx = 1;
+			return;
+		case GSM48_SHALL_NOT:
+			op->dtx = 2;
+			return;
+		}
+	} else {
+		switch (full) {
+		case GSM48_MAY_USE:
+			op->dtx = (half == GSM48_SHALL_USE) ? 3 : 0;
+			op->d =   (half == GSM48_SHALL_NOT) ? 0 : 1;
+			return;
+		case GSM48_SHALL_USE:
+			op->dtx = (half == GSM48_MAY_USE) ? 3 : 1;
+			op->d =   (half == GSM48_SHALL_USE) ? 1 : 0;
+			return;
+		case GSM48_SHALL_NOT:
+			op->dtx = 2;
+			op->d =   (half == GSM48_SHALL_USE) ? 1 : 0;
+			return;
+		}
+	}
+}
+
 int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi)
 {
 	uint32_t tmsi_be = htonl(tmsi);
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index e0d9dcb..834e5d6 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -162,6 +162,8 @@ 
 gsm48_number_of_paging_subchannels;
 gsm48_parse_ra;
 gsm48_rr_att_tlvdef;
+gsm48_set_dtx;
+gsm48_dtx_mode;
 gsm48_mi_type_name;
 gsm48_mcc_mnc_to_bcd;
 gsm48_mcc_mnc_from_bcd;