Sidelink configuration passed from RRC->MAC, defined interface functions
- Phy configuration will be prepared by MAC - Sidelink preconfiguration parameters passed from RRC->MAC - Only 1 SSB TA allocation used - psbch payload prepared by MAC after receiving the tx slss req
This commit is contained in:
@@ -94,6 +94,32 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
|
||||
AssertFatal(false, "use RLC instead\n");
|
||||
break;
|
||||
|
||||
case NR_SBCCH_SL_BCH:
|
||||
if (pdu_len>0) {
|
||||
LOG_T(NR_RRC, "[UE %d] Received SL-MIB for NR_SBCCH_SL_BCH.\n", module_id);
|
||||
|
||||
MessageDef *message_p;
|
||||
int msg_sdu_size = BCCH_SDU_SIZE;
|
||||
|
||||
if (pdu_len > msg_sdu_size) {
|
||||
LOG_E(NR_RRC, "SDU larger than NR_SBCCH_SL_BCH SDU buffer size (%d, %d)", sdu_size, msg_sdu_size);
|
||||
sdu_size = msg_sdu_size;
|
||||
} else {
|
||||
sdu_size = pdu_len;
|
||||
}
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_SBCCH_DATA_IND);
|
||||
memset(NR_RRC_MAC_SBCCH_DATA_IND (message_p).sdu, 0, BCCH_SDU_SIZE);
|
||||
memcpy(NR_RRC_MAC_SBCCH_DATA_IND (message_p).sdu, pduP, sdu_size);
|
||||
NR_RRC_MAC_SBCCH_DATA_IND (message_p).frame = frame; //frameP
|
||||
NR_RRC_MAC_SBCCH_DATA_IND (message_p).slot = slot;
|
||||
NR_RRC_MAC_SBCCH_DATA_IND (message_p).sdu_size = sdu_size;
|
||||
NR_RRC_MAC_SBCCH_DATA_IND (message_p).gnb_index = gNB_index;
|
||||
NR_RRC_MAC_SBCCH_DATA_IND (message_p).rx_slss_id = rnti;//rx_slss_id is rnti
|
||||
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -322,10 +322,8 @@ NR_UE_RRC_INST_t* nr_rrc_init_ue(char* uecap_file, int nb_inst)
|
||||
// SRB0 activated by default
|
||||
ptr->Srb[0] = RB_ESTABLISHED;
|
||||
}
|
||||
}
|
||||
|
||||
if (get_softmodem_params()->sl_mode) {
|
||||
configure_NR_SL_Preconfig(get_softmodem_params()->sync_ref);
|
||||
init_sidelink(rrc);
|
||||
}
|
||||
|
||||
return NR_UE_rrc_inst;
|
||||
@@ -1462,6 +1460,14 @@ void *rrc_nrue(void *notUsed)
|
||||
nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(rrc, bcch->gnb_index, bcch->sdu, bcch->sdu_size, bcch->rsrq, bcch->rsrp);
|
||||
break;
|
||||
|
||||
case NR_RRC_MAC_SBCCH_DATA_IND:
|
||||
LOG_D(NR_RRC, "[UE %ld] Received %s: gNB %d\n", instance, ITTI_MSG_NAME(msg_p), NR_RRC_MAC_SBCCH_DATA_IND(msg_p).gnb_index);
|
||||
NRRrcMacSBcchDataInd *sbcch = &NR_RRC_MAC_SBCCH_DATA_IND(msg_p);
|
||||
|
||||
nr_rrc_ue_decode_NR_SBCCH_SL_BCH_Message(rrc, sbcch->gnb_index,sbcch->frame, sbcch->slot, sbcch->sdu,
|
||||
sbcch->sdu_size, sbcch->rx_slss_id);
|
||||
break;
|
||||
|
||||
case NR_RRC_MAC_CCCH_DATA_IND: {
|
||||
NRRrcMacCcchDataInd *ind = &NR_RRC_MAC_CCCH_DATA_IND(msg_p);
|
||||
nr_rrc_ue_decode_ccch(rrc, ind, 0);
|
||||
@@ -1956,3 +1962,17 @@ void handle_t300_expiry(NR_UE_RRC_INST_t *rrc)
|
||||
// TODO handle connEstFailureControl
|
||||
// TODO inform upper layers about the failure to establish the RRC connection
|
||||
}
|
||||
|
||||
//This calls the sidelink preconf message after RRC, MAC instances are created.
|
||||
void start_sidelink(int instance)
|
||||
{
|
||||
|
||||
NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[instance];
|
||||
|
||||
if (get_softmodem_params()->sl_mode == 2) {
|
||||
|
||||
//Process the Sidelink Preconfiguration
|
||||
rrc_ue_process_sidelink_Preconfiguration(rrc, get_softmodem_params()->sync_ref);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
#include "NR_DL-DCCH-Message.h"
|
||||
#include "NR_SystemInformation.h"
|
||||
#include "NR_UE-NR-Capability.h"
|
||||
#include "NR_SL-PreconfigurationNR-r16.h"
|
||||
#include "NR_MasterInformationBlockSidelink.h"
|
||||
|
||||
#include "RRC/NR/nr_rrc_common.h"
|
||||
#include "as_message.h"
|
||||
@@ -232,6 +234,10 @@ typedef struct NR_UE_RRC_INST_s {
|
||||
long selected_plmn_identity;
|
||||
Rrc_State_NR_t nrRrcState;
|
||||
as_nas_info_t initialNasMsg;
|
||||
|
||||
//Sidelink params
|
||||
NR_SL_PreconfigurationNR_r16_t *sl_preconfig;
|
||||
|
||||
} NR_UE_RRC_INST_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -121,7 +121,20 @@ void handle_rlf_sync(NR_UE_Timers_Constants_t *tac,
|
||||
void nr_rrc_handle_SetupRelease_RLF_TimersAndConstants(NR_UE_RRC_INST_t *rrc,
|
||||
struct NR_SetupRelease_RLF_TimersAndConstants *rlf_TimersAndConstants);
|
||||
|
||||
int configure_NR_SL_Preconfig(int sync_source);
|
||||
int configure_NR_SL_Preconfig(NR_UE_RRC_INST_t *rrc,int sync_source);
|
||||
|
||||
void init_sidelink(NR_UE_RRC_INST_t *rrc);
|
||||
void start_sidelink(int instance);
|
||||
|
||||
void rrc_ue_process_sidelink_Preconfiguration(NR_UE_RRC_INST_t *rrc_inst, int sync_ref);
|
||||
|
||||
void nr_rrc_ue_decode_NR_SBCCH_SL_BCH_Message(NR_UE_RRC_INST_t *rrc,
|
||||
const uint8_t gNB_index,
|
||||
const frame_t frame,
|
||||
const int slot,
|
||||
uint8_t* pduP,
|
||||
const sdu_size_t pdu_len,
|
||||
const uint16_t rx_slss_id);
|
||||
|
||||
/** @}*/
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,17 @@
|
||||
#include "common/utils/LOG/log.h"
|
||||
#include "sl_preconfig_paramvalues.h"
|
||||
#include "common/config/config_userapi.h"
|
||||
#include "rrc_defs.h"
|
||||
#include "LAYER2/NR_MAC_UE/mac_proto.h"
|
||||
#include "nr-uesoftmodem.h"
|
||||
|
||||
void free_sl_rrc(NR_UE_RRC_INST_t *rrc)
|
||||
{
|
||||
|
||||
if (rrc->sl_preconfig) {
|
||||
ASN_STRUCT_FREE(asn_DEF_NR_SL_PreconfigurationNR_r16, rrc->sl_preconfig);
|
||||
}
|
||||
}
|
||||
|
||||
static void prepare_NR_SL_SyncConfig(NR_SL_SyncConfig_r16_t *sl_syncconfig)
|
||||
{
|
||||
@@ -399,8 +410,7 @@ NR_SL_PreconfigurationNR_r16_t *prepare_NR_SL_PRECONFIGURATION(uint16_t num_tx_p
|
||||
return sl_preconfiguration;
|
||||
}
|
||||
|
||||
|
||||
int configure_NR_SL_Preconfig(int sync_source)
|
||||
int configure_NR_SL_Preconfig(NR_UE_RRC_INST_t *rrc,int sync_source)
|
||||
{
|
||||
|
||||
NR_SL_PreconfigurationNR_r16_t *sl_preconfig = NULL;
|
||||
@@ -424,9 +434,136 @@ int configure_NR_SL_Preconfig(int sync_source)
|
||||
}
|
||||
}
|
||||
|
||||
ASN_STRUCT_FREE(asn_DEF_NR_SL_PreconfigurationNR_r16, sl_preconfig);
|
||||
sl_preconfig = NULL;
|
||||
//END.......
|
||||
rrc->sl_preconfig = sl_preconfig;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*decode SL-BCH (SL-MIB) message*/
|
||||
static int8_t nr_sl_rrc_ue_decode_SL_MIB(const uint8_t gNB_index,
|
||||
uint8_t *const bufferP,
|
||||
const uint8_t buffer_len)
|
||||
{
|
||||
NR_MasterInformationBlockSidelink_t *sl_mib = NULL;
|
||||
|
||||
asn_dec_rval_t dec_rval = uper_decode_complete(NULL, &asn_DEF_NR_MasterInformationBlockSidelink,
|
||||
(void **)&sl_mib,
|
||||
(const void *)bufferP, buffer_len);
|
||||
|
||||
int ret = 0;
|
||||
if ((dec_rval.code != RC_OK) || (dec_rval.consumed == 0)) {
|
||||
LOG_E(NR_RRC, "SL-MIB decode error\n");
|
||||
ret = -1;
|
||||
} else {
|
||||
|
||||
int bits_unused = sl_mib->directFrameNumber_r16.bits_unused;
|
||||
uint16_t val_fn = sl_mib->directFrameNumber_r16.buf[0];
|
||||
val_fn = (val_fn << (8 - bits_unused)) + (sl_mib->directFrameNumber_r16.buf[1] >> bits_unused);
|
||||
|
||||
uint8_t val_slot = sl_mib->slotIndex_r16.buf[0];
|
||||
|
||||
LOG_D(NR_RRC, "SL-RRC - Received MIB\n");
|
||||
LOG_D(NR_RRC, "SL-MIB Contents - DFN:%d\n" , val_fn);
|
||||
LOG_D(NR_RRC, "SL-MIB Contents - SLOT:%d\n" , val_slot >> 1);
|
||||
LOG_D(NR_RRC, "SL-MIB Contents - Incoverage:%d\n", sl_mib->inCoverage_r16);
|
||||
LOG_D(NR_RRC, "SL-MIB Contents - sl-TDD-Config:%x\n" , *((uint16_t *)(sl_mib->sl_TDD_Config_r16.buf)));
|
||||
|
||||
ASN_STRUCT_FREE(asn_DEF_NR_MasterInformationBlockSidelink, sl_mib);
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void nr_rrc_ue_decode_NR_SBCCH_SL_BCH_Message(NR_UE_RRC_INST_t *rrc,
|
||||
const uint8_t gNB_index,
|
||||
const frame_t frame,
|
||||
const int slot,
|
||||
uint8_t* pduP,
|
||||
const sdu_size_t pdu_len,
|
||||
const uint16_t rx_slss_id)
|
||||
{
|
||||
|
||||
nr_sl_rrc_ue_decode_SL_MIB(gNB_index, (uint8_t*)pduP, pdu_len);
|
||||
|
||||
DevAssert(rrc->sl_preconfig);
|
||||
|
||||
NR_SL_FreqConfigCommon_r16_t *fcfg = NULL;
|
||||
if (rrc->sl_preconfig->sidelinkPreconfigNR_r16.sl_PreconfigFreqInfoList_r16)
|
||||
fcfg = rrc->sl_preconfig->sidelinkPreconfigNR_r16.sl_PreconfigFreqInfoList_r16->list.array[0];
|
||||
DevAssert(fcfg);
|
||||
|
||||
NR_SL_SSB_TimeAllocation_r16_t *sl_SSB_TimeAllocation = NULL;
|
||||
|
||||
//Current implementation only supports one SSB Timeallocation
|
||||
//Extend RRC to use multiple SSB Time allocations TBD....
|
||||
if (fcfg->sl_SyncConfigList_r16)
|
||||
sl_SSB_TimeAllocation = fcfg->sl_SyncConfigList_r16->list.array[0]->sl_SSB_TimeAllocation1_r16;
|
||||
DevAssert(sl_SSB_TimeAllocation);
|
||||
|
||||
nr_rrc_mac_config_req_sl_mib(rrc->ue_id,
|
||||
sl_SSB_TimeAllocation,
|
||||
rx_slss_id,
|
||||
pduP);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void rrc_ue_process_sidelink_Preconfiguration(NR_UE_RRC_INST_t *rrc_inst,
|
||||
sl_sync_source_enum_t sync_source)
|
||||
{
|
||||
|
||||
AssertFatal(rrc_inst, "RRC instance not created.\n");
|
||||
|
||||
NR_SL_PreconfigurationNR_r16_t *sl_preconfig = rrc_inst->sl_preconfig;
|
||||
AssertFatal(rrc_inst->sl_preconfig, "Check if SL-preconfig was created");
|
||||
|
||||
AssertFatal(sync_source != SL_SYNC_SOURCE_GNBENB, "Sync source GNB not supported\n");
|
||||
|
||||
nr_rrc_mac_config_req_sl_preconfig(rrc_inst->ue_id, sl_preconfig, sync_source);
|
||||
|
||||
//TBD.. These should be chosen by RRC according to 3GPP 38.331 RRC specification.
|
||||
//Currently hardcoding the values to these
|
||||
uint16_t slss_id = 671, ssb_ta_index = 1;
|
||||
//12 bits -sl-TDD-config will be filled by MAC
|
||||
//Incoverage 1bit is FALSE as this is mode 2
|
||||
//DFN, sfn will be filled by PHY
|
||||
uint8_t sl_mib_payload[4] = {0,0,0,0};
|
||||
|
||||
NR_SL_SSB_TimeAllocation_r16_t *ssb_ta = NULL;
|
||||
NR_SL_FreqConfigCommon_r16_t *fcfg = NULL;
|
||||
NR_SL_SyncConfig_r16_t *synccfg = NULL;
|
||||
if (sl_preconfig->sidelinkPreconfigNR_r16.sl_PreconfigFreqInfoList_r16)
|
||||
fcfg = sl_preconfig->sidelinkPreconfigNR_r16.sl_PreconfigFreqInfoList_r16->list.array[0];
|
||||
AssertFatal(fcfg, "Fcfg cannot be NULL\n");
|
||||
if (fcfg->sl_SyncConfigList_r16)
|
||||
synccfg = fcfg->sl_SyncConfigList_r16->list.array[0];
|
||||
AssertFatal(synccfg, "Synccfg cannot be NULL\n");
|
||||
|
||||
if (ssb_ta_index == 1)
|
||||
ssb_ta = synccfg->sl_SSB_TimeAllocation1_r16;
|
||||
else if (ssb_ta_index == 2)
|
||||
ssb_ta = synccfg->sl_SSB_TimeAllocation2_r16;
|
||||
else if (ssb_ta_index == 3)
|
||||
ssb_ta = synccfg->sl_SSB_TimeAllocation3_r16;
|
||||
else DevAssert(0);
|
||||
|
||||
AssertFatal(ssb_ta, "SSB_timeallocation cannot be NULL\n");
|
||||
|
||||
if (sync_source == SL_SYNC_SOURCE_LOCAL_TIMING || sync_source == SL_SYNC_SOURCE_GNSS)
|
||||
nr_rrc_mac_transmit_slss_req(rrc_inst->ue_id,sl_mib_payload, slss_id, ssb_ta);
|
||||
|
||||
}
|
||||
|
||||
//For Sidelink mode 2 operation this prepares the sidelink preconfiguration
|
||||
void init_sidelink(NR_UE_RRC_INST_t *rrc)
|
||||
{
|
||||
int sync_ref = get_softmodem_params()->sync_ref;
|
||||
|
||||
if (get_softmodem_params()->sl_mode == 2) {
|
||||
//Preparation of the Sidelink PRE-Configuration message
|
||||
configure_NR_SL_Preconfig(rrc, sync_ref);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user