blob: abd5d22fdd460fb5718fa0f65fd858bb7c4f914b [file] [log] [blame]
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +02001/* AllocTest.cpp
2 *
3 * Copyright (C) 2013 by Holger Hans Peter Freyther
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
20#include "gprs_rlcmac.h"
21#include "gprs_debug.h"
22#include "tbf.h"
Pau Espin Pedrol9d1cdb12019-09-25 17:47:02 +020023#include "tbf_ul.h"
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020024#include "bts.h"
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +020025
26#include <string.h>
27#include <stdio.h>
28
29extern "C" {
Max9f460712018-01-23 20:57:08 +010030#include "mslot_class.h"
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +020031#include <osmocom/core/application.h>
32#include <osmocom/core/msgb.h>
33#include <osmocom/core/talloc.h>
34#include <osmocom/core/utils.h>
35}
36
37/* globals used by the code */
38void *tall_pcu_ctx;
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +020039int16_t spoof_mnc = 0, spoof_mcc = 0;
Neels Hofmeyrbdc55fa2018-02-21 00:39:07 +010040bool spoof_mnc_3_digits = false;
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +020041
Daniel Willmann48aa0b02014-07-16 18:54:10 +020042static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts,
Jacob Erlbecke2e004e2015-06-18 17:16:26 +020043 GprsMs *ms, gprs_rlcmac_tbf_direction dir,
Jacob Erlbeck5879c642015-07-10 10:41:36 +020044 uint8_t use_trx,
Maxe9fe0e32017-09-28 15:56:05 +020045 uint8_t ms_class, uint8_t egprs_ms_class, bool single_slot)
Daniel Willmann48aa0b02014-07-16 18:54:10 +020046{
Pau Espin Pedrol17402a52020-05-08 17:44:33 +020047 if (dir == GPRS_RLCMAC_UL_TBF && !ms)
48 ms = bts->bts->ms_alloc(ms_class, egprs_ms_class);
49
Daniel Willmann48aa0b02014-07-16 18:54:10 +020050 if (dir == GPRS_RLCMAC_UL_TBF)
Pau Espin Pedrol17402a52020-05-08 17:44:33 +020051 return tbf_alloc_ul_tbf(bts, ms, use_trx, single_slot);
Daniel Willmann48aa0b02014-07-16 18:54:10 +020052 else
Jacob Erlbeck86b6f052015-11-27 15:17:34 +010053 return tbf_alloc_dl_tbf(bts, ms, use_trx,
54 ms_class, egprs_ms_class, single_slot);
Daniel Willmann48aa0b02014-07-16 18:54:10 +020055}
56
Jacob Erlbeck61205a72015-07-09 11:35:50 +020057static void check_tfi_usage(BTS *the_bts)
58{
59 int pdch_no;
Jacob Erlbeck61205a72015-07-09 11:35:50 +020060
61 struct gprs_rlcmac_tbf *tfi_usage[8][8][2][32] = {{{{NULL}}}};
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010062 LListHead<gprs_rlcmac_tbf> *tbf_lists[2] = {
63 &the_bts->ul_tbfs(),
64 &the_bts->dl_tbfs()
Jacob Erlbeck61205a72015-07-09 11:35:50 +020065 };
66
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010067 LListHead<gprs_rlcmac_tbf> *pos;
Jacob Erlbeck61205a72015-07-09 11:35:50 +020068 gprs_rlcmac_tbf *tbf;
Jacob Erlbeck61205a72015-07-09 11:35:50 +020069 unsigned list_idx;
70 struct gprs_rlcmac_tbf **tbf_var;
71
72 for (list_idx = 0; list_idx < ARRAY_SIZE(tbf_lists); list_idx += 1)
73 {
74
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010075 llist_for_each(pos, tbf_lists[list_idx]) {
76 tbf = pos->entry();
Jacob Erlbeck61205a72015-07-09 11:35:50 +020077 for (pdch_no = 0; pdch_no < 8; pdch_no += 1) {
78 struct gprs_rlcmac_pdch *pdch = tbf->pdch[pdch_no];
79 if (pdch == NULL)
80 continue;
81
82 tbf_var = &tfi_usage
83 [tbf->trx->trx_no]
84 [pdch_no]
85 [tbf->direction]
86 [tbf->tfi()];
87
88 OSMO_ASSERT(*tbf_var == NULL);
89 if (tbf->direction == GPRS_RLCMAC_DL_TBF) {
90 OSMO_ASSERT(pdch->dl_tbf_by_tfi(
91 tbf->tfi()) == tbf);
Jacob Erlbeck61205a72015-07-09 11:35:50 +020092 OSMO_ASSERT(the_bts->dl_tbf_by_tfi(
93 tbf->tfi(),
Jacob Erlbeck3a10dbd2015-07-10 19:52:37 +020094 tbf->trx->trx_no,
95 pdch_no) == tbf);
Jacob Erlbeck61205a72015-07-09 11:35:50 +020096 } else {
97 OSMO_ASSERT(pdch->ul_tbf_by_tfi(
98 tbf->tfi()) == tbf);
Jacob Erlbeck61205a72015-07-09 11:35:50 +020099 OSMO_ASSERT(the_bts->ul_tbf_by_tfi(
100 tbf->tfi(),
Jacob Erlbeck3a10dbd2015-07-10 19:52:37 +0200101 tbf->trx->trx_no,
102 pdch_no) == tbf);
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200103 }
104 *tbf_var = tbf;
Jacob Erlbeck47a57f62015-07-08 12:53:16 +0200105 OSMO_ASSERT(pdch->assigned_tfi(tbf->direction) &
106 (1 << tbf->tfi()));
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200107 }
108 }
109 }
110}
111
Jacob Erlbeckfa464bb2015-06-29 12:45:11 +0200112static void test_alloc_a(gprs_rlcmac_tbf_direction dir,
113 uint8_t slots, const int count)
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200114{
115 int tfi;
Jacob Erlbeckfa464bb2015-06-29 12:45:11 +0200116 int i;
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200117 uint8_t used_trx, tmp_trx;
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +0200118 BTS the_bts;
119 struct gprs_rlcmac_bts *bts;
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200120 struct gprs_rlcmac_tbf *tbfs[32*8+1] = { 0, };
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200121
122 printf("Testing alloc_a direction(%d)\n", dir);
123
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +0200124 bts = the_bts.bts_data();
125 bts->alloc_algorithm = alloc_algorithm_a;
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200126
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +0200127 struct gprs_rlcmac_trx *trx = &bts->trx[0];
Jacob Erlbeckfa464bb2015-06-29 12:45:11 +0200128 for (i = 0; i < 8; i += 1)
129 if (slots & (1 << i))
130 trx->pdch[i].enable();
131
132 OSMO_ASSERT(count >= 0 && count <= (int)ARRAY_SIZE(tbfs));
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200133
134 /**
135 * Currently alloc_a will only allocate from the first
136 * PDCH and all possible usf's. We run out of usf's before
137 * we are out of tfi's. Observe this and make sure that at
138 * least this part is working okay.
139 */
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200140 for (i = 0; i < (int)ARRAY_SIZE(tbfs); ++i) {
Jacob Erlbeck86b6f052015-11-27 15:17:34 +0100141 tbfs[i] = tbf_alloc(bts, NULL, dir, -1, 0, 0, 0);
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200142 if (tbfs[i] == NULL)
143 break;
144
145 used_trx = tbfs[i]->trx->trx_no;
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200146 tfi = the_bts.tfi_find_free(dir, &tmp_trx, used_trx);
147 OSMO_ASSERT(tbfs[i]->tfi() != tfi);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200148 }
149
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200150 check_tfi_usage(&the_bts);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200151
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200152 OSMO_ASSERT(i == count);
153
154 for (i = 0; i < count; ++i)
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200155 if (tbfs[i])
156 tbf_free(tbfs[i]);
157
Holger Hans Peter Freytherf3f1bde2016-02-22 15:14:01 +0100158 tbfs[0] = tbf_alloc(bts, NULL, dir, -1, 0, 0, 0);
159 OSMO_ASSERT(tbfs[0]);
160 tbf_free(tbfs[0]);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200161}
162
163static void test_alloc_a()
164{
Jacob Erlbeckfa464bb2015-06-29 12:45:11 +0200165 /* slots 2 - 3 */
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200166 test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x0c, 32*2);
Jacob Erlbeckec478752015-06-19 16:35:38 +0200167 test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x0c, 14);
Jacob Erlbeckfa464bb2015-06-29 12:45:11 +0200168
169 /* slots 1 - 5 */
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200170 test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x1e, 32*4);
Jacob Erlbeckec478752015-06-19 16:35:38 +0200171 test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x1e, 28);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200172}
173
Max2ecf0fd2017-11-21 18:13:31 +0100174static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir, bool verbose)
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100175{
Max2ecf0fd2017-11-21 18:13:31 +0100176 if (!verbose)
177 return;
178
Jacob Erlbeck1f332942015-05-04 08:21:17 +0200179 for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i)
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100180 if (tbf->pdch[i])
Neels Hofmeyrd34646a2017-02-08 17:07:40 +0100181 printf("PDCH[%zu] is used for %s\n", i, dir);
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100182 printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir);
183 printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir);
184}
185
Max2ecf0fd2017-11-21 18:13:31 +0100186#define ENABLE_PDCH(ts_no, enable_flag, trx) \
187 if (enable_flag) \
188 trx->pdch[ts_no].enable();
189
190static inline void enable_ts_on_bts(struct gprs_rlcmac_bts *bts,
191 bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7)
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100192{
Max2ecf0fd2017-11-21 18:13:31 +0100193 struct gprs_rlcmac_trx *trx = &bts->trx[0];
194
195 ENABLE_PDCH(0, ts0, trx);
196 ENABLE_PDCH(1, ts1, trx);
197 ENABLE_PDCH(2, ts2, trx);
198 ENABLE_PDCH(3, ts3, trx);
199 ENABLE_PDCH(4, ts4, trx);
200 ENABLE_PDCH(5, ts5, trx);
201 ENABLE_PDCH(6, ts6, trx);
202 ENABLE_PDCH(7, ts7, trx);
203}
204
205static inline bool test_alloc_b_ul_dl(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
206 uint8_t ms_class, bool verbose)
207{
208 BTS the_bts;
209 struct gprs_rlcmac_bts *bts = the_bts.bts_data();
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200210 GprsMs *ms;
Max2ecf0fd2017-11-21 18:13:31 +0100211 gprs_rlcmac_ul_tbf *ul_tbf;
212 gprs_rlcmac_dl_tbf *dl_tbf;
213
214 if (verbose)
215 printf("Testing UL then DL assignment.\n");
216
217 bts->alloc_algorithm = alloc_algorithm_b;
218
219 enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);
220
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200221 ms = the_bts.ms_alloc(ms_class, 0);
222 ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, true);
Max2ecf0fd2017-11-21 18:13:31 +0100223 if (!ul_tbf)
224 return false;
225
226 OSMO_ASSERT(ul_tbf->ms());
227 OSMO_ASSERT(ul_tbf->ms()->current_trx());
228
229 dump_assignment(ul_tbf, "UL", verbose);
230
231 /* assume final ack has not been sent */
Max92b7a502018-01-26 11:01:35 +0100232 dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), ul_tbf->ms()->current_trx()->trx_no, ms_class, 0,
233 false);
Max2ecf0fd2017-11-21 18:13:31 +0100234 if (!dl_tbf)
235 return false;
236
237 dump_assignment(dl_tbf, "DL", verbose);
238
239 OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
240
241 check_tfi_usage(&the_bts);
242
243 tbf_free(dl_tbf);
244 tbf_free(ul_tbf);
245
246 return true;
247}
248
249static inline bool test_alloc_b_dl_ul(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7,
250 uint8_t ms_class, bool verbose)
251{
252 BTS the_bts;
253 struct gprs_rlcmac_bts *bts = the_bts.bts_data();
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200254 GprsMs *ms;
Max2ecf0fd2017-11-21 18:13:31 +0100255 gprs_rlcmac_ul_tbf *ul_tbf;
256 gprs_rlcmac_dl_tbf *dl_tbf;
257
258 if (verbose)
259 printf("Testing DL then UL assignment followed by update\n");
260
261 bts->alloc_algorithm = alloc_algorithm_b;
262
263 enable_ts_on_bts(bts, ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7);
264
Max92b7a502018-01-26 11:01:35 +0100265 dl_tbf = tbf_alloc_dl_tbf(bts, NULL, -1, ms_class, 0, true);
Max2ecf0fd2017-11-21 18:13:31 +0100266 if (!dl_tbf)
267 return false;
268
269 dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF);
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200270 ms = dl_tbf->ms();
Max2ecf0fd2017-11-21 18:13:31 +0100271 OSMO_ASSERT(dl_tbf->ms());
272 OSMO_ASSERT(dl_tbf->ms()->current_trx());
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200273 ms->set_ms_class(ms_class);
Max2ecf0fd2017-11-21 18:13:31 +0100274
275 dump_assignment(dl_tbf, "DL", verbose);
276
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200277 ul_tbf = tbf_alloc_ul_tbf(bts, ms, ms->current_trx()->trx_no, false);
Max2ecf0fd2017-11-21 18:13:31 +0100278 if (!ul_tbf)
279 return false;
280
281 ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF);
282 ul_tbf->m_contention_resolution_done = 1;
283
284 dump_assignment(ul_tbf, "UL", verbose);
285
286 OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
287
288 /* now update the dl_tbf */
289 dl_tbf->update();
290 dump_assignment(dl_tbf, "DL", verbose);
291 OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
292
293 check_tfi_usage(&the_bts);
294
295 tbf_free(dl_tbf);
296 tbf_free(ul_tbf);
297
298 return true;
299}
300
301static inline bool test_alloc_b_jolly(uint8_t ms_class)
302{
303 BTS the_bts;
304 struct gprs_rlcmac_bts *bts = the_bts.bts_data();
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200305 GprsMs *ms;
Max2ecf0fd2017-11-21 18:13:31 +0100306 int tfi;
307 uint8_t trx_no;
308 gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
309
310 printf("Testing jolly example\n");
311
312 bts->alloc_algorithm = alloc_algorithm_b;
313
314 enable_ts_on_bts(bts, false, true, true, true, true, false, false, false);
315
316 tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1);
317 OSMO_ASSERT(tfi >= 0);
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200318 ms = the_bts.ms_alloc(ms_class, 0);
319 ul_tbf = tbf_alloc_ul_tbf(bts, ms, -1, false);
Max2ecf0fd2017-11-21 18:13:31 +0100320 if (!ul_tbf)
321 return false;
322
323 OSMO_ASSERT(ul_tbf->ms());
324 OSMO_ASSERT(ul_tbf->ms()->current_trx());
325 trx_no = ul_tbf->ms()->current_trx()->trx_no;
326 dump_assignment(ul_tbf, "UL", true);
327
328 /* assume final ack has not been sent */
Max92b7a502018-01-26 11:01:35 +0100329 dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0,
330 false);
Max2ecf0fd2017-11-21 18:13:31 +0100331 if (!dl_tbf)
332 return false;
333
334 dump_assignment(dl_tbf, "DL", true);
335
336 OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts);
337
338 check_tfi_usage(&the_bts);
339
340 tbf_free(dl_tbf);
341 tbf_free(ul_tbf);
342
343 return true;
344}
345
346static void test_alloc_b_for_ms(uint8_t ms_class)
347{
348 bool rc;
349
Holger Hans Peter Freytherc7b998c2013-12-25 19:25:10 +0100350 printf("Going to test multislot assignment MS_CLASS=%d\n", ms_class);
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100351 /*
352 * PDCH is on TS 6,7,8 and we start with a UL allocation and
353 * then follow two DL allocations (once single, once normal).
354 *
355 * Uplink assigned and still available..
356 */
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100357
Max2ecf0fd2017-11-21 18:13:31 +0100358 rc = test_alloc_b_ul_dl(false, false, false, false, false, true, true, true, ms_class, true);
359 if (!rc)
360 return;
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100361
362 /**
363 * Test with the other order.. first DL and then UL
364 */
Max2ecf0fd2017-11-21 18:13:31 +0100365 rc = test_alloc_b_dl_ul(false, false, false, false, false, true, true, true, ms_class, true);
366 if (!rc)
367 return;
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100368
369 /* Andreas osmocom-pcu example */
Max2ecf0fd2017-11-21 18:13:31 +0100370 test_alloc_b_jolly(ms_class);
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100371}
372
Max2ecf0fd2017-11-21 18:13:31 +0100373static void test_alloc_mass(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7, int ms_class)
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100374{
Max2ecf0fd2017-11-21 18:13:31 +0100375 bool rc;
376
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100377 /* we can test the allocation failures differently */
378 if (!ts0 && !ts1 && !ts2 && !ts3 && !ts4 && !ts5 && !ts6 && !ts7)
379 return;
380
381 printf("Mass test: TS0(%c%c%c%c%c%c%c%c)TS7 MS_Class=%d\n",
382 ts0 ? 'O' : 'x',
383 ts1 ? 'O' : 'x',
384 ts2 ? 'O' : 'x',
385 ts3 ? 'O' : 'x',
386 ts4 ? 'O' : 'x',
387 ts5 ? 'O' : 'x',
388 ts6 ? 'O' : 'x',
389 ts7 ? 'O' : 'x', ms_class);
390 fflush(stdout);
391
Max2ecf0fd2017-11-21 18:13:31 +0100392 rc = test_alloc_b_ul_dl(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class, false);
393 if (!rc)
394 return;
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100395
396 /**
397 * Test with the other order.. first DL and then UL
398 */
Max2ecf0fd2017-11-21 18:13:31 +0100399 test_alloc_b_dl_ul(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class, false);
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100400}
401
402static void test_all_alloc_b()
403{
404 /* it is a bit crazy... */
405 for (uint8_t ts0 = 0; ts0 < 2; ++ts0)
406 for (uint8_t ts1 = 0; ts1 < 2; ++ts1)
407 for (uint8_t ts2 = 0; ts2 < 2; ++ts2)
408 for (uint8_t ts3 = 0; ts3 < 2; ++ts3)
409 for (uint8_t ts4 = 0; ts4 < 2; ++ts4)
410 for (uint8_t ts5 = 0; ts5 < 2; ++ts5)
411 for (uint8_t ts6 = 0; ts6 < 2; ++ts6)
412 for (uint8_t ts7 = 0; ts7 < 2; ++ts7)
Max9f460712018-01-23 20:57:08 +0100413 for (int ms_class = 0; ms_class < mslot_class_max(); ++ms_class)
Max2ecf0fd2017-11-21 18:13:31 +0100414 test_alloc_mass(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class);
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100415}
416
Holger Hans Peter Freytherc7b998c2013-12-25 19:25:10 +0100417static void test_alloc_b()
418{
Max9f460712018-01-23 20:57:08 +0100419 for (int i = 0; i < mslot_class_max(); ++i)
Max2ecf0fd2017-11-21 18:13:31 +0100420 test_alloc_b_for_ms(i);
Holger Hans Peter Freytherf3eec042013-12-26 10:19:18 +0100421
422 test_all_alloc_b();
Holger Hans Peter Freytherc7b998c2013-12-25 19:25:10 +0100423}
424
Maxe9fe0e32017-09-28 15:56:05 +0200425typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, struct GprsMs *ms, struct gprs_rlcmac_tbf *tbf, bool single,
426 int8_t use_trx);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200427
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200428static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx, uint8_t busy)
Jacob Erlbecke5655642015-06-29 12:19:52 +0200429{
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200430 int offs = busy ? 32 : 0;
431 return (mask & tx & rx) ? 'C' + offs :
432 (mask & tx) ? 'U' + offs :
433 (mask & rx) ? 'D' + offs :
Jacob Erlbecke5655642015-06-29 12:19:52 +0200434 '.';
435}
436
437enum test_mode {
438 TEST_MODE_UL_ONLY,
439 TEST_MODE_DL_ONLY,
440 TEST_MODE_UL_AND_DL,
441 TEST_MODE_DL_AND_UL,
442 TEST_MODE_DL_AFTER_UL,
443 TEST_MODE_UL_AFTER_DL,
444};
445
Maxc59ef122017-11-27 13:21:41 +0100446static inline char *test_mode_descr(enum test_mode t)
447{
448 switch (t) {
449 case TEST_MODE_UL_ONLY: return (char*)"UL only";
450 case TEST_MODE_DL_ONLY: return (char*)"DL only";
451 case TEST_MODE_UL_AND_DL: return (char*)"UL and DL";
452 case TEST_MODE_DL_AND_UL: return (char*)"DL and UL";
453 case TEST_MODE_DL_AFTER_UL: return (char*)"DL after UL";
454 case TEST_MODE_UL_AFTER_DL: return (char*)"UL after DL";
455 default: return NULL;
456 }
457}
458
Jacob Erlbecke5655642015-06-29 12:19:52 +0200459static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, unsigned ms_class,
460 enum test_mode mode)
461{
462 struct gprs_rlcmac_bts *bts;
Jacob Erlbeck5879c642015-07-10 10:41:36 +0200463 uint8_t trx_no = -1;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200464
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200465 OSMO_ASSERT(ms != NULL);
466
Jacob Erlbecke5655642015-06-29 12:19:52 +0200467 bts = the_bts->bts_data();
468
469 gprs_rlcmac_tbf *tbf = NULL;
470
Jacob Erlbeck5879c642015-07-10 10:41:36 +0200471 if (ms && ms->current_trx())
472 trx_no = ms->current_trx()->trx_no;
473
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200474 GprsMs::Guard guard1(ms);
475
Jacob Erlbecke5655642015-06-29 12:19:52 +0200476 /* Allocate what is needed first */
477 switch (mode) {
478 case TEST_MODE_UL_ONLY:
479 case TEST_MODE_DL_AFTER_UL:
480 case TEST_MODE_UL_AND_DL:
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200481 if (ms && ms->ul_tbf())
482 tbf_free(ms->ul_tbf());
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200483 ms->set_ms_class(ms_class);
484 tbf = tbf_alloc_ul_tbf(bts, ms, trx_no, false);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200485 if (tbf == NULL)
486 return NULL;
487 break;
488 case TEST_MODE_DL_ONLY:
489 case TEST_MODE_UL_AFTER_DL:
490 case TEST_MODE_DL_AND_UL:
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200491 if (ms && ms->dl_tbf())
492 tbf_free(ms->dl_tbf());
Max92b7a502018-01-26 11:01:35 +0100493 tbf = tbf_alloc_dl_tbf(bts, ms, trx_no, ms_class, 0, false);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200494 if (tbf == NULL)
495 return NULL;
496 }
497
498 OSMO_ASSERT(tbf);
499 OSMO_ASSERT(tbf->ms());
500 OSMO_ASSERT(ms == NULL || ms == tbf->ms());
501 ms = tbf->ms();
502
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200503 GprsMs::Guard guard2(ms);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200504
Jacob Erlbeck14376a72015-07-07 11:31:28 +0200505 /* Continue with what is needed next */
506 switch (mode) {
507 case TEST_MODE_UL_ONLY:
508 case TEST_MODE_DL_ONLY:
509 /* We are done */
510 break;
511
512 case TEST_MODE_DL_AFTER_UL:
513 case TEST_MODE_UL_AND_DL:
514 ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_DL_ONLY);
515 break;
516
517 case TEST_MODE_UL_AFTER_DL:
518 case TEST_MODE_DL_AND_UL:
519 ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_UL_ONLY);
520 break;
521 }
522
Jacob Erlbecke5655642015-06-29 12:19:52 +0200523 /* Optionally delete the TBF */
524 switch (mode) {
525 case TEST_MODE_DL_AFTER_UL:
526 case TEST_MODE_UL_AFTER_DL:
527 tbf_free(tbf);
Jacob Erlbeck0f352a62015-07-16 18:23:33 +0200528 tbf = NULL;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200529 break;
530
531 default:
532 break;
533 }
534
Jacob Erlbeck0f352a62015-07-16 18:23:33 +0200535 if (!ms && tbf)
536 tbf_free(tbf);
537
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200538 return guard2.is_idle() ? NULL : ms;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200539}
540
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200541static unsigned alloc_many_tbfs(BTS *the_bts, unsigned min_class,
542 unsigned max_class, enum test_mode mode)
Jacob Erlbecke5655642015-06-29 12:19:52 +0200543{
Jacob Erlbecke5655642015-06-29 12:19:52 +0200544 unsigned counter;
545 unsigned ms_class = min_class;
546
Jacob Erlbecke5655642015-06-29 12:19:52 +0200547 for (counter = 0; 1; counter += 1) {
548 gprs_rlcmac_tbf *ul_tbf, *dl_tbf;
549 uint8_t ul_slots = 0;
550 uint8_t dl_slots = 0;
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200551 uint8_t busy_slots = 0;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200552 unsigned i;
553 int tfi = -1;
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200554 int tfi2;
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200555 uint8_t trx_no2;
556 struct gprs_rlcmac_trx *trx;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200557 GprsMs *ms;
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200558 enum gprs_rlcmac_tbf_direction dir;
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200559 uint32_t tlli = counter + 0xc0000000;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200560
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200561 ms = the_bts->ms_by_tlli(tlli);
Pau Espin Pedrol17402a52020-05-08 17:44:33 +0200562 if (!ms)
563 ms = the_bts->ms_alloc(0, 0);
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200564
565 ms = alloc_tbfs(the_bts, ms, ms_class, mode);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200566 if (!ms)
567 break;
568
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200569 ms->set_tlli(tlli);
570
Jacob Erlbecke5655642015-06-29 12:19:52 +0200571 ul_tbf = ms->ul_tbf();
572 dl_tbf = ms->dl_tbf();
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200573 trx = ms->current_trx();
574
575 OSMO_ASSERT(ul_tbf || dl_tbf);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200576
577 if (ul_tbf) {
578 ul_slots = 1 << ul_tbf->first_common_ts;
579 tfi = ul_tbf->tfi();
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200580 dir = GPRS_RLCMAC_UL_TBF;
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200581 } else {
Jacob Erlbecke5655642015-06-29 12:19:52 +0200582 ul_slots = 1 << dl_tbf->first_common_ts;
583 tfi = dl_tbf->tfi();
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200584 dir = GPRS_RLCMAC_DL_TBF;
Jacob Erlbecke5655642015-06-29 12:19:52 +0200585 }
586
587 for (i = 0; dl_tbf && i < ARRAY_SIZE(dl_tbf->pdch); i += 1)
588 if (dl_tbf->pdch[i])
589 dl_slots |= 1 << i;
590
Max5b0df1f2017-09-11 10:38:59 +0200591 for (i = 0; ul_tbf && i < ARRAY_SIZE(ul_tbf->pdch); i += 1)
592 if (ul_tbf->pdch[i])
593 ul_slots |= 1 << i;
594
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200595 for (i = 0; trx && i < ARRAY_SIZE(trx->pdch); i += 1) {
596 struct gprs_rlcmac_pdch *pdch = &trx->pdch[i];
597
598 if (ul_tbf && dl_tbf)
599 continue;
600
601 if (ul_tbf &&
Maxd000d802017-09-20 17:55:28 +0200602 pdch->assigned_tfi(GPRS_RLCMAC_DL_TBF) != NO_FREE_TFI)
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200603 continue;
604
605 if (dl_tbf &&
Maxd000d802017-09-20 17:55:28 +0200606 pdch->assigned_tfi(GPRS_RLCMAC_UL_TBF) != NO_FREE_TFI)
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200607 continue;
608
609 busy_slots |= 1 << i;
610 }
611
Maxd000d802017-09-20 17:55:28 +0200612 printf(" TBF[%d] class %d reserves " OSMO_BIT_SPEC "\n",
Jacob Erlbecke5655642015-06-29 12:19:52 +0200613 tfi, ms_class,
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200614 get_dir_char(0x01, ul_slots, dl_slots, busy_slots),
615 get_dir_char(0x02, ul_slots, dl_slots, busy_slots),
616 get_dir_char(0x04, ul_slots, dl_slots, busy_slots),
617 get_dir_char(0x08, ul_slots, dl_slots, busy_slots),
618 get_dir_char(0x10, ul_slots, dl_slots, busy_slots),
619 get_dir_char(0x20, ul_slots, dl_slots, busy_slots),
620 get_dir_char(0x40, ul_slots, dl_slots, busy_slots),
621 get_dir_char(0x80, ul_slots, dl_slots, busy_slots));
Jacob Erlbecke5655642015-06-29 12:19:52 +0200622
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200623 if (tfi >= 0) {
624 OSMO_ASSERT(ms->current_trx());
Jacob Erlbeckbf904222015-07-16 18:19:09 +0200625 tfi2 = the_bts->tfi_find_free(dir, &trx_no2,
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200626 ms->current_trx()->trx_no);
627 OSMO_ASSERT(tfi != tfi2);
Jacob Erlbeck7b3675b2015-07-16 18:28:22 +0200628 OSMO_ASSERT(tfi2 < 0 ||
629 trx_no2 == ms->current_trx()->trx_no);
Jacob Erlbeck61205a72015-07-09 11:35:50 +0200630 }
631
Jacob Erlbecke5655642015-06-29 12:19:52 +0200632 ms_class += 1;
633 if (ms_class > max_class)
634 ms_class = min_class;
635 }
636
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200637 return counter;
638}
639
640static void test_successive_allocation(algo_t algo, unsigned min_class,
641 unsigned max_class, enum test_mode mode,
642 unsigned expect_num, const char *text)
643{
644 BTS the_bts;
645 struct gprs_rlcmac_bts *bts;
646 struct gprs_rlcmac_trx *trx;
647 unsigned counter;
648
Maxc59ef122017-11-27 13:21:41 +0100649 printf("Going to test assignment with many TBF, algorithm %s class %u..%u (%s)\n",
650 text, min_class, max_class, test_mode_descr(mode));
Jacob Erlbeck69c9bfa2015-07-13 14:38:18 +0200651
652 bts = the_bts.bts_data();
653 bts->alloc_algorithm = algo;
654
655 trx = &bts->trx[0];
656 trx->pdch[3].enable();
657 trx->pdch[4].enable();
658 trx->pdch[5].enable();
659 trx->pdch[6].enable();
660 trx->pdch[7].enable();
661
662 counter = alloc_many_tbfs(&the_bts, min_class, max_class, mode);
663
Maxc59ef122017-11-27 13:21:41 +0100664 printf(" Successfully allocated %u UL TBFs, algorithm %s class %u..%u (%s)\n",
665 counter, text, min_class, max_class, test_mode_descr(mode));
Jacob Erlbeck88fb6132015-07-16 15:01:38 +0200666 if (counter != expect_num)
Maxc59ef122017-11-27 13:21:41 +0100667 fprintf(stderr, " Expected %u TBFs (got %u), algorithm %s class %u..%u (%s)\n",
668 expect_num, counter, text, min_class, max_class, test_mode_descr(mode));
Jacob Erlbeck88fb6132015-07-16 15:01:38 +0200669
Jacob Erlbeckec478752015-06-19 16:35:38 +0200670 OSMO_ASSERT(counter == expect_num);
Jacob Erlbecke0853cd2015-07-10 12:25:25 +0200671
672 check_tfi_usage(&the_bts);
Jacob Erlbecke5655642015-06-29 12:19:52 +0200673}
674
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200675static void test_many_connections(algo_t algo, unsigned expect_num,
676 const char *text)
677{
678 BTS the_bts;
679 struct gprs_rlcmac_bts *bts;
680 struct gprs_rlcmac_trx *trx;
681 int counter1, counter2 = -1;
682 unsigned i;
683 enum test_mode mode_seq[] = {
684 TEST_MODE_DL_AFTER_UL,
685 TEST_MODE_UL_ONLY,
686 TEST_MODE_DL_AFTER_UL,
687 TEST_MODE_DL_ONLY,
688 };
689
Maxc59ef122017-11-27 13:21:41 +0100690 printf("Going to test assignment with many connections, algorithm %s\n", text);
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200691
692 bts = the_bts.bts_data();
693 bts->alloc_algorithm = algo;
694
695 trx = &bts->trx[0];
696 trx->pdch[3].enable();
697 trx->pdch[4].enable();
698 trx->pdch[5].enable();
699 trx->pdch[6].enable();
700 trx->pdch[7].enable();
701
702 for (i = 0; i < ARRAY_SIZE(mode_seq); i += 1) {
Max9f460712018-01-23 20:57:08 +0100703 counter1 = alloc_many_tbfs(&the_bts, 1, mslot_class_max(), mode_seq[i]);
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200704 fprintf(stderr, " Allocated %d TBFs (previously %d)\n",
705 counter1, counter2);
706
707 check_tfi_usage(&the_bts);
708
709 /* This will stop earlier due to USF shortage */
710 if (mode_seq[i] == TEST_MODE_UL_ONLY)
711 continue;
712
Jacob Erlbeck88fb6132015-07-16 15:01:38 +0200713 if (counter2 >= 0) {
714 if (counter1 < counter2)
715 fprintf(stderr, " Expected %d >= %d in %s\n",
716 counter1, counter2, text);
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200717 OSMO_ASSERT(counter1 >= counter2);
Jacob Erlbeck88fb6132015-07-16 15:01:38 +0200718 }
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200719
720 counter2 = counter1;
721 }
722
723 printf(" Successfully allocated %d TBFs\n", counter1);
Jacob Erlbeck88fb6132015-07-16 15:01:38 +0200724 if (counter1 != (int)expect_num)
Maxc59ef122017-11-27 13:21:41 +0100725 fprintf(stderr, " Expected %d TBFs (got %d) for algorithm %s\n", expect_num, counter1, text);
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200726
727 OSMO_ASSERT(expect_num == (unsigned)counter1);
728}
729
Maxc59ef122017-11-27 13:21:41 +0100730static inline void test_a_b_dyn(enum test_mode mode, uint8_t exp_A, uint8_t exp_B, uint8_t exp_dyn)
Jacob Erlbecke5655642015-06-29 12:19:52 +0200731{
Maxc59ef122017-11-27 13:21:41 +0100732 test_successive_allocation(alloc_algorithm_a, 1, 1, mode, exp_A, "A");
733 test_successive_allocation(alloc_algorithm_b, 10, 10, mode, exp_B, "B");
734 test_successive_allocation(alloc_algorithm_dynamic, 10, 10, mode, exp_dyn, "dynamic");
Jacob Erlbecke5655642015-06-29 12:19:52 +0200735}
736
Maxc59ef122017-11-27 13:21:41 +0100737static void test_successive_allocations()
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200738{
Maxc59ef122017-11-27 13:21:41 +0100739 test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AND_DL, 35, "A");
740 test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AND_DL, 32, "B");
741 test_successive_allocation(alloc_algorithm_b, 12, 12, TEST_MODE_UL_AND_DL, 32, "B");
742
Max9f460712018-01-23 20:57:08 +0100743 test_successive_allocation(alloc_algorithm_b, 1, 12, TEST_MODE_UL_AND_DL, 32, "B");
Max01bd0cc2018-01-23 20:58:49 +0100744 test_successive_allocation(alloc_algorithm_b, 1, mslot_class_max(), TEST_MODE_UL_AND_DL, 32, "B");
Max9f460712018-01-23 20:57:08 +0100745 test_successive_allocation(alloc_algorithm_dynamic, 1, mslot_class_max(), TEST_MODE_UL_AND_DL, 35, "dynamic");
Maxc59ef122017-11-27 13:21:41 +0100746
747 test_a_b_dyn(TEST_MODE_DL_AND_UL, 35, 32, 32);
748 test_a_b_dyn(TEST_MODE_DL_AFTER_UL, 160, 32, 95);
749 test_a_b_dyn(TEST_MODE_UL_AFTER_DL, 35, 32, 35);
750 test_a_b_dyn(TEST_MODE_UL_ONLY, 35, 32, 35);
751 test_a_b_dyn(TEST_MODE_DL_ONLY, 160, 32, 101);
Jacob Erlbecka8c2aaf2015-07-13 14:50:08 +0200752}
753
Aravind Sirsikare26ee012016-09-06 18:15:45 +0530754static void test_2_consecutive_dl_tbfs()
755{
756 BTS the_bts;
757 struct gprs_rlcmac_bts *bts;
758 struct gprs_rlcmac_trx *trx;
759 uint8_t ms_class = 11;
760 uint8_t egprs_ms_class = 11;
761 gprs_rlcmac_tbf *dl_tbf1, *dl_tbf2;
762 uint8_t numTs1 = 0, numTs2 = 0;
763
764 printf("Testing DL TS allocation for Multi UEs\n");
765
766 bts = the_bts.bts_data();
767 bts->alloc_algorithm = alloc_algorithm_b;
768
769 trx = &bts->trx[0];
770 trx->pdch[4].enable();
771 trx->pdch[5].enable();
772 trx->pdch[6].enable();
773 trx->pdch[7].enable();
774
Max92b7a502018-01-26 11:01:35 +0100775 dl_tbf1 = tbf_alloc_dl_tbf(bts, NULL, 0, ms_class, egprs_ms_class,
776 false);
Aravind Sirsikare26ee012016-09-06 18:15:45 +0530777 OSMO_ASSERT(dl_tbf1);
778
779 for (int i = 0; i < 8; i++) {
780 if (dl_tbf1->pdch[i])
781 numTs1++;
782 }
783 OSMO_ASSERT(numTs1 == 4);
784 printf("TBF1: numTs(%d)\n", numTs1);
785
Max92b7a502018-01-26 11:01:35 +0100786 dl_tbf2 = tbf_alloc_dl_tbf(bts, NULL, 0, ms_class, egprs_ms_class,
787 false);
Aravind Sirsikare26ee012016-09-06 18:15:45 +0530788 OSMO_ASSERT(dl_tbf2);
789
790 for (int i = 0; i < 8; i++) {
791 if (dl_tbf2->pdch[i])
792 numTs2++;
793 }
794
795 /*
796 * TODO: currently 2nd DL TBF gets 3 TS
797 * This behaviour will be fixed in subsequent patch
798 */
799 printf("TBF2: numTs(%d)\n", numTs2);
800 OSMO_ASSERT(numTs2 == 3);
801
802 tbf_free(dl_tbf1);
803 tbf_free(dl_tbf2);
804}
805
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200806int main(int argc, char **argv)
807{
808 tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context");
809 if (!tall_pcu_ctx)
810 abort();
811
Neels Hofmeyr78ce5912017-02-08 17:07:31 +0100812 msgb_talloc_ctx_init(tall_pcu_ctx, 0);
Neels Hofmeyr42f2d612018-04-01 16:54:40 +0200813 osmo_init_logging2(tall_pcu_ctx, &gprs_log_info);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200814 log_set_use_color(osmo_stderr_target, 0);
815 log_set_print_filename(osmo_stderr_target, 0);
Jacob Erlbeck9ec49e22015-06-29 13:00:20 +0200816 if (getenv("LOGL_DEBUG"))
817 log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200818
819 test_alloc_a();
Holger Hans Peter Freyther4af30532013-12-25 19:16:55 +0100820 test_alloc_b();
Maxc59ef122017-11-27 13:21:41 +0100821 test_successive_allocations();
822 test_many_connections(alloc_algorithm_a, 160, "A");
Max01bd0cc2018-01-23 20:58:49 +0100823 test_many_connections(alloc_algorithm_b, 32, "B");
Maxc59ef122017-11-27 13:21:41 +0100824 test_many_connections(alloc_algorithm_dynamic, 160, "dynamic");
Aravind Sirsikare26ee012016-09-06 18:15:45 +0530825 test_2_consecutive_dl_tbfs();
Holger Hans Peter Freytherbfdd5f22013-10-16 17:29:31 +0200826 return EXIT_SUCCESS;
827}
828
829/*
830 * stubs that should not be reached
831 */
832extern "C" {
833void l1if_pdch_req() { abort(); }
834void l1if_connect_pdch() { abort(); }
835void l1if_close_pdch() { abort(); }
836void l1if_open_pdch() { abort(); }
837}