Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1 | /* pcu_l1_if.cpp |
| 2 | * |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 3 | * Copyright (C) 2012 Andreas Eversberg <jolly@eversberg.eu> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 4 | * |
| 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <unistd.h> |
Pau Espin Pedrol | 32499b6 | 2019-12-09 13:55:12 +0100 | [diff] [blame] | 22 | #include <inttypes.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 23 | #include <stdlib.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 24 | #include <string.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 25 | #include <errno.h> |
| 26 | #include <assert.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 27 | #include <sys/socket.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 28 | #include <sys/un.h> |
Andreas Eversberg | 81a12be | 2013-03-16 16:16:41 +0100 | [diff] [blame] | 29 | #include <arpa/inet.h> |
Pau Espin Pedrol | 754b093 | 2020-03-26 14:47:13 +0100 | [diff] [blame] | 30 | #include <ctype.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 31 | |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 32 | extern "C" { |
| 33 | #include <osmocom/core/talloc.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 34 | #include <osmocom/core/select.h> |
| 35 | #include <osmocom/core/msgb.h> |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 36 | #include <osmocom/core/gsmtap_util.h> |
| 37 | #include <osmocom/core/gsmtap.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 38 | #include <osmocom/core/bitvec.h> |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 39 | #include <osmocom/core/sockaddr_str.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 40 | #include <osmocom/core/logging.h> |
| 41 | #include <osmocom/core/utils.h> |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 42 | #include <osmocom/gprs/gprs_ns2.h> |
Max | 1187a77 | 2018-01-26 13:31:42 +0100 | [diff] [blame] | 43 | #include <osmocom/gsm/l1sap.h> |
| 44 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Pau Espin Pedrol | fe8de45 | 2021-02-09 18:47:34 +0100 | [diff] [blame] | 45 | #include <osmocom/gsm/gsm48_rest_octets.h> |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 46 | #include <osmocom/gsm/sysinfo.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 47 | } |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 48 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 49 | #include <gprs_rlcmac.h> |
| 50 | #include <pcu_l1_if.h> |
| 51 | #include <gprs_debug.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 52 | #include <gprs_bssgp_pcu.h> |
Harald Welte | 68fc127 | 2016-11-16 22:48:33 +0100 | [diff] [blame] | 53 | #include <osmocom/pcu/pcuif_proto.h> |
Holger Hans Peter Freyther | 67ed34e | 2013-10-17 17:01:54 +0200 | [diff] [blame] | 54 | #include <bts.h> |
Max | 6dc90b8 | 2018-02-19 17:17:28 +0100 | [diff] [blame] | 55 | #include <pdch.h> |
Pau Espin Pedrol | bd9973a | 2020-09-22 15:57:37 +0200 | [diff] [blame] | 56 | #include <tbf_ul.h> |
| 57 | #include <tbf_dl.h> |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 58 | #include <gprs_ms_storage.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 59 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 60 | // FIXME: move this, when changed from c++ to c. |
| 61 | extern "C" { |
Max | 58b6646 | 2016-05-13 10:34:15 +0200 | [diff] [blame] | 62 | void *l1if_open_pdch(uint8_t trx_no, uint32_t hlayer1, |
| 63 | struct gsmtap_inst *gsmtap); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 64 | int l1if_connect_pdch(void *obj, uint8_t ts); |
| 65 | int 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 Eversberg | e266bd4 | 2012-07-13 14:00:21 +0200 | [diff] [blame] | 69 | extern void *tall_pcu_ctx; |
| 70 | |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 71 | #define PAGING_GROUP_LEN 3 |
| 72 | |
| 73 | /* returns [0,999] on success, > 999 on error */ |
| 74 | uint16_t imsi2paging_group(const char* imsi) |
| 75 | { |
| 76 | uint16_t pgroup = 0; |
Vadim Yanitskiy | bd0b0b3 | 2020-01-16 00:25:48 +0700 | [diff] [blame] | 77 | size_t len; |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 78 | |
Vadim Yanitskiy | bd0b0b3 | 2020-01-16 00:25:48 +0700 | [diff] [blame] | 79 | len = (imsi != NULL) ? strlen(imsi) : 0; |
| 80 | if (len < PAGING_GROUP_LEN) |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 81 | 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 Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 94 | /* |
| 95 | * PCU messages |
| 96 | */ |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 97 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 98 | struct 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 Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 110 | |
| 111 | return msg; |
| 112 | } |
| 113 | |
Max | 0a8fae8 | 2017-03-08 18:53:30 +0100 | [diff] [blame] | 114 | const 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 | |
| 120 | int 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 Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 150 | static int pcu_tx_act_req(struct gprs_rlcmac_bts *bts, const struct gprs_rlcmac_pdch *pdch, |
| 151 | uint8_t activate) |
Ivan Kluchnikov | 4277f0c | 2012-04-12 14:24:35 +0400 | [diff] [blame] | 152 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 153 | struct msgb *msg; |
| 154 | struct gsm_pcu_if *pcu_prim; |
| 155 | struct gsm_pcu_if_act_req *act_req; |
| 156 | |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 157 | LOGPDCH(pdch, DL1IF, LOGL_INFO, "Sending %s request\n", |
| 158 | (activate) ? "activate" : "deactivate"); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 159 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 160 | msg = pcu_msgb_alloc(PCU_IF_MSG_ACT_REQ, bts->nr); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 161 | if (!msg) |
| 162 | return -ENOMEM; |
| 163 | pcu_prim = (struct gsm_pcu_if *) msg->data; |
| 164 | act_req = &pcu_prim->u.act_req; |
| 165 | act_req->activate = activate; |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 166 | act_req->trx_nr = pdch->trx_no(); |
| 167 | act_req->ts_nr = pdch->ts_no; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 168 | |
| 169 | return pcu_sock_send(msg); |
| 170 | } |
| 171 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 172 | static int pcu_tx_data_req(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint8_t sapi, |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 173 | uint16_t arfcn, uint32_t fn, uint8_t block_nr, uint8_t *data, |
| 174 | uint8_t len) |
| 175 | { |
| 176 | struct msgb *msg; |
| 177 | struct gsm_pcu_if *pcu_prim; |
| 178 | struct gsm_pcu_if_data *data_req; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 179 | int current_fn = bts_current_frame_number(bts); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 180 | |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 181 | LOGP(DL1IF, LOGL_DEBUG, "(bts=%u,trx=%u,ts=%u) FN=%u Sending data request: sapi=%d " |
| 182 | "arfcn=%d cur_fn=%d block=%d data=%s\n", bts->nr, trx, ts, fn, sapi, |
| 183 | arfcn, current_fn, block_nr, osmo_hexdump(data, len)); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 184 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 185 | msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_REQ, bts->nr); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 186 | if (!msg) |
| 187 | return -ENOMEM; |
| 188 | pcu_prim = (struct gsm_pcu_if *) msg->data; |
| 189 | data_req = &pcu_prim->u.data_req; |
| 190 | |
| 191 | data_req->sapi = sapi; |
| 192 | data_req->fn = fn; |
| 193 | data_req->arfcn = arfcn; |
| 194 | data_req->trx_nr = trx; |
| 195 | data_req->ts_nr = ts; |
| 196 | data_req->block_nr = block_nr; |
| 197 | memcpy(data_req->data, data, len); |
| 198 | data_req->len = len; |
| 199 | |
| 200 | return pcu_sock_send(msg); |
| 201 | } |
| 202 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 203 | void pcu_l1if_tx_pdtch(msgb *msg, struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint16_t arfcn, |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 204 | uint32_t fn, uint8_t block_nr) |
| 205 | { |
Max | b216c6b | 2017-09-01 11:00:39 +0200 | [diff] [blame] | 206 | #ifdef ENABLE_DIRECT_PHY |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 207 | if (bts->trx[trx].fl1h) { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 208 | l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr, |
| 209 | msg->data, msg->len); |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 210 | msgb_free(msg); |
| 211 | return; |
| 212 | } |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 213 | #endif |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 214 | pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PDTCH, arfcn, fn, block_nr, |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 215 | msg->data, msg->len); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 216 | msgb_free(msg); |
Ivan Kluchnikov | 4277f0c | 2012-04-12 14:24:35 +0400 | [diff] [blame] | 217 | } |
| 218 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 219 | void pcu_l1if_tx_ptcch(struct gprs_rlcmac_bts *bts, |
| 220 | uint8_t trx, uint8_t ts, uint16_t arfcn, |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 221 | uint32_t fn, uint8_t block_nr, |
| 222 | uint8_t *data, size_t data_len) |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 223 | { |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 224 | if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PTCCH)) |
| 225 | gsmtap_send(the_pcu->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, data, data_len); |
Max | cad867e | 2016-04-21 14:35:55 +0200 | [diff] [blame] | 226 | #ifdef ENABLE_DIRECT_PHY |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 227 | if (bts->trx[trx].fl1h) { |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 228 | l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr, data, data_len); |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 229 | return; |
| 230 | } |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 231 | #endif |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 232 | pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, data, data_len); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 233 | } |
| 234 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 235 | void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen) |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 236 | { |
Pau Espin Pedrol | d752d7c | 2019-10-07 20:56:48 +0200 | [diff] [blame] | 237 | uint8_t data[GSM_MACBLOCK_LEN]; /* prefix PLEN */ |
| 238 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 239 | /* FIXME: why does OpenBTS has no PLEN and no fill in message? */ |
| 240 | bitvec_pack(block, data + 1); |
| 241 | data[0] = (plen << 2) | 0x01; |
Pau Espin Pedrol | 5854370 | 2019-09-30 19:07:16 +0200 | [diff] [blame] | 242 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 243 | if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_AGCH)) |
| 244 | gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_AGCH, 0, 0, 0, 0, data, GSM_MACBLOCK_LEN); |
Pau Espin Pedrol | 5854370 | 2019-09-30 19:07:16 +0200 | [diff] [blame] | 245 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 246 | pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, GSM_MACBLOCK_LEN); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 247 | } |
| 248 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 249 | void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec * block, int plen, uint16_t pgroup) |
Ivan Kluchnikov | c7e7f68 | 2012-06-29 22:53:15 +0400 | [diff] [blame] | 250 | { |
Pau Espin Pedrol | 8dc09e7 | 2019-10-07 20:56:02 +0200 | [diff] [blame] | 251 | uint8_t data[PAGING_GROUP_LEN + GSM_MACBLOCK_LEN]; |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 252 | int i; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 253 | |
Pau Espin Pedrol | 8dc09e7 | 2019-10-07 20:56:02 +0200 | [diff] [blame] | 254 | /* prepend paging group */ |
Pau Espin Pedrol | d7c3265 | 2019-12-23 12:41:34 +0100 | [diff] [blame] | 255 | for (i = 0; i < PAGING_GROUP_LEN; i++) { |
| 256 | data[PAGING_GROUP_LEN - 1 - i] = '0' + (char)(pgroup % 10); |
| 257 | pgroup = pgroup / 10; |
| 258 | } |
| 259 | OSMO_ASSERT(pgroup == 0); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 260 | |
Pau Espin Pedrol | 8dc09e7 | 2019-10-07 20:56:02 +0200 | [diff] [blame] | 261 | /* block provided by upper layer comes without first byte (plen), |
| 262 | * prepend it manually: |
| 263 | */ |
| 264 | OSMO_ASSERT(sizeof(data) >= PAGING_GROUP_LEN + 1 + block->data_len); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 265 | data[3] = (plen << 2) | 0x01; |
Pau Espin Pedrol | 8dc09e7 | 2019-10-07 20:56:02 +0200 | [diff] [blame] | 266 | bitvec_pack(block, data + PAGING_GROUP_LEN + 1); |
Pau Espin Pedrol | 5854370 | 2019-09-30 19:07:16 +0200 | [diff] [blame] | 267 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 268 | if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PCH)) |
| 269 | gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_PCH, 0, 0, 0, 0, data + 3, GSM_MACBLOCK_LEN); |
Pau Espin Pedrol | 5854370 | 2019-09-30 19:07:16 +0200 | [diff] [blame] | 270 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 271 | pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, PAGING_GROUP_LEN + GSM_MACBLOCK_LEN); |
Ivan Kluchnikov | c7e7f68 | 2012-06-29 22:53:15 +0400 | [diff] [blame] | 272 | } |
| 273 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 274 | void pcu_rx_block_time(struct gprs_rlcmac_bts *bts, uint16_t arfcn, uint32_t fn, uint8_t ts_no) |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 275 | { |
Pau Espin Pedrol | fecab50 | 2021-03-17 15:26:37 +0100 | [diff] [blame] | 276 | bts_set_current_block_frame_number(bts, fn); |
Jacob Erlbeck | af75ce8 | 2015-08-26 13:22:28 +0200 | [diff] [blame] | 277 | } |
| 278 | |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 279 | int pcu_rx_data_ind_pdtch(struct gprs_rlcmac_bts *bts, struct gprs_rlcmac_pdch *pdch, uint8_t *data, |
Jacob Erlbeck | 20f6fd1 | 2015-06-08 11:05:45 +0200 | [diff] [blame] | 280 | uint8_t len, uint32_t fn, struct pcu_l1_meas *meas) |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 281 | { |
Pau Espin Pedrol | 15c58ac | 2021-03-08 14:57:58 +0100 | [diff] [blame] | 282 | int rc; |
| 283 | |
| 284 | rc = pdch->rcv_block(data, len, fn, meas); |
| 285 | pdch_ulc_expire_fn(pdch->ulc, fn); |
| 286 | return rc; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 287 | } |
| 288 | |
Pau Espin Pedrol | 86f4c09 | 2021-06-08 18:53:40 +0200 | [diff] [blame] | 289 | static int list_arfcn(const struct gprs_rlcmac_bts *bts, const struct gsm_sysinfo_freq *freq, const char *text) |
| 290 | { |
| 291 | int n = 0, i; |
| 292 | for (i = 0; i < 1024; i++) { |
| 293 | if (freq[i].mask) { |
| 294 | if (!n) |
| 295 | LOGP(DL1IF, LOGL_INFO, "BTS%d: %s", bts->nr, text); |
| 296 | LOGPC(DL1IF, LOGL_INFO, " %d", i); |
| 297 | n++; |
| 298 | } |
| 299 | } |
| 300 | if (n) |
| 301 | LOGPC(DL1IF, LOGL_INFO, "\n"); |
| 302 | |
| 303 | return n; |
| 304 | } |
| 305 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 306 | static int pcu_rx_data_ind_bcch(struct gprs_rlcmac_bts *bts, uint8_t *data, uint8_t len) |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 307 | { |
Pau Espin Pedrol | 86f4c09 | 2021-06-08 18:53:40 +0200 | [diff] [blame] | 308 | struct gsm48_system_information_type_2 *si2; |
Pau Espin Pedrol | fe8de45 | 2021-02-09 18:47:34 +0100 | [diff] [blame] | 309 | const uint8_t *si_ro; |
Pau Espin Pedrol | 86f4c09 | 2021-06-08 18:53:40 +0200 | [diff] [blame] | 310 | |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 311 | switch (len) { |
| 312 | case 0: |
| 313 | /* Due to historical reasons also accept a completely empty message as |
| 314 | * revoke command for SI13. */ |
| 315 | LOGP(DL1IF, LOGL_ERROR, |
| 316 | "Received PCU data indication that contains no data -- Revoked SI13.\n"); |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 317 | bts->si13_is_set = false; |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 318 | |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 319 | return 0; |
| 320 | case 1: |
| 321 | /* Revoke SI, type is identified by a single byte which is coded after |
| 322 | * enum osmo_sysinfo_type. */ |
| 323 | switch (data[0]) { |
| 324 | case SYSINFO_TYPE_1: |
| 325 | bts->si1_is_set = false; |
| 326 | break; |
Pau Espin Pedrol | 86f4c09 | 2021-06-08 18:53:40 +0200 | [diff] [blame] | 327 | case SYSINFO_TYPE_2: |
| 328 | bts->si2_is_set = false; |
| 329 | break; |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 330 | case SYSINFO_TYPE_3: |
| 331 | bts->si3_is_set = false; |
| 332 | break; |
| 333 | case SYSINFO_TYPE_13: |
| 334 | bts->si13_is_set = false; |
| 335 | break; |
| 336 | default: |
| 337 | LOGP(DL1IF, LOGL_ERROR, |
| 338 | "Received PCU data indication that contains an unsupported system information identifier (%02x,OSMO) -- ignored.\n", data[0]); |
| 339 | return -EINVAL; |
| 340 | } |
| 341 | LOGP(DPCU, LOGL_DEBUG, |
| 342 | "Received PCU data indication: Revoked SI%s\n", |
| 343 | get_value_string(osmo_sitype_strs, data[0])); |
| 344 | return 0; |
| 345 | case GSM_MACBLOCK_LEN: |
| 346 | /* Update SI, type is identified by the RR sysinfo type, which is the |
| 347 | * 3rd byte in the buffer. */ |
| 348 | switch (data[2]) { |
| 349 | case GSM48_MT_RR_SYSINFO_1: |
| 350 | memcpy(bts->si1, data, GSM_MACBLOCK_LEN); |
| 351 | bts->si1_is_set = true; |
| 352 | break; |
Pau Espin Pedrol | 86f4c09 | 2021-06-08 18:53:40 +0200 | [diff] [blame] | 353 | case GSM48_MT_RR_SYSINFO_2: |
| 354 | memcpy(bts->si2, data, GSM_MACBLOCK_LEN); |
| 355 | bts->si2_is_set = true; |
| 356 | si2 = (struct gsm48_system_information_type_2 *)bts->si2; |
| 357 | gsm48_decode_freq_list(bts->si2_bcch_cell_list, si2->bcch_frequency_list, |
| 358 | sizeof(si2->bcch_frequency_list), 0xce, 1); |
| 359 | list_arfcn(bts, bts->si2_bcch_cell_list, "SI2 Neighbour cells in same band:"); |
| 360 | break; |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 361 | case GSM48_MT_RR_SYSINFO_3: |
| 362 | memcpy(bts->si3, data, GSM_MACBLOCK_LEN); |
| 363 | bts->si3_is_set = true; |
| 364 | break; |
| 365 | case GSM48_MT_RR_SYSINFO_13: |
| 366 | memcpy(bts->si13, data, GSM_MACBLOCK_LEN); |
| 367 | bts->si13_is_set = true; |
Pau Espin Pedrol | fe8de45 | 2021-02-09 18:47:34 +0100 | [diff] [blame] | 368 | si_ro = ((struct gsm48_system_information_type_13*)data)->rest_octets; |
Pau Espin Pedrol | d65bd9d | 2021-06-01 16:43:41 +0200 | [diff] [blame] | 369 | if (osmo_gsm48_rest_octets_si13_decode(&bts->si13_ro_decoded, si_ro) < 0) |
Pau Espin Pedrol | fe8de45 | 2021-02-09 18:47:34 +0100 | [diff] [blame] | 370 | LOGP(DPCU, LOGL_ERROR, "Error decoding SI13\n"); |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 371 | break; |
| 372 | default: |
| 373 | LOGP(DL1IF, LOGL_ERROR, |
| 374 | "Received PCU data indication that contains an unsupported system information identifier (%02x,RR) -- ignored.\n", data[2]); |
| 375 | return -EINVAL; |
| 376 | } |
| 377 | LOGP(DPCU, LOGL_DEBUG, |
| 378 | "Received PCU data indication: Updated %s: %s\n", |
| 379 | gsm48_pdisc_msgtype_name(data[1], data[2]), |
| 380 | osmo_hexdump_nospc(data + 1, GSM_MACBLOCK_LEN)); |
| 381 | return 0; |
| 382 | default: |
| 383 | LOGP(DL1IF, LOGL_ERROR, |
| 384 | "Received PCU data indication with unexpected data length: %u -- ignored.\n", |
| 385 | len); |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 386 | return -EINVAL; |
| 387 | } |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 388 | } |
| 389 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 390 | static int pcu_rx_data_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_ind) |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 391 | { |
Max | 528ff39 | 2016-02-22 11:42:33 +0100 | [diff] [blame] | 392 | int rc; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 393 | int current_fn = bts_current_frame_number(bts); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 394 | struct pcu_l1_meas meas = {0}; |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 395 | struct gprs_rlcmac_pdch *pdch; |
Pau Espin Pedrol | 72e3956 | 2020-06-30 17:57:42 +0200 | [diff] [blame] | 396 | uint8_t gsmtap_chantype; |
Max | b216c6b | 2017-09-01 11:00:39 +0200 | [diff] [blame] | 397 | |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 398 | LOGP(DL1IF, LOGL_DEBUG, "(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ") FN=%u " |
| 399 | "Rx DATA.ind: sapi=%d arfcn=%d cur_fn=%d " |
| 400 | "block=%d data=%s\n", bts->nr, data_ind->trx_nr, data_ind->ts_nr, |
| 401 | data_ind->fn, data_ind->sapi, data_ind->arfcn, current_fn, |
| 402 | data_ind->block_nr, osmo_hexdump(data_ind->data, data_ind->len)); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 403 | |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 404 | switch (data_ind->sapi) { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 405 | case PCU_IF_SAPI_PDTCH: |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 406 | pdch = &bts->trx[data_ind->trx_nr].pdch[data_ind->ts_nr]; |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 407 | pcu_l1_meas_set_rssi(&meas, data_ind->rssi); |
Max | b216c6b | 2017-09-01 11:00:39 +0200 | [diff] [blame] | 408 | /* convert BER to % value */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 409 | pcu_l1_meas_set_ber(&meas, data_ind->ber10k / 100); |
| 410 | pcu_l1_meas_set_bto(&meas, data_ind->ta_offs_qbits); |
| 411 | pcu_l1_meas_set_link_qual(&meas, data_ind->lqual_cb / 10); |
Vadim Yanitskiy | f17dfc0 | 2019-07-09 16:16:35 +0700 | [diff] [blame] | 412 | |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 413 | LOGPDCH(pdch, DL1IF, LOGL_DEBUG, "FN=%u Rx DATA.ind PDTCH: " |
| 414 | "BER10k = %d, BTO = %d, Q = %d\n", data_ind->fn, |
| 415 | data_ind->ber10k, data_ind->ta_offs_qbits, data_ind->lqual_cb); |
Vadim Yanitskiy | f17dfc0 | 2019-07-09 16:16:35 +0700 | [diff] [blame] | 416 | |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 417 | rc = pcu_rx_data_ind_pdtch(bts, pdch, data_ind->data, data_ind->len, |
| 418 | data_ind->fn, &meas); |
Pau Espin Pedrol | 72e3956 | 2020-06-30 17:57:42 +0200 | [diff] [blame] | 419 | gsmtap_chantype = GSMTAP_CHANNEL_PDTCH; |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 420 | break; |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 421 | case PCU_IF_SAPI_BCCH: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 422 | rc = pcu_rx_data_ind_bcch(bts, data_ind->data, data_ind->len); |
Pau Espin Pedrol | 72e3956 | 2020-06-30 17:57:42 +0200 | [diff] [blame] | 423 | gsmtap_chantype = GSMTAP_CHANNEL_BCCH; |
Max | 84bf0fa | 2017-09-01 11:02:40 +0200 | [diff] [blame] | 424 | break; |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 425 | default: |
Pau Espin Pedrol | c1f31c4 | 2021-03-09 14:50:14 +0100 | [diff] [blame] | 426 | LOGP(DL1IF, LOGL_ERROR, "(bts=%" PRIu8 ",trx=%" PRIu8 ",ts=%" PRIu8 ") " |
| 427 | "FN=%u Rx DATA.ind with unsupported sapi %d\n", |
| 428 | bts->nr, data_ind->trx_nr, data_ind->ts_nr, data_ind->fn, data_ind->sapi); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 429 | rc = -EINVAL; |
Pau Espin Pedrol | 72e3956 | 2020-06-30 17:57:42 +0200 | [diff] [blame] | 430 | gsmtap_chantype = GSMTAP_CHANNEL_UNKNOWN; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 431 | } |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 432 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 433 | if (rc < 0 && (the_pcu->gsmtap_categ_mask & (1 <<PCU_GSMTAP_C_UL_UNKNOWN))) { |
| 434 | gsmtap_send(the_pcu->gsmtap, data_ind->arfcn | GSMTAP_ARFCN_F_UPLINK, data_ind->ts_nr, |
Pau Espin Pedrol | 72e3956 | 2020-06-30 17:57:42 +0200 | [diff] [blame] | 435 | gsmtap_chantype, 0, data_ind->fn, meas.rssi, meas.link_qual, data_ind->data, data_ind->len); |
Harald Welte | 717cdf5 | 2017-07-21 21:56:23 +0200 | [diff] [blame] | 436 | } |
| 437 | |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 438 | return rc; |
| 439 | } |
| 440 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 441 | static int pcu_rx_data_cnf(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_cnf) |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 442 | { |
| 443 | int rc = 0; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 444 | int current_fn = bts_current_frame_number(bts); |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 445 | |
Philipp Maier | 7e8e397 | 2018-04-10 13:31:45 +0200 | [diff] [blame] | 446 | LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d fn=%d cur_fn=%d\n", |
| 447 | data_cnf->sapi, data_cnf->fn, current_fn); |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 448 | |
| 449 | switch (data_cnf->sapi) { |
| 450 | case PCU_IF_SAPI_PCH: |
Andreas Eversberg | 8c3680d | 2012-10-08 12:30:56 +0200 | [diff] [blame] | 451 | if (data_cnf->data[2] == 0x3f) |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 452 | bts_rcv_imm_ass_cnf(bts, data_cnf->data, data_cnf->fn); |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 453 | break; |
| 454 | default: |
| 455 | LOGP(DL1IF, LOGL_ERROR, "Received PCU data confirm with " |
| 456 | "unsupported sapi %d\n", data_cnf->sapi); |
| 457 | rc = -EINVAL; |
| 458 | } |
| 459 | |
| 460 | return rc; |
| 461 | } |
| 462 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 463 | // FIXME: remove this, when changed from c++ to c. |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 464 | int pcu_rx_rts_req_pdtch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 465 | uint32_t fn, uint8_t block_nr) |
| 466 | { |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 467 | return gprs_rlcmac_rcv_rts_block(bts, |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 468 | trx, ts, fn, block_nr); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 469 | } |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 470 | int pcu_rx_rts_req_ptcch(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 471 | uint32_t fn, uint8_t block_nr) |
| 472 | { |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 473 | struct gprs_rlcmac_pdch *pdch; |
| 474 | |
| 475 | /* Prevent buffer overflow */ |
| 476 | if (trx >= ARRAY_SIZE(bts->trx) || ts >= 8) |
| 477 | return -EINVAL; |
| 478 | |
| 479 | /* Make sure PDCH time-slot is enabled */ |
| 480 | pdch = &bts->trx[trx].pdch[ts]; |
| 481 | if (!pdch->m_is_enabled) |
| 482 | return -EAGAIN; |
| 483 | |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 484 | pcu_l1if_tx_ptcch(bts, trx, ts, bts->trx[trx].arfcn, fn, block_nr, |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 485 | pdch->ptcch_msg, GSM_MACBLOCK_LEN); |
| 486 | return 0; |
| 487 | } |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 488 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 489 | static int pcu_rx_rts_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_rts_req *rts_req) |
Ivan Kluchnikov | 5310d45 | 2012-04-17 22:00:31 +0400 | [diff] [blame] | 490 | { |
| 491 | int rc = 0; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 492 | int current_fn = bts_current_frame_number(bts); |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 493 | const struct gprs_rlcmac_pdch *pdch; |
| 494 | pdch = &bts->trx[rts_req->trx_nr].pdch[rts_req->ts_nr]; |
Ivan Kluchnikov | 5310d45 | 2012-04-17 22:00:31 +0400 | [diff] [blame] | 495 | |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 496 | LOGPDCH(pdch, DL1IF, LOGL_DEBUG, "FN=%u RX RTS.req: sapi=%d " |
| 497 | "arfcn=%d cur_fn=%d block=%d\n", rts_req->fn, |
| 498 | rts_req->sapi, rts_req->arfcn, current_fn, rts_req->block_nr); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 499 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 500 | switch (rts_req->sapi) { |
| 501 | case PCU_IF_SAPI_PDTCH: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 502 | pcu_rx_rts_req_pdtch(bts, rts_req->trx_nr, rts_req->ts_nr, |
Max | 878bd1f | 2016-07-20 13:05:05 +0200 | [diff] [blame] | 503 | rts_req->fn, rts_req->block_nr); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 504 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 505 | case PCU_IF_SAPI_PTCCH: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 506 | pcu_rx_rts_req_ptcch(bts, rts_req->trx_nr, rts_req->ts_nr, |
Vadim Yanitskiy | 78f5861 | 2019-10-05 22:22:08 +0700 | [diff] [blame] | 507 | rts_req->fn, rts_req->block_nr); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 508 | break; |
| 509 | default: |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 510 | LOGP(DL1IF, LOGL_ERROR, "(bts=%u,trx=%u,ts=%u) FN=%u RX RTS.req with " |
| 511 | "unsupported sapi %d\n", bts->nr, rts_req->trx_nr, rts_req->ts_nr, |
| 512 | rts_req->fn, rts_req->sapi); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 513 | rc = -EINVAL; |
| 514 | } |
| 515 | |
| 516 | return rc; |
| 517 | } |
| 518 | |
Vadim Yanitskiy | ffebd24 | 2019-10-05 23:45:31 +0700 | [diff] [blame] | 519 | /* C -> C++ adapter for direct DSP access code (e.g. osmo-bts-sysmo) */ |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 520 | extern "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 Yanitskiy | ffebd24 | 2019-10-05 23:45:31 +0700 | [diff] [blame] | 521 | { |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 522 | struct rach_ind_params rip = { |
| 523 | /* The content of RA is not of interest on PTCCH/U */ |
| 524 | .burst_type = GSM_L1_BURST_TYPE_ACCESS_0, |
| 525 | .is_11bit = false, |
| 526 | .ra = 0x00, |
| 527 | .trx_nr = trx_nr, |
| 528 | .ts_nr = ts_nr, |
| 529 | .rfn = fn, |
| 530 | .qta = qta, |
| 531 | }; |
| 532 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 533 | return bts_rcv_ptcch_rach(bts, &rip); |
Vadim Yanitskiy | ffebd24 | 2019-10-05 23:45:31 +0700 | [diff] [blame] | 534 | } |
| 535 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 536 | static int pcu_rx_rach_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_rach_ind *rach_ind) |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 537 | { |
| 538 | int rc = 0; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 539 | int current_fn = bts_current_frame_number(bts); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 540 | |
| 541 | LOGP(DL1IF, LOGL_INFO, "RACH request received: sapi=%d " |
Vadim Yanitskiy | b30f28f | 2020-03-29 19:01:58 +0700 | [diff] [blame] | 542 | "qta=%d, ra=0x%02x, fn=%u, cur_fn=%d, is_11bit=%d\n", rach_ind->sapi, rach_ind->qta, |
Philipp Maier | 7e8e397 | 2018-04-10 13:31:45 +0200 | [diff] [blame] | 543 | rach_ind->ra, rach_ind->fn, current_fn, rach_ind->is_11bit); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 544 | |
Vadim Yanitskiy | a0a0b7f | 2020-05-21 19:55:46 +0700 | [diff] [blame] | 545 | struct rach_ind_params rip = { |
| 546 | .burst_type = (enum ph_burst_type) rach_ind->burst_type, |
| 547 | .is_11bit = rach_ind->is_11bit > 0, |
| 548 | .ra = rach_ind->ra, |
| 549 | .trx_nr = rach_ind->trx_nr, |
| 550 | .ts_nr = rach_ind->ts_nr, |
| 551 | .rfn = rach_ind->fn, |
| 552 | .qta = rach_ind->qta, |
| 553 | }; |
| 554 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 555 | switch (rach_ind->sapi) { |
| 556 | case PCU_IF_SAPI_RACH: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 557 | rc = bts_rcv_rach(bts, &rip); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 558 | break; |
Vadim Yanitskiy | ffebd24 | 2019-10-05 23:45:31 +0700 | [diff] [blame] | 559 | case PCU_IF_SAPI_PTCCH: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 560 | rc = bts_rcv_ptcch_rach(bts, &rip); |
Vadim Yanitskiy | ffebd24 | 2019-10-05 23:45:31 +0700 | [diff] [blame] | 561 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 562 | default: |
| 563 | LOGP(DL1IF, LOGL_ERROR, "Received PCU rach request with " |
| 564 | "unsupported sapi %d\n", rach_ind->sapi); |
| 565 | rc = -EINVAL; |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 566 | } |
| 567 | |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 568 | return rc; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 569 | } |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 570 | |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 571 | static int pcu_info_ind_ns(struct gprs_rlcmac_bts *bts, |
| 572 | const struct gsm_pcu_if_info_ind *info_ind) |
| 573 | { |
| 574 | struct osmo_sockaddr remote[PCU_IF_NUM_NSVC] = { }; |
| 575 | struct osmo_sockaddr local[PCU_IF_NUM_NSVC] = { }; |
| 576 | uint16_t nsvci[PCU_IF_NUM_NSVC] = { }; |
| 577 | uint16_t valid = 0; |
| 578 | |
| 579 | for (unsigned int i = 0; i < PCU_IF_NUM_NSVC; i++) { |
| 580 | struct osmo_sockaddr_str sockstr; |
| 581 | |
| 582 | switch (info_ind->address_type[i]) { |
| 583 | case PCU_IF_ADDR_TYPE_IPV4: |
| 584 | local[i].u.sin.sin_family = AF_INET; |
| 585 | local[i].u.sin.sin_addr.s_addr = INADDR_ANY; |
| 586 | local[i].u.sin.sin_port = htons(info_ind->local_port[i]); |
| 587 | |
| 588 | remote[i].u.sin.sin_family = AF_INET; |
Alexander Couzens | 87c6dd3 | 2020-10-27 13:24:40 +0100 | [diff] [blame] | 589 | memcpy(&remote[i].u.sin.sin_addr, &info_ind->remote_ip[i].v4, |
| 590 | sizeof(struct in_addr)); |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 591 | remote[i].u.sin.sin_port = htons(info_ind->remote_port[i]); |
| 592 | break; |
| 593 | case PCU_IF_ADDR_TYPE_IPV6: |
| 594 | local[i].u.sin6.sin6_family = AF_INET6; |
| 595 | local[i].u.sin6.sin6_addr = in6addr_any; |
| 596 | local[i].u.sin6.sin6_port = htons(info_ind->local_port[i]); |
| 597 | |
| 598 | remote[i].u.sin6.sin6_family = AF_INET6; |
Alexander Couzens | 87c6dd3 | 2020-10-27 13:24:40 +0100 | [diff] [blame] | 599 | memcpy(&remote[i].u.sin6.sin6_addr, |
| 600 | &info_ind->remote_ip[i].v6, |
| 601 | sizeof(struct in6_addr)); |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 602 | remote[i].u.sin6.sin6_port = htons(info_ind->remote_port[i]); |
| 603 | break; |
| 604 | default: |
| 605 | continue; |
| 606 | } |
| 607 | nsvci[i] = info_ind->nsvci[i]; |
| 608 | |
| 609 | LOGP(DL1IF, LOGL_DEBUG, " NS%u nsvci=%u\n", i, nsvci[i]); |
| 610 | if (osmo_sockaddr_str_from_sockaddr(&sockstr, &remote[i].u.sas)) |
| 611 | strcpy(sockstr.ip, "invalid"); |
| 612 | |
| 613 | LOGP(DL1IF, LOGL_DEBUG, " NS%u address: r=%s:%u<->l=NULL:%u\n", |
| 614 | i, sockstr.ip, sockstr.port, info_ind->local_port[i]); |
| 615 | |
| 616 | valid |= 1 << i; |
| 617 | } |
| 618 | |
| 619 | if (valid == 0) { |
| 620 | LOGP(DL1IF, LOGL_ERROR, "No NSVC available to connect to the SGSN!\n"); |
| 621 | return -EINVAL; |
| 622 | } |
| 623 | |
Alexander Couzens | 94a367f | 2021-02-16 16:57:15 +0100 | [diff] [blame] | 624 | return gprs_ns_update_config(bts, info_ind->nsei, local, remote, nsvci, valid); |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 625 | } |
| 626 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 627 | static int pcu_rx_info_ind(struct gprs_rlcmac_bts *bts, const struct gsm_pcu_if_info_ind *info_ind) |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 628 | { |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 629 | struct gprs_bssgp_pcu *pcu; |
Harald Welte | bb47d95 | 2016-11-17 18:40:02 +0100 | [diff] [blame] | 630 | int rc = 0; |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 631 | unsigned int trx_nr, ts_nr; |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 632 | unsigned int i; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 633 | |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 634 | if (info_ind->version != PCU_IF_VERSION) { |
Vadim Yanitskiy | fad2128 | 2020-07-19 02:05:33 +0700 | [diff] [blame] | 635 | fprintf(stderr, "PCU interface version number of BTS (%u) is " |
| 636 | "different (%u).\nPlease re-compile!\n", |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 637 | info_ind->version, PCU_IF_VERSION); |
| 638 | exit(-1); |
| 639 | } |
| 640 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 641 | LOGP(DL1IF, LOGL_DEBUG, "Info indication received:\n"); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 642 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 643 | if (!(info_ind->flags & PCU_IF_FLAG_ACTIVE)) { |
| 644 | LOGP(DL1IF, LOGL_NOTICE, "BTS not available\n"); |
Stefan Sperling | 5b22fb7 | 2018-02-14 19:46:33 +0100 | [diff] [blame] | 645 | if (!bts->active) |
| 646 | return -EAGAIN; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 647 | bssgp_failed: |
Stefan Sperling | 5b22fb7 | 2018-02-14 19:46:33 +0100 | [diff] [blame] | 648 | bts->active = false; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 649 | /* free all TBF */ |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 650 | for (trx_nr = 0; trx_nr < ARRAY_SIZE(bts->trx); trx_nr++) { |
| 651 | bts->trx[trx_nr].arfcn = info_ind->trx[trx_nr].arfcn; |
| 652 | for (ts_nr = 0; ts_nr < ARRAY_SIZE(bts->trx[0].pdch); ts_nr++) |
| 653 | bts->trx[trx_nr].pdch[ts_nr].free_resources(); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 654 | } |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 655 | gprs_bssgp_destroy(bts); |
Daniel Willmann | 6d8884d | 2014-06-04 18:30:59 +0200 | [diff] [blame] | 656 | exit(0); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 657 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 658 | LOGP(DL1IF, LOGL_INFO, "BTS available\n"); |
Neels Hofmeyr | bdc55fa | 2018-02-21 00:39:07 +0100 | [diff] [blame] | 659 | LOGP(DL1IF, LOGL_DEBUG, " mcc=%03u\n", info_ind->mcc); |
| 660 | LOGP(DL1IF, LOGL_DEBUG, " mnc=%0*u\n", info_ind->mnc_3_digits, info_ind->mnc); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 661 | LOGP(DL1IF, LOGL_DEBUG, " lac=%d\n", info_ind->lac); |
| 662 | LOGP(DL1IF, LOGL_DEBUG, " rac=%d\n", info_ind->rac); |
Harald Welte | 1473b37 | 2019-03-21 19:48:55 +0100 | [diff] [blame] | 663 | LOGP(DL1IF, LOGL_DEBUG, " cell_id=%d\n", info_ind->cell_id); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 664 | LOGP(DL1IF, LOGL_DEBUG, " bsic=%d\n", info_ind->bsic); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 665 | LOGP(DL1IF, LOGL_DEBUG, " nsei=%d\n", info_ind->nsei); |
| 666 | LOGP(DL1IF, LOGL_DEBUG, " nse_timer=%d %d %d %d %d %d %d\n", |
| 667 | info_ind->nse_timer[0], info_ind->nse_timer[1], |
| 668 | info_ind->nse_timer[2], info_ind->nse_timer[3], |
| 669 | info_ind->nse_timer[4], info_ind->nse_timer[5], |
| 670 | info_ind->nse_timer[6]); |
| 671 | LOGP(DL1IF, LOGL_DEBUG, " cell_timer=%d %d %d %d %d %d %d %d %d %d " |
| 672 | "%d\n", |
| 673 | info_ind->cell_timer[0], info_ind->cell_timer[1], |
| 674 | info_ind->cell_timer[2], info_ind->cell_timer[3], |
| 675 | info_ind->cell_timer[4], info_ind->cell_timer[5], |
| 676 | info_ind->cell_timer[6], info_ind->cell_timer[7], |
| 677 | info_ind->cell_timer[8], info_ind->cell_timer[9], |
| 678 | info_ind->cell_timer[10]); |
| 679 | LOGP(DL1IF, LOGL_DEBUG, " repeat_time=%d\n", info_ind->repeat_time); |
| 680 | LOGP(DL1IF, LOGL_DEBUG, " repeat_count=%d\n", info_ind->repeat_count); |
| 681 | LOGP(DL1IF, LOGL_DEBUG, " bvci=%d\n", info_ind->bvci); |
| 682 | LOGP(DL1IF, LOGL_DEBUG, " t3142=%d\n", info_ind->t3142); |
| 683 | LOGP(DL1IF, LOGL_DEBUG, " t3169=%d\n", info_ind->t3169); |
| 684 | LOGP(DL1IF, LOGL_DEBUG, " t3191=%d\n", info_ind->t3191); |
| 685 | LOGP(DL1IF, LOGL_DEBUG, " t3193=%d (ms)\n", info_ind->t3193_10ms * 10); |
| 686 | LOGP(DL1IF, LOGL_DEBUG, " t3195=%d\n", info_ind->t3195); |
| 687 | LOGP(DL1IF, LOGL_DEBUG, " n3101=%d\n", info_ind->n3101); |
| 688 | LOGP(DL1IF, LOGL_DEBUG, " n3103=%d\n", info_ind->n3103); |
| 689 | LOGP(DL1IF, LOGL_DEBUG, " n3105=%d\n", info_ind->n3105); |
| 690 | LOGP(DL1IF, LOGL_DEBUG, " cv_countdown=%d\n", info_ind->cv_countdown); |
| 691 | LOGP(DL1IF, LOGL_DEBUG, " dl_tbf_ext=%d\n", info_ind->dl_tbf_ext); |
| 692 | LOGP(DL1IF, LOGL_DEBUG, " ul_tbf_ext=%d\n", info_ind->ul_tbf_ext); |
Pau Espin Pedrol | 2e6b60d | 2021-01-20 13:48:31 +0100 | [diff] [blame] | 693 | bts->cgi_ps.rai.lac.plmn.mcc = info_ind->mcc; |
| 694 | bts->cgi_ps.rai.lac.plmn.mnc = info_ind->mnc; |
| 695 | bts->cgi_ps.rai.lac.plmn.mnc_3_digits = info_ind->mnc_3_digits; |
| 696 | bts->cgi_ps.rai.lac.lac = info_ind->lac; |
| 697 | bts->cgi_ps.rai.rac = info_ind->rac; |
| 698 | bts->cgi_ps.cell_identity = info_ind->cell_id; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 699 | bts->bsic = info_ind->bsic; |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 700 | |
| 701 | bts->cs_mask = 1 << 0; /* We need at least 1 CS, let's enable CS1 */ |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 702 | for (i = 0; i < 4; i++) { |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 703 | uint8_t allowed = !!(info_ind->flags & (PCU_IF_FLAG_CS1 << i)); |
| 704 | bts->cs_mask |= allowed << i; |
| 705 | if (allowed) |
| 706 | LOGP(DL1IF, LOGL_DEBUG, " Use CS%d\n", i + 1); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 707 | } |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 708 | bts_recalc_max_cs(bts); |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 709 | |
| 710 | bts->mcs_mask = 0; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 711 | for (i = 0; i < 9; i++) { |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 712 | uint8_t allowed = !!(info_ind->flags & (PCU_IF_FLAG_MCS1 << i)); |
| 713 | bts->mcs_mask |= allowed << i; |
Pau Espin Pedrol | 87eec1f | 2020-10-30 18:46:24 +0100 | [diff] [blame] | 714 | if (allowed) |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 715 | LOGP(DL1IF, LOGL_DEBUG, " Use MCS%d\n", i + 1); |
Pau Espin Pedrol | 87eec1f | 2020-10-30 18:46:24 +0100 | [diff] [blame] | 716 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 717 | } |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 718 | bts_recalc_max_mcs(bts); |
Pau Espin Pedrol | d87722d | 2020-10-30 17:14:26 +0100 | [diff] [blame] | 719 | |
Pau Espin Pedrol | b47b137 | 2020-11-03 15:59:39 +0100 | [diff] [blame] | 720 | LOGP(DL1IF, LOGL_DEBUG, " initial_cs=%u%s\n", info_ind->initial_cs, |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 721 | the_pcu->vty.force_initial_cs ? " (VTY forced, ignoring)" : ""); |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 722 | bts->pcuif_info_ind.initial_cs = info_ind->initial_cs; |
| 723 | bts_recalc_initial_cs(bts); |
Pau Espin Pedrol | b47b137 | 2020-11-03 15:59:39 +0100 | [diff] [blame] | 724 | |
| 725 | LOGP(DL1IF, LOGL_DEBUG, " initial_mcs=%u%s\n", info_ind->initial_mcs, |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 726 | the_pcu->vty.force_initial_mcs ? " (VTY forced, ignoring)" : ""); |
Pau Espin Pedrol | 793583e | 2021-01-14 16:20:57 +0100 | [diff] [blame] | 727 | bts->pcuif_info_ind.initial_mcs = info_ind->initial_mcs; |
| 728 | bts_recalc_initial_mcs(bts); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 729 | |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 730 | pcu = gprs_bssgp_init( |
| 731 | bts, |
| 732 | info_ind->nsei, info_ind->bvci, |
| 733 | info_ind->mcc, info_ind->mnc, info_ind->mnc_3_digits, |
| 734 | info_ind->lac, info_ind->rac, info_ind->cell_id); |
| 735 | if (!pcu) { |
Vadim Yanitskiy | c1a726c | 2020-10-08 22:46:26 +0700 | [diff] [blame] | 736 | LOGP(DL1IF, LOGL_ERROR, "Failed to init BSSGP\n"); |
Alexander Couzens | 9b5c960 | 2020-07-28 13:47:18 +0200 | [diff] [blame] | 737 | goto bssgp_failed; |
| 738 | } |
| 739 | |
Alexander Couzens | 5bece2a | 2020-10-12 02:27:22 +0200 | [diff] [blame] | 740 | rc = pcu_info_ind_ns(pcu->bts, info_ind); |
| 741 | if (rc < 0) { |
Alexander Couzens | 290d903 | 2020-09-16 21:52:02 +0200 | [diff] [blame] | 742 | LOGP(DL1IF, LOGL_ERROR, "No NSVC available to connect to the SGSN!\n"); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 743 | goto bssgp_failed; |
| 744 | } |
| 745 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 746 | if (info_ind->t3142) { /* if timer values are set */ |
Pau Espin Pedrol | 28f160e | 2019-09-05 14:48:35 +0200 | [diff] [blame] | 747 | osmo_tdef_set(bts->T_defs_bts, 3142, info_ind->t3142, OSMO_TDEF_S); |
| 748 | osmo_tdef_set(bts->T_defs_bts, 3169, info_ind->t3169, OSMO_TDEF_S); |
| 749 | osmo_tdef_set(bts->T_defs_bts, 3191, info_ind->t3191, OSMO_TDEF_S); |
| 750 | osmo_tdef_set(bts->T_defs_bts, 3193, info_ind->t3193_10ms * 10, OSMO_TDEF_MS); |
| 751 | osmo_tdef_set(bts->T_defs_bts, 3195, info_ind->t3195, OSMO_TDEF_S); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 752 | bts->n3101 = info_ind->n3101; |
| 753 | bts->n3103 = info_ind->n3103; |
| 754 | bts->n3105 = info_ind->n3105; |
| 755 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 756 | |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 757 | for (trx_nr = 0; trx_nr < ARRAY_SIZE(bts->trx); trx_nr++) { |
| 758 | bts->trx[trx_nr].arfcn = info_ind->trx[trx_nr].arfcn; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 759 | if ((info_ind->flags & PCU_IF_FLAG_SYSMO) |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 760 | && info_ind->trx[trx_nr].hlayer1) { |
Max | cad867e | 2016-04-21 14:35:55 +0200 | [diff] [blame] | 761 | #ifdef ENABLE_DIRECT_PHY |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 762 | LOGP(DL1IF, LOGL_DEBUG, " TRX %d hlayer1=%x\n", trx_nr, |
| 763 | info_ind->trx[trx_nr].hlayer1); |
| 764 | if (!bts->trx[trx_nr].fl1h) |
| 765 | bts->trx[trx_nr].fl1h = l1if_open_pdch( |
| 766 | trx_nr, |
| 767 | info_ind->trx[trx_nr].hlayer1, |
Pau Espin Pedrol | ac3fd12 | 2021-01-13 18:54:38 +0100 | [diff] [blame] | 768 | the_pcu->gsmtap); |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 769 | if (!bts->trx[trx_nr].fl1h) { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 770 | LOGP(DL1IF, LOGL_FATAL, "Failed to open direct " |
| 771 | "DSP access for PDCH.\n"); |
| 772 | exit(0); |
| 773 | } |
| 774 | #else |
| 775 | LOGP(DL1IF, LOGL_FATAL, "Compiled without direct DSP " |
| 776 | "access for PDCH, but enabled at " |
| 777 | "BTS. Please deactivate it!\n"); |
| 778 | exit(0); |
| 779 | #endif |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 780 | } |
| 781 | |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 782 | for (ts_nr = 0; ts_nr < ARRAY_SIZE(bts->trx[0].pdch); ts_nr++) { |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 783 | const struct gsm_pcu_if_info_ts *its = &info_ind->trx[trx_nr].ts[ts_nr]; |
Vadim Yanitskiy | 0f41b71 | 2020-07-24 01:28:13 +0700 | [diff] [blame] | 784 | struct gprs_rlcmac_pdch *pdch = &bts->trx[trx_nr].pdch[ts_nr]; |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 785 | if ((info_ind->trx[trx_nr].pdch_mask & (1 << ts_nr))) { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 786 | /* FIXME: activate dynamically at RLCMAC */ |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 787 | if (!pdch->is_enabled()) { |
Max | cad867e | 2016-04-21 14:35:55 +0200 | [diff] [blame] | 788 | #ifdef ENABLE_DIRECT_PHY |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 789 | if ((info_ind->flags & |
| 790 | PCU_IF_FLAG_SYSMO)) |
| 791 | l1if_connect_pdch( |
Vadim Yanitskiy | 11b0f00 | 2020-07-24 01:24:47 +0700 | [diff] [blame] | 792 | bts->trx[trx_nr].fl1h, ts_nr); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 793 | #endif |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 794 | pcu_tx_act_req(bts, pdch, 1); |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 795 | pdch->enable(); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 796 | } |
Vadim Yanitskiy | 8e2bd1e | 2020-07-21 00:54:42 +0700 | [diff] [blame] | 797 | |
| 798 | pdch->tsc = its->tsc; |
| 799 | |
| 800 | /* (Optional) frequency hopping parameters */ |
| 801 | if (its->h) { |
| 802 | pdch->fh.enabled = true; |
| 803 | pdch->fh.maio = its->maio; |
| 804 | pdch->fh.hsn = its->hsn; |
| 805 | |
| 806 | OSMO_ASSERT(its->ma_bit_len <= sizeof(pdch->fh.ma) * 8); |
| 807 | pdch->fh.ma_oct_len = OSMO_BYTES_FOR_BITS(its->ma_bit_len); |
| 808 | pdch->fh.ma_bit_len = its->ma_bit_len; |
| 809 | |
| 810 | /* Mobile Allocation + padding (byte/bit order as on the wire): |
| 811 | * | 00 00 00 00 00 cc bb aa | -> | cc bb aa 00 00 00 00 00 | */ |
| 812 | unsigned int offset = sizeof(pdch->fh.ma) - pdch->fh.ma_oct_len; |
| 813 | memcpy(pdch->fh.ma, its->ma + offset, pdch->fh.ma_oct_len); |
| 814 | } |
| 815 | |
| 816 | LOGP(DL1IF, LOGL_INFO, "PDCH (trx=%u, ts=%u): tsc=%u, hopping=%s\n", |
| 817 | trx_nr, ts_nr, pdch->tsc, pdch->fh.enabled ? "yes" : "no"); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 818 | } else { |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 819 | if (pdch->is_enabled()) { |
Pau Espin Pedrol | df58ddf | 2021-03-09 16:19:22 +0100 | [diff] [blame] | 820 | pcu_tx_act_req(bts, pdch, 0); |
Holger Hans Peter Freyther | 09ef27a | 2013-10-20 16:37:05 +0200 | [diff] [blame] | 821 | pdch->free_resources(); |
Holger Hans Peter Freyther | 17b0d83 | 2013-10-19 17:37:48 +0200 | [diff] [blame] | 822 | pdch->disable(); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 823 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
Stefan Sperling | 5b22fb7 | 2018-02-14 19:46:33 +0100 | [diff] [blame] | 828 | bts->active = true; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 829 | return rc; |
| 830 | } |
| 831 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 832 | static int pcu_rx_time_ind(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_time_ind *time_ind) |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 833 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 834 | uint8_t fn13 = time_ind->fn % 13; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 835 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 836 | /* omit frame numbers not starting at a MAC block */ |
| 837 | if (fn13 != 0 && fn13 != 4 && fn13 != 8) |
| 838 | return 0; |
Max | 3741f14 | 2017-06-26 12:10:12 +0200 | [diff] [blame] | 839 | |
| 840 | LOGP(DL1IF, LOGL_DEBUG, "Time indication received: %d\n", time_ind->fn % 52); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 841 | |
Pau Espin Pedrol | 3061711 | 2021-03-05 18:59:05 +0100 | [diff] [blame] | 842 | /* Ignore TIME.ind completely, we nowadays relay on DATA.ind always |
| 843 | * providing all block FNs. */ |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 844 | return 0; |
| 845 | } |
| 846 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 847 | static int pcu_rx_pag_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_pag_req *pag_req) |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 848 | { |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 849 | struct osmo_mobile_identity mi; |
Pau Espin Pedrol | bd54205 | 2021-05-13 17:44:51 +0200 | [diff] [blame] | 850 | struct GprsMs *ms = NULL; |
| 851 | struct paging_req_cs req = { .chan_needed = pag_req->chan_needed, |
| 852 | .tlli = GSM_RESERVED_TMSI }; |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 853 | int rc; |
| 854 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 855 | LOGP(DL1IF, LOGL_DEBUG, "Paging request received: chan_needed=%d " |
| 856 | "length=%d\n", pag_req->chan_needed, pag_req->identity_lv[0]); |
| 857 | |
Pau Espin Pedrol | 32499b6 | 2019-12-09 13:55:12 +0100 | [diff] [blame] | 858 | /* check if identity does not fit: length > sizeof(lv) - 1 */ |
| 859 | if (pag_req->identity_lv[0] >= sizeof(pag_req->identity_lv)) { |
| 860 | LOGP(DL1IF, LOGL_ERROR, "Paging identity too large (%" PRIu8 ")\n", |
| 861 | pag_req->identity_lv[0]); |
| 862 | return -EINVAL; |
| 863 | } |
| 864 | |
Neels Hofmeyr | 59fc0bd | 2020-08-21 16:21:23 +0200 | [diff] [blame] | 865 | rc = osmo_mobile_identity_decode(&mi, &pag_req->identity_lv[1], pag_req->identity_lv[0], true); |
| 866 | if (rc < 0) { |
| 867 | LOGP(DL1IF, LOGL_ERROR, "Failed to decode Mobile Identity in Paging Request (rc=%d)\n", rc); |
| 868 | return -EINVAL; |
| 869 | } |
| 870 | |
Pau Espin Pedrol | bd54205 | 2021-05-13 17:44:51 +0200 | [diff] [blame] | 871 | switch (mi.type) { |
| 872 | case GSM_MI_TYPE_TMSI: |
| 873 | req.mi_tmsi = mi; |
| 874 | req.mi_tmsi_present = true; |
| 875 | /* TODO: look up MS by TMSI? Derive TLLI? */ |
| 876 | break; |
| 877 | case GSM_MI_TYPE_IMSI: |
| 878 | req.mi_imsi = mi; |
| 879 | req.mi_imsi_present = true; |
| 880 | ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi); |
| 881 | break; |
| 882 | default: |
| 883 | LOGP(DL1IF, LOGL_ERROR, "Unexpected MI type %u\n", mi.type); |
| 884 | return -EINVAL; |
| 885 | } |
| 886 | |
| 887 | return bts_add_paging(bts, &req, ms); |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 888 | } |
| 889 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 890 | static int pcu_rx_susp_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_susp_req *susp_req) |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 891 | { |
Philipp Maier | a58ec61 | 2021-01-25 23:43:52 +0100 | [diff] [blame] | 892 | struct bssgp_bvc_ctx *bctx = the_pcu->bssgp.bctx; |
Pau Espin Pedrol | bd9973a | 2020-09-22 15:57:37 +0200 | [diff] [blame] | 893 | GprsMs *ms; |
| 894 | struct gprs_rlcmac_dl_tbf *dl_tbf; |
| 895 | struct gprs_rlcmac_ul_tbf *ul_tbf; |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 896 | struct gprs_ra_id ra_id; |
| 897 | |
| 898 | gsm48_parse_ra(&ra_id, susp_req->ra_id); |
| 899 | |
| 900 | LOGP(DL1IF, LOGL_INFO, "GPRS Suspend request received: TLLI=0x%08x RAI=%s\n", |
| 901 | susp_req->tlli, osmo_rai_name(&ra_id)); |
| 902 | |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 903 | if ((ms = bts_ms_store(bts)->get_ms(susp_req->tlli))) { |
Pau Espin Pedrol | bd9973a | 2020-09-22 15:57:37 +0200 | [diff] [blame] | 904 | /* We need to catch both pointers here since MS may become freed |
| 905 | after first tbf_free(dl_tbf) if only DL TBF was available */ |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 906 | dl_tbf = ms_dl_tbf(ms); |
| 907 | ul_tbf = ms_ul_tbf(ms); |
Pau Espin Pedrol | bd9973a | 2020-09-22 15:57:37 +0200 | [diff] [blame] | 908 | if (dl_tbf) |
| 909 | tbf_free(dl_tbf); |
| 910 | if (ul_tbf) |
| 911 | tbf_free(ul_tbf); |
| 912 | } |
| 913 | |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 914 | if (!bctx) |
| 915 | return -1; |
| 916 | |
| 917 | return bssgp_tx_suspend(bctx->nsei, susp_req->tlli, &ra_id); |
| 918 | } |
| 919 | |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 920 | static int pcu_rx_app_info_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_app_info_req *app_info_req) |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 921 | { |
Pau Espin Pedrol | 54faf02 | 2021-01-14 12:12:43 +0100 | [diff] [blame] | 922 | struct llist_head *tmp; |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 923 | |
| 924 | LOGP(DL1IF, LOGL_DEBUG, "Application Information Request received: type=0x%08x len=%i\n", |
| 925 | app_info_req->application_type, app_info_req->len); |
| 926 | |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 927 | bts->app_info_pending = 0; |
Pau Espin Pedrol | 2182e62 | 2021-01-14 16:48:38 +0100 | [diff] [blame] | 928 | llist_for_each(tmp, bts_ms_store(bts)->ms_list()) { |
Pau Espin Pedrol | 54faf02 | 2021-01-14 12:12:43 +0100 | [diff] [blame] | 929 | GprsMs *ms = llist_entry(tmp, typeof(*ms), list); |
Pau Espin Pedrol | da971ee | 2020-12-16 15:59:45 +0100 | [diff] [blame] | 930 | if (!ms_dl_tbf(ms)) |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 931 | continue; |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 932 | bts->app_info_pending++; |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 933 | ms->app_info_pending = true; |
| 934 | } |
| 935 | |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 936 | if (!bts->app_info_pending) { |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 937 | LOGP(DL1IF, LOGL_NOTICE, "Packet Application Information will not be sent, no subscribers with active" |
| 938 | " TBF\n"); |
| 939 | return -1; |
| 940 | } |
| 941 | |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 942 | if (bts->app_info) { |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 943 | LOGP(DL1IF, LOGL_NOTICE, "Previous Packet Application Information was not sent to all subscribers," |
| 944 | " overwriting with new one\n"); |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 945 | msgb_free(bts->app_info); |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | LOGP(DL1IF, LOGL_INFO, "Sending Packet Application Information to %i subscribers with active TBF\n", |
Pau Espin Pedrol | 0ece97d | 2021-01-18 12:53:54 +0100 | [diff] [blame] | 949 | bts->app_info_pending); |
| 950 | bts->app_info = gprs_rlcmac_app_info_msg(app_info_req); |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 951 | return 0; |
| 952 | } |
| 953 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 954 | int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim) |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 955 | { |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 956 | int rc = 0; |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 957 | struct gprs_rlcmac_bts *bts = gprs_pcu_get_bts_by_nr(the_pcu, pcu_prim->bts_nr); |
| 958 | if (!bts) { |
| 959 | LOGP(DL1IF, LOGL_NOTICE, "Received message for new BTS%d\n", pcu_prim->bts_nr); |
| 960 | bts = bts_alloc(the_pcu, pcu_prim->bts_nr); |
| 961 | if (!bts) { |
| 962 | LOGP(DL1IF, LOGL_ERROR, "Failed to create object for BTS%d!\n", pcu_prim->bts_nr); |
| 963 | return -EAGAIN; |
| 964 | } |
| 965 | } |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 966 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 967 | switch (msg_type) { |
| 968 | case PCU_IF_MSG_DATA_IND: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 969 | rc = pcu_rx_data_ind(bts, &pcu_prim->u.data_ind); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 970 | break; |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 971 | case PCU_IF_MSG_DATA_CNF: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 972 | rc = pcu_rx_data_cnf(bts, &pcu_prim->u.data_cnf); |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 973 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 974 | case PCU_IF_MSG_RTS_REQ: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 975 | rc = pcu_rx_rts_req(bts, &pcu_prim->u.rts_req); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 976 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 977 | case PCU_IF_MSG_RACH_IND: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 978 | rc = pcu_rx_rach_ind(bts, &pcu_prim->u.rach_ind); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 979 | break; |
| 980 | case PCU_IF_MSG_INFO_IND: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 981 | rc = pcu_rx_info_ind(bts, &pcu_prim->u.info_ind); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 982 | break; |
| 983 | case PCU_IF_MSG_TIME_IND: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 984 | rc = pcu_rx_time_ind(bts, &pcu_prim->u.time_ind); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 985 | break; |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 986 | case PCU_IF_MSG_PAG_REQ: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 987 | rc = pcu_rx_pag_req(bts, &pcu_prim->u.pag_req); |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 988 | break; |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 989 | case PCU_IF_MSG_SUSP_REQ: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 990 | rc = pcu_rx_susp_req(bts, &pcu_prim->u.susp_req); |
Harald Welte | 3447c4a | 2017-07-11 00:06:38 +0200 | [diff] [blame] | 991 | break; |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 992 | case PCU_IF_MSG_APP_INFO_REQ: |
Pau Espin Pedrol | d1049dc | 2021-01-18 17:14:14 +0100 | [diff] [blame] | 993 | rc = pcu_rx_app_info_req(bts, &pcu_prim->u.app_info_req); |
Oliver Smith | cfb6321 | 2019-09-05 17:13:33 +0200 | [diff] [blame] | 994 | break; |
Vadim Yanitskiy | b657213 | 2021-06-20 21:05:24 +0200 | [diff] [blame] | 995 | case PCU_IF_MSG_INTERF_IND: |
| 996 | /* TODO: handle interference reports */ |
| 997 | break; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 998 | default: |
Thorsten Alteholz | 8bb7904 | 2018-10-06 10:42:58 +0200 | [diff] [blame] | 999 | LOGP(DL1IF, LOGL_ERROR, "Received unknown PCU msg type %d\n", |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 1000 | msg_type); |
| 1001 | rc = -EINVAL; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 1002 | } |
Philipp Maier | 8ccf704 | 2018-04-10 13:12:42 +0200 | [diff] [blame] | 1003 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1004 | return rc; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 1005 | } |