Hello Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/3150 to look at the new patch set (#6). Move DL scheduling and RTS handler to trx level Use TRX object directly instead of BTS singleton and trx_no. This is necessary to facilitate the move of UL/DL TBF lists to TRX level. Change-Id: Ia176245647c19fa1551fb6f5c8225b2529f73cbf Related: OS#1541 --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac.h M src/gprs_rlcmac_sched.cpp M src/pcu_l1_if.cpp M src/tbf.cpp M src/tbf.h M tests/tbf/TbfTest.cpp 8 files changed, 58 insertions(+), 68 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/50/3150/6 diff --git a/src/bts.cpp b/src/bts.cpp index add6ab3..ada8456 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -1375,8 +1375,7 @@ egprs_ms_class, tlli, ta, ms); if (!ul_tbf) { - handle_tbf_reject(bts_data(), ms, tlli, - trx_no(), ts_no); + handle_tbf_reject(get_trx(), ms, tlli, ts_no); return; } diff --git a/src/bts.h b/src/bts.h index 1f1dae2..71dfb7b 100644 --- a/src/bts.h +++ b/src/bts.h @@ -91,7 +91,7 @@ gprs_rlcmac_bts *bts_data() const; BTS *bts() const; uint8_t trx_no() const; - + gprs_rlcmac_trx *get_trx(); struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi); struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi); @@ -692,6 +692,11 @@ return trx->bts->bts_data(); } +inline gprs_rlcmac_trx *gprs_rlcmac_pdch::get_trx() +{ + return trx; +} + inline uint8_t gprs_rlcmac_pdch::trx_no() const { return trx->trx_no; diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index be1e686..3d825a8 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -89,9 +89,7 @@ int gprs_rlcmac_paging_request(uint8_t *ptmsi, uint16_t ptmsi_len, const char *imsi); -int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts, - uint8_t trx, uint8_t ts, - uint32_t fn, uint8_t block_nr); +int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_trx *trx, uint8_t ts, uint32_t fn, uint8_t block_nr); int gprs_alloc_max_dl_slots_per_ms(struct gprs_rlcmac_bts *bts, uint8_t ms_class = 0); diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index 42f0308..c5fbf84 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/src/gprs_rlcmac_sched.cpp @@ -25,12 +25,10 @@ #include "pcu_utils.h" -static uint32_t sched_poll(BTS *bts, - uint8_t trx, uint8_t ts, uint32_t fn, uint8_t block_nr, - struct gprs_rlcmac_tbf **poll_tbf, - struct gprs_rlcmac_tbf **ul_ass_tbf, - struct gprs_rlcmac_tbf **dl_ass_tbf, - struct gprs_rlcmac_ul_tbf **ul_ack_tbf) +static uint32_t sched_poll(struct gprs_rlcmac_trx *trx, uint8_t ts, uint32_t fn, uint8_t block_nr, + struct gprs_rlcmac_tbf **poll_tbf, + struct gprs_rlcmac_tbf **ul_ass_tbf, struct gprs_rlcmac_tbf **dl_ass_tbf, + struct gprs_rlcmac_ul_tbf **ul_ack_tbf) { struct gprs_rlcmac_ul_tbf *ul_tbf; struct gprs_rlcmac_dl_tbf *dl_tbf; @@ -42,11 +40,11 @@ if ((block_nr % 3) == 2) poll_fn ++; poll_fn = poll_fn % GSM_MAX_FN; - llist_for_each(pos, &bts->ul_tbfs()) { + llist_for_each(pos, &trx->bts->ul_tbfs()) { ul_tbf = as_ul_tbf(pos->entry()); OSMO_ASSERT(ul_tbf); /* this trx, this ts */ - if (ul_tbf->trx->trx_no != trx || !ul_tbf->is_control_ts(ts)) + if (ul_tbf->trx->trx_no != trx->trx_no || !ul_tbf->is_control_ts(ts)) continue; /* polling for next uplink block */ if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED @@ -62,11 +60,11 @@ *ul_ass_tbf = ul_tbf; #warning "Is this supposed to be fair? The last TBF for each wins? Maybe use llist_add_tail and skip once we have all states?" } - llist_for_each(pos, &bts->dl_tbfs()) { + llist_for_each(pos, &trx->bts->dl_tbfs()) { dl_tbf = as_dl_tbf(pos->entry()); OSMO_ASSERT(dl_tbf); /* this trx, this ts */ - if (dl_tbf->trx->trx_no != trx || !dl_tbf->is_control_ts(ts)) + if (dl_tbf->trx->trx_no != trx->trx_no || !dl_tbf->is_control_ts(ts)) continue; /* polling for next uplink block */ if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED @@ -206,9 +204,8 @@ return NULL; } -static struct msgb *sched_select_downlink(struct gprs_rlcmac_bts *bts, - uint8_t trx, uint8_t ts, uint32_t fn, - uint8_t block_nr, struct gprs_rlcmac_pdch *pdch) +static struct msgb *sched_select_downlink(struct gprs_rlcmac_trx *trx, uint8_t ts, uint32_t fn, uint8_t block_nr, + struct gprs_rlcmac_pdch *pdch) { struct msgb *msg = NULL; struct gprs_rlcmac_dl_tbf *tbf, *prio_tbf = NULL; @@ -225,7 +222,7 @@ int age; const int age_thresh1 = msecs_to_frames(200); const int high_prio_msecs = - OSMO_MIN(BTS::TIMER_T3190_MSEC/2, bts->dl_tbf_idle_msec); + OSMO_MIN(BTS::TIMER_T3190_MSEC/2, trx->bts->bts_data()->dl_tbf_idle_msec); const int age_thresh2 = msecs_to_frames(high_prio_msecs); /* select downlink resource */ @@ -277,7 +274,7 @@ if (prio_tbf) { LOGP(DRLCMACSCHED, LOGL_DEBUG, "Scheduling data message at " "RTS for DL TFI=%d (TRX=%d, TS=%d) prio=%d\n", - prio_tfi, trx, ts, max_prio); + prio_tfi, trx->trx_no, ts, max_prio); /* next TBF to handle resource is the next one */ pdch->next_dl_tfi = (prio_tfi + 1) & 31; /* generate DL data block */ @@ -307,9 +304,7 @@ return msg; } -int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts, - uint8_t trx, uint8_t ts, - uint32_t fn, uint8_t block_nr) +int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_trx *trx, uint8_t ts, uint32_t fn, uint8_t block_nr) { struct gprs_rlcmac_pdch *pdch; struct gprs_rlcmac_tbf *poll_tbf = NULL, *dl_ass_tbf = NULL, @@ -319,55 +314,53 @@ struct msgb *msg = NULL; uint32_t poll_fn, sba_fn; - if (trx >= 8 || ts >= 8) + if (trx->trx_no >= 8 || ts >= 8) return -EINVAL; - pdch = &bts->trx[trx].pdch[ts]; + pdch = &trx->pdch[ts]; if (!pdch->is_enabled()) { LOGP(DRLCMACSCHED, LOGL_ERROR, "Received RTS on disabled PDCH: " - "TRX=%d TS=%d\n", trx, ts); + "TRX=%d TS=%d\n", trx->trx_no, ts); return -EIO; } /* store last frame number of RTS */ pdch->last_rts_fn = fn; - poll_fn = sched_poll(bts->bts, trx, ts, fn, block_nr, &poll_tbf, &ul_ass_tbf, - &dl_ass_tbf, &ul_ack_tbf); + poll_fn = sched_poll(trx, ts, fn, block_nr, &poll_tbf, &ul_ass_tbf, &dl_ass_tbf, &ul_ack_tbf); /* check uplink resource for polling */ if (poll_tbf) LOGP(DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: TRX=%d " "TS=%d FN=%d block_nr=%d scheduling free USF for " - "polling at FN=%d of %s\n", trx, ts, fn, + "polling at FN=%d of %s\n", trx->trx_no, ts, fn, block_nr, poll_fn, tbf_name(poll_tbf)); /* use free USF */ /* else. check for sba */ - else if ((sba_fn = bts->bts->sba()->sched(trx, ts, fn, block_nr) != 0xffffffff)) + else if ((sba_fn = trx->bts->sba()->sched(trx->trx_no, ts, fn, block_nr) != 0xffffffff)) LOGP(DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: TRX=%d " "TS=%d FN=%d block_nr=%d scheduling free USF for " - "single block allocation at FN=%d\n", trx, ts, fn, + "single block allocation at FN=%d\n", trx->trx_no, ts, fn, block_nr, sba_fn); /* use free USF */ /* else, we search for uplink resource */ else - usf = sched_select_uplink(trx, ts, fn, block_nr, pdch); + usf = sched_select_uplink(trx->trx_no, ts, fn, block_nr, pdch); /* Prio 1: select control message */ - msg = sched_select_ctrl_msg(trx, ts, fn, block_nr, pdch, ul_ass_tbf, - dl_ass_tbf, ul_ack_tbf); + msg = sched_select_ctrl_msg(trx->trx_no, ts, fn, block_nr, pdch, ul_ass_tbf, dl_ass_tbf, ul_ack_tbf); if (msg) { - bts->bts->rlc_sent_control(); - bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_CTRL, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len); + trx->bts->rlc_sent_control(); + trx->bts->send_gsmtap(PCU_GSMTAP_C_DL_CTRL, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len); } /* Prio 2: select data message for downlink */ if (!msg) { - msg = sched_select_downlink(bts, trx, ts, fn, block_nr, pdch); + msg = sched_select_downlink(trx, ts, fn, block_nr, pdch); if (msg) { - bts->bts->rlc_sent(); + trx->bts->rlc_sent(); /* FIXME: distinguish between GPRS and EGPRS */ - bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, trx, ts, GSMTAP_CHANNEL_PDTCH, fn, msg->data, msg->len); + trx->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, trx, ts, GSMTAP_CHANNEL_PDTCH, fn, msg->data, msg->len); } } @@ -376,15 +369,15 @@ /* increase counter */ msg = sched_dummy(); if (msg) { - bts->bts->rlc_sent_dummy(); - bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DUMMY, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len); + trx->bts->rlc_sent_dummy(); + trx->bts->send_gsmtap(PCU_GSMTAP_C_DL_DUMMY, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len); } } if (!msg) return -ENOMEM; /* msg is now available */ - bts->bts->rlc_dl_bytes(msg->data_len); + trx->bts->rlc_dl_bytes(msg->data_len); /* set USF */ OSMO_ASSERT(msgb_length(msg) > 0); @@ -394,7 +387,7 @@ gprs_bssgp_update_frames_sent(); /* send PDTCH/PACCH to L1 */ - pcu_l1if_tx_pdtch(msg, trx, ts, bts->trx[trx].arfcn, fn, block_nr); + pcu_l1if_tx_pdtch(msg, trx->trx_no, ts, trx->arfcn, fn, block_nr); return 0; } diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 8ea2ad5..b38244b 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -307,11 +307,13 @@ } // FIXME: remove this, when changed from c++ to c. -extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts, +extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx_no, uint8_t ts, uint32_t fn, uint8_t block_nr) { - return gprs_rlcmac_rcv_rts_block(bts_main_data(), - trx, ts, fn, block_nr); + struct gprs_rlcmac_bts *bts = bts_main_data(); + struct gprs_rlcmac_trx *trx = &bts->trx[trx_no]; + + return gprs_rlcmac_rcv_rts_block(trx, ts, fn, block_nr); } static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req) diff --git a/src/tbf.cpp b/src/tbf.cpp index c5f4348..f143960 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1450,24 +1450,22 @@ return ts == control_ts; } -struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts, - GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts) +struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_trx *trx, GprsMs *ms, uint32_t tlli, uint8_t ts) { struct gprs_rlcmac_ul_tbf *ul_tbf = NULL; - struct gprs_rlcmac_trx *trx = &bts->trx[trx_no]; ul_tbf = talloc(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); if (!ul_tbf) return ul_tbf; talloc_set_destructor(ul_tbf, ul_tbf_dtor); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts->bts); + new (ul_tbf) gprs_rlcmac_ul_tbf(trx->bts); if (!ms) - ms = bts->bts->ms_alloc(0, 0); + ms = trx->bts->ms_alloc(0, 0); ms->set_tlli(tlli); - llist_add(&ul_tbf->list(), &bts->bts->ul_tbfs()); + llist_add(&ul_tbf->list(), &trx->bts->ul_tbfs()); ul_tbf->bts->tbf_ul_created(); ul_tbf->set_state(GPRS_RLCMAC_ASSIGN); ul_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH); diff --git a/src/tbf.h b/src/tbf.h index 95e1e89..c13e61f 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -324,8 +324,7 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf); -struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts, - GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts_no); +struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_trx *trx, GprsMs *ms, uint32_t tlli, uint8_t ts_no); int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 0db7fde..886856a 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -203,7 +203,8 @@ uint32_t *fn, uint8_t *block_nr = NULL) { uint8_t bn = fn2bn(*fn); - gprs_rlcmac_rcv_rts_block(bts, trx_no, ts_no, *fn, bn); + struct gprs_rlcmac_trx *trx = &bts->trx[trx_no]; + gprs_rlcmac_rcv_rts_block(trx, ts_no, *fn, bn); *fn = fn_add_blocks(*fn, 1); bn += 1; if (block_nr) @@ -1651,9 +1652,8 @@ for (ts_no = 0 ; ts_no < 8; ts_no += 1) { if (!(slots & (1 << ts_no))) continue; - gprs_rlcmac_rcv_rts_block(the_bts->bts_data(), - dl_tbf->trx->trx_no, ts_no, - *fn, bn); + struct gprs_rlcmac_trx *trx = &the_bts->bts_data()->trx[dl_tbf->trx->trx_no]; + gprs_rlcmac_rcv_rts_block(trx, ts_no, *fn, bn); } *fn = fn_add_blocks(*fn, 1); } @@ -3222,17 +3222,14 @@ setup_bts(&the_bts, ts_no, 4); int rc = 0; - - ul_tbf = handle_tbf_reject(the_bts.bts_data(), NULL, tlli, - trx_no, ts_no); + struct gprs_rlcmac_trx *trx = &the_bts.bts_data()->trx[trx_no]; + ul_tbf = handle_tbf_reject(trx, NULL, tlli, ts_no); OSMO_ASSERT(ul_tbf != 0); /* trigger packet access reject */ uint8_t bn = fn2bn(fn); - - rc = gprs_rlcmac_rcv_rts_block(the_bts.bts_data(), - trx_no, ts_no, fn, bn); + rc = gprs_rlcmac_rcv_rts_block(trx, ts_no, fn, bn); OSMO_ASSERT(rc == 0); @@ -3307,9 +3304,8 @@ /* trigger packet access reject */ uint8_t bn = fn2bn(fn); - - rc = gprs_rlcmac_rcv_rts_block(the_bts.bts_data(), - trx_no, ts_no, fn, bn); + struct gprs_rlcmac_trx *trx = &the_bts.bts_data()->trx[trx_no]; + rc = gprs_rlcmac_rcv_rts_block(trx, ts_no, fn, bn); OSMO_ASSERT(rc == 0); -- To view, visit https://gerrit.osmocom.org/3150 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ia176245647c19fa1551fb6f5c8225b2529f73cbf Gerrit-PatchSet: 6 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: Max <msur...@sysmocom.de> Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org> Gerrit-Reviewer: Jenkins Builder