Get rid of allocating first timeslot at tfi_alloc

This simpliefies the allocation process.

tfi_alloc is responsible to allocate a TFI, not a time slot.

The first time slot available depends on multislot class and on other
ongoing TBF (concurrent TBFs), so it is part of the allocation
algorithm to select it.
This commit is contained in:
Andreas Eversberg 2013-01-15 08:59:34 +01:00
parent 138f4e62d2
commit 02d7cd2ac2
4 changed files with 37 additions and 37 deletions

View File

@ -192,7 +192,8 @@ int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp)
tbf->ms_class = ms_class;
}
} else {
uint8_t trx, ts, use_trx, first_ts, ta, ss;
uint8_t trx, ta, ss;
int8_t use_trx;
struct gprs_rlcmac_tbf *old_tbf;
/* check for uplink data, so we copy our informations */
@ -200,27 +201,25 @@ int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp)
if (tbf && tbf->dir.ul.contention_resolution_done
&& !tbf->dir.ul.final_ack_sent) {
use_trx = tbf->trx;
first_ts = tbf->first_ts;
ta = tbf->ta;
ss = 0;
old_tbf = tbf;
} else {
use_trx = -1;
first_ts = -1;
ta = 0; /* FIXME: initial TA */
ss = 1; /* PCH assignment only allows one timeslot */
old_tbf = NULL;
}
// Create new TBF (any TRX)
tfi = tfi_alloc(GPRS_RLCMAC_DL_TBF, &trx, &ts, use_trx, first_ts);
tfi = tfi_alloc(GPRS_RLCMAC_DL_TBF, &trx, use_trx);
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
/* FIXME: send reject */
return -EBUSY;
}
/* set number of downlink slots according to multislot class */
tbf = tbf_alloc(tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ts, ms_class,
tbf = tbf_alloc(tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ms_class,
ss);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");

View File

@ -175,9 +175,8 @@ void debug_diagram(int diag, const char *format, ...)
/* FIXME: spread ressources over multiple TRX. Also add option to use same
* TRX in case of existing TBF for TLLI in the other direction. */
/* search for free TFI and return TFI, TRX and first TS */
int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts,
int8_t use_trx, int8_t first_ts)
/* search for free TFI and return TFI, TRX */
int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, int8_t use_trx)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_pdch *pdch;
@ -190,12 +189,10 @@ int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts,
trx_from = 0;
trx_to = 7;
}
if (first_ts < 0 || first_ts >= 8)
first_ts = 0;
/* on TRX find first enabled TS */
for (trx = trx_from; trx <= trx_to; trx++) {
for (ts = first_ts; ts < 8; ts++) {
for (ts = 0; ts < 8; ts++) {
pdch = &bts->trx[trx].pdch[ts];
if (!pdch->enable)
continue;
@ -224,7 +221,6 @@ int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts,
if (tfi < 32) {
LOGP(DRLCMAC, LOGL_DEBUG, " Found TFI=%d.\n", tfi);
*_trx = trx;
*_ts = ts;
return tfi;
}
LOGP(DRLCMAC, LOGL_NOTICE, "No TFI available.\n");
@ -324,7 +320,7 @@ struct gprs_rlcmac_tbf *tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts)
struct gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_tbf *old_tbf,
enum gprs_rlcmac_tbf_direction dir, uint8_t tfi, uint8_t trx,
uint8_t first_ts, uint8_t ms_class, uint8_t single_slot)
uint8_t ms_class, uint8_t single_slot)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_tbf *tbf;
@ -353,7 +349,7 @@ next_diagram:
"MS_CLASS=%d\n", (dir == GPRS_RLCMAC_UL_TBF) ? "UL" : "DL",
tfi, trx, ms_class);
if (trx >= 8 || first_ts >= 8 || tfi >= 32)
if (trx >= 8 || tfi >= 32)
return NULL;
tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_tbf);
@ -367,7 +363,6 @@ next_diagram:
tbf->tfi = tfi;
tbf->trx = trx;
tbf->arfcn = bts->trx[trx].arfcn;
tbf->first_ts = first_ts;
tbf->ms_class = ms_class;
tbf->ws = 64;
tbf->sns = 128;
@ -414,17 +409,24 @@ int alloc_algorithm_a(struct gprs_rlcmac_tbf *old_tbf,
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct gprs_rlcmac_pdch *pdch;
uint8_t ts = tbf->first_ts;
uint8_t ts;
int8_t usf; /* must be signed */
LOGP(DRLCMAC, LOGL_DEBUG, "Slot Allocation (Algorithm A) for class "
"%d\n", tbf->ms_class);
pdch = &bts->trx[tbf->trx].pdch[ts];
if (!pdch->enable) {
LOGP(DRLCMAC, LOGL_ERROR, "TS=%d not enabled.", ts);
return -EIO;
for (ts = 0; ts < 8; ts++) {
pdch = &bts->trx[tbf->trx].pdch[ts];
if (!pdch->enable) {
LOGP(DRLCMAC, LOGL_DEBUG, "- Skipping TS %d, because "
"not enabled\n", ts);
continue;
}
break;
}
if (ts == 8)
return -EINVAL;
tbf->tsc = pdch->tsc;
if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
/* if USF available */
@ -447,7 +449,7 @@ int alloc_algorithm_a(struct gprs_rlcmac_tbf *old_tbf,
tbf->pdch[ts] = pdch;
}
/* the only one TS is the common TS */
tbf->first_common_ts = ts;
tbf->first_ts = tbf->first_common_ts = ts;
return 0;
}
@ -467,7 +469,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf,
uint8_t Rx, Tx, Sum; /* Maximum Number of Slots: RX, Tx, Sum Rx+Tx */
uint8_t Tta, Ttb, Tra, Trb, Tt, Tr; /* Minimum Number of Slots */
uint8_t Type; /* Type of Mobile */
uint8_t rx_win_min, rx_win_max;
uint8_t rx_win_min = 0, rx_win_max = 7;
uint8_t tx_win_min, tx_win_max, tx_range;
uint8_t rx_window = 0, tx_window = 0;
const char *digit[10] = { "0","1","2","3","4","5","6","7","8","9" };
@ -622,7 +624,7 @@ int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf,
int j;
/* calculate mask of colliding slots */
for (ts = old_tbf->first_ts; ts < 8; ts++) {
for (ts = 0; ts < 8; ts++) {
if (old_tbf->pdch[ts]) {
ul_usage |= (1 << ts);
/* mark bits from TS-t .. TS+r */

View File

@ -282,12 +282,12 @@ int sba_alloc(uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta);
struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn);
int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts,
int8_t use_trx, int8_t first_ts);
int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx,
int8_t use_trx);
struct gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_tbf *old_tbf,
enum gprs_rlcmac_tbf_direction dir, uint8_t tfi, uint8_t trx,
uint8_t first_ts, uint8_t ms_class, uint8_t single_slot);
uint8_t ms_class, uint8_t single_slot);
struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx,
enum gprs_rlcmac_tbf_direction dir);

