blob: 4ed57e572ccf33c085ed0923a412e870588d2bb7 [file] [log] [blame]
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +02001module PCUIF_RAW_Components {
2
3/*
4 * Components for (RAW) PCU test cases.
5 *
6 * (C) 2019 Vadim Yanitskiy <axilirator@gmail.com>
7 *
8 * All rights reserved.
9 *
10 * Released under the terms of GNU General Public License, Version 2 or
11 * (at your option) any later version.
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 */
15
16import from IPL4asp_Types all;
17import from UD_Types all;
18
19import from PCUIF_Types all;
20import from PCUIF_CodecPort all;
21
22/* Component communication diagram:
23 *
24 * +-----+ +----------+ +---------+
25 * | MTC +---------------+ PCUIF_CT +------+ OsmoPCU |
26 * +--+--+ +----+-----+ +---------+
27 * | |
28 * | |
29 * | |
30 * | +-----------+ | +---------------+
31 * +----+ BTS_CT #1 +------+ | ClckGen_CT #1 |
32 * | +-----+-----+ | +-------+-------+
33 * | | | |
34 * | +---------------------------+
35 * | |
36 * | +-----------+ | +---------------+
37 * +----+ BTS_CT #2 +------+ | ClckGen_CT #2 |
38 * | +-----+-----+ | +-------+-------+
39 * | | | |
40 * | +---------------------------+
41 * | |
42 * | +-----------+ | +---------------+
43 * +----+ BTS_CT #N +------+ | ClckGen_CT #N |
44 * +-----+-----+ +-------+-------+
45 * | |
46 * +---------------------------+
47 */
48
49/* Events are used by the components to indicate that something
50 * has happened, e.g. we have got a connection from the PCU. */
51type enumerated RAW_PCU_EventType {
52 /* Events related to RAW_PCUIF_CT */
53 PCU_EV_DISCONNECT, /*!< OsmoPCU has disconnected */
54 PCU_EV_CONNECT, /*!< OsmoPCU is now connected */
55
56 /* Events related to RAW_PCU_BTS_CT */
57 BTS_EV_SI13_NEGO, /*!< SI13 negotiation complete */
58
59 /* TDMA clock related events (TDMA frame-number in parameters) */
60 TDMA_EV_PDTCH_BLOCK_BEG, /*!< 1/4 bursts of a PDTCH block on both Uplink and Downlink */
61 TDMA_EV_PDTCH_BLOCK_END, /*!< 4/4 bursts of a PDTCH block on both Uplink and Downlink */
62 TDMA_EV_PTCCH_DL_BLOCK, /*!< 4/4 bursts of a PTCCH block on Downlink */
63 TDMA_EV_PTCCH_UL_BURST, /*!< One Access Burst on PTCCH/U */
64
65 TDMA_EV_PDTCH_BLOCK_SENT /*!< A PDTCH block has been sent to the PCU */
66};
67
68/* Union of all possible parameters of the events */
69type union RAW_PCU_EventParam {
70 integer tdma_fn
71};
72
73type record RAW_PCU_Event {
74 RAW_PCU_EventType event,
75 /* TODO: can we use 'anytype' here? */
76 RAW_PCU_EventParam data optional
77};
78
79template (value) RAW_PCU_Event ts_RAW_PCU_EV(RAW_PCU_EventType event) := {
80 event := event,
81 data := omit
82}
83template RAW_PCU_Event tr_RAW_PCU_EV(template RAW_PCU_EventType event := ?,
84 template RAW_PCU_EventParam data := *) := {
85 event := event,
86 data := data
87}
88
89template (value) RAW_PCU_Event ts_RAW_PCU_CLCK_EV(RAW_PCU_EventType event, integer fn) := {
90 event := event,
91 data := { tdma_fn := fn }
92}
93template RAW_PCU_Event tr_RAW_PCU_CLCK_EV := {
94 event := (TDMA_EV_PDTCH_BLOCK_BEG, TDMA_EV_PDTCH_BLOCK_END,
95 TDMA_EV_PTCCH_DL_BLOCK, TDMA_EV_PTCCH_UL_BURST,
96 TDMA_EV_PDTCH_BLOCK_SENT),
97 data := { tdma_fn := ? }
98}
99
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700100/* Commands are mostly used by the MTC to configure the components
101 * at run-time, e.g. to enable or disable some optional features. */
102type enumerated RAW_PCU_CommandType {
103 TDMA_CMD_ENABLE_PTCCH_UL_FWD /*!< Enable forwarding of TDMA_EV_PTCCH_UL_BURST to the MTC */
104};
105
106type record RAW_PCU_Command {
107 RAW_PCU_CommandType cmd,
108 anytype data optional
109};
110
111template (value) RAW_PCU_Command ts_RAW_PCU_CMD(RAW_PCU_CommandType cmd) := {
112 cmd := cmd,
113 data := omit
114}
115template RAW_PCU_Command tr_RAW_PCU_CMD(template RAW_PCU_CommandType cmd := ?,
116 template anytype data := *) := {
117 cmd := cmd,
118 data := data
119}
120
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200121/* Generic port for messages and events */
122type port RAW_PCU_MSG_PT message {
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700123 inout RAW_PCU_Command;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200124 inout RAW_PCU_Event;
125 inout PCUIF_Message;
126} with { extension "internal" };
127
128/* TDMA frame clock generator */
129type component RAW_PCU_ClckGen_CT {
130 /* One TDMA frame is 4.615 ms long */
131 timer T_TDMAClock := 4.615 / 1000.0;
132 port RAW_PCU_MSG_PT CLCK;
133 var integer fn := 0;
134}
135
Vadim Yanitskiy20f87002019-10-06 00:51:50 +0700136/* Derive PTCCH/U sub-slot from a given TDMA frame-number */
137function f_tdma_ptcch_fn2ss(integer fn) return integer
138{
139 var integer ss := -1;
140
141 /* See 3GPP TS 45.002, table 6 */
142 select (fn mod 416) {
143 case (12) { ss := 0; }
144 case (38) { ss := 1; }
145 case (64) { ss := 2; }
146 case (90) { ss := 3; }
147
148 case (116) { ss := 4; }
149 case (142) { ss := 5; }
150 case (168) { ss := 6; }
151 case (194) { ss := 7; }
152
153 case (220) { ss := 8; }
154 case (246) { ss := 9; }
155 case (272) { ss := 10; }
156 case (298) { ss := 11; }
157
158 case (324) { ss := 12; }
159 case (350) { ss := 13; }
160 case (376) { ss := 14; }
161 case (402) { ss := 15; }
162 }
163
164 return ss;
165}
166
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200167function f_ClckGen_CT_handler()
168runs on RAW_PCU_ClckGen_CT {
169 var integer fn104, fn52, fn13;
170
171 while (true) {
172 fn104 := fn mod 104;
173 fn52 := fn mod 52;
174 fn13 := fn mod 13;
175
176 if (fn13 == 0 or fn13 == 4 or fn13 == 8) {
177 /* 1/4 bursts of a PDTCH block on both Uplink and Downlink */
178 CLCK.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PDTCH_BLOCK_BEG, fn));
179 } else if (fn13 == 3 or fn13 == 7 or fn13 == 11) {
180 /* 4/4 bursts of a PDTCH block on both Uplink and Downlink */
181 CLCK.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PDTCH_BLOCK_END, fn));
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200182 } else if (fn52 == 12 or fn52 == 38) {
Vadim Yanitskiyb58b7302019-10-06 01:01:48 +0700183 /* 4/4 bursts of a PTCCH (Timing Advance Control) block on Downlink */
184 if (fn104 == 90) {
185 CLCK.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PTCCH_DL_BLOCK, fn));
186 }
187 /* One Access Burst on PTCCH/U (goes 3 time-slots after PTCCH/D) */
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200188 CLCK.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PTCCH_UL_BURST, fn));
189 }
190
191 /* TDMA hyperframe period is (2048 * 51 * 26) frames */
192 fn := (fn + 1) mod (2048 * 51 * 26);
193
194 /* (Re)start TDMA clock timer and wait */
195 T_TDMAClock.start;
196 T_TDMAClock.timeout;
197 }
198}
199
200type record of PCUIF_Message PCUIF_MsgQueue;
201
202/* Enqueue a given message to the end of a given queue */
203private function f_PCUIF_MsgQueue_enqueue(inout PCUIF_MsgQueue queue,
204 in PCUIF_Message msg)
205{
206 queue := queue & { msg };
207}
208
209/* Dequeue the first message of a given queue */
210private function f_PCUIF_MsgQueue_dequeue(inout PCUIF_MsgQueue queue,
211 out PCUIF_Message msg)
212{
213 var integer len := lengthof(queue);
214
215 if (len == 0) {
216 setverdict(fail, "Failed to dequeue a message: the queue is empty!");
217 mtc.stop;
218 }
219
220 /* Store the first message */
221 msg := queue[0];
222
223 /* Remove the first message from queue */
224 if (len > 1) {
225 queue := substr(queue, 1, len - 1);
226 } else {
227 queue := { };
228 }
229}
230
Pau Espin Pedrol65bab9e2019-12-04 21:05:10 +0100231/* Get first message from queue. true if non-empty, false otherwise */
232private function f_PCUIF_MsgQueue_first(inout PCUIF_MsgQueue queue,
233 out PCUIF_Message msg) return boolean
234{
235 if (lengthof(queue) == 0) {
236 return false;
237 }
238
239 msg := queue[0];
240 return true;
241}
242
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200243/* Multiple base stations can be connected to the PCU. This component
244 * represents one BTS with an associated TDMA clock generator. */
245type component RAW_PCU_BTS_CT {
246 /* TDMA clock generator */
247 var RAW_PCU_ClckGen_CT vc_CLCK_GEN;
248 port RAW_PCU_MSG_PT CLCK;
249
250 /* Queues of PCUIF messages to be sent
251 * TODO: we may have multiple PDCH time-slots */
252 var PCUIF_MsgQueue pdtch_data_queue := { };
253 var PCUIF_MsgQueue pdtch_rts_queue := { };
254 var PCUIF_MsgQueue ptcch_rts_queue := { };
255
256 /* Connection towards the PCU interface */
257 port RAW_PCU_MSG_PT PCUIF;
258 /* Connection towards the test case */
259 port RAW_PCU_MSG_PT TC;
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700260
261 /* Whether to forward PTCCH/U burst events to the TC */
262 var boolean cfg_ptcch_burst_fwd := false;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200263}
264
Pau Espin Pedrol65bab9e2019-12-04 21:05:10 +0100265/* Queue received messages from Test Case, they will eventually be scheduled and
266 * sent according to their FN. FN value of 0 has the special meaning of "schedule
267 * as soon as possible". */
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200268private altstep as_BTS_CT_MsgQueue(integer bts_nr)
269runs on RAW_PCU_BTS_CT {
270 var PCUIF_Message pcu_msg;
271
272 /* Enqueue DATA.ind and RTS.req messages */
273 [] TC.receive(tr_PCUIF_MSG(PCU_IF_MSG_DATA_IND, bts_nr)) -> value pcu_msg {
274 f_PCUIF_MsgQueue_enqueue(pdtch_data_queue, pcu_msg);
275 repeat;
276 }
277 [] TC.receive(tr_PCUIF_RTS_REQ(bts_nr, sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg {
278 f_PCUIF_MsgQueue_enqueue(pdtch_rts_queue, pcu_msg);
279 repeat;
280 }
281 [] TC.receive(tr_PCUIF_RTS_REQ(bts_nr, sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
282 f_PCUIF_MsgQueue_enqueue(ptcch_rts_queue, pcu_msg);
283 repeat;
284 }
285 /* Forward other messages directly to the PCU */
286 [] TC.receive(tr_PCUIF_MSG(?, bts_nr)) -> value pcu_msg {
287 PCUIF.send(pcu_msg);
288 repeat;
289 }
290}
291
Pau Espin Pedrol65bab9e2019-12-04 21:05:10 +0100292/* Handle schedule events and manage actions: Send msgs over PCUIF to PCU,
293 * advertise Test Case about sent messages, etc. */
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200294private altstep as_BTS_CT_TDMASched(integer bts_nr)
295runs on RAW_PCU_BTS_CT {
296 var PCUIF_Message pcu_msg;
297 var RAW_PCU_Event event;
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100298 var integer ev_begin_fn;
Pau Espin Pedrol65bab9e2019-12-04 21:05:10 +0100299 var integer next_fn;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200300
301 [] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_BEG)) -> value event {
302 /* If the RTS queue for PDTCH is not empty, send a message */
303 if (lengthof(pdtch_rts_queue) > 0) {
304 f_PCUIF_MsgQueue_dequeue(pdtch_rts_queue, pcu_msg);
305
306 /* Patch TDMA frame / block number and send */
307 pcu_msg.u.rts_req.fn := event.data.tdma_fn;
308 pcu_msg.u.rts_req.block_nr := 0; /* FIXME! */
309 PCUIF.send(pcu_msg);
310 }
311
312 /* We don't really need to send every frame to OsmoPCU, because
313 * it omits frame numbers not starting at a MAC block. */
314 PCUIF.send(ts_PCUIF_TIME_IND(bts_nr, event.data.tdma_fn));
315 repeat;
316 }
317 [lengthof(pdtch_data_queue) > 0] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_END)) -> value event {
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100318 /* FN matching the beginning of current block: */
319 ev_begin_fn := event.data.tdma_fn - 3;
Pau Espin Pedrol65bab9e2019-12-04 21:05:10 +0100320
321 /* Check if we reached time to serve the first DATA.ind message in the queue: */
322 f_PCUIF_MsgQueue_first(pdtch_data_queue, pcu_msg);
323 next_fn := pcu_msg.u.data_ind.fn;
324 if (next_fn != 0 and next_fn != ev_begin_fn) {
325 if (next_fn < ev_begin_fn) {
326 setverdict(fail, "We are late scheduling the block! ", next_fn, " < ", ev_begin_fn);
327 mtc.stop;
328 }
329 repeat;
330 }
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200331 /* Dequeue a DATA.ind message */
332 f_PCUIF_MsgQueue_dequeue(pdtch_data_queue, pcu_msg);
333
334 /* Patch TDMA frame / block number */
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100335 pcu_msg.u.data_ind.fn := ev_begin_fn;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200336 pcu_msg.u.data_ind.block_nr := 0; /* FIXME! */
337
338 PCUIF.send(pcu_msg); /* Send to the PCU and notify the TC */
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100339 TC.send(ts_RAW_PCU_CLCK_EV(TDMA_EV_PDTCH_BLOCK_SENT, ev_begin_fn));
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200340 repeat;
341 }
342 [lengthof(ptcch_rts_queue) > 0] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_DL_BLOCK)) -> value event {
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100343 /* FN matching the beginning of current block (PTCCH is interleaved over 4 non-consecutive bursts): */
344 ev_begin_fn := event.data.tdma_fn - 78;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200345 /* Dequeue an RTS.req message for PTCCH */
346 f_PCUIF_MsgQueue_dequeue(ptcch_rts_queue, pcu_msg);
347
348 /* Patch TDMA frame / block number and send */
Pau Espin Pedrol60727252019-12-04 21:40:25 +0100349 pcu_msg.u.rts_req.fn := ev_begin_fn;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200350 pcu_msg.u.rts_req.block_nr := 0; /* FIXME! */
351 PCUIF.send(pcu_msg);
352 repeat;
353 }
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700354 /* Optional forwarding of PTCCH/U burst indications to the test case */
355 [cfg_ptcch_burst_fwd] CLCK.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
356 TC.send(event);
357 repeat;
358 }
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200359 /* Ignore other clock events (and guard against an empty queue) */
360 [] CLCK.receive(tr_RAW_PCU_CLCK_EV) { repeat; }
361}
362
363function f_BTS_CT_handler(integer bts_nr, PCUIF_info_ind info_ind)
364runs on RAW_PCU_BTS_CT {
365 var PCUIF_Message pcu_msg;
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700366 var RAW_PCU_Command cmd;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200367 var RAW_PCU_Event event;
368
369 /* Init TDMA clock generator (so we can stop and start it) */
370 vc_CLCK_GEN := RAW_PCU_ClckGen_CT.create("ClckGen-" & int2str(bts_nr)) alive;
371 connect(vc_CLCK_GEN:CLCK, self:CLCK);
372
373 /* Wait until the PCU is connected */
374 PCUIF.receive(tr_RAW_PCU_EV(PCU_EV_CONNECT));
375
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200376 alt {
377 /* Wait for TXT.ind (PCU_VERSION) and respond with INFO.ind (SI13) */
378 [] PCUIF.receive(tr_PCUIF_TXT_IND(bts_nr, PCU_VERSION, ?)) -> value pcu_msg {
379 log("Rx TXT.ind from the PCU, version is ", pcu_msg.u.txt_ind.text);
380
381 /* Send System Information 13 to the PCU */
382 PCUIF.send(PCUIF_Message:{
383 msg_type := PCU_IF_MSG_INFO_IND,
384 bts_nr := bts_nr,
385 spare := '0000'O,
386 u := { info_ind := info_ind }
387 });
388
389 /* Notify the test case that we're done with SI13 */
390 TC.send(ts_RAW_PCU_EV(BTS_EV_SI13_NEGO));
391
392 /* Start feeding clock to the PCU */
393 vc_CLCK_GEN.start(f_ClckGen_CT_handler());
394 repeat;
395 }
Pau Espin Pedrold16bb272019-12-02 12:57:03 +0100396 /* PCU -> TS becomes active */
397 [] PCUIF.receive(tr_PCUIF_ACT_REQ(bts_nr, ?, ?)) -> value pcu_msg {
398 log("Rx ACT.req from the PCU: TRX" & int2str(pcu_msg.u.act_req.trx_nr) &
399 "/TS" & int2str(pcu_msg.u.act_req.ts_nr));
400 repeat;
401 }
402 /* PCU -> TS becomes inactive */
403 [] PCUIF.receive(tr_PCUIF_DEACT_REQ(bts_nr, ?, ?)) -> value pcu_msg {
404 log("Rx DEACT.req from the PCU: TRX" & int2str(pcu_msg.u.act_req.trx_nr) &
405 "/TS" & int2str(pcu_msg.u.act_req.ts_nr));
406 repeat;
407 }
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200408 /* PCU -> test case forwarding (filter by the BTS number) */
409 [] PCUIF.receive(tr_PCUIF_MSG(?, bts_nr)) -> value pcu_msg {
410 TC.send(pcu_msg);
411 repeat;
412 }
413
414 /* TC -> [Queue] -> PCU forwarding */
415 [] as_BTS_CT_MsgQueue(bts_nr);
416 /* TDMA scheduler (clock and queue handling) */
417 [] as_BTS_CT_TDMASched(bts_nr);
418
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700419 /* Command handling */
420 [] TC.receive(tr_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)) {
421 log("Enabling forwarding of PTCCH/U TDMA events to the TC");
422 cfg_ptcch_burst_fwd := true;
423 repeat;
424 }
425 [] TC.receive(tr_RAW_PCU_CMD) -> value cmd {
426 log("Ignore unhandled command: ", cmd);
427 repeat;
428 }
429
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200430 /* TODO: handle events (e.g. disconnection) from the PCU interface */
431 [] PCUIF.receive(tr_RAW_PCU_EV) -> value event {
432 log("Ignore unhandled event: ", event);
433 repeat;
434 }
435 }
436}
437
438/* PCU interface (UNIX domain socket) handler */
439type component RAW_PCUIF_CT {
440 var ConnectionId g_pcu_conn_id := -1;
441 var boolean g_pcu_connected := false;
442 port PCUIF_CODEC_PT PCU;
443
444 /* Connection towards BTS component(s) */
445 port RAW_PCU_MSG_PT BTS;
446 /* Connection to the MTC (test case) */
447 port RAW_PCU_MSG_PT MTC;
448};
449
450/* All received messages and events from OsmoPCU can be additionally sent
451 * directly to the MTC component. Pass direct := true to enable this mode. */
452function f_PCUIF_CT_handler(charstring pcu_sock_path, boolean direct := false)
453runs on RAW_PCUIF_CT {
454 var PCUIF_send_data pcu_sd_msg;
455 var PCUIF_Message pcu_msg;
456 timer T_Conn := 10.0;
457
458 log("Init PCU interface on '" & pcu_sock_path & "', waiting for connection...");
459 g_pcu_conn_id := f_pcuif_listen(PCU, pcu_sock_path);
460
461 /* Wait for connection */
462 T_Conn.start;
463 alt {
464 [not g_pcu_connected] PCU.receive(UD_connected:?) {
465 log("OsmoPCU is now connected");
466 /* Duplicate this event to the MTC if requested */
467 if (direct) { MTC.send(ts_RAW_PCU_EV(PCU_EV_CONNECT)); }
468 BTS.send(ts_RAW_PCU_EV(PCU_EV_CONNECT));
469 g_pcu_connected := true;
470 setverdict(pass);
471 T_Conn.stop;
472 repeat;
473 }
474 /* PCU -> BTS / MTC message forwarding */
475 [g_pcu_connected] PCU.receive(PCUIF_send_data:?) -> value pcu_sd_msg {
476 /* Send to the BTSes if at least one is connected */
477 if (BTS.checkstate("Connected")) { BTS.send(pcu_sd_msg.data); }
478 /* Duplicate this message to the MTC if requested */
479 if (direct) { MTC.send(pcu_sd_msg.data); }
480 repeat;
481 }
482 /* MTC -> PCU message forwarding */
483 [g_pcu_connected] MTC.receive(PCUIF_Message:?) -> value pcu_msg {
484 PCU.send(t_SD_PCUIF(g_pcu_conn_id, pcu_msg));
485 repeat;
486 }
487 /* BTS -> PCU message forwarding */
488 [g_pcu_connected] BTS.receive(PCUIF_Message:?) -> value pcu_msg {
489 PCU.send(t_SD_PCUIF(g_pcu_conn_id, pcu_msg));
490 repeat;
491 }
492 [not g_pcu_connected] MTC.receive(PCUIF_Message:?) -> value pcu_msg {
493 log("PCU is not connected, dropping ", pcu_msg);
494 repeat;
495 }
496 [not g_pcu_connected] BTS.receive(PCUIF_Message:?) -> value pcu_msg {
497 log("PCU is not connected, dropping ", pcu_msg);
498 repeat;
499 }
500 /* TODO: handle disconnect and reconnect of the PCU */
501 [] PCU.receive {
502 log("Unhandled message on PCU interface");
503 repeat;
504 }
505 [not g_pcu_connected] T_Conn.timeout {
506 setverdict(fail, "Timeout waiting for PCU connection");
507 mtc.stop;
508 }
509 }
510}
511
512}