Commit 153af28d authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

first version for supporting PC5-S

parent d5d6ecab
......@@ -33,8 +33,8 @@ OAI build/execute
- cp ../../../targets/bin/.ue* .
- cp ../../../targets/bin/.usim* .
- sudo insmod ../../../targets/bin/ue_ip.ko
UE1:
UE1:
- sudo ifconfig oip0 10.0.0.1
- sudo iptables -A POSTROUTING -t mangle -o oip0 -d 224.0.0.1 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eth0
......@@ -42,8 +42,11 @@ UE2:
- sudo ifconfig oip1 10.0.0.2
- sudo iptables -A POSTROUTING -t mangle -o oip1 -d 224.0.0.1 -j MARK --set-mark 3
- (if necessary) sudo route add default gw 10.10.10.1 eth0
Run UE1, then UE2
- sudo ./lte-softmodem-stub -U --emul_iface eth0
TEST ONE-TO-MANY
Run UE1 then UE2, for example:
UE1: sudo ./lte-softmodem-stub -U --emul_iface eth0
UE2: sudo ./lte-softmodem-stub -U --emul_iface eno1
Test with Ping
- Sender - UE1: ping -I oip0 224.0.0.1
......@@ -53,8 +56,6 @@ Test with Iperf
- Sender - UE1: iperf -c 224.0.0.1 -u -b 0.1M --bind 10.0.0.1 -t 100
- Receiver - UE2: sudo ./mcreceive 224.0.0.1 5001
......
......@@ -1368,6 +1368,7 @@ typedef struct {
int sltx_active;
SLSCH_t slsch;
ULSCH_PDU slsch_pdu;
int slsch_lcid;
#endif
/// number of attempt for rach
uint8_t RA_attempt_number;
......
......@@ -77,6 +77,7 @@ extern UL_IND_t *UL_INFO;
extern uint8_t nfapi_mode;
/*
*
#ifndef USER_MODE
#define msg debug_msg
#endif
......@@ -753,7 +754,6 @@ void ue_send_sl_sdu(module_id_t module_idP,
int rlc_sdu_len;
char *rlc_sdu;
uint32_t sourceL2Id;
uint32_t destinationL2Id =0x00000000;
// Notes: 1. no control elements are supported yet
......@@ -762,7 +762,7 @@ void ue_send_sl_sdu(module_id_t module_idP,
// extract header
SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu;
AssertFatal(longh->E==0,"E is non-zero\n");
AssertFatal(longh->LCID==3,"LCID is %d (not 3)\n",longh->LCID);
AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID);
//filter incoming packet based on destination address
destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
LOG_I( MAC, "[DestinationL2Id: %"PRIu32"] \n", destinationL2Id );
......@@ -771,7 +771,6 @@ void ue_send_sl_sdu(module_id_t module_idP,
LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
return;
}
//AssertFatal(((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (destinationL2Id == UE_mac_inst[module_idP].groupL2Id)), "Destination Id is neither matched with Source Id nor with Group Id \n")
if (longh->F==1) {
rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
......@@ -788,7 +787,7 @@ void ue_send_sl_sdu(module_id_t module_idP,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
3,
longh->LCID, //3/10
rlc_sdu,
rlc_sdu_len,
1,
......@@ -2736,11 +2735,12 @@ SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t
SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) {
mac_rlc_status_resp_t rlc_status;
mac_rlc_status_resp_t rlc_status, rlc_status_data;
uint32_t absSF = (frameP*10)+subframeP;
UE_MAC_INST *ue = &UE_mac_inst[module_idP];
int rvtab[4] = {0,2,3,1};
int sdu_length;
// Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch;
......@@ -2748,13 +2748,25 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
ue->sltx_active = 0;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (rlc_status.bytes_in_buffer > 2) {
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
10,
0xFFFF);//for signaling - hardcoded
rlc_status_data = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF); //for data - hardcoded
if (rlc_status.bytes_in_buffer > 2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
ue->slsch_lcid = 10;
}
else if (rlc_status_data.bytes_in_buffer >2){
LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status_data.bytes_in_buffer);
// Fill in group id for off-network communications
ue->sltx_active = 1;
ue->slsch_lcid = 3;
}
} // we're not in the SCCH period
else if (((absSF & 3) == 0 ) &&
......@@ -2762,14 +2774,15 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
// 10 PRBs, mcs 19
int TBS = 4584/8;
int req;
rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
3,
0xFFFF);
if (ue->slsch_lcid == 10) {
if (TBS<=rlc_status.bytes_in_buffer) req=TBS;
else req = rlc_status.bytes_in_buffer;
} else if (ue->slsch_lcid == 3){
if (TBS<=rlc_status_data.bytes_in_buffer) req=TBS;
else req = rlc_status_data.bytes_in_buffer;
}
if (req>0) {
sdu_length = mac_rlc_data_req(module_idP,
0x1234,
......@@ -2777,7 +2790,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
3,
ue->slsch_lcid,
req,
(char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG)));
......@@ -2787,8 +2800,8 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
if (sdu_length > 0) {
LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
LOG_I(MAC,"sourceL2Id %d: \n",ue->sourceL2Id);
LOG_I(MAC,"groupL2Id %d: \n",ue->groupL2Id);
LOG_I(MAC,"sourceL2Id: %d \n",ue->sourceL2Id);
LOG_I(MAC,"groupL2Id: %d \n",ue->groupL2Id);
slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
if (sdu_length < 128) {
......@@ -2797,14 +2810,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
shorth->F=0;
shorth->L=sdu_length;
shorth->E=0;
shorth->LCID=3;
/* shorth->SRC07=0x12;
shorth->SRC1623=0x56;
shorth->SRC815=0x34;
shorth->DST07=0x78;
shorth->DST815=0x9A;
shorth->DST1623=0xBC;*/
shorth->LCID=ue->slsch_lcid;
shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff;
shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
shorth->SRC1623 = ue->sourceL2Id & 0x000000ff;
......@@ -2820,15 +2826,7 @@ SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_
longh->L_LSB=sdu_length&0xff;
longh->L_MSB=(sdu_length>>8)&0x7f;
longh->E=0;
longh->LCID=3;
/*
longh->SRC07=0x12;
longh->SRC815=0x34;
longh->SRC1623=0x56;
longh->DST07=0x78;
longh->DST815=0x9A;
longh->DST1623=0xBC;
*/
longh->LCID=ue->slsch_lcid;
longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff;
longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
longh->SRC1623 = ue->sourceL2Id & 0x000000ff;
......
......@@ -403,6 +403,54 @@ struct pdcp_netlink_element_s {
uint8_t *data;
};
//TTN for D2D (PC5S)
#ifdef Rel14
#define PDCP_SOCKET_PORT_NO 9999 //temporary value
int pdcp_pc5_sockfd;
struct sockaddr_in prose_app_addr;
struct sockaddr_in pdcp_sin;
int pdcp_pc5_socket_init();
typedef enum SL_PC5S_TYPES_e {
SL_PC5S_INIT=1,
SL_DIRECT_COMMUNICATION_REQUEST,
SL_DIRECT_COMMUNICATION_ACCEPT,
SL_DIRECT_COMMUNICATION_REJECT,
SL_DIRECT_SECURITY_MODE_COMMAND,
SL_DIRECT_SECURITY_MODE_COMPLETE
} SL_PC5S_TYPES_t;
typedef struct {
SL_PC5S_TYPES_t msg_type;
uint16_t rb_id;
int32_t data_size;
uint8_t inst;
} __attribute__((__packed__)) pdcp_data_header_t;
//should be completed with other IEs (3GPP TS 24.334)
typedef struct {
uint16_t sequenceNumber;
uint8_t ipAddressConfig;
} __attribute__((__packed__)) PC5SDirectCommunicationRequest;
typedef struct {
uint16_t sequenceNumber;
uint8_t ipAddressConfig;
} __attribute__((__packed__)) PC5SDirectCommunicationAccept;
//example of PC5-S messages
typedef struct {
pdcp_data_header_t pdcp_data_header;
union {
PC5SDirectCommunicationRequest pc5s_direct_communication_req;
PC5SDirectCommunicationAccept pc5s_direct_communication_accept;
uint8_t status;
} pc5sPrimitive;
} __attribute__((__packed__)) sidelink_pc5s_element;
#endif
#if 0
/*
* Missing PDU information struct, a copy of this will be enqueued
......
......@@ -64,6 +64,7 @@ extern int otg_enabled;
#include "UTIL/LOG/vcd_signal_dumper.h"
#include "platform_constants.h"
#include "msc.h"
#include "pdcp.h"
#include "assertions.h"
......@@ -114,528 +115,794 @@ pdcp_data_req_header_t pdcp_read_header_g;
//-----------------------------------------------------------------------------
int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP)
{
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//#if defined(PDCP_USE_NETLINK) && defined(LINUX)
int ret = 0;
//#endif
//#if defined(PDCP_USE_NETLINK) && defined(LINUX)
int ret = 0;
//#endif
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
#define THREAD_NAME_LEN 16
static char threadname[THREAD_NAME_LEN];
ret = pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN);
if (ret != 0)
{
perror("pthread_getname_np : ");
exit_fun("Error getting thread name");
}
static char threadname[THREAD_NAME_LEN];
ret = pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN);
if (ret != 0)
{
perror("pthread_getname_np : ");
exit_fun("Error getting thread name");
}
#undef THREAD_NAME_LEN
#endif
#ifdef PDCP_SDU_FLUSH_LOCK
ret = pthread_mutex_trylock(&mtex);
if (ret == EBUSY) {
ret = pthread_mutex_trylock(&mtex);
if (ret == EBUSY) {
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
LOG_W(PDCP, "[%s] at SFN/SF=%d/%d wait for PDCP FIFO to be unlocked\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe);
LOG_W(PDCP, "[%s] at SFN/SF=%d/%d wait for PDCP FIFO to be unlocked\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe);
#endif
if (pthread_mutex_lock(&mtex)) {
exit_fun("PDCP_SDU_FLUSH_LOCK lock error!");
}
if (pthread_mutex_lock(&mtex)) {
exit_fun("PDCP_SDU_FLUSH_LOCK lock error!");
}
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
LOG_I(PDCP, "[%s] at SFN/SF=%d/%d PDCP FIFO is unlocked\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe);
LOG_I(PDCP, "[%s] at SFN/SF=%d/%d PDCP FIFO is unlocked\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe);
#endif
} else if (ret != 0) {
exit_fun("PDCP_SDU_FLUSH_LOCK trylock error!");
}
} else if (ret != 0) {
exit_fun("PDCP_SDU_FLUSH_LOCK trylock error!");
}
#endif
mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list);
int bytes_wrote = 0;
int pdcp_nb_sdu_sent = 0;
uint8_t cont = 1;
mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list);
int bytes_wrote = 0;
int pdcp_nb_sdu_sent = 0;
uint8_t cont = 1;
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
//MessageDef *message_p = NULL;
//MessageDef *message_p = NULL;
#endif
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 1 );
while (sdu_p && cont) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH, 1 );
while (sdu_p && cont) {
#ifdef DEBUG_PDCP_FIFO_FLUSH_SDU
LOG_D(PDCP, "[%s] SFN/SF=%d/%d inst=%d size=%d\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe,
((pdcp_data_ind_header_t*) sdu_p->data)->inst,
((pdcp_data_ind_header_t *) sdu_p->data)->data_size);
LOG_D(PDCP, "[%s] SFN/SF=%d/%d inst=%d size=%d\n",
threadname, ctxt_pP->frame, ctxt_pP->subframe,
((pdcp_data_ind_header_t*) sdu_p->data)->inst,
((pdcp_data_ind_header_t *) sdu_p->data)->data_size);
#else
#if ! defined(OAI_EMU)
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
/* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
// ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
#endif
#endif
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
if (ctxt_pP->enb_flag) {
AssertFatal(0, "Now execution should not go here");
LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
gtpv1u_new_data_req(
ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
&(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
0);
list_remove_head (&pdcp_sdu_list);
free_mem_block (sdu_p, __func__);
cont = 1;
pdcp_nb_sdu_sent += 1;
sdu_p = list_get_head (&pdcp_sdu_list);
LOG_D(OTG,"After GTPV1U\n");
continue; // loop again
}
if (ctxt_pP->enb_flag) {
AssertFatal(0, "Now execution should not go here");
LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
gtpv1u_new_data_req(
ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
&(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
0);
list_remove_head (&pdcp_sdu_list);
free_mem_block (sdu_p, __func__);
cont = 1;
pdcp_nb_sdu_sent += 1;
sdu_p = list_get_head (&pdcp_sdu_list);
LOG_D(OTG,"After GTPV1U\n");
continue; // loop again
}
#endif /* defined(ENABLE_USE_MME) */
#ifdef PDCP_DEBUG
LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n",
ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n",
ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
#endif //PDCP_DEBUG
cont = 0;
cont = 0;
//TTN - for D2D (PC5S)
#ifdef Rel14
sidelink_pc5s_element *sl_pc5s_msg_recv = NULL;
sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
char send_buf[BUFSIZE];
if ((((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id) == 10) { //hardcoded for PC5-Signaling
#ifdef PDCP_DEBUG
sl_pc5s_msg_recv = calloc(1, sizeof(sidelink_pc5s_element));
memcpy((void*)sl_pc5s_msg_recv, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header msg_type: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.msg_type);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header rb_id: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.rb_id);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header data_size: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.data_size);
LOG_D(PDCP,"[pdcp_fifo_flush_sdus]: Received DirectCommunicationRequest (PC5-S), header inst: %d)\n", sl_pc5s_msg_recv->pdcp_data_header.inst);
if (sl_pc5s_msg_recv->pdcp_data_header.msg_type == SL_DIRECT_COMMUNICATION_REQUEST){
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), seqno: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.sequenceNumber);
LOG_D(PDCP,"[pdcp_pc5_socket_thread_fct]: Received DirectCommunicationRequest (PC5-S), ipAddressConfig: %d)\n", sl_pc5s_msg_recv->pc5sPrimitive.pc5s_direct_communication_req.ipAddressConfig);
}
//send to ProSe app
LOG_D(RRC,"[pdcp_fifo_flush_sdus]: Send DirectCommunicationRequest to ProSe App \n");
#endif
memset(send_buf, 0, BUFSIZE);
//memcpy((void *)send_buf, (void *)sl_pc5s_msg_recv, sizeof(sidelink_pc5s_element));
memcpy((void *)send_buf, (void*)(sdu_p->data+sizeof(pdcp_data_ind_header_t)), sizeof(sidelink_pc5s_element));
//free(sl_ctrl_msg_send);
int prose_addr_len = sizeof(prose_app_addr);
int n = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_app_addr, prose_addr_len);
if (n < 0) {
LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
exit(EXIT_FAILURE);
}
if (!pdcp_output_sdu_bytes_to_write) {
if (!pdcp_output_header_bytes_to_write) {
pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
}
#endif
if (!pdcp_output_sdu_bytes_to_write) {
if (!pdcp_output_header_bytes_to_write) {
pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
}
#ifdef PDCP_USE_RT_FIFO
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
&(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
pdcp_output_header_bytes_to_write);
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
&(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
pdcp_output_header_bytes_to_write);
#else
#ifdef PDCP_USE_NETLINK
#ifdef LINUX
memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
pdcp_output_header_bytes_to_write);
nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write;
memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
pdcp_output_header_bytes_to_write);
nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write;
#endif //LINUX
#endif //PDCP_USE_NETLINK
bytes_wrote = pdcp_output_header_bytes_to_write;
bytes_wrote = pdcp_output_header_bytes_to_write;
#endif //PDCP_USE_RT_FIFO
#ifdef PDCP_DEBUG
LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n",
ctxt_pP->frame,
bytes_wrote);
LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n",
ctxt_pP->frame,
bytes_wrote);
#endif //PDCP_DEBUG
if (bytes_wrote > 0) {
pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote;
if (bytes_wrote > 0) {
pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote;
if (!pdcp_output_header_bytes_to_write) { // continue with sdu
pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size;
AssertFatal(pdcp_output_sdu_bytes_to_write >= 0, "invalid data_size!");
if (!pdcp_output_header_bytes_to_write) { // continue with sdu
pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size;
AssertFatal(pdcp_output_sdu_bytes_to_write >= 0, "invalid data_size!");
#ifdef PDCP_USE_RT_FIFO
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
#else
#ifdef PDCP_USE_NETLINK
#ifdef LINUX
memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_SIZE, pdcp_output_sdu_bytes_to_write);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 1 );
ret = sendmsg(nas_sock_fd,&nas_msg_tx,0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 0 );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_ERR, ret );
if (ret<0) {
LOG_E(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno);
MSC_LOG_TX_MESSAGE_FAILED(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
AssertFatal(1==0,"sendmsg failed for nas_sock_fd\n");
break;
} else {
MSC_LOG_TX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
}
memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_SIZE, pdcp_output_sdu_bytes_to_write);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 1 );
ret = sendmsg(nas_sock_fd,&nas_msg_tx,0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 0 );
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_ERR, ret );
if (ret<0) {
LOG_E(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno);
MSC_LOG_TX_MESSAGE_FAILED(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
AssertFatal(1==0,"sendmsg failed for nas_sock_fd\n");
break;
} else {
MSC_LOG_TX_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
NULL,
0,
MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
MSC_AS_TIME_ARGS(ctxt_pP),
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
}
#endif // LINUX
#endif //PDCP_USE_NETLINK
bytes_wrote= pdcp_output_sdu_bytes_to_write;
bytes_wrote= pdcp_output_sdu_bytes_to_write;
#endif // PDCP_USE_RT_FIFO
#ifdef PDCP_DEBUG
LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n",
ctxt_pP->frame,
((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
bytes_wrote,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n",
ctxt_pP->frame,
((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
bytes_wrote,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
#endif //PDCP_DEBUG
if (bytes_wrote > 0) {
pdcp_output_sdu_bytes_to_write -= bytes_wrote;
if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
// LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP);
LOG_D(PDCP,
"[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n",
ctxt_pP->frame,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
list_remove_head (&pdcp_sdu_list);
free_mem_block (sdu_p, __func__);
cont = 1;
pdcp_nb_sdu_sent += 1;
sdu_p = list_get_head (&pdcp_sdu_list);
if (bytes_wrote > 0) {
pdcp_output_sdu_bytes_to_write -= bytes_wrote;
if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
// LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP);
LOG_D(PDCP,
"[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n",
ctxt_pP->frame,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
list_remove_head (&pdcp_sdu_list);
free_mem_block (sdu_p, __func__);
cont = 1;
pdcp_nb_sdu_sent += 1;
sdu_p = list_get_head (&pdcp_sdu_list);
} else {
LOG_D(PDCP, "1 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write);
AssertFatal(pdcp_output_sdu_bytes_to_write > 0, "pdcp_output_sdu_bytes_to_write cannot be negative!");
}
} else {
LOG_W(PDCP, "2: RADIO->IP SEND SDU CONGESTION!\n");
}
} else {
LOG_D(PDCP, "1 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write);
AssertFatal(pdcp_output_sdu_bytes_to_write > 0, "pdcp_output_sdu_bytes_to_write cannot be negative!");
LOG_W(PDCP, "3: RADIO->IP SEND SDU CONGESTION!\n");
}
} else {
LOG_W(PDCP, "2: RADIO->IP SEND SDU CONGESTION!\n");
}
} else {
LOG_W(PDCP, "3: RADIO->IP SEND SDU CONGESTION!\n");
}
} else {
LOG_D(PDCP, "4 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote);
}
} else {
LOG_D(PDCP, "4 skip free_mem_block: bytes_wrote = %d\n", bytes_wrote);
}
} else {
// continue writing sdu
// continue writing sdu
#ifdef PDCP_USE_RT_FIFO
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
(uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])),
pdcp_output_sdu_bytes_to_write);
bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
(uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])),
pdcp_output_sdu_bytes_to_write);
#else // PDCP_USE_RT_FIFO
bytes_wrote = pdcp_output_sdu_bytes_to_write;
bytes_wrote = pdcp_output_sdu_bytes_to_write;
#endif // PDCP_USE_RT_FIFO
LOG_D(PDCP, "THINH 2 bytes_wrote = %d\n", bytes_wrote);
if (bytes_wrote > 0) {
pdcp_output_sdu_bytes_to_write -= bytes_wrote;
if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
//PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n");
list_remove_head (&pdcp_sdu_list);
free_mem_block (sdu_p, __func__);
cont = 1;
pdcp_nb_sdu_sent += 1;
sdu_p = list_get_head (&pdcp_sdu_list);
// LOG_D(PDCP, "rb sent a sdu from rab\n");
} else {
LOG_D(PDCP, "5 skip free_mem_block: pdcp_output_sdu_bytes_to_write = %d\n", pdcp_output_sdu_bytes_to_write);
}