tbf: Move the current CS field to GprsMs

Currently the current CS value is stored in the cs field of
gprs_rlcmac_tbf and initialised when it is used the first time.

This commit adds separate fields for UL and DL CS values to the
GprsMs class and provides corresponding getter methods for GprsMs and
gprs_rlcmac_tbf.

Ticket: #1739
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2015-06-02 16:00:41 +02:00
parent 17214bb06d
commit a700dd9e11
8 changed files with 59 additions and 17 deletions

View File

@ -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

View File

@ -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()

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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 */

View File

@ -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);

View File

@ -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 -------------------------