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 | |
| 23 | #include <BitVector.h> |
| 24 | #include <gsm_rlcmac.h> |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame^] | 25 | #include <gsm_timer.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 26 | |
| 27 | extern "C" { |
| 28 | #include <osmocom/core/linuxlist.h> |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame^] | 29 | #include <osmocom/core/timer.h> |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | enum gprs_rlcmac_tbf_state { |
| 33 | GPRS_RLCMAC_WAIT_DATA_SEQ_START, |
| 34 | GPRS_RLCMAC_WAIT_NEXT_DATA_BLOCK, |
| 35 | GPRS_RLCMAC_WAIT_NEXT_DATA_SEQ |
| 36 | }; |
| 37 | |
| 38 | enum gprs_rlcmac_tbf_direction { |
| 39 | GPRS_RLCMAC_DL_TBF, |
| 40 | GPRS_RLCMAC_UL_TBF |
| 41 | }; |
| 42 | |
| 43 | struct gprs_rlcmac_tbf { |
| 44 | struct llist_head list; |
| 45 | enum gprs_rlcmac_tbf_state state; |
| 46 | enum gprs_rlcmac_tbf_direction direction; |
| 47 | uint8_t tfi; |
| 48 | uint32_t tlli; |
| 49 | uint8_t rlc_data[60]; |
| 50 | uint16_t data_index; |
| 51 | uint8_t bsn; |
Ivan Kluchnikov | 61a33f7 | 2012-04-12 15:22:06 +0400 | [diff] [blame^] | 52 | |
| 53 | struct osmo_timer_list timer; |
| 54 | unsigned int T; /* Txxxx number */ |
| 55 | unsigned int num_T_exp; /* number of consecutive T expirations */ |
| 56 | |
| 57 | struct osmo_gsm_timer_list gsm_timer; |
| 58 | unsigned int fT; /* fTxxxx number */ |
| 59 | unsigned int num_fT_exp; /* number of consecutive fT expirations */ |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | extern struct llist_head gprs_rlcmac_tbfs; |
| 63 | |
| 64 | int tfi_alloc(); |
| 65 | |
| 66 | struct gprs_rlcmac_tbf *tbf_alloc(uint8_t tfi); |
| 67 | |
| 68 | static struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi); |
| 69 | |
| 70 | static struct gprs_rlcmac_tbf *tbf_by_tlli(uint8_t tlli); |
| 71 | |
| 72 | static void tbf_free(struct gprs_rlcmac_tbf *tbf); |
| 73 | |
| 74 | /* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */ |
| 75 | enum gprs_rlcmac_block_type { |
| 76 | GPRS_RLCMAC_DATA_BLOCK = 0x0, |
| 77 | GPRS_RLCMAC_CONTROL_BLOCK = 0x1, |
| 78 | GPRS_RLCMAC_CONTROL_BLOCK_OPT = 0x2, |
| 79 | GPRS_RLCMAC_RESERVED = 0x3 |
| 80 | }; |
| 81 | |
| 82 | void gprs_rlcmac_tx_ul_ack(uint8_t tfi, uint32_t tlli, RlcMacUplinkDataBlock_t * ul_data_block); |
| 83 | |
| 84 | void gprs_rlcmac_data_block_parse(gprs_rlcmac_tbf* tbf, RlcMacUplinkDataBlock_t * ul_data_block); |
| 85 | |
| 86 | int gprs_rlcmac_rcv_data_block(BitVector *rlc_block); |
| 87 | |
| 88 | int gprs_rlcmac_rcv_control_block(BitVector *rlc_block); |
| 89 | |
| 90 | void gprs_rlcmac_rcv_block(BitVector *rlc_block); |
| 91 | |
Ivan Kluchnikov | c320d86 | 2012-03-18 15:04:48 +0400 | [diff] [blame] | 92 | void gprs_rlcmac_tx_dl_data_block(uint32_t tlli, uint8_t tfi, uint8_t *pdu, int start_index, int end_index, uint8_t bsn, uint8_t fbi); |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 93 | |
| 94 | int gprs_rlcmac_segment_llc_pdu(struct gprs_rlcmac_tbf *tbf); |
| 95 | |
| 96 | void gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf); |
| 97 | |
Ivan Kluchnikov | c320d86 | 2012-03-18 15:04:48 +0400 | [diff] [blame] | 98 | void gprs_rlcmac_downlink_assignment(gprs_rlcmac_tbf *tbf); |
| 99 | |
Ivan Kluchnikov | 8ee6051 | 2012-03-05 19:24:57 +0400 | [diff] [blame] | 100 | #endif // GPRS_RLCMAC_H |