<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12960">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Rewrite EGPRS Packet Uplink IA Rest Octets for SBA<br><br>Use bitvec_set_*() directly without external write pointer tracking to<br>simplify the code. This is part of IA Rest Octets (3GPP TS 44.018<br>§10.5.2.16) which is the last part of the message so it should not<br>interfere with the rest of encoding functions.<br><br>That's partially based on reverted commit 529ce885450946d85d1920fb3d1a994c3efe5849.<br><br>Change-Id: I143b3dd02aa54b9ce206d9e780a5554f6d9fd118<br>Related: OS#3014<br>---<br>M src/encoding.cpp<br>1 file changed, 58 insertions(+), 26 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/60/12960/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/encoding.cpp b/src/encoding.cpp</span><br><span>index ba0e474..3d88e47 100644</span><br><span>--- a/src/encoding.cpp</span><br><span>+++ b/src/encoding.cpp</span><br><span>@@ -85,6 +85,33 @@</span><br><span>    return rc;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* 3GPP TS 44.018 §10.5.2.16:</span><br><span style="color: hsl(120, 100%, 40%);">+   < TFI_ASSIGNMENT : bit (5) ></span><br><span style="color: hsl(120, 100%, 40%);">+   < POLLING : bit ></span><br><span style="color: hsl(120, 100%, 40%);">+   0 -- The value '1' was allocated in an earlier version of the protocol and shall not be used.</span><br><span style="color: hsl(120, 100%, 40%);">+   < USF: bit (3) ></span><br><span style="color: hsl(120, 100%, 40%);">+   < USF_GRANULARITY : bit ></span><br><span style="color: hsl(120, 100%, 40%);">+   { 0 | 1 < P0 : bit (4) > < PR_MODE : bit (1) > }</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+static int write_tfi_usf(bitvec *dest, const gprs_rlcmac_ul_tbf *tbf, uint8_t usf)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       int rc = bitvec_set_u64(dest, tbf->tfi(), 5, false); /* TFI_ASSIGNMENT */</span><br><span style="color: hsl(120, 100%, 40%);">+       CHECK(rc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       SET_0(dest); /* POLLING -- no action is required from MS */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       SET_0(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       rc = bitvec_set_u64(dest, usf, 3, false); /* USF */</span><br><span style="color: hsl(120, 100%, 40%);">+       CHECK(rc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       SET_0(dest); /* USF_GRANULARITY -- the mobile station shall transmit one RLC/MAC block */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       SET_0(dest); /* No P0 nor PR_MODE */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* { 0 | 1 < TIMING_ADVANCE_INDEX : bit (4) > } */</span><br><span> static int write_ta_index(bitvec *dest, int8_t tai)</span><br><span> {</span><br><span>@@ -278,38 +305,42 @@</span><br><span> }</span><br><span> </span><br><span> static int write_ia_rest_egprs_uplink_sba(const gprs_rlcmac_ul_tbf *tbf, bitvec * dest, uint8_t usf,</span><br><span style="color: hsl(0, 100%, 40%);">-                                    uint8_t alpha, uint8_t gamma, unsigned& wp)</span><br><span style="color: hsl(120, 100%, 40%);">+                                       uint8_t alpha, uint8_t gamma)</span><br><span> {</span><br><span>         int rc = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- bitvec_write_field(dest, &wp, 1, 1);     /* single block allocation */</span><br><span style="color: hsl(0, 100%, 40%);">-      bitvec_write_field(dest, &wp, tbf->tfi(), 5); /* TFI assignment */</span><br><span style="color: hsl(0, 100%, 40%);">-       bitvec_write_field(dest, &wp, 0, 1);     /* polling bit */</span><br><span style="color: hsl(0, 100%, 40%);">-  bitvec_write_field(dest, &wp, 0, 1);     /* constant */</span><br><span style="color: hsl(0, 100%, 40%);">-     bitvec_write_field(dest, &wp, usf, 3);   /* USF bit */</span><br><span style="color: hsl(0, 100%, 40%);">-      bitvec_write_field(dest, &wp, 0, 1);     /* USF granularity */</span><br><span style="color: hsl(0, 100%, 40%);">-      bitvec_write_field(dest, &wp, 0, 1);     /* P0 */</span><br><span style="color: hsl(120, 100%, 40%);">+ SET_1(dest); /* Single Block Allocation */</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  /* MCS */</span><br><span style="color: hsl(0, 100%, 40%);">-       bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 4);</span><br><span style="color: hsl(120, 100%, 40%);">+      rc = write_tfi_usf(dest, tbf, usf);</span><br><span style="color: hsl(120, 100%, 40%);">+   CHECK(rc);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  /* TLLI channel block */</span><br><span style="color: hsl(0, 100%, 40%);">-        bitvec_write_field(dest, &wp, tbf->tlli(), 1);</span><br><span style="color: hsl(0, 100%, 40%);">-   bitvec_write_field(dest, &wp, 0, 1);   /* BEP period present */</span><br><span style="color: hsl(0, 100%, 40%);">-     bitvec_write_field(dest, &wp, 0, 1);   /* resegmentation */</span><br><span style="color: hsl(0, 100%, 40%);">- write_ws(dest, &wp, tbf->window_size()); /* EGPRS window size */</span><br><span style="color: hsl(120, 100%, 40%);">+       /* 3GPP TS 44.060 §12.10d EGPRS Modulation and coding Scheme description: */</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = bitvec_set_u64(dest, tbf->current_cs().to_num() - 1, 4, false); /* EGPRS CHANNEL_CODING_COMMAND */</span><br><span style="color: hsl(120, 100%, 40%);">+    CHECK(rc);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  if (alpha) {</span><br><span style="color: hsl(0, 100%, 40%);">-            bitvec_write_field(dest, &wp, 0x1, 1);   /* ALPHA = yes */</span><br><span style="color: hsl(0, 100%, 40%);">-          bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */</span><br><span style="color: hsl(0, 100%, 40%);">-        } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                bitvec_write_field(dest, &wp, 0x0, 1);   /* ALPHA = no */</span><br><span style="color: hsl(0, 100%, 40%);">-   }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* TLLI_BLOCK_CHANNEL_CODING */</span><br><span style="color: hsl(120, 100%, 40%);">+       rc = bitvec_set_bit(dest, (bit_value)tbf->tlli());</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-       bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */</span><br><span style="color: hsl(0, 100%, 40%);">-   bitvec_write_field(dest, &wp, 0, 1); /* TIMING_ADVANCE_INDEX */</span><br><span style="color: hsl(0, 100%, 40%);">-     bitvec_write_field(dest, &wp, 0, 1); /* TBF_STARTING_TIME_FLAG */</span><br><span style="color: hsl(0, 100%, 40%);">-   bitvec_write_field(dest, &wp, 0, 1); /* NULL */</span><br><span style="color: hsl(120, 100%, 40%);">+   /* No BEP_PERIOD2 */</span><br><span style="color: hsl(120, 100%, 40%);">+  SET_0(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Retransmitted RLC data blocks shall not be re-segmented: (see 3GPP TS 44.060 §12.10e) */</span><br><span style="color: hsl(120, 100%, 40%);">+  SET_0(dest); /* RESEGMENT */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        rc = bitvec_set_u64(dest, enc_ws(tbf->window_size()), 5, false); /* EGPRS Window Size */</span><br><span style="color: hsl(120, 100%, 40%);">+   CHECK(rc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  rc = write_alpha_gamma(dest, alpha, gamma);</span><br><span style="color: hsl(120, 100%, 40%);">+   CHECK(rc);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  /* No TIMING_ADVANCE_INDEX */</span><br><span style="color: hsl(120, 100%, 40%);">+ SET_0(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* No TBF_STARTING_TIME */</span><br><span style="color: hsl(120, 100%, 40%);">+    SET_0(dest);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* No Additions for Rel-7 */</span><br><span style="color: hsl(120, 100%, 40%);">+  SET_L(dest);</span><br><span> </span><br><span>     return rc;</span><br><span> }</span><br><span>@@ -476,7 +507,8 @@</span><br><span>                bitvec_write_field(dest, &wp, 0, 1);    /* Access technology Request */</span><br><span> </span><br><span>              if (as_ul_tbf(tbf) != NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   rc = write_ia_rest_egprs_uplink_sba(as_ul_tbf(tbf), dest, usf, alpha, gamma, wp);</span><br><span style="color: hsl(120, 100%, 40%);">+                     dest->cur_bit = wp;</span><br><span style="color: hsl(120, 100%, 40%);">+                        rc = write_ia_rest_egprs_uplink_sba(as_ul_tbf(tbf), dest, usf, alpha, gamma);</span><br><span>                } else {</span><br><span>                     dest->cur_bit = wp;</span><br><span>                       rc = write_ia_rest_egprs_uplink_mba(dest, fn, alpha, gamma);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12960">change 12960</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12960"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I143b3dd02aa54b9ce206d9e780a5554f6d9fd118 </div>
<div style="display:none"> Gerrit-Change-Number: 12960 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>