tbf: Remove copy and paste between several call sites
This commit is contained in:
parent
bbe51c5ce2
commit
ad53ffaf6a
14
src/bts.cpp
14
src/bts.cpp
|
@ -414,19 +414,9 @@ bool BTS::rcv_rach_sba(uint8_t ra, uint32_t Fn, int16_t qta, bitvec *immediate_a
|
|||
bool BTS::rcv_rach_tbf(uint8_t ra, uint32_t Fn, int16_t qta, bitvec *immediate_assignment, uint8_t *plen)
|
||||
{
|
||||
struct gprs_rlcmac_tbf *tbf;
|
||||
uint8_t trx_no;
|
||||
int8_t tfi; /* must be signed */
|
||||
|
||||
// Create new TBF
|
||||
#warning "Copy and pate with other routines.."
|
||||
tfi = tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
|
||||
if (tfi < 0) {
|
||||
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
|
||||
/* FIXME: send reject */
|
||||
return false;
|
||||
}
|
||||
/* set class to 0, since we don't know the multislot class yet */
|
||||
tbf = tbf_alloc(&m_bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx_no, 0, 1);
|
||||
// Create new TBF with unknown ms class
|
||||
tbf = gprs_rlcmac_tbf::allocate(this, NULL, GPRS_RLCMAC_UL_TBF, -1, 0, 1);
|
||||
if (!tbf) {
|
||||
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
|
||||
/* FIXME: send reject */
|
||||
|
|
32
src/tbf.cpp
32
src/tbf.cpp
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 Ivan Klyuchnikov
|
||||
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
|
||||
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
||||
* Copyright (C) 2013-2014 by Holger Hans Peter Freyther
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -121,10 +121,9 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
|
|||
const uint32_t tlli, const uint8_t ms_class,
|
||||
const uint8_t *data, const uint16_t len)
|
||||
{
|
||||
uint8_t trx, ta, ss;
|
||||
uint8_t ta, ss;
|
||||
int8_t use_trx;
|
||||
struct gprs_rlcmac_tbf *old_tbf, *tbf;
|
||||
int8_t tfi; /* must be signed */
|
||||
int rc;
|
||||
|
||||
/* check for uplink data, so we copy our informations */
|
||||
|
@ -157,15 +156,8 @@ static int tbf_new_dl_assignment(struct gprs_rlcmac_bts *bts,
|
|||
}
|
||||
|
||||
// Create new TBF (any TRX)
|
||||
#warning "Copy and paste with alloc_ul_tbf"
|
||||
tfi = bts->bts->tfi_find_free(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(bts, tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ms_class, ss);
|
||||
tbf = gprs_rlcmac_tbf::allocate(bts->bts, tbf, GPRS_RLCMAC_DL_TBF,
|
||||
use_trx, ms_class, ss);
|
||||
if (!tbf) {
|
||||
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
|
||||
/* FIXME: send reject */
|
||||
|
@ -1794,3 +1786,19 @@ void tbf_print_vty_info(struct vty *vty, llist_head *ltbf)
|
|||
}
|
||||
vty_out(vty, " CS=%d%s%s", tbf->cs, VTY_NEWLINE, VTY_NEWLINE);
|
||||
}
|
||||
|
||||
gprs_rlcmac_tbf *gprs_rlcmac_tbf::allocate(BTS *bts, gprs_rlcmac_tbf *old_tbf,
|
||||
enum gprs_rlcmac_tbf_direction dir, int use_trx,
|
||||
int ms_class, int single_slot)
|
||||
{
|
||||
uint8_t trx_no;
|
||||
int8_t tfi;
|
||||
|
||||
tfi = bts->tfi_find_free(dir, &trx_no, use_trx);
|
||||
if (tfi < 0) {
|
||||
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tbf_alloc(bts->bts_data(), old_tbf, dir, tfi, trx_no, ms_class, single_slot);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
||||
* Copyright (C) 2013-2014 by Holger Hans Peter Freyther
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -89,6 +89,8 @@ struct gprs_rlcmac_tbf {
|
|||
static void free_all(struct gprs_rlcmac_trx *trx);
|
||||
static void free_all(struct gprs_rlcmac_pdch *pdch);
|
||||
|
||||
static gprs_rlcmac_tbf *allocate(BTS *bts, gprs_rlcmac_tbf *tbf, enum gprs_rlcmac_tbf_direction, int use_trx, int ms_class, int single_slot);
|
||||
|
||||
bool state_is(enum gprs_rlcmac_tbf_state rhs) const;
|
||||
bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
|
||||
void set_state(enum gprs_rlcmac_tbf_state new_state);
|
||||
|
|
Loading…
Reference in New Issue