blob: 0f6998545415cd1baa6981e939fba951b2fc273f [file] [log] [blame]
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04001/* gprs_rlcmac.h
2 *
3 * Copyright (C) 2012 Ivan Klyuchnikov
Holger Hans Peter Freytherd6bd91e2013-08-24 21:16:55 +02004 * Copyright (C) 2013 by Holger Hans Peter Freyther
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +04005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#ifndef GPRS_RLCMAC_H
22#define GPRS_RLCMAC_H
23
Andreas Eversberg8b761a32012-07-20 21:50:31 +020024#ifdef __cplusplus
Ivan Kluchnikov835f91e2012-04-30 18:00:36 +040025#include <bitvector.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040026#include <gsm_rlcmac.h>
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +040027#include <gsm_timer.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040028
29extern "C" {
30#include <osmocom/core/linuxlist.h>
Ivan Kluchnikov61a33f72012-04-12 15:22:06 +040031#include <osmocom/core/timer.h>
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040032}
Andreas Eversberg8b761a32012-07-20 21:50:31 +020033#endif
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040034
Andreas Eversbergb83e2a72012-10-07 15:26:00 +020035/* generate a diagram for debugging timing issues */
36//#define DEBUG_DIAGRAM
37
Andreas Eversberge6228b32012-07-03 13:36:03 +020038/* This special feature will delay assignment of downlink TBF by one second,
39 * in case there is already a TBF.
40 * This is usefull to debug downlink establishment during packet idle mode.
41 */
42//#define DEBUG_DL_ASS_IDLE
Ivan Kluchnikovc5d8c272012-06-04 21:55:02 +040043
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020044
45struct gprs_rlcmac_tbf;
Holger Hans Peter Freytherb6acfda2013-10-17 19:41:11 +020046struct gprs_rlcmac_bts;
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020047struct BTS;
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020048
Andreas Eversberg8b761a32012-07-20 21:50:31 +020049#ifdef __cplusplus
Andreas Eversberg5dac2f02012-06-27 15:52:04 +020050/*
Andreas Eversberg2b914642012-07-19 13:06:26 +020051 * paging entry
52 */
53struct gprs_rlcmac_paging {
54 struct llist_head list;
55 uint8_t chan_needed;
56 uint8_t identity_lv[9];
57};
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040058
Andreas Eversberg07e97cf2012-08-07 16:00:56 +020059/*
Andreas Eversberg3b1332c2012-10-03 14:20:53 +020060 * coding scheme info
61 */
62struct gprs_rlcmac_cs {
63 uint8_t block_length;
64 uint8_t block_data;
65 uint8_t block_payload;
66};
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040067
Andreas Eversbergb83e2a72012-10-07 15:26:00 +020068#ifdef DEBUG_DIAGRAM
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020069void debug_diagram(BTS *bts, int diag, const char *format, ...);
Andreas Eversbergb83e2a72012-10-07 15:26:00 +020070#else
Holger Hans Peter Freyther34bd8bd2013-10-19 21:10:38 +020071#define debug_diagram(a, b, c, args...) ;
Andreas Eversbergb83e2a72012-10-07 15:26:00 +020072#endif
73
Andreas Eversberg050ace22013-03-16 16:22:02 +010074int gprs_rlcmac_received_lost(struct gprs_rlcmac_tbf *tbf, uint16_t received,
75 uint16_t lost);
76
77int gprs_rlcmac_lost_rep(struct gprs_rlcmac_tbf *tbf);
78
79int gprs_rlcmac_meas_rep(Packet_Measurement_Report_t *pmr);
80
81int gprs_rlcmac_rssi(struct gprs_rlcmac_tbf *tbf, int8_t rssi);
82
83int gprs_rlcmac_rssi_rep(struct gprs_rlcmac_tbf *tbf);
84
85int gprs_rlcmac_dl_bw(struct gprs_rlcmac_tbf *tbf, uint16_t octets);
86
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +040087/* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */
88enum gprs_rlcmac_block_type {
89 GPRS_RLCMAC_DATA_BLOCK = 0x0,
90 GPRS_RLCMAC_CONTROL_BLOCK = 0x1,
91 GPRS_RLCMAC_CONTROL_BLOCK_OPT = 0x2,
92 GPRS_RLCMAC_RESERVED = 0x3
93};
94
Andreas Eversberg3e372d52012-07-06 09:28:15 +020095int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf);
Ivan Kluchnikova9e6dc52012-06-17 08:30:06 +040096
Andreas Eversberg8c3680d2012-10-08 12:30:56 +020097int gprs_rlcmac_paging_request(uint8_t *ptmsi, uint16_t ptmsi_len,
98 const char *imsi);
99
Holger Hans Peter Freytherb19d7262013-10-17 18:12:18 +0200100int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts,
101 uint8_t trx, uint8_t ts, uint16_t arfcn,
Andreas Eversberge6228b32012-07-03 13:36:03 +0200102 uint32_t fn, uint8_t block_nr);
103
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200104extern "C" {
105#endif
Holger Hans Peter Freytherb67a8a32013-07-28 18:55:14 +0200106int alloc_algorithm_a(struct gprs_rlcmac_bts *bts,
107 struct gprs_rlcmac_tbf *old_tbf,
Andreas Eversbergf01929b2012-10-08 12:40:49 +0200108 struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200109
Holger Hans Peter Freytherb67a8a32013-07-28 18:55:14 +0200110int alloc_algorithm_b(struct gprs_rlcmac_bts *bts,
111 struct gprs_rlcmac_tbf *old_tbf,
Andreas Eversbergf01929b2012-10-08 12:40:49 +0200112 struct gprs_rlcmac_tbf *tbf, uint32_t cust, uint8_t single);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200113#ifdef __cplusplus
114}
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200115#endif
Andreas Eversberg2b914642012-07-19 13:06:26 +0200116
Ivan Kluchnikov8ee60512012-03-05 19:24:57 +0400117#endif // GPRS_RLCMAC_H