blob: 27cf825d169769f48de16d147c14decef3777bf2 [file] [log] [blame]
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04001/* 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 Eversberg8b761a32012-07-20 21:50:31 +020023#ifdef __cplusplus
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +040024#include <bitvector.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040025#include <gsm_rlcmac.h>
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +040026#include <gsm_timer.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040027
28extern "C" {
29#include <osmocom/core/linuxlist.h>
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +040030#include <osmocom/core/timer.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040031}
Andreas Eversberg8b761a32012-07-20 21:50:31 +020032#endif
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040033
Andreas Eversberge6228b32012-07-03 13:36:03 +020034/* 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 Kluchnikovc5d8c272012-06-04 21:55:02 +040039
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020040/*
41 * PDCH instanc
42 */
43
44struct gprs_rlcmac_tbf;
45
46struct 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 Eversbergb0c7ea72012-07-13 14:46:03 +020051 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 Eversberg2b914642012-07-19 13:06:26 +020053 struct llist_head paging_list; /* list of paging messages */
Andreas Eversberge6228b32012-07-03 13:36:03 +020054 uint32_t last_rts_fn; /* store last frame number of RTS */
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +040055};
56
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020057struct gprs_rlcmac_trx {
58 uint16_t arfcn;
59 struct gprs_rlcmac_pdch pdch[8];
Andreas Eversbergadb2f182012-08-07 17:06:08 +020060 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 Eversberg5dac2f02012-06-27 15:52:04 +020062};
63
64struct gprs_rlcmac_bts {
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +020065 uint8_t fc_interval;
Andreas Eversbergb3c6f6c2012-07-06 07:40:08 +020066 uint8_t cs1;
67 uint8_t cs2;
68 uint8_t cs3;
69 uint8_t cs4;
70 uint8_t initial_cs;
Andreas Eversberg8b761a32012-07-20 21:50:31 +020071 uint8_t force_cs; /* 0=use from BTS 1=use from VTY */
Andreas Eversberg24131bf2012-07-21 11:09:58 +020072 uint16_t force_llc_lifetime; /* overrides lifetime from SGSN */
Andreas Eversbergb3c6f6c2012-07-06 07:40:08 +020073 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 Eversberg5dac2f02012-06-27 15:52:04 +020081 struct gprs_rlcmac_trx trx[8];
Andreas Eversberg592e04a2012-07-15 06:25:37 +020082 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 Eversberg07e97cf2012-08-07 16:00:56 +020085 uint8_t force_two_phase;
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +020086 uint8_t alpha, gamma;
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020087};
88
89extern struct gprs_rlcmac_bts *gprs_rlcmac_bts;
90
Andreas Eversberg8b761a32012-07-20 21:50:31 +020091#ifdef __cplusplus
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020092/*
93 * TBF instance
94 */
95
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040096#define LLC_MAX_LEN 1543
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020097#define RLC_MAX_SNS 128 /* GPRS, must be power of 2 */
98#define RLC_MAX_WS 64 /* max window size */
Andreas Eversberge6228b32012-07-03 13:36:03 +020099#define RLC_MAX_LEN 54 /* CS-4 including spare bits */
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400100
Andreas Eversberga9be1542012-09-27 09:23:24 +0200101#define Tassign_agch 0,200000 /* waiting after IMM.ASS confirm */
Andreas Eversbergcbcd1242012-08-07 15:48:21 +0200102#define Tassign_pacch 2,0 /* timeout for pacch assigment */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200103
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400104enum gprs_rlcmac_tbf_state {
Andreas Eversberge6228b32012-07-03 13:36:03 +0200105 GPRS_RLCMAC_NULL = 0, /* new created TBF */
106 GPRS_RLCMAC_ASSIGN, /* wait for downlink assignment */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200107 GPRS_RLCMAC_FLOW, /* RLC/MAC flow, ressource needed */
108 GPRS_RLCMAC_FINISHED, /* flow finished, wait for release */
Andreas Eversberge6228b32012-07-03 13:36:03 +0200109 GPRS_RLCMAC_WAIT_RELEASE,/* wait for release or restart of DL TBF */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200110 GPRS_RLCMAC_RELEASING, /* releasing, wait to free TBI/USF */
111};
112
113enum gprs_rlcmac_tbf_poll_state {
114 GPRS_RLCMAC_POLL_NONE = 0,
115 GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
116};
117
Andreas Eversberge6228b32012-07-03 13:36:03 +0200118enum gprs_rlcmac_tbf_dl_ass_state {
119 GPRS_RLCMAC_DL_ASS_NONE = 0,
120 GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */
121 GPRS_RLCMAC_DL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
122};
123
124enum gprs_rlcmac_tbf_ul_ass_state {
125 GPRS_RLCMAC_UL_ASS_NONE = 0,
126 GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
127 GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
128};
129
130enum gprs_rlcmac_tbf_ul_ack_state {
131 GPRS_RLCMAC_UL_ACK_NONE = 0,
132 GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */
133 GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400134};
135
136enum gprs_rlcmac_tbf_direction {
137 GPRS_RLCMAC_DL_TBF,
138 GPRS_RLCMAC_UL_TBF
139};
140
Andreas Eversberg14db19e2012-08-06 15:03:03 +0200141#define GPRS_RLCMAC_FLAG_CCCH 0 /* assignment on CCCH */
142#define GPRS_RLCMAC_FLAG_PACCH 1 /* assignment on PACCH */
143#define GPRS_RLCMAC_FLAG_UL_DATA 2 /* uplink data received */
144#define GPRS_RLCMAC_FLAG_DL_ACK 3 /* downlink acknowledge received */
145#define GPRS_RLCMAC_FLAG_TO_UL_ACK 4
146#define GPRS_RLCMAC_FLAG_TO_DL_ACK 5
147#define GPRS_RLCMAC_FLAG_TO_UL_ASS 6
148#define GPRS_RLCMAC_FLAG_TO_DL_ASS 7
Andreas Eversberga9be1542012-09-27 09:23:24 +0200149#define GPRS_RLCMAC_FLAG_TO_MASK 0xf0 /* timeout bits */
Andreas Eversberg14db19e2012-08-06 15:03:03 +0200150
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400151struct gprs_rlcmac_tbf {
152 struct llist_head list;
153 enum gprs_rlcmac_tbf_state state;
Andreas Eversberg14db19e2012-08-06 15:03:03 +0200154 uint32_t state_flags;
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400155 enum gprs_rlcmac_tbf_direction direction;
156 uint8_t tfi;
157 uint32_t tlli;
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200158 uint8_t tlli_valid;
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200159 uint8_t trx;
160 uint16_t arfcn;
161 uint8_t tsc;
Andreas Eversberg592e04a2012-07-15 06:25:37 +0200162 uint8_t first_ts; /* first TS used by TBF */
163 uint8_t first_common_ts; /* first TS that the phone can send and
164 reveive simultaniously */
165 uint8_t control_ts; /* timeslot control messages and polling */
Andreas Eversbergf298fa82012-07-13 14:50:57 +0200166 uint8_t ms_class;
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200167 struct gprs_rlcmac_pdch *pdch[8]; /* list of PDCHs allocated to TBF */
168 uint16_t ta;
Andreas Eversberge6228b32012-07-03 13:36:03 +0200169 uint8_t llc_frame[LLC_MAX_LEN]; /* current DL or UL frame */
170 uint16_t llc_index; /* current write/read position of frame */
171 uint16_t llc_length; /* len of current DL LLC_frame, 0 == no frame */
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200172 struct llist_head llc_queue; /* queued LLC DL data */
Andreas Eversberge6228b32012-07-03 13:36:03 +0200173
174 enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
175 enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
176 enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200177
178 enum gprs_rlcmac_tbf_poll_state poll_state;
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200179 uint32_t poll_fn; /* frame number to poll */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200180
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200181 uint16_t ws; /* window size */
182 uint16_t sns; /* sequence number space */
Andreas Eversberge6228b32012-07-03 13:36:03 +0200183
184 /* Please note that all variables here will be reset when changing
185 * from WAIT RELEASE back to FLOW state (re-use of TBF).
186 * All states that need reset must be in this struct, so this is why
187 * variables are in both (dl and ul) structs and not outside union.
188 */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200189 union {
190 struct {
Andreas Eversberge6228b32012-07-03 13:36:03 +0200191 uint16_t bsn; /* block sequence number */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200192 uint16_t v_s; /* send state */
193 uint16_t v_a; /* ack state */
194 char v_b[RLC_MAX_SNS/2]; /* acknowledge state array */
Andreas Eversberge6228b32012-07-03 13:36:03 +0200195 int32_t tx_counter; /* count all transmitted blocks */
Andreas Eversberga9be1542012-09-27 09:23:24 +0200196 char imsi[16]; /* store IMSI for PCH retransmission */
197 uint8_t wait_confirm; /* wait for CCCH IMM.ASS cnf */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200198 } dl;
199 struct {
Andreas Eversberge6228b32012-07-03 13:36:03 +0200200 uint16_t bsn; /* block sequence number */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200201 uint16_t v_r; /* receive state */
202 uint16_t v_q; /* receive window state */
203 char v_n[RLC_MAX_SNS/2]; /* receive state array */
204 int32_t rx_counter; /* count all received blocks */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200205 uint8_t n3103; /* N3103 counter */
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200206 uint8_t usf[8]; /* list USFs per PDCH (timeslot) */
Andreas Eversberg08e93cd2012-07-26 08:13:06 +0200207 uint8_t contention_resolution_done; /* set after done */
208 uint8_t final_ack_sent; /* set if we sent final ack */
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200209 } ul;
210 } dir;
211 uint8_t rlc_block[RLC_MAX_SNS/2][RLC_MAX_LEN]; /* block history */
212 uint8_t rlc_block_len[RLC_MAX_SNS/2]; /* block len of history */
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +0400213
Andreas Eversberg802bb6e2012-08-06 11:15:05 +0200214 uint8_t n3105; /* N3105 counter */
215
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +0400216 struct osmo_timer_list timer;
217 unsigned int T; /* Txxxx number */
218 unsigned int num_T_exp; /* number of consecutive T expirations */
219
220 struct osmo_gsm_timer_list gsm_timer;
221 unsigned int fT; /* fTxxxx number */
222 unsigned int num_fT_exp; /* number of consecutive fT expirations */
Andreas Eversbergb3ded4c2012-07-24 10:47:24 +0200223
224 struct timeval bw_tv; /* timestamp for bandwidth calculation */
225 uint32_t bw_octets; /* number of octets transmitted since bw_tv */
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400226};
227
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200228extern struct llist_head gprs_rlcmac_ul_tbfs; /* list of uplink TBFs */
229extern struct llist_head gprs_rlcmac_dl_tbfs; /* list of downlink TBFs */
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200230extern struct llist_head gprs_rlcmac_sbas; /* list of single block allocs */
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400231
Andreas Eversberg2b914642012-07-19 13:06:26 +0200232/*
233 * paging entry
234 */
235struct gprs_rlcmac_paging {
236 struct llist_head list;
237 uint8_t chan_needed;
238 uint8_t identity_lv[9];
239};
240
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200241/*
242 * single block allocation entry
243 */
244struct gprs_rlcmac_sba {
245 struct llist_head list;
246 uint8_t trx;
247 uint8_t ts;
248 uint32_t fn;
249 uint8_t ta;
250};
251
252int sba_alloc(uint8_t *_trx, uint8_t *_ts, uint32_t *_fn, uint8_t ta);
253
254struct gprs_rlcmac_sba *sba_find(uint8_t trx, uint8_t ts, uint32_t fn);
255
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200256int tfi_alloc(enum gprs_rlcmac_tbf_direction dir, uint8_t *_trx, uint8_t *_ts,
Andreas Eversberg309ce742012-08-07 15:31:16 +0200257 int8_t use_trx, int8_t first_ts);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400258
Andreas Eversberg592e04a2012-07-15 06:25:37 +0200259struct gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_tbf *old_tbf,
260 enum gprs_rlcmac_tbf_direction dir, uint8_t tfi, uint8_t trx,
261 uint8_t first_ts, uint8_t ms_class, uint8_t single_slot);
Andreas Eversbergf298fa82012-07-13 14:50:57 +0200262
Andreas Eversbergadb2f182012-08-07 17:06:08 +0200263struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, uint8_t trx,
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200264 enum gprs_rlcmac_tbf_direction dir);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400265
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200266struct gprs_rlcmac_tbf *tbf_by_tlli(uint32_t tlli,
267 enum gprs_rlcmac_tbf_direction dir);
Andreas Eversberge6228b32012-07-03 13:36:03 +0200268
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200269struct gprs_rlcmac_tbf *tbf_by_poll_fn(uint32_t fn, uint8_t trx, uint8_t ts);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400270
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200271void tbf_free(struct gprs_rlcmac_tbf *tbf);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400272
Andreas Eversberg592e04a2012-07-15 06:25:37 +0200273int tbf_update(struct gprs_rlcmac_tbf *tbf);
274
275int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
276
Andreas Eversberge6228b32012-07-03 13:36:03 +0200277void tbf_new_state(struct gprs_rlcmac_tbf *tbf,
278 enum gprs_rlcmac_tbf_state state);
279
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200280void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T,
Andreas Eversberge6228b32012-07-03 13:36:03 +0200281 unsigned int seconds, unsigned int microseconds);
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200282
283void tbf_timer_stop(struct gprs_rlcmac_tbf *tbf);
284
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400285/* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */
286enum gprs_rlcmac_block_type {
287 GPRS_RLCMAC_DATA_BLOCK = 0x0,
288 GPRS_RLCMAC_CONTROL_BLOCK = 0x1,
289 GPRS_RLCMAC_CONTROL_BLOCK_OPT = 0x2,
290 GPRS_RLCMAC_RESERVED = 0x3
291};
292
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200293int gprs_rlcmac_rcv_block(uint8_t trx, uint8_t ts, uint8_t *data, uint8_t len,
294 uint32_t fn);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400295
Andreas Eversberge6228b32012-07-03 13:36:03 +0200296int write_immediate_assignment(bitvec * dest, uint8_t downlink, uint8_t ra,
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200297 uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts, uint8_t tsc,
Andreas Eversberge6228b32012-07-03 13:36:03 +0200298 uint8_t tfi, uint8_t usf, uint32_t tlli, uint8_t polling,
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200299 uint32_t fn, uint8_t single_block, uint8_t alpha, uint8_t gamma);
Ivan Kluchnikovcf7b3a52012-06-26 16:54:22 +0400300
Andreas Eversberge6228b32012-07-03 13:36:03 +0200301void write_packet_uplink_assignment(bitvec * dest, uint8_t old_tfi,
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200302 uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200303 struct gprs_rlcmac_tbf *tbf, uint8_t poll, uint8_t alpha,
304 uint8_t gamma);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400305
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400306void write_packet_downlink_assignment(RlcMacDownlink_t * block, uint8_t old_tfi,
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200307 uint8_t old_downlink, struct gprs_rlcmac_tbf *tbf, uint8_t poll,
308 uint8_t alpha, uint8_t gamma);
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200309
310
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400311
Ivan Kluchnikovef7f28c2012-07-12 14:49:15 +0400312void write_packet_uplink_ack(RlcMacDownlink_t * block, struct gprs_rlcmac_tbf *tbf,
Andreas Eversberge6228b32012-07-03 13:36:03 +0200313 uint8_t final);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400314
Andreas Eversberg3e372d52012-07-06 09:28:15 +0200315int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400316
Andreas Eversberge6228b32012-07-03 13:36:03 +0200317void tbf_timer_cb(void *_tbf);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +0400318
Andreas Eversberge6228b32012-07-03 13:36:03 +0200319int gprs_rlcmac_poll_timeout(struct gprs_rlcmac_tbf *tbf);
Andreas Eversberg0aed6542012-06-23 10:33:16 +0200320
321int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, int16_t qta);
Ivan Kluchnikov5310d452012-04-17 22:00:31 +0400322
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200323int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
324 uint32_t fn);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400325
Andreas Eversberge6228b32012-07-03 13:36:03 +0200326struct msgb *gprs_rlcmac_send_packet_uplink_assignment(
327 struct gprs_rlcmac_tbf *tbf, uint32_t fn);
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400328
Andreas Eversberge6228b32012-07-03 13:36:03 +0200329struct msgb *gprs_rlcmac_send_packet_downlink_assignment(
330 struct gprs_rlcmac_tbf *tbf, uint32_t fn);
Ivan Kluchnikovc320d862012-03-18 15:04:48 +0400331
Andreas Eversberg7f5352c2012-07-23 18:20:36 +0200332void gprs_rlcmac_trigger_downlink_assignment(struct gprs_rlcmac_tbf *tbf,
333 struct gprs_rlcmac_tbf *old_tbf, char *imsi);
Ivan Kluchnikovc7e7f682012-06-29 22:53:15 +0400334
Andreas Eversberge6228b32012-07-03 13:36:03 +0200335int gprs_rlcmac_downlink_ack(struct gprs_rlcmac_tbf *tbf, uint8_t final,
336 uint8_t ssn, uint8_t *rbb);
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200337
Andreas Eversberg2b914642012-07-19 13:06:26 +0200338unsigned write_packet_paging_request(bitvec * dest);
339
340unsigned write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len,
341 uint8_t *identity, uint8_t chan_needed);
342
Andreas Eversbergb0c7ea72012-07-13 14:46:03 +0200343int gprs_rlcmac_rcv_data_block_acknowledged(uint8_t trx, uint8_t ts,
344 uint8_t *data, uint8_t len);
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200345
Andreas Eversberge6228b32012-07-03 13:36:03 +0200346struct msgb *gprs_rlcmac_send_data_block_acknowledged(
Andreas Eversberg592e04a2012-07-15 06:25:37 +0200347 struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts);
Andreas Eversberge6228b32012-07-03 13:36:03 +0200348
Andreas Eversberg5dac2f02012-06-27 15:52:04 +0200349struct msgb *gprs_rlcmac_send_uplink_ack(struct gprs_rlcmac_tbf *tbf,
350 uint32_t fn);
Ivan Kluchnikov9c795ab2012-05-24 23:12:59 +0400351
Andreas Eversberge6228b32012-07-03 13:36:03 +0200352int gprs_rlcmac_rcv_rts_block(uint8_t trx, uint8_t ts, uint16_t arfcn,
353 uint32_t fn, uint8_t block_nr);
354
Andreas Eversberga9be1542012-09-27 09:23:24 +0200355int gprs_rlcmac_imm_ass_cnf(uint8_t *data, uint32_t fn);
356
Andreas Eversberg2b914642012-07-19 13:06:26 +0200357int gprs_rlcmac_add_paging(uint8_t chan_needed, uint8_t *identity_lv);
358
359struct gprs_rlcmac_paging *gprs_rlcmac_dequeue_paging(
360 struct gprs_rlcmac_pdch *pdch);
361
362struct msgb *gprs_rlcmac_send_packet_paging_request(
363 struct gprs_rlcmac_pdch *pdch);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200364
365extern "C" {
366#endif
367int alloc_algorithm_a(struct gprs_rlcmac_tbf *old_tbf,
368 struct gprs_rlcmac_tbf *tbf, uint32_t cust);
369
370int alloc_algorithm_b(struct gprs_rlcmac_tbf *old_tbf,
371 struct gprs_rlcmac_tbf *tbf, uint32_t cust);
372#ifdef __cplusplus
373}
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200374#endif
Andreas Eversberg2b914642012-07-19 13:06:26 +0200375
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400376#endif // GPRS_RLCMAC_H