Commit 18db5f68 authored by Robert Schmidt's avatar Robert Schmidt

Put PLMN/TAC/CellID into SIB1, correct CellIdentity encoding

parent c9305639
...@@ -557,6 +557,18 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c ...@@ -557,6 +557,18 @@ void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, c
//NR_SCHED_UNLOCK(&nrmac->sched_lock); //NR_SCHED_UNLOCK(&nrmac->sched_lock);
} }
void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_t cellID, int tac)
{
AssertFatal(get_softmodem_params()->sa > 0, "error: SIB1 only applicable for SA\n");
NR_COMMON_channels_t *cc = &nrmac->common_channels[0];
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(scc, plmn, cellID, tac);
cc->sib1 = sib1;
cc->sib1_bcch_length = encode_SIB1_NR(sib1, cc->sib1_bcch_pdu, sizeof(cc->sib1_bcch_pdu));
AssertFatal(cc->sib1_bcch_length > 0, "could not encode SIB1\n");
}
bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup) bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup)
{ {
DevAssert(nrmac != NULL); DevAssert(nrmac != NULL);
......
...@@ -50,6 +50,8 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, ...@@ -50,6 +50,8 @@ int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP,
uint32_t rrc_reconfiguration_delay); uint32_t rrc_reconfiguration_delay);
void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *mac_config); void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *mac_config);
void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_t cellID, int tac);
bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup);
......
...@@ -255,12 +255,6 @@ void mac_top_init_gNB(ngran_node_t node_type, ...@@ -255,12 +255,6 @@ void mac_top_init_gNB(ngran_node_t node_type,
RC.nrmac[i]->cset0_bwp_start = 0; RC.nrmac[i]->cset0_bwp_start = 0;
RC.nrmac[i]->cset0_bwp_size = 0; RC.nrmac[i]->cset0_bwp_size = 0;
NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(config, scc);
NR_COMMON_channels_t *cc = &RC.nrmac[i]->common_channels[0];
cc->sib1 = sib1;
cc->sib1_bcch_length = encode_SIB1_NR(sib1, cc->sib1_bcch_pdu, sizeof(cc->sib1_bcch_pdu));
AssertFatal(cc->sib1_bcch_length > 0, "could not encode SIB1\n");
pthread_mutex_init(&RC.nrmac[i]->sched_lock, NULL); pthread_mutex_init(&RC.nrmac[i]->sched_lock, NULL);
pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL); pthread_mutex_init(&RC.nrmac[i]->UE_info.mutex, NULL);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
* \email: raymond.knopp@eurecom.fr, kroempa@gmail.com * \email: raymond.knopp@eurecom.fr, kroempa@gmail.com
*/ */
#include "openair3/UTILS/conversions.h"
#include "nr_rrc_config.h" #include "nr_rrc_config.h"
#include "common/utils/nr/nr_common.h" #include "common/utils/nr/nr_common.h"
#include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h" #include "openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
...@@ -1713,8 +1714,10 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s ...@@ -1713,8 +1714,10 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s
return (enc_rval.encoded + 7) / 8; return (enc_rval.encoded + 7) / 8;
} }
NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, const NR_ServingCellConfigCommon_t *scc) NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const NR_ServingCellConfigCommon_t *scc, const f1ap_plmn_t *plmn, uint64_t cellID, int tac)
{ {
AssertFatal(cellID < (1l << 36), "cellID must fit within 36 bits, but is %ld\n", cellID);
NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t)); NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t));
AssertFatal(sib1_message != NULL, "out of memory\n"); AssertFatal(sib1_message != NULL, "out of memory\n");
sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1; sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1;
...@@ -1741,15 +1744,15 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, cons ...@@ -1741,15 +1744,15 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, cons
for (int i = 0; i < num_plmn; ++i) { for (int i = 0; i < num_plmn; ++i) {
asn1cSequenceAdd(nr_plmn_info->plmn_IdentityList.list, struct NR_PLMN_Identity, nr_plmn); asn1cSequenceAdd(nr_plmn_info->plmn_IdentityList.list, struct NR_PLMN_Identity, nr_plmn);
asn1cCalloc(nr_plmn->mcc, mcc); asn1cCalloc(nr_plmn->mcc, mcc);
int confMcc = 0; int confMcc = plmn->mcc;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc0); asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc0);
*mcc0 = (confMcc / 100) % 10; *mcc0 = (confMcc / 100) % 10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc1); asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc1);
*mcc1 = (confMcc / 10) % 10; *mcc1 = (confMcc / 10) % 10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc2); asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc2);
*mcc2 = confMcc % 10; *mcc2 = confMcc % 10;
int mnc = 0; int mnc = plmn->mnc;
if (0 == 3) { if (plmn->mnc_digit_length == 3) {
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc0); asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc0);
*mnc0 = (0 / 100) % 10; *mnc0 = (0 / 100) % 10;
} }
...@@ -1759,17 +1762,12 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, cons ...@@ -1759,17 +1762,12 @@ NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, cons
*mnc2 = (mnc) % 10; *mnc2 = (mnc) % 10;
} }
nr_plmn_info->cellIdentity.buf = CALLOC(1, 5); NR_CELL_ID_TO_BIT_STRING(cellID, &nr_plmn_info->cellIdentity);
AssertFatal(nr_plmn_info->cellIdentity.buf != NULL, "out of memory\n");
nr_plmn_info->cellIdentity.size = 5;
nr_plmn_info->cellIdentity.bits_unused = 4;
uint64_t tmp = htobe64(0) << 4;
memcpy(nr_plmn_info->cellIdentity.buf, ((char *)&tmp) + 3, 5);
nr_plmn_info->cellReservedForOperatorUse = NR_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved; nr_plmn_info->cellReservedForOperatorUse = NR_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
nr_plmn_info->trackingAreaCode = CALLOC(1, sizeof(NR_TrackingAreaCode_t)); nr_plmn_info->trackingAreaCode = CALLOC(1, sizeof(NR_TrackingAreaCode_t));
AssertFatal(nr_plmn_info->trackingAreaCode != NULL, "out of memory\n"); AssertFatal(nr_plmn_info->trackingAreaCode != NULL, "out of memory\n");
uint32_t tmp2 = htobe32(0); uint32_t tmp2 = htobe32(tac);
nr_plmn_info->trackingAreaCode->buf = CALLOC(1, 3); nr_plmn_info->trackingAreaCode->buf = CALLOC(1, 3);
AssertFatal(nr_plmn_info->trackingAreaCode->buf != NULL, "out of memory\n"); AssertFatal(nr_plmn_info->trackingAreaCode->buf != NULL, "out of memory\n");
memcpy(nr_plmn_info->trackingAreaCode->buf, ((char *)&tmp2) + 1, 3); memcpy(nr_plmn_info->trackingAreaCode->buf, ((char *)&tmp2) + 1, 3);
......
...@@ -57,7 +57,7 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s ...@@ -57,7 +57,7 @@ int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_s
#define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1 #define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1
NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const nr_mac_config_t *configuration, const NR_ServingCellConfigCommon_t *scc); NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const NR_ServingCellConfigCommon_t *scc, const f1ap_plmn_t *plmn, uint64_t cellID, int tac);
void free_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1); void free_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1);
int encode_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1, uint8_t *buffer, int max_buffer_size); int encode_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1, uint8_t *buffer, int max_buffer_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