diff options
-rw-r--r-- | src/encoding.cpp | 4 | ||||
-rw-r--r-- | src/gprs_ms.cpp | 12 | ||||
-rw-r--r-- | src/gprs_ms.h | 17 | ||||
-rw-r--r-- | src/tbf.cpp | 14 | ||||
-rw-r--r-- | src/tbf.h | 3 | ||||
-rw-r--r-- | src/tbf_dl.cpp | 12 | ||||
-rw-r--r-- | tests/tbf/TbfTest.cpp | 10 | ||||
-rw-r--r-- | tests/tbf/TbfTest.err | 4 |
8 files changed, 59 insertions, 17 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp index 167bfd4c..d0dc35c9 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -192,7 +192,7 @@ void Encoding::write_packet_uplink_assignment( } bitvec_write_field(dest, wp,0x0,1); // Message escape - bitvec_write_field(dest, wp,bts->initial_cs_ul-1, 2); // CHANNEL_CODING_COMMAND + bitvec_write_field(dest, wp,tbf->current_cs()-1, 2); // CHANNEL_CODING_COMMAND bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING bitvec_write_field(dest, wp,0x1,1); // switch TIMING_ADVANCE_VALUE = on bitvec_write_field(dest, wp,tbf->ta(),6); // TIMING_ADVANCE_VALUE @@ -397,7 +397,7 @@ void Encoding::write_packet_uplink_ack(struct gprs_rlcmac_bts *bts, block->u.Packet_Uplink_Ack_Nack.UPLINK_TFI = tbf->tfi(); // Uplink TFI block->u.Packet_Uplink_Ack_Nack.UnionType = 0x0; // PU_AckNack_GPRS = on - block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.CHANNEL_CODING_COMMAND = bts->initial_cs_ul - 1; // CS1 + block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.CHANNEL_CODING_COMMAND = tbf->current_cs() - 1; // CS1 block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.FINAL_ACK_INDICATION = final; // FINAL ACK INDICATION block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.Ack_Nack_Description.STARTING_SEQUENCE_NUMBER = tbf->m_window.ssn(); // STARTING_SEQUENCE_NUMBER diff --git a/src/gprs_ms.cpp b/src/gprs_ms.cpp index c2e83721..dc8783c4 100644 --- a/src/gprs_ms.cpp +++ b/src/gprs_ms.cpp @@ -21,6 +21,7 @@ #include "gprs_ms.h" +#include "bts.h" #include "tbf.h" #include "gprs_debug.h" @@ -74,6 +75,8 @@ GprsMs::GprsMs(BTS *bts, uint32_t tlli) : m_new_dl_tlli(0), m_ta(0), m_ms_class(0), + m_current_cs_ul(1), + m_current_cs_dl(1), m_is_idle(true), m_ref(0), m_list(this) @@ -84,6 +87,15 @@ GprsMs::GprsMs(BTS *bts, uint32_t tlli) : memset(&m_timer, 0, sizeof(m_timer)); m_timer.cb = GprsMs::timeout; m_llc_queue.init(); + if (m_bts) { + m_current_cs_ul = m_bts->bts_data()->initial_cs_ul; + if (m_current_cs_ul < 1) + m_current_cs_ul = 1; + + m_current_cs_dl = m_bts->bts_data()->initial_cs_dl; + if (m_current_cs_dl < 1) + m_current_cs_dl = 1; + } } GprsMs::~GprsMs() diff --git a/src/gprs_ms.h b/src/gprs_ms.h index 7c71bd14..01858366 100644 --- a/src/gprs_ms.h +++ b/src/gprs_ms.h @@ -72,6 +72,9 @@ public: uint8_t ms_class() const; void set_ms_class(uint8_t ms_class); + uint8_t current_cs_ul() const; + uint8_t current_cs_dl() const; + gprs_llc_queue *llc_queue(); const gprs_llc_queue *llc_queue() const; @@ -114,6 +117,10 @@ private: char m_imsi[16]; uint8_t m_ta; uint8_t m_ms_class; + /* current coding scheme */ + uint8_t m_current_cs_ul; + uint8_t m_current_cs_dl; + gprs_llc_queue m_llc_queue; bool m_is_idle; @@ -151,6 +158,16 @@ inline uint8_t GprsMs::ms_class() const return m_ms_class; } +inline uint8_t GprsMs::current_cs_dl() const +{ + return m_current_cs_dl; +} + +inline uint8_t GprsMs::current_cs_ul() const +{ + return m_current_cs_ul; +} + inline void GprsMs::set_timeout(unsigned secs) { m_delay = secs; diff --git a/src/tbf.cpp b/src/tbf.cpp index e058348f..f3c5e69e 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -115,6 +115,17 @@ void gprs_rlcmac_tbf::set_ms_class(uint8_t ms_class_) m_ms_class = ms_class_; } +uint8_t gprs_rlcmac_tbf::current_cs() const +{ + uint8_t cs; + if (direction == GPRS_RLCMAC_UL_TBF) + cs = m_ms ? m_ms->current_cs_ul() : bts->bts_data()->initial_cs_ul; + else + cs = m_ms ? m_ms->current_cs_dl() : bts->bts_data()->initial_cs_dl; + + return cs < 1 ? 1 : cs; +} + gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() { return m_ms ? m_ms->llc_queue() : NULL; @@ -945,5 +956,6 @@ void tbf_print_vty_info(struct vty *vty, struct llist_head *ltbf) if (tbf->pdch[i]) vty_out(vty, "%d ", i); } - vty_out(vty, " CS=%d%s%s", tbf->cs, VTY_NEWLINE, VTY_NEWLINE); + vty_out(vty, " CS=%d%s%s", tbf->ms() ? tbf->ms()->current_cs_dl() : 1, + VTY_NEWLINE, VTY_NEWLINE); } @@ -153,6 +153,7 @@ struct gprs_rlcmac_tbf { void set_ta(uint8_t); uint8_t ms_class() const; void set_ms_class(uint8_t); + uint8_t current_cs() const; gprs_llc_queue *llc_queue(); const gprs_llc_queue *llc_queue() const; @@ -198,8 +199,6 @@ struct gprs_rlcmac_tbf { int rssi_num; /* number of rssi values added since rssi_tv */ } meas; - uint8_t cs; /* current coding scheme */ - /* these should become protected but only after gprs_rlcmac_data.c * stops to iterate over all tbf in its current form */ enum gprs_rlcmac_tbf_state state; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index d1ed1cd9..0aa41a26 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -394,16 +394,16 @@ struct msgb *gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, const uint8_t uint16_t space, chunk; gprs_rlc_data *rlc_data; const uint16_t bsn = m_window.v_s(); + uint8_t cs = 1; LOGP(DRLCMACDL, LOGL_DEBUG, "- Sending new block at BSN %d\n", m_window.v_s()); -#warning "Selection of the CS doesn't belong here" - if (cs == 0) { - cs = bts_data()->initial_cs_dl; - if (cs < 1 || cs > 4) - cs = 1; - } + cs = current_cs(); + + OSMO_ASSERT(cs >= 1); + OSMO_ASSERT(cs <= 4); + /* total length of block, including spare bits */ const uint8_t block_length = gprs_rlcmac_cs[cs].block_length; /* length of usable data of block, w/o spare bits, inc. MAC */ diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 2184b324..e5e71566 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -133,13 +133,15 @@ int pcu_sock_send(struct msgb *msg) return 0; } -static void setup_bts(BTS *the_bts, uint8_t ts_no) +static void setup_bts(BTS *the_bts, uint8_t ts_no, uint8_t cs = 1) { gprs_rlcmac_bts *bts; gprs_rlcmac_trx *trx; bts = the_bts->bts_data(); bts->alloc_algorithm = alloc_algorithm_a; + bts->initial_cs_dl = cs; + bts->initial_cs_ul = cs; trx = &bts->trx[0]; trx->pdch[ts_no].enable(); @@ -492,7 +494,7 @@ static void test_tbf_two_phase() printf("=== start %s ===\n", __func__); - setup_bts(&the_bts, ts_no); + setup_bts(&the_bts, ts_no, 4); bts = the_bts.bts_data(); /* needed to set last_rts_fn in the PDCH object */ @@ -524,8 +526,8 @@ static void test_tbf_two_phase() ul_tbf = the_bts.ul_tbf_by_tfi(tfi, trx_no); OSMO_ASSERT(ul_tbf != NULL); - fprintf(stderr, "Got '%s', TA=%d\n", - ul_tbf->name(), ul_tbf->ta()); + fprintf(stderr, "Got '%s', TA=%d, CS=%d\n", + ul_tbf->name(), ul_tbf->ta(), ul_tbf->current_cs()); OSMO_ASSERT(ul_tbf->ta() == qta / 4); diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err index ecdc3fe6..0704c0a3 100644 --- a/tests/tbf/TbfTest.err +++ b/tests/tbf/TbfTest.err @@ -1130,7 +1130,7 @@ TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) starting timer 3169. TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) [UPLINK] START TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) RX: [PCU <- BTS] RACH qbit-ta=31 ra=0x03, Fn=2654167 (17,25,9) TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW) TX: START Immediate Assignment Uplink (AGCH) -Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b 29 07 00 c8 00 70 0b 2b 2b 2b 2b 2b 2b 2b +Sending data request: trx=0 ts=0 sapi=2 arfcn=0 fn=0 block=0 data=2d 06 3f 10 0f 00 00 03 8b 29 07 00 c8 00 10 0b 2b 2b 2b 2b 2b 2b 2b Got 'TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=FLOW)', TA=7 UL DATA TFI=0 received (V(Q)=0 .. V(R)=0) Creating MS object, TLLI = 0x00000000 @@ -1188,7 +1188,7 @@ Modifying MS object, UL TLLI: 0x00000000 -> 0xf1223344, not yet confirmed Attaching TBF to MS object, TLLI = 0xf1223344, TBF = TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=ASSIGN) Modifying MS object, TLLI = 0xf1223344, TA 0 -> 7 Change control TS to 7 until assinment is complete. -Got 'TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=ASSIGN)', TA=7 +Got 'TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=ASSIGN)', TA=7, CS=4 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=ASSIGN)s start Packet Uplink Assignment (PACCH) +++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++ ------------------------- TX : Packet Uplink Assignment ------------------------- |