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> |
| 22 | #include <stdlib.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 23 | #include <string.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 24 | #include <errno.h> |
| 25 | #include <assert.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 26 | #include <sys/socket.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 27 | #include <sys/un.h> |
Andreas Eversberg | 81a12be | 2013-03-16 16:16:41 +0100 | [diff] [blame] | 28 | #include <arpa/inet.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 29 | extern "C" { |
| 30 | #include <osmocom/core/talloc.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 31 | #include <osmocom/core/select.h> |
| 32 | #include <osmocom/core/msgb.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 33 | } |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 34 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 35 | #include <gprs_rlcmac.h> |
| 36 | #include <pcu_l1_if.h> |
| 37 | #include <gprs_debug.h> |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 38 | #include <gprs_bssgp_pcu.h> |
| 39 | #include <pcuif_proto.h> |
Holger Hans Peter Freyther | 099535a | 2013-10-16 17:42:31 +0200 | [diff] [blame] | 40 | #include <tbf.h> |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 41 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 42 | // FIXME: move this, when changed from c++ to c. |
| 43 | extern "C" { |
| 44 | void *l1if_open_pdch(void *priv, uint32_t hlayer1); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 45 | int l1if_connect_pdch(void *obj, uint8_t ts); |
| 46 | int l1if_pdch_req(void *obj, uint8_t ts, int is_ptcch, uint32_t fn, |
| 47 | uint16_t arfcn, uint8_t block_nr, uint8_t *data, uint8_t len); |
| 48 | } |
| 49 | |
Andreas Eversberg | e266bd4 | 2012-07-13 14:00:21 +0200 | [diff] [blame] | 50 | extern void *tall_pcu_ctx; |
| 51 | |
Ivan Kluchnikov | 4277f0c | 2012-04-12 14:24:35 +0400 | [diff] [blame] | 52 | // Variable for storage current FN. |
| 53 | int frame_number; |
| 54 | |
| 55 | int get_current_fn() |
| 56 | { |
| 57 | return frame_number; |
| 58 | } |
| 59 | |
| 60 | void set_current_fn(int fn) |
| 61 | { |
| 62 | frame_number = fn; |
| 63 | } |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 64 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 65 | /* |
| 66 | * PCU messages |
| 67 | */ |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 68 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 69 | struct msgb *pcu_msgb_alloc(uint8_t msg_type, uint8_t bts_nr) |
| 70 | { |
| 71 | struct msgb *msg; |
| 72 | struct gsm_pcu_if *pcu_prim; |
| 73 | |
| 74 | msg = msgb_alloc(sizeof(struct gsm_pcu_if), "pcu_sock_tx"); |
| 75 | if (!msg) |
| 76 | return NULL; |
| 77 | msgb_put(msg, sizeof(struct gsm_pcu_if)); |
| 78 | pcu_prim = (struct gsm_pcu_if *) msg->data; |
| 79 | pcu_prim->msg_type = msg_type; |
| 80 | pcu_prim->bts_nr = bts_nr; |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 81 | |
| 82 | return msg; |
| 83 | } |
| 84 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 85 | static int pcu_tx_act_req(uint8_t trx, uint8_t ts, uint8_t activate) |
Ivan Kluchnikov | 4277f0c | 2012-04-12 14:24:35 +0400 | [diff] [blame] | 86 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 87 | struct msgb *msg; |
| 88 | struct gsm_pcu_if *pcu_prim; |
| 89 | struct gsm_pcu_if_act_req *act_req; |
| 90 | |
| 91 | LOGP(DL1IF, LOGL_INFO, "Sending %s request: trx=%d ts=%d\n", |
| 92 | (activate) ? "activate" : "deactivate", trx, ts); |
| 93 | |
| 94 | msg = pcu_msgb_alloc(PCU_IF_MSG_ACT_REQ, 0); |
| 95 | if (!msg) |
| 96 | return -ENOMEM; |
| 97 | pcu_prim = (struct gsm_pcu_if *) msg->data; |
| 98 | act_req = &pcu_prim->u.act_req; |
| 99 | act_req->activate = activate; |
| 100 | act_req->trx_nr = trx; |
| 101 | act_req->ts_nr = ts; |
| 102 | |
| 103 | return pcu_sock_send(msg); |
| 104 | } |
| 105 | |
| 106 | static int pcu_tx_data_req(uint8_t trx, uint8_t ts, uint8_t sapi, |
| 107 | uint16_t arfcn, uint32_t fn, uint8_t block_nr, uint8_t *data, |
| 108 | uint8_t len) |
| 109 | { |
| 110 | struct msgb *msg; |
| 111 | struct gsm_pcu_if *pcu_prim; |
| 112 | struct gsm_pcu_if_data *data_req; |
| 113 | |
| 114 | LOGP(DL1IF, LOGL_DEBUG, "Sending data request: trx=%d ts=%d sapi=%d " |
| 115 | "arfcn=%d fn=%d block=%d data=%s\n", trx, ts, sapi, arfcn, fn, |
| 116 | block_nr, osmo_hexdump(data, len)); |
| 117 | |
| 118 | msg = pcu_msgb_alloc(PCU_IF_MSG_DATA_REQ, 0); |
| 119 | if (!msg) |
| 120 | return -ENOMEM; |
| 121 | pcu_prim = (struct gsm_pcu_if *) msg->data; |
| 122 | data_req = &pcu_prim->u.data_req; |
| 123 | |
| 124 | data_req->sapi = sapi; |
| 125 | data_req->fn = fn; |
| 126 | data_req->arfcn = arfcn; |
| 127 | data_req->trx_nr = trx; |
| 128 | data_req->ts_nr = ts; |
| 129 | data_req->block_nr = block_nr; |
| 130 | memcpy(data_req->data, data, len); |
| 131 | data_req->len = len; |
| 132 | |
| 133 | return pcu_sock_send(msg); |
| 134 | } |
| 135 | |
| 136 | void pcu_l1if_tx_pdtch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 137 | uint32_t fn, uint8_t block_nr) |
| 138 | { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 139 | #ifdef ENABLE_SYSMODSP |
| 140 | struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; |
| 141 | |
| 142 | if (bts->trx[trx].fl1h) |
| 143 | l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr, |
| 144 | msg->data, msg->len); |
| 145 | else |
| 146 | #endif |
| 147 | pcu_tx_data_req(trx, ts, PCU_IF_SAPI_PDTCH, arfcn, fn, block_nr, |
| 148 | msg->data, msg->len); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 149 | msgb_free(msg); |
Ivan Kluchnikov | 4277f0c | 2012-04-12 14:24:35 +0400 | [diff] [blame] | 150 | } |
| 151 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 152 | void pcu_l1if_tx_ptcch(msgb *msg, uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 153 | uint32_t fn, uint8_t block_nr) |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 154 | { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 155 | #ifdef ENABLE_SYSMODSP |
| 156 | struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; |
| 157 | |
| 158 | if (bts->trx[trx].fl1h) |
| 159 | l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr, |
| 160 | msg->data, msg->len); |
| 161 | else |
| 162 | #endif |
| 163 | pcu_tx_data_req(trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, |
| 164 | msg->data, msg->len); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 165 | msgb_free(msg); |
| 166 | } |
| 167 | |
Andreas Eversberg | 7b04501 | 2012-07-05 07:38:49 +0200 | [diff] [blame] | 168 | void pcu_l1if_tx_agch(bitvec * block, int plen) |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 169 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 170 | uint8_t data[23]; /* prefix PLEN */ |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 171 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 172 | /* FIXME: why does OpenBTS has no PLEN and no fill in message? */ |
| 173 | bitvec_pack(block, data + 1); |
| 174 | data[0] = (plen << 2) | 0x01; |
| 175 | pcu_tx_data_req(0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, 23); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 176 | } |
| 177 | |
Holger Hans Peter Freyther | 52c911b | 2013-08-24 18:30:54 +0200 | [diff] [blame] | 178 | void pcu_l1if_tx_pch(bitvec * block, int plen, const char *imsi) |
Ivan Kluchnikov | c7e7f68 | 2012-06-29 22:53:15 +0400 | [diff] [blame] | 179 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 180 | uint8_t data[23+3]; /* prefix PLEN */ |
| 181 | |
| 182 | /* paging group */ |
| 183 | if (!imsi || strlen(imsi) < 3) |
| 184 | return; |
| 185 | imsi += strlen(imsi) - 3; |
| 186 | data[0] = imsi[0]; |
| 187 | data[1] = imsi[1]; |
| 188 | data[2] = imsi[2]; |
| 189 | |
| 190 | bitvec_pack(block, data + 3+1); |
| 191 | data[3] = (plen << 2) | 0x01; |
| 192 | pcu_tx_data_req(0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, 23+3); |
Ivan Kluchnikov | c7e7f68 | 2012-06-29 22:53:15 +0400 | [diff] [blame] | 193 | } |
| 194 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 195 | extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data, |
Andreas Eversberg | 570b44b | 2013-03-16 16:15:01 +0100 | [diff] [blame] | 196 | uint8_t len, uint32_t fn, int8_t rssi) |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 197 | { |
Holger Hans Peter Freyther | 698b612 | 2013-10-17 13:44:18 +0200 | [diff] [blame^] | 198 | return gprs_rlcmac_rcv_block(gprs_rlcmac_bts, trx, ts, data, len, fn, rssi); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 199 | } |
| 200 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 201 | static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind) |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 202 | { |
| 203 | int rc = 0; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 204 | |
| 205 | LOGP(DL1IF, LOGL_DEBUG, "Data indication received: sapi=%d arfcn=%d " |
| 206 | "block=%d data=%s\n", data_ind->sapi, |
| 207 | data_ind->arfcn, data_ind->block_nr, |
| 208 | osmo_hexdump(data_ind->data, data_ind->len)); |
| 209 | |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 210 | switch (data_ind->sapi) { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 211 | case PCU_IF_SAPI_PDTCH: |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 212 | rc = pcu_rx_data_ind_pdtch(data_ind->trx_nr, data_ind->ts_nr, |
Andreas Eversberg | 570b44b | 2013-03-16 16:15:01 +0100 | [diff] [blame] | 213 | data_ind->data, data_ind->len, data_ind->fn, |
| 214 | data_ind->rssi); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 215 | break; |
| 216 | default: |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 217 | LOGP(DL1IF, LOGL_ERROR, "Received PCU data indication with " |
| 218 | "unsupported sapi %d\n", data_ind->sapi); |
| 219 | rc = -EINVAL; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 220 | } |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 221 | |
| 222 | return rc; |
| 223 | } |
| 224 | |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 225 | static int pcu_rx_data_cnf(struct gsm_pcu_if_data *data_cnf) |
| 226 | { |
| 227 | int rc = 0; |
| 228 | |
| 229 | LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d fn=%d\n", |
| 230 | data_cnf->sapi, data_cnf->fn); |
| 231 | |
| 232 | switch (data_cnf->sapi) { |
| 233 | case PCU_IF_SAPI_PCH: |
Andreas Eversberg | 8c3680d | 2012-10-08 12:30:56 +0200 | [diff] [blame] | 234 | if (data_cnf->data[2] == 0x3f) |
| 235 | rc = gprs_rlcmac_imm_ass_cnf(data_cnf->data, |
| 236 | data_cnf->fn); |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 237 | break; |
| 238 | default: |
| 239 | LOGP(DL1IF, LOGL_ERROR, "Received PCU data confirm with " |
| 240 | "unsupported sapi %d\n", data_cnf->sapi); |
| 241 | rc = -EINVAL; |
| 242 | } |
| 243 | |
| 244 | return rc; |
| 245 | } |
| 246 | |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 247 | // FIXME: remove this, when changed from c++ to c. |
| 248 | extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 249 | uint32_t fn, uint8_t block_nr) |
| 250 | { |
| 251 | return gprs_rlcmac_rcv_rts_block(trx, ts, arfcn, fn, block_nr); |
| 252 | } |
| 253 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 254 | static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req) |
Ivan Kluchnikov | 5310d45 | 2012-04-17 22:00:31 +0400 | [diff] [blame] | 255 | { |
| 256 | int rc = 0; |
Ivan Kluchnikov | 5310d45 | 2012-04-17 22:00:31 +0400 | [diff] [blame] | 257 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 258 | LOGP(DL1IF, LOGL_DEBUG, "RTS request received: trx=%d ts=%d sapi=%d " |
| 259 | "arfcn=%d fn=%d block=%d\n", rts_req->trx_nr, rts_req->ts_nr, |
| 260 | rts_req->sapi, rts_req->arfcn, rts_req->fn, rts_req->block_nr); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 261 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 262 | switch (rts_req->sapi) { |
| 263 | case PCU_IF_SAPI_PDTCH: |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 264 | pcu_rx_rts_req_pdtch(rts_req->trx_nr, rts_req->ts_nr, |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 265 | rts_req->arfcn, rts_req->fn, rts_req->block_nr); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 266 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 267 | case PCU_IF_SAPI_PTCCH: |
| 268 | /* FIXME */ |
| 269 | { |
| 270 | struct msgb *msg = msgb_alloc(23, "l1_prim"); |
| 271 | memset(msgb_put(msg, 23), 0x2b, 23); |
| 272 | pcu_l1if_tx_ptcch(msg, rts_req->trx_nr, rts_req->ts_nr, |
| 273 | rts_req->arfcn, rts_req->fn, rts_req->block_nr); |
| 274 | } |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 275 | break; |
| 276 | default: |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 277 | LOGP(DL1IF, LOGL_ERROR, "Received PCU RTS request with " |
| 278 | "unsupported sapi %d\n", rts_req->sapi); |
| 279 | rc = -EINVAL; |
| 280 | } |
| 281 | |
| 282 | return rc; |
| 283 | } |
| 284 | |
| 285 | static int pcu_rx_rach_ind(struct gsm_pcu_if_rach_ind *rach_ind) |
| 286 | { |
| 287 | int rc = 0; |
| 288 | |
| 289 | LOGP(DL1IF, LOGL_INFO, "RACH request received: sapi=%d " |
| 290 | "qta=%d, ra=%d, fn=%d\n", rach_ind->sapi, rach_ind->qta, |
| 291 | rach_ind->ra, rach_ind->fn); |
| 292 | |
| 293 | switch (rach_ind->sapi) { |
| 294 | case PCU_IF_SAPI_RACH: |
| 295 | rc = gprs_rlcmac_rcv_rach(rach_ind->ra, rach_ind->fn, |
| 296 | rach_ind->qta); |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 297 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 298 | default: |
| 299 | LOGP(DL1IF, LOGL_ERROR, "Received PCU rach request with " |
| 300 | "unsupported sapi %d\n", rach_ind->sapi); |
| 301 | rc = -EINVAL; |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 302 | } |
| 303 | |
Ivan Kluchnikov | e3a0596 | 2012-03-18 15:48:51 +0400 | [diff] [blame] | 304 | return rc; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 305 | } |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 306 | |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 307 | int flush_pdch(struct gprs_rlcmac_pdch *pdch, uint8_t trx, uint8_t ts) |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 308 | { |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 309 | struct gprs_rlcmac_paging *pag; |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 310 | struct gprs_rlcmac_sba *sba, *sba2; |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 311 | |
| 312 | /* kick all TBF on slot */ |
Holger Hans Peter Freyther | 4f6a4e5d | 2013-10-16 17:58:46 +0200 | [diff] [blame] | 313 | gprs_rlcmac_tbf::free_all(pdch); |
| 314 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 315 | /* flush all pending paging messages */ |
| 316 | while ((pag = gprs_rlcmac_dequeue_paging(pdch))) |
| 317 | talloc_free(pag); |
| 318 | |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 319 | llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) { |
| 320 | if (sba->trx == trx && sba->ts == ts) { |
| 321 | llist_del(&sba->list); |
| 322 | talloc_free(sba); |
| 323 | } |
| 324 | } |
| 325 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 329 | static int pcu_rx_info_ind(struct gsm_pcu_if_info_ind *info_ind) |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 330 | { |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 331 | struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 332 | struct gprs_bssgp_pcu *pcu; |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 333 | struct gprs_rlcmac_pdch *pdch; |
Andreas Eversberg | 81a12be | 2013-03-16 16:16:41 +0100 | [diff] [blame] | 334 | struct in_addr ia; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 335 | int rc = 0; |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 336 | int trx, ts; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 337 | int i; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 338 | |
Andreas Eversberg | 8389fd0 | 2012-07-18 10:06:48 +0200 | [diff] [blame] | 339 | if (info_ind->version != PCU_IF_VERSION) { |
| 340 | fprintf(stderr, "PCU interface version number of BTS (%d) is " |
| 341 | "different (%d).\nPlease re-compile!\n", |
| 342 | info_ind->version, PCU_IF_VERSION); |
| 343 | exit(-1); |
| 344 | } |
| 345 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 346 | LOGP(DL1IF, LOGL_DEBUG, "Info indication received:\n"); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 347 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 348 | if (!(info_ind->flags & PCU_IF_FLAG_ACTIVE)) { |
| 349 | LOGP(DL1IF, LOGL_NOTICE, "BTS not available\n"); |
| 350 | bssgp_failed: |
| 351 | /* free all TBF */ |
| 352 | for (trx = 0; trx < 8; trx++) { |
| 353 | bts->trx[trx].arfcn = info_ind->trx[trx].arfcn; |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 354 | for (ts = 0; ts < 8; ts++) { |
| 355 | if (bts->trx[trx].pdch[ts].enable) |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 356 | flush_pdch(&bts->trx[trx].pdch[ts], |
| 357 | trx, ts); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 358 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 359 | } |
Holger Hans Peter Freyther | a30f476 | 2013-07-11 16:13:38 +0200 | [diff] [blame] | 360 | gprs_bssgp_destroy_or_exit(); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 361 | return 0; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 362 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 363 | LOGP(DL1IF, LOGL_INFO, "BTS available\n"); |
Andreas Eversberg | 514491d | 2012-09-23 06:42:07 +0200 | [diff] [blame] | 364 | LOGP(DL1IF, LOGL_DEBUG, " mcc=%x\n", info_ind->mcc); |
| 365 | LOGP(DL1IF, LOGL_DEBUG, " mnc=%x\n", info_ind->mnc); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 366 | LOGP(DL1IF, LOGL_DEBUG, " lac=%d\n", info_ind->lac); |
| 367 | LOGP(DL1IF, LOGL_DEBUG, " rac=%d\n", info_ind->rac); |
Andreas Eversberg | 514491d | 2012-09-23 06:42:07 +0200 | [diff] [blame] | 368 | LOGP(DL1IF, LOGL_DEBUG, " cell_id=%d\n", ntohs(info_ind->cell_id)); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 369 | LOGP(DL1IF, LOGL_DEBUG, " bsic=%d\n", info_ind->bsic); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 370 | LOGP(DL1IF, LOGL_DEBUG, " nsei=%d\n", info_ind->nsei); |
| 371 | LOGP(DL1IF, LOGL_DEBUG, " nse_timer=%d %d %d %d %d %d %d\n", |
| 372 | info_ind->nse_timer[0], info_ind->nse_timer[1], |
| 373 | info_ind->nse_timer[2], info_ind->nse_timer[3], |
| 374 | info_ind->nse_timer[4], info_ind->nse_timer[5], |
| 375 | info_ind->nse_timer[6]); |
| 376 | LOGP(DL1IF, LOGL_DEBUG, " cell_timer=%d %d %d %d %d %d %d %d %d %d " |
| 377 | "%d\n", |
| 378 | info_ind->cell_timer[0], info_ind->cell_timer[1], |
| 379 | info_ind->cell_timer[2], info_ind->cell_timer[3], |
| 380 | info_ind->cell_timer[4], info_ind->cell_timer[5], |
| 381 | info_ind->cell_timer[6], info_ind->cell_timer[7], |
| 382 | info_ind->cell_timer[8], info_ind->cell_timer[9], |
| 383 | info_ind->cell_timer[10]); |
| 384 | LOGP(DL1IF, LOGL_DEBUG, " repeat_time=%d\n", info_ind->repeat_time); |
| 385 | LOGP(DL1IF, LOGL_DEBUG, " repeat_count=%d\n", info_ind->repeat_count); |
| 386 | LOGP(DL1IF, LOGL_DEBUG, " bvci=%d\n", info_ind->bvci); |
| 387 | LOGP(DL1IF, LOGL_DEBUG, " t3142=%d\n", info_ind->t3142); |
| 388 | LOGP(DL1IF, LOGL_DEBUG, " t3169=%d\n", info_ind->t3169); |
| 389 | LOGP(DL1IF, LOGL_DEBUG, " t3191=%d\n", info_ind->t3191); |
| 390 | LOGP(DL1IF, LOGL_DEBUG, " t3193=%d (ms)\n", info_ind->t3193_10ms * 10); |
| 391 | LOGP(DL1IF, LOGL_DEBUG, " t3195=%d\n", info_ind->t3195); |
| 392 | LOGP(DL1IF, LOGL_DEBUG, " n3101=%d\n", info_ind->n3101); |
| 393 | LOGP(DL1IF, LOGL_DEBUG, " n3103=%d\n", info_ind->n3103); |
| 394 | LOGP(DL1IF, LOGL_DEBUG, " n3105=%d\n", info_ind->n3105); |
| 395 | LOGP(DL1IF, LOGL_DEBUG, " cv_countdown=%d\n", info_ind->cv_countdown); |
| 396 | LOGP(DL1IF, LOGL_DEBUG, " dl_tbf_ext=%d\n", info_ind->dl_tbf_ext); |
| 397 | LOGP(DL1IF, LOGL_DEBUG, " ul_tbf_ext=%d\n", info_ind->ul_tbf_ext); |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 398 | bts->bsic = info_ind->bsic; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 399 | for (i = 0; i < 4; i++) { |
| 400 | if ((info_ind->flags & (PCU_IF_FLAG_CS1 << i))) |
| 401 | LOGP(DL1IF, LOGL_DEBUG, " Use CS%d\n", i+1); |
| 402 | } |
| 403 | for (i = 0; i < 9; i++) { |
| 404 | if ((info_ind->flags & (PCU_IF_FLAG_MCS1 << i))) |
| 405 | LOGP(DL1IF, LOGL_DEBUG, " Use MCS%d\n", i+1); |
| 406 | } |
| 407 | LOGP(DL1IF, LOGL_DEBUG, " initial_cs=%d\n", info_ind->initial_cs); |
| 408 | LOGP(DL1IF, LOGL_DEBUG, " initial_mcs=%d\n", info_ind->initial_mcs); |
| 409 | LOGP(DL1IF, LOGL_DEBUG, " nsvci=%d\n", info_ind->nsvci[0]); |
| 410 | LOGP(DL1IF, LOGL_DEBUG, " local_port=%d\n", info_ind->local_port[0]); |
| 411 | LOGP(DL1IF, LOGL_DEBUG, " remote_port=%d\n", info_ind->remote_port[0]); |
Andreas Eversberg | 81a12be | 2013-03-16 16:16:41 +0100 | [diff] [blame] | 412 | ia.s_addr = htonl(info_ind->remote_ip[0]); |
| 413 | LOGP(DL1IF, LOGL_DEBUG, " remote_ip=%s\n", inet_ntoa(ia)); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 414 | |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 415 | pcu = gprs_bssgp_create_and_connect(bts, info_ind->local_port[0], |
Harald Welte | 30a73d8 | 2013-03-10 08:54:30 +0000 | [diff] [blame] | 416 | info_ind->remote_ip[0], info_ind->remote_port[0], |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 417 | info_ind->nsei, info_ind->nsvci[0], info_ind->bvci, |
| 418 | info_ind->mcc, info_ind->mnc, info_ind->lac, info_ind->rac, |
| 419 | info_ind->cell_id); |
Holger Hans Peter Freyther | e8d9a5f | 2013-07-28 19:11:20 +0200 | [diff] [blame] | 420 | if (!pcu) { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 421 | LOGP(DL1IF, LOGL_NOTICE, "SGSN not available\n"); |
| 422 | goto bssgp_failed; |
| 423 | } |
| 424 | |
| 425 | bts->cs1 = !!(info_ind->flags & PCU_IF_FLAG_CS1); |
| 426 | bts->cs2 = !!(info_ind->flags & PCU_IF_FLAG_CS2); |
| 427 | bts->cs3 = !!(info_ind->flags & PCU_IF_FLAG_CS3); |
| 428 | bts->cs4 = !!(info_ind->flags & PCU_IF_FLAG_CS4); |
| 429 | if (!bts->cs1 && !bts->cs2 && !bts->cs3 && !bts->cs4) |
| 430 | bts->cs1 = 1; |
| 431 | if (info_ind->t3142) { /* if timer values are set */ |
| 432 | bts->t3142 = info_ind->t3142; |
| 433 | bts->t3169 = info_ind->t3169; |
| 434 | bts->t3191 = info_ind->t3191; |
| 435 | bts->t3193_msec = info_ind->t3193_10ms * 10; |
| 436 | bts->t3195 = info_ind->t3195; |
| 437 | bts->n3101 = info_ind->n3101; |
| 438 | bts->n3103 = info_ind->n3103; |
| 439 | bts->n3105 = info_ind->n3105; |
| 440 | } |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 441 | if (!bts->force_cs) { |
| 442 | if (info_ind->initial_cs < 1 || info_ind->initial_cs > 4) |
Andreas Eversberg | 499ff41 | 2012-10-03 14:21:36 +0200 | [diff] [blame] | 443 | bts->initial_cs_dl = 1; |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 444 | else |
Andreas Eversberg | 499ff41 | 2012-10-03 14:21:36 +0200 | [diff] [blame] | 445 | bts->initial_cs_dl = info_ind->initial_cs; |
| 446 | bts->initial_cs_ul = bts->initial_cs_dl; |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 447 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 448 | |
| 449 | for (trx = 0; trx < 8; trx++) { |
| 450 | bts->trx[trx].arfcn = info_ind->trx[trx].arfcn; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 451 | if ((info_ind->flags & PCU_IF_FLAG_SYSMO) |
| 452 | && info_ind->trx[trx].hlayer1) { |
| 453 | #ifdef ENABLE_SYSMODSP |
| 454 | LOGP(DL1IF, LOGL_DEBUG, " TRX %d hlayer1=%x\n", trx, |
| 455 | info_ind->trx[trx].hlayer1); |
| 456 | if (!bts->trx[trx].fl1h) |
| 457 | bts->trx[trx].fl1h = l1if_open_pdch( |
| 458 | (void *)trx, |
| 459 | info_ind->trx[trx].hlayer1); |
| 460 | if (!bts->trx[trx].fl1h) { |
| 461 | LOGP(DL1IF, LOGL_FATAL, "Failed to open direct " |
| 462 | "DSP access for PDCH.\n"); |
| 463 | exit(0); |
| 464 | } |
| 465 | #else |
| 466 | LOGP(DL1IF, LOGL_FATAL, "Compiled without direct DSP " |
| 467 | "access for PDCH, but enabled at " |
| 468 | "BTS. Please deactivate it!\n"); |
| 469 | exit(0); |
| 470 | #endif |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 471 | } |
| 472 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 473 | for (ts = 0; ts < 8; ts++) { |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 474 | pdch = &bts->trx[trx].pdch[ts]; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 475 | if ((info_ind->trx[trx].pdch_mask & (1 << ts))) { |
| 476 | /* FIXME: activate dynamically at RLCMAC */ |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 477 | if (!pdch->enable) { |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 478 | #ifdef ENABLE_SYSMODSP |
| 479 | if ((info_ind->flags & |
| 480 | PCU_IF_FLAG_SYSMO)) |
| 481 | l1if_connect_pdch( |
| 482 | bts->trx[trx].fl1h, ts); |
| 483 | #endif |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 484 | pcu_tx_act_req(trx, ts, 1); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 485 | INIT_LLIST_HEAD(&pdch->paging_list); |
| 486 | pdch->enable = 1; |
| 487 | } |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 488 | pdch->tsc = info_ind->trx[trx].tsc[ts]; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 489 | LOGP(DL1IF, LOGL_INFO, "PDCH: trx=%d ts=%d\n", |
| 490 | trx, ts); |
| 491 | } else { |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 492 | if (pdch->enable) { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 493 | pcu_tx_act_req(trx, ts, 0); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 494 | pdch->enable = 0; |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 495 | flush_pdch(pdch, trx, ts); |
Andreas Eversberg | 3b7461c | 2012-07-20 11:19:59 +0200 | [diff] [blame] | 496 | } |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 501 | return rc; |
| 502 | } |
| 503 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 504 | static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind) |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 505 | { |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 506 | struct gprs_rlcmac_tbf *tbf; |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 507 | struct gprs_rlcmac_sba *sba, *sba2; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 508 | uint32_t elapsed; |
| 509 | uint8_t fn13 = time_ind->fn % 13; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 510 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 511 | /* omit frame numbers not starting at a MAC block */ |
| 512 | if (fn13 != 0 && fn13 != 4 && fn13 != 8) |
| 513 | return 0; |
Andreas Eversberg | a23c7ee | 2012-12-18 10:47:28 +0100 | [diff] [blame] | 514 | #warning uncomment |
| 515 | // LOGP(DL1IF, LOGL_DEBUG, "Time indication received: %d\n", |
| 516 | // time_ind->fn % 52); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 517 | |
| 518 | set_current_fn(time_ind->fn); |
| 519 | |
| 520 | /* check for poll timeout */ |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 521 | llist_for_each_entry(tbf, &gprs_rlcmac_ul_tbfs, list) { |
| 522 | if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) { |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 523 | elapsed = (frame_number + 2715648 - tbf->poll_fn) |
| 524 | % 2715648; |
| 525 | if (elapsed >= 20 && elapsed < 2715400) |
Holger Hans Peter Freyther | 344ff48 | 2013-10-17 12:01:04 +0200 | [diff] [blame] | 526 | gprs_rlcmac_poll_timeout(gprs_rlcmac_bts, tbf); |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | llist_for_each_entry(tbf, &gprs_rlcmac_dl_tbfs, list) { |
| 530 | if (tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) { |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 531 | elapsed = (frame_number + 2715648 - tbf->poll_fn) |
| 532 | % 2715648; |
| 533 | if (elapsed >= 20 && elapsed < 2715400) |
Holger Hans Peter Freyther | 344ff48 | 2013-10-17 12:01:04 +0200 | [diff] [blame] | 534 | gprs_rlcmac_poll_timeout(gprs_rlcmac_bts, tbf); |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 535 | } |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 536 | } |
Andreas Eversberg | a004e6a | 2013-05-13 16:45:21 +0200 | [diff] [blame] | 537 | llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) { |
| 538 | elapsed = (frame_number + 2715648 - sba->fn) % 2715648; |
| 539 | if (elapsed >= 20 && elapsed < 2715400) { |
| 540 | /* sba will be freed here */ |
| 541 | gprs_rlcmac_sba_timeout(sba); |
| 542 | } |
| 543 | } |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 544 | |
| 545 | return 0; |
| 546 | } |
| 547 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 548 | static int pcu_rx_pag_req(struct gsm_pcu_if_pag_req *pag_req) |
| 549 | { |
| 550 | LOGP(DL1IF, LOGL_DEBUG, "Paging request received: chan_needed=%d " |
| 551 | "length=%d\n", pag_req->chan_needed, pag_req->identity_lv[0]); |
| 552 | |
| 553 | return gprs_rlcmac_add_paging(pag_req->chan_needed, |
| 554 | pag_req->identity_lv); |
| 555 | } |
| 556 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 557 | 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] | 558 | { |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 559 | int rc = 0; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 560 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 561 | switch (msg_type) { |
| 562 | case PCU_IF_MSG_DATA_IND: |
| 563 | rc = pcu_rx_data_ind(&pcu_prim->u.data_ind); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 564 | break; |
Andreas Eversberg | a9be154 | 2012-09-27 09:23:24 +0200 | [diff] [blame] | 565 | case PCU_IF_MSG_DATA_CNF: |
| 566 | rc = pcu_rx_data_cnf(&pcu_prim->u.data_cnf); |
| 567 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 568 | case PCU_IF_MSG_RTS_REQ: |
| 569 | rc = pcu_rx_rts_req(&pcu_prim->u.rts_req); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 570 | break; |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 571 | case PCU_IF_MSG_RACH_IND: |
| 572 | rc = pcu_rx_rach_ind(&pcu_prim->u.rach_ind); |
| 573 | break; |
| 574 | case PCU_IF_MSG_INFO_IND: |
| 575 | rc = pcu_rx_info_ind(&pcu_prim->u.info_ind); |
| 576 | break; |
| 577 | case PCU_IF_MSG_TIME_IND: |
| 578 | rc = pcu_rx_time_ind(&pcu_prim->u.time_ind); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 579 | break; |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 580 | case PCU_IF_MSG_PAG_REQ: |
| 581 | rc = pcu_rx_pag_req(&pcu_prim->u.pag_req); |
| 582 | break; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 583 | default: |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 584 | LOGP(DL1IF, LOGL_ERROR, "Received unknwon PCU msg type %d\n", |
| 585 | msg_type); |
| 586 | rc = -EINVAL; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 587 | } |
| 588 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 589 | return rc; |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 590 | } |