Commit d247ee79 authored by Robert Schmidt's avatar Robert Schmidt

Make unified UE/eNB PDCP task

* reorganize function pdcp_run() into pdcp_task() as ITTI task
* comment all calls to pdcp_run()
* rename all PDCP_TASK_UE/PDCP_TASK_ENB occurences to PDCP_TASK
* define PDCP_UPDATE_STATS message
parent f2c5c0f7
......@@ -90,7 +90,7 @@
<TASK_PHY_ENB enabled="1"/>
<TASK_MAC_ENB enabled="1"/>
<TASK_RLC_ENB enabled="1"/>
<TASK_PDCP_ENB enabled="1"/>
<TASK_PDCP enabled="1"/>
<TASK_RRC_ENB enabled="1"/>
<TASK_RAL_ENB enabled="1"/>
<TASK_S1AP enabled="1"/>
......@@ -100,7 +100,6 @@
<TASK_PHY_UE enabled="1"/>
<TASK_MAC_UE enabled="1"/>
<TASK_RLC_UE enabled="1"/>
<TASK_PDCP_UE enabled="1"/>
<TASK_RRC_UE enabled="1"/>
<TASK_NAS_UE enabled="1"/>
<TASK_RAL_UE enabled="1"/>
......@@ -113,7 +112,7 @@
<TASK_PHY_ENB enabled="1"/>
<TASK_MAC_ENB enabled="1"/>
<TASK_RLC_ENB enabled="1"/>
<TASK_PDCP_ENB enabled="1"/>
<TASK_PDCP enabled="1"/>
<TASK_RRC_ENB enabled="1"/>
<TASK_RAL_ENB enabled="1"/>
<TASK_S1AP enabled="1"/>
......@@ -123,7 +122,6 @@
<TASK_PHY_UE enabled="1"/>
<TASK_MAC_UE enabled="1"/>
<TASK_RLC_UE enabled="1"/>
<TASK_PDCP_UE enabled="1"/>
<TASK_RRC_UE enabled="1"/>
<TASK_NAS_UE enabled="1"/>
<TASK_RAL_UE enabled="1"/>
......
......@@ -126,10 +126,10 @@
<TASK_TIMER enabled="1"/>
<TASK_L2L1 enabled="1"/>
<TASK_BM enabled="1"/>
<TASK_PDCP enabled="1"/>
<TASK_PHY_ENB enabled="1"/>
<TASK_MAC_ENB enabled="1"/>
<TASK_RLC_ENB enabled="1"/>
<TASK_PDCP_ENB enabled="1"/>
<TASK_RRC_ENB enabled="1"/>
<TASK_RAL_ENB enabled="1"/>
<TASK_S1AP enabled="1"/>
......@@ -139,7 +139,6 @@
<TASK_PHY_UE enabled="1"/>
<TASK_MAC_UE enabled="1"/>
<TASK_RLC_UE enabled="1"/>
<TASK_PDCP_UE enabled="1"/>
<TASK_RRC_UE enabled="1"/>
<TASK_NAS_UE enabled="1"/>
<TASK_RAL_UE enabled="1"/>
......@@ -149,10 +148,10 @@
<TASK_TIMER enabled="1"/>
<TASK_L2L1 enabled="1"/>
<TASK_BM enabled="1"/>
<TASK_PDCP enabled="1"/>
<TASK_PHY_ENB enabled="1"/>
<TASK_MAC_ENB enabled="1"/>
<TASK_RLC_ENB enabled="1"/>
<TASK_PDCP_ENB enabled="1"/>
<TASK_RRC_ENB enabled="1"/>
<TASK_RAL_ENB enabled="1"/>
<TASK_S1AP enabled="1"/>
......@@ -162,7 +161,6 @@
<TASK_PHY_UE enabled="1"/>
<TASK_MAC_UE enabled="1"/>
<TASK_RLC_UE enabled="1"/>
<TASK_PDCP_UE enabled="1"/>
<TASK_RRC_UE enabled="1"/>
<TASK_NAS_UE enabled="1"/>
<TASK_RAL_UE enabled="1"/>
......
......@@ -343,7 +343,6 @@ typedef struct {
MAC_MEAS_REQ_ENTRY* (*mac_meas_req)(uint8_t , MAC_MEAS_REQ*);
void (*mac_out_of_sync_ind)(uint8_t,uint32_t,unsigned short);
//RLC_INTERFACE_FUNCTIONS
void (*pdcp_run)(void);
void (*pdcp_data_req)(module_id_t, rb_id_t, sdu_size_t, char*);
signed int (*rrc_rlc_config_req)(unsigned int, unsigned int, unsigned int, unsigned int, rlc_info_t );
int (*rrc_mac_config_req)(uint8_t Mod_id,uint8_t eNB_flag,uint8_t UE_id,uint8_t eNB_index,
......
......@@ -31,3 +31,4 @@
MESSAGE_DEF(RRC_DCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataReq, rrc_dcch_data_req)
MESSAGE_DEF(RRC_DCCH_DATA_IND, MESSAGE_PRIORITY_MED_PLUS, RrcDcchDataInd, rrc_dcch_data_ind)
MESSAGE_DEF(RRC_PCCH_DATA_REQ, MESSAGE_PRIORITY_MED_PLUS, RrcPcchDataReq, rrc_pcch_data_req)
MESSAGE_DEF(PDCP_UPDATE_STATS, MESSAGE_PRIORITY_MED, IttiMsgEmpty, pdcp_update_stats)
......@@ -34,6 +34,7 @@
#define RRC_DCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_req
#define RRC_DCCH_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.rrc_dcch_data_ind
#define RRC_PCCH_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.rrc_pcch_data_req
#define PDCP_UPDATE_STATS(mSGpTR) (mSGpTR)->ittiMsg.pdcp_update_stats
//-------------------------------------------------------------------------------------------//
// Messages between RRC and PDCP layers
......
......@@ -36,7 +36,6 @@ TASK_DEF(TASK_BM, TASK_PRIORITY_MED, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_PHY_ENB, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_MAC_ENB, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_RLC_ENB, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_ENB, 200)
/// Radio Resource Control task
TASK_DEF(TASK_RRC_ENB, TASK_PRIORITY_MED, 200)
......@@ -48,6 +47,8 @@ TASK_DEF(TASK_RRC_ENB_NB_IoT, TASK_PRIORITY_MED, 200)
/// RAL task for ENB
TASK_DEF(TASK_RAL_ENB, TASK_PRIORITY_MED, 200)
/// common eNB and UE PDCP task
TASK_DEF(TASK_PDCP, TASK_PRIORITY_MED, 200)
// UDP TASK
TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000)
// GTP_V1U task
......@@ -63,13 +64,11 @@ TASK_DEF(TASK_SCTP, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_ENB_APP, TASK_PRIORITY_MED, 200)
/// eNB Agent task
TASK_DEF(TASK_FLEXRAN_AGENT, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_PROTO_AGENT, TASK_PRIORITY_MED, 200)
// UE tasks and sub-tasks:
//// Layer 2 and Layer 1 sub-tasks
SUB_TASK_DEF(TASK_L2L1, TASK_PHY_UE, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_MAC_UE, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_RLC_UE, 200)
SUB_TASK_DEF(TASK_L2L1, TASK_PDCP_UE, 200)
/// Radio Resource Control task
TASK_DEF(TASK_RRC_UE, TASK_PRIORITY_MED, 200)
......
......@@ -623,7 +623,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,
NOT_A_RNTI, frameP, subframeP,
module_idP);
pdcp_run(&ctxt);
//pdcp_run(&ctxt);
rrc_rx_tx(&ctxt, CC_id);
#endif
......
......@@ -2485,10 +2485,9 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
//------------------------------------------------------------------------------
// called at each subframe
// Performs :
// 1. Trigger PDCP every 5ms
// 2. Call RRC for link status return to PHY
// 3. Perform SR/BSR procedures for scheduling feedback
// 4. Perform PHR procedures
// 1. Call RRC for link status return to PHY
// 2. Perform SR/BSR procedures for scheduling feedback
// 3. Perform PHR procedures
UE_L2_STATE_t
ue_scheduler(const module_id_t module_idP,
......@@ -2561,7 +2560,7 @@ ue_scheduler(const module_id_t module_idP,
//Rrc_xface->Frame_index=Mac_rlc_xface->frameP;
//if (subframe%5 == 0)
//LG#ifdef EXMIMO
pdcp_run(&ctxt);
//pdcp_run(&ctxt);
//#endif
UE_mac_inst[module_idP].txFrame = txFrameP;
UE_mac_inst[module_idP].txSubframe = txSubframeP;
......
......@@ -420,8 +420,8 @@ boolean_t pdcp_data_req(
(RC.rrc[ctxt_pP->module_id]->node_type == ngran_gNB_CU) ) {
// DL transfer
MessageDef *message_p;
// Note: the acyual task must be TASK_PDCP_ENB, but this task is not created
message_p = itti_alloc_new_message (TASK_PDCP_ENB, F1AP_DL_RRC_MESSAGE);
// Note: the acyual task must be TASK_PDCP, but this task is not created
message_p = itti_alloc_new_message (TASK_PDCP, F1AP_DL_RRC_MESSAGE);
F1AP_DL_RRC_MESSAGE (message_p).rrc_container = &pdcp_pdu_p->data[0] ;
F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = pdcp_pdu_size;
F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
......@@ -815,11 +815,11 @@ pdcp_data_ind(
rb_id + 4,
sdu_buffer_sizeP - payload_offset);
//LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset);
gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
gtpu_buffer_p = itti_malloc(TASK_PDCP, TASK_GTPV1_U,
sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX);
AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
memcpy(&gtpu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset);
message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
message_p = itti_alloc_new_message(TASK_PDCP, GTPV1U_ENB_TUNNEL_DATA_REQ);
AssertFatal(message_p != NULL, "OUT OF MEMORY");
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset;
......@@ -999,109 +999,10 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){
}
}
//-----------------------------------------------------------------------------
void
pdcp_run (
const protocol_ctxt_t* const ctxt_pP
void pdcp_process_fifo(
const protocol_ctxt_t* const ctxt_pP
)
//-----------------------------------------------------------------------------
{
if (ctxt_pP->enb_flag) {
start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else {
start_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run);
}
pdcp_enb[ctxt_pP->module_id].sfn++; // range: 0 to 18,446,744,073,709,551,615
pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023
pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe;
pdcp_update_stats(ctxt_pP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_IN);
#if defined(ENABLE_ITTI)
MessageDef *msg_p;
int result;
protocol_ctxt_t ctxt;
do {
// Checks if a message has been sent to PDCP sub-task
itti_poll_msg (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p);
if (msg_p != NULL) {
switch (ITTI_MSG_ID(msg_p)) {
case RRC_DCCH_DATA_REQ:
PROTOCOL_CTXT_SET_BY_MODULE_ID(
&ctxt,
RRC_DCCH_DATA_REQ (msg_p).module_id,
RRC_DCCH_DATA_REQ (msg_p).enb_flag,
RRC_DCCH_DATA_REQ (msg_p).rnti,
RRC_DCCH_DATA_REQ (msg_p).frame,
0,
RRC_DCCH_DATA_REQ (msg_p).eNB_index);
LOG_I(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
PROTOCOL_CTXT_ARGS(&ctxt),
ITTI_MSG_NAME (msg_p),
ITTI_MSG_ORIGIN_NAME(msg_p),
ITTI_MSG_INSTANCE (msg_p),
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).mode);
log_dump(PDCP, RRC_DCCH_DATA_REQ (msg_p).sdu_p, RRC_DCCH_DATA_REQ (msg_p).sdu_size, LOG_DUMP_CHAR,"[MSG] pdcp run\n");
result = pdcp_data_req (&ctxt,
SRB_FLAG_YES,
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).sdu_size,
RRC_DCCH_DATA_REQ (msg_p).sdu_p,
RRC_DCCH_DATA_REQ (msg_p).mode
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
, NULL, NULL
#endif
);
if (result != TRUE)
LOG_E(PDCP, "PDCP data request failed!\n");
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_REQ (msg_p).sdu_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
break;
case RRC_PCCH_DATA_REQ:
{
sdu_size_t sdu_buffer_sizeP;
sdu_buffer_sizeP = RRC_PCCH_DATA_REQ(msg_p).sdu_size;
uint8_t CC_id = RRC_PCCH_DATA_REQ(msg_p).CC_id;
uint8_t ue_index = RRC_PCCH_DATA_REQ(msg_p).ue_index;
RC.rrc[ctxt_pP->module_id]->carrier[CC_id].sizeof_paging[ue_index] = sdu_buffer_sizeP;
if (sdu_buffer_sizeP > 0) {
memcpy(RC.rrc[ctxt_pP->module_id]->carrier[CC_id].paging[ue_index], RRC_PCCH_DATA_REQ(msg_p).sdu_p, sdu_buffer_sizeP);
}
//paging pdcp log
LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP);
}
break;
default:
LOG_E(PDCP, "Received unexpected message %s\n", ITTI_MSG_NAME (msg_p));
break;
}
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
}
} while(msg_p != NULL);
#endif
// IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
......@@ -1127,14 +1028,108 @@ pdcp_run (
} else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_ip);
}
}
#if defined(ENABLE_ITTI)
//-----------------------------------------------------------------------------
void
pdcp_task(void *arg)
{
//-----------------------------------------------------------------------------
MessageDef *msg_p;
int result;
protocol_ctxt_t ctxt;
instance_t instance;
LOG_I(PDCP, "Starting PDCP task\n");
itti_mark_task_ready(TASK_PDCP);
while (1) {
itti_receive_msg(TASK_PDCP, &msg_p);
instance = ITTI_MSG_INSTANCE(msg_p);
switch (ITTI_MSG_ID(msg_p)) {
case RRC_DCCH_DATA_REQ:
PROTOCOL_CTXT_SET_BY_MODULE_ID(
&ctxt,
RRC_DCCH_DATA_REQ (msg_p).module_id,
RRC_DCCH_DATA_REQ (msg_p).enb_flag,
RRC_DCCH_DATA_REQ (msg_p).rnti,
RRC_DCCH_DATA_REQ (msg_p).frame,
0,
RRC_DCCH_DATA_REQ (msg_p).eNB_index);
LOG_I(PDCP, PROTOCOL_CTXT_FMT"Received %s from %s: instance %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
PROTOCOL_CTXT_ARGS(&ctxt),
ITTI_MSG_NAME (msg_p),
ITTI_MSG_ORIGIN_NAME(msg_p),
ITTI_MSG_INSTANCE (msg_p),
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).mode);
log_dump(PDCP, RRC_DCCH_DATA_REQ (msg_p).sdu_p, RRC_DCCH_DATA_REQ (msg_p).sdu_size, LOG_DUMP_CHAR,"[MSG] pdcp run\n");
result = pdcp_data_req (&ctxt,
SRB_FLAG_YES,
RRC_DCCH_DATA_REQ (msg_p).rb_id,
RRC_DCCH_DATA_REQ (msg_p).muip,
RRC_DCCH_DATA_REQ (msg_p).confirmp,
RRC_DCCH_DATA_REQ (msg_p).sdu_size,
RRC_DCCH_DATA_REQ (msg_p).sdu_p,
RRC_DCCH_DATA_REQ (msg_p).mode
#if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
, NULL, NULL
#endif
);
if (result != TRUE)
LOG_E(PDCP, "PDCP data request failed!\n");
break;
case RRC_PCCH_DATA_REQ:
{
sdu_size_t sdu_buffer_sizeP;
sdu_buffer_sizeP = RRC_PCCH_DATA_REQ(msg_p).sdu_size;
uint8_t CC_id = RRC_PCCH_DATA_REQ(msg_p).CC_id;
uint8_t ue_index = RRC_PCCH_DATA_REQ(msg_p).ue_index;
RC.rrc[instance]->carrier[CC_id].sizeof_paging[ue_index] = sdu_buffer_sizeP;
if (sdu_buffer_sizeP > 0)
memcpy(RC.rrc[instance]->carrier[CC_id].paging[ue_index],
RRC_PCCH_DATA_REQ(msg_p).sdu_p, sdu_buffer_sizeP);
LOG_D(PDCP, "PDCP Received RRC_PCCH_DATA_REQ CC_id %d length %d \n", CC_id, sdu_buffer_sizeP);
}
break;
case PDCP_UPDATE_STATS:
//pdcp_process_fifo(ctxt_pP);
//pdcp_enb[ctxt_pP->module_id].sfn++; // range: 0 to 18,446,744,073,709,551,615
//pdcp_enb[ctxt_pP->module_id].frame=ctxt_pP->frame; // 1023
//pdcp_enb[ctxt_pP->module_id].subframe= ctxt_pP->subframe;
//pdcp_update_stats(ctxt_pP);
break;
case TERMINATE_MESSAGE:
LOG_W(PDCP, " *** Exiting PDCP task\n");
itti_exit_task();
break;
default:
LOG_E(PDCP, "Received unexpected message %s (%d)\n", ITTI_MSG_NAME(msg_p), ITTI_MSG_ID(msg_p));
break;
}
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
msg_p = NULL;
} // while
if (ctxt_pP->enb_flag) {
stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].pdcp_run);
} else {
stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].pdcp_run);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT);
}
#endif
void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP){
int i, ue_flag=1; //, ret=-1; to be decied later
......
......@@ -116,7 +116,6 @@ typedef struct pdcp_enb_s {
pdcp_enb_t pdcp_enb[MAX_NUM_CCs];
typedef struct pdcp_stats_s {
time_stats_t pdcp_run;
time_stats_t data_req;
time_stats_t data_ind;
time_stats_t apply_security; //
......@@ -367,15 +366,14 @@ boolean_t pdcp_remove_UE(
*/
//void rrc_pdcp_config_release ( const protocol_ctxt_t* const ctxt_pP, rb_id_t);
/*! \fn void pdcp_run(const protocol_ctxt_t* const ctxt_pP)
* \brief Runs PDCP entity to let it handle incoming/outgoing SDUs
* \param[in] ctxt_pP Running context.
/*! \fn void pdcp_task(void *args)
* \brief Runs PDCP task to let it handle incoming/outgoing SDUs
* \param[in] args initial args
* \return none
* \note None
* @ingroup _pdcp
*/
void pdcp_run (
const protocol_ctxt_t* const ctxt_pP);
void pdcp_task(void *args);
int pdcp_module_init (void);
void pdcp_module_cleanup (void);
void pdcp_layer_init (void);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file pdcp_thread.c
* \brief
* \author F. Kaltenberger
* \date 2013
* \version 0.1
* \company Eurecom
* \email: florian.kaltenberger@eurecom.fr
* \note
* \warning
*/
#include <pthread.h>
//#include <inttypes.h>
#include "pdcp.h"
#include "PHY/extern.h" //for PHY_vars
#include "UTIL/LOG/log.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "msc.h"
#define OPENAIR_THREAD_STACK_SIZE 8192
#define OPENAIR_THREAD_PRIORITY 255
extern int oai_exit;
extern char UE_flag;
pthread_t pdcp_thread;
pthread_attr_t pdcp_thread_attr;
pthread_mutex_t pdcp_mutex;
pthread_cond_t pdcp_cond;
int pdcp_instance_cnt;
static void *pdcp_thread_main(void* param);
static void *pdcp_thread_main(void* param)
{
uint8_t eNB_flag = !UE_flag;
LOG_I(PDCP,"This is pdcp_thread eNB_flag = %d\n",eNB_flag);
MSC_START_USE();
while (!oai_exit) {
if (pthread_mutex_lock(&pdcp_mutex) != 0) {
LOG_E(PDCP,"Error locking mutex.\n");
} else {
while (pdcp_instance_cnt < 0) {
pthread_cond_wait(&pdcp_cond,&pdcp_mutex);
}
if (pthread_mutex_unlock(&pdcp_mutex) != 0) {
LOG_E(PDCP,"Error unlocking mutex.\n");
}
}
if (oai_exit) break;
if (eNB_flag) {
pdcp_run(PHY_vars_eNB_g[0]->frame, eNB_flag, PHY_vars_eNB_g[0]->Mod_id, 0);
LOG_D(PDCP,"Calling pdcp_run (eNB) for frame %d\n",PHY_vars_eNB_g[0]->frame);
} else {
pdcp_run(PHY_vars_UE_g[0]->frame, eNB_flag, 0, PHY_vars_UE_g[0]->Mod_id);
LOG_D(PDCP,"Calling pdcp_run (UE) for frame %d\n",PHY_vars_UE_g[0]->frame);
}
if (pthread_mutex_lock(&pdcp_mutex) != 0) {
LOG_E(PDCP,"Error locking mutex.\n");
} else {
pdcp_instance_cnt--;
if (pthread_mutex_unlock(&pdcp_mutex) != 0) {
LOG_E(PDCP,"Error unlocking mutex.\n");
}
}
}
return(NULL);
}
int init_pdcp_thread(void)
{
int error_code;
struct sched_param p;
pthread_attr_init (&pdcp_thread_attr);
pthread_attr_setstacksize(&pdcp_thread_attr,OPENAIR_THREAD_STACK_SIZE);
//attr_dlsch_threads.priority = 1;
p.sched_priority = OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&pdcp_thread_attr, &p);
pthread_attr_setschedpolicy (&pdcp_thread_attr, SCHED_FIFO);
pthread_mutex_init(&pdcp_mutex,NULL);
pthread_cond_init(&pdcp_cond,NULL);
pdcp_instance_cnt = -1;
LOG_I(PDCP,"Allocating PDCP thread\n");
error_code = pthread_create(&pdcp_thread,
&pdcp_thread_attr,
pdcp_thread_main,
(void*)NULL);
if (error_code!= 0) {
LOG_I(PDCP,"Could not allocate PDCP thread, error %d\n",error_code);
return(error_code);
} else {
LOG_I(PDCP,"Allocate PDCP thread successful\n");
pthread_setname_np( pdcp_thread, "PDCP" );
}
return(0);
}
void cleanup_pdcp_thread(void)
{
void *status_p = NULL;
LOG_I(PDCP,"Scheduling PDCP thread to exit\n");
pdcp_instance_cnt = 0;
if (pthread_cond_signal(&pdcp_cond) != 0) {
LOG_I(PDCP,"ERROR pthread_cond_signal\n");
} else {
LOG_I(PDCP,"Signalled PDCP thread to exit\n");
}
pthread_join(pdcp_thread,&status_p);
LOG_I(PDCP,"PDCP thread exited\n");
pthread_cond_destroy(&pdcp_cond);
pthread_mutex_destroy(&pdcp_mutex);
}
......@@ -81,8 +81,7 @@ rrc_data_req(
message_buffer = itti_malloc (
ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE,
ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
sdu_sizeP);
TASK_PDCP, sdu_sizeP);
memcpy (message_buffer, buffer_pP, sdu_sizeP);
......@@ -101,13 +100,10 @@ rrc_data_req(
RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti;
RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index;
itti_send_msg_to_task (
ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
ctxt_pP->instance,
message_p);
LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP_ENB\n");
itti_send_msg_to_task (TASK_PDCP, ctxt_pP->instance, message_p);
LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP\n");
// RS/BK: Fix ME
pdcp_run(ctxt_pP);
//pdcp_run(ctxt_pP);
return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
......@@ -156,10 +152,10 @@ rrc_data_ind(
// Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
uint8_t *message_buffer;
message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
message_buffer = itti_malloc(TASK_PDCP, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
memcpy (message_buffer, buffer_pP, sdu_sizeP);
message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND);
message_p = itti_alloc_new_message(TASK_PDCP, RRC_DCCH_DATA_IND);
RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame;
RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index;
RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP;
......
......@@ -292,8 +292,7 @@ rrc_data_req_ue(
message_buffer = itti_malloc (
ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE,
ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
sdu_sizeP);
TASK_PDCP, sdu_sizeP);
memcpy (message_buffer, buffer_pP, sdu_sizeP);
......@@ -310,10 +309,7 @@ rrc_data_req_ue(
RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti;
RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index;
itti_send_msg_to_task (
TASK_PDCP_UE,
ctxt_pP->instance,
message_p);
itti_send_msg_to_task (TASK_PDCP, ctxt_pP->instance, message_p);
return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
}
......@@ -355,10 +351,10 @@ rrc_data_ind_ue(
// Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
uint8_t *message_buffer;
message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
message_buffer = itti_malloc(TASK_PDCP, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
memcpy (message_buffer, buffer_pP, sdu_sizeP);
message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND);
message_p = itti_alloc_new_message(TASK_PDCP, RRC_DCCH_DATA_IND);
RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame;
RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index;
RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP;
......
......@@ -1979,7 +1979,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
LOG_I(RRC, "do_Paging error");
return -1;
}
message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP_ENB, length);
message_buffer = itti_malloc (TASK_RRC_ENB, TASK_PDCP, length);
/* Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling). */
memcpy (message_buffer, buffer, length);
RRC_PCCH_DATA_REQ (message_p).sdu_size = length;
......@@ -1989,7 +1989,7 @@ int rrc_eNB_process_PAGING_IND(MessageDef *msg_p, const char *msg_name, instance
RRC_PCCH_DATA_REQ (message_p).ue_index = i;
RRC_PCCH_DATA_REQ (message_p).CC_id = CC_id;
LOG_D(RRC, "[eNB %d] CC_id %d In S1AP_PAGING_IND: send encdoed buffer to PDCP buffer_size %d\n", instance, CC_id, length);
itti_send_msg_to_task (TASK_PDCP_ENB, instance, message_p);
itti_send_msg_to_task (TASK_PDCP, instance, message_p);
}
}
}
......
......@@ -734,18 +734,7 @@ void nfapi_log(char *file, char *func, int line, int comp, int level, const char
break;
case PDCP:
switch (log_instance_type) {
case LOG_INSTANCE_ENB:
origin_task_id = TASK_PDCP_ENB;
break;
case LOG_INSTANCE_UE:
origin_task_id = TASK_PDCP_UE;
default:
break;
}
origin_task_id = TASK_PDCP;
break;
default:
......@@ -1224,18 +1213,7 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
break;
case PDCP:
switch (log_instance_type) {
case LOG_INSTANCE_ENB:
origin_task_id = TASK_PDCP_ENB;
break;
case LOG_INSTANCE_UE:
origin_task_id = TASK_PDCP_UE;
default:
break;
}
origin_task_id = TASK_PDCP;
break;
default:
......@@ -1500,18 +1478,7 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
break;
case PDCP:
switch (log_instance_type) {
case LOG_INSTANCE_ENB:
origin_task_id = TASK_PDCP_ENB;
break;
case LOG_INSTANCE_UE:
origin_task_id = TASK_PDCP_UE;
default:
break;
}
origin_task_id = TASK_PDCP;
break;
default:
......
......@@ -1928,7 +1928,7 @@ void* pre_scd_thread( void* param ){
pthread_mutex_unlock(&ru->proc.mutex_pre_scd);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, Mod_id, ENB_FLAG_YES,
NOT_A_RNTI, frame, subframe,Mod_id);
pdcp_run(&ctxt);
//pdcp_run(&ctxt);
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
......@@ -2945,4 +2945,4 @@ void RCconfig_RU(void) {
return;
}
\ No newline at end of file
}
......@@ -1083,14 +1083,14 @@ int main( int argc, char **argv )
}
if (RC.rrc[0]->node_type == ngran_eNB_CU || RC.rrc[0]->node_type == ngran_ng_eNB_CU) {
protocol_ctxt_t ctxt;
ctxt.module_id = 0 ;
ctxt.instance = 0;
ctxt.rnti = 0;
ctxt.enb_flag = 1;
pdcp_run(&ctxt);
}
//if (RC.rrc[0]->node_type == ngran_eNB_CU || RC.rrc[0]->node_type == ngran_ng_eNB_CU) {
// protocol_ctxt_t ctxt;
// ctxt.module_id = 0 ;
// ctxt.instance = 0;
// ctxt.rnti = 0;
// ctxt.enb_flag = 1;
// pdcp_run(&ctxt);
//}
/* start threads if only L1 or not a CU */
if (RC.nb_inst == 0 ||
......
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