[MERGED] osmo-pcu[master]: Revert "Rewrite Packet Uplink Assignment"

2018-03-28 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Revert "Rewrite Packet Uplink Assignment"
..


Revert "Rewrite Packet Uplink Assignment"

This reverts commit 93d947f5e8a30acc9250c124bf9d5bb6a8863526,
I44db2eeea7448ff67e688ae716487bc6dbfc96a3.

Commit I52ec9b07413daabba8cd5f1fba5c7b3af6a33389 /
896574e92bea09ed8d39688b6fdf504e84521746 was found (empirically) to be a
regression, rendering GPRS service fatally unreliable.

This reverted commit seems to follow after the regression and is reverted along
with it.

Related: OS#3013
Change-Id: If7038127e9a663c93006475b3add961adc0b1922
---
M src/encoding.cpp
1 file changed, 47 insertions(+), 47 deletions(-)

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



diff --git a/src/encoding.cpp b/src/encoding.cpp
index e96894f..279bbfe 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -230,51 +230,50 @@
return 0;
 }
 
-/* 3GPP TS 44.018 §10.5.2.16 IA Rest Octets ::= Packet Uplink Assignment */
-static inline int write_ia_rest_uplink(const gprs_rlcmac_ul_tbf *tbf, bitvec * 
dest,
-  uint8_t usf, uint32_t fn, uint8_t alpha, 
uint8_t gamma, int8_t ta_idx)
+static int write_ia_rest_uplink(
+   gprs_rlcmac_ul_tbf *tbf,
+   bitvec * dest, unsigned& wp,
+   uint8_t usf, uint32_t fn,
+   uint8_t alpha, uint8_t gamma, int8_t ta_idx)
 {
-   int rc;
+   OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled());
 
