Commit b6e3718d authored by cig's avatar cig Committed by Thomas Schlichter

Changes to nr_write_ce_ulsch_pdu

- takes in input MAC instance
- uses a mac ce struct
- minor fixes
parent 07a80bc8
......@@ -311,6 +311,15 @@ typedef struct {
} RAR_grant_t;
typedef struct {
uint8_t phr_reporting;
uint16_t truncated_bsr;
uint16_t short_bsr;
uint16_t long_bsr;
} NR_UE_MAC_CE_t;
/*!\brief Top level UE MAC structure */
typedef struct {
......@@ -374,12 +383,8 @@ typedef struct {
nr_ue_if_module_t *if_module;
nr_phy_config_t phy_config;
/// BSR report flag management
uint8_t BSR_reporting_active;
NR_UE_SCHEDULING_INFO scheduling_info;
/// PHR
uint8_t PHR_reporting_active;
NR_UE_MAC_CE_t nr_ue_mac_ce;
NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config;
NR_SearchSpace_t *search_space_zero;
......@@ -390,16 +395,6 @@ typedef struct {
} NR_UE_MAC_INST_t;
typedef struct {
uint8_t power_headroom;
uint16_t crnti;
uint16_t truncated_bsr;
uint16_t short_bsr;
uint16_t long_bsr;
} NR_UE_MAC_CE_t;
typedef enum seach_space_mask_e {
type0_pdcch = 0x1,
type0a_pdcch = 0x2,
......
......@@ -156,8 +156,8 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
NR_UL_TIME_ALIGNMENT_t *ul_time_alignment,
int pdu_id);
int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
NR_UE_MAC_CE_t *nr_ue_mac_ce);
int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
NR_UE_MAC_INST_t *mac);
void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15);
......
......@@ -2141,22 +2141,22 @@ void nr_ue_process_mac_pdu(nr_downlink_indication_t *dl_info,
}
}
// about: generating MAC CEs (MAC CE and subheader) for the ULSCH PDU
// returns: number of written bytes
/**
* Function: generating MAC CEs (MAC CE and subheader) for the ULSCH PDU
* Notes: TODO: PHR and BSR reporting
* Parameters:
* @mac_ce pointer to the MAC sub-PDUs including the MAC CEs
* @nr_ue_mac_ce pointer to the MAC CEs to be transmitted
* @mac pointer to the MAC instance
* Return: number of written bytes
*/
int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
NR_UE_MAC_CE_t *nr_ue_mac_ce) {
int nr_write_ce_ulsch_pdu(uint8_t *mac_ce,
NR_UE_MAC_INST_t *mac) {
int mac_ce_len = 0;
uint8_t mac_ce_size = 0;
NR_UE_MAC_CE_t *nr_ue_mac_ce = &mac->nr_ue_mac_ce;
if (nr_ue_mac_ce->power_headroom) {
LOG_D(NR_MAC, "In %s: generating PHR MAC CE with command %d\n", __FUNCTION__, nr_ue_mac_ce->power_headroom);
if (nr_ue_mac_ce->phr_reporting && mac->phr_Config != NULL) {
// MAC CE fixed subheader
((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0;
......@@ -2164,9 +2164,9 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
mac_ce++;
// PHR MAC CE (1 octet)
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = nr_ue_mac_ce->power_headroom;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PH = 0;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R1 = 0;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = 0; // todo
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->PCMAX = 0;
((NR_SINGLE_ENTRY_PHR_MAC_CE *) mac_ce)->R2 = 0;
// update pointer and length
......@@ -2176,9 +2176,9 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
}
if (nr_ue_mac_ce->crnti) {
if (!get_softmodem_params()->sa && mac->ra.ra_state == WAIT_RAR) {
LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, nr_ue_mac_ce->crnti);
LOG_D(NR_MAC, "In %s: generating C-RNTI MAC CE with C-RNTI %x\n", __FUNCTION__, mac->crnti);
// MAC CE fixed subheader
((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0;
......@@ -2186,7 +2186,7 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
mac_ce++;
// C-RNTI MAC CE (2 octets)
*(uint16_t *) mac_ce = nr_ue_mac_ce->crnti;
*(uint16_t *) mac_ce = mac->crnti;
// update pointer and length
mac_ce_size = sizeof(uint16_t);
......@@ -2197,7 +2197,7 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
if (nr_ue_mac_ce->truncated_bsr) {
LOG_D(NR_MAC, "In %s: generating Truncated BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->truncated_bsr);
LOG_D(NR_MAC, "In %s: generating short truncated BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->truncated_bsr);
// MAC CE fixed subheader
((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0;
......@@ -2205,7 +2205,7 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
mac_ce++;
// Short truncated BSR MAC CE (1 octet)
((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> Buffer_size = nr_ue_mac_ce->truncated_bsr;
((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> Buffer_size = 0;
((NR_BSR_SHORT_TRUNCATED *) mac_ce)-> LcgID = 0;
// update pointer and length
......@@ -2215,7 +2215,7 @@ int nr_write_ce_ulsch_pdu(unsigned char *mac_ce,
} else if (nr_ue_mac_ce->short_bsr) {
LOG_D(NR_MAC, "In %s: generating Truncated short BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->short_bsr);
LOG_D(NR_MAC, "In %s: generating short BSR MAC CE with command %x\n", __FUNCTION__, nr_ue_mac_ce->short_bsr);
// MAC CE fixed subheader
((NR_MAC_SUBHEADER_FIXED *) mac_ce)->R = 0;
......
......@@ -1966,8 +1966,7 @@ uint8_t nr_ue_get_sdu(module_id_t module_idP,
// Preparing the MAC CEs sub-PDUs and get the total size
unsigned char mac_header_control_elements[16] = {0};
NR_UE_MAC_CE_t nr_ue_mac_ce = {.crnti = mac->crnti};
int tot_mac_ce_len = nr_write_ce_ulsch_pdu(&mac_header_control_elements[0], &nr_ue_mac_ce);
int tot_mac_ce_len = nr_write_ce_ulsch_pdu(&mac_header_control_elements[0], mac);
uint8_t total_mac_pdu_header_len = tot_mac_ce_len;
LOG_D(NR_MAC, "In %s: [UE %d] [%d.%d] process UL transport block at with size TBS = %d bytes \n", __FUNCTION__, module_idP, frameP, subframe, buflen);
......
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