Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 1 | /* 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" |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 23 | #include "bts.h" |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 24 | |
| 25 | #include <string.h> |
| 26 | #include <stdio.h> |
| 27 | |
| 28 | extern "C" { |
| 29 | #include <osmocom/core/application.h> |
| 30 | #include <osmocom/core/msgb.h> |
| 31 | #include <osmocom/core/talloc.h> |
| 32 | #include <osmocom/core/utils.h> |
| 33 | } |
| 34 | |
| 35 | /* globals used by the code */ |
| 36 | void *tall_pcu_ctx; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 37 | int16_t spoof_mnc = 0, spoof_mcc = 0; |
| 38 | |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 39 | static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts, |
Jacob Erlbeck | e2e004e | 2015-06-18 17:16:26 +0200 | [diff] [blame] | 40 | GprsMs *ms, gprs_rlcmac_tbf_direction dir, |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 41 | uint8_t use_trx, |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 42 | uint8_t ms_class, uint8_t single_slot) |
| 43 | { |
| 44 | if (dir == GPRS_RLCMAC_UL_TBF) |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 45 | return tbf_alloc_ul_tbf(bts, ms, use_trx, ms_class, single_slot); |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 46 | else |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 47 | return tbf_alloc_dl_tbf(bts, ms, use_trx, ms_class, single_slot); |
Daniel Willmann | 48aa0b0 | 2014-07-16 18:54:10 +0200 | [diff] [blame] | 48 | } |
| 49 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 50 | static void check_tfi_usage(BTS *the_bts) |
| 51 | { |
| 52 | int pdch_no; |
| 53 | struct gprs_rlcmac_bts *bts = the_bts->bts_data(); |
| 54 | |
| 55 | struct gprs_rlcmac_tbf *tfi_usage[8][8][2][32] = {{{{NULL}}}}; |
| 56 | struct llist_head *tbf_lists[2] = { |
| 57 | &bts->ul_tbfs, |
| 58 | &bts->dl_tbfs |
| 59 | }; |
| 60 | |
| 61 | gprs_rlcmac_tbf *tbf; |
| 62 | struct llist_pods *lpods; |
| 63 | unsigned list_idx; |
| 64 | struct gprs_rlcmac_tbf **tbf_var; |
| 65 | |
| 66 | for (list_idx = 0; list_idx < ARRAY_SIZE(tbf_lists); list_idx += 1) |
| 67 | { |
| 68 | |
| 69 | llist_pods_for_each_entry(tbf, tbf_lists[list_idx], list, lpods) { |
| 70 | for (pdch_no = 0; pdch_no < 8; pdch_no += 1) { |
| 71 | struct gprs_rlcmac_pdch *pdch = tbf->pdch[pdch_no]; |
| 72 | if (pdch == NULL) |
| 73 | continue; |
| 74 | |
| 75 | tbf_var = &tfi_usage |
| 76 | [tbf->trx->trx_no] |
| 77 | [pdch_no] |
| 78 | [tbf->direction] |
| 79 | [tbf->tfi()]; |
| 80 | |
| 81 | OSMO_ASSERT(*tbf_var == NULL); |
| 82 | if (tbf->direction == GPRS_RLCMAC_DL_TBF) { |
| 83 | OSMO_ASSERT(pdch->dl_tbf_by_tfi( |
| 84 | tbf->tfi()) == tbf); |
| 85 | /* This assertion cannot hold with the |
| 86 | * current API and shared TFI */ |
| 87 | OSMO_ASSERT(the_bts->dl_tbf_by_tfi( |
| 88 | tbf->tfi(), |
| 89 | tbf->trx->trx_no) == tbf); |
| 90 | } else { |
| 91 | OSMO_ASSERT(pdch->ul_tbf_by_tfi( |
| 92 | tbf->tfi()) == tbf); |
| 93 | /* This assertion cannot hold with the |
| 94 | * current API and shared TFI */ |
| 95 | OSMO_ASSERT(the_bts->ul_tbf_by_tfi( |
| 96 | tbf->tfi(), |
| 97 | tbf->trx->trx_no) == tbf); |
| 98 | } |
| 99 | *tbf_var = tbf; |
Jacob Erlbeck | 47a57f6 | 2015-07-08 12:53:16 +0200 | [diff] [blame] | 100 | OSMO_ASSERT(pdch->assigned_tfi(tbf->direction) & |
| 101 | (1 << tbf->tfi())); |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 107 | static void test_alloc_a(gprs_rlcmac_tbf_direction dir, |
| 108 | uint8_t slots, const int count) |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 109 | { |
| 110 | int tfi; |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 111 | int i; |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 112 | uint8_t used_trx, tmp_trx; |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 113 | BTS the_bts; |
| 114 | struct gprs_rlcmac_bts *bts; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 115 | struct gprs_rlcmac_tbf *tbfs[33] = { 0, }; |
| 116 | |
| 117 | printf("Testing alloc_a direction(%d)\n", dir); |
| 118 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 119 | bts = the_bts.bts_data(); |
| 120 | bts->alloc_algorithm = alloc_algorithm_a; |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 121 | |
Holger Hans Peter Freyther | 34bd8bd | 2013-10-19 21:10:38 +0200 | [diff] [blame] | 122 | struct gprs_rlcmac_trx *trx = &bts->trx[0]; |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 123 | for (i = 0; i < 8; i += 1) |
| 124 | if (slots & (1 << i)) |
| 125 | trx->pdch[i].enable(); |
| 126 | |
| 127 | OSMO_ASSERT(count >= 0 && count <= (int)ARRAY_SIZE(tbfs)); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Currently alloc_a will only allocate from the first |
| 131 | * PDCH and all possible usf's. We run out of usf's before |
| 132 | * we are out of tfi's. Observe this and make sure that at |
| 133 | * least this part is working okay. |
| 134 | */ |
| 135 | for (int i = 0; i < count; ++i) { |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 136 | tbfs[i] = tbf_alloc(bts, NULL, dir, -1, 0, 0); |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 137 | OSMO_ASSERT(tbfs[i] != NULL); |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 138 | tfi = the_bts.tfi_find_free(dir, &tmp_trx, used_trx); |
| 139 | OSMO_ASSERT(tbfs[i]->tfi() != tfi); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* Now check that there are still some TFIs */ |
Holger Hans Peter Freyther | 70ddde6 | 2013-10-26 19:17:58 +0200 | [diff] [blame] | 143 | tfi = the_bts.tfi_find_free(dir, &used_trx, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 144 | switch (dir) { |
| 145 | case GPRS_RLCMAC_UL_TBF: |
| 146 | OSMO_ASSERT(tfi >= 0); |
| 147 | break; |
| 148 | case GPRS_RLCMAC_DL_TBF: |
| 149 | OSMO_ASSERT(tfi < 0); |
| 150 | break; |
| 151 | } |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 152 | OSMO_ASSERT(!tbf_alloc(bts, NULL, dir, -1, 0, 0)); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 153 | |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 154 | for (size_t i = 0; i < ARRAY_SIZE(tbfs); ++i) |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 155 | if (tbfs[i]) |
| 156 | tbf_free(tbfs[i]); |
| 157 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 158 | tbfs[tfi] = tbf_alloc(bts, NULL, dir, -1, 0, 0); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 159 | OSMO_ASSERT(tbfs[tfi]); |
| 160 | tbf_free(tbfs[tfi]); |
| 161 | } |
| 162 | |
| 163 | static void test_alloc_a() |
| 164 | { |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 165 | /* slots 2 - 3 */ |
| 166 | test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x0c, 32); |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 167 | test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x0c, 14); |
Jacob Erlbeck | fa464bb | 2015-06-29 12:45:11 +0200 | [diff] [blame] | 168 | |
| 169 | /* slots 1 - 5 */ |
| 170 | test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x1e, 32); |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 171 | test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x1e, 28); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 172 | } |
| 173 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 174 | static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir) |
| 175 | { |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 176 | for (size_t i = 0; i < ARRAY_SIZE(tbf->pdch); ++i) |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 177 | if (tbf->pdch[i]) |
| 178 | printf("PDCH[%d] is used for %s\n", i, dir); |
| 179 | printf("PDCH[%d] is control_ts for %s\n", tbf->control_ts, dir); |
| 180 | printf("PDCH[%d] is first common for %s\n", tbf->first_common_ts, dir); |
| 181 | } |
| 182 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 183 | static void test_alloc_b(int ms_class) |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 184 | { |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 185 | printf("Going to test multislot assignment MS_CLASS=%d\n", ms_class); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 186 | /* |
| 187 | * PDCH is on TS 6,7,8 and we start with a UL allocation and |
| 188 | * then follow two DL allocations (once single, once normal). |
| 189 | * |
| 190 | * Uplink assigned and still available.. |
| 191 | */ |
| 192 | { |
| 193 | BTS the_bts; |
| 194 | struct gprs_rlcmac_bts *bts; |
| 195 | struct gprs_rlcmac_trx *trx; |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 196 | uint8_t trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 197 | |
| 198 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 199 | |
| 200 | printf("Testing UL then DL assignment.\n"); |
| 201 | |
| 202 | bts = the_bts.bts_data(); |
| 203 | bts->alloc_algorithm = alloc_algorithm_b; |
| 204 | |
| 205 | trx = &bts->trx[0]; |
| 206 | trx->pdch[5].enable(); |
| 207 | trx->pdch[6].enable(); |
| 208 | trx->pdch[7].enable(); |
| 209 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 210 | ul_tbf = tbf_alloc_ul_tbf(bts, NULL, -1, ms_class, 1); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 211 | OSMO_ASSERT(ul_tbf); |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 212 | OSMO_ASSERT(ul_tbf->ms()); |
| 213 | OSMO_ASSERT(ul_tbf->ms()->current_trx()); |
| 214 | trx_no = ul_tbf->ms()->current_trx()->trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 215 | dump_assignment(ul_tbf, "UL"); |
| 216 | |
| 217 | /* assume final ack has not been sent */ |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 218 | dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 219 | OSMO_ASSERT(dl_tbf); |
| 220 | dump_assignment(dl_tbf, "DL"); |
| 221 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 222 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 223 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 224 | check_tfi_usage(&the_bts); |
| 225 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 226 | tbf_free(dl_tbf); |
| 227 | tbf_free(ul_tbf); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Test with the other order.. first DL and then UL |
| 232 | */ |
| 233 | { |
| 234 | BTS the_bts; |
| 235 | struct gprs_rlcmac_bts *bts; |
| 236 | struct gprs_rlcmac_trx *trx; |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 237 | uint8_t trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 238 | |
Daniel Willmann | 351a573 | 2014-08-07 12:57:44 +0200 | [diff] [blame] | 239 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 240 | gprs_rlcmac_dl_tbf *dl_tbf; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 241 | |
| 242 | printf("Testing DL then UL assignment followed by update\n"); |
| 243 | |
| 244 | bts = the_bts.bts_data(); |
| 245 | bts->alloc_algorithm = alloc_algorithm_b; |
| 246 | |
| 247 | trx = &bts->trx[0]; |
| 248 | trx->pdch[5].enable(); |
| 249 | trx->pdch[6].enable(); |
| 250 | trx->pdch[7].enable(); |
| 251 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 252 | dl_tbf = tbf_alloc_dl_tbf(bts, NULL, -1, ms_class, 1); |
Jacob Erlbeck | 767193e | 2015-05-20 12:06:46 +0200 | [diff] [blame] | 253 | dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 254 | OSMO_ASSERT(dl_tbf); |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 255 | OSMO_ASSERT(dl_tbf->ms()); |
| 256 | OSMO_ASSERT(dl_tbf->ms()->current_trx()); |
| 257 | trx_no = dl_tbf->ms()->current_trx()->trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 258 | dump_assignment(dl_tbf, "DL"); |
| 259 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 260 | ul_tbf = tbf_alloc_ul_tbf(bts, dl_tbf->ms(), trx_no, ms_class, 0); |
Jacob Erlbeck | 767193e | 2015-05-20 12:06:46 +0200 | [diff] [blame] | 261 | ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF); |
Daniel Willmann | 7e994e3 | 2014-08-07 15:49:21 +0200 | [diff] [blame] | 262 | ul_tbf->m_contention_resolution_done = 1; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 263 | OSMO_ASSERT(ul_tbf); |
| 264 | dump_assignment(ul_tbf, "UL"); |
| 265 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 266 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 267 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 268 | /* now update the dl_tbf */ |
| 269 | dl_tbf->update(); |
| 270 | dump_assignment(dl_tbf, "DL"); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 271 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 272 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 273 | check_tfi_usage(&the_bts); |
| 274 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 275 | tbf_free(dl_tbf); |
| 276 | tbf_free(ul_tbf); |
| 277 | } |
| 278 | |
| 279 | /* Andreas osmocom-pcu example */ |
| 280 | { |
| 281 | BTS the_bts; |
| 282 | struct gprs_rlcmac_bts *bts; |
| 283 | struct gprs_rlcmac_trx *trx; |
| 284 | int tfi; |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 285 | uint8_t trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 286 | |
| 287 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 288 | |
| 289 | printf("Testing jolly example\n"); |
| 290 | |
| 291 | bts = the_bts.bts_data(); |
| 292 | bts->alloc_algorithm = alloc_algorithm_b; |
| 293 | |
| 294 | trx = &bts->trx[0]; |
| 295 | trx->pdch[1].enable(); |
| 296 | trx->pdch[2].enable(); |
| 297 | trx->pdch[3].enable(); |
| 298 | trx->pdch[4].enable(); |
| 299 | |
| 300 | tfi = the_bts.tfi_find_free(GPRS_RLCMAC_UL_TBF, &trx_no, -1); |
| 301 | OSMO_ASSERT(tfi >= 0); |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 302 | ul_tbf = tbf_alloc_ul_tbf(bts, NULL, .1, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 303 | OSMO_ASSERT(ul_tbf); |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 304 | OSMO_ASSERT(ul_tbf->ms()); |
| 305 | OSMO_ASSERT(ul_tbf->ms()->current_trx()); |
| 306 | trx_no = ul_tbf->ms()->current_trx()->trx_no; |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 307 | dump_assignment(ul_tbf, "UL"); |
| 308 | |
| 309 | /* assume final ack has not been sent */ |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 310 | dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 311 | OSMO_ASSERT(dl_tbf); |
| 312 | dump_assignment(dl_tbf, "DL"); |
| 313 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 314 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 315 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 316 | check_tfi_usage(&the_bts); |
| 317 | |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 318 | tbf_free(dl_tbf); |
| 319 | tbf_free(ul_tbf); |
| 320 | } |
| 321 | } |
| 322 | |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 323 | #define ENABLE_PDCH(ts_no, enable_flag, trx) \ |
| 324 | if (enable_flag) \ |
| 325 | trx->pdch[ts_no].enable(); |
| 326 | |
| 327 | static void test_alloc_b(bool ts0, bool ts1, bool ts2, bool ts3, bool ts4, bool ts5, bool ts6, bool ts7, int ms_class) |
| 328 | { |
| 329 | /* we can test the allocation failures differently */ |
| 330 | if (!ts0 && !ts1 && !ts2 && !ts3 && !ts4 && !ts5 && !ts6 && !ts7) |
| 331 | return; |
| 332 | |
| 333 | printf("Mass test: TS0(%c%c%c%c%c%c%c%c)TS7 MS_Class=%d\n", |
| 334 | ts0 ? 'O' : 'x', |
| 335 | ts1 ? 'O' : 'x', |
| 336 | ts2 ? 'O' : 'x', |
| 337 | ts3 ? 'O' : 'x', |
| 338 | ts4 ? 'O' : 'x', |
| 339 | ts5 ? 'O' : 'x', |
| 340 | ts6 ? 'O' : 'x', |
| 341 | ts7 ? 'O' : 'x', ms_class); |
| 342 | fflush(stdout); |
| 343 | |
| 344 | { |
| 345 | BTS the_bts; |
| 346 | struct gprs_rlcmac_bts *bts; |
| 347 | struct gprs_rlcmac_trx *trx; |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 348 | uint8_t trx_no; |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 349 | |
| 350 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 351 | |
| 352 | bts = the_bts.bts_data(); |
| 353 | bts->alloc_algorithm = alloc_algorithm_b; |
| 354 | |
| 355 | trx = &bts->trx[0]; |
| 356 | ENABLE_PDCH(0, ts0, trx); |
| 357 | ENABLE_PDCH(1, ts1, trx); |
| 358 | ENABLE_PDCH(2, ts2, trx); |
| 359 | ENABLE_PDCH(3, ts3, trx); |
| 360 | ENABLE_PDCH(4, ts4, trx); |
| 361 | ENABLE_PDCH(5, ts5, trx); |
| 362 | ENABLE_PDCH(6, ts6, trx); |
| 363 | ENABLE_PDCH(7, ts7, trx); |
| 364 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 365 | ul_tbf = tbf_alloc_ul_tbf(bts, NULL, -1, ms_class, 1); |
| 366 | OSMO_ASSERT(ul_tbf->ms()); |
| 367 | OSMO_ASSERT(ul_tbf->ms()->current_trx()); |
| 368 | trx_no = ul_tbf->ms()->current_trx()->trx_no; |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 369 | OSMO_ASSERT(ul_tbf); |
| 370 | |
| 371 | /* assume final ack has not been sent */ |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 372 | dl_tbf = tbf_alloc_dl_tbf(bts, ul_tbf->ms(), trx_no, ms_class, 0); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 373 | OSMO_ASSERT(dl_tbf); |
| 374 | |
| 375 | /* verify that both are on the same ts */ |
| 376 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 377 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 378 | check_tfi_usage(&the_bts); |
| 379 | |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 380 | tbf_free(dl_tbf); |
| 381 | tbf_free(ul_tbf); |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Test with the other order.. first DL and then UL |
| 386 | */ |
| 387 | { |
| 388 | BTS the_bts; |
| 389 | struct gprs_rlcmac_bts *bts; |
| 390 | struct gprs_rlcmac_trx *trx; |
Jacob Erlbeck | 1f33294 | 2015-05-04 08:21:17 +0200 | [diff] [blame] | 391 | uint8_t trx_no; |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 392 | |
Daniel Willmann | 351a573 | 2014-08-07 12:57:44 +0200 | [diff] [blame] | 393 | gprs_rlcmac_ul_tbf *ul_tbf; |
| 394 | gprs_rlcmac_dl_tbf *dl_tbf; |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 395 | |
| 396 | bts = the_bts.bts_data(); |
| 397 | bts->alloc_algorithm = alloc_algorithm_b; |
| 398 | |
| 399 | trx = &bts->trx[0]; |
| 400 | ENABLE_PDCH(0, ts0, trx); |
| 401 | ENABLE_PDCH(1, ts1, trx); |
| 402 | ENABLE_PDCH(2, ts2, trx); |
| 403 | ENABLE_PDCH(3, ts3, trx); |
| 404 | ENABLE_PDCH(4, ts4, trx); |
| 405 | ENABLE_PDCH(5, ts5, trx); |
| 406 | ENABLE_PDCH(6, ts6, trx); |
| 407 | ENABLE_PDCH(7, ts7, trx); |
| 408 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 409 | dl_tbf = tbf_alloc_dl_tbf(bts, NULL, -1, ms_class, 1); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 410 | OSMO_ASSERT(dl_tbf); |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 411 | OSMO_ASSERT(dl_tbf->ms()); |
| 412 | OSMO_ASSERT(dl_tbf->ms()->current_trx()); |
| 413 | trx_no = dl_tbf->ms()->current_trx()->trx_no; |
Jacob Erlbeck | 767193e | 2015-05-20 12:06:46 +0200 | [diff] [blame] | 414 | dl_tbf->update_ms(0x23, GPRS_RLCMAC_DL_TBF); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 415 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 416 | ul_tbf = tbf_alloc_ul_tbf(bts, dl_tbf->ms(), trx_no, ms_class, 0); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 417 | OSMO_ASSERT(ul_tbf); |
Jacob Erlbeck | 767193e | 2015-05-20 12:06:46 +0200 | [diff] [blame] | 418 | ul_tbf->update_ms(0x23, GPRS_RLCMAC_UL_TBF); |
Daniel Willmann | 7e994e3 | 2014-08-07 15:49:21 +0200 | [diff] [blame] | 419 | ul_tbf->m_contention_resolution_done = 1; |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 420 | |
| 421 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 422 | |
| 423 | /* now update the dl_tbf */ |
| 424 | dl_tbf->update(); |
| 425 | OSMO_ASSERT(dl_tbf->first_common_ts == ul_tbf->first_common_ts); |
| 426 | |
Jacob Erlbeck | befc760 | 2015-06-02 12:33:30 +0200 | [diff] [blame] | 427 | OSMO_ASSERT(ul_tbf->ms_class() == ms_class); |
| 428 | OSMO_ASSERT(dl_tbf->ms_class() == ms_class); |
| 429 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 430 | check_tfi_usage(&the_bts); |
| 431 | |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 432 | tbf_free(dl_tbf); |
| 433 | tbf_free(ul_tbf); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | static void test_all_alloc_b() |
| 438 | { |
| 439 | /* it is a bit crazy... */ |
| 440 | for (uint8_t ts0 = 0; ts0 < 2; ++ts0) |
| 441 | for (uint8_t ts1 = 0; ts1 < 2; ++ts1) |
| 442 | for (uint8_t ts2 = 0; ts2 < 2; ++ts2) |
| 443 | for (uint8_t ts3 = 0; ts3 < 2; ++ts3) |
| 444 | for (uint8_t ts4 = 0; ts4 < 2; ++ts4) |
| 445 | for (uint8_t ts5 = 0; ts5 < 2; ++ts5) |
| 446 | for (uint8_t ts6 = 0; ts6 < 2; ++ts6) |
| 447 | for (uint8_t ts7 = 0; ts7 < 2; ++ts7) |
| 448 | for (int ms_class = 0; ms_class < 30; ++ms_class) |
| 449 | test_alloc_b(ts0, ts1, ts2, ts3, ts4, ts5, ts6, ts7, ms_class); |
| 450 | } |
| 451 | |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 452 | static void test_alloc_b() |
| 453 | { |
| 454 | for (int i = 0; i < 30; ++i) |
| 455 | test_alloc_b(i); |
Holger Hans Peter Freyther | f3eec04 | 2013-12-26 10:19:18 +0100 | [diff] [blame] | 456 | |
| 457 | test_all_alloc_b(); |
Holger Hans Peter Freyther | c7b998c | 2013-12-25 19:25:10 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 460 | typedef int (*algo_t)(struct gprs_rlcmac_bts *bts, |
| 461 | struct GprsMs *ms, |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 462 | struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single, |
| 463 | int use_trx); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 464 | |
| 465 | static char get_dir_char(uint8_t mask, uint8_t tx, uint8_t rx) |
| 466 | { |
| 467 | return (mask & tx & rx) ? 'C' : |
| 468 | (mask & tx) ? 'U' : |
| 469 | (mask & rx) ? 'D' : |
| 470 | '.'; |
| 471 | } |
| 472 | |
| 473 | enum test_mode { |
| 474 | TEST_MODE_UL_ONLY, |
| 475 | TEST_MODE_DL_ONLY, |
| 476 | TEST_MODE_UL_AND_DL, |
| 477 | TEST_MODE_DL_AND_UL, |
| 478 | TEST_MODE_DL_AFTER_UL, |
| 479 | TEST_MODE_UL_AFTER_DL, |
| 480 | }; |
| 481 | |
| 482 | static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, unsigned ms_class, |
| 483 | enum test_mode mode) |
| 484 | { |
| 485 | struct gprs_rlcmac_bts *bts; |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 486 | uint8_t trx_no = -1; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 487 | |
| 488 | bts = the_bts->bts_data(); |
| 489 | |
| 490 | gprs_rlcmac_tbf *tbf = NULL; |
| 491 | |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 492 | if (ms && ms->current_trx()) |
| 493 | trx_no = ms->current_trx()->trx_no; |
| 494 | |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 495 | /* Allocate what is needed first */ |
| 496 | switch (mode) { |
| 497 | case TEST_MODE_UL_ONLY: |
| 498 | case TEST_MODE_DL_AFTER_UL: |
| 499 | case TEST_MODE_UL_AND_DL: |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 500 | tbf = tbf_alloc_ul_tbf(bts, ms, trx_no, ms_class, 0); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 501 | if (tbf == NULL) |
| 502 | return NULL; |
| 503 | break; |
| 504 | case TEST_MODE_DL_ONLY: |
| 505 | case TEST_MODE_UL_AFTER_DL: |
| 506 | case TEST_MODE_DL_AND_UL: |
Jacob Erlbeck | 5879c64 | 2015-07-10 10:41:36 +0200 | [diff] [blame^] | 507 | tbf = tbf_alloc_dl_tbf(bts, ms, trx_no, ms_class, 0); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 508 | if (tbf == NULL) |
| 509 | return NULL; |
| 510 | } |
| 511 | |
| 512 | OSMO_ASSERT(tbf); |
| 513 | OSMO_ASSERT(tbf->ms()); |
| 514 | OSMO_ASSERT(ms == NULL || ms == tbf->ms()); |
| 515 | ms = tbf->ms(); |
| 516 | |
| 517 | GprsMs::Guard guard(ms); |
| 518 | |
Jacob Erlbeck | 14376a7 | 2015-07-07 11:31:28 +0200 | [diff] [blame] | 519 | /* Continue with what is needed next */ |
| 520 | switch (mode) { |
| 521 | case TEST_MODE_UL_ONLY: |
| 522 | case TEST_MODE_DL_ONLY: |
| 523 | /* We are done */ |
| 524 | break; |
| 525 | |
| 526 | case TEST_MODE_DL_AFTER_UL: |
| 527 | case TEST_MODE_UL_AND_DL: |
| 528 | ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_DL_ONLY); |
| 529 | break; |
| 530 | |
| 531 | case TEST_MODE_UL_AFTER_DL: |
| 532 | case TEST_MODE_DL_AND_UL: |
| 533 | ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_UL_ONLY); |
| 534 | break; |
| 535 | } |
| 536 | |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 537 | /* Optionally delete the TBF */ |
| 538 | switch (mode) { |
| 539 | case TEST_MODE_DL_AFTER_UL: |
| 540 | case TEST_MODE_UL_AFTER_DL: |
| 541 | tbf_free(tbf); |
| 542 | break; |
| 543 | |
| 544 | default: |
| 545 | break; |
| 546 | } |
| 547 | |
Jacob Erlbeck | 14376a7 | 2015-07-07 11:31:28 +0200 | [diff] [blame] | 548 | return ms; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | static void test_successive_allocation(algo_t algo, unsigned min_class, |
| 552 | unsigned max_class, enum test_mode mode, |
| 553 | unsigned expect_num, const char *text) |
| 554 | { |
| 555 | BTS the_bts; |
| 556 | struct gprs_rlcmac_bts *bts; |
| 557 | struct gprs_rlcmac_trx *trx; |
| 558 | unsigned counter; |
| 559 | unsigned ms_class = min_class; |
| 560 | |
| 561 | printf("Going to test assignment with many TBF, %s\n", text); |
| 562 | |
| 563 | bts = the_bts.bts_data(); |
| 564 | bts->alloc_algorithm = algo; |
| 565 | |
| 566 | trx = &bts->trx[0]; |
| 567 | trx->pdch[3].enable(); |
| 568 | trx->pdch[4].enable(); |
| 569 | trx->pdch[5].enable(); |
| 570 | trx->pdch[6].enable(); |
| 571 | trx->pdch[7].enable(); |
| 572 | |
| 573 | for (counter = 0; 1; counter += 1) { |
| 574 | gprs_rlcmac_tbf *ul_tbf, *dl_tbf; |
| 575 | uint8_t ul_slots = 0; |
| 576 | uint8_t dl_slots = 0; |
| 577 | unsigned i; |
| 578 | int tfi = -1; |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 579 | int tfi2; |
| 580 | uint8_t trx2; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 581 | GprsMs *ms; |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 582 | enum gprs_rlcmac_tbf_direction dir; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 583 | |
| 584 | ms = alloc_tbfs(&the_bts, NULL, ms_class, mode); |
| 585 | if (!ms) |
| 586 | break; |
| 587 | |
| 588 | ul_tbf = ms->ul_tbf(); |
| 589 | dl_tbf = ms->dl_tbf(); |
| 590 | |
| 591 | if (ul_tbf) { |
| 592 | ul_slots = 1 << ul_tbf->first_common_ts; |
| 593 | tfi = ul_tbf->tfi(); |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 594 | dir = GPRS_RLCMAC_UL_TBF; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 595 | } else if (dl_tbf) { |
| 596 | ul_slots = 1 << dl_tbf->first_common_ts; |
| 597 | tfi = dl_tbf->tfi(); |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 598 | dir = GPRS_RLCMAC_DL_TBF; |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | for (i = 0; dl_tbf && i < ARRAY_SIZE(dl_tbf->pdch); i += 1) |
| 602 | if (dl_tbf->pdch[i]) |
| 603 | dl_slots |= 1 << i; |
| 604 | |
| 605 | printf(" TBF[%d] class %d reserves %c%c%c%c%c%c%c%c\n", |
| 606 | tfi, ms_class, |
| 607 | get_dir_char(0x01, ul_slots, dl_slots), |
| 608 | get_dir_char(0x02, ul_slots, dl_slots), |
| 609 | get_dir_char(0x04, ul_slots, dl_slots), |
| 610 | get_dir_char(0x08, ul_slots, dl_slots), |
| 611 | get_dir_char(0x10, ul_slots, dl_slots), |
| 612 | get_dir_char(0x20, ul_slots, dl_slots), |
| 613 | get_dir_char(0x40, ul_slots, dl_slots), |
| 614 | get_dir_char(0x80, ul_slots, dl_slots)); |
| 615 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 616 | if (tfi >= 0) { |
| 617 | OSMO_ASSERT(ms->current_trx()); |
| 618 | tfi2 = the_bts.tfi_find_free(dir, &trx2, |
| 619 | ms->current_trx()->trx_no); |
| 620 | OSMO_ASSERT(tfi != tfi2); |
| 621 | OSMO_ASSERT(trx2 == ms->current_trx()->trx_no); |
| 622 | } |
| 623 | |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 624 | ms_class += 1; |
| 625 | if (ms_class > max_class) |
| 626 | ms_class = min_class; |
| 627 | } |
| 628 | |
Jacob Erlbeck | 61205a7 | 2015-07-09 11:35:50 +0200 | [diff] [blame] | 629 | check_tfi_usage(&the_bts); |
| 630 | |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 631 | printf(" Successfully allocated %d UL TBFs\n", counter); |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 632 | OSMO_ASSERT(counter == expect_num); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | static void test_successive_allocation() |
| 636 | { |
| 637 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AND_DL, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 638 | 32, "algorithm A (UL and DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 639 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AND_DL, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 640 | 32, "algorithm B class 10 (UL and DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 641 | test_successive_allocation(alloc_algorithm_b, 12, 12, TEST_MODE_UL_AND_DL, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 642 | 32, "algorithm B class 12 (UL and DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 643 | test_successive_allocation(alloc_algorithm_b, 1, 12, TEST_MODE_UL_AND_DL, |
Jacob Erlbeck | ed46afd | 2015-07-01 12:19:40 +0200 | [diff] [blame] | 644 | 32, "algorithm B class 1-12 (UL and DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 645 | test_successive_allocation(alloc_algorithm_b, 1, 29, TEST_MODE_UL_AND_DL, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 646 | 32, "algorithm B class 1-29 (UL and DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 647 | |
| 648 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_AND_UL, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 649 | 32, "algorithm A (DL and UL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 650 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_AND_UL, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 651 | 32, "algorithm B class 10 (DL and UL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 652 | |
| 653 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_AFTER_UL, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 654 | 32, "algorithm A (DL after UL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 655 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_AFTER_UL, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 656 | 32, "algorithm B class 10 (DL after UL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 657 | |
| 658 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AFTER_DL, |
Jacob Erlbeck | efe62a7 | 2015-07-02 15:48:25 +0200 | [diff] [blame] | 659 | 32, "algorithm A (UL after DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 660 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AFTER_DL, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 661 | 32, "algorithm B class 10 (UL after DL)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 662 | |
| 663 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_ONLY, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 664 | 32, "algorithm A (UL only)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 665 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_ONLY, |
Jacob Erlbeck | 16c6ecc | 2015-06-30 13:40:18 +0200 | [diff] [blame] | 666 | 32, "algorithm B class 10 (UL only)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 667 | |
| 668 | test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_ONLY, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 669 | 32, "algorithm A (DL ONLY)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 670 | test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_ONLY, |
Jacob Erlbeck | ec47875 | 2015-06-19 16:35:38 +0200 | [diff] [blame] | 671 | 32, "algorithm B class 10 (DL ONLY)"); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 672 | } |
| 673 | |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 674 | int main(int argc, char **argv) |
| 675 | { |
| 676 | tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context"); |
| 677 | if (!tall_pcu_ctx) |
| 678 | abort(); |
| 679 | |
| 680 | msgb_set_talloc_ctx(tall_pcu_ctx); |
| 681 | osmo_init_logging(&gprs_log_info); |
| 682 | log_set_use_color(osmo_stderr_target, 0); |
| 683 | log_set_print_filename(osmo_stderr_target, 0); |
Jacob Erlbeck | 9ec49e2 | 2015-06-29 13:00:20 +0200 | [diff] [blame] | 684 | if (getenv("LOGL_DEBUG")) |
| 685 | log_set_log_level(osmo_stderr_target, LOGL_DEBUG); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 686 | |
| 687 | test_alloc_a(); |
Holger Hans Peter Freyther | 4af3053 | 2013-12-25 19:16:55 +0100 | [diff] [blame] | 688 | test_alloc_b(); |
Jacob Erlbeck | e565564 | 2015-06-29 12:19:52 +0200 | [diff] [blame] | 689 | test_successive_allocation(); |
Holger Hans Peter Freyther | bfdd5f2 | 2013-10-16 17:29:31 +0200 | [diff] [blame] | 690 | return EXIT_SUCCESS; |
| 691 | } |
| 692 | |
| 693 | /* |
| 694 | * stubs that should not be reached |
| 695 | */ |
| 696 | extern "C" { |
| 697 | void l1if_pdch_req() { abort(); } |
| 698 | void l1if_connect_pdch() { abort(); } |
| 699 | void l1if_close_pdch() { abort(); } |
| 700 | void l1if_open_pdch() { abort(); } |
| 701 | } |