View File

@ -221,24 +221,23 @@ static uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap)
return 0;
}
static struct gprs_rlcmac_tbf *alloc_ul_tbf(int8_t use_trx, int8_t first_ts,
uint8_t ms_class, uint32_t tlli, uint8_t ta,
struct gprs_rlcmac_tbf *dl_tbf)
static struct gprs_rlcmac_tbf *alloc_ul_tbf(int8_t use_trx, uint8_t ms_class,
uint32_t tlli, uint8_t ta, struct gprs_rlcmac_tbf *dl_tbf)
{
struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
uint8_t trx, ts;
uint8_t trx;
struct gprs_rlcmac_tbf *tbf;
uint8_t tfi;
/* create new TBF, use sme TRX as DL TBF */
tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, &ts, use_trx, first_ts);
tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, use_trx);
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */
return NULL;
}
/* use multislot class of downlink TBF */
tbf = tbf_alloc(dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx, ts, ms_class, 0);
tbf = tbf_alloc(dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx, ms_class, 0);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */
@ -401,7 +400,7 @@ int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
if (ul_control_block->u.Packet_Downlink_Ack_Nack.Exist_Channel_Request_Description) {
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack "
"message, so we provide one:\n");
alloc_ul_tbf(tbf->trx, tbf->first_ts, tbf->ms_class, tbf->tlli, tbf->ta, tbf);
alloc_ul_tbf(tbf->trx, tbf->ms_class, tbf->tlli, tbf->ta, tbf);
/* schedule uplink assignment */
tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
}
@ -436,7 +435,7 @@ int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
ms_class = get_ms_class_by_capability(&ul_control_block->u.Packet_Resource_Request.MS_Radio_Access_capability);
if (!ms_class)
LOGP(DRLCMAC, LOGL_NOTICE, "MS does not give us a class.\n");
tbf = alloc_ul_tbf(trx, ts, ms_class, tlli, 0, NULL);
tbf = alloc_ul_tbf(trx, ms_class, tlli, 0, NULL);
#warning FIXME TA!!!
if (!tbf)
break;
@ -1095,7 +1094,7 @@ 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;
uint8_t trx, ts = 0;
int8_t tfi; /* must be signed */
uint8_t sb = 0;
uint32_t sb_fn = 0;
@ -1128,14 +1127,14 @@ int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta)
"(AGCH)\n");
} else {
// Create new TBF
tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, &ts, -1, -1);
tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, -1);
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */
return -EBUSY;
}
/* set class to 0, since we don't know the multislot class yet */
tbf = tbf_alloc(NULL, GPRS_RLCMAC_UL_TBF, tfi, trx, ts, 0, 1);
tbf = tbf_alloc(NULL, GPRS_RLCMAC_UL_TBF, tfi, trx, 0, 1);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */