RLC/MAC process makes use from attributes, received from PCU socket

For OpenBTS interface and BSSGP, fixed values are still used.
This commit is contained in:
Andreas Eversberg 2012-07-06 08:13:59 +02:00
parent b3c6f6c716
commit dfa563cd3b
4 changed files with 54 additions and 26 deletions

View File

@ -385,6 +385,7 @@ int write_immediate_assignment(bitvec * dest, uint8_t downlink, uint8_t ra,
}
else
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
// 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
@ -395,8 +396,8 @@ int write_immediate_assignment(bitvec * dest, uint8_t downlink, uint8_t ra,
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, 0, 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, wp, 0, 1); // TLLI_BLOCK_CHANNEL_CODING
bitvec_write_field(dest, wp, bts->initial_cs-1, 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING
bitvec_write_field(dest, wp, 1 , 1); // "1" Alpha : Present
bitvec_write_field(dest, wp, 0, 4); // Alpha
bitvec_write_field(dest, wp, 0, 5); // Gamma
@ -417,6 +418,7 @@ void write_packet_uplink_assignment(bitvec * dest, uint8_t old_tfi,
uint8_t poll)
{
// TODO We should use our implementation of encode RLC/MAC Control messages.
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
unsigned wp = 0;
int i;
@ -439,8 +441,8 @@ void write_packet_uplink_assignment(bitvec * dest, uint8_t old_tfi,
}
bitvec_write_field(dest, wp,0x0,1); // Message escape
bitvec_write_field(dest, wp,0x0,2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, wp,0x0,1); // TLLI_BLOCK_CHANNEL_CODING
bitvec_write_field(dest, wp, bts->initial_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,ta,6); // TIMING_ADVANCE_VALUE
@ -448,7 +450,7 @@ void write_packet_uplink_assignment(bitvec * dest, uint8_t old_tfi,
#if 1
bitvec_write_field(dest, wp,0x1,1); // Frequency Parameters information elements = present
bitvec_write_field(dest, wp,tsc,3); // Training Sequence Code (TSC) = 2
bitvec_write_field(dest, wp,tsc,3); // Training Sequence Code (TSC)
bitvec_write_field(dest, wp,0x0,2); // ARFCN = present
bitvec_write_field(dest, wp,arfcn,10); // ARFCN
#else

View File

@ -85,14 +85,6 @@ extern struct gprs_rlcmac_bts *gprs_rlcmac_bts;
#define Tassign_agch 0,500000/* wait for assignment, before transmitting DL */
#define Tassign_pacch 0,100000/* wait for assignment, before transmitting DL */
#define T3169 6,0 /* 5 seconds + one second, because we don't use
* counters before starting timer. */
#define T3191 5,0 /* 5 Seconds */
#define T3193 2,0 /* >T3192, which can be max 1,5s */
#define T3195 5,0 /* 5 Seconds */
//#define N3101_MAX 12 /* how many missed uplink blocks */
#define N3103_MAX 4 /* how many tries to poll PACKET CONTROL ACK */
#define N3105_MAX 4 /* how many tries to poll PACKET DOWNLINK ACK */
enum gprs_rlcmac_tbf_state {
GPRS_RLCMAC_NULL = 0, /* new created TBF */

View File

@ -73,11 +73,13 @@ int gprs_rlcmac_poll_timeout(struct gprs_rlcmac_tbf *tbf)
"CONTROL ACK for PACKET UPLINK ACK\n");
tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE;
if (tbf->state == GPRS_RLCMAC_FINISHED) {
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
tbf->dir.ul.n3103++;
if (tbf->dir.ul.n3103 == N3103_MAX) {
if (tbf->dir.ul.n3103 == bts->n3103) {
LOGP(DRLCMAC, LOGL_DEBUG, "- N3103 exceeded\n");
tbf_new_state(tbf, GPRS_RLCMAC_RELEASING);
tbf_timer_start(tbf, 3169, T3169);
tbf_timer_start(tbf, 3169, bts->t3169, 0);
return 0;
}
/* reschedule UL ack */
@ -101,13 +103,15 @@ int gprs_rlcmac_poll_timeout(struct gprs_rlcmac_tbf *tbf)
} else
if (tbf->direction == GPRS_RLCMAC_DL_TBF)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
LOGP(DRLCMAC, LOGL_DEBUG, "- Timeout for polling PACKET "
" DOWNLINK ACK.\n");
tbf->dir.dl.n3105++;
if (tbf->dir.dl.n3105 == N3105_MAX) {
if (tbf->dir.dl.n3105 == bts->n3105) {
LOGP(DRLCMAC, LOGL_DEBUG, "- N3105 exceeded\n");
tbf_new_state(tbf, GPRS_RLCMAC_RELEASING);
tbf_timer_start(tbf, 3195, T3195);
tbf_timer_start(tbf, 3195, bts->t3195, 0);
return 0;
}
}
@ -189,6 +193,7 @@ int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint32_t fn)
if (ul_control_block->u.Packet_Downlink_Ack_Nack.Exist_Channel_Request_Description) {
uint8_t trx, ts, usf;
struct gprs_rlcmac_tbf *ul_tbf;
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack "
"message, so we provide one:\n");
@ -213,7 +218,7 @@ uplink_request:
ul_tbf->direction = GPRS_RLCMAC_UL_TBF;
ul_tbf->dir.ul.usf = usf;
tbf_new_state(ul_tbf, GPRS_RLCMAC_FLOW);
tbf_timer_start(ul_tbf, 3169, T3169);
tbf_timer_start(ul_tbf, 3169, bts->t3169, 0);
LOGP(DRLCMAC, LOGL_NOTICE, "TBF: [UPLINK] START TFI: %u\n", ul_tbf->tfi);
/* schedule uplink assignment */
tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
@ -550,14 +555,30 @@ struct msgb *gprs_rlcmac_send_uplink_ack(struct gprs_rlcmac_tbf *tbf,
*/
int gprs_rlcmac_rcv_data_block_acknowledged(uint8_t *data, uint8_t len)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_tbf *tbf;
struct rlc_ul_header *rh = (struct rlc_ul_header *)data;
uint16_t mod_sns, mod_sns_half, offset_v_q, offset_v_r, index;
int rc;
if (len < 23) {
LOGP(DRLCMACUL, LOGL_ERROR, "Dropping short frame "
"(len = %d)\n", len);
switch (len) {
case 54:
/* omitting spare bits */
len = 53;
break;
case 40:
/* omitting spare bits */
len = 39;
break;
case 34:
/* omitting spare bits */
len = 33;
break;
case 23:
break;
default:
LOGP(DRLCMACUL, LOGL_ERROR, "Dropping data block with invalid"
"length: %d)\n", len);
return -EINVAL;
}
@ -616,7 +637,7 @@ int gprs_rlcmac_rcv_data_block_acknowledged(uint8_t *data, uint8_t len)
mod_sns_half = (tbf->sns >> 1) - 1;
/* restart T3169 */
tbf_timer_start(tbf, 3169, T3169);
tbf_timer_start(tbf, 3169, bts->t3169, 0);
/* Increment RX-counter */
tbf->dir.ul.rx_counter++;
@ -782,6 +803,7 @@ struct msgb *gprs_rlcmac_send_packet_uplink_assignment(
int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_tbf *tbf;
uint8_t trx, ts;
int tfi, usf; /* must be signed */
@ -810,7 +832,7 @@ int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta)
tbf->direction = GPRS_RLCMAC_UL_TBF;
tbf->dir.ul.usf = usf;
tbf_new_state(tbf, GPRS_RLCMAC_FLOW);
tbf_timer_start(tbf, 3169, T3169);
tbf_timer_start(tbf, 3169, bts->t3169, 0);
LOGP(DRLCMAC, LOGL_NOTICE, "TBF: [UPLINK] START TFI: %u\n", tbf->tfi);
LOGP(DRLCMAC, LOGL_NOTICE, "RX: [PCU <- BTS] TFI: %u RACH qbit-ta=%d ra=%d, Fn=%d (%d,%d,%d)\n", tbf->tfi, qta, ra, Fn, (Fn / (26 * 51)) % 32, Fn % 51, Fn % 26);
LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] TFI: %u Packet Immidiate Assignment\n", tbf->tfi);
@ -1106,7 +1128,7 @@ tx_block:
else {
/* start timer whenever we send the final block */
if (rh->fbi == 1)
tbf_timer_start(tbf, 3191, T3191);
tbf_timer_start(tbf, 3191, bts->t3191, 0);
/* schedule polling */
tbf->poll_state = GPRS_RLCMAC_POLL_SCHED;
@ -1219,7 +1241,8 @@ int gprs_rlcmac_downlink_ack(struct gprs_rlcmac_tbf *tbf, uint8_t final,
LOGP(DRLCMACDL, LOGL_DEBUG, "- No new message, so we "
"release.\n");
/* start T3193 */
tbf_timer_start(tbf, 3193, T3193);
tbf_timer_start(tbf, 3193, bts->t3193_msec / 1000,
bts->t3193_msec & 1000);
tbf_new_state(tbf, GPRS_RLCMAC_WAIT_RELEASE);
return 0;

View File

@ -54,11 +54,22 @@ int main(int argc, char *argv[])
uint16_t nsvci = NSVCI;
struct gprs_ns_inst *sgsn_nsi;
struct gprs_nsvc *nsvc;
struct gprs_rlcmac_bts *bts;
gprs_rlcmac_bts = talloc_zero(NULL, struct gprs_rlcmac_bts);
bts = gprs_rlcmac_bts = talloc_zero(NULL, struct gprs_rlcmac_bts);
if (!gprs_rlcmac_bts)
return -ENOMEM;
gprs_rlcmac_bts->initial_cs = 1;
bts->initial_cs = 1;
bts->cs1 = 1;
bts->t3142 = 20;
bts->t3169 = 5;
bts->t3191 = 5;
bts->t3193_msec = 100;
bts->t3195 = 5;
bts->n3101 = 10;
bts->n3103 = 4;
bts->n3105 = 8;
osmo_init_logging(&gprs_log_info);
pcu_l1if_open();