Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 1 | /* gprs_rlcmac.h |
| 2 | * |
| 3 | * Copyright (C) 2012 Ivan Klyuchnikov |
| 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 | #ifndef GPRS_RLCMAC_H |
| 21 | #define GPRS_RLCMAC_H |
| 22 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 23 | #ifdef __cplusplus |
Ivan Kluchnikov | 835f91e | 2012-04-30 18:00:36 +0400 | [diff] [blame] | 24 | #include <bitvector.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 25 | #include <gsm_rlcmac.h> |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame] | 26 | #include <gsm_timer.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 27 | |
| 28 | extern "C" { |
| 29 | #include <osmocom/core/linuxlist.h> |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame] | 30 | #include <osmocom/core/timer.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 31 | } |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 32 | #endif |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 33 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 34 | /* This special feature will delay assignment of downlink TBF by one second, |
| 35 | * in case there is already a TBF. |
| 36 | * This is usefull to debug downlink establishment during packet idle mode. |
| 37 | */ |
| 38 | //#define DEBUG_DL_ASS_IDLE |
Ivan Kluchnikov | c5d8c27 | 2012-06-04 21:55:02 +0400 | [diff] [blame] | 39 | |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 40 | /* |
| 41 | * PDCH instanc |
| 42 | */ |
| 43 | |
| 44 | struct gprs_rlcmac_tbf; |
| 45 | |
| 46 | struct gprs_rlcmac_pdch { |
| 47 | uint8_t enable; /* TS is enabled */ |
| 48 | uint8_t tsc; /* TSC of this slot */ |
| 49 | uint8_t next_ul_tfi; /* next uplink TBF/TFI to schedule (0..31) */ |
| 50 | uint8_t next_dl_tfi; /* next downlink TBF/TFI to schedule (0..31) */ |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 51 | struct gprs_rlcmac_tbf *ul_tbf[32]; /* array of UL TBF, by UL TFI */ |
| 52 | struct gprs_rlcmac_tbf *dl_tbf[32]; /* array of DL TBF, by DL TFI */ |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 53 | struct llist_head paging_list; /* list of paging messages */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 54 | uint32_t last_rts_fn; /* store last frame number of RTS */ |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 55 | }; |
| 56 | |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 57 | struct gprs_rlcmac_trx { |
| 58 | uint16_t arfcn; |
| 59 | struct gprs_rlcmac_pdch pdch[8]; |
Andreas Eversberg | adb2f18 | 2012-08-07 17:06:08 +0200 | [diff] [blame] | 60 | struct gprs_rlcmac_tbf *ul_tbf[32]; /* array of UL TBF, by UL TFI */ |
| 61 | struct gprs_rlcmac_tbf *dl_tbf[32]; /* array of DL TBF, by DL TFI */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | struct gprs_rlcmac_bts { |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 65 | uint8_t fc_interval; |
Andreas Eversberg | b3c6f6c | 2012-07-06 07:40:08 +0200 | [diff] [blame] | 66 | uint8_t cs1; |
| 67 | uint8_t cs2; |
| 68 | uint8_t cs3; |
| 69 | uint8_t cs4; |
| 70 | uint8_t initial_cs; |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 71 | uint8_t force_cs; /* 0=use from BTS 1=use from VTY */ |
Andreas Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 72 | uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */ |
Andreas Eversberg | b3c6f6c | 2012-07-06 07:40:08 +0200 | [diff] [blame] | 73 | uint8_t t3142; |
| 74 | uint8_t t3169; |
| 75 | uint8_t t3191; |
| 76 | uint16_t t3193_msec; |
| 77 | uint8_t t3195; |
| 78 | uint8_t n3101; |
| 79 | uint8_t n3103; |
| 80 | uint8_t n3105; |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 81 | struct gprs_rlcmac_trx trx[8]; |
Andreas Eversberg | 592e04a | 2012-07-15 06:25:37 +0200 | [diff] [blame] | 82 | int (*alloc_algorithm)(struct gprs_rlcmac_tbf *old_tbf, |
| 83 | struct gprs_rlcmac_tbf *tbf, uint32_t cust); |
| 84 | uint32_t alloc_algorithm_curst; /* options to customize algorithm */ |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 85 | uint8_t force_two_phase; |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | extern struct gprs_rlcmac_bts *gprs_rlcmac_bts; |
| 89 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 90 | #ifdef __cplusplus |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 91 | /* |
| 92 | * TBF instance |
| 93 | */ |
| 94 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 95 | #define LLC_MAX_LEN 1543 |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 96 | #define RLC_MAX_SNS 128 /* GPRS, must be power of 2 */ |
| 97 | #define RLC_MAX_WS 64 /* max window size */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 98 | #define RLC_MAX_LEN 54 /* CS-4 including spare bits */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 99 | |
Andreas Eversberg | cbcd124 | 2012-08-07 15:48:21 +0200 | [diff] [blame] | 100 | #define Tassign_agch 0,800000 /* FIXME: we need a confirm from BTS */ |
| 101 | #define Tassign_pacch 2,0 /* timeout for pacch assigment */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 102 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 103 | enum gprs_rlcmac_tbf_state { |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 104 | GPRS_RLCMAC_NULL = 0, /* new created TBF */ |
| 105 | GPRS_RLCMAC_ASSIGN, /* wait for downlink assignment */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 106 | GPRS_RLCMAC_FLOW, /* RLC/MAC flow, ressource needed */ |
| 107 | GPRS_RLCMAC_FINISHED, /* flow finished, wait for release */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 108 | GPRS_RLCMAC_WAIT_RELEASE,/* wait for release or restart of DL TBF */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 109 | GPRS_RLCMAC_RELEASING, /* releasing, wait to free TBI/USF */ |
| 110 | }; |
| 111 | |
| 112 | enum gprs_rlcmac_tbf_poll_state { |
| 113 | GPRS_RLCMAC_POLL_NONE = 0, |
| 114 | GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */ |
| 115 | }; |
| 116 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 117 | enum gprs_rlcmac_tbf_dl_ass_state { |
| 118 | GPRS_RLCMAC_DL_ASS_NONE = 0, |
| 119 | GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */ |
| 120 | GPRS_RLCMAC_DL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 121 | }; |
| 122 | |
| 123 | enum gprs_rlcmac_tbf_ul_ass_state { |
| 124 | GPRS_RLCMAC_UL_ASS_NONE = 0, |
| 125 | GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */ |
| 126 | GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 127 | }; |
| 128 | |
| 129 | enum gprs_rlcmac_tbf_ul_ack_state { |
| 130 | GPRS_RLCMAC_UL_ACK_NONE = 0, |
| 131 | GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */ |
| 132 | GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | enum gprs_rlcmac_tbf_direction { |
| 136 | GPRS_RLCMAC_DL_TBF, |
| 137 | GPRS_RLCMAC_UL_TBF |
| 138 | }; |
| 139 | |
Andreas Eversberg | 14db19e | 2012-08-06 15:03:03 +0200 | [diff] [blame] | 140 | #define GPRS_RLCMAC_FLAG_CCCH 0 /* assignment on CCCH */ |
| 141 | #define GPRS_RLCMAC_FLAG_PACCH 1 /* assignment on PACCH */ |
| 142 | #define GPRS_RLCMAC_FLAG_UL_DATA 2 /* uplink data received */ |
| 143 | #define GPRS_RLCMAC_FLAG_DL_ACK 3 /* downlink acknowledge received */ |
| 144 | #define GPRS_RLCMAC_FLAG_TO_UL_ACK 4 |
| 145 | #define GPRS_RLCMAC_FLAG_TO_DL_ACK 5 |
| 146 | #define GPRS_RLCMAC_FLAG_TO_UL_ASS 6 |
| 147 | #define GPRS_RLCMAC_FLAG_TO_DL_ASS 7 |
| 148 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 149 | struct gprs_rlcmac_tbf { |
| 150 | struct llist_head list; |
| 151 | enum gprs_rlcmac_tbf_state state; |
Andreas Eversberg | 14db19e | 2012-08-06 15:03:03 +0200 | [diff] [blame] | 152 | uint32_t state_flags; |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 153 | enum gprs_rlcmac_tbf_direction direction; |
| 154 | uint8_t tfi; |
| 155 | uint32_t tlli; |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 156 | uint8_t tlli_valid; |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 157 | uint8_t trx; |
| 158 | uint16_t arfcn; |
| 159 | uint8_t tsc; |
Andreas Eversberg | 592e04a | 2012-07-15 06:25:37 +0200 | [diff] [blame] | 160 | uint8_t first_ts; /* first TS used by TBF */ |
| 161 | uint8_t first_common_ts; /* first TS that the phone can send and |
| 162 | reveive simultaniously */ |
| 163 | uint8_t control_ts; /* timeslot control messages and polling */ |
Andreas Eversberg | f298fa8 | 2012-07-13 14:50:57 +0200 | [diff] [blame] | 164 | uint8_t ms_class; |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 165 | struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */ |
| 166 | uint16_t ta; |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 167 | uint8_t llc_frame[LLC_MAX_LEN]; /* current DL or UL frame */ |
| 168 | uint16_t llc_index; /* current write/read position of frame */ |
| 169 | uint16_t llc_length; /* len of current DL LLC_frame, 0 == no frame */ |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 170 | struct llist_head llc_queue; /* queued LLC DL data */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 171 | |
| 172 | enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state; |
| 173 | enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state; |
| 174 | enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state; |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 175 | |
| 176 | enum gprs_rlcmac_tbf_poll_state poll_state; |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 177 | uint32_t poll_fn; /* frame number to poll */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 178 | |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 179 | uint16_t ws; /* window size */ |
| 180 | uint16_t sns; /* sequence number space */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 181 | |
| 182 | /* Please note that all variables here will be reset when changing |
| 183 | * from WAIT RELEASE back to FLOW state (re-use of TBF). |
| 184 | * All states that need reset must be in this struct, so this is why |
| 185 | * variables are in both (dl and ul) structs and not outside union. |
| 186 | */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 187 | union { |
| 188 | struct { |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 189 | uint16_t bsn; /* block sequence number */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 190 | uint16_t v_s; /* send state */ |
| 191 | uint16_t v_a; /* ack state */ |
| 192 | char v_b[RLC_MAX_SNS/2]; /* acknowledge state array */ |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 193 | int32_t tx_counter; /* count all transmitted blocks */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 194 | } dl; |
| 195 | struct { |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 196 | uint16_t bsn; /* block sequence number */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 197 | uint16_t v_r; /* receive state */ |
| 198 | uint16_t v_q; /* receive window state */ |
| 199 | char v_n[RLC_MAX_SNS/2]; /* receive state array */ |
| 200 | int32_t rx_counter; /* count all received blocks */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 201 | uint8_t n3103; /* N3103 counter */ |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 202 | uint8_t usf[8]; /* list USFs per PDCH (timeslot) */ |
Andreas Eversberg | 08e93cd | 2012-07-26 08:13:06 +0200 | [diff] [blame] | 203 | uint8_t contention_resolution_done; /* set after done */ |
| 204 | uint8_t final_ack_sent; /* set if we sent final ack */ |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 205 | } ul; |
| 206 | } dir; |
| 207 | uint8_t rlc_block[RLC_MAX_SNS/2][RLC_MAX_LEN]; /* block history */ |
| 208 | uint8_t rlc_block_len[RLC_MAX_SNS/2]; /* block len of history */ |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame] | 209 | |
Andreas Eversberg | 802bb6e | 2012-08-06 11:15:05 +0200 | [diff] [blame] | 210 | uint8_t n3105; /* N3105 counter */ |
| 211 | |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame] | 212 | struct osmo_timer_list timer; |
| 213 | unsigned int T; /* Txxxx number */ |
| 214 | unsigned int num_T_exp; /* number of consecutive T expirations */ |
| 215 | |
| 216 | struct osmo_gsm_timer_list gsm_timer; |
| 217 | unsigned int fT; /* fTxxxx number */ |
| 218 | unsigned int num_fT_exp; /* number of consecutive fT expirations */ |
Andreas Eversberg | b3ded4c | 2012-07-24 10:47:24 +0200 | [diff] [blame] | 219 | |
| 220 | struct timeval bw_tv; /* timestamp for bandwidth calculation */ |
| 221 | uint32_t bw_octets; /* number of octets transmitted since bw_tv */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 222 | }; |
| 223 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 224 | extern struct llist_head gprs_rlcmac_ul_tbfs; /* list of uplink TBFs */ |
| 225 | extern struct llist_head gprs_rlcmac_dl_tbfs; /* list of downlink TBFs */ |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 226 | extern struct llist_head gprs_rlcmac_sbas; /* list of single block allocs */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 227 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 228 | /* |
| 229 | * paging entry |
| 230 | */ |
| 231 | struct gprs_rlcmac_paging { |
| 232 | struct llist_head list; |
| 233 | uint8_t chan_needed; |
| 234 | uint8_t identity_lv[9]; |
| 235 | }; |
| 236 | |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 237 | /* |
| 238 | * single block allocation entry |
| 239 | */ |
| 240 | struct gprs_rlcmac_sba { |
| 241 | struct llist_head list; |
| 242 | uint8_t trx; |
| 243 | uint8_t ts; |
| 244 | uint32_t fn; |
| 245 | uint8_t ta; |
| 246 | }; |
| 247 | |
| 248 | int sba_alloc(uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta); |
| 249 | |
| 250 | struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn); |
| 251 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 252 | int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts, |
Andreas Eversberg | 309ce74 | 2012-08-07 15:31:16 +0200 | [diff] [blame] | 253 | int8_t use_trx, int8_t first_ts); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 254 | |
Andreas Eversberg | 592e04a | 2012-07-15 06:25:37 +0200 | [diff] [blame] | 255 | struct gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_tbf *old_tbf, |
| 256 | enum gprs_rlcmac_tbf_direction dir, uint8_t tfi, uint8_t trx, |
| 257 | uint8_t first_ts, uint8_t ms_class, uint8_t single_slot); |
Andreas Eversberg | f298fa8 | 2012-07-13 14:50:57 +0200 | [diff] [blame] | 258 | |
Andreas Eversberg | adb2f18 | 2012-08-07 17:06:08 +0200 | [diff] [blame] | 259 | struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx, |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 260 | enum gprs_rlcmac_tbf_direction dir); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 261 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 262 | struct gprs_rlcmac_tbf *tbf_by_tlli(uint32_t tlli, |
| 263 | enum gprs_rlcmac_tbf_direction dir); |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 264 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 265 | struct gprs_rlcmac_tbf *tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 266 | |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 267 | void tbf_free(struct gprs_rlcmac_tbf *tbf); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 268 | |
Andreas Eversberg | 592e04a | 2012-07-15 06:25:37 +0200 | [diff] [blame] | 269 | int tbf_update(struct gprs_rlcmac_tbf *tbf); |
| 270 | |
| 271 | int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf); |
| 272 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 273 | void tbf_new_state(struct gprs_rlcmac_tbf *tbf, |
| 274 | enum gprs_rlcmac_tbf_state state); |
| 275 | |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 276 | void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T, |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 277 | unsigned int seconds, unsigned int microseconds); |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 278 | |
| 279 | void tbf_timer_stop(struct gprs_rlcmac_tbf *tbf); |
| 280 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 281 | /* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */ |
| 282 | enum gprs_rlcmac_block_type { |
| 283 | GPRS_RLCMAC_DATA_BLOCK = 0x0, |
| 284 | GPRS_RLCMAC_CONTROL_BLOCK = 0x1, |
| 285 | GPRS_RLCMAC_CONTROL_BLOCK_OPT = 0x2, |
| 286 | GPRS_RLCMAC_RESERVED = 0x3 |
| 287 | }; |
| 288 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 289 | int gprs_rlcmac_rcv_block(uint8_t trx, uint8_t ts, uint8_t *data, uint8_t len, |
| 290 | uint32_t fn); |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 291 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 292 | int write_immediate_assignment(bitvec * dest, uint8_t downlink, uint8_t ra, |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 293 | uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts, uint8_t tsc, |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 294 | uint8_t tfi, uint8_t usf, uint32_t tlli, uint8_t polling, |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 295 | uint32_t fn, uint8_t single_block); |
Ivan Kluchnikov | cf7b3a5 | 2012-06-26 16:54:22 +0400 | [diff] [blame] | 296 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 297 | void write_packet_uplink_assignment(bitvec * dest, uint8_t old_tfi, |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 298 | uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli, |
| 299 | struct gprs_rlcmac_tbf *tbf, uint8_t poll); |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 300 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 301 | void write_packet_downlink_assignment(RlcMacDownlink_t * block, uint8_t old_tfi, |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 302 | uint8_t old_downlink, struct gprs_rlcmac_tbf *tbf, uint8_t poll); |
| 303 | |
| 304 | |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 305 | |
Ivan Kluchnikov | ef7f28c | 2012-07-12 14:49:15 +0400 | [diff] [blame] | 306 | void write_packet_uplink_ack(RlcMacDownlink_t * block, struct gprs_rlcmac_tbf *tbf, |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 307 | uint8_t final); |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 308 | |
Andreas Eversberg | 3e372d5 | 2012-07-06 09:28:15 +0200 | [diff] [blame] | 309 | int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf); |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 310 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 311 | void tbf_timer_cb(void *_tbf); |
Ivan Kluchnikov | a9e6dc5 | 2012-06-17 08:30:06 +0400 | [diff] [blame] | 312 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 313 | int gprs_rlcmac_poll_timeout(struct gprs_rlcmac_tbf *tbf); |
Andreas Eversberg | 0aed654 | 2012-06-23 10:33:16 +0200 | [diff] [blame] | 314 | |
| 315 | int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta); |
Ivan Kluchnikov | 5310d45 | 2012-04-17 22:00:31 +0400 | [diff] [blame] | 316 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 317 | int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts, |
| 318 | uint32_t fn); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 319 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 320 | struct msgb *gprs_rlcmac_send_packet_uplink_assignment( |
| 321 | struct gprs_rlcmac_tbf *tbf, uint32_t fn); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 322 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 323 | struct msgb *gprs_rlcmac_send_packet_downlink_assignment( |
| 324 | struct gprs_rlcmac_tbf *tbf, uint32_t fn); |
Ivan Kluchnikov | c320d86 | 2012-03-18 15:04:48 +0400 | [diff] [blame] | 325 | |
Andreas Eversberg | 7f5352c | 2012-07-23 18:20:36 +0200 | [diff] [blame] | 326 | void gprs_rlcmac_trigger_downlink_assignment(struct gprs_rlcmac_tbf *tbf, |
| 327 | struct gprs_rlcmac_tbf *old_tbf, char *imsi); |
Ivan Kluchnikov | c7e7f68 | 2012-06-29 22:53:15 +0400 | [diff] [blame] | 328 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 329 | int gprs_rlcmac_downlink_ack(struct gprs_rlcmac_tbf *tbf, uint8_t final, |
| 330 | uint8_t ssn, uint8_t *rbb); |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 331 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 332 | unsigned write_packet_paging_request(bitvec * dest); |
| 333 | |
| 334 | unsigned write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len, |
| 335 | uint8_t *identity, uint8_t chan_needed); |
| 336 | |
Andreas Eversberg | b0c7ea7 | 2012-07-13 14:46:03 +0200 | [diff] [blame] | 337 | int gprs_rlcmac_rcv_data_block_acknowledged(uint8_t trx, uint8_t ts, |
| 338 | uint8_t *data, uint8_t len); |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 339 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 340 | struct msgb *gprs_rlcmac_send_data_block_acknowledged( |
Andreas Eversberg | 592e04a | 2012-07-15 06:25:37 +0200 | [diff] [blame] | 341 | struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts); |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 342 | |
Andreas Eversberg | 5dac2f0 | 2012-06-27 15:52:04 +0200 | [diff] [blame] | 343 | struct msgb *gprs_rlcmac_send_uplink_ack(struct gprs_rlcmac_tbf *tbf, |
| 344 | uint32_t fn); |
Ivan Kluchnikov | 9c795ab | 2012-05-24 23:12:59 +0400 | [diff] [blame] | 345 | |
Andreas Eversberg | e6228b3 | 2012-07-03 13:36:03 +0200 | [diff] [blame] | 346 | int gprs_rlcmac_rcv_rts_block(uint8_t trx, uint8_t ts, uint16_t arfcn, |
| 347 | uint32_t fn, uint8_t block_nr); |
| 348 | |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 349 | int gprs_rlcmac_add_paging(uint8_t chan_needed, uint8_t *identity_lv); |
| 350 | |
| 351 | struct gprs_rlcmac_paging *gprs_rlcmac_dequeue_paging( |
| 352 | struct gprs_rlcmac_pdch *pdch); |
| 353 | |
| 354 | struct msgb *gprs_rlcmac_send_packet_paging_request( |
| 355 | struct gprs_rlcmac_pdch *pdch); |
Andreas Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 356 | |
| 357 | extern "C" { |
| 358 | #endif |
| 359 | int alloc_algorithm_a(struct gprs_rlcmac_tbf *old_tbf, |
| 360 | struct gprs_rlcmac_tbf *tbf, uint32_t cust); |
| 361 | |
| 362 | int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf, |
| 363 | struct gprs_rlcmac_tbf *tbf, uint32_t cust); |
| 364 | #ifdef __cplusplus |
| 365 | } |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 366 | #endif |
Andreas Eversberg | 2b91464 | 2012-07-19 13:06:26 +0200 | [diff] [blame] | 367 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 368 | #endif // GPRS_RLCMAC_H |