2012-06-27 13:36:27 +00:00
|
|
|
/* PDCH scheduler
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2019-09-25 15:48:35 +00:00
|
|
|
|
2012-06-27 13:36:27 +00:00
|
|
|
#include <gprs_bssgp_pcu.h>
|
|
|
|
#include <gprs_rlcmac.h>
|
|
|
|
#include <pcu_l1_if.h>
|
2013-10-17 15:01:54 +00:00
|
|
|
#include <bts.h>
|
2013-10-16 15:42:31 +00:00
|
|
|
#include <tbf.h>
|
2019-09-25 15:47:02 +00:00
|
|
|
#include <tbf_ul.h>
|
2018-01-26 12:31:42 +00:00
|
|
|
#include <gprs_debug.h>
|
|
|
|
#include <gprs_ms.h>
|
|
|
|
#include <rlc.h>
|
|
|
|
#include <sba.h>
|
2018-02-19 16:17:28 +00:00
|
|
|
#include <pdch.h>
|
2015-03-20 13:26:05 +00:00
|
|
|
#include "pcu_utils.h"
|
|
|
|
|
2018-01-26 12:31:42 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/core/gsmtap.h>
|
|
|
|
}
|
|
|
|
|
2020-12-15 17:46:33 +00:00
|
|
|
struct tbf_sched_candidates {
|
|
|
|
struct gprs_rlcmac_tbf *ul_ass;
|
|
|
|
struct gprs_rlcmac_tbf *dl_ass;
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
struct gprs_rlcmac_tbf *nacc;
|
2020-12-15 17:46:33 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *ul_ack;
|
|
|
|
};
|
|
|
|
|
2021-05-13 16:39:36 +00:00
|
|
|
static void get_ctrl_msg_tbf_candidates(const struct gprs_rlcmac_pdch *pdch,
|
2021-04-30 12:15:46 +00:00
|
|
|
struct tbf_sched_candidates *tbf_cand)
|
2012-06-27 13:36:27 +00:00
|
|
|
{
|
2014-08-07 12:58:59 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *ul_tbf;
|
|
|
|
struct gprs_rlcmac_dl_tbf *dl_tbf;
|
2021-01-14 15:48:38 +00:00
|
|
|
struct llist_item *pos;
|
2012-07-03 11:36:03 +00:00
|
|
|
|
2021-05-13 16:39:36 +00:00
|
|
|
llist_for_each_entry(pos, &pdch->trx->ul_tbfs, list) {
|
2021-01-14 15:48:38 +00:00
|
|
|
ul_tbf = as_ul_tbf((struct gprs_rlcmac_tbf *)pos->entry);
|
2015-12-28 18:15:40 +00:00
|
|
|
OSMO_ASSERT(ul_tbf);
|
2012-07-15 04:25:37 +00:00
|
|
|
/* this trx, this ts */
|
2021-05-13 16:39:36 +00:00
|
|
|
if (!ul_tbf->is_control_ts(pdch->ts_no))
|
2012-07-15 04:25:37 +00:00
|
|
|
continue;
|
2018-01-23 19:16:23 +00:00
|
|
|
if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
|
2020-12-15 17:46:33 +00:00
|
|
|
tbf_cand->ul_ack = ul_tbf;
|
2018-01-23 19:09:06 +00:00
|
|
|
if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
|
2020-12-15 17:46:33 +00:00
|
|
|
tbf_cand->dl_ass = ul_tbf;
|
2018-01-23 19:09:06 +00:00
|
|
|
if (ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
|
|
|
|
|| ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
2020-12-15 17:46:33 +00:00
|
|
|
tbf_cand->ul_ass = ul_tbf;
|
2021-02-18 13:27:14 +00:00
|
|
|
/* NACC ready to send. TFI assigned is needed to send messages */
|
|
|
|
if (ul_tbf->is_tfi_assigned() && ms_nacc_rts(ul_tbf->ms()))
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
tbf_cand->nacc = ul_tbf;
|
2017-09-01 12:36:44 +00:00
|
|
|
/* FIXME: Is this supposed to be fair? The last TBF for each wins? Maybe use llist_add_tail and skip once we have all
|
|
|
|
states? */
|
2012-06-27 13:36:27 +00:00
|
|
|
}
|
2021-05-13 16:39:36 +00:00
|
|
|
llist_for_each_entry(pos, &pdch->trx->dl_tbfs, list) {
|
2021-01-14 15:48:38 +00:00
|
|
|
dl_tbf = as_dl_tbf((struct gprs_rlcmac_tbf *)pos->entry);
|
2015-12-28 18:15:40 +00:00
|
|
|
OSMO_ASSERT(dl_tbf);
|
2012-07-15 04:25:37 +00:00
|
|
|
/* this trx, this ts */
|
2021-05-13 16:39:36 +00:00
|
|
|
if (!dl_tbf->is_control_ts(pdch->ts_no))
|
2012-07-15 04:25:37 +00:00
|
|
|
continue;
|
2018-01-23 19:09:06 +00:00
|
|
|
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
|
2020-12-15 17:46:33 +00:00
|
|
|
tbf_cand->dl_ass = dl_tbf;
|
2018-01-23 19:09:06 +00:00
|
|
|
if (dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
|
|
|
|
|| dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
2020-12-15 17:46:33 +00:00
|
|
|
tbf_cand->ul_ass = dl_tbf;
|
2021-02-18 13:27:14 +00:00
|
|
|
/* NACC ready to send. TFI assigned is needed to send messages */
|
|
|
|
if (dl_tbf->is_tfi_assigned() && ms_nacc_rts(dl_tbf->ms()))
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
tbf_cand->nacc = dl_tbf;
|
2012-07-15 04:25:37 +00:00
|
|
|
}
|
2012-07-25 06:38:21 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 12:04:33 +00:00
|
|
|
static struct gprs_rlcmac_ul_tbf *sched_select_uplink(struct gprs_rlcmac_pdch *pdch, bool require_gprs_only)
|
2012-07-25 06:38:21 +00:00
|
|
|
{
|
2021-03-24 16:06:15 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *tbf;
|
2012-07-25 06:38:21 +00:00
|
|
|
uint8_t i, tfi;
|
|
|
|
|
2013-10-27 09:38:31 +00:00
|
|
|
/* select uplink resource */
|
2012-07-25 06:38:21 +00:00
|
|
|
for (i = 0, tfi = pdch->next_ul_tfi; i < 32;
|
|
|
|
i++, tfi = (tfi + 1) & 31) {
|
2014-06-04 12:56:09 +00:00
|
|
|
tbf = pdch->ul_tbf_by_tfi(tfi);
|
2012-07-25 06:38:21 +00:00
|
|
|
/* no TBF for this tfi, go next */
|
|
|
|
if (!tbf)
|
|
|
|
continue;
|
2013-10-16 14:33:00 +00:00
|
|
|
/* no UL resources needed, go next */
|
|
|
|
/* we don't need to give resources in FINISHED state,
|
2012-07-25 06:38:21 +00:00
|
|
|
* because we have received all blocks and only poll
|
|
|
|
* for packet control ack. */
|
2021-05-14 10:50:46 +00:00
|
|
|
if (tbf->state_is_not(TBF_ST_FLOW))
|
2012-07-25 06:38:21 +00:00
|
|
|
continue;
|
|
|
|
|
2020-11-16 16:35:10 +00:00
|
|
|
if (require_gprs_only && tbf->is_egprs_enabled())
|
|
|
|
continue;
|
|
|
|
|
2021-05-11 12:04:33 +00:00
|
|
|
/* use this USF (tbf) */
|
2013-10-27 09:38:31 +00:00
|
|
|
/* next TBF to handle resource is the next one */
|
2012-07-25 06:38:21 +00:00
|
|
|
pdch->next_ul_tfi = (tfi + 1) & 31;
|
2021-03-24 16:06:15 +00:00
|
|
|
return tbf;
|
2012-06-27 13:36:27 +00:00
|
|
|
}
|
|
|
|
|
2021-03-24 16:06:15 +00:00
|
|
|
return NULL;
|
2012-07-25 06:38:21 +00:00
|
|
|
}
|
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
struct msgb *sched_app_info(struct gprs_rlcmac_tbf *tbf) {
|
2021-01-18 11:53:54 +00:00
|
|
|
struct gprs_rlcmac_bts *bts;
|
2019-09-05 15:13:33 +00:00
|
|
|
struct msgb *msg = NULL;
|
|
|
|
|
|
|
|
if (!tbf || !tbf->ms()->app_info_pending)
|
|
|
|
return NULL;
|
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
bts = tbf->bts;
|
2019-09-05 15:13:33 +00:00
|
|
|
|
2021-01-18 11:53:54 +00:00
|
|
|
if (bts->app_info) {
|
2019-09-05 15:13:33 +00:00
|
|
|
LOGP(DRLCMACSCHED, LOGL_DEBUG, "Sending Packet Application Information message\n");
|
2021-01-18 11:53:54 +00:00
|
|
|
msg = msgb_copy(bts->app_info, "app_info_msg_sched");
|
2019-09-05 15:13:33 +00:00
|
|
|
} else
|
|
|
|
LOGP(DRLCMACSCHED, LOGL_ERROR, "MS has app_info_pending flag set, but no Packet Application Information"
|
|
|
|
" message stored in BTS!\n");
|
|
|
|
|
|
|
|
tbf->ms()->app_info_pending = false;
|
2021-01-18 11:53:54 +00:00
|
|
|
bts->app_info_pending--;
|
2019-09-05 15:13:33 +00:00
|
|
|
|
2021-01-18 11:53:54 +00:00
|
|
|
if (!bts->app_info_pending) {
|
2019-09-05 15:13:33 +00:00
|
|
|
LOGP(DRLCMACSCHED, LOGL_DEBUG, "Packet Application Information successfully sent to all MS with active"
|
|
|
|
" TBF\n");
|
2021-01-18 11:53:54 +00:00
|
|
|
msgb_free(bts->app_info);
|
|
|
|
bts->app_info = NULL;
|
2019-09-05 15:13:33 +00:00
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2021-03-03 19:47:07 +00:00
|
|
|
static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_pdch *pdch, uint32_t fn,
|
|
|
|
uint8_t block_nr, struct tbf_sched_candidates *tbfs)
|
2012-07-25 06:38:21 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = NULL;
|
|
|
|
struct gprs_rlcmac_tbf *tbf = NULL;
|
2020-12-15 17:55:16 +00:00
|
|
|
struct gprs_rlcmac_tbf *next_list[] = { tbfs->ul_ass,
|
|
|
|
tbfs->dl_ass,
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
tbfs->ul_ack,
|
|
|
|
tbfs->nacc };
|
2021-03-03 19:47:07 +00:00
|
|
|
uint8_t ts = pdch->ts_no;
|
2012-07-25 06:38:21 +00:00
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
/* Send Packet Application Information first (ETWS primary notifications) */
|
2020-12-15 17:46:33 +00:00
|
|
|
msg = sched_app_info(tbfs->dl_ass);
|
2013-11-26 15:39:28 +00:00
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
if (!msg) {
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(next_list); ++i) {
|
2020-12-15 17:55:16 +00:00
|
|
|
tbf = next_list[(pdch->next_ctrl_prio + i) % ARRAY_SIZE(next_list)];
|
2019-09-05 15:13:33 +00:00
|
|
|
if (!tbf)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assignments for the same direction have lower precedence,
|
|
|
|
* because they may kill the TBF when the CONTROL ACK is
|
|
|
|
* received, thus preventing the others from being processed.
|
|
|
|
*/
|
2020-12-15 17:46:33 +00:00
|
|
|
if (tbf == tbfs->ul_ass && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
|
|
|
msg = tbfs->ul_ass->create_packet_access_reject();
|
2021-04-26 16:02:52 +00:00
|
|
|
else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF)
|
|
|
|
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
|
2020-12-15 17:46:33 +00:00
|
|
|
else if (tbf == tbfs->dl_ass && tbf->direction == GPRS_RLCMAC_UL_TBF)
|
|
|
|
msg = tbfs->dl_ass->create_dl_ass(fn, ts);
|
|
|
|
else if (tbf == tbfs->ul_ack)
|
|
|
|
msg = tbfs->ul_ack->create_ul_ack(fn, ts);
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
else if (tbf == tbfs->nacc) {
|
2021-02-01 13:52:48 +00:00
|
|
|
msg = ms_nacc_create_rlcmac_msg(tbf->ms(), tbf, fn, ts);
|
Introduce NACC support
A new nacc_fsm is introduced per MS object, with its partner priv
structure struct nacc_fsm_ctx, which exists and is available in the MS
object only during the duration of the NACC procedure.
The NACC context is created on an MS whenever a Pkt Cell Change
Notification is received on Uplink RLCMAC, which asks for neighbor
information of a given ARFCN+BSIC.
First, the target ARFCN+BSIC needs to be translated into a CGI-PS
(RAC+CI) address. That's done by asking the BSC through the Neighbour
Resolution Service available in osmo-bsc using the CTRL interface.
Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO
request against the SGSN (which will route the request as needed), and
wait for a response containing the SI bits from the target cell.
After the SI are received, the scheduler is instructed to eventually
poll a TBF for the MS originating the CCN, so that we can send the SI
encapsulated into multiple Packet Neighbor Cell Data messages on the
downlink.
One all the SI bits are sent, the scheduler is instructed to send a
Packet Cell Change Continue message.
Once the message above has been sent, the FSM autodestroys itself.
Caches are also introduced in this patch which allows for re-using
recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO
respectively.
Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-21 17:46:13 +00:00
|
|
|
}
|
2013-11-26 15:39:28 +00:00
|
|
|
|
2019-09-05 15:13:33 +00:00
|
|
|
if (!msg) {
|
|
|
|
tbf = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-12-15 17:55:16 +00:00
|
|
|
pdch->next_ctrl_prio = (pdch->next_ctrl_prio + 1) % ARRAY_SIZE(next_list);
|
2019-09-05 15:13:33 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-07-15 04:25:37 +00:00
|
|
|
}
|
2013-11-26 15:39:28 +00:00
|
|
|
|
2016-02-01 18:42:09 +00:00
|
|
|
if (!msg) {
|
|
|
|
/*
|
|
|
|
* If one of these is left, the response (CONTROL ACK) from the
|
|
|
|
* MS will kill the current TBF, only one of them can be
|
|
|
|
* non-NULL
|
|
|
|
*/
|
2020-12-15 17:46:33 +00:00
|
|
|
if (tbfs->dl_ass) {
|
|
|
|
tbf = tbfs->dl_ass;
|
|
|
|
msg = tbfs->dl_ass->create_dl_ass(fn, ts);
|
|
|
|
} else if (tbfs->ul_ass) {
|
|
|
|
tbf = tbfs->ul_ass;
|
|
|
|
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
|
2016-02-01 18:42:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-25 06:38:21 +00:00
|
|
|
/* any message */
|
2012-07-15 04:25:37 +00:00
|
|
|
if (msg) {
|
fix PACCH paging: don't return early in case of NULL TBF
Commit b78a4a6dfef217c538d45949a6ae725e22a36b05 tried to fix a NULL dereference
error, but apparently was overly eager to return, because it looked like all
code paths would dereference the tbf.
In fact the code path further above, for msg != NULL, has "always" dereferenced
the tbf, but the lower code path, the one effecting the paging, has only
started to dereference tbf since shortly before the overly eager fix: in
da7250ad2c1cd5ddc7d3c6e10435a00b357ef8f7, to "update the dl ctrl msg counter
for ms". It seems that this tbf dereference in the paging path is bogus and the
cause for the segfault that made me write the early exit fix.
Fix that fix:
Do not exit early if tbf == NULL, stay in there to be able to reach the paging
path below.
In case of a message to be sent, assume that tbf is present, and verify: print
an error message and abort if there is a msg but no tbf, so that we will see
the error if I'm wrong there. If a tbf is missing, free the msg.
In case of no message, go on to send pending pagings, but do not attempt to
count ctrl messages for a tbf -- IIUC there will never be a tbf if we're
paging.
This should avoid segfaults while keeping PACCH paging intact.
Tweak a comment for and add a blank line above the paging section.
Related: OS#2176 CID#158969
Change-Id: Ib79f4a945e211a13ac7d1e511cc37b0940ac6202
2017-04-26 23:33:39 +00:00
|
|
|
if (!tbf) {
|
2021-03-03 19:47:07 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_ERROR, "FN=%" PRIu32
|
|
|
|
" Control message to be scheduled, but no TBF\n", fn);
|
fix PACCH paging: don't return early in case of NULL TBF
Commit b78a4a6dfef217c538d45949a6ae725e22a36b05 tried to fix a NULL dereference
error, but apparently was overly eager to return, because it looked like all
code paths would dereference the tbf.
In fact the code path further above, for msg != NULL, has "always" dereferenced
the tbf, but the lower code path, the one effecting the paging, has only
started to dereference tbf since shortly before the overly eager fix: in
da7250ad2c1cd5ddc7d3c6e10435a00b357ef8f7, to "update the dl ctrl msg counter
for ms". It seems that this tbf dereference in the paging path is bogus and the
cause for the segfault that made me write the early exit fix.
Fix that fix:
Do not exit early if tbf == NULL, stay in there to be able to reach the paging
path below.
In case of a message to be sent, assume that tbf is present, and verify: print
an error message and abort if there is a msg but no tbf, so that we will see
the error if I'm wrong there. If a tbf is missing, free the msg.
In case of no message, go on to send pending pagings, but do not attempt to
count ctrl messages for a tbf -- IIUC there will never be a tbf if we're
paging.
This should avoid segfaults while keeping PACCH paging intact.
Tweak a comment for and add a blank line above the paging section.
Related: OS#2176 CID#158969
Change-Id: Ib79f4a945e211a13ac7d1e511cc37b0940ac6202
2017-04-26 23:33:39 +00:00
|
|
|
msgb_free(msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-11-26 12:08:12 +00:00
|
|
|
tbf->rotate_in_list();
|
2021-03-03 19:47:07 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "FN=%" PRIu32
|
|
|
|
" Scheduling control message at RTS for %s\n",
|
|
|
|
fn, tbf_name(tbf));
|
2021-01-11 16:32:18 +00:00
|
|
|
rate_ctr_inc(&tbf->ms()->ctrs->ctr[MS_CTR_DL_CTRL_MSG_SCHED]);
|
2012-07-25 06:38:21 +00:00
|
|
|
return msg;
|
2012-06-27 13:36:27 +00:00
|
|
|
}
|
fix PACCH paging: don't return early in case of NULL TBF
Commit b78a4a6dfef217c538d45949a6ae725e22a36b05 tried to fix a NULL dereference
error, but apparently was overly eager to return, because it looked like all
code paths would dereference the tbf.
In fact the code path further above, for msg != NULL, has "always" dereferenced
the tbf, but the lower code path, the one effecting the paging, has only
started to dereference tbf since shortly before the overly eager fix: in
da7250ad2c1cd5ddc7d3c6e10435a00b357ef8f7, to "update the dl ctrl msg counter
for ms". It seems that this tbf dereference in the paging path is bogus and the
cause for the segfault that made me write the early exit fix.
Fix that fix:
Do not exit early if tbf == NULL, stay in there to be able to reach the paging
path below.
In case of a message to be sent, assume that tbf is present, and verify: print
an error message and abort if there is a msg but no tbf, so that we will see
the error if I'm wrong there. If a tbf is missing, free the msg.
In case of no message, go on to send pending pagings, but do not attempt to
count ctrl messages for a tbf -- IIUC there will never be a tbf if we're
paging.
This should avoid segfaults while keeping PACCH paging intact.
Tweak a comment for and add a blank line above the paging section.
Related: OS#2176 CID#158969
Change-Id: Ib79f4a945e211a13ac7d1e511cc37b0940ac6202
2017-04-26 23:33:39 +00:00
|
|
|
|
|
|
|
/* schedule PACKET PAGING REQUEST, if any are pending */
|
2013-10-19 16:15:44 +00:00
|
|
|
msg = pdch->packet_paging_request();
|
2012-08-07 14:00:56 +00:00
|
|
|
if (msg) {
|
2021-03-03 19:47:07 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "FN=%" PRIu32
|
|
|
|
" Scheduling paging request message at RTS\n", fn);
|
2012-08-07 14:00:56 +00:00
|
|
|
return msg;
|
|
|
|
}
|
2012-07-25 06:38:21 +00:00
|
|
|
|
2012-08-07 14:00:56 +00:00
|
|
|
return NULL;
|
2012-07-25 06:38:21 +00:00
|
|
|
}
|
|
|
|
|
2017-12-13 17:27:32 +00:00
|
|
|
static inline enum tbf_dl_prio tbf_compute_priority(const struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_dl_tbf *tbf,
|
|
|
|
uint8_t ts, uint32_t fn, int age)
|
|
|
|
{
|
2020-10-23 19:00:23 +00:00
|
|
|
const gprs_rlc_dl_window *w = static_cast<gprs_rlc_dl_window *>(tbf->window());
|
2021-01-14 11:01:42 +00:00
|
|
|
unsigned long msecs_t3190 = osmo_tdef_get(the_pcu->T_defs, 3190, OSMO_TDEF_MS, -1);
|
|
|
|
unsigned long dl_tbf_idle_msec = osmo_tdef_get(the_pcu->T_defs, -2031, OSMO_TDEF_MS, -1);
|
2019-09-09 10:55:01 +00:00
|
|
|
int age_thresh1 = msecs_to_frames(200);
|
2019-09-09 11:41:00 +00:00
|
|
|
int age_thresh2 = msecs_to_frames(OSMO_MIN(msecs_t3190/2, dl_tbf_idle_msec));
|
2017-12-13 17:27:32 +00:00
|
|
|
|
|
|
|
if (tbf->is_control_ts(ts) && tbf->need_control_ts())
|
|
|
|
return DL_PRIO_CONTROL;
|
|
|
|
|
|
|
|
if (tbf->is_control_ts(ts) && age > age_thresh2 && age_thresh2 > 0)
|
|
|
|
return DL_PRIO_HIGH_AGE;
|
|
|
|
|
2021-05-14 10:50:46 +00:00
|
|
|
if ((tbf->state_is(TBF_ST_FLOW) && tbf->have_data()) || w->resend_needed() >= 0)
|
2017-12-13 17:27:32 +00:00
|
|
|
return DL_PRIO_NEW_DATA;
|
|
|
|
|
|
|
|
if (tbf->is_control_ts(ts) && age > age_thresh1 && tbf->keep_open(fn))
|
|
|
|
return DL_PRIO_LOW_AGE;
|
|
|
|
|
|
|
|
if (!w->window_empty())
|
|
|
|
return DL_PRIO_SENT_DATA;
|
|
|
|
|
|
|
|
return DL_PRIO_NONE;
|
|
|
|
}
|
|
|
|
|
2021-01-25 16:30:31 +00:00
|
|
|
/* Check if next data block of a TBF can be encoded in GMSK [(M)CS1-4]. */
|
|
|
|
static bool can_produce_gmsk_data_block_next(struct gprs_rlcmac_dl_tbf *tbf, enum tbf_dl_prio prio)
|
|
|
|
{
|
|
|
|
const gprs_rlc_dl_window *w;
|
|
|
|
|
|
|
|
/* GPRS TBFs can always send GMSK */
|
|
|
|
if (!tbf->is_egprs_enabled())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
switch (prio) {
|
|
|
|
case DL_PRIO_CONTROL:
|
|
|
|
/* Control blocks are always CS-1 */
|
|
|
|
return true;
|
|
|
|
case DL_PRIO_NEW_DATA:
|
|
|
|
/* We can send any new data (no block generated yet) using any
|
|
|
|
* MCS. However, we don't (yet) support resegmenting already
|
|
|
|
* sent blocks (NACKed blocks in this case) into lower MCS of
|
|
|
|
* the same family. See OS#4966 */
|
|
|
|
w = static_cast<gprs_rlc_dl_window *>(tbf->window());
|
|
|
|
return w->resend_needed() < 0;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-03 19:52:19 +00:00
|
|
|
static struct msgb *sched_select_downlink(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_pdch *pdch, uint32_t fn,
|
|
|
|
uint8_t block_nr, enum mcs_kind req_mcs_kind, bool *is_egprs)
|
2012-07-25 06:38:21 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = NULL;
|
2015-03-02 13:28:12 +00:00
|
|
|
struct gprs_rlcmac_dl_tbf *tbf, *prio_tbf = NULL;
|
2017-12-13 17:27:32 +00:00
|
|
|
enum tbf_dl_prio prio, max_prio = DL_PRIO_NONE;
|
2021-03-03 19:52:19 +00:00
|
|
|
uint8_t ts = pdch->ts_no;
|
2015-03-20 13:26:05 +00:00
|
|
|
|
2015-03-02 13:28:12 +00:00
|
|
|
uint8_t i, tfi, prio_tfi;
|
2015-03-20 13:26:05 +00:00
|
|
|
int age;
|
2012-07-25 06:38:21 +00:00
|
|
|
|
2013-10-27 09:38:31 +00:00
|
|
|
/* select downlink resource */
|
2012-07-25 06:38:21 +00:00
|
|
|
for (i = 0, tfi = pdch->next_dl_tfi; i < 32;
|
|
|
|
i++, tfi = (tfi + 1) & 31) {
|
2014-06-04 12:56:09 +00:00
|
|
|
tbf = pdch->dl_tbf_by_tfi(tfi);
|
2012-07-25 06:38:21 +00:00
|
|
|
/* no TBF for this tfi, go next */
|
|
|
|
if (!tbf)
|
|
|
|
continue;
|
|
|
|
/* no DL TBF, go next */
|
|
|
|
if (tbf->direction != GPRS_RLCMAC_DL_TBF)
|
|
|
|
continue;
|
2013-10-16 14:33:00 +00:00
|
|
|
/* no DL resources needed, go next */
|
2021-05-14 10:50:46 +00:00
|
|
|
if (tbf->state_is_not(TBF_ST_FLOW)
|
|
|
|
&& tbf->state_is_not(TBF_ST_FINISHED))
|
2012-07-25 06:38:21 +00:00
|
|
|
continue;
|
|
|
|
|
2012-09-27 07:23:24 +00:00
|
|
|
/* waiting for CCCH IMM.ASS confirm */
|
2014-08-07 13:49:21 +00:00
|
|
|
if (tbf->m_wait_confirm)
|
2012-09-27 07:23:24 +00:00
|
|
|
continue;
|
|
|
|
|
2020-11-16 16:35:10 +00:00
|
|
|
/* If a GPRS (CS1-4) Dl block is required, skip EGPRS(_GSMK) tbfs: */
|
|
|
|
if (req_mcs_kind == GPRS && tbf->is_egprs_enabled())
|
|
|
|
continue;
|
|
|
|
|
2015-03-20 13:26:05 +00:00
|
|
|
age = tbf->frames_since_last_poll(fn);
|
|
|
|
|
2015-03-02 13:28:12 +00:00
|
|
|
/* compute priority */
|
2017-12-13 17:27:32 +00:00
|
|
|
prio = tbf_compute_priority(bts, tbf, ts, fn, age);
|
|
|
|
if (prio == DL_PRIO_NONE)
|
2015-03-20 13:26:05 +00:00
|
|
|
continue;
|
2015-03-02 13:28:12 +00:00
|
|
|
|
Implement downgrade to DL MCS1-4 when USF for GPRS_only MS
In previous status, if USF for GPRS-only MS was selected, then EGPRS
TBFs were skipped and either a GPRS TBF was selected or a Dummy Block
was sent. That means the behavior was unfair towards EGPRS TBFs, because
sometimes they were skipped in favor of GPRS ones.
This patch imporves the situation in the above mentioned USF scenario, by
first, under specific conditions, allowing selection of an EGPRS TBF and
then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the
USF-targeted MS can still decode the USF, while at the same time
providing more fairness by allowing the EGPRS TBF to transmit data.
The specific conditions mentioned above are, mainly, related to the fact
that once a DL data block has been sent, and hence a BSN was assigned to
it, it cannot be retransmitted later using another MCS, since lower
MCS1-4 wouldn't be able to contain higher MCS RLC payload.
The set of conditions could be expanded in the future by also selecting
the EGPRS TBF if retransmition is required and the block to be
retransmitted was originally transmitted as MCS1-4.
Related: OS#4544
Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-11-16 17:49:39 +00:00
|
|
|
/* If a GPRS (CS1-4/MCS1-4) Dl block is required, downgrade MCS
|
|
|
|
* below instead of skipping. However, downgrade can only be
|
|
|
|
* done on new data BSNs (not yet sent) and control blocks. */
|
2021-01-25 16:30:31 +00:00
|
|
|
if (req_mcs_kind == EGPRS_GMSK && !can_produce_gmsk_data_block_next(tbf, prio)) {
|
2021-03-03 19:52:19 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "FN=%" PRIu32
|
|
|
|
" Cannot downgrade EGPRS TBF with prio %d for %s\n",
|
|
|
|
fn, prio, tbf_name(tbf));
|
Implement downgrade to DL MCS1-4 when USF for GPRS_only MS
In previous status, if USF for GPRS-only MS was selected, then EGPRS
TBFs were skipped and either a GPRS TBF was selected or a Dummy Block
was sent. That means the behavior was unfair towards EGPRS TBFs, because
sometimes they were skipped in favor of GPRS ones.
This patch imporves the situation in the above mentioned USF scenario, by
first, under specific conditions, allowing selection of an EGPRS TBF and
then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the
USF-targeted MS can still decode the USF, while at the same time
providing more fairness by allowing the EGPRS TBF to transmit data.
The specific conditions mentioned above are, mainly, related to the fact
that once a DL data block has been sent, and hence a BSN was assigned to
it, it cannot be retransmitted later using another MCS, since lower
MCS1-4 wouldn't be able to contain higher MCS RLC payload.
The set of conditions could be expanded in the future by also selecting
the EGPRS TBF if retransmition is required and the block to be
retransmitted was originally transmitted as MCS1-4.
Related: OS#4544
Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-11-16 17:49:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-03-02 13:28:12 +00:00
|
|
|
/* get the TBF with the highest priority */
|
|
|
|
if (prio > max_prio) {
|
|
|
|
prio_tfi = tfi;
|
|
|
|
prio_tbf = tbf;
|
|
|
|
max_prio = prio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prio_tbf) {
|
2021-03-03 19:52:19 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "FN=%" PRIu32
|
|
|
|
" Scheduling data message at RTS for DL TFI=%d prio=%d mcs_mode_restrict=%s\n",
|
|
|
|
fn, prio_tfi, max_prio, mode_name(req_mcs_kind));
|
2013-10-27 09:38:31 +00:00
|
|
|
/* next TBF to handle resource is the next one */
|
2015-03-02 13:28:12 +00:00
|
|
|
pdch->next_dl_tfi = (prio_tfi + 1) & 31;
|
2012-07-25 06:38:21 +00:00
|
|
|
/* generate DL data block */
|
Implement downgrade to DL MCS1-4 when USF for GPRS_only MS
In previous status, if USF for GPRS-only MS was selected, then EGPRS
TBFs were skipped and either a GPRS TBF was selected or a Dummy Block
was sent. That means the behavior was unfair towards EGPRS TBFs, because
sometimes they were skipped in favor of GPRS ones.
This patch imporves the situation in the above mentioned USF scenario, by
first, under specific conditions, allowing selection of an EGPRS TBF and
then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the
USF-targeted MS can still decode the USF, while at the same time
providing more fairness by allowing the EGPRS TBF to transmit data.
The specific conditions mentioned above are, mainly, related to the fact
that once a DL data block has been sent, and hence a BSN was assigned to
it, it cannot be retransmitted later using another MCS, since lower
MCS1-4 wouldn't be able to contain higher MCS RLC payload.
The set of conditions could be expanded in the future by also selecting
the EGPRS TBF if retransmition is required and the block to be
retransmitted was originally transmitted as MCS1-4.
Related: OS#4544
Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-11-16 17:49:39 +00:00
|
|
|
msg = prio_tbf->create_dl_acked_block(fn, ts, req_mcs_kind);
|
2021-01-25 10:31:57 +00:00
|
|
|
*is_egprs = prio_tbf->is_egprs_enabled();
|
2012-07-20 09:19:59 +00:00
|
|
|
}
|
2012-06-27 13:36:27 +00:00
|
|
|
|
2012-07-25 06:38:21 +00:00
|
|
|
return msg;
|
|
|
|
}
|
2013-11-23 22:03:14 +00:00
|
|
|
|
|
|
|
static const uint8_t rlcmac_dl_idle[23] = {
|
2012-07-25 06:38:21 +00:00
|
|
|
0x47, /* control without optional header octets, no polling, USF=111 */
|
|
|
|
0x94, /* dummy downlink control message, paging mode 00 */
|
|
|
|
0x2b, /* no persistance level, 7 bits spare pattern */
|
|
|
|
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b,
|
|
|
|
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
|
|
|
|
};
|
|
|
|
|
2013-11-23 22:03:14 +00:00
|
|
|
static struct msgb *sched_dummy(void)
|
2012-07-25 06:38:21 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg;
|
|
|
|
|
|
|
|
msg = msgb_alloc(23, "rlcmac_dl_idle");
|
|
|
|
if (!msg)
|
|
|
|
return NULL;
|
|
|
|
memcpy(msgb_put(msg, 23), rlcmac_dl_idle, 23);
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2021-01-14 15:48:38 +00:00
|
|
|
static inline void tap_n_acc(const struct msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
|
2017-08-31 13:42:06 +00:00
|
|
|
uint32_t fn, enum pcu_gsmtap_category cat)
|
|
|
|
{
|
|
|
|
if (!msg)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(cat) {
|
|
|
|
case PCU_GSMTAP_C_DL_CTRL:
|
2021-01-14 15:48:38 +00:00
|
|
|
bts_do_rate_ctr_inc(bts, CTR_RLC_SENT_CONTROL);
|
|
|
|
bts_send_gsmtap(bts, PCU_GSMTAP_C_DL_CTRL, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data,
|
2017-08-31 13:42:06 +00:00
|
|
|
msg->len);
|
|
|
|
break;
|
|
|
|
case PCU_GSMTAP_C_DL_DATA_GPRS:
|
2020-11-16 13:25:06 +00:00
|
|
|
case PCU_GSMTAP_C_DL_DATA_EGPRS:
|
2021-01-14 15:48:38 +00:00
|
|
|
bts_do_rate_ctr_inc(bts, CTR_RLC_SENT);
|
|
|
|
bts_send_gsmtap(bts, cat, false, trx, ts, GSMTAP_CHANNEL_PDTCH, fn, msg->data,
|
2017-08-31 13:42:06 +00:00
|
|
|
msg->len);
|
|
|
|
break;
|
|
|
|
case PCU_GSMTAP_C_DL_DUMMY:
|
2021-01-14 15:48:38 +00:00
|
|
|
bts_do_rate_ctr_inc(bts, CTR_RLC_SENT_DUMMY);
|
|
|
|
bts_send_gsmtap(bts, PCU_GSMTAP_C_DL_DUMMY, false, trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data,
|
2017-08-31 13:42:06 +00:00
|
|
|
msg->len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-17 16:12:18 +00:00
|
|
|
int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
|
2016-07-20 11:05:05 +00:00
|
|
|
uint8_t trx, uint8_t ts,
|
2012-07-25 06:38:21 +00:00
|
|
|
uint32_t fn, uint8_t block_nr)
|
|
|
|
{
|
|
|
|
struct gprs_rlcmac_pdch *pdch;
|
2020-12-15 17:46:33 +00:00
|
|
|
struct tbf_sched_candidates tbf_cand = {0};
|
2021-03-11 15:59:50 +00:00
|
|
|
struct gprs_rlcmac_tbf *poll_tbf;
|
2021-03-24 11:40:18 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *usf_tbf = NULL;
|
2021-03-11 15:59:50 +00:00
|
|
|
struct gprs_rlcmac_sba *sba;
|
2020-11-16 16:35:10 +00:00
|
|
|
uint8_t usf;
|
2012-07-25 06:38:21 +00:00
|
|
|
struct msgb *msg = NULL;
|
2021-03-11 15:59:50 +00:00
|
|
|
uint32_t poll_fn;
|
2020-11-16 13:23:29 +00:00
|
|
|
enum pcu_gsmtap_category gsmtap_cat;
|
2020-11-16 16:35:10 +00:00
|
|
|
bool tx_is_egprs = false;
|
|
|
|
bool require_gprs_only;
|
|
|
|
enum mcs_kind req_mcs_kind; /* Restrict CS/MCS if DL Data block is to be sent */
|
2012-07-25 06:38:21 +00:00
|
|
|
|
|
|
|
if (trx >= 8 || ts >= 8)
|
|
|
|
return -EINVAL;
|
|
|
|
pdch = &bts->trx[trx].pdch[ts];
|
|
|
|
|
2013-10-19 15:37:48 +00:00
|
|
|
if (!pdch->is_enabled()) {
|
2012-07-25 06:38:21 +00:00
|
|
|
LOGP(DRLCMACSCHED, LOGL_ERROR, "Received RTS on disabled PDCH: "
|
|
|
|
"TRX=%d TS=%d\n", trx, ts);
|
|
|
|
return -EIO;
|
2012-06-27 13:36:27 +00:00
|
|
|
}
|
|
|
|
|
2012-07-25 06:38:21 +00:00
|
|
|
/* store last frame number of RTS */
|
|
|
|
pdch->last_rts_fn = fn;
|
|
|
|
|
2020-11-16 16:35:10 +00:00
|
|
|
/* require_gprs_only: Prioritize USF for GPRS-only MS here,
|
|
|
|
* since anyway we'll need to tx a Dl block with CS1-4 due to
|
|
|
|
* synchronization requirements. See 3GPP TS 03.64 version
|
|
|
|
* 8.12.0
|
|
|
|
*/
|
|
|
|
require_gprs_only = (pdch->fn_without_cs14 == MS_RESYNC_NUM_FRAMES - 1);
|
|
|
|
if (require_gprs_only) {
|
|
|
|
LOGP(DRLCMACSCHED, LOGL_DEBUG, "TRX=%d TS=%d FN=%d "
|
|
|
|
"synchronization frame (every 18 frames), only CS1-4 allowed",
|
|
|
|
trx, ts, fn);
|
|
|
|
req_mcs_kind = GPRS; /* only GPRS CS1-4 allowed, all MS need to be able to decode it */
|
|
|
|
} else {
|
|
|
|
req_mcs_kind = EGPRS; /* all kinds are fine */
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:59:50 +00:00
|
|
|
/* polling for next uplink block */
|
|
|
|
poll_fn = rts_next_fn(fn, block_nr);
|
2021-03-24 12:14:09 +00:00
|
|
|
/* check for sba */
|
|
|
|
if ((sba = pdch_ulc_get_sba(pdch->ulc, poll_fn))) {
|
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: "
|
|
|
|
"FN=%d block_nr=%d scheduling free USF for "
|
|
|
|
"single block allocation at FN=%d\n", fn, block_nr, sba->fn);
|
|
|
|
/* else, check uplink resource for polling */
|
|
|
|
} else if ((poll_tbf = pdch_ulc_get_tbf_poll(pdch->ulc, poll_fn))) {
|
2021-05-11 12:04:33 +00:00
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: FN=%d "
|
|
|
|
"block_nr=%d scheduling free USF for polling at FN=%d of %s\n",
|
|
|
|
fn, block_nr, poll_fn, tbf_name(poll_tbf));
|
2021-03-24 12:14:09 +00:00
|
|
|
/* If POLL TBF is UL and already has a USF assigned on this TS,
|
|
|
|
* let's set its USF in the DL msg. This is not really needed,
|
|
|
|
* but it helps understand better the flow when looking at
|
|
|
|
* pcaps. */
|
|
|
|
if (poll_tbf->direction == GPRS_RLCMAC_UL_TBF && as_ul_tbf(poll_tbf)->m_usf[ts] != USF_INVALID)
|
|
|
|
usf_tbf = as_ul_tbf(poll_tbf);
|
|
|
|
/* else, search for uplink tbf */
|
2021-05-11 12:04:33 +00:00
|
|
|
} else if ((usf_tbf = sched_select_uplink(pdch, require_gprs_only))) {
|
|
|
|
LOGPDCH(pdch, DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: FN=%d "
|
|
|
|
"block_nr=%d scheduling USF=%d for %s, expect answer on UL FN=%d\n",
|
|
|
|
fn, block_nr, usf_tbf->m_usf[pdch->ts_no], tbf_name(usf_tbf), poll_fn);
|
2021-03-24 13:06:15 +00:00
|
|
|
pdch_ulc_reserve_tbf_usf(pdch->ulc, poll_fn, usf_tbf);
|
2020-11-16 16:35:10 +00:00
|
|
|
}
|
2021-03-24 12:14:09 +00:00
|
|
|
/* If MS selected for USF is GPRS-only, then it will only be
|
|
|
|
* able to read USF if dl block uses GMSK * (CS1-4, MCS1-4) */
|
|
|
|
if (usf_tbf && req_mcs_kind == EGPRS && ms_mode(usf_tbf->ms()) != EGPRS)
|
|
|
|
req_mcs_kind = EGPRS_GMSK;
|
2012-07-25 06:38:21 +00:00
|
|
|
|
2021-05-13 16:39:36 +00:00
|
|
|
get_ctrl_msg_tbf_candidates(pdch, &tbf_cand);
|
2021-03-11 15:59:50 +00:00
|
|
|
|
2012-07-25 06:38:21 +00:00
|
|
|
/* Prio 1: select control message */
|
2021-03-03 19:47:07 +00:00
|
|
|
if ((msg = sched_select_ctrl_msg(pdch, fn, block_nr, &tbf_cand))) {
|
2020-11-16 16:35:10 +00:00
|
|
|
gsmtap_cat = PCU_GSMTAP_C_DL_CTRL;
|
|
|
|
}
|
2012-07-25 06:38:21 +00:00
|
|
|
/* Prio 2: select data message for downlink */
|
2021-03-03 19:52:19 +00:00
|
|
|
else if((msg = sched_select_downlink(bts, pdch, fn, block_nr, req_mcs_kind, &tx_is_egprs))) {
|
2020-11-16 16:35:10 +00:00
|
|
|
gsmtap_cat = tx_is_egprs ? PCU_GSMTAP_C_DL_DATA_EGPRS :
|
|
|
|
PCU_GSMTAP_C_DL_DATA_GPRS;
|
2016-05-18 14:41:03 +00:00
|
|
|
}
|
2012-06-27 13:36:27 +00:00
|
|
|
/* Prio 3: send dummy contol message */
|
2020-11-16 16:35:10 +00:00
|
|
|
else if ((msg = sched_dummy())) {
|
2016-05-18 14:43:10 +00:00
|
|
|
/* increase counter */
|
2020-11-16 13:23:29 +00:00
|
|
|
gsmtap_cat = PCU_GSMTAP_C_DL_DUMMY;
|
2020-11-16 16:35:10 +00:00
|
|
|
} else {
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx_is_egprs && pdch->has_gprs_only_tbf_attached()) {
|
|
|
|
pdch->fn_without_cs14 += 1;
|
|
|
|
} else {
|
|
|
|
pdch->fn_without_cs14 = 0;
|
2016-05-18 14:43:10 +00:00
|
|
|
}
|
2012-07-25 06:38:21 +00:00
|
|
|
|
2012-06-27 13:36:27 +00:00
|
|
|
/* msg is now available */
|
2021-01-14 15:48:38 +00:00
|
|
|
bts_do_rate_ctr_add(bts, CTR_RLC_DL_BYTES, msg->data_len);
|
2012-06-27 13:36:27 +00:00
|
|
|
|
|
|
|
/* set USF */
|
2015-12-28 13:10:14 +00:00
|
|
|
OSMO_ASSERT(msgb_length(msg) > 0);
|
2021-03-24 11:40:18 +00:00
|
|
|
usf = usf_tbf ? usf_tbf->m_usf[ts] : USF_UNUSED;
|
2012-06-27 13:36:27 +00:00
|
|
|
msg->data[0] = (msg->data[0] & 0xf8) | usf;
|
|
|
|
|
2015-09-07 16:49:00 +00:00
|
|
|
/* Used to measure the leak rate, count all blocks */
|
|
|
|
gprs_bssgp_update_frames_sent();
|
|
|
|
|
2020-11-16 13:23:29 +00:00
|
|
|
/* Send to GSMTAP */
|
|
|
|
tap_n_acc(msg, bts, trx, ts, fn, gsmtap_cat);
|
|
|
|
|
2012-06-27 13:36:27 +00:00
|
|
|
/* send PDTCH/PACCH to L1 */
|
2021-01-18 16:14:14 +00:00
|
|
|
pcu_l1if_tx_pdtch(msg, bts, trx, ts, bts->trx[trx].arfcn, fn, block_nr);
|
2012-06-27 13:36:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|