Commit 3c6f1e19 authored by Lionel Gauthier's avatar Lionel Gauthier

Old rev code


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7374 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 9c6a83e6
This diff is collapsed.
This diff is collapsed.
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_constants.h
* \brief This file defines constant values used in RLC TM.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_CONSTANT_H__
# define __RLC_TM_CONSTANT_H__
//----------------------------------------------------------
// Events defined for state model of the acknowledged mode entity
# define RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT 0x00
# define RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT 0x01
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/***************************************************************************
rlc_tm_control_primitives.c -
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
//#include "rtos_header.h"
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "rlc_tm_entity.h"
#include "rlc_primitives.h"
#include "rlc_tm_fsm_proto_extern.h"
#include "rlc_tm_segment_proto_extern.h"
#include "rlc_tm_proto_extern.h"
#include "list.h"
#include "mem_block.h"
#include "rrm_config_structs.h"
//-----------------------------------------------------------------------------
void config_req_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP);
void send_rlc_tm_control_primitive (struct rlc_tm_entity *rlcP, module_id_t module_idP, mem_block_t *cprimitiveP);
void init_rlc_tm (struct rlc_tm_entity *rlcP);
void rlc_tm_reset_state_variables (struct rlc_tm_entity *rlcP);
void rlc_tm_free_all_resources (struct rlc_tm_entity *rlcP);
void rlc_tm_set_configured_parameters (struct rlc_tm_entity *rlcP, mem_block_t *cprimitiveP);
//-----------------------------------------------------------------------------
void
config_req_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP)
{
//-----------------------------------------------------------------------------
mem_block_t *mb;
mb = get_free_mem_block (sizeof (struct crlc_primitive));
((struct crlc_primitive *) mb->data)->type = CRLC_CONFIG_REQ;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.e_r = RLC_E_R_ESTABLISHMENT;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.timer_discard = config_tmP->timer_discard;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.sdu_discard_mode = config_tmP->sdu_discard_mode;
#warning frame_tick_milliseconds
#ifdef NODE_RG
//((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.frame_tick_milliseconds = &protocol_bs->frame_tick_milliseconds;
#else
//((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.frame_tick_milliseconds = &protocol_ms->frame_tick_milliseconds;
#endif
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.segmentation_indication = config_tmP->segmentation_indication;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.delivery_of_erroneous_sdu = config_tmP->delivery_of_erroneous_sdu;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.size_input_sdus_buffer = 128;
((struct crlc_primitive *) mb->data)->primitive.c_config_req.parameters.tm_parameters.rb_id = rb_idP;
send_rlc_tm_control_primitive (rlcP, module_idP, mb);
if (rb_typeP != SIGNALLING_RADIO_BEARER) {
rlcP->data_plane = 1;
} else {
rlcP->data_plane = 0;
}
}
//-----------------------------------------------------------------------------
void
send_rlc_tm_control_primitive (struct rlc_tm_entity *rlcP, module_id_t module_idP, mem_block_t *cprimitiveP)
{
//-----------------------------------------------------------------------------
switch (((struct crlc_primitive *) cprimitiveP->data)->type) {
case CRLC_CONFIG_REQ:
rlcP->module_id = module_idP;
switch (((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.e_r) {
case RLC_E_R_ESTABLISHMENT:
if (rlc_tm_fsm_notify_event (rlcP, RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) {
rlc_tm_set_configured_parameters (rlcP, cprimitiveP); // the order of the calling of procedures...
rlc_tm_reset_state_variables (rlcP); // ...must not ...
}
break;
case RLC_E_R_RELEASE:
if (rlc_tm_fsm_notify_event (rlcP, RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT)) {
rlc_tm_free_all_resources (rlcP);
}
break;
default:
msg ("[RLC_TM][ERROR] send_rlc_tm_control_primitive(CRLC_CONFIG_REQ) unknown parameter E_R\n");
}
break;
default:
msg ("[RLC_TM %p][ERROR] send_rlc_tm_control_primitive(UNKNOWN CPRIMITIVE)\n", rlcP);
}
free_mem_block (cprimitiveP);
}
//-----------------------------------------------------------------------------
void
init_rlc_tm (struct rlc_tm_entity *rlcP)
{
//-----------------------------------------------------------------------------
memset (rlcP, 0, sizeof (struct rlc_tm_entity));
list_init (&rlcP->pdus_to_mac_layer, NULL);
list_init (&rlcP->pdus_from_mac_layer, NULL);
rlcP->protocol_state = RLC_NULL_STATE;
rlcP->nb_sdu = 0;
rlcP->next_sdu_index = 0;
rlcP->current_sdu_index = 0;
}
//-----------------------------------------------------------------------------
void
rlc_tm_reset_state_variables (struct rlc_tm_entity *rlcP)
{
//-----------------------------------------------------------------------------
rlcP->output_sdu_size_to_write = 0;
rlcP->buffer_occupancy = 0;
rlcP->nb_sdu = 0;
rlcP->next_sdu_index = 0;
rlcP->current_sdu_index = 0;
rlcP->last_tti = 0xFFFFFFFF;
}
//-----------------------------------------------------------------------------
void
rlc_tm_free_all_resources (struct rlc_tm_entity *rlcP)
{
//-----------------------------------------------------------------------------
int index;
list_free (&rlcP->pdus_to_mac_layer);
list_free (&rlcP->pdus_from_mac_layer);
if (rlcP->input_sdus_alloc) {
for (index = 0; index < rlcP->size_input_sdus_buffer; index++) {
if ((rlcP->input_sdus[index])) {
free_mem_block (rlcP->input_sdus[index]);
}
}
free_mem_block (rlcP->input_sdus_alloc);
rlcP->input_sdus_alloc = NULL;
}
if ((rlcP->output_sdu_in_construction)) {
free_mem_block (rlcP->output_sdu_in_construction);
}
}
//-----------------------------------------------------------------------------
void
rlc_tm_set_configured_parameters (struct rlc_tm_entity *rlcP, mem_block_t *cprimitiveP)
{
//-----------------------------------------------------------------------------
// timers
rlcP->timer_discard_init = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.timer_discard;
// protocol_parameters
rlcP->sdu_discard_mode = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.sdu_discard_mode;
rlcP->segmentation_indication = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.segmentation_indication;
rlcP->delivery_of_erroneous_sdu = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.delivery_of_erroneous_sdu;
// SPARE : not 3GPP
rlcP->frame_tick_milliseconds = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.frame_tick_milliseconds;
rlcP->size_input_sdus_buffer = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.size_input_sdus_buffer;
rlcP->rb_id = ((struct crlc_primitive *) cprimitiveP->data)->primitive.c_config_req.parameters.tm_parameters.rb_id;
if ((rlcP->input_sdus_alloc == NULL) && (rlcP->size_input_sdus_buffer > 0)) {
rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void *));
rlcP->input_sdus = (mem_block_t **) (rlcP->input_sdus_alloc->data);
memset (rlcP->input_sdus, 0, rlcP->size_input_sdus_buffer * sizeof (void *));
}
if (rlcP->segmentation_indication == RLC_TM_SEGMENTATION_ALLOWED) {
rlcP->segmentation = rlc_tm_segment;
rlcP->rx = rlc_tm_rx_segment;
} else {
rlcP->segmentation = rlc_tm_no_segment;
rlcP->rx = rlc_tm_rx_no_segment;
}
}
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_control_primitives_proto_extern.h
* \brief This file defines the prototypes of the functions dealing with the control primitives and initialization.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_CONTROL_PRIMITIVES_H__
# define __RLC_TM_CONTROL_PRIMITIVES_H__
//-----------------------------------------------------------------------------
# include "rlc_tm_entity.h"
# include "mem_block.h"
# include "rrm_config_structs.h"
//-----------------------------------------------------------------------------
extern void config_req_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t module_idP,rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP);
extern void send_rlc_tm_control_primitive (struct rlc_tm_entity *rlcP, module_id_t module_idP, mem_block_t *cprimitiveP);
extern void init_rlc_tm (struct rlc_tm_entity *rlcP);
extern void rlc_tm_reset_state_variables (struct rlc_tm_entity *rlcP);
extern void rlc_tm_free_all_resources (struct rlc_tm_entity *rlcP);
extern void rlc_tm_set_configured_parameters (struct rlc_tm_entity *rlcP, mem_block_t *cprimitiveP);
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_entity.h
* \brief This file defines the RLC TM variables stored in a struct called rlc_tm_entity_t.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_ENTITY_H__
# define __RLC_TM_ENTITY_H__
//-----------------------------------------------------------------------------
# include "platform_types.h"
# include "platform_constants.h"
# include "rlc_tm_structs.h"
# include "rlc_def.h"
//-----------------------------------------------------------------------------
struct rlc_tm_entity {
module_id_t module_id;
uint8_t allocation;
uint8_t protocol_state;
// for stats and trace purpose :
uint16_t data_plane; // act as a boolean
uint16_t rb_id;
//-----------------------------
// discard info
//-----------------------------
uint8_t sdu_discard_mode;
//-----------------------------
// time
//-----------------------------
uint16_t timer_discard_init;
uint32_t *frame_tick_milliseconds; // pointer on this tick variable handled by RRC : READ ONLY
int32_t last_tti;
//-----------------------------
// tranmission
//-----------------------------
// sdu communication;
mem_block_t **input_sdus; // should be accessed as an array
mem_block_t *input_sdus_alloc; // allocation of the array
uint16_t size_input_sdus_buffer;
uint16_t nb_sdu;
void (*segmentation) (struct rlc_tm_entity * rlcP);
uint16_t next_sdu_index; // next location of incoming sdu
uint16_t current_sdu_index;
list_t pdus_to_mac_layer;
uint16_t rlc_pdu_size;
uint16_t nb_pdu_requested_by_mac;
uint8_t segmentation_indication;
uint8_t delivery_of_erroneous_sdu;
uint32_t buffer_occupancy;
//-----------------------------
// receiver
//-----------------------------
unsigned int output_sdu_size_to_write; // for writing in sdu
mem_block_t *output_sdu_in_construction;
void (*rx) (void *argP, struct mac_data_ind data_indP);
uint8_t last_bit_position_reassemblied;
list_t pdus_from_mac_layer;
//-----------------------------
// C-SAP
//-----------------------------
list_t c_sap;
//-----------------------------
// Mapping info
//-----------------------------
uint8_t logical_channel_identity;
};
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/***************************************************************************
rlc_tm_fsm.c -
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "rlc_tm_entity.h"
#include "rlc_tm_constants.h"
#include "rlc_def.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int
rlc_tm_fsm_notify_event (struct rlc_tm_entity *rlcP, uint8_t eventP)
{
//-----------------------------------------------------------------------------
switch (rlcP->protocol_state) {
//-------------------------------
// RLC_NULL_STATE
//-------------------------------
case RLC_NULL_STATE:
switch (eventP) {
case RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT:
#ifdef DEBUG_RLC_TM_FSM
msg ("[RLC_TM %p][FSM] RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", rlcP);
#endif
rlcP->protocol_state = RLC_DATA_TRANSFER_READY_STATE;
return 1;
break;
default:
msg ("[RLC_TM %p][FSM] WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", rlcP, eventP);
return 0;
}
break;
//-------------------------------
// RLC_DATA_TRANSFER_READY_STATE
//-------------------------------
case RLC_DATA_TRANSFER_READY_STATE:
switch (eventP) {
case RLC_TM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT:
#ifdef DEBUG_RLC_TM_FSM
msg ("[RLC_TM %p][FSM] RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", rlcP);
#endif
rlcP->protocol_state = RLC_NULL_STATE;
return 1;
break;
}
break;
default:
msg ("[RLC_TM %p][FSM] ERROR UNKNOWN STATE %d\n", rlcP, rlcP->protocol_state);
return 0;
}
return 0;
}
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_fsm_proto_extern.h
* \brief This file defines the prototypes of the functions dealing with the finite state machine of the RLC TM protocol instance.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_FSM_H__
# define __RLC_TM_FSM_H__
//-----------------------------------------------------------------------------
# include "platform_types.h"
# include "rlc_tm_entity.h"
//-----------------------------------------------------------------------------
extern int rlc_tm_fsm_notify_event (struct rlc_tm_entity *rlcP, uint8_t eventP);
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
# ifndef __RLC_TM_PROTO_EXTERN_H__
# define __RLC_TM_PROTO_EXTERN_H__
//-----------------------------------------------------------------------------
# include "platform_types.h"
# include "platform_constants.h"
//-----------------------------------------------------------------------------
# include "list.h"
# include "rlc_tm_entity.h"
# include "mac_primitives.h"
# include "mem_block.h"
//-----------------------------------------------------------------------------
extern void display_protocol_vars_rlc_tm (struct rlc_tm_entity *rlcP);
extern uint32_t rlc_tm_get_buffer_occupancy (struct rlc_tm_entity *rlcP, uint8_t logical_channelsP);
extern void init_rlc_tm (struct rlc_tm_entity *rlcP);
extern void *rlc_tm_tx (void *argP);
extern void rlc_tm_rx_no_segment (void *argP, struct mac_data_ind data_indP);
extern void rlc_tm_rx_segment (void *argP, struct mac_data_ind data_indP);
extern void send_rlc_tm_control_primitive (struct rlc_tm_entity *rlcP, module_id_t module_idP, mem_block_t *cprimitiveP);
extern struct mac_status_resp rlc_tm_mac_status_indication (void *rlcP, uint16_t tb_sizeP, struct mac_status_ind tx_statusP);
extern struct mac_data_req rlc_tm_mac_data_request (void *rlcP);
extern void rlc_tm_mac_data_indication (void *rlcP, struct mac_data_ind data_indP);
extern void rlc_tm_data_req (void *rlcP, mem_block_t *sduP);
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/***************************************************************************
rlc_tm_reassembly.c -
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#define RLC_TM_C
//#include "rtos_header.h"
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "rlc.h"
#include "rlc_tm_structs.h"
#include "rlc_primitives.h"
#include "rlc_tm_constants.h"
#include "list.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
rlc_tm_send_sdu_no_segment (struct rlc_tm_entity *rlcP, uint8_t error_indicationP, uint8_t * srcP, uint16_t length_in_bitsP)
{
//-----------------------------------------------------------------------------
int length_in_bytes;
#ifdef DEBUG_RLC_TM_DISPLAY_ASCII_DATA
int index;
#endif
#ifdef DEBUG_RLC_TM_REASSEMBLY
msg ("[RLC_TM %p][SEND_SDU] %d bits\n", rlcP, length_in_bitsP);
#endif
length_in_bytes = (length_in_bitsP + 7) >> 3;
if (rlcP->output_sdu_in_construction == NULL) {
rlcP->output_sdu_in_construction = get_free_mem_block (length_in_bytes);
}
if ((rlcP->output_sdu_in_construction)) {
#ifdef DEBUG_RLC_TM_DISPLAY_ASCII_DATA
msg ("[RLC_TM %p][SEND_SDU] DATA :", rlcP);
for (index = 0; index < length_in_bytes; index++) {
msg ("%c", srcP[index]);
}
msg ("\n");
#endif
memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, length_in_bytes);
#warning loss of error indication parameter
rlc_data_ind (rlcP->module_id, rlcP->rb_id, length_in_bytes, rlcP->output_sdu_in_construction, rlcP->data_plane);
rlcP->output_sdu_in_construction = NULL;
} else {
msg ("[RLC_TM %p][SEND_SDU] ERROR OUTPUT SDU IS NULL\n", rlcP);
}
}
//-----------------------------------------------------------------------------
void
rlc_tm_send_sdu_segment (struct rlc_tm_entity *rlcP, uint8_t error_indicationP)
{
//-----------------------------------------------------------------------------
if ((rlcP->output_sdu_in_construction) && (rlcP->output_sdu_size_to_write)) {
#ifdef DEBUG_RLC_TM_SEND_SDU
msg ("[RLC_TM %p] SEND_SDU %d bytes\n", rlcP, rlcP->output_sdu_size_to_write);
#endif
#warning loss of error indication parameter
rlc_data_ind (rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction, rlcP->data_plane);
rlcP->output_sdu_in_construction = NULL;
rlcP->output_sdu_size_to_write = 0;
}
}
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_reassembly_proto_extern.h
* \brief This file defines the prototypes of the functions dealing with the reassembly and the sent of SDUs to upper layer.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_REASSEMBLY_H__
# define __RLC_TM_REASSEMBLY_H__
//-----------------------------------------------------------------------------
# include "rlc_tm_entity.h"
//-----------------------------------------------------------------------------
extern void rlc_tm_send_sdu_no_segment (struct rlc_tm_entity *rlcP, uint8_t error_indicationP, uint8_t * srcP, uint16_t length_in_bitsP);
extern void rlc_tm_send_sdu_segment (struct rlc_tm_entity *rlcP, uint8_t error_indicationP);
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/***************************************************************************
rlc_tm_segment.c -
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
//#include "rtos_header.h"
#include "platform_types.h"
//-----------------------------------------------------------------------------
#include "list.h"
#include "rlc_tm_entity.h"
#include "rlc_tm_structs.h"
#include "rlc_primitives.h"
#include "mem_block.h"
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
rlc_tm_no_segment (struct rlc_tm_entity* rlcP)
{
//-----------------------------------------------------------------------------
mem_block_t* pdu;
struct rlc_tm_tx_sdu_management* sdu_mngt;
struct rlc_tm_tx_pdu_management* pdu_mngt;
int discard_go_on;
int nb_pdu_to_transmit;
nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac;
pdu = NULL;
if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_NO_EXPLICIT)) {
discard_go_on = 1;
while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) {
if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >=
rlcP->timer_discard_init) {
#ifdef DEBUG_RLC_TM_DISCARD_SDU
msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP,
(*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time));
msg("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu);
#endif
rlcP->buffer_occupancy -= (((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3);
rlcP->nb_sdu -= 1;
free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]);
rlcP->input_sdus[rlcP->current_sdu_index] = NULL;
rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer;
} else {
discard_go_on = 0;
}
}
}
// only one SDU per TTI
while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_pdu_to_transmit > 0)) {
sdu_mngt = ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data));
//PRINT_RLC_TM_SEGMENT("[RLC_TM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP, sdu_mngt, sdu_mngt->sdu_remaining_size);
if (!(pdu = get_free_mem_block (((rlcP->rlc_pdu_size + 7) >> 3) + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE))) {
msg ("[RLC_TM %p][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP);
return;
}
// SHOULD BE OPTIMIZED...SOON
pdu_mngt = (struct rlc_tm_tx_pdu_management*) (pdu->data);
memset (pdu->data, 0, sizeof (struct rlc_tm_tx_pdu_management));
pdu_mngt->first_byte = (uint8_t*)&pdu->data[sizeof (struct rlc_tm_tx_data_pdu_struct)];
memcpy (pdu_mngt->first_byte, sdu_mngt->first_byte, ((rlcP->rlc_pdu_size + 7) >> 3));
((struct mac_tb_req*) (pdu->data))->rlc = NULL;
((struct mac_tb_req*) (pdu->data))->data_ptr = pdu_mngt->first_byte;
((struct mac_tb_req*) (pdu->data))->first_bit = 0;
((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size;
list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer);
rlcP->buffer_occupancy -= (sdu_mngt->sdu_size >> 3);
free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]);
rlcP->input_sdus[rlcP->current_sdu_index] = NULL;
rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer;
rlcP->nb_sdu -= 1;
}
}
//-----------------------------------------------------------------------------
void
rlc_tm_segment (struct rlc_tm_entity* rlcP)
{
//-----------------------------------------------------------------------------
mem_block_t* pdu;
struct rlc_tm_tx_sdu_management* sdu_mngt;
struct rlc_tm_tx_pdu_management* pdu_mngt;
int discard_go_on;
int nb_pdu_to_transmit;
nb_pdu_to_transmit = rlcP->nb_pdu_requested_by_mac;
pdu = NULL;
if ((rlcP->sdu_discard_mode & RLC_SDU_DISCARD_TIMER_BASED_NO_EXPLICIT)) {
discard_go_on = 1;
while ((rlcP->input_sdus[rlcP->current_sdu_index]) && discard_go_on) {
if ((*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time) >=
rlcP->timer_discard_init) {
#ifdef DEBUG_RLC_TM_DISCARD_SDU
msg("[RLC_TM %p] SDU DISCARDED TIMED OUT %ld ms ", rlcP,
(*rlcP->frame_tick_milliseconds - ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_creation_time));
msg ("BO %d, NB SDU %d\n", rlcP->buffer_occupancy, rlcP->nb_sdu);
#endif
rlcP->nb_sdu -= 1;
free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]);
rlcP->input_sdus[rlcP->current_sdu_index] = NULL;
rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer;
} else {
discard_go_on = 0;
}
}
}
// only one SDU per TTI
if ((rlcP->input_sdus[rlcP->current_sdu_index])) {
sdu_mngt = (struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data);
//PRINT_RLC_TM_SEGMENT("[RLC_TM %p] SEGMENT GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP, sdu_mngt, sdu_mngt->sdu_remaining_size);
while ((nb_pdu_to_transmit > 0) && (sdu_mngt->sdu_segmented_size < sdu_mngt->sdu_size)) {
if (!(pdu = get_free_mem_block (((rlcP->rlc_pdu_size + 7) >> 3) + 1 + sizeof (struct rlc_tm_tx_data_pdu_struct) + GUARD_CRC_LIH_SIZE))) {
msg ("[RLC_TM %p][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP);
return;
}
// SHOULD BE OPTIMIZED...SOON
pdu_mngt = (struct rlc_tm_tx_pdu_management*) (pdu->data);
memset (pdu->data, 0, sizeof (struct rlc_tm_tx_pdu_management));
pdu_mngt->first_byte = (uint8_t*)&pdu->data[sizeof (struct rlc_tm_tx_data_pdu_struct)];
memcpy (pdu_mngt->first_byte, &sdu_mngt->first_byte[sdu_mngt->sdu_segmented_size >> 3], ((rlcP->rlc_pdu_size + 7) >> 3));
((struct mac_tb_req*) (pdu->data))->rlc = NULL;
((struct mac_tb_req*) (pdu->data))->data_ptr = pdu_mngt->first_byte;
((struct mac_tb_req*) (pdu->data))->first_bit = sdu_mngt->sdu_segmented_size & 0x07;
((struct mac_tb_req*) (pdu->data))->tb_size_in_bits = rlcP->rlc_pdu_size;
list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer);
sdu_mngt->sdu_segmented_size += rlcP->rlc_pdu_size;
nb_pdu_to_transmit -= 1;
}
free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]);
rlcP->input_sdus[rlcP->current_sdu_index] = NULL;
rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer;
rlcP->nb_sdu -= 1;
}
if ((rlcP->input_sdus[rlcP->current_sdu_index])) {
rlcP->buffer_occupancy = ((struct rlc_tm_tx_sdu_management*) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size >> 3;
} else {
rlcP->buffer_occupancy = 0;
}
}
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_segment_proto_extern.h
* \brief This file defines the prototypes of the functions dealing with the segmentation of SDUs coming from upper layers.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_SEGMENT_H__
# define __RLC_TM_SEGMENT_H__
//-----------------------------------------------------------------------------
# include "rlc_tm_entity.h"
//-----------------------------------------------------------------------------
extern void rlc_tm_segment (struct rlc_tm_entity *rlcP);
extern void rlc_tm_no_segment (struct rlc_tm_entity *rlcP);
# endif
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface 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 3 of the License, or
(at your option) any later version.
OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*! \file rlc_tm_structs.h
* \brief This file defines structures used inside the RLC TM.
* \author GAUTHIER Lionel
* \date 2010-2011
* \version
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
* \note
* \bug
* \warning
*/
# ifndef __RLC_TM_STRUCTS_H__
# define __RLC_TM_STRUCTS_H__
//-----------------------
# include "platform_types.h"
# include "platform_constants.h"
# include "list.h"
# include "mem_block.h"
# include "rlc_tm_constants.h"
# include "rlc_primitives.h"
# include "mac_primitives.h"
# include "mac_rlc_primitives.h"
//-----------------------
struct rlc_tm_tx_sdu_management {
uint8_t *first_byte;
int32_t sdu_creation_time;
uint16_t sdu_segmented_size;
uint16_t sdu_size;
};
//-----------------------
struct rlc_tm_tx_pdu_management {
uint8_t *first_byte;
uint8_t dummy[MAC_HEADER_MAX_SIZE];
};
//-----------------------
struct rlc_tm_rx_pdu_management {
uint8_t *first_byte;
};
//-----------------------
struct rlc_tm_tx_data_pdu_struct {
union {
struct rlc_tm_tx_pdu_management tx_pdu_mngmnt;
struct mac_tb_req tb_req;
struct mac_tx_tb_management tb_mngt;
# ifdef BYPASS_L1
struct rlc_tm_rx_pdu_management dummy1;
struct mac_tb_ind dummy2;
struct mac_rx_tb_management dummy3;
struct rlc_indication dummy4;
# endif
} dummy;
uint8_t data[1];
};
//-----------------------
struct rlc_tm_data_req_alloc { // alloc enought bytes for sdu mngt also
union {
struct rlc_tm_data_req dummy1;
struct rlc_tm_tx_sdu_management dummy2;
} dummy;
};
# endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment