Commit 7e339b46 authored by Melissa Elkadi's avatar Melissa Elkadi

Currently receiving measurement data from NR UE

This commit has several other changes. The changes
include the following:
1. Changed the port numbers for the NRUE<->Proxy
2. Fixed the send to function in the NR UE
   (Previously only sending buffer not buffer+msg_type)
3. Updated pack/unpack of the SSB PDU (new RSRB field added)
4. Fixed several NR logs
5. Opening socket with NRUE<->Proxy AFTER receving RRC
   measurement request from the LTE UE
parent 34eeae08
......@@ -127,8 +127,8 @@ void init_nr_ue_vars(PHY_VARS_NR_UE *ue,
void init_nrUE_standalone_thread(int ue_idx)
{
const char *standalone_addr = "127.0.0.1";
int standalone_tx_port = 3211 + (1+ue_idx)*2;
int standalone_rx_port = 3212 + (1+ue_idx)*2;
int standalone_tx_port = 3611 + (ue_idx)*2;
int standalone_rx_port = 3612 + (ue_idx)*2;
nrue_init_standalone_socket(standalone_addr, standalone_tx_port, standalone_rx_port);
pthread_t thread;
......
......@@ -587,20 +587,8 @@ int main( int argc, char **argv ) {
printf("UE threads created by %ld\n", gettid());
}
if (NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
init_queue(&dl_itti_config_req_tx_data_req_queue);
init_queue(&ul_dci_config_req_queue);
config_sync_var=0;
if (sem_init(&sfn_slot_semaphore, 0, 0) != 0)
{
LOG_E(MAC, "sem_init() error\n");
abort();
}
init_nrUE_standalone_thread(ue_id_g);
//init_NR_UE_threads(NB_UE_INST);
}
config_sync_var=0;
// wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n");
// Sleep a while before checking all parameters have been used
......
......@@ -1007,6 +1007,8 @@ typedef struct {
/// A value indicating how the BCH payload is generated. This should match the PARAM/CONFIG TLVs. Value: 0: MAC generates the full PBCH payload, see Table 3-41, where bchPayload has 31 bits 1: PHY generates the timing PBCH bits, see Table 3-41, where the bchPayload has 24 bits 2: PHY generates the full PBCH payload
uint8_t bchPayloadFlag;
uint32_t bchPayload;
/// A value indicating the channel quality between the gNB and nrUE
uint8_t ssRSRB;
nfapi_nr_tx_precoding_and_beamforming_t precoding_and_beamforming;
} nfapi_nr_dl_tti_ssb_pdu_rel15_t;
......
......@@ -371,7 +371,8 @@ static uint8_t pack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppWritePacke
push8(value->SsbSubcarrierOffset, ppWritePackedMsg, end) &&
push16(value->ssbOffsetPointA, ppWritePackedMsg, end) &&
push8(value->bchPayloadFlag, ppWritePackedMsg, end) &&
push32(value->bchPayload, ppWritePackedMsg, end)
push32(value->bchPayload, ppWritePackedMsg, end) &&
push8(value->ssRSRB, ppWritePackedMsg, end)
// TODO: pack precoding_and_beamforming too
);
......@@ -3409,7 +3410,7 @@ int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packe
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
result = pack_dl_tti_request(pMessageHeader, &pWritePackedMessage, end, config);
printf("result of pack dl_tti_req is %d. \n",result);
NFAPI_TRACE(NFAPI_TRACE_INFO, "result of pack dl_tti_req is %d. \n", result);
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
......@@ -3874,7 +3875,8 @@ static uint8_t unpack_dl_tti_ssb_pdu_rel15_value(void* tlv, uint8_t **ppReadPack
pull8(ppReadPackedMsg, &value->SsbSubcarrierOffset, end) &&
pull16(ppReadPackedMsg, &value->ssbOffsetPointA, end) &&
pull8(ppReadPackedMsg, &value->bchPayloadFlag, end) &&
pull32(ppReadPackedMsg, &value->bchPayload, end)
pull32(ppReadPackedMsg, &value->bchPayload, end) &&
pull8(ppReadPackedMsg, &value->ssRSRB, end)
// TODO: pack precoding_and_beamforming too
);
......
......@@ -37,6 +37,7 @@
#include "NR_MAC_UE/mac_extern.h"
#include "SCHED_NR_UE/fapi_nr_ue_l1.h"
#include "executables/softmodem-common.h"
#include "openair2/RRC/NR_UE/rrc_proto.h"
#include <stdio.h>
......@@ -128,6 +129,44 @@ void nrue_init_standalone_socket(const char *addr, int tx_port, int rx_port)
tx_port, rx_port, addr);
}
static void save_nr_measurement_info(nfapi_nr_dl_tti_request_t *dl_tti_request)
{
int num_pdus = dl_tti_request->dl_tti_request_body.nPDUs;
char buffer[MAX_MESSAGE_SIZE];
if (num_pdus <= 0)
{
LOG_E(NR_PHY, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__);
abort();
}
LOG_D(NR_PHY, "%s: dl_tti_request number of PDUS: %d\n", __FUNCTION__, num_pdus);
for (int i = 0; i < num_pdus; i++)
{
nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request->dl_tti_request_body.dl_tti_pdu_list[i];
if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE)
{
LOG_I(NR_PHY, "Cell_id: %d, the ssb_block_idx %d, sc_offset: %d and payload %d\n",
pdu_list->ssb_pdu.ssb_pdu_rel15.PhysCellId,
pdu_list->ssb_pdu.ssb_pdu_rel15.SsbBlockIndex,
pdu_list->ssb_pdu.ssb_pdu_rel15.SsbSubcarrierOffset,
pdu_list->ssb_pdu.ssb_pdu_rel15.bchPayload);
pdu_list->ssb_pdu.ssb_pdu_rel15.ssRSRB = 60;
LOG_D(NR_RRC, "Setting pdulist[%d].ssRSRB to %d\n", i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssRSRB);
}
}
size_t pack_len = nfapi_nr_p7_message_pack((void *)dl_tti_request,
buffer,
sizeof(buffer),
NULL);
if (pack_len < 0)
{
LOG_E(NR_PHY, "%s: Error packing nr p7 message.\n", __FUNCTION__);
}
LOG_I(NR_RRC, "Calling nsa_sendmsg_to_lte_ue to send a NR_UE_RRC_MEASUREMENT\n");
nsa_sendmsg_to_lte_ue(buffer, pack_len, NR_UE_RRC_MEASUREMENT);
}
void *nrue_standalone_pnf_task(void *context)
{
struct sockaddr_in server_address;
......@@ -142,12 +181,12 @@ void *nrue_standalone_pnf_task(void *context)
ssize_t len = recvfrom(sd, buffer, sizeof(buffer), MSG_TRUNC, (struct sockaddr *)&server_address, &addr_len);
if (len == -1)
{
LOG_E(MAC, "reading from standalone pnf sctp socket failed \n");
LOG_E(NR_PHY, "reading from standalone pnf sctp socket failed \n");
continue;
}
if (len > sizeof(buffer))
{
LOG_E(MAC, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len);
LOG_E(NR_PHY, "%s(%d). Message truncated. %zd\n", __FUNCTION__, __LINE__, len);
continue;
}
if (len == sizeof(uint16_t))
......@@ -158,19 +197,20 @@ void *nrue_standalone_pnf_task(void *context)
if (sem_post(&sfn_slot_semaphore) != 0)
{
LOG_E(MAC, "sem_post() error\n");
LOG_E(NR_PHY, "sem_post() error\n");
abort();
}
int sfn = NFAPI_SFNSLOT2SFN(sfn_slot);
int slot = NFAPI_SFNSLOT2SLOT(sfn_slot);
LOG_D(MAC, "Received from proxy sfn %d slot %d\n", sfn, slot);
LOG_D(NR_PHY, "Received from proxy sfn %d slot %d\n", sfn, slot);
}
else
{
nfapi_p7_message_header_t header;
nfapi_nr_dl_tti_request_t dl_tti_request;
if (nfapi_p7_message_header_unpack((void *)buffer, len, &header, sizeof(header), NULL) < 0)
{
LOG_E(MAC, "Header unpack failed for nrue_standalone pnf\n");
LOG_E(NR_PHY, "Header unpack failed for nrue_standalone pnf\n");
continue;
}
else
......@@ -178,26 +218,32 @@ void *nrue_standalone_pnf_task(void *context)
switch (header.message_id)
{
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
LOG_I(NR_PHY, "Melissa, we have received a NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message. \n");
/* Melissa, not 100% sure what to do but I think we need to
0. Add TX_DATA_REQUEST and pair them similarly
1. Queue them
2. De-queue and pair them
3. Get SSB PDU when received. Inside this NFAPI_NR_DL_TTI_SSB_PDU_TYPE
we need the cell_id, SSB block index, SSB subcarrier offset, and the BCH payload
4. Send back the SSB PDU type (that comes in from Proxy) and send to LTE */
LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST message. \n");
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &dl_tti_request,
sizeof(nfapi_nr_dl_tti_request_t), NULL) < 0)
{
LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n");
break;
}
save_nr_measurement_info(&dl_tti_request);
break;
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
LOG_I(NR_PHY, "Melissa, we have received a NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message. \n");
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST message. \n");
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
LOG_I(NR_PHY, "Melissa, we have received a NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message. \n");
LOG_I(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST message. \n");
break;
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
LOG_I(NR_PHY, "Melissa, we have received a NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message. \n");
LOG_D(NR_PHY, "Received an NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST message. \n");
if (nfapi_nr_p7_message_unpack((void *)buffer, len, &dl_tti_request,
sizeof(dl_tti_request), NULL) < 0)
{
LOG_E(NR_PHY, "Message dl_tti_request failed to unpack\n");
break;
}
break;
default:
LOG_E(MAC, "Case Statement has no corresponding nfapi message, this is the header ID %d\n", header.message_id);
LOG_E(NR_PHY, "Case Statement has no corresponding nfapi message, this is the header ID %d\n", header.message_id);
break;
}
}
......
......@@ -6091,7 +6091,7 @@ void *recv_msgs_from_nr_ue(void *args_p)
LOG_E(NR_RRC, "%s: Received a truncated message %d\n", __func__, recvLen);
continue;
}
LOG_I(RRC, "We have received a msg. Calling process_nr_nsa_msg\n");
LOG_D(RRC, "We have received a %d msg (%d bytes). Calling process_nr_nsa_msg\n", msg.msg_type, recvLen);
process_nr_nsa_msg(&msg, recvLen);
}
......@@ -6127,7 +6127,7 @@ void nsa_sendmsg_to_nrue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg
LOG_E(RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send);
return;
}
LOG_I(RRC, "Sent a %d message to the nrUE (%zu bytes) \n", msg_type, to_send);
LOG_D(RRC, "Sent a %d message to the nrUE (%d bytes) \n", msg_type, sent);
}
void init_connections_with_nr_ue(void)
......@@ -6169,9 +6169,10 @@ void init_connections_with_nr_ue(void)
void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len)
{
LOG_I(RRC, "We are processing an NSA message \n");
LOG_D(RRC, "We are processing an NSA message %d \n", msg->msg_type);
Rrc_Msg_Type_t msg_type = msg->msg_type;
uint8_t *const msg_buffer = msg->msg_buffer;
msg_len -= sizeof(msg->msg_type);
bool received_nr_msg = true;
protocol_ctxt_t ctxt;
......@@ -6179,7 +6180,7 @@ void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len)
{
case UE_CAPABILITY_INFO:
{
LOG_I(RRC, "Processing a UE_CAPABILITY_INFO message \n");
LOG_D(RRC, "Processing a UE_CAPABILITY_INFO message \n");
/* Melissa:
1. Set these parameters if we get UE_CAPABILITY_INFO message:
a. irat-ParametersNR-r15
......@@ -6220,6 +6221,49 @@ void process_nr_nsa_msg(nsa_msg_t *msg, int msg_len)
LOG_D(RRC, "Sent itti RRC_DCCH_DATA_COPY_IND\n");
break;
}
case NR_UE_RRC_MEASUREMENT:
{
nfapi_p7_message_header_t header;
if (nfapi_p7_message_header_unpack((void *)msg_buffer, msg_len, &header, sizeof(header), NULL) < 0)
{
LOG_E(MAC, "Header unpack failed in %s \n", __FUNCTION__);
break;
}
if (header.message_id != NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST)
{
LOG_E(MAC, "%s: Unexpected nfapi message type: %d\n", __FUNCTION__, header.message_id);
break;
}
nfapi_nr_dl_tti_request_t dl_tti_request;
int unpack_len = nfapi_nr_p7_message_unpack((void *)msg_buffer,
msg_len,
&dl_tti_request,
sizeof(nfapi_nr_dl_tti_request_t),
NULL);
if (unpack_len < 0)
{
LOG_E(RRC, "%s: SSB PDU unpack failed \n", __FUNCTION__);
break;
}
int num_pdus = dl_tti_request.dl_tti_request_body.nPDUs;
if (num_pdus <= 0)
{
LOG_E(RRC, "%s: dl_tti_request number of PDUS <= 0\n", __FUNCTION__);
abort();
}
for (int i = 0; i < num_pdus; i++)
{
nfapi_nr_dl_tti_request_pdu_t *pdu_list = &dl_tti_request.dl_tti_request_body.dl_tti_pdu_list[i];
if (pdu_list->PDUType == NFAPI_NR_DL_TTI_SSB_PDU_TYPE)
{
LOG_I(RRC, "Got an NR_UE_RRC_MEASUREMENT. pdulist[%d].ssRSRB = %d\n",
i, pdu_list->ssb_pdu.ssb_pdu_rel15.ssRSRB);
}
}
break;
}
default:
LOG_E(RRC, "No NSA Message Found\n");
}
......
......@@ -66,6 +66,7 @@ typedef enum Rrc_Msg_Type_e {
UE_CAPABILITY_ENQUIRY,
UE_CAPABILITY_INFO,
RRC_MEASUREMENT_PROCEDURE,
NR_UE_RRC_MEASUREMENT,
} Rrc_Msg_Type_t;
......
......@@ -133,7 +133,6 @@ uint8_t first_rrcreconfigurationcomplete = 0;
static const char nsa_ipaddr[] = "127.0.0.1";
static int from_lte_ue_fd = -1;
static int to_lte_ue_fd = -1;
uint16_t node_number;
uint16_t ue_id_g;
static Rrc_State_NR_t nr_rrc_get_state (module_id_t ue_mod_idP) {
......@@ -209,7 +208,7 @@ extern rlc_op_status_t nr_rrc_rlc_config_asn1_req (const protocol_ctxt_t * con
struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list);
static void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len);
static void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type);
static void start_oai_nrue_threads(void);
// from LTE-RRC DL-DCCH RRCConnectionReconfiguration nr-secondary-cell-group-config (encoded)
int8_t nr_rrc_ue_decode_secondary_cellgroup_config(
......@@ -2910,7 +2909,7 @@ void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_
.sin_family = AF_INET,
.sin_port = htons(6007),
};
int sent = sendto(from_lte_ue_fd, n_msg.msg_buffer, to_send, 0,
int sent = sendto(from_lte_ue_fd, &n_msg, to_send, 0,
(struct sockaddr *)&sa, sizeof(sa));
if (sent == -1)
{
......@@ -2922,6 +2921,7 @@ void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_
LOG_E(RRC, "%s: Short send %d != %zu\n", __func__, sent, to_send);
return;
}
LOG_D(NR_RRC, "Sent a %d message to the LTE UE (%d bytes) \n", msg_type, sent);
}
void init_connections_with_lte_ue(void)
......@@ -2961,23 +2961,21 @@ void init_connections_with_lte_ue(void)
LOG_I(NR_RRC, "Started LTE-NR link in the nr-UE\n");
}
static void process_measurement_objects_nr(LTE_MeasObjectToAddMod_t *buf)
static void start_oai_nrue_threads()
{
LOG_I(NR_RRC, "NR carrierFreq_r15 (ssb): %ld and sub carrier spacing:%ld\n",
buf->measObject.choice.measObjectNR_r15.carrierFreq_r15,
buf->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15);
#if 0
uint16_t node_num = get_softmodem_params()->node_number;
/* Receiving the RRC_Reconfiguration with the measurement objects
from the LTE UE should trigger the socket to be opened between
the NRUE(s) and the proxy. This allows us to start receiving
nFAPI messages from the gNB via the proxy. */
init_queue(&dl_itti_config_req_tx_data_req_queue);
init_queue(&ul_dci_config_req_queue);
if (sem_init(&sfn_slot_semaphore, 0, 0) != 0)
{
LOG_E(MAC, "sem_init() error\n");
abort();
}
int node_num = get_softmodem_params()->node_number;
ue_id_g = (node_num == 0)? 0 : node_num-2;
init_nrUE_standalone_thread(ue_id_g);
#endif
}
void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
{
LOG_I(NR_RRC, "We are processing an NSA message\n");
......@@ -3015,6 +3013,7 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
}
case RRC_MEASUREMENT_PROCEDURE:
{
LOG_I(NR_RRC, "We are processing a %d message \n", msg_type);
LTE_MeasObjectToAddMod_t *nr_meas_obj = NULL;
......@@ -3029,7 +3028,10 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
LOG_E(RRC, "Failed to decode measurement object (%zu bits) %d\n", dec_rval.consumed, dec_rval.code);
break;
}
process_measurement_objects_nr(nr_meas_obj);
LOG_I(NR_RRC, "NR carrierFreq_r15 (ssb): %ld and sub carrier spacing:%ld\n",
nr_meas_obj->measObject.choice.measObjectNR_r15.carrierFreq_r15,
nr_meas_obj->measObject.choice.measObjectNR_r15.rs_ConfigSSB_r15.subcarrierSpacingSSB_r15);
start_oai_nrue_threads();
/* Create a processs RRC_MEASUREMENT_PROCEDURE function. This
function will tell the NR UE which frequency to take measurements
on. You can log these values for fun. This will trigger 5G UE socket with proxy
......@@ -3038,6 +3040,7 @@ void process_lte_nsa_msg(nsa_msg_t *msg, int msg_len)
Also, after receiving PBCH it will start sending SSB index/cellID and some info from MIB to UE
as measurement reporting message*/
break;
}
default:
LOG_E(NR_RRC, "No NSA Message Found\n");
......
......@@ -132,6 +132,8 @@ void *recv_msgs_from_lte_ue(void *args_p);
void init_connections_with_lte_ue(void);
void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, MessagesIds msg_type);
/**\brief RRC UE generate RRCSetupRequest message.
\param ctxt_pP protocol context
\param gNB_index gNB index */
......
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