2012-03-05 15:24:57 +00:00
|
|
|
/* pcu_l1_if.h
|
2012-02-04 22:27:17 +00:00
|
|
|
*
|
2012-03-05 15:24:57 +00:00
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
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.
|
|
|
|
*/
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
#ifndef PCU_L1_IF_H
|
|
|
|
#define PCU_L1_IF_H
|
2012-02-04 22:27:17 +00:00
|
|
|
|
2012-06-23 08:33:16 +00:00
|
|
|
#include <stdint.h>
|
2012-12-18 09:47:28 +00:00
|
|
|
#ifdef __cplusplus
|
2012-03-18 11:48:51 +00:00
|
|
|
extern "C" {
|
2012-12-18 09:47:28 +00:00
|
|
|
#endif
|
2012-03-18 11:48:51 +00:00
|
|
|
#include <osmocom/core/write_queue.h>
|
|
|
|
#include <osmocom/core/socket.h>
|
|
|
|
#include <osmocom/core/timer.h>
|
2012-06-23 08:33:16 +00:00
|
|
|
#include <osmocom/core/bitvec.h>
|
2012-03-18 11:48:51 +00:00
|
|
|
#include <osmocom/gsm/gsm_utils.h>
|
2017-03-08 17:53:30 +00:00
|
|
|
#include <osmocom/pcu/pcuif_proto.h>
|
2012-12-18 09:47:28 +00:00
|
|
|
#ifdef __cplusplus
|
2012-03-18 11:48:51 +00:00
|
|
|
}
|
2015-06-08 09:05:45 +00:00
|
|
|
#endif
|
|
|
|
|
2021-03-09 13:50:14 +00:00
|
|
|
#include "pdch.h"
|
|
|
|
|
2016-09-19 14:17:06 +00:00
|
|
|
static inline uint8_t qta2ta(int16_t qta)
|
|
|
|
{
|
|
|
|
if (qta < 0)
|
|
|
|
return 0;
|
|
|
|
if (qta > 252)
|
|
|
|
qta = 252;
|
|
|
|
return qta >> 2;
|
|
|
|
}
|
|
|
|
|
2017-11-01 18:41:37 +00:00
|
|
|
static inline int8_t sign_qta2ta(int16_t qta)
|
|
|
|
{
|
|
|
|
int8_t ta_adj = 0;
|
|
|
|
|
|
|
|
if (qta < -252)
|
|
|
|
qta = -252;
|
|
|
|
|
|
|
|
if (qta > 252)
|
|
|
|
qta = 252;
|
|
|
|
|
|
|
|
/* 1-bit TA adjustment if TA error reported by L1 is outside +/- 2 qbits */
|
|
|
|
if (qta > 2)
|
|
|
|
ta_adj = 1;
|
|
|
|
if (qta < -2)
|
|
|
|
ta_adj = -1;
|
|
|
|
|
|
|
|
return (qta >> 2) + ta_adj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint8_t ta_limit(int16_t ta)
|
|
|
|
{
|
|
|
|
if (ta < 0)
|
|
|
|
ta = 0;
|
|
|
|
if (ta > 63)
|
|
|
|
ta = 63;
|
|
|
|
return ta;
|
|
|
|
}
|
|
|
|
|
2015-06-08 09:05:45 +00:00
|
|
|
/*
|
|
|
|
* L1 Measurement values
|
|
|
|
*/
|
|
|
|
|
2015-06-11 14:54:50 +00:00
|
|
|
struct pcu_l1_meas_ts {
|
|
|
|
unsigned have_ms_i_level:1;
|
|
|
|
|
|
|
|
int16_t ms_i_level; /* I_LEVEL in dB */
|
|
|
|
};
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
static inline void pcu_l1_meas_ts_set_ms_i_level(struct pcu_l1_meas_ts* ts, int16_t v) {
|
|
|
|
ts->ms_i_level = v;
|
|
|
|
ts->have_ms_i_level = 1;
|
|
|
|
}
|
|
|
|
|
2015-06-08 09:05:45 +00:00
|
|
|
struct pcu_l1_meas {
|
|
|
|
unsigned have_rssi:1;
|
|
|
|
unsigned have_ber:1;
|
|
|
|
unsigned have_bto:1;
|
|
|
|
unsigned have_link_qual:1;
|
2015-06-11 14:54:50 +00:00
|
|
|
unsigned have_ms_rx_qual:1;
|
|
|
|
unsigned have_ms_c_value:1;
|
|
|
|
unsigned have_ms_sign_var:1;
|
|
|
|
unsigned have_ms_i_level:1;
|
2012-03-18 11:48:51 +00:00
|
|
|
|
2015-06-08 09:05:45 +00:00
|
|
|
int8_t rssi; /* RSSI in dBm */
|
|
|
|
uint8_t ber; /* Bit error rate in % */
|
|
|
|
int16_t bto; /* Burst timing offset in quarter bits */
|
2015-06-11 14:54:50 +00:00
|
|
|
int16_t link_qual; /* Link quality in dB */
|
|
|
|
int16_t ms_rx_qual; /* MS RXQUAL value in % */
|
|
|
|
int16_t ms_c_value; /* C value in dB */
|
|
|
|
int16_t ms_sign_var; /* SIGN_VAR in dB */
|
|
|
|
|
|
|
|
struct pcu_l1_meas_ts ts[8];
|
2015-06-08 09:05:45 +00:00
|
|
|
};
|
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
static inline void pcu_l1_meas_set_rssi(struct pcu_l1_meas *m, int8_t v) {
|
|
|
|
m->rssi = v;
|
|
|
|
m->have_rssi = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_ber(struct pcu_l1_meas *m, uint8_t v) {
|
|
|
|
m->ber = v;
|
|
|
|
m->have_ber = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_bto(struct pcu_l1_meas *m, int16_t v) {
|
|
|
|
m->bto = v;
|
|
|
|
m->have_bto = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_link_qual(struct pcu_l1_meas *m, int16_t v) {
|
|
|
|
m->link_qual = v;
|
|
|
|
m->have_link_qual = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_ms_rx_qual(struct pcu_l1_meas *m, int16_t v) {
|
|
|
|
m->ms_rx_qual = v;
|
|
|
|
m->have_ms_rx_qual = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_ms_c_value(struct pcu_l1_meas *m, int16_t v) {
|
|
|
|
m->ms_c_value = v;
|
|
|
|
m->have_ms_c_value = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_ms_sign_var(struct pcu_l1_meas *m, int16_t v) {
|
|
|
|
m->ms_sign_var = v;
|
|
|
|
m->have_ms_sign_var = 1;
|
|
|
|
}
|
|
|
|
static inline void pcu_l1_meas_set_ms_i_level(struct pcu_l1_meas *m, size_t idx, int16_t v) {
|
|
|
|
pcu_l1_meas_ts_set_ms_i_level(&m->ts[idx], v);
|
|
|
|
m->have_ms_i_level = 1;
|
|
|
|
}
|
|
|
|
|
2015-06-08 09:05:45 +00:00
|
|
|
#ifdef __cplusplus
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts;
|
|
|
|
void pcu_l1if_tx_pdtch(msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
|
|
|
|
uint16_t arfcn, uint32_t fn, uint8_t block_nr);
|
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
|
|
|
void pcu_l1if_tx_ptcch(struct gprs_rlcmac_bts *bts,
|
|
|
|
uint8_t trx, uint8_t ts, uint16_t arfcn,
|
2019-10-05 15:22:08 +00:00
|
|
|
uint32_t fn, uint8_t block_nr,
|
|
|
|
uint8_t *data, size_t data_len);
|
2021-01-18 16:14:14 +00:00
|
|
|
void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec * block, int len);
|
2012-07-12 10:49:15 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen, uint16_t pgroup);
|
2012-12-18 09:47:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2015-08-26 11:22:28 +00:00
|
|
|
extern "C" {
|
2012-12-18 09:47:28 +00:00
|
|
|
#endif
|
2021-01-18 16:14:14 +00:00
|
|
|
struct gprs_rlcmac_bts;
|
|
|
|
|
Support Neighbor Address Resolution over PCUIF IPA multiplex
While NACC was initially developed, it became clear there was need for
a way to interact PCU<->BSC in order resolve ARFCN+BSIC into CGI-PS
for later RIM usage.
Hence, this resolution was first (until today) implemented using an out
of bands RPC system using the CTRL interface, which required specific
config to be written and matches in osmo-pcu and osmo-bsc VTY (ip+port
of the CTRL interface to use).
However, this has several shortcomings:
* As explained above, specific configuration is required
* Since recently, we do support BSC redundancy in osmo-bts. Hence the BTS
may switch to a BSC other than first one. If that happened, that'd mean
the CTRL interface would still point to the initially configured one,
which may not be the same currently serving the PCU.
During recent development of ANR related features, a similar need for
PCU<->BSC was required, but this time it was decided to extend the IPA
multiplex of the Abis OML connection to pass PCUIF messages,
transparently forwarded to each side by the BTS.
This has the advantage that connection PCU<->BTS is handled by BTS and
both sides send messages transparently.
Let's switch by default to using this new interface, while still
maintaing the old way for a while (announcing them as deprecated) to
avoid breaking existing deployments until they are upgraded to new
versions of osmo-pcu and osmo-bsc.
Related: SYS#4971
Change-Id: I6ad33c7ab10202840cf804dea9ba595978d0e920
2021-09-07 12:09:50 +00:00
|
|
|
int pcu_tx_neigh_addr_res_req(struct gprs_rlcmac_bts *bts, const struct neigh_cache_entry_key *neigh_key);
|
|
|
|
|
2021-06-23 17:46:07 +00:00
|
|
|
int pcu_rx(struct gsm_pcu_if *pcu_prim, size_t pcu_prim_length);
|
2021-01-18 16:54:30 +00:00
|
|
|
int pcu_l1if_open(void);
|
|
|
|
void pcu_l1if_close(void);
|
|
|
|
int pcu_sock_send(struct msgb *msg);
|
|
|
|
|
|
|
|
int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...);
|
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
int pcu_rx_rts_req_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
|
2012-12-18 09:47:28 +00:00
|
|
|
uint32_t fn, uint8_t block_nr);
|
2021-01-18 16:14:14 +00:00
|
|
|
int pcu_rx_rts_req_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
|
2019-10-05 15:22:08 +00:00
|
|
|
uint32_t fn, uint8_t block_nr);
|
2012-12-18 09:47:28 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
int pcu_rx_rach_ind_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx_nr, uint8_t ts_nr, uint32_t fn, int16_t qta);
|
2021-03-09 13:50:14 +00:00
|
|
|
int pcu_rx_data_ind_pdtch(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_pdch *pdch, uint8_t *data,
|
2015-06-08 09:05:45 +00:00
|
|
|
uint8_t len, uint32_t fn, struct pcu_l1_meas *meas);
|
2012-12-18 09:47:28 +00:00
|
|
|
|
2021-01-18 16:14:14 +00:00
|
|
|
void pcu_rx_block_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no);
|
2019-12-23 11:41:34 +00:00
|
|
|
uint16_t imsi2paging_group(const char* imsi);
|
2021-06-23 17:46:07 +00:00
|
|
|
|
|
|
|
#define PCUIF_HDR_SIZE ( sizeof(struct gsm_pcu_if) - sizeof(((struct gsm_pcu_if *)0)->u) )
|
|
|
|
|
2015-08-26 11:22:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2012-03-05 15:24:57 +00:00
|
|
|
#endif // PCU_L1_IF_H
|