2012-03-05 15:24:57 +00:00
|
|
|
/* gprs_bssgp_pcu.cpp
|
2012-02-04 22:27:17 +00:00
|
|
|
*
|
2012-03-05 15:24:57 +00:00
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
2013-08-22 06:44:04 +00:00
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
2012-02-04 22:27:17 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
#include <gprs_rlcmac.h>
|
|
|
|
#include <gprs_bssgp_pcu.h>
|
2021-01-21 17:44:23 +00:00
|
|
|
#include <gprs_bssgp_rim.h>
|
2012-03-05 15:24:57 +00:00
|
|
|
#include <pcu_l1_if.h>
|
2018-01-26 12:31:42 +00:00
|
|
|
#include <gprs_debug.h>
|
2013-10-17 15:01:54 +00:00
|
|
|
#include <bts.h>
|
2013-08-24 16:31:27 +00:00
|
|
|
#include <tbf.h>
|
2020-05-18 09:35:35 +00:00
|
|
|
#include <coding_scheme.h>
|
2018-02-19 16:17:28 +00:00
|
|
|
#include <pdch.h>
|
2020-01-23 11:37:15 +00:00
|
|
|
#include <decoding.h>
|
2019-03-05 13:59:03 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
#include <osmocom/gprs/gprs_ns2.h>
|
|
|
|
#include <osmocom/gsm/protocol/gsm_23_003.h>
|
|
|
|
#include <osmocom/gprs/protocol/gsm_08_16.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
2021-07-05 09:11:42 +00:00
|
|
|
#include <osmocom/core/stats.h>
|
2021-01-18 16:14:14 +00:00
|
|
|
#include <osmocom/gsm/gsm48.h>
|
|
|
|
#include "coding_scheme.h"
|
|
|
|
#include "tbf_dl.h"
|
|
|
|
#include "llc.h"
|
|
|
|
#include "gprs_rlcmac.h"
|
2012-02-04 22:27:17 +00:00
|
|
|
|
2015-04-30 13:01:15 +00:00
|
|
|
/* Tuning parameters for BSSGP flow control */
|
|
|
|
#define FC_DEFAULT_LIFE_TIME_SECS 10 /* experimental value, 10s */
|
|
|
|
#define FC_MS_BUCKET_SIZE_BY_BMAX(bmax) ((bmax) / 2 + 500) /* experimental */
|
|
|
|
#define FC_FALLBACK_BVC_BUCKET_SIZE 2000 /* e.g. on R = 0, value taken from PCAP files */
|
|
|
|
#define FC_MS_MAX_RX_SLOTS 4 /* limit MS default R to 4 TS per MS */
|
|
|
|
|
|
|
|
/* Constants for BSSGP flow control */
|
|
|
|
#define FC_MAX_BUCKET_LEAK_RATE (6553500 / 8) /* Byte/s */
|
|
|
|
#define FC_MAX_BUCKET_SIZE 6553500 /* Octets */
|
|
|
|
|
2013-01-16 12:49:00 +00:00
|
|
|
extern void *tall_pcu_ctx;
|
2012-07-06 06:58:22 +00:00
|
|
|
extern uint16_t spoof_mcc, spoof_mnc;
|
2018-02-20 23:39:07 +00:00
|
|
|
extern bool spoof_mnc_3_digits;
|
2012-02-04 22:27:17 +00:00
|
|
|
|
2021-07-05 09:11:42 +00:00
|
|
|
static const struct rate_ctr_desc sgsn_ctr_description[] = {
|
|
|
|
[SGSN_CTR_RX_PAGING_CS] = { "rx_paging_cs", "Amount of paging CS requests received" },
|
|
|
|
[SGSN_CTR_RX_PAGING_PS] = { "rx_paging_ps", "Amount of paging PS requests received" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct rate_ctr_group_desc sgsn_ctrg_desc = {
|
|
|
|
.group_name_prefix = "pcu:sgsn",
|
|
|
|
.group_description = "SGSN Statistics",
|
|
|
|
.class_id = OSMO_STATS_CLASS_SUBSCRIBER,
|
|
|
|
.num_ctr = ARRAY_SIZE(sgsn_ctr_description),
|
|
|
|
.ctr_desc = sgsn_ctr_description,
|
|
|
|
};
|
|
|
|
|
2012-09-23 04:41:21 +00:00
|
|
|
static void bvc_timeout(void *_priv);
|
|
|
|
|
2016-01-20 11:22:07 +00:00
|
|
|
static int parse_ra_cap(struct tlv_parsed *tp, MS_Radio_Access_capability_t *rac)
|
2013-07-13 13:23:58 +00:00
|
|
|
{
|
2021-01-18 16:14:14 +00:00
|
|
|
struct bitvec *block;
|
2013-07-13 13:23:58 +00:00
|
|
|
uint8_t cap_len;
|
|
|
|
uint8_t *cap;
|
|
|
|
|
2016-01-20 11:22:07 +00:00
|
|
|
memset(rac, 0, sizeof(*rac));
|
|
|
|
|
2013-07-13 13:23:58 +00:00
|
|
|
if (!TLVP_PRESENT(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP))
|
2016-01-20 11:22:07 +00:00
|
|
|
return -EINVAL;
|
2013-07-13 13:23:58 +00:00
|
|
|
|
|
|
|
cap_len = TLVP_LEN(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP);
|
|
|
|
cap = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_MS_RADIO_ACCESS_CAP);
|
|
|
|
|
2016-01-20 11:22:07 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Got BSSGP RA Capability of size %d\n", cap_len);
|
|
|
|
|
2017-02-04 02:10:08 +00:00
|
|
|
block = bitvec_alloc(cap_len, tall_pcu_ctx);
|
2013-07-13 13:23:58 +00:00
|
|
|
bitvec_unpack(block, cap);
|
2016-01-20 11:22:07 +00:00
|
|
|
|
|
|
|
/* TS 24.008, 10.5.5.12a */
|
|
|
|
decode_gsm_ra_cap(block, rac);
|
2013-07-13 13:23:58 +00:00
|
|
|
|
|
|
|
bitvec_free(block);
|
2016-01-20 11:22:07 +00:00
|
|
|
return 0;
|
2013-07-13 13:23:58 +00:00
|
|
|
}
|
|
|
|
|
2013-07-28 19:14:15 +00:00
|
|
|
static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp)
|
2012-02-04 22:27:17 +00:00
|
|
|
{
|
2012-03-05 15:24:57 +00:00
|
|
|
struct bssgp_ud_hdr *budh;
|
|
|
|
|
2012-07-03 11:36:03 +00:00
|
|
|
uint32_t tlli;
|
TLLI 0x00000000 is a valid TLLI, use 0xffffffff instead
The assumption that TLLI 0x00000000 is invalid and can be used
as the initializer is wrong. Similar to TMSI, 0x00000000 is a
perfectly valid value, while 0xffffffff is reserved - use it.
According to 3GPP TS 23.003, section 2.4, a TMSI/P-TMSI with
all 32 bits equal to 1 is special and shall not be allocated by
the network. The reason is that it must be stored on the SIM,
where 'ff'O represents the erased state. According to section
2.6 of the same document, a local/foreign TLLI is derived from
P-TMSI, so the same rule applies to TLLI.
I manually checked and corrected all occurances of 'tlli' in the
code. The test expectations have been adjusted with this command:
$ find tests/ -name "*.err" | xargs sed -i "s/0x00000000/0xffffffff/g"
so there should be no behavior change. The only exception is
the 'TypesTest', where TLLI 0xffffffff is being encoded and
expected in the hexdump, so I regenerated the test output.
Change-Id: Ie89fab75ecc1d8b5e238d3ff214ea7ac830b68b5
Related: OS#4844
2020-11-08 06:27:35 +00:00
|
|
|
uint32_t tlli_old = GSM_RESERVED_TMSI;
|
2012-07-03 11:36:03 +00:00
|
|
|
uint8_t *data;
|
|
|
|
uint16_t len;
|
2016-01-20 11:22:07 +00:00
|
|
|
uint8_t ms_class = 0;
|
|
|
|
uint8_t egprs_ms_class = 0;
|
2019-07-24 09:44:13 +00:00
|
|
|
int rc;
|
2016-01-20 11:22:07 +00:00
|
|
|
MS_Radio_Access_capability_t rac;
|
2020-08-21 13:44:58 +00:00
|
|
|
/* TODO: is it really necessary to initialize this as a "000" IMSI? It seems, the function should just return an
|
|
|
|
* error if no IMSI IE was found. */
|
|
|
|
struct osmo_mobile_identity mi_imsi = {
|
|
|
|
.type = GSM_MI_TYPE_TMSI,
|
|
|
|
};
|
|
|
|
OSMO_STRLCPY_ARRAY(mi_imsi.imsi, "000");
|
2012-06-25 07:26:15 +00:00
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
budh = (struct bssgp_ud_hdr *)msgb_bssgph(msg);
|
2012-07-03 11:36:03 +00:00
|
|
|
tlli = ntohl(budh->tlli);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2012-06-12 11:33:52 +00:00
|
|
|
/* LLC_PDU is mandatory IE */
|
|
|
|
if (!TLVP_PRESENT(tp, BSSGP_IE_LLC_PDU))
|
2012-02-20 11:15:12 +00:00
|
|
|
{
|
2012-07-06 09:04:57 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP TLLI=0x%08x Rx UL-UD missing mandatory IE\n", tlli);
|
2012-06-12 11:33:52 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
|
|
|
|
}
|
2012-06-06 21:51:49 +00:00
|
|
|
|
2012-07-03 11:36:03 +00:00
|
|
|
data = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_LLC_PDU);
|
|
|
|
len = TLVP_LEN(tp, BSSGP_IE_LLC_PDU);
|
2020-02-03 09:38:51 +00:00
|
|
|
if (len > LLC_MAX_LEN)
|
2012-06-12 11:33:52 +00:00
|
|
|
{
|
2012-07-06 09:04:57 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP TLLI=0x%08x Rx UL-UD IE_LLC_PDU too large\n", tlli);
|
2012-07-03 11:36:03 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg);
|
2012-02-20 11:15:12 +00:00
|
|
|
}
|
2012-06-12 11:33:52 +00:00
|
|
|
|
2012-07-09 15:10:44 +00:00
|
|
|
/* read IMSI. if no IMSI exists, use first paging block (any paging),
|
|
|
|
* because during attachment the IMSI might not be known, so the MS
|
|
|
|
* will listen to all paging blocks. */
|
2019-07-24 09:36:45 +00:00
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_IMSI))
|
|
|
|
{
|
2020-08-21 13:44:58 +00:00
|
|
|
rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI),
|
|
|
|
true);
|
2020-08-26 11:41:45 +00:00
|
|
|
if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_IMSI) {
|
2019-07-24 09:44:13 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg);
|
|
|
|
}
|
2019-07-24 09:36:45 +00:00
|
|
|
}
|
2012-07-13 12:52:50 +00:00
|
|
|
|
|
|
|
/* parse ms radio access capability */
|
2016-01-20 11:22:07 +00:00
|
|
|
if (parse_ra_cap(tp, &rac) >= 0) {
|
|
|
|
/* Get the EGPRS class from the RA capability */
|
2021-01-18 16:14:14 +00:00
|
|
|
ms_class = get_ms_class_by_capability(&rac);
|
|
|
|
egprs_ms_class = get_egprs_ms_class_by_capability(&rac);
|
2016-01-20 11:22:07 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Got downlink MS class %d/%d\n",
|
|
|
|
ms_class, egprs_ms_class);
|
|
|
|
}
|
2013-07-13 13:23:58 +00:00
|
|
|
|
2012-07-21 09:09:58 +00:00
|
|
|
/* get lifetime */
|
|
|
|
uint16_t delay_csec = 0xffff;
|
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_PDU_LIFETIME))
|
|
|
|
{
|
|
|
|
uint8_t lt_len = TLVP_LEN(tp, BSSGP_IE_PDU_LIFETIME);
|
|
|
|
if (lt_len == 2)
|
2017-06-11 09:27:59 +00:00
|
|
|
delay_csec = tlvp_val16be(tp, BSSGP_IE_PDU_LIFETIME);
|
2012-07-21 09:09:58 +00:00
|
|
|
else
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP invalid length of "
|
|
|
|
"PDU_LIFETIME IE\n");
|
|
|
|
} else
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP missing mandatory "
|
|
|
|
"PDU_LIFETIME IE\n");
|
|
|
|
|
2015-05-15 13:50:43 +00:00
|
|
|
/* get optional TLLI old */
|
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_TLLI))
|
|
|
|
{
|
|
|
|
uint8_t tlli_len = TLVP_LEN(tp, BSSGP_IE_PDU_LIFETIME);
|
|
|
|
if (tlli_len == 2)
|
2017-06-11 09:27:59 +00:00
|
|
|
tlli_old = tlvp_val16be(tp, BSSGP_IE_TLLI);
|
2015-05-15 13:50:43 +00:00
|
|
|
else
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "BSSGP invalid length of "
|
|
|
|
"TLLI (old) IE\n");
|
|
|
|
}
|
|
|
|
|
2020-08-21 13:44:58 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "LLC [SGSN -> PCU] = TLLI: 0x%08x IMSI: %s len: %d\n", tlli, mi_imsi.imsi, len);
|
2012-06-17 04:30:06 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
return dl_tbf_handle(the_pcu->bssgp.bts, tlli, tlli_old, mi_imsi.imsi,
|
2015-11-27 17:10:39 +00:00
|
|
|
ms_class, egprs_ms_class, delay_csec, data, len);
|
2012-06-29 18:53:15 +00:00
|
|
|
}
|
2012-06-17 04:30:06 +00:00
|
|
|
|
Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).
The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.
This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).
In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.
Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-13 15:44:51 +00:00
|
|
|
/* 3GPP TS 48.018 Table 10.3.2. Returns 0 on success, suggested BSSGP cause otherwise */
|
|
|
|
static unsigned int get_paging_cs_mi(struct paging_req_cs *req, const struct tlv_parsed *tp)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
req->chan_needed = tlvp_val8(tp, BSSGP_IE_CHAN_NEEDED, 0);
|
|
|
|
|
|
|
|
if (!TLVP_PRESENT(tp, BSSGP_IE_IMSI)) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "IMSI Mobile Identity mandatory IE not found\n");
|
|
|
|
return BSSGP_CAUSE_MISSING_MAND_IE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = osmo_mobile_identity_decode(&req->mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI),
|
|
|
|
TLVP_LEN(tp, BSSGP_IE_IMSI), true);
|
|
|
|
if (rc < 0 || req->mi_imsi.type != GSM_MI_TYPE_IMSI) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Invalid IMSI Mobile Identity\n");
|
|
|
|
return BSSGP_CAUSE_INV_MAND_INF;
|
|
|
|
}
|
|
|
|
req->mi_imsi_present = true;
|
|
|
|
|
2021-05-21 11:44:02 +00:00
|
|
|
/* TMSI is optional */
|
Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).
The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.
This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).
In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.
Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-13 15:44:51 +00:00
|
|
|
req->mi_tmsi_present = false;
|
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_TMSI)) {
|
|
|
|
/* Be safe against an evil SGSN - check the length */
|
|
|
|
if (TLVP_LEN(tp, BSSGP_IE_TMSI) != GSM23003_TMSI_NUM_BYTES) {
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "TMSI IE has odd length (!= 4)\n");
|
|
|
|
return BSSGP_CAUSE_COND_IE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: TMSI (unlike IMSI) IE comes without MI type header */
|
|
|
|
req->mi_tmsi = (struct osmo_mobile_identity){
|
|
|
|
.type = GSM_MI_TYPE_TMSI,
|
|
|
|
};
|
|
|
|
req->mi_tmsi.tmsi = osmo_load32be(TLVP_VAL(tp, BSSGP_IE_TMSI));
|
|
|
|
req->mi_tmsi_present = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_TLLI))
|
|
|
|
req->tlli = osmo_load32be(TLVP_VAL(tp, BSSGP_IE_TLLI));
|
|
|
|
else
|
|
|
|
req->tlli = GSM_RESERVED_TMSI;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gprs_bssgp_pcu_rx_paging_cs(struct msgb *msg, const struct tlv_parsed *tp)
|
|
|
|
{
|
|
|
|
struct paging_req_cs req;
|
|
|
|
struct gprs_rlcmac_bts *bts;
|
|
|
|
struct GprsMs *ms;
|
|
|
|
int rc;
|
|
|
|
|
2021-07-05 09:11:42 +00:00
|
|
|
rate_ctr_inc(rate_ctr_group_get_ctr(the_pcu->bssgp.ctrs, SGSN_CTR_RX_PAGING_CS));
|
|
|
|
|
Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).
The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.
This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).
In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.
Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-13 15:44:51 +00:00
|
|
|
if ((rc = get_paging_cs_mi(&req, tp)) > 0)
|
|
|
|
return bssgp_tx_status((enum gprs_bssgp_cause) rc, NULL, msg);
|
|
|
|
|
|
|
|
/* We need to page all BTSs since even if a BTS has a matching MS, it
|
|
|
|
* may have already moved to a newer BTS. On Each BTS, if the MS is
|
|
|
|
* known, then bts_add_paging() can optimize and page only on PDCHs the
|
|
|
|
* target MS is using. */
|
|
|
|
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
|
|
|
|
/* TODO: Match by TMSI before IMSI if present?! */
|
|
|
|
ms = bts_ms_by_tlli(bts, req.tlli, req.tlli);
|
|
|
|
if (!ms && req.mi_imsi_present)
|
|
|
|
ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi);
|
|
|
|
bts_add_paging(bts, &req, ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-25 20:38:05 +00:00
|
|
|
/* Returns 0 on success, suggested BSSGP cause otherwise */
|
Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).
The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.
This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).
In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.
Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-13 15:44:51 +00:00
|
|
|
static unsigned int get_paging_ps_mi(struct osmo_mobile_identity *mi, const struct tlv_parsed *tp)
|
2019-12-10 18:29:22 +00:00
|
|
|
{
|
2020-03-25 20:38:05 +00:00
|
|
|
/* Use TMSI (if present) or IMSI */
|
2019-12-10 18:29:22 +00:00
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_TMSI)) {
|
2020-03-25 20:38:05 +00:00
|
|
|
/* Be safe against an evil SGSN - check the length */
|
|
|
|
if (TLVP_LEN(tp, BSSGP_IE_TMSI) != GSM23003_TMSI_NUM_BYTES) {
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "TMSI IE has odd length (!= 4)\n");
|
|
|
|
return BSSGP_CAUSE_COND_IE_ERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: TMSI (unlike IMSI) IE comes without MI type header */
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
*mi = (struct osmo_mobile_identity){
|
|
|
|
.type = GSM_MI_TYPE_TMSI,
|
|
|
|
};
|
|
|
|
mi->tmsi = osmo_load32be(TLVP_VAL(tp, BSSGP_IE_TMSI));
|
2020-03-25 20:38:05 +00:00
|
|
|
} else if (TLVP_PRESENT(tp, BSSGP_IE_IMSI)) {
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
int rc = osmo_mobile_identity_decode(mi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI),
|
|
|
|
true);
|
|
|
|
if (rc < 0 || mi->type != GSM_MI_TYPE_IMSI) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Invalid IMSI Mobile Identity\n");
|
|
|
|
return BSSGP_CAUSE_COND_IE_ERR;
|
|
|
|
}
|
2019-12-10 18:29:22 +00:00
|
|
|
} else {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Neither TMSI IE nor IMSI IE is present\n");
|
2020-03-25 20:38:05 +00:00
|
|
|
return BSSGP_CAUSE_MISSING_COND_IE;
|
2019-12-10 18:29:22 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 20:38:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-10-30 19:00:21 +00:00
|
|
|
static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, const struct tlv_parsed *tp)
|
2012-10-08 10:30:56 +00:00
|
|
|
{
|
2020-08-21 13:44:58 +00:00
|
|
|
struct osmo_mobile_identity mi_imsi;
|
paging: pass struct osmo_mobile_identity, not encoded IE bytes
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is
returned. Code paths following this repeatedly decode the Mobile Identity
bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in
from a different encoding than a typical Mobile Identity IE, the TMSI was
manually encoded into a typical Mobile Identity IE. This is essentially a code
dup of osmo_mobile_identity_encode(). Stop this madness.
Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code
paths after this use the struct osmo_mobile_identity directly without repeated
decoding.
At the point of finally needing an encoded Mobile Identity IE (in
Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode().
Since this may return errors, add an rc check for the caller of
write_paging_request(), gprs_rlcmac_paging_request().
A side effect is stricter validation of the Mobile Identity passing through the
Paging code path. Before, invalid MI might have passed through unnoticed.
Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21 14:21:23 +00:00
|
|
|
struct osmo_mobile_identity paging_mi;
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts *bts;
|
2019-12-23 11:41:34 +00:00
|
|
|
uint16_t pgroup;
|
2019-07-24 09:44:13 +00:00
|
|
|
int rc;
|
2012-10-08 10:30:56 +00:00
|
|
|
|
2021-07-05 09:11:42 +00:00
|
|
|
rate_ctr_inc(rate_ctr_group_get_ctr(the_pcu->bssgp.ctrs, SGSN_CTR_RX_PAGING_PS));
|
|
|
|
|
2019-03-19 14:39:05 +00:00
|
|
|
if (!TLVP_PRESENT(tp, BSSGP_IE_IMSI)) {
|
2012-10-08 10:30:56 +00:00
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "No IMSI\n");
|
2019-12-10 18:26:27 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
|
2012-10-08 10:30:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-21 13:44:58 +00:00
|
|
|
rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI), true);
|
|
|
|
if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_IMSI) {
|
2019-07-24 09:44:13 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);
|
2019-12-23 11:41:34 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
|
|
|
|
}
|
2020-08-21 13:44:58 +00:00
|
|
|
pgroup = imsi2paging_group(mi_imsi.imsi);
|
2019-12-23 11:41:34 +00:00
|
|
|
if (pgroup > 999) {
|
2020-08-21 13:44:58 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Failed to compute IMSI %s paging group\n", mi_imsi.imsi);
|
2019-12-23 11:41:34 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
|
2019-07-24 09:44:13 +00:00
|
|
|
}
|
2019-03-19 14:39:05 +00:00
|
|
|
|
Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).
The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.
This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).
In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.
Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-13 15:44:51 +00:00
|
|
|
if ((rc = get_paging_ps_mi(&paging_mi, tp)) > 0)
|
2020-03-25 20:38:05 +00:00
|
|
|
return bssgp_tx_status((enum gprs_bssgp_cause) rc, NULL, msg);
|
2019-12-10 18:26:27 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
/* FIXME: look if MS is attached a specific BTS and then only page on that one? */
|
|
|
|
llist_for_each_entry(bts, &the_pcu->bts_list, list) {
|
|
|
|
gprs_rlcmac_paging_request(bts, &paging_mi, pgroup);
|
|
|
|
}
|
|
|
|
return 0;
|
2012-10-08 10:30:56 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 22:27:17 +00:00
|
|
|
/* Receive a BSSGP PDU from a BSS on a PTP BVCI */
|
2013-07-28 19:14:15 +00:00
|
|
|
static int gprs_bssgp_pcu_rx_ptp(struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx)
|
2012-02-04 22:27:17 +00:00
|
|
|
{
|
|
|
|
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
|
2017-05-23 15:53:38 +00:00
|
|
|
enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
|
2017-07-29 08:16:44 +00:00
|
|
|
int bvci = bctx ? bctx->bvci : -1;
|
2012-02-04 22:27:17 +00:00
|
|
|
unsigned rc = 0;
|
|
|
|
|
2012-07-25 07:14:09 +00:00
|
|
|
if (!bctx)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-02-04 22:27:17 +00:00
|
|
|
/* If traffic is received on a BVC that is marked as blocked, the
|
|
|
|
* received PDU shall not be accepted and a STATUS PDU (Cause value:
|
|
|
|
* BVC Blocked) shall be sent to the peer entity on the signalling BVC */
|
|
|
|
if (bctx->state & BVC_S_BLOCKED && pdu_type != BSSGP_PDUT_STATUS)
|
|
|
|
{
|
|
|
|
uint16_t bvci = msgb_bvci(msg);
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "rx BVC_S_BLOCKED\n");
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, &bvci, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pdu_type) {
|
2017-07-29 08:16:44 +00:00
|
|
|
case BSSGP_PDUT_STATUS:
|
|
|
|
/* already handled in libosmogb */
|
|
|
|
OSMO_ASSERT(0);
|
|
|
|
break;
|
2012-02-04 22:27:17 +00:00
|
|
|
case BSSGP_PDUT_DL_UNITDATA:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) DL_UNITDATA\n", bvci);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.on_dl_unit_data)
|
|
|
|
the_pcu->bssgp.on_dl_unit_data(&the_pcu->bssgp, msg, tp);
|
2012-06-12 11:33:52 +00:00
|
|
|
gprs_bssgp_pcu_rx_dl_ud(msg, tp);
|
2012-02-04 22:27:17 +00:00
|
|
|
break;
|
2017-07-29 08:16:44 +00:00
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK:
|
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) %s\n",
|
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
2012-02-04 22:27:17 +00:00
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_PAGING_CS:
|
2019-12-10 18:31:25 +00:00
|
|
|
gprs_bssgp_pcu_rx_paging_cs(msg, tp);
|
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_PAGING_PS:
|
|
|
|
gprs_bssgp_pcu_rx_paging_ps(msg, tp);
|
|
|
|
break;
|
2017-07-29 08:16:44 +00:00
|
|
|
case BSSGP_PDUT_RA_CAPABILITY:
|
2012-02-04 22:27:17 +00:00
|
|
|
case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "Rx BSSGP BVCI=%d (PTP) PDU type %s not implemented\n",
|
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
2012-02-04 22:27:17 +00:00
|
|
|
break;
|
2017-07-29 08:16:44 +00:00
|
|
|
/* See TS 08.18 5.4.1 */
|
|
|
|
case BSSGP_PDUT_SUSPEND:
|
|
|
|
case BSSGP_PDUT_SUSPEND_ACK:
|
|
|
|
case BSSGP_PDUT_SUSPEND_NACK:
|
|
|
|
case BSSGP_PDUT_RESUME:
|
|
|
|
case BSSGP_PDUT_RESUME_ACK:
|
|
|
|
case BSSGP_PDUT_RESUME_NACK:
|
|
|
|
case BSSGP_PDUT_FLUSH_LL:
|
|
|
|
case BSSGP_PDUT_FLUSH_LL_ACK:
|
|
|
|
case BSSGP_PDUT_LLC_DISCARD:
|
|
|
|
case BSSGP_PDUT_BVC_BLOCK:
|
|
|
|
case BSSGP_PDUT_BVC_BLOCK_ACK:
|
|
|
|
case BSSGP_PDUT_BVC_UNBLOCK:
|
|
|
|
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
|
|
|
|
case BSSGP_PDUT_BVC_RESET:
|
|
|
|
case BSSGP_PDUT_BVC_RESET_ACK:
|
|
|
|
case BSSGP_PDUT_SGSN_INVOKE_TRACE:
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s unexpected at PTP\n",
|
|
|
|
bctx->bvci, bssgp_pdu_str(pdu_type));
|
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
|
2012-02-04 22:27:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s unknown\n",
|
2017-05-25 17:05:32 +00:00
|
|
|
bctx->bvci, bssgp_pdu_str(pdu_type));
|
2012-02-04 22:27:17 +00:00
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Receive a BSSGP PDU from a SGSN on a SIGNALLING BVCI */
|
2013-07-28 19:14:15 +00:00
|
|
|
static int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx)
|
2012-02-04 22:27:17 +00:00
|
|
|
{
|
|
|
|
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
|
2017-05-23 15:53:38 +00:00
|
|
|
enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
|
2012-02-04 22:27:17 +00:00
|
|
|
int rc = 0;
|
2019-11-07 21:18:46 +00:00
|
|
|
int bvci = bctx ? bctx->bvci : msgb_bvci(msg);
|
2017-05-23 15:53:38 +00:00
|
|
|
switch (pdu_type) {
|
2012-02-04 22:27:17 +00:00
|
|
|
case BSSGP_PDUT_STATUS:
|
2017-07-29 08:16:44 +00:00
|
|
|
/* already handled in libosmogb */
|
|
|
|
OSMO_ASSERT(0);
|
2012-02-04 22:27:17 +00:00
|
|
|
break;
|
2013-07-28 17:01:20 +00:00
|
|
|
case BSSGP_PDUT_SUSPEND_ACK:
|
2017-07-29 08:16:44 +00:00
|
|
|
case BSSGP_PDUT_RESUME_ACK:
|
|
|
|
case BSSGP_PDUT_BVC_BLOCK_ACK:
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (SIGN) %s\n",
|
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
2013-07-28 17:01:20 +00:00
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_BVC_RESET_ACK:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%d (SIGN) BVC_RESET_ACK\n", bvci);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.bvc_sig_reset)
|
|
|
|
the_pcu->bssgp.bvc_sig_reset = 1;
|
2013-07-28 17:01:20 +00:00
|
|
|
else
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bvc_reset = 1;
|
2013-07-28 17:01:20 +00:00
|
|
|
bvc_timeout(NULL);
|
|
|
|
break;
|
2019-12-10 18:29:22 +00:00
|
|
|
case BSSGP_PDUT_PAGING_CS:
|
|
|
|
gprs_bssgp_pcu_rx_paging_cs(msg, tp);
|
|
|
|
break;
|
2013-07-28 17:01:20 +00:00
|
|
|
case BSSGP_PDUT_PAGING_PS:
|
|
|
|
gprs_bssgp_pcu_rx_paging_ps(msg, tp);
|
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%d (SIGN) BVC_UNBLOCK_ACK\n", bvci);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bvc_unblocked = 1;
|
|
|
|
if (the_pcu->bssgp.on_unblock_ack)
|
|
|
|
the_pcu->bssgp.on_unblock_ack(&the_pcu->bssgp);
|
2013-07-28 17:01:20 +00:00
|
|
|
bvc_timeout(NULL);
|
|
|
|
break;
|
2017-07-29 08:16:44 +00:00
|
|
|
case BSSGP_PDUT_SUSPEND_NACK:
|
|
|
|
case BSSGP_PDUT_RESUME_NACK:
|
|
|
|
case BSSGP_PDUT_FLUSH_LL:
|
2013-07-28 17:01:20 +00:00
|
|
|
case BSSGP_PDUT_SGSN_INVOKE_TRACE:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "Rx BSSGP BVCI=%d (SIGN) PDU type %s not implemented\n",
|
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
|
|
|
break;
|
|
|
|
/* See TS 08.18 5.4.1 */
|
|
|
|
case BSSGP_PDUT_UL_UNITDATA:
|
|
|
|
case BSSGP_PDUT_DL_UNITDATA:
|
|
|
|
case BSSGP_PDUT_RA_CAPABILITY:
|
|
|
|
case BSSGP_PDUT_PTM_UNITDATA:
|
|
|
|
case BSSGP_PDUT_RA_CAPA_UDPATE:
|
|
|
|
case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
|
|
|
|
case BSSGP_PDUT_RADIO_STATUS:
|
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_BVC:
|
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK:
|
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_MS:
|
|
|
|
case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
|
|
|
|
case BSSGP_PDUT_DOWNLOAD_BSS_PFC:
|
|
|
|
case BSSGP_PDUT_CREATE_BSS_PFC:
|
|
|
|
case BSSGP_PDUT_CREATE_BSS_PFC_ACK:
|
|
|
|
case BSSGP_PDUT_CREATE_BSS_PFC_NACK:
|
|
|
|
case BSSGP_PDUT_MODIFY_BSS_PFC:
|
|
|
|
case BSSGP_PDUT_MODIFY_BSS_PFC_ACK:
|
|
|
|
case BSSGP_PDUT_DELETE_BSS_PFC:
|
|
|
|
case BSSGP_PDUT_DELETE_BSS_PFC_ACK:
|
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%d (SIGN) PDU type %s unexpected at SIGN\n",
|
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
2013-07-28 17:01:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-07-29 08:16:44 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%d (SIGN) PDU type %s unknown\n",
|
2017-05-23 15:53:38 +00:00
|
|
|
bvci, bssgp_pdu_str(pdu_type));
|
2013-07-28 17:01:20 +00:00
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
|
|
|
|
break;
|
2012-02-04 22:27:17 +00:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-07-28 19:14:15 +00:00
|
|
|
static int gprs_bssgp_pcu_rcvmsg(struct msgb *msg)
|
2012-02-04 22:27:17 +00:00
|
|
|
{
|
|
|
|
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
|
|
|
|
struct bssgp_ud_hdr *budh = (struct bssgp_ud_hdr *) msgb_bssgph(msg);
|
|
|
|
struct tlv_parsed tp;
|
2017-05-23 15:53:38 +00:00
|
|
|
enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
|
2017-06-27 15:18:40 +00:00
|
|
|
uint16_t ns_bvci = msgb_bvci(msg), nsei = msgb_nsei(msg);
|
2021-02-22 01:08:18 +00:00
|
|
|
uint16_t bvci;
|
2012-02-04 22:27:17 +00:00
|
|
|
int data_len;
|
|
|
|
int rc = 0;
|
2012-07-06 07:28:15 +00:00
|
|
|
struct bssgp_bvc_ctx *bctx;
|
|
|
|
|
2021-01-21 17:44:23 +00:00
|
|
|
switch (pdu_type) {
|
|
|
|
case BSSGP_PDUT_STATUS:
|
2015-03-16 11:27:11 +00:00
|
|
|
/* Pass the message to the generic BSSGP parser, which handles
|
2017-06-27 15:18:40 +00:00
|
|
|
* STATUS and RESET messages in either direction. */
|
2021-01-21 17:44:23 +00:00
|
|
|
case BSSGP_PDUT_RAN_INFO:
|
|
|
|
case BSSGP_PDUT_RAN_INFO_REQ:
|
|
|
|
case BSSGP_PDUT_RAN_INFO_ACK:
|
|
|
|
case BSSGP_PDUT_RAN_INFO_ERROR:
|
|
|
|
case BSSGP_PDUT_RAN_INFO_APP_ERROR:
|
|
|
|
/* Also pass all RIM related messages to the generic BSSGP
|
|
|
|
* parser so that it can deliver primitive to the RIM SAP
|
|
|
|
* (SAP_BSSGP_RIM) */
|
2015-03-16 11:27:11 +00:00
|
|
|
return bssgp_rcvmsg(msg);
|
2021-01-21 17:44:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-02-04 22:27:17 +00:00
|
|
|
|
|
|
|
/* Identifiers from DOWN: NSEI, BVCI (both in msg->cb) */
|
|
|
|
|
|
|
|
/* UNITDATA BSSGP headers have TLLI in front */
|
|
|
|
if (pdu_type != BSSGP_PDUT_UL_UNITDATA && pdu_type != BSSGP_PDUT_DL_UNITDATA)
|
|
|
|
{
|
|
|
|
data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
|
|
|
|
rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data_len = msgb_bssgp_len(msg) - sizeof(*budh);
|
|
|
|
rc = bssgp_tlv_parse(&tp, budh->data, data_len);
|
|
|
|
}
|
2018-06-25 10:17:39 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to parse BSSGP %s message. Invalid message was: %s\n",
|
|
|
|
bssgp_pdu_str(pdu_type), msgb_hexdump(msg));
|
2019-07-21 07:26:20 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
|
2018-06-25 10:17:39 +00:00
|
|
|
}
|
2012-02-04 22:27:17 +00:00
|
|
|
|
2017-06-27 15:18:40 +00:00
|
|
|
if (pdu_type == BSSGP_PDUT_BVC_RESET) {
|
2021-02-22 01:08:18 +00:00
|
|
|
if (ns_bvci != BVCI_SIGNALLING || !TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Rx an invalid BVC-RESET %s\n", msgb_hexdump(msg));
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
bvci = tlvp_val16be(&tp, BSSGP_IE_BVCI);
|
|
|
|
if (bvci != BVCI_SIGNALLING && bvci != the_pcu->bssgp.bctx->bvci) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Rx BVC-RESET for an unknown BVCI %d\n", bvci);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &bvci, msg);
|
|
|
|
}
|
|
|
|
|
2021-02-17 01:31:37 +00:00
|
|
|
return bssgp_rcvmsg(msg);
|
2017-06-27 15:18:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 22:27:17 +00:00
|
|
|
/* look-up or create the BTS context for this BVC */
|
|
|
|
bctx = btsctx_by_bvci_nsei(ns_bvci, msgb_nsei(msg));
|
|
|
|
|
2019-11-07 21:02:31 +00:00
|
|
|
if (!bctx && ns_bvci != BVCI_SIGNALLING)
|
2012-02-04 22:27:17 +00:00
|
|
|
{
|
2017-06-27 15:18:40 +00:00
|
|
|
LOGP(DBSSGP, LOGL_NOTICE, "NSEI=%u/BVCI=%u Rejecting PDU type %s for unknown BVCI\n",
|
|
|
|
nsei, ns_bvci, bssgp_pdu_str(pdu_type));
|
2012-02-04 22:27:17 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bctx)
|
|
|
|
{
|
2017-02-23 17:10:13 +00:00
|
|
|
log_set_context(LOG_CTX_GB_BVC, bctx);
|
2021-06-04 15:05:51 +00:00
|
|
|
rate_ctr_inc(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_PKTS_IN));
|
|
|
|
rate_ctr_add(rate_ctr_group_get_ctr(bctx->ctrg, BSSGP_CTR_BYTES_IN), msgb_bssgp_len(msg));
|
2012-02-04 22:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ns_bvci == BVCI_SIGNALLING)
|
|
|
|
{
|
2012-07-06 09:04:57 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "rx BVCI_SIGNALLING gprs_bssgp_rx_sign\n");
|
2012-03-05 15:24:57 +00:00
|
|
|
rc = gprs_bssgp_pcu_rx_sign(msg, &tp, bctx);
|
2012-02-04 22:27:17 +00:00
|
|
|
}
|
|
|
|
else if (ns_bvci == BVCI_PTM)
|
|
|
|
{
|
2012-07-06 09:04:57 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "rx BVCI_PTM bssgp_tx_status\n");
|
2012-02-04 22:27:17 +00:00
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-23 13:27:54 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "rx BVCI_PTP=%u gprs_bssgp_rx_ptp\n", ns_bvci);
|
2012-03-05 15:24:57 +00:00
|
|
|
rc = gprs_bssgp_pcu_rx_ptp(msg, &tp, bctx);
|
2012-02-04 22:27:17 +00:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2012-06-18 04:21:03 +00:00
|
|
|
|
2015-03-16 11:27:11 +00:00
|
|
|
static void handle_nm_status(struct osmo_bssgp_prim *bp)
|
|
|
|
{
|
|
|
|
enum gprs_bssgp_cause cause;
|
|
|
|
|
|
|
|
LOGP(DPCU, LOGL_DEBUG,
|
|
|
|
"Got NM-STATUS.ind, BVCI=%d, NSEI=%d\n",
|
|
|
|
bp->bvci, bp->nsei);
|
|
|
|
|
|
|
|
if (!TLVP_PRESENT(bp->tp, BSSGP_IE_CAUSE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
cause = (enum gprs_bssgp_cause)*TLVP_VAL(bp->tp, BSSGP_IE_CAUSE);
|
|
|
|
|
|
|
|
if (cause != BSSGP_CAUSE_BVCI_BLOCKED &&
|
|
|
|
cause != BSSGP_CAUSE_UNKNOWN_BVCI)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!TLVP_PRESENT(bp->tp, BSSGP_IE_BVCI))
|
|
|
|
return;
|
|
|
|
|
2021-01-21 17:02:40 +00:00
|
|
|
if (the_pcu->bssgp.bctx->bvci != bp->bvci) {
|
2015-03-16 11:27:11 +00:00
|
|
|
LOGP(DPCU, LOGL_NOTICE,
|
|
|
|
"Received BSSGP STATUS message for an unknown BVCI (%d), "
|
|
|
|
"ignored\n",
|
|
|
|
bp->bvci);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cause) {
|
|
|
|
case BSSGP_CAUSE_BVCI_BLOCKED:
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.bvc_unblocked) {
|
|
|
|
the_pcu->bssgp.bvc_unblocked = 0;
|
2015-03-16 11:27:11 +00:00
|
|
|
bvc_timeout(NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BSSGP_CAUSE_UNKNOWN_BVCI:
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.bvc_reset) {
|
|
|
|
the_pcu->bssgp.bvc_reset = 0;
|
2015-03-16 11:27:11 +00:00
|
|
|
bvc_timeout(NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-18 04:21:03 +00:00
|
|
|
int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
|
|
|
|
{
|
2015-03-16 11:27:11 +00:00
|
|
|
struct osmo_bssgp_prim *bp;
|
2021-02-17 01:31:37 +00:00
|
|
|
int rc;
|
|
|
|
enum gprs_bssgp_cause cause;
|
2015-03-16 11:27:11 +00:00
|
|
|
bp = container_of(oph, struct osmo_bssgp_prim, oph);
|
|
|
|
|
|
|
|
switch (oph->sap) {
|
|
|
|
case SAP_BSSGP_NM:
|
2021-02-17 01:31:37 +00:00
|
|
|
switch (oph->primitive) {
|
|
|
|
case PRIM_NM_STATUS:
|
2015-03-16 11:27:11 +00:00
|
|
|
handle_nm_status(bp);
|
2021-02-17 01:31:37 +00:00
|
|
|
break;
|
|
|
|
case PRIM_NM_BVC_RESET:
|
|
|
|
/* received a BVC PTP reset */
|
|
|
|
LOGP(DPCU, LOGL_INFO, "Rx BVC_RESET on bvci %d\n", bp->bvci);
|
|
|
|
/* Rx Reset from SGSN */
|
|
|
|
if (bp->bvci == BVCI_SIGNALLING) {
|
|
|
|
if (TLVP_PRES_LEN(bp->tp, BSSGP_IE_CAUSE, 1))
|
|
|
|
cause = (enum gprs_bssgp_cause)*TLVP_VAL(bp->tp, BSSGP_IE_CAUSE);
|
|
|
|
else {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u BVC RESET without cause?!\n", bp->nsei);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = bssgp_tx_bvc_ptp_reset(bp->nsei, cause);
|
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "NSEI=%u BVC PTP reset procedure failed: %d\n", bp->nsei, rc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
the_pcu->bssgp.bvc_sig_reset = 1;
|
|
|
|
the_pcu->bssgp.bvc_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_unblocked = 0;
|
|
|
|
} else if (bp->bvci == the_pcu->bssgp.bctx->bvci) {
|
|
|
|
the_pcu->bssgp.bvc_reset = 1;
|
|
|
|
the_pcu->bssgp.bvc_unblocked = 0;
|
|
|
|
bvc_timeout(NULL);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-03-16 11:27:11 +00:00
|
|
|
break;
|
2021-01-21 17:44:23 +00:00
|
|
|
case SAP_BSSGP_RIM:
|
|
|
|
return handle_rim(bp);
|
2015-03-16 11:27:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-06-18 04:21:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-07-06 06:58:22 +00:00
|
|
|
|
2020-09-16 19:52:02 +00:00
|
|
|
void gprs_ns_prim_status_cb(struct osmo_gprs_ns2_prim *nsp)
|
2012-07-06 06:58:22 +00:00
|
|
|
{
|
2020-09-16 19:52:02 +00:00
|
|
|
switch (nsp->u.status.cause) {
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_AFF_CAUSE_SNS_CONFIGURED:
|
2020-09-16 19:52:02 +00:00
|
|
|
LOGP(DPCU, LOGL_NOTICE, "NS-NSE %d SNS configured.\n", nsp->nsei);
|
2018-07-05 01:11:17 +00:00
|
|
|
break;
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_AFF_CAUSE_RECOVERY:
|
2020-09-16 19:52:02 +00:00
|
|
|
LOGP(DPCU, LOGL_NOTICE, "NS-NSE %d became available\n", nsp->nsei);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.nsvc_unblocked) {
|
|
|
|
the_pcu->bssgp.bvc_sig_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_reset = 0;
|
|
|
|
the_pcu->bssgp.nsvc_unblocked = 1;
|
2012-09-23 04:41:21 +00:00
|
|
|
bvc_timeout(NULL);
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_AFF_CAUSE_FAILURE:
|
2020-09-16 19:52:02 +00:00
|
|
|
LOGP(DPCU, LOGL_NOTICE, "NS-NSE %d became unavailable\n", nsp->nsei);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.nsvc_unblocked) {
|
|
|
|
the_pcu->bssgp.nsvc_unblocked = 0;
|
|
|
|
osmo_timer_del(&the_pcu->bssgp.bvc_timer);
|
|
|
|
the_pcu->bssgp.bvc_sig_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_unblocked = 0;
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_AFF_CAUSE_SNS_FAILURE:
|
2020-10-27 00:25:51 +00:00
|
|
|
break;
|
2020-09-16 19:52:02 +00:00
|
|
|
default:
|
2020-10-27 00:25:51 +00:00
|
|
|
LOGP(DPCU, LOGL_DEBUG,
|
|
|
|
"NS: %s Unknown affecting cause %s / %d from NS\n",
|
2020-09-16 19:52:02 +00:00
|
|
|
get_value_string(osmo_prim_op_names, nsp->oph.operation),
|
2020-10-27 00:25:51 +00:00
|
|
|
gprs_ns2_aff_cause_prim_str(nsp->u.status.cause), nsp->u.status.cause);
|
2015-08-17 12:43:52 +00:00
|
|
|
break;
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
2020-09-16 19:52:02 +00:00
|
|
|
}
|
2012-07-06 06:58:22 +00:00
|
|
|
|
2020-09-16 19:52:02 +00:00
|
|
|
/* called by the ns layer */
|
|
|
|
int gprs_ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
|
|
|
|
{
|
|
|
|
struct osmo_gprs_ns2_prim *nsp;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (oph->sap != SAP_NS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nsp = container_of(oph, struct osmo_gprs_ns2_prim, oph);
|
|
|
|
|
|
|
|
if (oph->operation != PRIM_OP_INDICATION) {
|
|
|
|
LOGP(DPCU, LOGL_NOTICE, "NS: %s Unknown prim %d from NS\n",
|
|
|
|
get_value_string(osmo_prim_op_names, oph->operation),
|
|
|
|
oph->operation);
|
2020-10-25 23:33:31 +00:00
|
|
|
goto out;
|
2020-09-16 19:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (oph->primitive) {
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_PRIM_UNIT_DATA:
|
2020-09-16 19:52:02 +00:00
|
|
|
/* hand the message into the BSSGP implementation */
|
|
|
|
/* add required msg fields for Gb layer */
|
|
|
|
msgb_bssgph(oph->msg) = oph->msg->l3h;
|
|
|
|
msgb_bvci(oph->msg) = nsp->bvci;
|
|
|
|
msgb_nsei(oph->msg) = nsp->nsei;
|
|
|
|
rc = gprs_bssgp_pcu_rcvmsg(oph->msg);
|
|
|
|
break;
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_PRIM_STATUS:
|
2020-09-16 19:52:02 +00:00
|
|
|
gprs_ns_prim_status_cb(nsp);
|
|
|
|
break;
|
2021-01-25 19:28:38 +00:00
|
|
|
case GPRS_NS2_PRIM_CONGESTION:
|
2020-10-27 00:25:51 +00:00
|
|
|
break;
|
2020-09-16 19:52:02 +00:00
|
|
|
default:
|
2020-10-27 00:25:51 +00:00
|
|
|
LOGP(DPCU, LOGL_DEBUG,
|
|
|
|
"NS: %s Unknown prim %s / %d from NS\n",
|
2020-09-16 19:52:02 +00:00
|
|
|
get_value_string(osmo_prim_op_names, oph->operation),
|
2021-01-18 16:14:14 +00:00
|
|
|
gprs_ns2_prim_str((enum gprs_ns2_prim) oph->primitive), oph->primitive);
|
2020-09-16 19:52:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-25 23:33:31 +00:00
|
|
|
out:
|
|
|
|
if (oph->msg)
|
|
|
|
msgb_free(oph->msg);
|
|
|
|
|
2020-09-16 19:52:02 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called by the bssgp layer to send NS PDUs */
|
|
|
|
int gprs_gp_send_cb(void *ctx, struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct gprs_ns2_inst *nsi = (struct gprs_ns2_inst *) ctx;
|
|
|
|
struct osmo_gprs_ns2_prim nsp = {};
|
|
|
|
nsp.nsei = msgb_nsei(msg);
|
|
|
|
nsp.bvci = msgb_bvci(msg);
|
2021-01-25 19:28:38 +00:00
|
|
|
osmo_prim_init(&nsp.oph, SAP_NS, GPRS_NS2_PRIM_UNIT_DATA,
|
2020-09-16 19:52:02 +00:00
|
|
|
PRIM_OP_REQUEST, msg);
|
|
|
|
return gprs_ns2_recv_prim(nsi, &nsp.oph);
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-30 13:01:15 +00:00
|
|
|
static unsigned count_pdch(const struct gprs_rlcmac_bts *bts)
|
|
|
|
{
|
|
|
|
size_t trx_no, ts_no;
|
|
|
|
unsigned num_pdch = 0;
|
|
|
|
|
|
|
|
for (trx_no = 0; trx_no < ARRAY_SIZE(bts->trx); ++trx_no) {
|
|
|
|
const struct gprs_rlcmac_trx *trx = &bts->trx[trx_no];
|
|
|
|
|
|
|
|
for (ts_no = 0; ts_no < ARRAY_SIZE(trx->pdch); ++ts_no) {
|
|
|
|
const struct gprs_rlcmac_pdch *pdch = &trx->pdch[ts_no];
|
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
if (pdch->m_is_enabled)
|
2015-04-30 13:01:15 +00:00
|
|
|
num_pdch += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return num_pdch;
|
|
|
|
}
|
|
|
|
|
2020-05-18 09:35:35 +00:00
|
|
|
static uint32_t gprs_bssgp_max_leak_rate(enum CodingScheme cs, int num_pdch)
|
2015-04-30 13:01:15 +00:00
|
|
|
{
|
2020-05-18 09:35:35 +00:00
|
|
|
int bytes_per_rlc_block = mcs_max_data_block_bytes(cs) * num_data_blocks(mcs_header_type(cs));
|
2015-04-30 13:01:15 +00:00
|
|
|
|
2016-02-04 16:54:42 +00:00
|
|
|
/* n byte payload per 20ms */
|
|
|
|
return bytes_per_rlc_block * (1000 / 20) * num_pdch;
|
2015-04-30 13:01:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t compute_bucket_size(struct gprs_rlcmac_bts *bts,
|
|
|
|
uint32_t leak_rate, uint32_t fallback)
|
|
|
|
{
|
|
|
|
uint32_t bucket_size = 0;
|
2021-01-14 13:03:17 +00:00
|
|
|
uint16_t bucket_time = the_pcu->vty.fc_bucket_time;
|
2015-04-30 13:01:15 +00:00
|
|
|
|
2015-05-06 08:47:30 +00:00
|
|
|
if (bucket_time == 0)
|
2021-01-14 13:45:14 +00:00
|
|
|
bucket_time = the_pcu->vty.force_llc_lifetime;
|
2015-05-06 08:47:30 +00:00
|
|
|
|
|
|
|
if (bucket_time == 0xffff)
|
2015-04-30 13:01:15 +00:00
|
|
|
bucket_size = FC_MAX_BUCKET_SIZE;
|
|
|
|
|
2015-05-06 08:47:30 +00:00
|
|
|
if (bucket_size == 0 && bucket_time && leak_rate)
|
|
|
|
bucket_size = (uint64_t)leak_rate * bucket_time / 100;
|
2015-04-30 13:01:15 +00:00
|
|
|
|
|
|
|
if (bucket_size == 0 && leak_rate)
|
|
|
|
bucket_size = leak_rate * FC_DEFAULT_LIFE_TIME_SECS;
|
|
|
|
|
|
|
|
if (bucket_size == 0)
|
|
|
|
bucket_size = fallback;
|
|
|
|
|
|
|
|
if (bucket_size > FC_MAX_BUCKET_SIZE)
|
|
|
|
bucket_size = FC_MAX_BUCKET_SIZE;
|
|
|
|
|
|
|
|
return bucket_size;
|
|
|
|
}
|
|
|
|
|
2015-05-06 12:24:36 +00:00
|
|
|
static uint32_t get_and_reset_avg_queue_delay(void)
|
|
|
|
{
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
struct timespec *delay_sum = &the_pcu->bssgp.queue_delay_sum;
|
2015-06-11 10:03:18 +00:00
|
|
|
uint32_t delay_sum_ms = delay_sum->tv_sec * 1000 +
|
2020-03-11 13:04:52 +00:00
|
|
|
delay_sum->tv_nsec / 1000000000;
|
2015-05-06 12:24:36 +00:00
|
|
|
uint32_t avg_delay_ms = 0;
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.queue_delay_count > 0)
|
|
|
|
avg_delay_ms = delay_sum_ms / the_pcu->bssgp.queue_delay_count;
|
2015-05-06 12:24:36 +00:00
|
|
|
|
|
|
|
/* Reset accumulator */
|
2020-03-11 13:04:52 +00:00
|
|
|
delay_sum->tv_sec = delay_sum->tv_nsec = 0;
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.queue_delay_count = 0;
|
2015-05-06 12:24:36 +00:00
|
|
|
|
|
|
|
return avg_delay_ms;
|
|
|
|
}
|
|
|
|
|
2015-09-07 16:49:00 +00:00
|
|
|
static int get_and_reset_measured_leak_rate(int *usage_by_1000, unsigned num_pdch)
|
|
|
|
{
|
|
|
|
int rate; /* byte per second */
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.queue_frames_sent == 0)
|
2015-09-07 16:49:00 +00:00
|
|
|
return -1;
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.queue_frames_recv == 0)
|
2015-09-07 16:49:00 +00:00
|
|
|
return -1;
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
*usage_by_1000 = the_pcu->bssgp.queue_frames_recv * 1000 /
|
|
|
|
the_pcu->bssgp.queue_frames_sent;
|
2015-09-07 16:49:00 +00:00
|
|
|
|
|
|
|
/* 20ms/num_pdch is the average RLC block duration, so the rate is
|
|
|
|
* calculated as:
|
|
|
|
* rate = bytes_recv / (block_dur * block_count) */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
rate = the_pcu->bssgp.queue_bytes_recv * 1000 * num_pdch /
|
|
|
|
(20 * the_pcu->bssgp.queue_frames_recv);
|
2015-09-07 16:49:00 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.queue_frames_sent = 0;
|
|
|
|
the_pcu->bssgp.queue_bytes_recv = 0;
|
|
|
|
the_pcu->bssgp.queue_frames_recv = 0;
|
2015-09-07 16:49:00 +00:00
|
|
|
|
|
|
|
return rate;
|
|
|
|
}
|
|
|
|
|
2020-05-18 09:35:35 +00:00
|
|
|
static enum CodingScheme max_coding_scheme_dl(struct gprs_rlcmac_bts *bts)
|
2016-02-04 16:54:42 +00:00
|
|
|
{
|
2020-10-30 16:14:26 +00:00
|
|
|
int num = 0;
|
|
|
|
int i;
|
2020-10-30 17:46:24 +00:00
|
|
|
bool mcs_any = false;
|
|
|
|
|
|
|
|
/* First check if we support any MCS: */
|
|
|
|
for (i = 8; i >= 0; i--) {
|
|
|
|
if (bts->mcs_mask & (1 << i)) {
|
|
|
|
num = i + 1;
|
|
|
|
mcs_any = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-02-04 16:54:42 +00:00
|
|
|
|
2020-10-30 17:46:24 +00:00
|
|
|
if (mcs_any) {
|
2021-01-14 12:17:01 +00:00
|
|
|
if (!the_pcu->vty.cs_adj_enabled) {
|
2020-10-30 16:14:26 +00:00
|
|
|
if (bts->initial_mcs_dl) {
|
2016-02-04 16:54:42 +00:00
|
|
|
num = bts->initial_mcs_dl;
|
2020-10-30 16:14:26 +00:00
|
|
|
} else {
|
2020-10-30 17:46:24 +00:00
|
|
|
/* We found "num" for free in the loop above */
|
2020-10-30 16:14:26 +00:00
|
|
|
}
|
2021-01-14 15:48:38 +00:00
|
|
|
} else if (bts_max_mcs_dl(bts)) {
|
|
|
|
num = bts_max_mcs_dl(bts);
|
2016-02-04 16:54:42 +00:00
|
|
|
} else {
|
|
|
|
num = 9;
|
|
|
|
}
|
|
|
|
|
2020-10-30 16:14:26 +00:00
|
|
|
if (num)
|
|
|
|
return mcs_get_egprs_by_num(num);
|
2016-02-04 16:54:42 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 12:17:01 +00:00
|
|
|
if (!the_pcu->vty.cs_adj_enabled) {
|
2020-10-30 16:14:26 +00:00
|
|
|
if (bts->initial_cs_dl) {
|
2016-02-04 16:54:42 +00:00
|
|
|
num = bts->initial_cs_dl;
|
2020-10-30 16:14:26 +00:00
|
|
|
} else {
|
|
|
|
for (i = 3; i >= 0; i--) {
|
|
|
|
if (bts->cs_mask & (1 << i)) {
|
|
|
|
num = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-14 15:48:38 +00:00
|
|
|
} else if (bts_max_cs_dl(bts)) {
|
|
|
|
num = bts_max_cs_dl(bts);
|
2016-02-04 16:54:42 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 16:14:26 +00:00
|
|
|
if (!num)
|
|
|
|
num = 4;
|
|
|
|
|
2020-05-18 09:35:35 +00:00
|
|
|
return mcs_get_gprs_by_num(num);
|
2016-02-04 16:54:42 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 16:09:51 +00:00
|
|
|
static int gprs_bssgp_tx_fc_bvc(void)
|
2012-09-23 04:41:21 +00:00
|
|
|
{
|
2015-04-21 10:56:48 +00:00
|
|
|
struct gprs_rlcmac_bts *bts;
|
2015-04-30 13:01:15 +00:00
|
|
|
uint32_t bucket_size; /* oct */
|
|
|
|
uint32_t ms_bucket_size; /* oct */
|
|
|
|
uint32_t leak_rate; /* oct/s */
|
|
|
|
uint32_t ms_leak_rate; /* oct/s */
|
2015-05-06 12:24:36 +00:00
|
|
|
uint32_t avg_delay_ms;
|
2015-04-30 13:01:15 +00:00
|
|
|
int num_pdch = -1;
|
2020-05-18 09:35:35 +00:00
|
|
|
enum CodingScheme max_cs_dl;
|
2015-04-21 10:56:48 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.bctx) {
|
2012-09-23 04:41:21 +00:00
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "No bctx\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2021-01-18 16:14:14 +00:00
|
|
|
|
|
|
|
/* FIXME: This calculation needs to be redone to support multiple BTS */
|
|
|
|
bts = llist_first_entry_or_null(&the_pcu->bts_list, struct gprs_rlcmac_bts, list);
|
|
|
|
if (!bts) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "No bts\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
2015-04-21 10:56:48 +00:00
|
|
|
|
2016-02-04 16:54:42 +00:00
|
|
|
max_cs_dl = max_coding_scheme_dl(bts);
|
2015-07-21 16:29:46 +00:00
|
|
|
|
2021-01-14 13:03:17 +00:00
|
|
|
bucket_size = the_pcu->vty.fc_bvc_bucket_size;
|
|
|
|
leak_rate = the_pcu->vty.fc_bvc_leak_rate;
|
|
|
|
ms_bucket_size = the_pcu->vty.fc_ms_bucket_size;
|
|
|
|
ms_leak_rate = the_pcu->vty.fc_ms_leak_rate;
|
2015-04-30 13:01:15 +00:00
|
|
|
|
2020-10-30 17:46:24 +00:00
|
|
|
/* FIXME: This calculation is mostly wrong. It should be done based on
|
|
|
|
currently established TBF (and whether the related (egprs)_ms_class
|
|
|
|
as per which CS/MCS they support). */
|
2015-09-07 16:49:00 +00:00
|
|
|
if (leak_rate == 0) {
|
|
|
|
int meas_rate;
|
|
|
|
int usage; /* in 0..1000 */
|
|
|
|
|
|
|
|
if (num_pdch < 0)
|
|
|
|
num_pdch = count_pdch(bts);
|
|
|
|
|
|
|
|
meas_rate = get_and_reset_measured_leak_rate(&usage, num_pdch);
|
|
|
|
if (meas_rate > 0) {
|
|
|
|
leak_rate = gprs_bssgp_max_leak_rate(max_cs_dl, num_pdch);
|
|
|
|
leak_rate =
|
|
|
|
(meas_rate * usage + leak_rate * (1000 - usage)) /
|
|
|
|
1000;
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG,
|
|
|
|
"Estimated BVC leak rate = %d "
|
|
|
|
"(measured %d, usage %d%%)\n",
|
|
|
|
leak_rate, meas_rate, usage/10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-30 13:01:15 +00:00
|
|
|
if (leak_rate == 0) {
|
|
|
|
if (num_pdch < 0)
|
|
|
|
num_pdch = count_pdch(bts);
|
|
|
|
|
2015-07-21 16:29:46 +00:00
|
|
|
leak_rate = gprs_bssgp_max_leak_rate(max_cs_dl, num_pdch);
|
2015-04-30 13:01:15 +00:00
|
|
|
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG,
|
2016-02-04 16:54:42 +00:00
|
|
|
"Computed BVC leak rate = %d, num_pdch = %d, cs = %s\n",
|
2019-03-05 13:59:03 +00:00
|
|
|
leak_rate, num_pdch, mcs_name(max_cs_dl));
|
2015-04-30 13:01:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (ms_leak_rate == 0) {
|
|
|
|
int ms_num_pdch;
|
2021-01-18 16:14:14 +00:00
|
|
|
int max_pdch = gprs_alloc_max_dl_slots_per_ms(bts, 0);
|
2015-04-30 13:01:15 +00:00
|
|
|
|
|
|
|
if (num_pdch < 0)
|
|
|
|
num_pdch = count_pdch(bts);
|
|
|
|
|
|
|
|
ms_num_pdch = num_pdch;
|
2015-07-17 09:38:49 +00:00
|
|
|
if (max_pdch > FC_MS_MAX_RX_SLOTS)
|
|
|
|
max_pdch = FC_MS_MAX_RX_SLOTS;
|
|
|
|
if (ms_num_pdch > max_pdch)
|
|
|
|
ms_num_pdch = max_pdch;
|
2015-04-30 13:01:15 +00:00
|
|
|
|
2015-07-21 16:29:46 +00:00
|
|
|
ms_leak_rate = gprs_bssgp_max_leak_rate(max_cs_dl, ms_num_pdch);
|
2015-04-30 13:01:15 +00:00
|
|
|
|
|
|
|
/* TODO: To properly support multiple TRX, the per MS leak rate
|
|
|
|
* should be derived from the max number of PDCH TS per TRX.
|
|
|
|
*/
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG,
|
2016-02-04 16:54:42 +00:00
|
|
|
"Computed MS default leak rate = %d, ms_num_pdch = %d, "
|
|
|
|
"cs = %s\n",
|
2019-03-05 13:59:03 +00:00
|
|
|
ms_leak_rate, ms_num_pdch, mcs_name(max_cs_dl));
|
2015-04-30 13:01:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* TODO: Force leak_rate to 0 on buffer bloat */
|
|
|
|
|
|
|
|
if (bucket_size == 0)
|
|
|
|
bucket_size = compute_bucket_size(bts, leak_rate,
|
|
|
|
FC_FALLBACK_BVC_BUCKET_SIZE);
|
|
|
|
|
|
|
|
if (ms_bucket_size == 0)
|
|
|
|
ms_bucket_size = compute_bucket_size(bts, ms_leak_rate,
|
|
|
|
FC_MS_BUCKET_SIZE_BY_BMAX(bucket_size));
|
|
|
|
|
|
|
|
if (leak_rate > FC_MAX_BUCKET_LEAK_RATE)
|
|
|
|
leak_rate = FC_MAX_BUCKET_LEAK_RATE;
|
|
|
|
|
|
|
|
if (ms_leak_rate > FC_MAX_BUCKET_LEAK_RATE)
|
|
|
|
ms_leak_rate = FC_MAX_BUCKET_LEAK_RATE;
|
|
|
|
|
2015-05-06 12:24:36 +00:00
|
|
|
/* Avg queue delay monitoring */
|
|
|
|
avg_delay_ms = get_and_reset_avg_queue_delay();
|
2015-04-30 13:01:15 +00:00
|
|
|
|
2015-05-06 13:26:08 +00:00
|
|
|
/* Update tag */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.fc_tag += 1;
|
2015-05-06 13:26:08 +00:00
|
|
|
|
2015-04-30 13:01:15 +00:00
|
|
|
LOGP(DBSSGP, LOGL_DEBUG,
|
2015-05-06 12:24:36 +00:00
|
|
|
"Sending FLOW CONTROL BVC, Bmax = %d, R = %d, Bmax_MS = %d, "
|
|
|
|
"R_MS = %d, avg_dly = %d\n",
|
|
|
|
bucket_size, leak_rate, ms_bucket_size, ms_leak_rate,
|
|
|
|
avg_delay_ms);
|
2015-04-30 13:01:15 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
return bssgp_tx_fc_bvc(the_pcu->bssgp.bctx, the_pcu->bssgp.fc_tag,
|
2015-04-30 13:01:15 +00:00
|
|
|
bucket_size, leak_rate,
|
|
|
|
ms_bucket_size, ms_leak_rate,
|
2015-05-06 12:24:36 +00:00
|
|
|
NULL, &avg_delay_ms);
|
2012-09-23 04:41:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void bvc_timeout(void *_priv)
|
|
|
|
{
|
2019-09-05 14:20:22 +00:00
|
|
|
unsigned long secs;
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.bvc_sig_reset) {
|
2012-09-23 04:41:21 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI 0\n");
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
bssgp_tx_bvc_reset(the_pcu->bssgp.bctx, 0, BSSGP_CAUSE_OML_INTERV);
|
2021-04-26 12:14:37 +00:00
|
|
|
secs = osmo_tdef_get(the_pcu->T_defs, -102, OSMO_TDEF_S, -1);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
osmo_timer_schedule(&the_pcu->bssgp.bvc_timer, secs, 0);
|
2012-09-23 04:41:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.bvc_reset) {
|
2012-09-23 04:41:21 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI %d\n",
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->bvci);
|
|
|
|
bssgp_tx_bvc_reset(the_pcu->bssgp.bctx, the_pcu->bssgp.bctx->bvci, BSSGP_CAUSE_OML_INTERV);
|
2021-04-26 12:14:37 +00:00
|
|
|
secs = osmo_tdef_get(the_pcu->T_defs, -102, OSMO_TDEF_S, -1);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
osmo_timer_schedule(&the_pcu->bssgp.bvc_timer, secs, 0);
|
2012-09-23 04:41:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!the_pcu->bssgp.bvc_unblocked) {
|
2012-09-23 04:41:21 +00:00
|
|
|
LOGP(DBSSGP, LOGL_INFO, "Sending unblock on BVCI %d\n",
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->bvci);
|
|
|
|
bssgp_tx_bvc_unblock(the_pcu->bssgp.bctx);
|
2021-04-26 12:14:37 +00:00
|
|
|
secs = osmo_tdef_get(the_pcu->T_defs, -101, OSMO_TDEF_S, -1);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
osmo_timer_schedule(&the_pcu->bssgp.bvc_timer, secs, 0);
|
2012-09-23 04:41:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, "Sending flow control info on BVCI %d\n",
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->bvci);
|
2012-09-23 04:41:21 +00:00
|
|
|
gprs_bssgp_tx_fc_bvc();
|
2021-01-14 13:03:17 +00:00
|
|
|
osmo_timer_schedule(&the_pcu->bssgp.bvc_timer, the_pcu->vty.fc_interval, 0);
|
2012-09-23 04:41:21 +00:00
|
|
|
}
|
|
|
|
|
2021-02-15 04:50:10 +00:00
|
|
|
/*! configure NS layer
|
|
|
|
*
|
|
|
|
* \param bts pointer to the bts object
|
|
|
|
* \param nsei the NSEI of the BSS
|
|
|
|
* \param local pointer to an array of local address to bind on.
|
|
|
|
* \param remote pointer to an array of remote address SGSNs. If dynamic IP-SNS is used remote is used as initial SGSN endpoints.
|
|
|
|
* \param nsvci pointer to an array of nsvcis
|
|
|
|
* \param valid bitmask. a 1 means the position in the array contains a valid entry for local, remote, nsvci
|
|
|
|
* \returns 0 if the configuration has succeeded. on error != 0
|
|
|
|
*/
|
|
|
|
static int ns_configure_nse(struct gprs_rlcmac_bts *bts,
|
|
|
|
uint16_t nsei,
|
|
|
|
const struct osmo_sockaddr *local,
|
|
|
|
const struct osmo_sockaddr *remote,
|
|
|
|
const uint16_t *nsvci,
|
|
|
|
uint16_t valid)
|
2015-08-17 12:43:52 +00:00
|
|
|
{
|
Make gcc 11.1.0 false positivies happy
After my system's gcc was upgraded, I get false positivies like the one
below:
"""
/git/osmo-pcu/src/gprs_bssgp_pcu.c: In function ‘ns_configure_nse’:
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:58: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 2 [-Werror=format-truncation=]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:54: note: directive argument in the range [-2147483648, 1]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:25: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 5
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
In this case, i can't never take a value with more than 1 digit, but gcc
seems to be unable to see that.
Let's increase the buffer size a few bytes to make gcc happy, and make
the variable unsigned since it never will get negative values.
Next change is also a false positive, since variables are always
initialized beforehand in the cod epaths where they are used:
"""
/git/osmo-pcu/src/bts.cpp: In function ‘int bts_rcv_rach(gprs_rlcmac_bts*, const rach_ind_params*)’:
/git/osmo-pcu/src/bts.cpp:859:25: error: ‘ts_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~
/git/osmo-pcu/src/bts.cpp:859:17: error: ‘trx_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~~
"""
Change-Id: I1362a335a0c761bde367dbc779de4afa88f13584
2021-07-15 12:34:35 +00:00
|
|
|
unsigned int i;
|
|
|
|
int rc;
|
2020-10-12 00:27:22 +00:00
|
|
|
uint16_t binds = 0;
|
|
|
|
bool nsvcs = false;
|
2020-09-16 19:52:02 +00:00
|
|
|
struct gprs_ns2_vc *nsvc;
|
2020-10-12 00:27:22 +00:00
|
|
|
struct gprs_ns2_vc_bind *bind[PCU_IF_NUM_NSVC] = { };
|
Make gcc 11.1.0 false positivies happy
After my system's gcc was upgraded, I get false positivies like the one
below:
"""
/git/osmo-pcu/src/gprs_bssgp_pcu.c: In function ‘ns_configure_nse’:
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:58: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 2 [-Werror=format-truncation=]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:54: note: directive argument in the range [-2147483648, 1]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:25: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 5
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
In this case, i can't never take a value with more than 1 digit, but gcc
seems to be unable to see that.
Let's increase the buffer size a few bytes to make gcc happy, and make
the variable unsigned since it never will get negative values.
Next change is also a false positive, since variables are always
initialized beforehand in the cod epaths where they are used:
"""
/git/osmo-pcu/src/bts.cpp: In function ‘int bts_rcv_rach(gprs_rlcmac_bts*, const rach_ind_params*)’:
/git/osmo-pcu/src/bts.cpp:859:25: error: ‘ts_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~
/git/osmo-pcu/src/bts.cpp:859:17: error: ‘trx_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~~
"""
Change-Id: I1362a335a0c761bde367dbc779de4afa88f13584
2021-07-15 12:34:35 +00:00
|
|
|
char name[16];
|
2021-02-15 04:50:10 +00:00
|
|
|
bool sns_configured = false;
|
2015-08-17 12:43:52 +00:00
|
|
|
|
2020-10-12 00:27:22 +00:00
|
|
|
if (!valid)
|
|
|
|
return -1;
|
|
|
|
|
2021-02-15 04:50:10 +00:00
|
|
|
bts->nse = gprs_ns2_nse_by_nsei(the_pcu->nsi, nsei);
|
|
|
|
if (!bts->nse)
|
|
|
|
bts->nse = gprs_ns2_create_nse(the_pcu->nsi, nsei,
|
|
|
|
GPRS_NS2_LL_UDP, the_pcu->vty.ns_dialect);
|
|
|
|
if (!bts->nse) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSE\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-12 00:27:22 +00:00
|
|
|
for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
|
|
|
|
if (!(valid & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (!gprs_ns2_ip_bind_by_sockaddr(the_pcu->nsi, &local[i])) {
|
Make gcc 11.1.0 false positivies happy
After my system's gcc was upgraded, I get false positivies like the one
below:
"""
/git/osmo-pcu/src/gprs_bssgp_pcu.c: In function ‘ns_configure_nse’:
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:58: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 2 [-Werror=format-truncation=]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:54: note: directive argument in the range [-2147483648, 1]
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~
/git/osmo-pcu/src/gprs_bssgp_pcu.c:1103:25: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 5
1103 | snprintf(name, sizeof(name), "pcu%d", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
In this case, i can't never take a value with more than 1 digit, but gcc
seems to be unable to see that.
Let's increase the buffer size a few bytes to make gcc happy, and make
the variable unsigned since it never will get negative values.
Next change is also a false positive, since variables are always
initialized beforehand in the cod epaths where they are used:
"""
/git/osmo-pcu/src/bts.cpp: In function ‘int bts_rcv_rach(gprs_rlcmac_bts*, const rach_ind_params*)’:
/git/osmo-pcu/src/bts.cpp:859:25: error: ‘ts_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~
/git/osmo-pcu/src/bts.cpp:859:17: error: ‘trx_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
859 | uint8_t trx_no, ts_no;
| ^~~~~~
"""
Change-Id: I1362a335a0c761bde367dbc779de4afa88f13584
2021-07-15 12:34:35 +00:00
|
|
|
snprintf(name, sizeof(name), "pcu%u", i);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
rc = gprs_ns2_ip_bind(the_pcu->nsi, name, &local[i], 0, &bind[i]);
|
2020-10-12 00:27:22 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to bind to %s\n", osmo_sockaddr_to_str(&local[i]));
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-15 04:53:12 +00:00
|
|
|
|
|
|
|
if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS) {
|
|
|
|
rc = gprs_ns2_sns_add_bind(bts->nse, bind[i]);
|
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to add bind %s to the NSE for IP-SNS\n", osmo_sockaddr_to_str(&local[i]));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2021-04-29 20:02:47 +00:00
|
|
|
|
|
|
|
if (the_pcu->vty.ns_ip_dscp != -1)
|
|
|
|
gprs_ns2_ip_bind_set_dscp(bind[i], the_pcu->vty.ns_ip_dscp);
|
|
|
|
if (the_pcu->vty.ns_priority != -1)
|
|
|
|
gprs_ns2_ip_bind_set_priority(bind[i], the_pcu->vty.ns_priority);
|
2020-10-12 00:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
binds |= 1 << i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!binds) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to bind to any NS-VC\n");
|
2021-02-15 04:50:10 +00:00
|
|
|
gprs_ns2_free_nses(the_pcu->nsi);
|
2020-10-12 00:27:22 +00:00
|
|
|
return -1;
|
2020-10-09 23:00:05 +00:00
|
|
|
}
|
2020-09-16 19:52:02 +00:00
|
|
|
|
2020-10-12 00:27:22 +00:00
|
|
|
for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
|
|
|
|
if (!(binds & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
2021-01-25 19:28:38 +00:00
|
|
|
if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS) {
|
2020-12-09 00:41:24 +00:00
|
|
|
rc = gprs_ns2_sns_add_endpoint(bts->nse, &remote[i]);
|
2021-02-15 04:50:10 +00:00
|
|
|
if (rc && rc != -EALREADY) {
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to add SNS endpoint %s!\n", osmo_sockaddr_to_str(&remote[i]));
|
2020-10-12 00:27:22 +00:00
|
|
|
return rc;
|
2021-02-15 04:50:10 +00:00
|
|
|
} else {
|
|
|
|
sns_configured = true;
|
|
|
|
}
|
2020-10-12 00:27:22 +00:00
|
|
|
} else {
|
|
|
|
nsvc = gprs_ns2_ip_connect(bind[i], &remote[i], bts->nse, nsvci[i]);
|
|
|
|
if (nsvc)
|
|
|
|
nsvcs = true;
|
|
|
|
else
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to connect to towards SGSN %s!\n", osmo_sockaddr_to_str(&remote[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-15 04:50:10 +00:00
|
|
|
if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS)
|
|
|
|
return sns_configured ? 0 : -1;
|
|
|
|
else
|
|
|
|
return nsvcs ? 0 : -1;
|
2020-10-12 00:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct nsvc_cb {
|
|
|
|
const struct osmo_sockaddr *local;
|
|
|
|
const struct osmo_sockaddr *remote;
|
|
|
|
const uint16_t *nsvci;
|
|
|
|
/* [in] bitmask of valid nsvc in local/remote */
|
|
|
|
uint16_t valid;
|
|
|
|
/* [out] bitmask of found nsvcs */
|
|
|
|
uint16_t found;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int ns_conf_vc_cb(struct gprs_ns2_vc *nsvc, void *ctx)
|
|
|
|
{
|
|
|
|
struct nsvc_cb *data = (struct nsvc_cb *) ctx;
|
2021-01-18 16:14:14 +00:00
|
|
|
unsigned int i;
|
2020-10-12 00:27:22 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
|
2020-10-12 00:27:22 +00:00
|
|
|
if (!(data->valid & (1 << i)))
|
|
|
|
continue;
|
|
|
|
if (data->found & (1 << i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (gprs_ns2_ip_vc_equal(nsvc, &data->local[i],
|
|
|
|
&data->remote[i],
|
|
|
|
data->nsvci[i])) {
|
|
|
|
data->found |= 1 << i;
|
|
|
|
return 0;
|
|
|
|
}
|
2015-08-17 12:43:52 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 00:27:22 +00:00
|
|
|
/* Found an extra nsvc */
|
|
|
|
LOGP(DBSSGP, LOGL_DEBUG, " Removing NSVC %s\n", gprs_ns2_ll_str(nsvc));
|
|
|
|
gprs_ns2_free_nsvc(nsvc);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-16 15:57:15 +00:00
|
|
|
/* update the ns configuration if needed */
|
|
|
|
int gprs_ns_update_config(struct gprs_rlcmac_bts *bts, uint16_t nsei,
|
|
|
|
const struct osmo_sockaddr *local,
|
|
|
|
const struct osmo_sockaddr *remote,
|
|
|
|
uint16_t *nsvci, uint16_t valid)
|
2020-10-12 00:27:22 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
if (!bts->nse) {
|
|
|
|
/* there shouldn't any previous state. */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
gprs_ns2_free_nses(the_pcu->nsi);
|
|
|
|
gprs_ns2_free_binds(the_pcu->nsi);
|
2021-02-15 04:50:10 +00:00
|
|
|
rc = ns_configure_nse(bts, nsei, local, remote, nsvci, valid);
|
2020-10-12 00:27:22 +00:00
|
|
|
} else if (nsei != gprs_ns2_nse_nsei(bts->nse)) {
|
|
|
|
/* the NSEI has changed */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
gprs_ns2_free_nses(the_pcu->nsi);
|
|
|
|
gprs_ns2_free_binds(the_pcu->nsi);
|
2021-02-15 04:50:10 +00:00
|
|
|
rc = ns_configure_nse(bts, nsei, local, remote, nsvci, valid);
|
2021-01-25 19:28:38 +00:00
|
|
|
} else if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS) {
|
2020-10-12 00:27:22 +00:00
|
|
|
/* SNS: check if the initial nsvc is the same, if not recreate it */
|
|
|
|
const struct osmo_sockaddr *initial = gprs_ns2_nse_sns_remote(bts->nse);
|
2021-01-18 16:14:14 +00:00
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
|
2020-10-12 00:27:22 +00:00
|
|
|
if (!(valid & (1 << i)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* found the initial - everything should be fine */
|
|
|
|
if (!osmo_sockaddr_cmp(initial, &remote[i]))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
gprs_ns2_free_nses(the_pcu->nsi);
|
|
|
|
gprs_ns2_free_binds(the_pcu->nsi);
|
2021-02-15 04:50:10 +00:00
|
|
|
rc = ns_configure_nse(bts, nsei, local, remote, nsvci, valid);
|
2020-09-16 19:52:02 +00:00
|
|
|
} else {
|
2020-10-12 00:27:22 +00:00
|
|
|
/* check if all NSVC are still the same. */
|
|
|
|
struct nsvc_cb data = {
|
|
|
|
.local = &local[0],
|
|
|
|
.remote = &remote[0],
|
|
|
|
.nsvci = &nsvci[0],
|
|
|
|
.valid = valid,
|
|
|
|
.found = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* search the current active nsvcs */
|
|
|
|
gprs_ns2_nse_foreach_nsvc(bts->nse, &ns_conf_vc_cb, &data);
|
|
|
|
|
|
|
|
/* we found all our valid nsvcs and might have removed all other nsvcs */
|
|
|
|
if (valid == data.found)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* remove all found nsvcs from the valid field */
|
|
|
|
valid &= ~data.found;
|
2021-02-15 04:50:10 +00:00
|
|
|
rc = ns_configure_nse(bts, nsei, local, remote, nsvci, valid);
|
2020-09-16 19:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rc)
|
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to connect!\n");
|
|
|
|
|
|
|
|
return rc;
|
2015-08-17 12:43:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-16 19:52:02 +00:00
|
|
|
struct gprs_bssgp_pcu *gprs_bssgp_init(
|
|
|
|
struct gprs_rlcmac_bts *bts,
|
|
|
|
uint16_t nsei, uint16_t bvci,
|
|
|
|
uint16_t mcc, uint16_t mnc, bool mnc_3_digits,
|
|
|
|
uint16_t lac, uint16_t rac, uint16_t cell_id)
|
2012-07-06 06:58:22 +00:00
|
|
|
{
|
|
|
|
|
2013-07-28 17:11:20 +00:00
|
|
|
/* if already created... return the current address */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
if (the_pcu->bssgp.bctx)
|
|
|
|
return &the_pcu->bssgp;
|
2012-07-06 06:58:22 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bts = bts;
|
|
|
|
the_pcu->bssgp.bctx = btsctx_alloc(bvci, nsei);
|
|
|
|
if (!the_pcu->bssgp.bctx) {
|
2012-07-06 09:04:57 +00:00
|
|
|
LOGP(DBSSGP, LOGL_ERROR, "Failed to create BSSGP context\n");
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bts->nse = NULL;
|
2013-07-28 17:11:20 +00:00
|
|
|
return NULL;
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
2021-02-17 01:31:37 +00:00
|
|
|
the_pcu->bssgp.bctx->is_sgsn = false;
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->ra_id.mcc = spoof_mcc ? : mcc;
|
2018-02-20 23:39:07 +00:00
|
|
|
if (spoof_mnc) {
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->ra_id.mnc = spoof_mnc;
|
|
|
|
the_pcu->bssgp.bctx->ra_id.mnc_3_digits = spoof_mnc_3_digits;
|
2018-02-20 23:39:07 +00:00
|
|
|
} else {
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->ra_id.mnc = mnc;
|
|
|
|
the_pcu->bssgp.bctx->ra_id.mnc_3_digits = mnc_3_digits;
|
2018-02-20 23:39:07 +00:00
|
|
|
}
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.bctx->ra_id.lac = lac;
|
|
|
|
the_pcu->bssgp.bctx->ra_id.rac = rac;
|
|
|
|
the_pcu->bssgp.bctx->cell_id = cell_id;
|
2012-07-06 06:58:22 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
osmo_timer_setup(&the_pcu->bssgp.bvc_timer, bvc_timeout, bts);
|
2012-09-23 04:41:21 +00:00
|
|
|
|
2021-07-05 09:11:42 +00:00
|
|
|
the_pcu->bssgp.ctrs = rate_ctr_group_alloc(the_pcu, &sgsn_ctrg_desc, 0);
|
|
|
|
OSMO_ASSERT(the_pcu->bssgp.ctrs)
|
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
return &the_pcu->bssgp;
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-16 19:52:02 +00:00
|
|
|
void gprs_bssgp_destroy(struct gprs_rlcmac_bts *bts)
|
2012-07-06 06:58:22 +00:00
|
|
|
{
|
2021-07-05 09:11:42 +00:00
|
|
|
rate_ctr_group_free(the_pcu->bssgp.ctrs);
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
osmo_timer_del(&the_pcu->bssgp.bvc_timer);
|
2012-09-23 04:41:21 +00:00
|
|
|
|
2012-07-06 06:58:22 +00:00
|
|
|
/* FIXME: blocking... */
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.nsvc_unblocked = 0;
|
|
|
|
the_pcu->bssgp.bvc_sig_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_reset = 0;
|
|
|
|
the_pcu->bssgp.bvc_unblocked = 0;
|
2012-07-06 06:58:22 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
bssgp_bvc_ctx_free(the_pcu->bssgp.bctx);
|
|
|
|
the_pcu->bssgp.bctx = NULL;
|
2020-09-16 19:52:02 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
gprs_ns2_free(the_pcu->nsi);
|
|
|
|
the_pcu->nsi = NULL;
|
2020-09-16 19:52:02 +00:00
|
|
|
bts->nse = NULL;
|
2012-07-06 06:58:22 +00:00
|
|
|
}
|
|
|
|
|
2015-09-07 16:49:00 +00:00
|
|
|
void gprs_bssgp_update_frames_sent()
|
|
|
|
{
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.queue_frames_sent += 1;
|
2015-09-07 16:49:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gprs_bssgp_update_bytes_received(unsigned bytes_recv, unsigned frames_recv)
|
|
|
|
{
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.queue_bytes_recv += bytes_recv;
|
|
|
|
the_pcu->bssgp.queue_frames_recv += frames_recv;
|
2015-09-07 16:49:00 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 13:04:52 +00:00
|
|
|
void gprs_bssgp_update_queue_delay(const struct timespec *tv_recv,
|
|
|
|
const struct timespec *tv_now)
|
2015-05-06 12:24:36 +00:00
|
|
|
{
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
struct timespec *delay_sum = &the_pcu->bssgp.queue_delay_sum;
|
2020-03-11 13:04:52 +00:00
|
|
|
struct timespec tv_delay;
|
2015-05-06 12:24:36 +00:00
|
|
|
|
2020-03-11 13:04:52 +00:00
|
|
|
timespecsub(tv_now, tv_recv, &tv_delay);
|
|
|
|
timespecadd(delay_sum, &tv_delay, delay_sum);
|
2015-05-06 12:24:36 +00:00
|
|
|
|
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.
This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.
This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.
The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.
Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-13 17:54:38 +00:00
|
|
|
the_pcu->bssgp.queue_delay_count += 1;
|
2015-05-06 12:24:36 +00:00
|
|
|
}
|