2012-03-05 15:24:57 +00:00
|
|
|
/* gprs_rlcmac.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ivan Klyuchnikov
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GPRS_RLCMAC_H
|
|
|
|
#define GPRS_RLCMAC_H
|
|
|
|
|
2012-04-30 14:00:36 +00:00
|
|
|
#include <bitvector.h>
|
2012-03-05 15:24:57 +00:00
|
|
|
#include <gsm_rlcmac.h>
|
2012-04-12 11:22:06 +00:00
|
|
|
#include <gsm_timer.h>
|
2012-03-05 15:24:57 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
2012-04-12 11:22:06 +00:00
|
|
|
#include <osmocom/core/timer.h>
|
2012-03-05 15:24:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 17:55:02 +00:00
|
|
|
#define LLC_MAX_LEN 1543
|
2012-06-05 12:56:27 +00:00
|
|
|
#define UL_RLC_DATA_BLOCK_LEN 23
|
2012-06-04 17:55:02 +00:00
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
enum gprs_rlcmac_tbf_stage {
|
|
|
|
TBF_ESTABLISH,
|
|
|
|
TBF_DATA_TRANSFER,
|
|
|
|
TBF_RELEASE
|
|
|
|
};
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
enum gprs_rlcmac_tbf_state {
|
2012-06-17 04:30:06 +00:00
|
|
|
WAIT_ESTABLISH,
|
|
|
|
CCCH_ESTABLISH,
|
|
|
|
PACCH_ESTABLISH,
|
|
|
|
FINISH_ESTABLISH,
|
|
|
|
WAIT_DATA_TRANSFER,
|
|
|
|
DATA_TRANSFER,
|
|
|
|
FINISH_DATA_TRANSFER,
|
|
|
|
RELEASE
|
2012-03-05 15:24:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum gprs_rlcmac_tbf_direction {
|
|
|
|
GPRS_RLCMAC_DL_TBF,
|
|
|
|
GPRS_RLCMAC_UL_TBF
|
|
|
|
};
|
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
struct tbf_llc_pdu {
|
|
|
|
struct llist_head list;
|
|
|
|
uint8_t num;
|
|
|
|
uint8_t data[LLC_MAX_LEN];
|
|
|
|
uint16_t len;
|
|
|
|
};
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
struct gprs_rlcmac_tbf {
|
|
|
|
struct llist_head list;
|
|
|
|
enum gprs_rlcmac_tbf_state state;
|
2012-06-17 04:30:06 +00:00
|
|
|
enum gprs_rlcmac_tbf_stage stage;
|
2012-03-05 15:24:57 +00:00
|
|
|
enum gprs_rlcmac_tbf_direction direction;
|
2012-06-17 04:30:06 +00:00
|
|
|
struct gprs_rlcmac_tbf *next_tbf;
|
2012-03-05 15:24:57 +00:00
|
|
|
uint8_t tfi;
|
|
|
|
uint32_t tlli;
|
2012-06-17 04:30:06 +00:00
|
|
|
|
|
|
|
struct llist_head llc_pdus;
|
|
|
|
struct tbf_llc_pdu llc_pdu;
|
|
|
|
uint8_t llc_pdu_list_len;
|
2012-06-04 17:55:02 +00:00
|
|
|
uint8_t rlc_data[LLC_MAX_LEN];
|
2012-03-05 15:24:57 +00:00
|
|
|
uint16_t data_index;
|
|
|
|
uint8_t bsn;
|
2012-04-12 11:22:06 +00:00
|
|
|
|
|
|
|
struct osmo_timer_list timer;
|
|
|
|
unsigned int T; /* Txxxx number */
|
|
|
|
unsigned int num_T_exp; /* number of consecutive T expirations */
|
|
|
|
|
|
|
|
struct osmo_gsm_timer_list gsm_timer;
|
|
|
|
unsigned int fT; /* fTxxxx number */
|
|
|
|
unsigned int num_fT_exp; /* number of consecutive fT expirations */
|
2012-03-05 15:24:57 +00:00
|
|
|
};
|
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
/* TS 44.060 Section 10.4.7 Table 10.4.7.1: Payload Type field */
|
|
|
|
enum gprs_rlcmac_block_type {
|
|
|
|
GPRS_RLCMAC_DATA_BLOCK = 0x0,
|
|
|
|
GPRS_RLCMAC_CONTROL_BLOCK = 0x1,
|
|
|
|
GPRS_RLCMAC_CONTROL_BLOCK_OPT = 0x2,
|
|
|
|
GPRS_RLCMAC_RESERVED = 0x3
|
|
|
|
};
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
extern struct llist_head gprs_rlcmac_tbfs;
|
|
|
|
|
|
|
|
int tfi_alloc();
|
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
static struct gprs_rlcmac_tbf *tbf_by_tfi(uint8_t tfi, gprs_rlcmac_tbf_direction dir);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
static struct gprs_rlcmac_tbf *tbf_by_tlli(uint32_t tlli, gprs_rlcmac_tbf_direction dir);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
|
|
|
static void tbf_free(struct gprs_rlcmac_tbf *tbf);
|
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
static struct tbf_llc_pdu *tbf_llc_pdu_by_num(struct llist_head llc_pdus, uint8_t num);
|
|
|
|
|
|
|
|
int tbf_add_llc_pdu(struct gprs_rlcmac_tbf *tbf, uint8_t *data, uint16_t llc_pdu_len);
|
|
|
|
|
|
|
|
struct gprs_rlcmac_tbf *tbf_alloc(gprs_rlcmac_tbf_direction dir, uint32_t tlli = 0);
|
|
|
|
|
|
|
|
int tbf_ul_establish(struct gprs_rlcmac_tbf *tbf, uint8_t ra, uint32_t Fn, uint16_t ta);
|
|
|
|
|
|
|
|
int tbf_dl_establish(struct gprs_rlcmac_tbf *tbf, uint8_t *imsi = NULL);
|
|
|
|
|
|
|
|
int tbf_ul_data_transfer(struct gprs_rlcmac_tbf *tbf, RlcMacUplinkDataBlock_t * ul_data_block);
|
|
|
|
|
|
|
|
int tbf_dl_data_transfer(struct gprs_rlcmac_tbf *tbf, uint8_t *llc_pdu = NULL, uint16_t llc_pdu_len = 0);
|
|
|
|
|
|
|
|
int tbf_ul_release(struct gprs_rlcmac_tbf *tbf);
|
|
|
|
|
|
|
|
int tbf_dl_release(struct gprs_rlcmac_tbf *tbf);
|
|
|
|
|
|
|
|
static void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T, unsigned int seconds);
|
|
|
|
|
|
|
|
static void tbf_gsm_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int fT, int frames);
|
|
|
|
|
|
|
|
int write_immediate_assignment(bitvec * dest, uint8_t downlink, uint8_t ra, uint32_t fn, uint8_t ta, uint8_t tfi, uint32_t tlli = 0);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
|
|
|
void gprs_rlcmac_tx_ul_ack(uint8_t tfi, uint32_t tlli, RlcMacUplinkDataBlock_t * ul_data_block);
|
|
|
|
|
|
|
|
void gprs_rlcmac_data_block_parse(gprs_rlcmac_tbf* tbf, RlcMacUplinkDataBlock_t * ul_data_block);
|
|
|
|
|
2012-04-30 14:00:36 +00:00
|
|
|
int gprs_rlcmac_rcv_data_block(bitvec *rlc_block);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2012-04-30 14:00:36 +00:00
|
|
|
int gprs_rlcmac_rcv_control_block(bitvec *rlc_block);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2012-04-30 14:00:36 +00:00
|
|
|
void gprs_rlcmac_rcv_block(bitvec *rlc_block);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
2012-04-17 18:00:31 +00:00
|
|
|
int gprs_rlcmac_rcv_rach(uint8_t ra, uint32_t Fn, uint16_t ta);
|
|
|
|
|
2012-06-17 04:30:06 +00:00
|
|
|
int gprs_rlcmac_tx_llc_pdus(struct gprs_rlcmac_tbf *tbf);
|
2012-03-05 15:24:57 +00:00
|
|
|
|
|
|
|
void gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf);
|
|
|
|
|
2012-03-18 11:04:48 +00:00
|
|
|
void gprs_rlcmac_downlink_assignment(gprs_rlcmac_tbf *tbf);
|
|
|
|
|
2012-05-24 19:12:59 +00:00
|
|
|
void gprs_rlcmac_packet_downlink_assignment(gprs_rlcmac_tbf *tbf);
|
|
|
|
|
2012-03-05 15:24:57 +00:00
|
|
|
#endif // GPRS_RLCMAC_H
|