blob: c9901dfdf095c30aa319af5e701551a6d99de3b5 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm0502.h */
2
Sylvain Munaut12ba7782014-06-16 10:13:40 +02003#pragma once
Harald Welte94df39e2011-06-26 14:33:57 +02004
5#include <stdint.h>
6
7#include <osmocom/gsm/protocol/gsm_04_08.h>
8#include <osmocom/gsm/protocol/gsm_08_58.h>
9
10/* Table 5 Clause 7 TS 05.02 */
11static inline unsigned int
12gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc)
13{
14 if (chan_desc->ccch_conf == RSL_BCCH_CCCH_CONF_1_C)
15 return 3 - chan_desc->bs_ag_blks_res;
16 else
17 return 9 - chan_desc->bs_ag_blks_res;
18}
19
20/* Chapter 6.5.2 of TS 05.02 */
21static inline unsigned int
22gsm0502_get_ccch_group(uint64_t imsi, unsigned int bs_cc_chans,
23 unsigned int n_pag_blocks)
24{
25 return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) / n_pag_blocks;
26}
27
28/* Chapter 6.5.2 of TS 05.02 */
29static inline unsigned int
30gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans,
31 int n_pag_blocks)
32{
33 return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) % n_pag_blocks;
34}
35
Harald Welteea19c972011-06-26 14:47:16 +020036unsigned int
37gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi);
Philipp Maier69e00cc2019-10-09 13:38:38 +020038
39enum gsm0502_fn_remap_channel {
40 FN_REMAP_TCH_F,
41 FN_REMAP_TCH_H0,
42 FN_REMAP_TCH_H1,
43 FN_REMAP_FACCH_F,
44 FN_REMAP_FACCH_H0,
45 FN_REMAP_FACCH_H1,
46 FN_REMAP_MAX,
47};
48
49uint32_t gsm0502_fn_remap(uint32_t fn, enum gsm0502_fn_remap_channel channel);