+/*
+ * @brief Function to calculate Value Y
+ *
+ * Function: schCalY
+ *
+ * Calculates value of YpKp as per [10.1,TS38.213].
+ * A0 is for first CS, A1 for second CS and A2 is for third CS
+ *
+ * @params[in]: coresetId and Previous Y
+ * */
+uint32_t schCalY(uint8_t csId, uint32_t prevY)
+{
+ uint32_t A0 = 39827, A1 = 39829, A2 = 39839;
+ uint32_t D = 65537;
+
+ switch(csId % 3)
+ {
+ case 0:
+ {
+ return((A0 * prevY) % D);
+ }
+ case 1:
+ {
+ return((A1 * prevY) % D);
+ }
+ case 2:
+ {
+ return((A2 * prevY) % D);
+ }
+ default:
+ {
+ DU_LOG("\nERROR --> SCH: Issue in calculating value of Y");
+ return(0);
+ }
+ }
+ return 0;
+}
+
+/*
+ * @brief Function to calculate the value Y used for CCE Index formula
+ *
+ * Function: schUpdValY
+ *
+ * As per Spec 38.213, Sec 10.1 Formula for CCE Index contains a coefficient
+ * value called 'Y' and storing the same in the ueCb which will be later used
+ * in pdcch allocation
+ *
+ * @params[in] : SchUeCb, PdcchInfo
+ * [return] : uint8_t ROK, RFAILED : Memory allocation status
+ *
+ * */
+uint8_t schUpdValY(SchUeCb *ueCb, SchPdcchInfo *pdcchInfo)
+{
+ uint8_t slotIdx = 0;
+ if(pdcchInfo->y == NULLP)
+ {
+ SCH_ALLOC(pdcchInfo->y, (sizeof(uint32_t) * ueCb->cellCb->numSlots));
+ if(pdcchInfo->y == NULLP)
+ {
+ DU_LOG("\nERROR --> SCH: Memory Allocation of Y failed");
+ return RFAILED;
+ }
+ }
+
+ for(slotIdx= 0 ; slotIdx < ueCb->cellCb->numSlots; slotIdx++)
+ {
+ if(slotIdx == 0)
+ {
+ pdcchInfo->y[slotIdx] = schCalY(pdcchInfo->cRSetRef->cRSetId, ueCb->crnti);
+ }
+ else
+ {
+ pdcchInfo->y[slotIdx] = schCalY(pdcchInfo->cRSetRef->cRSetId, pdcchInfo->y[slotIdx - 1]);
+ }
+ }
+ return ROK;
+}
+
+/*
+ * @brief : Function to convert SlotPeriodicity to Value
+ *
+ * Function: schConvertSlotPeriodicityEnumToValue
+ *
+ * @param[IN]: SchMSlotPeriodicity enum
+ * [return]: slotOffsetVal
+ * */
+uint16_t schConvertSlotPeriodicityEnumToValue(SchMSlotPeriodicity slotPeriod)
+{
+ uint16_t slotPeriodVal = 0;
+
+ switch(slotPeriod)
+ {
+ case SLOT_PERIODICITY_SL_1:
+ {
+ slotPeriodVal = 1;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_2:
+ {
+ slotPeriodVal = 2;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_4:
+ {
+ slotPeriodVal = 4;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_5:
+ {
+ slotPeriodVal = 5;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_8:
+ {
+ slotPeriodVal = 8;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_10:
+ {
+ slotPeriodVal = 10;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_16:
+ {
+ slotPeriodVal = 16;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_20:
+ {
+ slotPeriodVal = 20;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_40:
+ {
+ slotPeriodVal = 40;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_80:
+ {
+ slotPeriodVal = 80;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_160:
+ {
+ slotPeriodVal = 160;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_320:
+ {
+ slotPeriodVal = 320;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_640:
+ {
+ slotPeriodVal = 640;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_1280:
+ {
+ slotPeriodVal = 1280;
+ break;
+ }
+ case SLOT_PERIODICITY_SL_2560:
+ {
+ slotPeriodVal = 2560;
+ break;
+ }
+ default:
+ {
+ slotPeriodVal = 0;
+ break;
+ }
+ }
+ return slotPeriodVal;
+}
+
+/*
+ * @brief: Function to extract the numCandidates from aggLevel.
+ *
+ * Function: extractNumOfCandForAggLvl
+ *
+ * @params[IN]: SearchSpace, aggLevel
+ * [RETURN]: numCandidates.
+ * */
+uint8_t extractNumOfCandForAggLvl(SchSearchSpace *searchSpace, uint8_t aggLvl)
+{
+ uint8_t numCand = 0;
+
+ switch(aggLvl)
+ {
+ case 1:
+ {
+ numCand = searchSpace->numCandidatesAggLevel1;
+ break;
+ }
+ case 2:
+ {
+ numCand = searchSpace->numCandidatesAggLevel2;
+ break;
+ }
+ case 4:
+ {
+ numCand = searchSpace->numCandidatesAggLevel4;
+ break;
+ }
+ case 8:
+ {
+ numCand = searchSpace->numCandidatesAggLevel8;
+ break;
+ }
+ case 16:
+ {
+ numCand = searchSpace->numCandidatesAggLevel16;
+ break;
+ }
+ default:
+ {
+ numCand = 0;
+ }
+ /*AGGREGATION_LEVEL_N8 enum Value is 7 thus hardcoding the correct Value
+ * (8)*/
+ if(numCand == AGGREGATION_LEVEL_N8)
+ {
+ numCand = 8;
+ }
+ }
+ return numCand;
+}