Commit 6e0737d9 authored by cig's avatar cig Committed by Thomas Schlichter

Send Msg3 CCCH SDU in SA mode only

- send C-RNTI MAC CE otherwise
- init RA if there are bytes to send and is a PRACH occasion
- minor cleanups
parent 9af71a7a
...@@ -234,8 +234,6 @@ typedef struct { ...@@ -234,8 +234,6 @@ typedef struct {
int RA_PCMAX; int RA_PCMAX;
/// Corresponding RA-RNTI for UL-grant /// Corresponding RA-RNTI for UL-grant
uint16_t ra_RNTI; uint16_t ra_RNTI;
/// Pointer to Msg3 payload for UL-grant
uint8_t *Msg3;
/// Frame of last completed synch /// Frame of last completed synch
uint16_t sync_frame; uint16_t sync_frame;
/// Flag to indicate that prach is ready to start: it is enabled with an initial delay after the sync /// Flag to indicate that prach is ready to start: it is enabled with an initial delay after the sync
......
...@@ -2117,7 +2117,8 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t ...@@ -2117,7 +2117,8 @@ void nr_ue_prach_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, uint8_t
int16_t ra_preamble_rx_power = (int16_t)(prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER - pathloss + 30); int16_t ra_preamble_rx_power = (int16_t)(prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER - pathloss + 30);
ue->tx_power_dBm[nr_slot_tx] = min(nr_get_Pcmax(mod_id), ra_preamble_rx_power); ue->tx_power_dBm[nr_slot_tx] = min(nr_get_Pcmax(mod_id), ra_preamble_rx_power);
LOG_D(PHY,"DEBUG [UE %d][RAPROC][%d.%d]: Generating PRACH Msg1 (preamble %d, PL %d dB, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, RA-RNTI %x)\n", LOG_D(PHY, "In %s: [UE %d][RAPROC][%d.%d]: Generating PRACH Msg1 (preamble %d, PL %d dB, P0_PRACH %d, TARGET_RECEIVED_POWER %d dBm, RA-RNTI %x)\n",
__FUNCTION__,
mod_id, mod_id,
frame_tx, frame_tx,
nr_slot_tx, nr_slot_tx,
......
...@@ -477,7 +477,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint ...@@ -477,7 +477,7 @@ void nr_Msg3_transmitted(module_id_t mod_id, uint8_t CC_id, frame_t frameP, uint
/** /**
* Function: handles Random Access Preamble Initialization (5.1.1 TS 38.321) * Function: handles Random Access Preamble Initialization (5.1.1 TS 38.321)
* handles Random Access Response reception (5.1.4 TS 38.321) * handles Random Access Response reception (5.1.4 TS 38.321)
* Note: In the current implementation, RA is 4-step contention free only * Note: In SA mode the Msg3 contains a CCCH SDU, therefore no C-RNTI MAC CE is transmitted.
* *
* @prach_resources pointer to PRACH resources * @prach_resources pointer to PRACH resources
* @prach_pdu pointer to FAPI UL PRACH PDU * @prach_pdu pointer to FAPI UL PRACH PDU
...@@ -497,8 +497,6 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -497,8 +497,6 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id); NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra; RA_config_t *ra = &mac->ra;
int8_t size_sdu = 0;
NR_RACH_ConfigCommon_t *setup; NR_RACH_ConfigCommon_t *setup;
if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup; if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
else setup = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup; else setup = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
...@@ -535,50 +533,63 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -535,50 +533,63 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
const uint8_t lcid = UL_SCH_LCID_CCCH; const uint8_t lcid = UL_SCH_LCID_CCCH;
const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_SHORT); const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_SHORT);
const uint8_t TBS_max = 8 + 2 * sh_size; const uint8_t TBS_max = 8 + 2 * sh_size;
uint8_t *pdu = (uint8_t*) mac->CCCH_pdu.payload; int8_t size_sdu = 0;
NR_MAC_SUBHEADER_SHORT *header = (NR_MAC_SUBHEADER_SHORT *) pdu; uint8_t mac_ce[16] = {0};
pdu += sh_size; uint8_t *pdu = get_softmodem_params()->sa ? mac->CCCH_pdu.payload : mac_ce;
uint8_t *payload = pdu;
// Concerning the C-RNTI MAC CE, it has to be included if the UL transmission (Msg3) is not being made for the CCCH logical channel.
// Therefore it has been assumed that this event only occurs only when RA is done and it is not SA mode.
if (get_softmodem_params()->sa) {
// initialisation by RRC NR_MAC_SUBHEADER_SHORT *header = (NR_MAC_SUBHEADER_SHORT *) pdu;
pdu += sh_size;
// TODO: To be removed after RA procedures fully implemented // initialisation by RRC
if(get_softmodem_params()->do_ra) {
nr_rrc_ue_generate_RRCSetupRequest(mod_id,gNB_id); nr_rrc_ue_generate_RRCSetupRequest(mod_id,gNB_id);
}
// CCCH PDU // CCCH PDU
size_sdu = nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, pdu); size_sdu = nr_mac_rrc_data_req_ue(mod_id, CC_id, gNB_id, frame, CCCH, pdu);
LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: Requested RRCConnectionRequest, got %d bytes for LCID 0x%02x \n", __FUNCTION__, mod_id, frame, nr_slot_tx, size_sdu, lcid);
if (size_sdu > 0) {
// UE Contention Resolution Identity
// Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the
// Random Access Procedure has been successful after reception of Msg4
memcpy(ra->cont_res_id, pdu, sizeof(uint8_t) * 6);
pdu += size_sdu;
ra->Msg3_size = size_sdu + sh_size;
LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: Requested RRCConnectionRequest, got %d bytes for LCID 0x%02x \n", __FUNCTION__, mod_id, frame, nr_slot_tx, size_sdu, lcid); // Build header
header->R = 0;
header->F = 0;
header->LCID = lcid;
header->L = (unsigned char) size_sdu;
if (size_sdu > 0) { } else {
pdu -= sh_size;
}
// UE Contention Resolution Identity } else {
// Store the first 48 bits belonging to the uplink CCCH SDU within Msg3 to determine whether or not the
// Random Access Procedure has been successful after reception of Msg4
memcpy(ra->cont_res_id, pdu, sizeof(uint8_t) * 6);
size_sdu = nr_write_ce_ulsch_pdu(pdu, mac);
pdu += size_sdu; pdu += size_sdu;
ra->Msg3_size = size_sdu;
LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", __FUNCTION__, mod_id, frame, nr_slot_tx); }
ra->Msg3_size = size_sdu + sh_size; if (size_sdu > 0 && ra->generate_nr_prach == GENERATE_PREAMBLE) {
LOG_D(NR_MAC, "In %s: [UE %d][%d.%d]: starting initialisation Random Access Procedure...\n", __FUNCTION__, mod_id, frame, nr_slot_tx);
AssertFatal(TBS_max > ra->Msg3_size, "In %s: allocated resources are not enough for Msg3!\n", __FUNCTION__); AssertFatal(TBS_max > ra->Msg3_size, "In %s: allocated resources are not enough for Msg3!\n", __FUNCTION__);
// Init RA procedure
init_RA(mod_id, prach_resources, setup, rach_ConfigGeneric, rach_ConfigDedicated); init_RA(mod_id, prach_resources, setup, rach_ConfigGeneric, rach_ConfigDedicated);
prach_resources->Msg3 = (uint8_t*) mac->CCCH_pdu.payload;
nr_get_RA_window(mac); nr_get_RA_window(mac);
// Fill in preamble and PRACH resources // Fill in preamble and PRACH resources
if (ra->generate_nr_prach == GENERATE_PREAMBLE) { nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
nr_get_prach_resources(mod_id, CC_id, gNB_id, prach_resources, prach_pdu, rach_ConfigDedicated);
}
header->R = 0;
header->F = 0;
header->LCID = lcid;
header->L = (unsigned char) size_sdu;
// Padding: fill remainder with 0 // Padding: fill remainder with 0
if (TBS_max - ra->Msg3_size > 0) { if (TBS_max - ra->Msg3_size > 0) {
...@@ -590,21 +601,22 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources, ...@@ -590,21 +601,22 @@ uint8_t nr_ue_get_rach(NR_PRACH_RESOURCES_t *prach_resources,
pdu[j] = 0; pdu[j] = 0;
} }
} }
} else {
pdu -= sh_size;
}
LOG_D(NR_MAC, "In %s: dumping UL Msg3 MAC PDU with length %d: \n", __FUNCTION__, TBS_max); // Dumping ULSCH payload
for(int k = 0; k < TBS_max; k++) { LOG_D(NR_MAC, "In %s: dumping UL Msg3 MAC PDU with length %d: \n", __FUNCTION__, TBS_max);
LOG_D(NR_MAC,"(%i): %i\n", k, prach_resources->Msg3[k]); for(int k = 0; k < TBS_max; k++) {
} LOG_D(NR_MAC,"(%i): %i\n", k, payload[k]);
}
// Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after // Msg3 was initialized with TBS_max bytes because the RA_Msg3_size will only be known after
// receiving Msg2 (which contains the Msg3 resource reserve). // receiving Msg2 (which contains the Msg3 resource reserve).
// Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s. // Msg3 will be transmitted with RA_Msg3_size bytes, removing unnecessary 0s.
mac->ulsch_pdu.Pdu_size = TBS_max; mac->ulsch_pdu.Pdu_size = TBS_max;
memcpy(mac->ulsch_pdu.payload, prach_resources->Msg3, TBS_max); memcpy(mac->ulsch_pdu.payload, payload, TBS_max);
} else {
return 0;
}
} else if (ra->RA_window_cnt != -1) { // RACH is active } else if (ra->RA_window_cnt != -1) { // RACH is active
LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt); LOG_D(MAC, "In %s [%d.%d] RA is active: RA window count %d, RA backoff count %d\n", __FUNCTION__, frame, nr_slot_tx, ra->RA_window_cnt, ra->RA_backoff_cnt);
......
...@@ -2176,7 +2176,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce, ...@@ -2176,7 +2176,7 @@ int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
} }
if (!get_softmodem_params()->sa && mac->ra.ra_state == WAIT_RAR) { if (!get_softmodem_params()->sa && get_softmodem_params()->do_ra && mac->ra.ra_state != RA_SUCCEEDED) {
LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, mac->crnti); LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, mac->crnti);
......
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