Commit f65ce8c4 authored by francescomani's avatar francescomani

handle BCH indication

parent 1cbd6c71
......@@ -515,6 +515,7 @@ int main( int argc, char **argv ) {
if (get_softmodem_params()->sa) { // set frame config to initial values from command line and assume that the SSB is centered on the grid
uint16_t nr_band = get_softmodem_params()->band;
mac->nr_band = nr_band;
mac->ssb_start_subcarrier = UE[CC_id]->frame_parms.ssb_start_subcarrier;
nr_init_frame_parms_ue_sa(&UE[CC_id]->frame_parms,
downlink_frequency[CC_id][0],
uplink_frequency_offset[CC_id][0],
......
......@@ -109,6 +109,7 @@ typedef struct NRRrcMacBcchDataInd_s {
uint32_t sdu_size;
uint8_t sdu[BCCH_SDU_SIZE];
uint8_t gnb_index;
bool is_bch;
uint8_t rsrq;
uint8_t rsrp;
} NRRrcMacBcchDataInd;
......
......@@ -713,6 +713,9 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id,
mac->get_sib1 = true;
else if (sched_sib == 2)
mac->get_otherSI = true;
nr_ue_decode_mib(module_id,
cc_idP,
NULL);
}
void nr_rrc_mac_config_req_sib1(module_id_t module_id,
......
......@@ -477,6 +477,7 @@ typedef struct {
RA_config_t ra;
/// SSB index from MIB decoding
uint8_t mib_ssb;
uint32_t mib_additional_bits;
nr_csi_report_t csi_report_template[MAX_CSI_REPORTCONFIG];
......@@ -510,6 +511,7 @@ typedef struct {
frequency_range_t frequency_range;
uint16_t nr_band;
uint8_t ssb_subcarrier_offset;
int ssb_start_subcarrier;
NR_SSB_meas_t ssb_measurements;
......
......@@ -57,17 +57,7 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac);
\param pduP pointer to pdu
\param pdu_length length of pdu
\param cell_id cell id */
int8_t nr_ue_decode_mib(
module_id_t module_id,
int cc_id,
uint8_t gNB_index,
void *phy_data,
uint8_t extra_bits,
uint32_t ssb_length,
uint32_t ssb_index,
void *pduP,
uint16_t ssb_start_subcarrier,
uint16_t cell_id );
int8_t nr_ue_decode_mib(module_id_t module_id, int cc_id, void *phy_data);
/**\brief decode SIB1 and other SIs pdus in NR_UE, from if_module dl_ind
\param module_id module id
......
......@@ -247,48 +247,34 @@ int get_rnti_type(NR_UE_MAC_INST_t *mac, uint16_t rnti)
int8_t nr_ue_decode_mib(module_id_t module_id,
int cc_id,
uint8_t gNB_index,
void *phy_data,
uint8_t extra_bits, // 8bits 38.212 c7.1.1
uint32_t ssb_length,
uint32_t ssb_index,
void *pduP,
uint16_t ssb_start_subcarrier,
uint16_t cell_id)
void *phy_data)
{
LOG_D(MAC,"[L2][MAC] decode mib\n");
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
mac->physCellId = cell_id;
nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU
AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused);
uint16_t frame_number_4lsb = 0;
for (int i=0; i<4; i++)
frame_number_4lsb |= ((extra_bits>>i)&1)<<(3-i);
int extra_bits = mac->mib_additional_bits;
for (int i = 0; i < 4; i++)
frame_number_4lsb |= ((extra_bits >> i) & 1) << (3 - i);
uint8_t ssb_subcarrier_offset_msb = ( extra_bits >> 5 ) & 0x1; // extra bits[5]
uint8_t ssb_subcarrier_offset_msb = (extra_bits >> 5) & 0x1; // extra bits[5]
uint8_t ssb_subcarrier_offset = (uint8_t)mac->mib->ssb_SubcarrierOffset;
frame = frame << 4;
frame = frame | frame_number_4lsb;
if(ssb_length == 64){
mac->frequency_range = FR2;
for (int i=0; i<3; i++)
ssb_index += (((extra_bits>>(7-i))&0x01)<<(3+i));
}else{
mac->frequency_range = FR1;
if(ssb_subcarrier_offset_msb){
if (mac->frequency_range == FR2) {
for (int i = 0; i < 3; i++)
mac->mib_ssb += (((extra_bits >> (7 - i)) & 0x01) << (3 + i));
} else{
if(ssb_subcarrier_offset_msb)
ssb_subcarrier_offset = ssb_subcarrier_offset | 0x10;
}
}
#ifdef DEBUG_MIB
uint8_t half_frame_bit = ( extra_bits >> 4 ) & 0x1; // extra bits[4]
uint8_t half_frame_bit = (extra_bits >> 4) & 0x1; // extra bits[4]
LOG_I(MAC,"system frame number(6 MSB bits): %d\n", mac->mib->systemFrameNumber.buf[0]);
LOG_I(MAC,"system frame number(with LSB): %d\n", (int)frame);
LOG_I(MAC,"subcarrier spacing (0=15or60, 1=30or120): %d\n", (int)mac->mib->subCarrierSpacingCommon);
......@@ -299,11 +285,9 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
LOG_I(MAC,"cell barred (0=barred,1=notBarred): %d\n", (int)mac->mib->cellBarred);
LOG_I(MAC,"intra frequency reselection (0=allowed,1=notAllowed): %d\n", (int)mac->mib->intraFreqReselection);
LOG_I(MAC,"half frame bit(extra bits): %d\n", (int)half_frame_bit);
LOG_I(MAC,"ssb index(extra bits): %d\n", (int)ssb_index);
LOG_I(MAC,"ssb index(extra bits): %d\n", (int)mac->mib_ssb);
#endif
//storing ssb index in the mac structure
mac->mib_ssb = ssb_index;
mac->ssb_subcarrier_offset = ssb_subcarrier_offset;
uint8_t scs_ssb;
......@@ -314,10 +298,10 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
scs_ssb = get_softmodem_params()->numerology;
band = mac->nr_band;
ssb_start_symbol = get_ssb_start_symbol(band,scs_ssb,ssb_index);
ssb_start_symbol = get_ssb_start_symbol(band, scs_ssb, mac->mib_ssb);
int ssb_sc_offset_norm;
if (ssb_subcarrier_offset<24 && mac->frequency_range == FR1)
ssb_sc_offset_norm = ssb_subcarrier_offset>>scs_ssb;
if (ssb_subcarrier_offset < 24 && mac->frequency_range == FR1)
ssb_sc_offset_norm = ssb_subcarrier_offset >> scs_ssb;
else
ssb_sc_offset_norm = ssb_subcarrier_offset;
......@@ -327,8 +311,8 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
ssb_start_symbol,
frame,
ssb_sc_offset_norm,
ssb_index,
ssb_start_subcarrier,
mac->mib_ssb,
mac->ssb_start_subcarrier,
mac->frequency_range,
phy_data);
mac->first_sync_frame = frame;
......@@ -338,7 +322,7 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
NR_ServingCellConfigCommon_t *scc = mac->scc;
scs_ssb = *scc->ssbSubcarrierSpacing;
band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
ssb_start_symbol = get_ssb_start_symbol(band,scs_ssb,ssb_index);
ssb_start_symbol = get_ssb_start_symbol(band, scs_ssb, mac->mib_ssb);
if (mac->first_sync_frame == -1)
mac->first_sync_frame = frame;
}
......
......@@ -1037,19 +1037,18 @@ int handle_bcch_bch(module_id_t module_id, int cc_id,
unsigned int gNB_index, void *phy_data, uint8_t *pduP,
unsigned int additional_bits,
uint32_t ssb_index, uint32_t ssb_length,
uint16_t ssb_start_subcarrier, uint16_t cell_id){
return nr_ue_decode_mib(module_id,
cc_id,
gNB_index,
phy_data,
additional_bits,
ssb_length, // Lssb = 64 is not support
ssb_index,
pduP,
ssb_start_subcarrier,
cell_id);
uint16_t ssb_start_subcarrier, uint16_t cell_id)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
mac->mib_ssb = ssb_index;
mac->physCellId = cell_id;
mac->mib_additional_bits = additional_bits;
if(ssb_length == 64)
mac->frequency_range = FR2;
else
mac->frequency_range = FR1;
nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU
return 0;
}
// L2 Abstraction Layer
......
......@@ -63,9 +63,6 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
switch(channel){
case NR_BCCH_BCH:
AssertFatal(nr_rrc_ue_decode_NR_BCCH_BCH_Message(module_id, gNB_index, (uint8_t*)pduP, pdu_len) == 0, "UE decode BCCH-BCH error!\n");
break;
case NR_BCCH_DL_SCH:
if (pdu_len>0) {
LOG_T(NR_RRC, "[UE %d] Received SDU for NR-BCCH-DL-SCH on SRB %u from gNB %d\n", module_id, channel & RAB_OFFSET,
......@@ -88,6 +85,7 @@ int8_t nr_mac_rrc_data_ind_ue(const module_id_t module_id,
NR_RRC_MAC_BCCH_DATA_IND (message_p).slot = slot;
NR_RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size;
NR_RRC_MAC_BCCH_DATA_IND (message_p).gnb_index = gNB_index;
NR_RRC_MAC_BCCH_DATA_IND (message_p).is_bch = (channel == NR_BCCH_BCH);
itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(module_id), message_p);
}
break;
......
......@@ -1961,10 +1961,16 @@ void *rrc_nrue_task(void *args_p)
break;
case NR_RRC_MAC_BCCH_DATA_IND:
LOG_D(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p),
LOG_I(NR_RRC, "[UE %d] Received %s: frameP %d, gNB %d\n", ue_mod_id, ITTI_MSG_NAME (msg_p),
NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, ue_mod_id, GNB_FLAG_NO, NOT_A_RNTI, NR_RRC_MAC_BCCH_DATA_IND (msg_p).frame, 0,NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index);
nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message (ctxt.module_id,
if (NR_RRC_MAC_BCCH_DATA_IND (msg_p).is_bch)
nr_rrc_ue_decode_NR_BCCH_BCH_Message(ue_mod_id,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size);
else
nr_rrc_ue_decode_NR_BCCH_DL_SCH_Message(ctxt.module_id,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).gnb_index,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu,
NR_RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size,
......
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