Commit 198c3197 authored by Raymond Knopp's avatar Raymond Knopp

intermediate commit

parent 18d720f3
...@@ -612,7 +612,7 @@ typedef struct { ...@@ -612,7 +612,7 @@ typedef struct {
sl_nr_ue_mac_params_t *SL_MAC_PARAMS; sl_nr_ue_mac_params_t *SL_MAC_PARAMS;
// SIDELINK Scheduling fields // SIDELINK Scheduling fields
NR_SL_UEs_t UE_info; NR_SL_UEs_t sl_info;
// current SCI pdu build from SCI1 and SCI2 // current SCI pdu build from SCI1 and SCI2
nr_sci_pdu_t sci_pdu_rx; nr_sci_pdu_t sci_pdu_rx;
......
...@@ -40,52 +40,58 @@ ...@@ -40,52 +40,58 @@
#include "NR_MAC_UE/mac_extern.h" #include "NR_MAC_UE/mac_extern.h"
#include "NR_MAC_UE/nr_ue_sci.h" #include "NR_MAC_UE/nr_ue_sci.h"
bool nr_schedule_slsch(nr_sci_pdu_t *sci_pdu,nr_sci_pdu_t *sci2_pdu,uint8_t *slsch_pdu,nr_sci_format_t format2, uint16_t *slsch_pdu_length) { bool nr_schedule_slsch(int frameP,int slotP, nr_sci_pdu_t *sci_pdu,nr_sci_pdu_t *sci2_pdu,uint8_t *slsch_pdu,nr_sci_format_t format2, uint16_t *slsch_pdu_length_max) {
mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(0, 0, 0,frameP,slotP,ENB_FLAG_NO,MBMS_FLAG_NO, 4, 0, 0);
if (rlc_status.bytes_in_buffer > 0) {
// Fill SCI1A // Fill SCI1A
sci_pdu->priority = 0; sci_pdu->priority = 0;
sci_pdu->frequency_resource_assignment.val=0; sci_pdu->frequency_resource_assignment.val=0;
sci_pdu->time_resource_assignment.val=0; sci_pdu->time_resource_assignment.val=0;
sci_pdu->resource_reservation_period.val=0; sci_pdu->resource_reservation_period.val=0;
sci_pdu->dmrs_pattern.val = 0; sci_pdu->dmrs_pattern.val = 0;
sci_pdu->second_stage_sci_format = 0; sci_pdu->second_stage_sci_format = 0;
sci_pdu->number_of_dmrs_port = 0; sci_pdu->number_of_dmrs_port = 0;
sci_pdu->mcs = 9; sci_pdu->mcs = 9;
sci_pdu->additional_mcs.val = 0; sci_pdu->additional_mcs.val = 0;
sci_pdu->psfch_overhead.val = 0; sci_pdu->psfch_overhead.val = 0;
sci_pdu->reserved.val = 0; sci_pdu->reserved.val = 0;
sci_pdu->conflict_information_receiver.val = 0; sci_pdu->conflict_information_receiver.val = 0;
sci_pdu->beta_offset_indicator = 0; sci_pdu->beta_offset_indicator = 0;
// Fill SCI2A // Fill SCI2A
sci2_pdu->harq_pid = 0; sci2_pdu->harq_pid = 0;
sci2_pdu->ndi = (1-sci2_pdu->ndi)&1; sci2_pdu->ndi = (1-sci2_pdu->ndi)&1;
sci2_pdu->rv_index=0; sci2_pdu->rv_index=0;
sci2_pdu->source_id=0x12; sci2_pdu->source_id=0x12;
sci2_pdu->dest_id=0xabcd; sci2_pdu->dest_id=0xabcd;
sci2_pdu->harq_feedback=1; sci2_pdu->harq_feedback=1;
sci2_pdu->cast_type=0; sci2_pdu->cast_type=0;
if (format2==NR_SL_SCI_FORMAT_2C || format2==NR_SL_SCI_FORMAT_2A) if (format2==NR_SL_SCI_FORMAT_2C || format2==NR_SL_SCI_FORMAT_2A)
sci2_pdu->csi_req=1; sci2_pdu->csi_req=1;
if (format2==NR_SL_SCI_FORMAT_2B) if (format2==NR_SL_SCI_FORMAT_2B)
sci2_pdu->zone_id=0; sci2_pdu->zone_id=0;
// Fill in for R17: communication_range // Fill in for R17: communication_range
sci2_pdu->communication_range.val = 0; sci2_pdu->communication_range.val = 0;
if (format2==NR_SL_SCI_FORMAT_2C) { if (format2==NR_SL_SCI_FORMAT_2C) {
sci2_pdu->providing_req_ind = 0; sci2_pdu->providing_req_ind = 0;
// Fill in for R17 : resource combinations // Fill in for R17 : resource combinations
sci2_pdu->resource_combinations.val = 0; sci2_pdu->resource_combinations.val = 0;
sci2_pdu->first_resource_location = 0; sci2_pdu->first_resource_location = 0;
// Fill in for R17 : reference_slot_location // Fill in for R17 : reference_slot_location
sci2_pdu->reference_slot_location.val = 0; sci2_pdu->reference_slot_location.val = 0;
sci2_pdu->resource_set_type=0; sci2_pdu->resource_set_type=0;
// Fill in for R17 : lowest_subchannel_indices // Fill in for R17 : lowest_subchannel_indices
sci2_pdu->lowest_subchannel_indices.val=0; sci2_pdu->lowest_subchannel_indices.val=0;
} }
// Set SLSCH // Set SLSCH
*slsch_pdu_length = 1024;
for (uint32_t n=0;n<*slsch_pdu_length;n++) slsch_pdu[n]=(uint8_t)(n&255); *slsch_pdu_length_max = rlc_status.bytes_in_buffer;
return true; return true;
}
return false;
} }
...@@ -590,7 +590,8 @@ void nr_ue_process_mac_sl_pdu(int module_idP, ...@@ -590,7 +590,8 @@ void nr_ue_process_mac_sl_pdu(int module_idP,
} }
LOG_I(NR_MAC, "In %s : processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, pdu_id, pdu_len, rx_ind->number_pdus); LOG_I(NR_MAC, "In %s : processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, pdu_id, pdu_len, rx_ind->number_pdus);
/* mac->sl_info
while (!done && pdu_len > 0){ while (!done && pdu_len > 0){
uint16_t mac_len = 0x0000; uint16_t mac_len = 0x0000;
uint16_t mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct uint16_t mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct
...@@ -600,37 +601,39 @@ void nr_ue_process_mac_sl_pdu(int module_idP, ...@@ -600,37 +601,39 @@ void nr_ue_process_mac_sl_pdu(int module_idP,
bool ret; bool ret;
switch(rx_lcid){ switch(rx_lcid){
// MAC CE // MAC CE
case SL_SCH_LCID_CCCH: case SL_SCH_LCID_4_19:
// MSG4 RRC Setup 38.331 if (!get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len))
// variable length return;
ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len); LOG_D(NR_MAC, "%4d.%2d : SLSCH -> LCID %d %d bytes\n", frameP, slot, rx_lcid, mac_len);
AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n",
mac_len, pdu_len); mac_rlc_data_ind(module_idP,
0,
// Check if it is a valid CCCH message, we get all 00's messages very often 0,
int i = 0; frameP,
for(i=0; i<(mac_subheader_len+mac_len); i++) { ENB_FLAG_NO,
if(pduP[i] != 0) { MBMS_FLAG_NO,
break; rx_lcid,
} (char *)(pduP + mac_subheader_len),
} mac_len,
if (i == (mac_subheader_len+mac_len)) { 1,
LOG_D(NR_MAC, "%s() Invalid CCCH message!, pdu_len: %d\n", __func__, pdu_len); NULL);
done = 1; break;
break; case SL_SCH_LCID_SL_CSI_REPORT:
} break;
case SL_SCH_LCID_SL_PADDING:
if ( mac_len > 0 ) { done = 1;
LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len); break;
for (int i = 0; i < mac_subheader_len; i++) { case SL_SCH_LCID_SCCH_PC5_NOT_PROT:
LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]); case SL_SCH_LCID_SCCH_PC5_DSMC:
} case SL_SCH_LCID_SCCH_PC5_PROT:
for (int i = 0; i < mac_len; i++) { case SL_SCH_LCID_SCCH_PC5_RRC:
LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]); case SL_SCH_LCID_20_55:
} case SL_SCH_LCID_SCCH_RRC_SL_RLC0:
nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_len); case SL_SCH_LCID_SCCH_RRC_SL_RLC1:
} case SL_SCH_LCID_SCCH_SL_DISCOVERY:
break; case SL_SCH_LCID_SL_INTER_UE_COORD_REQ:
case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH: case SL_SCH_LCID_SL_INTER_UE_COORD_INFO:
*/ case SL_SCH_LCID_SL_DRX_CMD:
LOG_W(NR_MAC,"Received unsupported SL LCID %d\n",rx_lcid);
break;
} }
...@@ -3265,11 +3265,15 @@ bool nr_ue_sl_pssch_scheduler(NR_UE_MAC_INST_t *mac, ...@@ -3265,11 +3265,15 @@ bool nr_ue_sl_pssch_scheduler(NR_UE_MAC_INST_t *mac,
LOG_D(NR_MAC,"[UE%d] SL-PSSCH SCHEDULER: Frame:SLOT %d:%d, slot_type:%d\n", LOG_D(NR_MAC,"[UE%d] SL-PSSCH SCHEDULER: Frame:SLOT %d:%d, slot_type:%d\n",
sl_ind->module_id, frame, slot,sl_ind->slot_type); sl_ind->module_id, frame, slot,sl_ind->slot_type);
uint16_t slsch_pdu_length; uint16_t slsch_pdu_length_max;
tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload = mac->slsch_payload; tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload = mac->slsch_payload;
bool schedule_slsch = nr_schedule_slsch(&mac->sci1_pdu,&mac->sci2_pdu,tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload,NR_SL_SCI_FORMAT_2A,&slsch_pdu_length); bool schedule_slsch = nr_schedule_slsch(&mac->sci1_pdu,&mac->sci2_pdu,tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload,NR_SL_SCI_FORMAT_2A,&slsch_pdu_length_max);
if (!schedule_slsch) return false; if (!schedule_slsch) return false;
const uint8_t sh_size = sizeof(NR_MAC_SUBHEADER_LONG);
uint8_t *pdu = tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload;
*config_type = SL_NR_CONFIG_TYPE_TX_PSCCH_PSSCH; *config_type = SL_NR_CONFIG_TYPE_TX_PSCCH_PSSCH;
tx_config->number_pdus = 1; tx_config->number_pdus = 1;
tx_config->sfn = frame; tx_config->sfn = frame;
...@@ -3280,17 +3284,104 @@ bool nr_ue_sl_pssch_scheduler(NR_UE_MAC_INST_t *mac, ...@@ -3280,17 +3284,104 @@ bool nr_ue_sl_pssch_scheduler(NR_UE_MAC_INST_t *mac,
sl_res_pool, sl_res_pool,
&mac->sci1_pdu, &mac->sci1_pdu,
&mac->sci2_pdu, &mac->sci2_pdu,
slsch_pdu_length, slsch_pdu_length_max,
NR_SL_SCI_FORMAT_1A, NR_SL_SCI_FORMAT_1A,
NR_SL_SCI_FORMAT_2A); NR_SL_SCI_FORMAT_2A);
int buflen = tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.tb_size;
LOG_I(NR_MAC, "[UE%d] TTI-%d:%d TX PSCCH_PSSCH REQ \n", sl_ind->module_id,frame, slot); NR_UE_MAC_CE_INFO mac_ce_info;
NR_UE_MAC_CE_INFO *mac_ce_p=&mac_ce_info;
mac_ce_p->bsr_len = 0;
mac_ce_p->bsr_ce_len = 0;
mac_ce_p->bsr_header_len = 0;
mac_ce_p->phr_len = 0;
LOG_I(NR_MAC, "[UE%d] TTI-%d:%d TX PSCCH_PSSCH REQ TBS %d\n", sl_ind->module_id,frame, slot,buflen);
//nr_ue_get_sdu_mac_ce_pre updates all mac_ce related header field related to length
mac_ce_p->tot_mac_ce_len = nr_ue_get_sdu_mac_ce_pre(module_idP, CC_id, frameP, subframe, gNB_index, ulsch_buffer, buflen, mac_ce_p);
mac_ce_p->total_mac_pdu_header_len = mac_ce_p->tot_mac_ce_len;
ret_status = schedule_slsch; buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size);
return ret_status; LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] SL-DXCH -> SLSCH, RLC with LCID 0x%02x (TBS %d bytes, sdu_length_total %d bytes, MAC header len %d bytes, buflen_remain %d bytes)\n",
__FUNCTION__,
module_idP,
frameP,
subframe,
lcid,
buflen,
mac_ce_p->sdu_length_total,
mac_ce_p->tot_mac_ce_len,
buflen_remain);
while (buflen_remain > 0){
// Pointer used to build the MAC sub-PDU headers in the ULSCH buffer for each SDU
NR_MAC_SUBHEADER_LONG *header = (NR_MAC_SUBHEADER_LONG *) pdu;
pdu += sh_size;
sdu_length = mac_rlc_data_req(module_idP,
0,
0,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
lcid,
buflen_remain,
(char *)pdu,
0,
0);
AssertFatal(buflen_remain >= sdu_length, "In %s: LCID = 0x%02x RLC has segmented %d bytes but MAC has max %d remaining bytes\n",
__FUNCTION__,
lcid,
sdu_length,
buflen_remain);
if (sdu_length > 0) {
LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] SL-DXCH -> SLSCH, Generating SL MAC sub-PDU for SDU %d, length %d bytes, RB with LCID 0x%02x (buflen (TBS) %d bytes)\n",
__FUNCTION__,
module_idP,
frameP,
subframe,
num_sdus + 1,
sdu_length,
lcid,
buflen);
header->R = 0;
header->F = 1;
header->LCID = lcid;
header->L = htons(sdu_length);
#ifdef ENABLE_SLMAC_PAYLOAD_DEBUG
LOG_I(NR_MAC, "In %s: dumping MAC sub-header with length %d: \n", __FUNCTION__, sh_size);
log_dump(NR_MAC, header, sh_size, LOG_DUMP_CHAR, "\n");
LOG_I(NR_MAC, "In %s: dumping MAC SDU with length %d \n", __FUNCTION__, sdu_length);
log_dump(NR_MAC, pdu, sdu_length, LOG_DUMP_CHAR, "\n");
#endif
pdu += sdu_length;
mac_ce_p->sdu_length_total += sdu_length;
mac_ce_p->total_mac_pdu_header_len += sh_size;
num_sdus++;
} else {
pdu -= sh_size;
LOG_D(NR_MAC, "In %s: no data to transmit for RB with LCID 0x%02x\n", __FUNCTION__, lcid);
break;
}
buflen_remain = buflen - (mac_ce_p->total_mac_pdu_header_len + mac_ce_p->sdu_length_total + sh_size);
}
}
return true;
} }
void nr_ue_sl_pscch_rx_scheduler(nr_sidelink_indication_t *sl_ind, void nr_ue_sl_pscch_rx_scheduler(nr_sidelink_indication_t *sl_ind,
......
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