Commit e7921f03 authored by gauthier's avatar gauthier

Changed default DRB id from 3 to 1

With folowwing implicit rule
drb id = x => correspondind lc id = x+2, eps bearer id = x+4

Changed RLC inner structs, no more statically allocated array, now it is dynamic via malloc and collection of RLC entities are stored in a hashtable.
Changed misc simple types
Started compiling with all warning setted and treated as errors, still working on RLC and around...
Add const qualifier wherever suitable (for example param frame, module id, const pointers, etc)

Thinking about a type of context parameter in procedure calls in L2 data plane (modules id, frame, srb flag, enb flag, etc)...


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5222 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 4b95c852
......@@ -4,7 +4,10 @@
#include <stdint.h>
#include <stddef.h>
typedef size_t hash_size_t;
typedef size_t hash_size_t;
typedef uint64_t hash_key_t;
#define HASHTABLE_QUESTIONABLE_KEY_VALUE ((uint64_t)-1)
typedef enum hashtable_return_code_e {
HASH_TABLE_OK = 0,
......@@ -18,28 +21,28 @@ typedef enum hashtable_return_code_e {
typedef struct hash_node_s {
uint64_t key;
void *data;
struct hash_node_s *next;
hash_key_t key;
void *data;
struct hash_node_s *next;
} hash_node_t;
typedef struct hash_table_s {
hash_size_t size;
hash_size_t num_elements;
struct hash_node_s **nodes;
hash_size_t (*hashfunc)(const uint64_t);
hash_size_t (*hashfunc)(const hash_key_t);
void (*freefunc)(void*);
} hash_table_t;
char* hashtble_rc_code2string(hashtable_rc_t rcP);
void hash_free_int_func(void* memoryP);
hash_table_t *hashtable_create (hash_size_t size, hash_size_t (*hashfunc)(const uint64_t ), void (*freefunc)(void*));
hash_table_t *hashtable_create (hash_size_t size, hash_size_t (*hashfunc)(const hash_key_t ), void (*freefunc)(void*));
hashtable_rc_t hashtable_destroy(hash_table_t *hashtbl);
hashtable_rc_t hashtable_is_key_exists (hash_table_t *hashtbl, const uint64_t key);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *hashtblP, void funct(uint64_t keyP, void* dataP, void* parameterP), void* parameterP);
hashtable_rc_t hashtable_insert (hash_table_t *hashtbl, const uint64_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t *hashtbl, const uint64_t key);
hashtable_rc_t hashtable_get (hash_table_t *hashtbl, const uint64_t key, void **dataP);
hashtable_rc_t hashtable_apply_funct_on_elements (hash_table_t *hashtblP, void funct(hash_key_t keyP, void* dataP, void* parameterP), void* parameterP);
hashtable_rc_t hashtable_insert (hash_table_t *hashtbl, const hash_key_t key, void *data);
hashtable_rc_t hashtable_remove (hash_table_t *hashtbl, const hash_key_t key);
hashtable_rc_t hashtable_get (hash_table_t *hashtbl, const hash_key_t key, void **dataP);
hashtable_rc_t hashtable_resize (hash_table_t *hashtbl, hash_size_t size);
......
......@@ -109,7 +109,7 @@ struct mac_tx_tb_management {
unsigned char first_bit; // 0 if data starts on byte boundary(b7), 1 if b6, 2 if b5, etc.
// Previously designed for interlayers optimizations, (avoid aligning on byte boundary)
// but not used by L1 !, so extra cost for alignement in MAC.
unsigned short tb_size_in_bits; // L1H does not care of the field first bit any more, so in order to byte
tb_size_t tb_size_in_bits; // L1H does not care of the field first bit any more, so in order to byte
// align the tb we have to know its size
// for reporting tx status to upper layers
......@@ -123,8 +123,8 @@ struct mac_tx_tb_management {
struct mac_rx_tb_management {
unsigned char *data_ptr;
unsigned short tb_size; // in bits
unsigned char valid_checksum;
tb_size_t tb_size; // in bits
boolean_t valid_checksum;
unsigned char first_bit; // 0 if data starts on byte boundary(b7), 1 if b6, 2 if b5, etc
};
......@@ -132,7 +132,7 @@ struct mac_tb_req {
// BE CAREFULL TO KEEP THE SAME MAPPING FOR THE 6 FIELDS BELLOW AS FOR struct mac_tx_tb_management
unsigned char *data_ptr;
unsigned char first_bit;
unsigned short tb_size;
tb_size_t tb_size;
// align the tb we have to know its size
// for reporting tx status to upper layers
......
......@@ -54,7 +54,7 @@
#define MAX_MANAGED_ENB_PER_MOBILE 2
#define DEFAULT_RAB_ID 3
#define DEFAULT_RAB_ID 1
#define NB_RB_MAX (maxDRB + 3) /* was 11, now 14, maxDRB comes from asn1_constants.h, + 3 because of 3 SRB, one invisible id 0, then id 1 and 2 */
#if defined(Rel10)
......
......@@ -26,11 +26,12 @@ typedef signed char boolean_t;
#define FALSE (boolean_t)0x00
#endif
#define BOOL_NOT(b) (b^TRUE)
//-----------------------------------------------------------------------------
// GENERIC ACCESS STRATUM TYPES
//-----------------------------------------------------------------------------
typedef uint16_t sdu_size_t;
typedef int16_t sdu_ssize_t;
typedef int32_t sdu_size_t;
typedef uint32_t frame_t;
typedef int32_t sframe_t;
typedef uint32_t sub_frame_t;
......@@ -74,8 +75,8 @@ typedef unsigned int crc_t;
//-----------------------------------------------------------------------------
// MAC TYPES
//-----------------------------------------------------------------------------
typedef unsigned int tbs_size_t;
typedef unsigned int tb_size_t;
typedef sdu_size_t tbs_size_t;
typedef sdu_size_t tb_size_t;
typedef unsigned int logical_chan_id_t;
typedef unsigned int num_tb_t;
......@@ -87,7 +88,7 @@ typedef unsigned int confirm_t;
typedef unsigned int rlc_tx_status_t;
typedef int16_t rlc_sn_t;
typedef uint16_t rlc_usn_t;
typedef uint32_t rlc_buffer_occupancy_t;
typedef int32_t rlc_buffer_occupancy_t;
typedef signed int rlc_op_status_t;
//-----------------------------------------------------------------------------
......
......@@ -6,10 +6,8 @@ EXTRA_CFLAGS += -DNO_RRM
COMMON_DIR = $(OPENAIR2_TOP)/COMMON
L2_INTERFACE_DIR = $(OPENAIR2_TOP)/RRC/L2_INTERFACE
#RLC_UM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/UM_v6.1.0_LITE
RLC_UM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/UM_v9.3.0
RLC_AM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/AM_v9.3.0
#RLC_TM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/TM
RLC_TM_DIR = $(OPENAIR2_TOP)/LAYER2/RLC/TM_v9.3.0
RLC_DIR = $(OPENAIR2_TOP)/LAYER2/RLC
PDCP_DIR = $(OPENAIR2_TOP)/LAYER2/PDCP_v10.1.0
......@@ -47,10 +45,6 @@ SOURCES_L2 += $(RLC_AM_DIR)/rlc_am_status_report.c
SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm.c
SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm_init.c
#SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm_control_primitives.c
#SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm_fsm.c
#SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm_segment.c
#SOURCES_L2 += $(RLC_TM_DIR)/rlc_tm_reassembly.c
SOURCES_L2 += $(RLC_UM_DIR)/rlc_um.c
SOURCES_L2 += $(RLC_UM_DIR)/rlc_um_fsm.c
......@@ -96,7 +90,6 @@ MAC_OBJS += $(MAC_DIR)/config.o
L2_INTERFACE_OBJS = $(L2_INTERFACE_DIR)/openair_rrc_L2_interface.o
L2_OBJS=$(addsuffix .o,$(basename $(SOURCES_L2))) $(PHY_INTERFACE_OBJS) $(MAC_OBJS) $(L2_INTERFACE_OBJS)
#$(OPT_OBJS)
L2_incl = -I$(OPENAIR2_TOP)
L2_incl += -I$(COMMON_DIR)
......
......@@ -317,53 +317,47 @@ pdcp_fifo_read_input_sdus ()
// if remaining bytes to read
if (pdcp_fifo_read_input_sdus_remaining_bytes () > 0) {
// all bytes that had to be read for a SDU were read
// if not overflow of list, try to get new sdus from rt fifo
cont = 1;
while (cont > 0) {
bytes_read = rtf_get (NAS2PDCP_FIFO,
// all bytes that had to be read for a SDU were read
// if not overflow of list, try to get new sdus from rt fifo
cont = 1;
while (cont > 0) {
bytes_read = rtf_get (NAS2PDCP_FIFO,
&(((uint8_t *) & pdcp_input_header)[pdcp_input_index_header]),
sizeof (pdcp_data_req_header_t) - pdcp_input_index_header);
if (bytes_read > 0) {
if (bytes_read > 0) {
#ifdef PDCP_DEBUG
msg("[PDCP_FIFOS] TTI %d Read %d Bytes of data (header %d) from Nas_mesh\n",
Mac_rlc_xface->frame,
bytes_read,
sizeof(pdcp_data_req_header_t));
#endif // PDCP_DEBUG
pdcp_input_index_header += bytes_read;
msg("[PDCP_FIFOS] TTI %d Read %d Bytes of data (header %d) from Nas_mesh\n",
Mac_rlc_xface->frame,
bytes_read,
sizeof(pdcp_data_req_header_t));
#endif
pdcp_input_index_header += bytes_read;
if (pdcp_input_index_header == sizeof (pdcp_data_req_header_t)) {
if (pdcp_input_index_header == sizeof (pdcp_data_req_header_t)) {
#ifdef PDCP_DEBUG
msg("[PDCP] TTI %d IP->RADIO READ HEADER sdu size %d\n",
Mac_rlc_xface->frame,
pdcp_input_header.data_size);
#endif //PDCP_DEBUG
pdcp_input_index_header = 0;
if(pdcp_input_header.data_size<0){
msg("[PDCP][FATAL ERROR] READ_FIFO: DATA_SIZE %d < 0\n",pdcp_input_header.data_size);
mac_xface->macphy_exit("");
return 0;
}
pdcp_input_sdu_remaining_size_to_read = pdcp_input_header.data_size;
pdcp_input_sdu_size_read = 0;
// we know the size of the sdu, so read the sdu;
cont = pdcp_fifo_read_input_sdus_remaining_bytes ();
} else {
cont = 0;
}
// error while reading rt fifo
} else {
cont = 0;
msg("[PDCP] TTI %d IP->RADIO READ HEADER sdu size %d\n",
Mac_rlc_xface->frame,
pdcp_input_header.data_size);
#endif
pdcp_input_index_header = 0;
if (pdcp_input_header.data_size < 0) {
msg("[PDCP][FATAL ERROR] READ_FIFO: DATA_SIZE %d < 0\n",pdcp_input_header.data_size);
mac_xface->macphy_exit("");
return 0;
}
pdcp_input_sdu_remaining_size_to_read = pdcp_input_header.data_size;
pdcp_input_sdu_size_read = 0;
// we know the size of the sdu, so read the sdu;
cont = pdcp_fifo_read_input_sdus_remaining_bytes ();
} else {
cont = 0;
}
// error while reading rt fifo
} else {
cont = 0;
}
}
}
}
return 0;
}
......@@ -381,89 +375,81 @@ pdcp_fifo_read_input_sdus ()
int bytes_read;
int len;
if (pdcp_read_state == 0) {
#ifdef LINUX
len = recvmsg(nas_sock_fd, &nas_msg, 0);
len = recvmsg(nas_sock_fd, &nas_msg, 0);
#else
len = -1;
len = -1;
#endif
if (len<0) {
// printf("[PDCP][NETLINK %d] nothing in pdcp NAS socket\n", nas_sock_fd);
}
else {
if (len<0) {
//printf("[PDCP][NETLINK %d] nothing in pdcp NAS socket\n", nas_sock_fd);
}
else {
#ifdef PDCP_DEBUG
#ifdef LINUX
printf("[PDCP][NETLINK] Received socket with length %d (nlmsg_len = %d)\n",len,nas_nlh->nlmsg_len-sizeof(struct nlmsghdr));
printf("[PDCP][NETLINK] Received socket with length %d (nlmsg_len = %d)\n",len,nas_nlh->nlmsg_len-sizeof(struct nlmsghdr));
#endif PDCP_DEBUG
#ifdef PDCP_DEBUG
printf("[PDCP][NETLINK] nlmsg_len = %d (%d,%d)\n",nas_nlh->nlmsg_len,
sizeof(pdcp_data_req_header_t),
sizeof(struct nlmsghdr));
printf("[PDCP][NETLINK] nlmsg_len = %d (%d,%d)\n",nas_nlh->nlmsg_len,
sizeof(pdcp_data_req_header_t),
sizeof(struct nlmsghdr));
#endif LINUX
#endif PDCP_DEBUG
}
}
#ifdef LINUX
if (nas_nlh->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
pdcp_read_state = 1; //get
memcpy((void *)&pdcp_read_header,
(void *)NLMSG_DATA(nas_nlh),
sizeof(pdcp_data_req_header_t));
}
if (nas_nlh->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
pdcp_read_state = 1; //get
memcpy((void *)&pdcp_read_header,
(void *)NLMSG_DATA(nas_nlh),
sizeof(pdcp_data_req_header_t));
}
#else //LINUX
pdcp_read_state = 1;
pdcp_read_state = 1;
#endif //LINUX
}
if (pdcp_read_state == 1) {
#ifdef LINUX
len = recvmsg(nas_sock_fd, &nas_msg, 0);
len = recvmsg(nas_sock_fd, &nas_msg, 0);
#else
len = -1;
len = -1;
#endif //LINUX
if (len<0) {
// nothing in pdcp NAS socket
}
else {
pdcp_read_state = 0;
// print_active_requests()
if (len<0) {
// nothing in pdcp NAS socket
} else {
pdcp_read_state = 0;
//print_active_requests()
#ifdef LINUX
memcpy(pdcp_read_payload,
(unsigned char *)NLMSG_DATA(nas_nlh),
nas_nlh->nlmsg_len - sizeof(struct nlmsghdr));
memcpy(pdcp_read_payload,
(unsigned char *)NLMSG_DATA(nas_nlh),
nas_nlh->nlmsg_len - sizeof(struct nlmsghdr));
#endif
#ifdef IDROMEL_NEMO
pdcp_read_header.inst = 0;
pdcp_read_header.inst = 0;
#endif
pdcp_read_header.inst = (pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) ?
pdcp_read_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
pdcp_read_header.inst + oai_emulation.info.first_enb_local;
pdcp_read_header.inst = (pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) ?
pdcp_read_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
pdcp_read_header.inst + oai_emulation.info.first_enb_local;
#ifdef PDCP_DEBUG
printf("[PDCP][NETLINK][IP->PDCP] TTI %d, INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n",
Mac_rlc_xface->frame,
pdcp_read_header.inst,
len,
nas_nlh->nlmsg_len-sizeof(struct nlmsghdr),
pdcp_read_header.rb_id);
printf("[PDCP][NETLINK][IP->PDCP] TTI %d, INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n",
Mac_rlc_xface->frame,
pdcp_read_header.inst,
len,
nas_nlh->nlmsg_len-sizeof(struct nlmsghdr),
pdcp_read_header.rb_id);
#endif PDCP_DEBUG
pdcp_data_req(pdcp_read_header.inst,
pdcp_read_header.rb_id,
pdcp_read_header.data_size,
pdcp_read_payload);
}
pdcp_data_req(pdcp_read_header.inst,
pdcp_read_header.rb_id,
pdcp_read_header.data_size,
pdcp_read_payload);
}
}
}
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -204,7 +204,7 @@ void *pdcp_netlink_thread_fct(void *arg) {
* NOTE: netlink messages can be assembled to form a multipart message
*/
for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf;
NLMSG_OK(nas_nlh_rx, len);
NLMSG_OK(nas_nlh_rx, (unsigned int)len);
nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) {
/* There is no need to check for nlmsg_type because
......
This diff is collapsed.
......@@ -93,35 +93,49 @@ Address : EURECOM,
* \brief Empty function, TO DO.
* \param[in] rlcP RLC AM protocol instance pointer.
*/
public_rlc_am(void rlc_am_release (rlc_am_entity_t *rlcP);)
public_rlc_am(void rlc_am_release (rlc_am_entity_t * const rlcP);)
/** @addtogroup _rlc_am_init_impl_
* @{
*/
/*! \fn void config_req_rlc_am (uint32_t frame, uint8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP)
/*! \fn void config_req_rlc_am (const frame_t frame, const eNB_flag_t eNB_flagP, const srb_flag_t srb_flagP, const module_id_t enb_module_idP, const module_id_t ue_module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP)
* \brief Configure the UL and DL parameters of the RLC AM
* \param[in] frame Frame index.
* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0)
* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0).
* \param[in] enb_module_idP eNB Virtualized module identifier.
* \param[in] ue_module_idP UE Virtualized module identifier.
* \param[in] config_amP Configuration parameters for RLC AM instance.
* \param[in] rb_idP Radio bearer identifier.
* \param[in] rb_typeP Radio bearer type (Signalling or Data).
*/
public_rlc_am(void config_req_rlc_am (uint32_t frame, uint8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);)
public_rlc_am(void config_req_rlc_am (
const frame_t frame,
const eNB_flag_t eNB_flagP,
const srb_flag_t srb_flagP,
const module_id_t enb_module_idP,
const module_id_t ue_module_idP,
const rlc_am_info_t * const config_amP,
const rb_id_t rb_idP);)
/*! \fn void config_req_rlc_am_asn1 (uint32_t frame, uint8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP)
/*! \fn void config_req_rlc_am_asn1 (const frame_t frame, const eNB_flag_t eNB_flagP, const srb_flag_t srb_flagP, const module_id_t enb_module_idP, const module_id_t ue_module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP)
* \brief Configure the UL and DL parameters of the RLC AM with the asn1c autogenerated pameters structs
* \param[in] frame Frame index.
* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0)
* \param[in] srb_flagP Flag to indicate signalling radio bearer (1) or data radio bearer (0).
* \param[in] enb_module_idP eNB Virtualized module identifier.
* \param[in] ue_module_idP UE Virtualized module identifier.
* \param[in] config_amP Configuration parameters for RLC AM instance.
* \param[in] rb_idP Radio bearer identifier.
* \param[in] rb_typeP Radio bearer type (Signalling or Data).
*/
public_rlc_am(void config_req_rlc_am_asn1 (uint32_t frame, uint8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);)
public_rlc_am(void config_req_rlc_am_asn1 (
const const frame_t frame,
const eNB_flag_t eNB_flagP,
const srb_flag_t srb_flagP,
const module_id_t enb_module_idP,
const module_id_t ue_module_idP,
const struct RLC_Config__am * const config_amP,
const rb_id_t rb_idP);)
/** @} */
......@@ -218,14 +232,14 @@ public_rlc_am(void rlc_am_stat_req (rlc_am_entity_t *rlcP,
*/
private_rlc_am( void rlc_am_get_pdus (void *argP);)
/*! \fn void rlc_am_rx (void *rlcP, uint32_t frame, uint8_t eNB_flag, struct mac_data_ind data_indication)
/*! \fn void rlc_am_rx (void *rlcP, uint32_t frame, const eNB_flag_t eNB_flag, struct mac_data_ind data_indication)
* \brief Process the received PDUs from lower layer.
* \param[in] rlcP RLC AM protocol instance pointer.
* \param[in] frame Frame index.
* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0).
* \param[in] data_indication PDUs from MAC.
*/
protected_rlc_am( void rlc_am_rx (void *, uint32_t frame, struct mac_data_ind);)
protected_rlc_am( void rlc_am_rx (void *, const frame_t frame, struct mac_data_ind);)
/*! \fn struct mac_status_resp rlc_am_mac_status_indication (void *rlcP, uint32_t frame,uint16_t tbs_sizeP, struct mac_status_ind tx_statusP)
* \brief Request the maximum number of bytes that can be served by RLC instance to MAC and fix the amount of bytes requested by MAC for next RLC transmission.
......@@ -235,7 +249,7 @@ protected_rlc_am( void rlc_am_rx (void *, uint32_t frame, struct mac_data_in
* \param[in] tx_statusP Transmission status given by MAC on previous MAC transmission of the PDU.
* \return The maximum number of bytes that can be served by RLC instance to MAC.
*/
public_rlc_am( struct mac_status_resp rlc_am_mac_status_indication (void *rlcP, uint32_t frame, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP);)
public_rlc_am( struct mac_status_resp rlc_am_mac_status_indication (void *rlcP, const frame_t frame, uint16_t tbs_sizeP, struct mac_status_ind tx_statusP);)
/*! \fn struct mac_data_req rlc_am_mac_data_request (void *rlcP, uint32_t frame)
* \brief Gives PDUs to lower layer MAC.
......@@ -243,16 +257,16 @@ public_rlc_am( struct mac_status_resp rlc_am_mac_status_indication (void *rlc
* \param[in] frame Frame index.
* \return A PDU of the previously requested number of bytes, and the updated maximum number of bytes that can be served by RLC instance to MAC for next RLC transmission.
*/
public_rlc_am( struct mac_data_req rlc_am_mac_data_request (void *rlcP, uint32_t frame);)
public_rlc_am( struct mac_data_req rlc_am_mac_data_request (void *rlcP, const frame_t frame);)
/*! \fn void rlc_am_mac_data_indication (void *rlcP, uint32_t frame, uint8_t eNB_flag, struct mac_data_ind data_indP)
/*! \fn void rlc_am_mac_data_indication (void *rlcP, uint32_t frame, const eNB_flag_t eNB_flag, struct mac_data_ind data_indP)
* \brief Receive PDUs from lower layer MAC.
* \param[in] rlcP RLC UM protocol instance pointer.
* \param[in] frame Frame index.
* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0).
* \param[in] data_indP PDUs from MAC.
*/
public_rlc_am( void rlc_am_mac_data_indication (void *rlcP, uint32_t frame, uint8_t eNB_flag, struct mac_data_ind data_indP);)
public_rlc_am( void rlc_am_mac_data_indication (void *rlcP, const frame_t frame, const eNB_flag_t eNB_flag, struct mac_data_ind data_indP);)
/*! \fn void rlc_am_data_req (void *rlcP, uint32_t frame, mem_block_t *sduP)
* \brief Interface with higher layers, buffer higher layer SDUS for transmission.
......@@ -260,6 +274,6 @@ public_rlc_am( void rlc_am_mac_data_indication (void *rlcP, uint32_t fram
* \param[in] frame Frame index.
* \param[in] sduP SDU. (A struct rlc_am_data_req is mapped on sduP->data.)
*/
public_rlc_am( void rlc_am_data_req (void *rlcP, uint32_t frame, mem_block_t *sduP);)
public_rlc_am( void rlc_am_data_req (void *rlcP, const frame_t frame, mem_block_t *sduP);)
/** @} */
# endif
......@@ -73,7 +73,6 @@ typedef struct rlc_am_entity_s {
//---------------------------------------------------------------------
// TX BUFFERS
//---------------------------------------------------------------------
mem_block_t* input_sdus_alloc; /*!< \brief Allocated memory for the input SDU buffer (for SDUs coming from upper layers). */
rlc_am_tx_sdu_management_t *input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). */
signed int nb_sdu; /*!< \brief Total number of valid rlc_am_tx_sdu_management_t in input_sdus[]. */
signed int nb_sdu_no_segmented; /*!< \brief Total number of SDUs not segmented and partially segmented. */
......@@ -81,7 +80,6 @@ typedef struct rlc_am_entity_s {
signed int current_sdu_index; /*!< \brief Current SDU index in input_sdus array to be segmented. */
mem_block_t* pdu_retrans_buffer_alloc; /*!< \brief Allocated memory for the retransmission buffer. */
rlc_am_tx_data_pdu_management_t *pdu_retrans_buffer; /*!< \brief Retransmission buffer. */
signed int retrans_num_pdus; /*!< \brief Number of PDUs in the retransmission buffer. */
signed int retrans_num_bytes; /*!< \brief Number of bytes in the retransmission buffer. */
......@@ -175,7 +173,7 @@ typedef struct rlc_am_entity_s {
//---------------------------------------------------------------------
// OUTPUTS
//---------------------------------------------------------------------
uint16_t nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */
sdu_size_t nb_bytes_requested_by_mac; /*!< \brief Number of bytes requested by lower layer for next transmission. */
list_t pdus_to_mac_layer; /*!< \brief PDUs buffered for transmission to MAC layer. */
list_t control_pdu_list; /*!< \brief Control PDUs buffered for transmission to MAC layer. */
rlc_sn_t first_retrans_pdu_sn; /*!< \brief Lowest sequence number of PDU to be retransmitted. */
......
......@@ -45,7 +45,10 @@ Address : EURECOM,
#define TRACE_RLC_AM_FREE_SDU
//-----------------------------------------------------------------------------
void rlc_am_free_in_sdu(rlc_am_entity_t *rlcP, frame_t frameP, unsigned int index_in_bufferP)
void rlc_am_free_in_sdu(
rlc_am_entity_t *const rlcP,
const frame_t frameP,
const unsigned int index_in_bufferP)
//-----------------------------------------------------------------------------
{
if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) {
......@@ -82,7 +85,9 @@ void rlc_am_free_in_sdu(rlc_am_entity_t *rlcP, frame_t frameP, unsigned int inde
}
// called when segmentation is done
//-----------------------------------------------------------------------------
void rlc_am_free_in_sdu_data(rlc_am_entity_t *rlcP, unsigned int index_in_bufferP)
void rlc_am_free_in_sdu_data(
rlc_am_entity_t *const rlcP,
const unsigned int index_in_bufferP)
//-----------------------------------------------------------------------------
{
if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) {
......@@ -95,7 +100,7 @@ void rlc_am_free_in_sdu_data(rlc_am_entity_t *rlcP, unsigned int index_in_buffer
}
}
//-----------------------------------------------------------------------------
signed int rlc_am_in_sdu_is_empty(rlc_am_entity_t *rlcP)
signed int rlc_am_in_sdu_is_empty(rlc_am_entity_t *const rlcP)
//-----------------------------------------------------------------------------
{
if (rlcP->nb_sdu == 0) {
......@@ -103,117 +108,3 @@ signed int rlc_am_in_sdu_is_empty(rlc_am_entity_t *rlcP)
}
return 0;
}
//uint8_t in_sdu_data_ring_buffer [RLC_AM_SDU_DATA_BUFFER_SIZE];
//rlc_am_in_sdu_control_t in_sdu_control_ring_buffer[RLC_AM_SDU_CONTROL_BUFFER_SIZE];
//signed int in_sdu_data_buffer_index_start;
//signed int in_sdu_data_buffer_index_end;
//signed int in_sdu_data_buffer_index_next;
//signed int in_sdu_control_buffer_index_start;
//signed int in_sdu_control_buffer_index_end;
//signed int in_sdu_control_buffer_index_next;
/*//-----------------------------------------------------------------------------
signed int rlc_am_in_sdu_data_get_available_size(rlc_am_entity_t *rlcP)
//-----------------------------------------------------------------------------
{
signed int index_diff = rlcP->in_sdu_data_buffer_index_next - rlcP->in_sdu_data_buffer_index_start;
if (index_diff > 0) {
return RLC_AM_SDU_DATA_BUFFER_SIZE - index_diff;
} else {
return 0 - index_diff;
}
}
//-----------------------------------------------------------------------------
signed int rlc_am_in_sdu_control_get_available_size(rlc_am_entity_t *rlcP)
//-----------------------------------------------------------------------------
{
signed int index_diff = rlcP->in_sdu_control_buffer_index_next - rlcP->in_sdu_control_buffer_index_start;
if (index_diff > 0) {
return RLC_AM_SDU_CONTROL_BUFFER_SIZE - index_diff;
} else {
return 0 - index_diff;
}
}
//-----------------------------------------------------------------------------
void rlc_am_in_sdu_data_copy_sdu(rlc_am_entity_t *rlcP, char* sourceP, unsigned int sizeP, unsigned int muiP)
//-----------------------------------------------------------------------------
{
signed int index_diff = rlcP->in_sdu_data_buffer_index_next - rlcP->in_sdu_data_buffer_index_start;
if (index_diff > 0) {
signed int available_size_first_write = RLC_AM_SDU_DATA_BUFFER_SIZE - rlcP->in_sdu_data_buffer_index_next;
if (sizeP <= available_size_first_write) {
memcpy(&rlcP->in_sdu_data_ring_buffer[rlcP->in_sdu_data_buffer_index_next],
sourceP,
sizeP);
} else {
memcpy(&rlcP->in_sdu_data_ring_buffer[rlcP->in_sdu_data_buffer_index_next],
sourceP,
available_size_first_write);
memcpy(&rlcP->in_sdu_data_ring_buffer[0],
&sourceP[available_size_first_write],
sizeP - available_size_first_write);
}
} else {
memcpy(&rlcP->in_sdu_data_ring_buffer[rlcP->in_sdu_data_buffer_index_next],
sourceP,
sizeP);
}
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].sdu_data_buffer_index_start = rlcP->in_sdu_data_buffer_index_next;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].sdu_data_buffer_index_end = (rlcP->in_sdu_data_buffer_index_end + sizeP) % RLC_AM_SDU_DATA_BUFFER_SIZE;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].sdu_size = sizeP;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].sdu_mui = muiP;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].sdu_segmented_size = 0;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].nb_pdus = 0;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].nb_pdus_ack = 0;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].segmented = 0;
rlcP->in_sdu_control_ring_buffer[rlcP->in_sdu_control_buffer_index_next].discarded = 0;
rlcP->in_sdu_data_buffer_index_end = (rlcP->in_sdu_data_buffer_index_end + sizeP) % RLC_AM_SDU_DATA_BUFFER_SIZE;
rlcP->in_sdu_data_buffer_index_next = (rlcP->in_sdu_data_buffer_index_end + 1) % RLC_AM_SDU_DATA_BUFFER_SIZE;
rlcP->in_sdu_control_buffer_index_end = (rlcP->in_sdu_control_buffer_index_end + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE;
rlcP->in_sdu_control_buffer_index_next = (rlcP->in_sdu_control_buffer_index_end + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE;
//rlc->stat_tx_pdcp_sdu += 1;
}
//-----------------------------------------------------------------------------
void rlc_am_in_sdu_data_req (rlc_am_entity_t *rlcP, mem_block_t * sduP)
//-----------------------------------------------------------------------------
{
uint32_t mui;
uint16_t data_offset;
uint16_t data_size;
if (rlcP->protocol_state == RLC_NULL_STATE) {
#ifdef DEBUG_RLC_AM_DATA_REQUEST
msg ("[RLC_AM] RLC_AM_DATA_REQ RLC NOT INITIALIZED, DISCARD SDU\n");
#endif
free_mem_block (sduP);
}
signed int size_available_in_data_buffer = rlc_am_in_sdu_data_get_available_size();
signed int size_available_in_control_buffer = rlc_am_in_sdu_control_get_available_size();
if ((size_available_in_control_buffer > 0) && (size_available_in_control_buffer > 0)){
// parameters from SDU
mui = ((struct rlc_am_data_req *) (sduP->data))->mui;
data_offset = ((struct rlc_am_data_req *) (sduP->data))->data_offset;
data_size = ((struct rlc_am_data_req *) (sduP->data))->data_size;
rlc_am_in_sdu_data_copy_sdu(rlcP, &sduP->data[data_offset], data_size, mui);
} else {
#ifdef DEBUG_RLC_AM_DATA_REQUEST
msg ("[RLC_AM][RB %d] RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d\n",
rlcP->rb_id, size_available_in_control_buffer, rlcP->in_sdu_control_buffer_index_start, rlcP->in_sdu_control_buffer_index_end, size_available_in_data_buffer);
#endif
rlc->stat_tx_pdcp_sdu_discarded += 1;
free_mem_block (sduP);
}
}*/
......@@ -53,10 +53,8 @@ void rlc_am_init(rlc_am_entity_t *rlc_pP, frame_t frameP)
list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST");
//LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t));
rlc_pP->input_sdus_alloc = get_free_mem_block(RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t));
rlc_pP->input_sdus = (rlc_am_tx_sdu_management_t*)((rlc_pP->input_sdus_alloc)->data);
rlc_pP->pdu_retrans_buffer_alloc = get_free_mem_block((uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t)));
rlc_pP->pdu_retrans_buffer = (rlc_am_tx_data_pdu_management_t*)((rlc_pP->pdu_retrans_buffer_alloc)->data);
rlc_pP->input_sdus = calloc(1, RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t));
rlc_pP->pdu_retrans_buffer = calloc(1, (uint16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t)));
LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][INIT] input_sdus[] = %p element size=%d\n", frameP, rlc_pP->input_sdus,sizeof(rlc_am_tx_sdu_management_t));
LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][INIT] pdu_retrans_buffer[] = %p element size=%d\n", frameP, rlc_pP->pdu_retrans_buffer,sizeof(rlc_am_tx_data_pdu_management_t));
......@@ -79,11 +77,10 @@ void rlc_am_init(rlc_am_entity_t *rlc_pP, frame_t frameP)
rlc_pP->first_retrans_pdu_sn = -1;
}
//-----------------------------------------------------------------------------
void rlc_am_cleanup(rlc_am_entity_t *rlc_pP, frame_t frameP)
void rlc_am_cleanup(rlc_am_entity_t *rlc_pP)
//-----------------------------------------------------------------------------
{
LOG_I(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][CLEANUP]\n",
frameP,
<