blob: a14a4eefc2e3911f3fb5974ab8f01966cfee8d15 [file] [log] [blame]
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04001/* pcu_l1_if.cpp
2 *
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +04003 * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040020#include <stdio.h>
21#include <unistd.h>
Pau Espin Pedrol32499b62019-12-09 13:55:12 +010022#include <inttypes.h>
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040023#include <stdlib.h>
Andreas Eversberg0aed6542012-06-23 10:33:16 +020024#include <string.h>
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040025#include <errno.h>
26#include <assert.h>
Andreas Eversberg0aed6542012-06-23 10:33:16 +020027#include <sys/socket.h>
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040028#include <sys/un.h>
Andreas Eversberg81a12be2013-03-16 16:16:41 +010029#include <arpa/inet.h>
Pau Espin Pedrol754b0932020-03-26 14:47:13 +010030#include <ctype.h>
Max1187a772018-01-26 13:31:42 +010031
Andreas Eversberg0aed6542012-06-23 10:33:16 +020032extern "C" {
33#include <osmocom/core/talloc.h>
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040034#include <osmocom/core/select.h>
35#include <osmocom/core/msgb.h>
Max528ff392016-02-22 11:42:33 +010036#include <osmocom/core/gsmtap_util.h>
37#include <osmocom/core/gsmtap.h>
Max1187a772018-01-26 13:31:42 +010038#include <osmocom/core/bitvec.h>
Alexander Couzens290d9032020-09-16 21:52:02 +020039#include <osmocom/core/sockaddr_str.h>
Max1187a772018-01-26 13:31:42 +010040#include <osmocom/core/logging.h>
41#include <osmocom/core/utils.h>
Alexander Couzens5bece2a2020-10-12 02:27:22 +020042#include <osmocom/gprs/gprs_ns2.h>
Max1187a772018-01-26 13:31:42 +010043#include <osmocom/gsm/l1sap.h>
44#include <osmocom/gsm/protocol/gsm_04_08.h>
Pau Espin Pedrolfe8de452021-02-09 18:47:34 +010045#include <osmocom/gsm/gsm48_rest_octets.h>
Philipp Maiera58ec612021-01-25 23:43:52 +010046#include <osmocom/gsm/sysinfo.h>
Andreas Eversberg0aed6542012-06-23 10:33:16 +020047}
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040048
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040049#include <gprs_rlcmac.h>
50#include <pcu_l1_if.h>
51#include <gprs_debug.h>
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040052#include <gprs_bssgp_pcu.h>
Harald Welte68fc1272016-11-16 22:48:33 +010053#include <osmocom/pcu/pcuif_proto.h>
Holger Hans Peter Freyther67ed34e2013-10-17 17:01:54 +020054#include <bts.h>
Max6dc90b82018-02-19 17:17:28 +010055#include <pdch.h>
Pau Espin Pedrolbd9973a2020-09-22 15:57:37 +020056#include <tbf_ul.h>
57#include <tbf_dl.h>
Pau Espin Pedrol2182e622021-01-14 16:48:38 +010058#include <gprs_ms_storage.h>
Andreas Eversberg0aed6542012-06-23 10:33:16 +020059
Andreas Eversberga23c7ee2012-12-18 10:47:28 +010060// FIXME: move this, when changed from c++ to c.
61extern "C" {
Max58b66462016-05-13 10:34:15 +020062void *l1if_open_pdch(uint8_t trx_no, uint32_t hlayer1,
63 struct gsmtap_inst *gsmtap);
Andreas Eversberga23c7ee2012-12-18 10:47:28 +010064int l1if_connect_pdch(void *obj, uint8_t ts);
65int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn,
66 uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len);
67}
68
Andreas Eversberge266bd42012-07-13 14:00:21 +020069extern void *tall_pcu_ctx;
70
Pau Espin Pedrold7c32652019-12-23 12:41:34 +010071#define PAGING_GROUP_LEN 3
72
73/* returns [0,999] on success, > 999 on error */
74uint16_t imsi2paging_group(const char* imsi)
75{
76 uint16_t pgroup = 0;
Vadim Yanitskiybd0b0b32020-01-16 00:25:48 +070077 size_t len;
Pau Espin Pedrold7c32652019-12-23 12:41:34 +010078
Vadim Yanitskiybd0b0b32020-01-16 00:25:48 +070079 len = (imsi != NULL) ? strlen(imsi) : 0;
80 if (len < PAGING_GROUP_LEN)
Pau Espin Pedrold7c32652019-12-23 12:41:34 +010081 return 0xFFFF;
82 imsi += len - PAGING_GROUP_LEN;
83
84 while (*imsi != '\0') {
85 if (!isdigit(*imsi))
86 return 0xFFFF;
87 pgroup *= 10;
88 pgroup += *imsi - '0';
89 imsi++;
90 }
91 return pgroup;
92}
93
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040094/*
95 * PCU messages
96 */
Ivan Kluchnikove3a05962012-03-18 15:48:51 +040097
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +040098struct msgb *pcu_msgb_alloc(uint8_t msg_type, uint8_t bts_nr)
99{
100 struct msgb *msg;
101 struct gsm_pcu_if *pcu_prim;
102
103 msg = msgb_alloc(sizeof(struct gsm_pcu_if), "pcu_sock_tx");
104 if (!msg)
105 return NULL;
106 msgb_put(msg, sizeof(struct gsm_pcu_if));
107 pcu_prim = (struct gsm_pcu_if *) msg->data;
108 pcu_prim->msg_type = msg_type;
109 pcu_prim->bts_nr = bts_nr;
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400110
111 return msg;
112}
113
Max0a8fae82017-03-08 18:53:30 +0100114const struct value_string gsm_pcu_if_text_type_names[] = {
115 OSMO_VALUE_STRING(PCU_VERSION),
116 OSMO_VALUE_STRING(PCU_OML_ALERT),
117 { 0, NULL }
118};
119
120int pcu_tx_txt_ind(enum gsm_pcu_if_text_type t, const char *fmt, ...)
121{
122 struct gsm_pcu_if *pcu_prim;
123 struct gsm_pcu_if_txt_ind *txt;
124 va_list ap;
125 char *rep;
126 struct msgb *msg = pcu_msgb_alloc(PCU_IF_MSG_TXT_IND, 0);
127 if (!msg)
128 return -ENOMEM;
129
130 pcu_prim = (struct gsm_pcu_if *) msg->data;
131 txt = &pcu_prim->u.txt_ind;
132 txt->type = t;
133
134 va_start(ap, fmt);
135 rep = talloc_vasprintf(tall_pcu_ctx, fmt, ap);
136 va_end(ap);
137
138 if (!rep)
139 return -ENOMEM;
140
141 osmo_strlcpy(txt->text, rep, TXT_MAX_LEN);
142 talloc_free(rep);
143
144 LOGP(DL1IF, LOGL_INFO, "Sending %s TXT as %s to BTS\n", txt->text,
145 get_value_string(gsm_pcu_if_text_type_names, t));
146
147 return pcu_sock_send(msg);
148}
149
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100150static int pcu_tx_act_req(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t activate)
Ivan Kluchnikov4277f0c2012-04-12 14:24:35 +0400151{
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400152 struct msgb *msg;
153 struct gsm_pcu_if *pcu_prim;
154 struct gsm_pcu_if_act_req *act_req;
155
156 LOGP(DL1IF, LOGL_INFO, "Sending %s request: trx=%d ts=%d\n",
157 (activate) ? "activate" : "deactivate", trx, ts);
158
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100159 msg = pcu_msgb_alloc(PCU_IF_MSG_ACT_REQ, bts->nr);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400160 if (!msg)
161 return -ENOMEM;
162 pcu_prim = (struct gsm_pcu_if *) msg->data;
163 act_req = &pcu_prim->u.act_req;
164 act_req->activate = activate;
165 act_req->trx_nr = trx;
166 act_req->ts_nr = ts;
167
168 return pcu_sock_send(msg);
169}
170
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100171static int pcu_tx_data_req(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t sapi,
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400172 uint16_t arfcn, uint32_t fn, uint8_t block_nr, uint8_t *data,
173 uint8_t len)
174{
175 struct msgb *msg;
176 struct gsm_pcu_if *pcu_prim;
177 struct gsm_pcu_if_data *data_req;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100178 int current_fn = bts_current_frame_number(bts);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400179
180 LOGP(DL1IF, LOGL_DEBUG, "Sending data request: trx=%d ts=%d sapi=%d "
Philipp Maier7e8e3972018-04-10 13:31:45 +0200181 "arfcn=%d fn=%d cur_fn=%d block=%d data=%s\n", trx, ts, sapi, arfcn, fn, current_fn,
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400182 block_nr, osmo_hexdump(data, len));
183
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100184 msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_REQ, bts->nr);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400185 if (!msg)
186 return -ENOMEM;
187 pcu_prim = (struct gsm_pcu_if *) msg->data;
188 data_req = &pcu_prim->u.data_req;
189
190 data_req->sapi = sapi;
191 data_req->fn = fn;
192 data_req->arfcn = arfcn;
193 data_req->trx_nr = trx;
194 data_req->ts_nr = ts;
195 data_req->block_nr = block_nr;
196 memcpy(data_req->data, data, len);
197 data_req->len = len;
198
199 return pcu_sock_send(msg);
200}
201
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100202void pcu_l1if_tx_pdtch(msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint16_t arfcn,
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400203 uint32_t fn, uint8_t block_nr)
204{
Maxb216c6b2017-09-01 11:00:39 +0200205#ifdef ENABLE_DIRECT_PHY
Max528ff392016-02-22 11:42:33 +0100206 if (bts->trx[trx].fl1h) {
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100207 l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr,
208 msg->data, msg->len);
Max528ff392016-02-22 11:42:33 +0100209 msgb_free(msg);
210 return;
211 }
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100212#endif
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100213 pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PDTCH, arfcn, fn, block_nr,
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100214 msg->data, msg->len);
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200215 msgb_free(msg);
Ivan Kluchnikov4277f0c2012-04-12 14:24:35 +0400216}
217
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100218void pcu_l1if_tx_ptcch(struct gprs_rlcmac_bts *bts,
219 uint8_t trx, uint8_t ts, uint16_t arfcn,
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700220 uint32_t fn, uint8_t block_nr,
221 uint8_t *data, size_t data_len)
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400222{
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100223 if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PTCCH))
224 gsmtap_send(the_pcu->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, data, data_len);
Maxcad867e2016-04-21 14:35:55 +0200225#ifdef ENABLE_DIRECT_PHY
Max528ff392016-02-22 11:42:33 +0100226 if (bts->trx[trx].fl1h) {
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700227 l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr, data, data_len);
Max528ff392016-02-22 11:42:33 +0100228 return;
229 }
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100230#endif
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100231 pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, data, data_len);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400232}
233
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100234void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen)
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400235{
Pau Espin Pedrold752d7c2019-10-07 20:56:48 +0200236 uint8_t data[GSM_MACBLOCK_LEN]; /* prefix PLEN */
237
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400238 /* FIXME: why does OpenBTS has no PLEN and no fill in message? */
239 bitvec_pack(block, data + 1);
240 data[0] = (plen << 2) | 0x01;
Pau Espin Pedrol58543702019-09-30 19:07:16 +0200241
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100242 if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_AGCH))
243 gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_AGCH, 0, 0, 0, 0, data, GSM_MACBLOCK_LEN);
Pau Espin Pedrol58543702019-09-30 19:07:16 +0200244
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100245 pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, GSM_MACBLOCK_LEN);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400246}
247
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100248void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen, uint16_t pgroup)
Ivan Kluchnikovc7e7f682012-06-29 22:53:15 +0400249{
Pau Espin Pedrol8dc09e72019-10-07 20:56:02 +0200250 uint8_t data[PAGING_GROUP_LEN + GSM_MACBLOCK_LEN];
Pau Espin Pedrold7c32652019-12-23 12:41:34 +0100251 int i;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400252
Pau Espin Pedrol8dc09e72019-10-07 20:56:02 +0200253 /* prepend paging group */
Pau Espin Pedrold7c32652019-12-23 12:41:34 +0100254 for (i = 0; i < PAGING_GROUP_LEN; i++) {
255 data[PAGING_GROUP_LEN - 1 - i] = '0' + (char)(pgroup % 10);
256 pgroup = pgroup / 10;
257 }
258 OSMO_ASSERT(pgroup == 0);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400259
Pau Espin Pedrol8dc09e72019-10-07 20:56:02 +0200260 /* block provided by upper layer comes without first byte (plen),
261 * prepend it manually:
262 */
263 OSMO_ASSERT(sizeof(data) >= PAGING_GROUP_LEN + 1 + block->data_len);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400264 data[3] = (plen << 2) | 0x01;
Pau Espin Pedrol8dc09e72019-10-07 20:56:02 +0200265 bitvec_pack(block, data + PAGING_GROUP_LEN + 1);
Pau Espin Pedrol58543702019-09-30 19:07:16 +0200266
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100267 if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PCH))
268 gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_PCH, 0, 0, 0, 0, data + 3, GSM_MACBLOCK_LEN);
Pau Espin Pedrol58543702019-09-30 19:07:16 +0200269
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100270 pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, PAGING_GROUP_LEN + GSM_MACBLOCK_LEN);
Ivan Kluchnikovc7e7f682012-06-29 22:53:15 +0400271}
272
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100273void pcu_rx_block_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no)
Jacob Erlbeckaf75ce82015-08-26 13:22:28 +0200274{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100275 bts_set_current_block_frame_number(bts, fn, 0);
Jacob Erlbeckaf75ce82015-08-26 13:22:28 +0200276}
277
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100278void pcu_rx_ra_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no)
Jacob Erlbeckaf75ce82015-08-26 13:22:28 +0200279{
280 /* access bursts may arrive some bursts earlier */
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100281 bts_set_current_block_frame_number(bts, fn, 5);
Jacob Erlbeckaf75ce82015-08-26 13:22:28 +0200282}
283
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100284int pcu_rx_data_ind_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx_no, uint8_t ts_no, uint8_t *data,
Jacob Erlbeck20f6fd12015-06-08 11:05:45 +0200285 uint8_t len, uint32_t fn, struct pcu_l1_meas *meas)
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100286{
Holger Hans Peter Freyther9ae367f2013-10-26 16:42:38 +0200287 struct gprs_rlcmac_pdch *pdch;
288
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100289 pdch = &bts->trx[trx_no].pdch[ts_no];
Jacob Erlbeck20f6fd12015-06-08 11:05:45 +0200290 return pdch->rcv_block(data, len, fn, meas);
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100291}
292
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100293static int pcu_rx_data_ind_bcch(struct gprs_rlcmac_bts *bts, uint8_t *data, uint8_t len)
Max84bf0fa2017-09-01 11:02:40 +0200294{
Pau Espin Pedrolfe8de452021-02-09 18:47:34 +0100295 const uint8_t *si_ro;
Philipp Maiera58ec612021-01-25 23:43:52 +0100296 switch (len) {
297 case 0:
298 /* Due to historical reasons also accept a completely empty message as
299 * revoke command for SI13. */
300 LOGP(DL1IF, LOGL_ERROR,
301 "Received PCU data indication that contains no data -- Revoked SI13.\n");
Max84bf0fa2017-09-01 11:02:40 +0200302 bts->si13_is_set = false;
Max84bf0fa2017-09-01 11:02:40 +0200303
Philipp Maiera58ec612021-01-25 23:43:52 +0100304 return 0;
305 case 1:
306 /* Revoke SI, type is identified by a single byte which is coded after
307 * enum osmo_sysinfo_type. */
308 switch (data[0]) {
309 case SYSINFO_TYPE_1:
310 bts->si1_is_set = false;
311 break;
312 case SYSINFO_TYPE_3:
313 bts->si3_is_set = false;
314 break;
315 case SYSINFO_TYPE_13:
316 bts->si13_is_set = false;
317 break;
318 default:
319 LOGP(DL1IF, LOGL_ERROR,
320 "Received PCU data indication that contains an unsupported system information identifier (%02x,OSMO) -- ignored.\n", data[0]);
321 return -EINVAL;
322 }
323 LOGP(DPCU, LOGL_DEBUG,
324 "Received PCU data indication: Revoked SI%s\n",
325 get_value_string(osmo_sitype_strs, data[0]));
326 return 0;
327 case GSM_MACBLOCK_LEN:
328 /* Update SI, type is identified by the RR sysinfo type, which is the
329 * 3rd byte in the buffer. */
330 switch (data[2]) {
331 case GSM48_MT_RR_SYSINFO_1:
332 memcpy(bts->si1, data, GSM_MACBLOCK_LEN);
333 bts->si1_is_set = true;
334 break;
335 case GSM48_MT_RR_SYSINFO_3:
336 memcpy(bts->si3, data, GSM_MACBLOCK_LEN);
337 bts->si3_is_set = true;
338 break;
339 case GSM48_MT_RR_SYSINFO_13:
340 memcpy(bts->si13, data, GSM_MACBLOCK_LEN);
341 bts->si13_is_set = true;
Pau Espin Pedrolfe8de452021-02-09 18:47:34 +0100342 si_ro = ((struct gsm48_system_information_type_13*)data)->rest_octets;
343 if (osmo_gsm48_rest_octets_si13_decode(&bts->si31_ro_decoded, si_ro) < 0)
344 LOGP(DPCU, LOGL_ERROR, "Error decoding SI13\n");
Philipp Maiera58ec612021-01-25 23:43:52 +0100345 break;
346 default:
347 LOGP(DL1IF, LOGL_ERROR,
348 "Received PCU data indication that contains an unsupported system information identifier (%02x,RR) -- ignored.\n", data[2]);
349 return -EINVAL;
350 }
351 LOGP(DPCU, LOGL_DEBUG,
352 "Received PCU data indication: Updated %s: %s\n",
353 gsm48_pdisc_msgtype_name(data[1], data[2]),
354 osmo_hexdump_nospc(data + 1, GSM_MACBLOCK_LEN));
355 return 0;
356 default:
357 LOGP(DL1IF, LOGL_ERROR,
358 "Received PCU data indication with unexpected data length: %u -- ignored.\n",
359 len);
Max84bf0fa2017-09-01 11:02:40 +0200360 return -EINVAL;
361 }
Max84bf0fa2017-09-01 11:02:40 +0200362}
363
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100364static int pcu_rx_data_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_ind)
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400365{
Max528ff392016-02-22 11:42:33 +0100366 int rc;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100367 int current_fn = bts_current_frame_number(bts);
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100368 struct pcu_l1_meas meas = {0};
Pau Espin Pedrol72e39562020-06-30 17:57:42 +0200369 uint8_t gsmtap_chantype;
Maxb216c6b2017-09-01 11:00:39 +0200370
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400371 LOGP(DL1IF, LOGL_DEBUG, "Data indication received: sapi=%d arfcn=%d "
Philipp Maier7e8e3972018-04-10 13:31:45 +0200372 "fn=%d cur_fn=%d block=%d data=%s\n", data_ind->sapi,
373 data_ind->arfcn, data_ind->fn, current_fn, data_ind->block_nr,
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400374 osmo_hexdump(data_ind->data, data_ind->len));
375
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400376 switch (data_ind->sapi) {
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400377 case PCU_IF_SAPI_PDTCH:
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100378 pcu_l1_meas_set_rssi(&meas, data_ind->rssi);
Maxb216c6b2017-09-01 11:00:39 +0200379 /* convert BER to % value */
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100380 pcu_l1_meas_set_ber(&meas, data_ind->ber10k / 100);
381 pcu_l1_meas_set_bto(&meas, data_ind->ta_offs_qbits);
382 pcu_l1_meas_set_link_qual(&meas, data_ind->lqual_cb / 10);
Vadim Yanitskiyf17dfc02019-07-09 16:16:35 +0700383
Maxb216c6b2017-09-01 11:00:39 +0200384 LOGP(DL1IF, LOGL_DEBUG, "Data indication with raw measurements received: BER10k = %d, BTO = %d, Q = %d\n",
385 data_ind->ber10k, data_ind->ta_offs_qbits, data_ind->lqual_cb);
Vadim Yanitskiyf17dfc02019-07-09 16:16:35 +0700386
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100387 rc = pcu_rx_data_ind_pdtch(bts, data_ind->trx_nr, data_ind->ts_nr,
Andreas Eversberg570b44b2013-03-16 16:15:01 +0100388 data_ind->data, data_ind->len, data_ind->fn,
Jacob Erlbeck20f6fd12015-06-08 11:05:45 +0200389 &meas);
Pau Espin Pedrol72e39562020-06-30 17:57:42 +0200390 gsmtap_chantype = GSMTAP_CHANNEL_PDTCH;
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400391 break;
Max84bf0fa2017-09-01 11:02:40 +0200392 case PCU_IF_SAPI_BCCH:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100393 rc = pcu_rx_data_ind_bcch(bts, data_ind->data, data_ind->len);
Pau Espin Pedrol72e39562020-06-30 17:57:42 +0200394 gsmtap_chantype = GSMTAP_CHANNEL_BCCH;
Max84bf0fa2017-09-01 11:02:40 +0200395 break;
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400396 default:
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400397 LOGP(DL1IF, LOGL_ERROR, "Received PCU data indication with "
398 "unsupported sapi %d\n", data_ind->sapi);
399 rc = -EINVAL;
Pau Espin Pedrol72e39562020-06-30 17:57:42 +0200400 gsmtap_chantype = GSMTAP_CHANNEL_UNKNOWN;
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400401 }
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400402
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100403 if (rc < 0 && (the_pcu->gsmtap_categ_mask & (1 <<PCU_GSMTAP_C_UL_UNKNOWN))) {
404 gsmtap_send(the_pcu->gsmtap, data_ind->arfcn | GSMTAP_ARFCN_F_UPLINK, data_ind->ts_nr,
Pau Espin Pedrol72e39562020-06-30 17:57:42 +0200405 gsmtap_chantype, 0, data_ind->fn, meas.rssi, meas.link_qual, data_ind->data, data_ind->len);
Harald Welte717cdf52017-07-21 21:56:23 +0200406 }
407
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400408 return rc;
409}
410
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100411static int pcu_rx_data_cnf(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_cnf)
Andreas Eversberga9be1542012-09-27 09:23:24 +0200412{
413 int rc = 0;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100414 int current_fn = bts_current_frame_number(bts);
Andreas Eversberga9be1542012-09-27 09:23:24 +0200415
Philipp Maier7e8e3972018-04-10 13:31:45 +0200416 LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d fn=%d cur_fn=%d\n",
417 data_cnf->sapi, data_cnf->fn, current_fn);
Andreas Eversberga9be1542012-09-27 09:23:24 +0200418
419 switch (data_cnf->sapi) {
420 case PCU_IF_SAPI_PCH:
Andreas Eversberg8c3680d2012-10-08 12:30:56 +0200421 if (data_cnf->data[2] == 0x3f)
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100422 bts_rcv_imm_ass_cnf(bts, data_cnf->data, data_cnf->fn);
Andreas Eversberga9be1542012-09-27 09:23:24 +0200423 break;
424 default:
425 LOGP(DL1IF, LOGL_ERROR, "Received PCU data confirm with "
426 "unsupported sapi %d\n", data_cnf->sapi);
427 rc = -EINVAL;
428 }
429
430 return rc;
431}
432
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100433// FIXME: remove this, when changed from c++ to c.
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100434int pcu_rx_rts_req_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100435 uint32_t fn, uint8_t block_nr)
436{
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100437 return gprs_rlcmac_rcv_rts_block(bts,
Max878bd1f2016-07-20 13:05:05 +0200438 trx, ts, fn, block_nr);
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100439}
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100440int pcu_rx_rts_req_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts,
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700441 uint32_t fn, uint8_t block_nr)
442{
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700443 struct gprs_rlcmac_pdch *pdch;
444
445 /* Prevent buffer overflow */
446 if (trx >= ARRAY_SIZE(bts->trx) || ts >= 8)
447 return -EINVAL;
448
449 /* Make sure PDCH time-slot is enabled */
450 pdch = &bts->trx[trx].pdch[ts];
451 if (!pdch->m_is_enabled)
452 return -EAGAIN;
453
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100454 pcu_l1if_tx_ptcch(bts, trx, ts, bts->trx[trx].arfcn, fn, block_nr,
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700455 pdch->ptcch_msg, GSM_MACBLOCK_LEN);
456 return 0;
457}
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100458
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100459static int pcu_rx_rts_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_rts_req *rts_req)
Ivan Kluchnikov5310d452012-04-17 22:00:31 +0400460{
461 int rc = 0;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100462 int current_fn = bts_current_frame_number(bts);
Ivan Kluchnikov5310d452012-04-17 22:00:31 +0400463
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400464 LOGP(DL1IF, LOGL_DEBUG, "RTS request received: trx=%d ts=%d sapi=%d "
Philipp Maier7e8e3972018-04-10 13:31:45 +0200465 "arfcn=%d fn=%d cur_fn=%d block=%d\n", rts_req->trx_nr, rts_req->ts_nr,
466 rts_req->sapi, rts_req->arfcn, rts_req->fn, current_fn, rts_req->block_nr);
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400467
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400468 switch (rts_req->sapi) {
469 case PCU_IF_SAPI_PDTCH:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100470 pcu_rx_rts_req_pdtch(bts, rts_req->trx_nr, rts_req->ts_nr,
Max878bd1f2016-07-20 13:05:05 +0200471 rts_req->fn, rts_req->block_nr);
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400472 break;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400473 case PCU_IF_SAPI_PTCCH:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100474 pcu_rx_rts_req_ptcch(bts, rts_req->trx_nr, rts_req->ts_nr,
Vadim Yanitskiy78f58612019-10-05 22:22:08 +0700475 rts_req->fn, rts_req->block_nr);
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400476 break;
477 default:
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400478 LOGP(DL1IF, LOGL_ERROR, "Received PCU RTS request with "
479 "unsupported sapi %d\n", rts_req->sapi);
480 rc = -EINVAL;
481 }
482
483 return rc;
484}
485
Vadim Yanitskiyffebd242019-10-05 23:45:31 +0700486/* C -> C++ adapter for direct DSP access code (e.g. osmo-bts-sysmo) */
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100487extern "C" 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)
Vadim Yanitskiyffebd242019-10-05 23:45:31 +0700488{
Vadim Yanitskiya0a0b7f2020-05-21 19:55:46 +0700489 struct rach_ind_params rip = {
490 /* The content of RA is not of interest on PTCCH/U */
491 .burst_type = GSM_L1_BURST_TYPE_ACCESS_0,
492 .is_11bit = false,
493 .ra = 0x00,
494 .trx_nr = trx_nr,
495 .ts_nr = ts_nr,
496 .rfn = fn,
497 .qta = qta,
498 };
499
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100500 return bts_rcv_ptcch_rach(bts, &rip);
Vadim Yanitskiyffebd242019-10-05 23:45:31 +0700501}
502
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100503static int pcu_rx_rach_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_rach_ind *rach_ind)
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400504{
505 int rc = 0;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100506 int current_fn = bts_current_frame_number(bts);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400507
508 LOGP(DL1IF, LOGL_INFO, "RACH request received: sapi=%d "
Vadim Yanitskiyb30f28f2020-03-29 19:01:58 +0700509 "qta=%d, ra=0x%02x, fn=%u, cur_fn=%d, is_11bit=%d\n", rach_ind->sapi, rach_ind->qta,
Philipp Maier7e8e3972018-04-10 13:31:45 +0200510 rach_ind->ra, rach_ind->fn, current_fn, rach_ind->is_11bit);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400511
Vadim Yanitskiya0a0b7f2020-05-21 19:55:46 +0700512 struct rach_ind_params rip = {
513 .burst_type = (enum ph_burst_type) rach_ind->burst_type,
514 .is_11bit = rach_ind->is_11bit > 0,
515 .ra = rach_ind->ra,
516 .trx_nr = rach_ind->trx_nr,
517 .ts_nr = rach_ind->ts_nr,
518 .rfn = rach_ind->fn,
519 .qta = rach_ind->qta,
520 };
521
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400522 switch (rach_ind->sapi) {
523 case PCU_IF_SAPI_RACH:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100524 rc = bts_rcv_rach(bts, &rip);
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400525 break;
Vadim Yanitskiyffebd242019-10-05 23:45:31 +0700526 case PCU_IF_SAPI_PTCCH:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100527 rc = bts_rcv_ptcch_rach(bts, &rip);
Vadim Yanitskiyffebd242019-10-05 23:45:31 +0700528 break;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400529 default:
530 LOGP(DL1IF, LOGL_ERROR, "Received PCU rach request with "
531 "unsupported sapi %d\n", rach_ind->sapi);
532 rc = -EINVAL;
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400533 }
534
Ivan Kluchnikove3a05962012-03-18 15:48:51 +0400535 return rc;
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400536}
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200537
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200538static int pcu_info_ind_ns(struct gprs_rlcmac_bts *bts,
539 const struct gsm_pcu_if_info_ind *info_ind)
540{
541 struct osmo_sockaddr remote[PCU_IF_NUM_NSVC] = { };
542 struct osmo_sockaddr local[PCU_IF_NUM_NSVC] = { };
543 uint16_t nsvci[PCU_IF_NUM_NSVC] = { };
544 uint16_t valid = 0;
545
546 for (unsigned int i = 0; i < PCU_IF_NUM_NSVC; i++) {
547 struct osmo_sockaddr_str sockstr;
548
549 switch (info_ind->address_type[i]) {
550 case PCU_IF_ADDR_TYPE_IPV4:
551 local[i].u.sin.sin_family = AF_INET;
552 local[i].u.sin.sin_addr.s_addr = INADDR_ANY;
553 local[i].u.sin.sin_port = htons(info_ind->local_port[i]);
554
555 remote[i].u.sin.sin_family = AF_INET;
Alexander Couzens87c6dd32020-10-27 13:24:40 +0100556 memcpy(&remote[i].u.sin.sin_addr, &info_ind->remote_ip[i].v4,
557 sizeof(struct in_addr));
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200558 remote[i].u.sin.sin_port = htons(info_ind->remote_port[i]);
559 break;
560 case PCU_IF_ADDR_TYPE_IPV6:
561 local[i].u.sin6.sin6_family = AF_INET6;
562 local[i].u.sin6.sin6_addr = in6addr_any;
563 local[i].u.sin6.sin6_port = htons(info_ind->local_port[i]);
564
565 remote[i].u.sin6.sin6_family = AF_INET6;
Alexander Couzens87c6dd32020-10-27 13:24:40 +0100566 memcpy(&remote[i].u.sin6.sin6_addr,
567 &info_ind->remote_ip[i].v6,
568 sizeof(struct in6_addr));
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200569 remote[i].u.sin6.sin6_port = htons(info_ind->remote_port[i]);
570 break;
571 default:
572 continue;
573 }
574 nsvci[i] = info_ind->nsvci[i];
575
576 LOGP(DL1IF, LOGL_DEBUG, " NS%u nsvci=%u\n", i, nsvci[i]);
577 if (osmo_sockaddr_str_from_sockaddr(&sockstr, &remote[i].u.sas))
578 strcpy(sockstr.ip, "invalid");
579
580 LOGP(DL1IF, LOGL_DEBUG, " NS%u address: r=%s:%u<->l=NULL:%u\n",
581 i, sockstr.ip, sockstr.port, info_ind->local_port[i]);
582
583 valid |= 1 << i;
584 }
585
586 if (valid == 0) {
587 LOGP(DL1IF, LOGL_ERROR, "No NSVC available to connect to the SGSN!\n");
588 return -EINVAL;
589 }
590
Alexander Couzens94a367f2021-02-16 16:57:15 +0100591 return gprs_ns_update_config(bts, info_ind->nsei, local, remote, nsvci, valid);
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200592}
593
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100594static int pcu_rx_info_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_info_ind *info_ind)
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200595{
Holger Hans Peter Freythere8d9a5f2013-07-28 19:11:20 +0200596 struct gprs_bssgp_pcu *pcu;
Harald Weltebb47d952016-11-17 18:40:02 +0100597 int rc = 0;
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700598 unsigned int trx_nr, ts_nr;
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100599 unsigned int i;
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200600
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200601 if (info_ind->version != PCU_IF_VERSION) {
Vadim Yanitskiyfad21282020-07-19 02:05:33 +0700602 fprintf(stderr, "PCU interface version number of BTS (%u) is "
603 "different (%u).\nPlease re-compile!\n",
Andreas Eversberg8389fd02012-07-18 10:06:48 +0200604 info_ind->version, PCU_IF_VERSION);
605 exit(-1);
606 }
607
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400608 LOGP(DL1IF, LOGL_DEBUG, "Info indication received:\n");
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200609
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400610 if (!(info_ind->flags & PCU_IF_FLAG_ACTIVE)) {
611 LOGP(DL1IF, LOGL_NOTICE, "BTS not available\n");
Stefan Sperling5b22fb72018-02-14 19:46:33 +0100612 if (!bts->active)
613 return -EAGAIN;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400614bssgp_failed:
Stefan Sperling5b22fb72018-02-14 19:46:33 +0100615 bts->active = false;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400616 /* free all TBF */
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700617 for (trx_nr = 0; trx_nr < ARRAY_SIZE(bts->trx); trx_nr++) {
618 bts->trx[trx_nr].arfcn = info_ind->trx[trx_nr].arfcn;
619 for (ts_nr = 0; ts_nr < ARRAY_SIZE(bts->trx[0].pdch); ts_nr++)
620 bts->trx[trx_nr].pdch[ts_nr].free_resources();
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400621 }
Alexander Couzens290d9032020-09-16 21:52:02 +0200622 gprs_bssgp_destroy(bts);
Daniel Willmann6d8884d2014-06-04 18:30:59 +0200623 exit(0);
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200624 }
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400625 LOGP(DL1IF, LOGL_INFO, "BTS available\n");
Neels Hofmeyrbdc55fa2018-02-21 00:39:07 +0100626 LOGP(DL1IF, LOGL_DEBUG, " mcc=%03u\n", info_ind->mcc);
627 LOGP(DL1IF, LOGL_DEBUG, " mnc=%0*u\n", info_ind->mnc_3_digits, info_ind->mnc);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400628 LOGP(DL1IF, LOGL_DEBUG, " lac=%d\n", info_ind->lac);
629 LOGP(DL1IF, LOGL_DEBUG, " rac=%d\n", info_ind->rac);
Harald Welte1473b372019-03-21 19:48:55 +0100630 LOGP(DL1IF, LOGL_DEBUG, " cell_id=%d\n", info_ind->cell_id);
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100631 LOGP(DL1IF, LOGL_DEBUG, " bsic=%d\n", info_ind->bsic);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400632 LOGP(DL1IF, LOGL_DEBUG, " nsei=%d\n", info_ind->nsei);
633 LOGP(DL1IF, LOGL_DEBUG, " nse_timer=%d %d %d %d %d %d %d\n",
634 info_ind->nse_timer[0], info_ind->nse_timer[1],
635 info_ind->nse_timer[2], info_ind->nse_timer[3],
636 info_ind->nse_timer[4], info_ind->nse_timer[5],
637 info_ind->nse_timer[6]);
638 LOGP(DL1IF, LOGL_DEBUG, " cell_timer=%d %d %d %d %d %d %d %d %d %d "
639 "%d\n",
640 info_ind->cell_timer[0], info_ind->cell_timer[1],
641 info_ind->cell_timer[2], info_ind->cell_timer[3],
642 info_ind->cell_timer[4], info_ind->cell_timer[5],
643 info_ind->cell_timer[6], info_ind->cell_timer[7],
644 info_ind->cell_timer[8], info_ind->cell_timer[9],
645 info_ind->cell_timer[10]);
646 LOGP(DL1IF, LOGL_DEBUG, " repeat_time=%d\n", info_ind->repeat_time);
647 LOGP(DL1IF, LOGL_DEBUG, " repeat_count=%d\n", info_ind->repeat_count);
648 LOGP(DL1IF, LOGL_DEBUG, " bvci=%d\n", info_ind->bvci);
649 LOGP(DL1IF, LOGL_DEBUG, " t3142=%d\n", info_ind->t3142);
650 LOGP(DL1IF, LOGL_DEBUG, " t3169=%d\n", info_ind->t3169);
651 LOGP(DL1IF, LOGL_DEBUG, " t3191=%d\n", info_ind->t3191);
652 LOGP(DL1IF, LOGL_DEBUG, " t3193=%d (ms)\n", info_ind->t3193_10ms * 10);
653 LOGP(DL1IF, LOGL_DEBUG, " t3195=%d\n", info_ind->t3195);
654 LOGP(DL1IF, LOGL_DEBUG, " n3101=%d\n", info_ind->n3101);
655 LOGP(DL1IF, LOGL_DEBUG, " n3103=%d\n", info_ind->n3103);
656 LOGP(DL1IF, LOGL_DEBUG, " n3105=%d\n", info_ind->n3105);
657 LOGP(DL1IF, LOGL_DEBUG, " cv_countdown=%d\n", info_ind->cv_countdown);
658 LOGP(DL1IF, LOGL_DEBUG, " dl_tbf_ext=%d\n", info_ind->dl_tbf_ext);
659 LOGP(DL1IF, LOGL_DEBUG, " ul_tbf_ext=%d\n", info_ind->ul_tbf_ext);
Pau Espin Pedrol2e6b60d2021-01-20 13:48:31 +0100660 bts->cgi_ps.rai.lac.plmn.mcc = info_ind->mcc;
661 bts->cgi_ps.rai.lac.plmn.mnc = info_ind->mnc;
662 bts->cgi_ps.rai.lac.plmn.mnc_3_digits = info_ind->mnc_3_digits;
663 bts->cgi_ps.rai.lac.lac = info_ind->lac;
664 bts->cgi_ps.rai.rac = info_ind->rac;
665 bts->cgi_ps.cell_identity = info_ind->cell_id;
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100666 bts->bsic = info_ind->bsic;
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100667
668 bts->cs_mask = 1 << 0; /* We need at least 1 CS, let's enable CS1 */
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400669 for (i = 0; i < 4; i++) {
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100670 uint8_t allowed = !!(info_ind->flags & (PCU_IF_FLAG_CS1 << i));
671 bts->cs_mask |= allowed << i;
672 if (allowed)
673 LOGP(DL1IF, LOGL_DEBUG, " Use CS%d\n", i + 1);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400674 }
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100675 bts_recalc_max_cs(bts);
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100676
677 bts->mcs_mask = 0;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400678 for (i = 0; i < 9; i++) {
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100679 uint8_t allowed = !!(info_ind->flags & (PCU_IF_FLAG_MCS1 << i));
680 bts->mcs_mask |= allowed << i;
Pau Espin Pedrol87eec1f2020-10-30 18:46:24 +0100681 if (allowed)
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100682 LOGP(DL1IF, LOGL_DEBUG, " Use MCS%d\n", i + 1);
Pau Espin Pedrol87eec1f2020-10-30 18:46:24 +0100683
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400684 }
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100685 bts_recalc_max_mcs(bts);
Pau Espin Pedrold87722d2020-10-30 17:14:26 +0100686
Pau Espin Pedrolb47b1372020-11-03 15:59:39 +0100687 LOGP(DL1IF, LOGL_DEBUG, " initial_cs=%u%s\n", info_ind->initial_cs,
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100688 the_pcu->vty.force_initial_cs ? " (VTY forced, ignoring)" : "");
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100689 bts->pcuif_info_ind.initial_cs = info_ind->initial_cs;
690 bts_recalc_initial_cs(bts);
Pau Espin Pedrolb47b1372020-11-03 15:59:39 +0100691
692 LOGP(DL1IF, LOGL_DEBUG, " initial_mcs=%u%s\n", info_ind->initial_mcs,
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100693 the_pcu->vty.force_initial_mcs ? " (VTY forced, ignoring)" : "");
Pau Espin Pedrol793583e2021-01-14 16:20:57 +0100694 bts->pcuif_info_ind.initial_mcs = info_ind->initial_mcs;
695 bts_recalc_initial_mcs(bts);
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200696
Alexander Couzens290d9032020-09-16 21:52:02 +0200697 pcu = gprs_bssgp_init(
698 bts,
699 info_ind->nsei, info_ind->bvci,
700 info_ind->mcc, info_ind->mnc, info_ind->mnc_3_digits,
701 info_ind->lac, info_ind->rac, info_ind->cell_id);
702 if (!pcu) {
Vadim Yanitskiyc1a726c2020-10-08 22:46:26 +0700703 LOGP(DL1IF, LOGL_ERROR, "Failed to init BSSGP\n");
Alexander Couzens9b5c9602020-07-28 13:47:18 +0200704 goto bssgp_failed;
705 }
706
Alexander Couzens5bece2a2020-10-12 02:27:22 +0200707 rc = pcu_info_ind_ns(pcu->bts, info_ind);
708 if (rc < 0) {
Alexander Couzens290d9032020-09-16 21:52:02 +0200709 LOGP(DL1IF, LOGL_ERROR, "No NSVC available to connect to the SGSN!\n");
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400710 goto bssgp_failed;
711 }
712
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400713 if (info_ind->t3142) { /* if timer values are set */
Pau Espin Pedrol28f160e2019-09-05 14:48:35 +0200714 osmo_tdef_set(bts->T_defs_bts, 3142, info_ind->t3142, OSMO_TDEF_S);
715 osmo_tdef_set(bts->T_defs_bts, 3169, info_ind->t3169, OSMO_TDEF_S);
716 osmo_tdef_set(bts->T_defs_bts, 3191, info_ind->t3191, OSMO_TDEF_S);
717 osmo_tdef_set(bts->T_defs_bts, 3193, info_ind->t3193_10ms * 10, OSMO_TDEF_MS);
718 osmo_tdef_set(bts->T_defs_bts, 3195, info_ind->t3195, OSMO_TDEF_S);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400719 bts->n3101 = info_ind->n3101;
720 bts->n3103 = info_ind->n3103;
721 bts->n3105 = info_ind->n3105;
722 }
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400723
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700724 for (trx_nr = 0; trx_nr < ARRAY_SIZE(bts->trx); trx_nr++) {
725 bts->trx[trx_nr].arfcn = info_ind->trx[trx_nr].arfcn;
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100726 if ((info_ind->flags & PCU_IF_FLAG_SYSMO)
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700727 && info_ind->trx[trx_nr].hlayer1) {
Maxcad867e2016-04-21 14:35:55 +0200728#ifdef ENABLE_DIRECT_PHY
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700729 LOGP(DL1IF, LOGL_DEBUG, " TRX %d hlayer1=%x\n", trx_nr,
730 info_ind->trx[trx_nr].hlayer1);
731 if (!bts->trx[trx_nr].fl1h)
732 bts->trx[trx_nr].fl1h = l1if_open_pdch(
733 trx_nr,
734 info_ind->trx[trx_nr].hlayer1,
Pau Espin Pedrolac3fd122021-01-13 18:54:38 +0100735 the_pcu->gsmtap);
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700736 if (!bts->trx[trx_nr].fl1h) {
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100737 LOGP(DL1IF, LOGL_FATAL, "Failed to open direct "
738 "DSP access for PDCH.\n");
739 exit(0);
740 }
741#else
742 LOGP(DL1IF, LOGL_FATAL, "Compiled without direct DSP "
743 "access for PDCH, but enabled at "
744 "BTS. Please deactivate it!\n");
745 exit(0);
746#endif
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100747 }
748
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700749 for (ts_nr = 0; ts_nr < ARRAY_SIZE(bts->trx[0].pdch); ts_nr++) {
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +0700750 const struct gsm_pcu_if_info_ts *its = &info_ind->trx[trx_nr].ts[ts_nr];
Vadim Yanitskiy0f41b712020-07-24 01:28:13 +0700751 struct gprs_rlcmac_pdch *pdch = &bts->trx[trx_nr].pdch[ts_nr];
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700752 if ((info_ind->trx[trx_nr].pdch_mask & (1 << ts_nr))) {
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400753 /* FIXME: activate dynamically at RLCMAC */
Holger Hans Peter Freyther17b0d832013-10-19 17:37:48 +0200754 if (!pdch->is_enabled()) {
Maxcad867e2016-04-21 14:35:55 +0200755#ifdef ENABLE_DIRECT_PHY
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100756 if ((info_ind->flags &
757 PCU_IF_FLAG_SYSMO))
758 l1if_connect_pdch(
Vadim Yanitskiy11b0f002020-07-24 01:24:47 +0700759 bts->trx[trx_nr].fl1h, ts_nr);
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100760#endif
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100761 pcu_tx_act_req(bts, trx_nr, ts_nr, 1);
Holger Hans Peter Freyther17b0d832013-10-19 17:37:48 +0200762 pdch->enable();
Andreas Eversberg3b7461c2012-07-20 11:19:59 +0200763 }
Vadim Yanitskiy8e2bd1e2020-07-21 00:54:42 +0700764
765 pdch->tsc = its->tsc;
766
767 /* (Optional) frequency hopping parameters */
768 if (its->h) {
769 pdch->fh.enabled = true;
770 pdch->fh.maio = its->maio;
771 pdch->fh.hsn = its->hsn;
772
773 OSMO_ASSERT(its->ma_bit_len <= sizeof(pdch->fh.ma) * 8);
774 pdch->fh.ma_oct_len = OSMO_BYTES_FOR_BITS(its->ma_bit_len);
775 pdch->fh.ma_bit_len = its->ma_bit_len;
776
777 /* Mobile Allocation + padding (byte/bit order as on the wire):
778 * | 00 00 00 00 00 cc bb aa | -> | cc bb aa 00 00 00 00 00 | */
779 unsigned int offset = sizeof(pdch->fh.ma) - pdch->fh.ma_oct_len;
780 memcpy(pdch->fh.ma, its->ma + offset, pdch->fh.ma_oct_len);
781 }
782
783 LOGP(DL1IF, LOGL_INFO, "PDCH (trx=%u, ts=%u): tsc=%u, hopping=%s\n",
784 trx_nr, ts_nr, pdch->tsc, pdch->fh.enabled ? "yes" : "no");
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400785 } else {
Holger Hans Peter Freyther17b0d832013-10-19 17:37:48 +0200786 if (pdch->is_enabled()) {
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100787 pcu_tx_act_req(bts, trx_nr, ts_nr, 0);
Holger Hans Peter Freyther09ef27a2013-10-20 16:37:05 +0200788 pdch->free_resources();
Holger Hans Peter Freyther17b0d832013-10-19 17:37:48 +0200789 pdch->disable();
Andreas Eversberg3b7461c2012-07-20 11:19:59 +0200790 }
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400791 }
792 }
793 }
794
Stefan Sperling5b22fb72018-02-14 19:46:33 +0100795 bts->active = true;
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200796 return rc;
797}
798
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100799static int pcu_rx_time_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_time_ind *time_ind)
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200800{
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400801 uint8_t fn13 = time_ind->fn % 13;
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200802
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400803 /* omit frame numbers not starting at a MAC block */
804 if (fn13 != 0 && fn13 != 4 && fn13 != 8)
805 return 0;
Max3741f142017-06-26 12:10:12 +0200806
807 LOGP(DL1IF, LOGL_DEBUG, "Time indication received: %d\n", time_ind->fn % 52);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400808
Pau Espin Pedrol30617112021-03-05 18:59:05 +0100809 /* Ignore TIME.ind completely, we nowadays relay on DATA.ind always
810 * providing all block FNs. */
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200811 return 0;
812}
813
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100814static int pcu_rx_pag_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_pag_req *pag_req)
Andreas Eversberg2b914642012-07-19 13:06:26 +0200815{
Neels Hofmeyr59fc0bd2020-08-21 16:21:23 +0200816 struct osmo_mobile_identity mi;
817 int rc;
818
Andreas Eversberg2b914642012-07-19 13:06:26 +0200819 LOGP(DL1IF, LOGL_DEBUG, "Paging request received: chan_needed=%d "
820 "length=%d\n", pag_req->chan_needed, pag_req->identity_lv[0]);
821
Pau Espin Pedrol32499b62019-12-09 13:55:12 +0100822 /* check if identity does not fit: length > sizeof(lv) - 1 */
823 if (pag_req->identity_lv[0] >= sizeof(pag_req->identity_lv)) {
824 LOGP(DL1IF, LOGL_ERROR, "Paging identity too large (%" PRIu8 ")\n",
825 pag_req->identity_lv[0]);
826 return -EINVAL;
827 }
828
Neels Hofmeyr59fc0bd2020-08-21 16:21:23 +0200829 rc = osmo_mobile_identity_decode(&mi, &pag_req->identity_lv[1], pag_req->identity_lv[0], true);
830 if (rc < 0) {
831 LOGP(DL1IF, LOGL_ERROR, "Failed to decode Mobile Identity in Paging Request (rc=%d)\n", rc);
832 return -EINVAL;
833 }
834
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100835 return bts_add_paging(bts, pag_req->chan_needed, &mi);
Andreas Eversberg2b914642012-07-19 13:06:26 +0200836}
837
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100838static int pcu_rx_susp_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_susp_req *susp_req)
Harald Welte3447c4a2017-07-11 00:06:38 +0200839{
Philipp Maiera58ec612021-01-25 23:43:52 +0100840 struct bssgp_bvc_ctx *bctx = the_pcu->bssgp.bctx;
Pau Espin Pedrolbd9973a2020-09-22 15:57:37 +0200841 GprsMs *ms;
842 struct gprs_rlcmac_dl_tbf *dl_tbf;
843 struct gprs_rlcmac_ul_tbf *ul_tbf;
Harald Welte3447c4a2017-07-11 00:06:38 +0200844 struct gprs_ra_id ra_id;
845
846 gsm48_parse_ra(&ra_id, susp_req->ra_id);
847
848 LOGP(DL1IF, LOGL_INFO, "GPRS Suspend request received: TLLI=0x%08x RAI=%s\n",
849 susp_req->tlli, osmo_rai_name(&ra_id));
850
Pau Espin Pedrol2182e622021-01-14 16:48:38 +0100851 if ((ms = bts_ms_store(bts)->get_ms(susp_req->tlli))) {
Pau Espin Pedrolbd9973a2020-09-22 15:57:37 +0200852 /* We need to catch both pointers here since MS may become freed
853 after first tbf_free(dl_tbf) if only DL TBF was available */
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100854 dl_tbf = ms_dl_tbf(ms);
855 ul_tbf = ms_ul_tbf(ms);
Pau Espin Pedrolbd9973a2020-09-22 15:57:37 +0200856 if (dl_tbf)
857 tbf_free(dl_tbf);
858 if (ul_tbf)
859 tbf_free(ul_tbf);
860 }
861
Harald Welte3447c4a2017-07-11 00:06:38 +0200862 if (!bctx)
863 return -1;
864
865 return bssgp_tx_suspend(bctx->nsei, susp_req->tlli, &ra_id);
866}
867
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100868static int pcu_rx_app_info_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_app_info_req *app_info_req)
Oliver Smithcfb63212019-09-05 17:13:33 +0200869{
Pau Espin Pedrol54faf022021-01-14 12:12:43 +0100870 struct llist_head *tmp;
Oliver Smithcfb63212019-09-05 17:13:33 +0200871
872 LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n",
873 app_info_req->application_type, app_info_req->len);
874
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100875 bts->app_info_pending = 0;
Pau Espin Pedrol2182e622021-01-14 16:48:38 +0100876 llist_for_each(tmp, bts_ms_store(bts)->ms_list()) {
Pau Espin Pedrol54faf022021-01-14 12:12:43 +0100877 GprsMs *ms = llist_entry(tmp, typeof(*ms), list);
Pau Espin Pedrolda971ee2020-12-16 15:59:45 +0100878 if (!ms_dl_tbf(ms))
Oliver Smithcfb63212019-09-05 17:13:33 +0200879 continue;
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100880 bts->app_info_pending++;
Oliver Smithcfb63212019-09-05 17:13:33 +0200881 ms->app_info_pending = true;
882 }
883
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100884 if (!bts->app_info_pending) {
Oliver Smithcfb63212019-09-05 17:13:33 +0200885 LOGP(DL1IF, LOGL_NOTICE, "Packet Application Information will not be sent, no subscribers with active"
886 " TBF\n");
887 return -1;
888 }
889
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100890 if (bts->app_info) {
Oliver Smithcfb63212019-09-05 17:13:33 +0200891 LOGP(DL1IF, LOGL_NOTICE, "Previous Packet Application Information was not sent to all subscribers,"
892 " overwriting with new one\n");
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100893 msgb_free(bts->app_info);
Oliver Smithcfb63212019-09-05 17:13:33 +0200894 }
895
896 LOGP(DL1IF, LOGL_INFO, "Sending Packet Application Information to %i subscribers with active TBF\n",
Pau Espin Pedrol0ece97d2021-01-18 12:53:54 +0100897 bts->app_info_pending);
898 bts->app_info = gprs_rlcmac_app_info_msg(app_info_req);
Oliver Smithcfb63212019-09-05 17:13:33 +0200899 return 0;
900}
901
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400902int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim)
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200903{
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400904 int rc = 0;
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100905 struct gprs_rlcmac_bts *bts = gprs_pcu_get_bts_by_nr(the_pcu, pcu_prim->bts_nr);
906 if (!bts) {
907 LOGP(DL1IF, LOGL_NOTICE, "Received message for new BTS%d\n", pcu_prim->bts_nr);
908 bts = bts_alloc(the_pcu, pcu_prim->bts_nr);
909 if (!bts) {
910 LOGP(DL1IF, LOGL_ERROR, "Failed to create object for BTS%d!\n", pcu_prim->bts_nr);
911 return -EAGAIN;
912 }
913 }
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200914
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400915 switch (msg_type) {
916 case PCU_IF_MSG_DATA_IND:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100917 rc = pcu_rx_data_ind(bts, &pcu_prim->u.data_ind);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400918 break;
Andreas Eversberga9be1542012-09-27 09:23:24 +0200919 case PCU_IF_MSG_DATA_CNF:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100920 rc = pcu_rx_data_cnf(bts, &pcu_prim->u.data_cnf);
Andreas Eversberga9be1542012-09-27 09:23:24 +0200921 break;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400922 case PCU_IF_MSG_RTS_REQ:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100923 rc = pcu_rx_rts_req(bts, &pcu_prim->u.rts_req);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400924 break;
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400925 case PCU_IF_MSG_RACH_IND:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100926 rc = pcu_rx_rach_ind(bts, &pcu_prim->u.rach_ind);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400927 break;
928 case PCU_IF_MSG_INFO_IND:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100929 rc = pcu_rx_info_ind(bts, &pcu_prim->u.info_ind);
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400930 break;
931 case PCU_IF_MSG_TIME_IND:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100932 rc = pcu_rx_time_ind(bts, &pcu_prim->u.time_ind);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400933 break;
Andreas Eversberg2b914642012-07-19 13:06:26 +0200934 case PCU_IF_MSG_PAG_REQ:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100935 rc = pcu_rx_pag_req(bts, &pcu_prim->u.pag_req);
Andreas Eversberg2b914642012-07-19 13:06:26 +0200936 break;
Harald Welte3447c4a2017-07-11 00:06:38 +0200937 case PCU_IF_MSG_SUSP_REQ:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100938 rc = pcu_rx_susp_req(bts, &pcu_prim->u.susp_req);
Harald Welte3447c4a2017-07-11 00:06:38 +0200939 break;
Oliver Smithcfb63212019-09-05 17:13:33 +0200940 case PCU_IF_MSG_APP_INFO_REQ:
Pau Espin Pedrold1049dc2021-01-18 17:14:14 +0100941 rc = pcu_rx_app_info_req(bts, &pcu_prim->u.app_info_req);
Oliver Smithcfb63212019-09-05 17:13:33 +0200942 break;
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400943 default:
Thorsten Alteholz8bb79042018-10-06 10:42:58 +0200944 LOGP(DL1IF, LOGL_ERROR, "Received unknown PCU msg type %d\n",
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400945 msg_type);
946 rc = -EINVAL;
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200947 }
Philipp Maier8ccf7042018-04-10 13:12:42 +0200948
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400949 return rc;
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200950}