-   set_H(dest); set_H(dest);
-   set_0(dest); set_0(dest); /* 00 Packet Uplink Assignment */
-
-   if (tbf) {
-   set_1(dest); /* Multi Block Allocation */
-
-   rc = write_tfi_usf(dest, tbf, usf);
-   check(rc);
-
-   /* 3GPP TS 44.060 Table 11.2.28.2 Channel Coding Indicator */
-   rc = bitvec_set_u64(dest, tbf->current_cs().to_num() - 1, 2, 
false); /* CHANNEL_CODING_COMMAND */
-   check(rc);
-
-   rc = bitvec_set_bit(dest, (bit_value)tbf->tlli());  
 /* TLLI_BLOCK_CHANNEL_CODING */
-   check(rc);
-
-   rc = write_alpha_gamma(dest, alpha, gamma);
-   check(rc);
-
-   set_0(dest); /* No TIMING_ADVANCE_INDEX */
-   set_0(dest); /* No TBF_STARTING_TIME */
+   // GMS 04.08 10.5.2.37b 10.5.2.16
+   bitvec_write_field(dest, &wp, 3, 2);// "HH"
+   bitvec_write_field(dest, &wp, 0, 2);// "0" Packet Uplink Assignment
+   if (tbf == NULL) {
+   bitvec_write_field(dest, &wp, 0, 1);// Block Allocation : 
Single Block Allocation
+   if (alpha) {
+   bitvec_write_field(dest, &wp,0x1,1);   // ALPHA = 
present
+   bitvec_write_field(dest, &wp,alpha,4);   // ALPHA = 
present
+   } else
+   bitvec_write_field(dest, &wp,0x0,1);   // ALPHA = not 
present
+   bitvec_write_field(dest, &wp,gamma,5);   // GAMMA power control 
parameter
+   write_tai(dest, wp, ta_idx);
+   bitvec_write_field(dest, &wp, 1, 1);// 
TBF_STARTING_TIME_FLAG
+   bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1'
+   bitvec_write_field(dest, &wp,fn % 51,6);   // T3
+   bitvec_write_field(dest, &wp,fn % 26,5);   // T2
} else {
-   set_0(dest); /* Single Block Allocation */
-   rc = write_alpha_gamma(dest, alpha, gamma);
-   check(rc);
-
-   /* A 'Timing Advance index' shall not be allocated at a Single 
Block allocation.
-  A 'TBF Starting Time' shall be allocated at a Single Block 
allocation. */
-   set_0(dest);
-   set_1(dest);
-
-   rc = write_tbf_start_time(dest, fn);/* TBF_STARTING_TIME */
-   check(rc);
-
-   set_L(dest); /* No P0 nor PR_MODE */
-   set_L(dest); /* No Additions for R99 */
-   set_L(dest); /* No Additions for Rel-6 */
+   bitvec_write_field(dest, &wp, 1, 1);// Block Allocation : 
Not Single Block Allocation
+   bitvec_write_field(dest, &wp, tbf->tfi(), 5);  // 
TFI_ASSIGNMENT Temporary Flow Identity
+   bitvec_write_field(dest, &wp, 0, 1);// POLLING
+   bitvec_write_field(dest, &wp, 0, 1);// ALLOCATION_TYPE: 
dynamic
+   bitvec_write_field(dest, &wp, usf, 3);// USF
+   bitvec_write_field(dest, &wp, 0, 1);// USF_GRANULARITY
+   bitvec_write_field(dest, &wp, 0, 1);   // "0" power control: 
Not Present
+   bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 2); 
   // CHANNEL_CODING_COMMAND
+   bitvec_write_field(dest, &wp, 1, 1);// 
TLLI_BLOCK_CHANNEL_CODING
+   if (alpha) {
+  

osmo-pcu[master]: Revert "Rewrite Packet Uplink Assignment"

2018-03-28 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: If7038127e9a663c93006475b3add961adc0b1922
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


osmo-pcu[master]: Revert "Rewrite Packet Uplink Assignment"

2018-02-27 Thread Neels Hofmeyr

Patch Set 1: Verified+1

verified on sysmoBTS that GPRS works better after the revert of these four 
patches

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

Gerrit-MessageType: comment
Gerrit-Change-Id: If7038127e9a663c93006475b3add961adc0b1922
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: Revert "Rewrite Packet Uplink Assignment"

2018-02-27 Thread Neels Hofmeyr

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

Revert "Rewrite Packet Uplink Assignment"

This reverts commit 93d947f5e8a30acc9250c124bf9d5bb6a8863526,
I44db2eeea7448ff67e688ae716487bc6dbfc96a3.

Commit I52ec9b07413daabba8cd5f1fba5c7b3af6a33389 /
896574e92bea09ed8d39688b6fdf504e84521746 was found (empirically) to be a
regression, rendering GPRS service fatally unreliable.

This reverted commit seems to follow after the regression and is reverted along
with it.

Related: OS#3013
Change-Id: If7038127e9a663c93006475b3add961adc0b1922
---
M src/encoding.cpp
1 file changed, 47 insertions(+), 47 deletions(-)


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

diff --git a/src/encoding.cpp b/src/encoding.cpp
index e96894f..279bbfe 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -230,51 +230,50 @@
return 0;
 }
 
-/* 3GPP TS 44.018 §10.5.2.16 IA Rest Octets ::= Packet Uplink Assignment */
-static inline int write_ia_rest_uplink(const gprs_rlcmac_ul_tbf *tbf, bitvec * 
dest,
-  uint8_t usf, uint32_t fn, uint8_t alpha, 
uint8_t gamma, int8_t ta_idx)
+static int write_ia_rest_uplink(
+   gprs_rlcmac_ul_tbf *tbf,
+   bitvec * dest, unsigned& wp,
+   uint8_t usf, uint32_t fn,
+   uint8_t alpha, uint8_t gamma, int8_t ta_idx)
 {
-   int rc;
+   OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled());
 
-   set_H(dest); set_H(dest);
-   set_0(dest); set_0(dest); /* 00 Packet Uplink Assignment */
-
-   if (tbf) {
-   set_1(dest); /* Multi Block Allocation */
-
-   rc = write_tfi_usf(dest, tbf, usf);
-   check(rc);
-
-   /* 3GPP TS 44.060 Table 11.2.28.2 Channel Coding Indicator */
-   rc = bitvec_set_u64(dest, tbf->current_cs().to_num() - 1, 2, 
false); /* CHANNEL_CODING_COMMAND */
-   check(rc);
-
-   rc = bitvec_set_bit(dest, (bit_value)tbf->tlli());  
 /* TLLI_BLOCK_CHANNEL_CODING */
-   check(rc);
-
-   rc = write_alpha_gamma(dest, alpha, gamma);
-   check(rc);
-
-   set_0(dest); /* No TIMING_ADVANCE_INDEX */
-   set_0(dest); /* No TBF_STARTING_TIME */
+   // GMS 04.08 10.5.2.37b 10.5.2.16
+   bitvec_write_field(dest, &wp, 3, 2);// "HH"
+   bitvec_write_field(dest, &wp, 0, 2);// "0" Packet Uplink Assignment
+   if (tbf == NULL) {
+   bitvec_write_field(dest, &wp, 0, 1);// Block Allocation : 
Single Block Allocation
+   if (alpha) {
+   bitvec_write_field(dest, &wp,0x1,1);   // ALPHA = 
present
+   bitvec_write_field(dest, &wp,alpha,4);   // ALPHA = 
present
+   } else
+   bitvec_write_field(dest, &wp,0x0,1);   // ALPHA = not 
present
+   bitvec_write_field(dest, &wp,gamma,5);   // GAMMA power control 
parameter
+   write_tai(dest, wp, ta_idx);
+   bitvec_write_field(dest, &wp, 1, 1);// 
TBF_STARTING_TIME_FLAG
+   bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1'
+   bitvec_write_field(dest, &wp,fn % 51,6);   // T3
+   bitvec_write_field(dest, &wp,fn % 26,5);   // T2
} else {
-   set_0(dest); /* Single Block Allocation */
-   rc = write_alpha_gamma(dest, alpha, gamma);
-   check(rc);
-
-   /* A 'Timing Advance index' shall not be allocated at a Single 
Block allocation.
-  A 'TBF Starting Time' shall be allocated at a Single Block 
allocation. */
-   set_0(dest);
-   set_1(dest);
-
-   rc = write_tbf_start_time(dest, fn);/* TBF_STARTING_TIME */
-   check(rc);
-
-   set_L(dest); /* No P0 nor PR_MODE */
-   set_L(dest); /* No Additions for R99 */
-   set_L(dest); /* No Additions for Rel-6 */
+   bitvec_write_field(dest, &wp, 1, 1);// Block Allocation : 
Not Single Block Allocation
+   bitvec_write_field(dest, &wp, tbf->tfi(), 5);  // 
TFI_ASSIGNMENT Temporary Flow Identity
+   bitvec_write_field(dest, &wp, 0, 1);// POLLING
+   bitvec_write_field(dest, &wp, 0, 1);// ALLOCATION_TYPE: 
dynamic
+   bitvec_write_field(dest, &wp, usf, 3);// USF
+   bitvec_write_field(dest, &wp, 0, 1);// USF_GRANULARITY
+   bitvec_write_field(dest, &wp, 0, 1);   // "0" power control: 
Not Present
+   bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 2); 
   // CHANNEL_CODING_COMMAND
+   bitvec_write_field(dest, &wp, 1, 1);// 
TLLI_BLOCK_CHANNEL_CODING
+   if (alpha) {
+   bitvec_write_field(dest, &wp,0x1,1);   // ALPHA = 
present
+   bitvec_write_field(dest, &wp,alpha,4);   // ALPHA
+   } else
+